Like this code?
Show the author your appreciation.
It can present a form in an administration page protected with a password to let the administrator set several options about common site content sections that it supports.
The class can generate PHP file with definitions that set configuration options according to the options the user set in the form.
The main application script includes the class and the generated options to determine how to present the site based on the option values.
Currently the class can present site pages with automatic headers, footers, a menu bar with links to an about section, news section, and a contact form, and products & services section.
The page presentation is configurable with CSS styles.
Installation notes:
1.- Put all files in root folder of your domain
2.- click in admin link in the footer
3.- initial password is 123
4.- Place all data in each secction
5.- Enjoy!
index.php
<?php
require_once( "autocms.php" );
if(isset( $_POST [ 'submit' ]))
{
$newemailcontact = new autocms ();
$newemailcontact -> engineemailcontact ( $_POST [ Email ], $_POST [ Msg ]);
}
if(isset( $_POST [ 'update' ]))
{
$newsavefile = new autocms ();
$newsavefile -> enginesavefile ();
}
if(isset( $_GET [ 'login' ]))
{
$newlogin = new autocms ();
$newlogin -> enginelogin ();
}
if(isset( $_POST [ 'password' ]))
{
$newpassword = new autocms ();
$newpassword -> enginepassword ();
}
$web =new autocms ();
$web -> show_web ();
?>
autocms.php
<?php /*AutoCMS v1.3,Roberto Aleman, BSD license*/
require_once( "vars.php" );class autocms {
function enginetopsiteheader ()
{
echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/><title>" . sitetitle . "</title><link href='" . cssfile . "' rel='stylesheet' type='text/css'/></head><body><a name='top' id='top'></a><div class='main'><div class='header'><div class='sitename'><a href='" . site_url . "' target='_self'>" . site_name . "</a></div><div class='sitedescription'>" . sitetitle . "</div></div>" ;
return;
}
function enginemenubar ()
{
echo "<div class='menubar'><a href='" . site_url . "' target='_self'>" . index_name_link . "</a> - <a href='#about' target='_self'>" . about_name_link . "</a> - <a href='#ps' target='_self'>" . ps_name_link . "</a> - <a href='#news' target='_self'>" . news_name_link . "</a> - <a href='#contact' target='_self'>" . contact_name_link . "</a></div>" ;
return;
}
function engineuptotop ()
{
echo "<div class='uptotop'><a href='#top' target='_self'>^</a></div>" ;
return;
}
function engineabout ()
{
echo "<div class='about'><a name='about' id='about'></a><h2>" . about_name_link . " " . site_name . "</h2>" . stripslashes ( about_content ). "</div>" ;
return;
}
function enginepys ()
{
echo "<div class='pys'><a name='ps' id='ps'></a><h2>" . ps_name_link . "</h2>" . stripslashes ( ps_content ). "</div>" ;
return;
}
function enginenews ()
{
$i = 0 ; $news = explode ( "/" , news_content );
echo "<div class='news'><a name='news' id='news'></a><h2>" . news_name_link . "</h2>" ;
do {
$news_split = explode ( ":" , $news [ $i ]);
echo "<p><b>" . stripslashes ( $news_split [ 0 ]). "</b> : " . stripslashes ( $news_split [ 1 ]). "</p>" ;
$i = $i + 1 ;
}while( $news [ $i ]!= null );
echo "</div>" ;
return;
}
function enginecontactform ()
{
echo "<div class='contact'><a name='contact' id='contact'></a><h2>" . contact_name_link . "</h2><form action='index.php' method='post' >
<p>Your Email:<br/><input name='Email' type='text' size='50' maxlength='100' /></p><p>Your Message:<br/><textarea name='Msg' cols='30' rows='2'></textarea></p>
<input name='submit' type='submit' /></form></div>" ;
return;
}
function enginefooter ()
{
echo "<div class='footer'>Auto CMS,Author:<a href='http://www.ventics.com' target='_self'>Roberto Aleman</a>,<a href='" . site_url . "?login=admin'>admin</a>,<a href='http://validator.w3.org/check?uri=referer'>Valid XHTML 1.0</a>,<a href='http://jigsaw.w3.org/css-validator/check/referer'>CSS 2.1 Valid</a></div></div></body></html>" ;return;
}
function engineemailcontact ( $EMAIL , $Msg ){if( $Msg != NULL )
{
$email = trim ( strtolower ( $EMAIL ));
if ( strlen ( $email ) <= 320 AND strlen ( $email )> 0 )
{
$model = '/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])' . '(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i' ;
if ( preg_match ( $model , $email ) == TRUE )
{
list( $user , $domain ) = explode ( "@" , $email );
$id = @ fopen ( "http://" . $domain , "r" );
if ( $id == true )
{
echo "<div class='email_good'>Thanks for your contact!</div>" ;
$mailheader = 'MIME-Version:1.0' . "\r\n" ;
$mailheader .= 'Content-type:text/html; charset=UTF-8' . "\r\n" ;
$mailheader .= "From:" . $email . "\r\n" ;
$Mssg = "New Email from your site,of:<b>" . $email . "</b><br/>" . $Msg ;
mail ( admin_email , "Contact from " . site_name , $Mssg , $mailheader );
$mailheader2 = 'MIME-Version:1.0' . "\r\n" ;
$mailheader2 .= 'Content-type:text/html; charset=UTF-8' . "\r\n" ;
$mailheader2 .= "From:" . admin_email . "\r\n" ;
$msg_to_client = "Thanks for your Contact!" . site_name ;
mail ( $email , "Contact from " . site_name , $msg_to_client , $mailheader2 );
return;
fclose ( $id );
}
else
{
echo "<div class='email_error' >Sorry,Not valid Host</div>" ;
}
}
else
{
echo "<div class='email_error' >Sorry,bad characters</div>" ;
}
}
else
{
if ( strlen ( $lower ) == NULL )
{
echo "<div class='email_error' >Sorry,Your entry is null</div>" ;
}
else
{
echo "<div class='email_error' >Sorry,Entry too much long:" . $email . "</div>" ;
}
}
}
else
{
echo "<div class='email_error' >Sorry,message is Empty</div>" ;
}
}
function enginupdateform ()
{
echo "<link href='default.css'rel='stylesheet'type='text/css'/><div class='update_form'><h2>Auto CMS,Control Panel</h2><form action='index.php'method='post'enctype='multipart/form-data'>" ;
echo "<p>Site Name:<input type='text'name='site_name' id='site_name' size='100'value='" . site_name . "'></p>" ;
echo "<p>Site URL(ej:http://www.domain.com/):<input type='text' name='site_url' id='site_url'size='100'value='" . site_url . "'></p>" ;
echo "<p>Site Title:<input type='text'name='sitetitle' id='sitetitle' size='100'value='" . sitetitle . "'></p>" ;
echo "<p>Admin Email:<input type='text'name='admin_email'id='admin_email'size='100'value='" . admin_email . "'></p>" ;
echo "<p>Admin Password:<input type='password'name='admin_password'id='admin_password'size='100' value=''></p>" ;echo "Select CSS Theme:" ;
$path = getcwd ();
$directorio = dir ( $path );
echo "<select name='css_file'>" ;
while ( $archivo = $directorio -> read ())
{
$cssext = explode ( "." , $archivo );
if ( $cssext [ 1 ] == "css" )
{
echo "<option value='$archivo'>$archivo</option>" ;
}
else
{
$cssfile = "default.css" ;
}
};
echo "</select>" ;
$directorio -> close ();
echo "<p>Index Link Name:<input type='text'name='index_name_link'id='index_name_link'size='100'value='" . index_name_link . "'></p>" ;
echo "<p>About Link Name:<input type='text'name='about_name_link'id='about_name_link'size='100'value='" . about_name_link . "'></p>" ;
echo "<p>About Content:<textarea name='about_content'cols='70'rows='20'id='about_content'>" . stripslashes ( about_content ). "</textarea></p>" ;
echo "<p>Products and Services Link Name:<input type='text'name='ps_name_link'id='ps_name_link'size='100'value='" . ps_name_link . "'></p>" ;
echo "<p>Products and Services:<textarea name='ps_content'cols='70'rows='20'id='os_content'>" . stripslashes ( ps_content ). "</textarea></p>" ;
echo "<p>News Link Name:<input type='text'name='news_name_link'id='news_name_link'size='100'value='" . news_name_link . "'></p>" ;
echo "<div class='messages'>Format to News Content:Title n:Text Content n/</div><p>News Content:<textarea name='news_content'cols='70'rows='20'id='news_content'>" . stripslashes ( news_content ). "</textarea></p>" ;
echo "<p>Contact Link Name:<input type='text'name='contact_name_link'id='contact_name_link'size='100'maxlength='100'value='" . contact_name_link . "'></p>" ;
echo "<p><input type='submit'name='update'id='update'value='update'></p>" ;
echo "</form></div>" ;
return;
}
function enginelogin ()
{
echo "<link href='default.css' rel='stylesheet' type='text/css'/><p align='center'><form action='index.php' method='post' class='password' ><p>Password:<input type='password' name='password' id='password' /></p></form></p>" ;
return;
}
function enginepassword ()
{
if( md5 ( $_POST [ 'password' ]) == admin_password )
{
$newupdate = new autocms ();
echo $newupdate -> enginupdateform ();
return;
}
else
{
echo "<script type='text/javascript'>alert('Password Invalid')</script><meta http-equiv='refresh' content='0;URL=index.php' />" ;
}
}
function enginesavefile ()
{
if( $_POST [ 'admin_password' ] != NULL )
{
$password = md5 ( $_POST [ 'admin_password' ]);
}
else
{
$password = admin_password ;
}
$content = "<?php define('site_name','" . $_POST [ 'site_name' ]. "');define('site_url','" . $_POST [ 'site_url' ]. "');define('sitetitle','" . $_POST [ 'sitetitle' ]. "');define('admin_email','" . $_POST [ 'admin_email' ]. "');define('admin_password','" . $password . "');define('index_name_link', '" . $_POST [ 'index_name_link' ]. "');define('about_name_link','" . $_POST [ 'about_name_link' ]. "');define('about_content','" . $_POST [ 'about_content' ]. "');define('ps_name_link','" . $_POST [ 'ps_name_link' ]. "');define('ps_content','" . $_POST [ 'ps_content' ]. "');define('news_name_link','" . $_POST [ 'news_name_link' ]. "');define('news_content','" . $_POST [ 'news_content' ]. "');define('contact_name_link','" . $_POST [ 'contact_name_link' ]. "');define('cssfile','" . $_POST [ 'css_file' ]. "'); ?>" ;
unlink ( 'vars.php' );
$indicator = fopen ( "vars.php" , "w+" );
if ( $indicator )
{
fwrite ( $indicator , $content );
chmod ( "vars.php" , 0600 );
fclose ( $indicator );
}
header ( "Location:index.php" );
return;
}
function show_web ()
{
$this -> enginetopsiteheader ();
$this -> enginemenubar ();
$this -> enginenews ();
$this -> engineuptotop ();
$this -> enginepys ();
$this -> engineuptotop ();
$this -> engineabout ();
$this -> engineuptotop ();
$this -> enginecontactform ( $EMAIL , $Msg );
$this -> engineuptotop ();
$this -> enginemenubar ();
$this -> enginefooter ();
}
} ?>
vars.php
<?php
define ( 'site_name' , 'AutoCMS by Roberto Aleman' );
define ( 'site_url' , 'index.php' );
define ( 'sitetitle' , 'AutoCMS by Roberto Aleman' );
define ( 'admin_email' , 'you@gmail.com' );
define ( 'admin_password' , '202cb962ac59075b964b07152d234b70' );
define ( 'index_name_link' , 'Index' );
define ( 'about_name_link' , 'About' );
define ( 'about_content' , 'put about text here' );
define ( 'ps_name_link' , 'Producs and Services' );
define ( 'ps_content' , 'put producs and services text here' );
define ( 'news_name_link' , 'News' );
define ( 'news_content' , 'Title Example1: Text Example1/Title Example2: Text Example2/' );
define ( 'contact_name_link' , 'Contact' );
?>
default.css
@charset "utf-8";
/* AutoCMS v1.0 by Roberto Aleman,
GNU GENERAL PUBLIC LICENSE
- less than 10kb in the main file,with initial values
- No database required,
- Only one user (Admin),
- password is protected with md5,
- css styles easy for built and to change
- very very fast for charge of page
- all the minimum it needs a person or company to have presence on Internet
- XHTML and CSS Valid by W3C!
*/
/*Links*/
a:link
{
color:#000000;
text-decoration:none;
}
a:hover
{
color:#ffffff;
text-decoration:none;
background:#999999;
}
a:visited
{
text-decoration:none;
color:#000000;
}
a:active
{
color:#000000;
text-decoration:none;
}
/*Front End*/
.sitename
{
font-size:40px;
}
.sitedescription
{
font-size:15px;
color:#000;
}
body
{
background:#f3f3f3;
margin-top:0px;
width:90%;
}
.main
{
padding:5px;
background:#D6D6D6;
border:#C1C1C1 1px solid;
width:50%;
font-family:Geneva, Arial, Helvetica, sans-serif;
position:absolute; left:25%;
}
.header
{
height:50%;
border:solid;
border:#C1C1C1 1px solid;
background-color:#ffffff;
padding:10px;
overflow:visible;
width:auto;
}
.news
{
border:ridge;
background:#ffffff;
border:#C1C1C1 1px solid;
padding:10px;
text-align:justify;
overflow:auto;
width:auto;
}
.about h2
{
float:left;
margin:5px;
padding:10px;
background:#f3f3f3;
border:#CCCCCC 1px solid;
}
.news h2
{
float:left;
margin:5px;
padding:10px;
background:#f3f3f3;
border:#CCCCCC 1px solid;
}
.pys h2
{
float:left;
margin:5px;
padding:10px;
background:#f3f3f3;
border:#CCCCCC 1px solid;
}
.contact h2
{
float:right;
margin:5px;
padding:10px;
background:#f3f3f3;
border:#CCCCCC 1px solid;
}
.menubar
{
border:solid;
border:#C1C1C1 1px solid;
background:#f3f3f3;
padding:5px;
width:auto;
}
.about
{
border:ridge;
background:#ffffff;
border:#C1C1C1 1px solid;
padding:10px;
text-align:justify;
overflow:auto;
width:auto;
}
.pys
{
border:ridge;
background:#ffffff;
border:#C1C1C1 1px solid;
padding:10px;
text-align:justify;
overflow:auto;
width:auto;
}
.contact
{
border:ridge;
background:#ffffff;
border:#C1C1C1 1px solid;
padding:10px;
text-align:justify;
overflow:auto;
width:auto;
}
.footer
{
border:ridge;
background:#ffffff;
border:#C1C1C1 1px solid;
font-size:10px;
padding:5px;
text-align:justify;
width:auto;
}
.uptotop
{
font-size:20px;
text-align:right;
height:15px;
}
.uptotop a:hover
{
font-size:20px;
color:#000000;
background:#FEF2C2;
text-align:right;
height:15px;
border:#cccccc 1px solid;
}
/*Back End*/
.messages
{
text-decoration:blink;
background:#ffffff;
font-size:10px;
}
.update_form
{
font-family:Geneva, Arial, Helvetica, sans-serif;
margin-top:0px;
background:#cccccc;
margin:5px;
border:#FFFFFF solid 3px;
padding:10px;
width:50%;
margin-left:27%;
}
.email_error
{
font-family:Geneva, Arial, Helvetica, sans-serif;
text-align:center;
color:#000000;
background:#FEF5DA;
font-size:20px;
border:#999999 solid 1px;
padding:5px;
text-align:center;
}
.email_good
{
font-family:Geneva, Arial, Helvetica, sans-serif;
text-align:center;
color:#000000;
background:#CCFFCC;
font-size:20px;
border:#999999 solid 1px;
padding:5px;text-align:center;
}
.password
{
font-family:Geneva, Arial, Helvetica, sans-serif;
text-align:center;
color:#000000;
background:#FEF5DA;
font-size:20px;
border:#999999 solid 1px;
padding:5px;
}
Database and Recordset classes fo SyBASE Usage is obvious. Categories : Sybase , Databases , PHP Classes , PHP The Ajax Tree view class fetches data from a db for the requested parent category id. The data is then stored in an array and converted into JSON (Javascript Object Notation) format. This format is then used by JavaScript for populating tree view. Categories : PHP , PHP Classes , Java Script , AJAX , Databases A complete Webmaster Content Managment Tool, with differing levels of
access. Allowing the dynamic additon and showing of: Links, Multiple
Articles and News.
Categories : PHP , MySQL , Content Management Advanced Image WaterMarker Categories : PHP , PHP Classes , GD image library , Graphics , Object Oriented Gonx URLs - This class is meant to generate URLs for accessing application dynamically generated pages based on parameters passed in the URL.
Categories : PHP , PHP Classes , Navigation , URLs SPL and ITERATOR : examples Categories : PHP , Object Oriented , PHP Classes , Sessions TAB_STRUCT Class: Is supporting Class for the DBXML Class Categories : PHP , PHP Classes , MySQL , XML , Databases Flexphpsite - a Content Management System (CMS) in PHP and MySQL Categories : Content Management , Complete Programs , Databases , Multimedia , PHP Menu in sliding bar or tree style. Handles frames by using small amount of javascript. Handles external and internal pages. Allows custom code to replace a menu item. Categories : PHP Classes , PHP , Java Script , DHTML pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP , Date Time , Calendar , PHP Classes XPertMailer - Sends TRUE Mails Categories : PHP , Mail , SMTP , PHP Classes PHP VXML Class : How to use PHP in VoiceXML applications Categories : PHP , PHP Classes , VXML Objects to XML Serializer/Unserializer Categories : PHP , PHP Classes , DOM XML , Serialize DbObject - A PHP wrapper for working with various databases Categories : Databases , PHP , PHP Classes Url To Pdf Report By Remote Application Categories : PHP , PHP Classes , PDF , CURL