EasyPHPScripts.com      Free Open Source PHP Scripts and Code Snippet Library

 +Menu
+   Site News
+   Main Pages
+   Other Downloads
 +PHP
+ Arrays (9)
+ Directory And Files (7)
+ Image (3)
+ LDAP (3)
+ MySQL (11)
+ Other (11)
+ Regular Expressions (3)
+ String Manipulation (13)
+ Time and Date (6)
 +Library Options
+   View Other Library
 +General Options
+   Log in

Main Pages

Downlaods -|- Contact
Home
EasyPHPNews
EasyPHPTabs
EasyPHPTemplate
EasyPHPEdit
Flat file CMS
EasyPHPCashe
EasyPHPNews Discussions
Fix Vista PHP CLI Errors
Contact

Flat-file Site CMS
this is a small demo of a dynamic web site builder. if you are learning php, try it, change it, do as you wish with it.
is a basic dynamic content web site builder using flat files.
i am not putting a lot of time into this project.(Some laity due to it is being used here) if you are seeking a one with more functions, their are many on-line free ones. a little php dynamic web page CMS.

these pages are running from this. (Rewritten April, 25 2009)
Made links an array with Category's. (Files was P.I.T.A.)
Added on line Editor and highlight code.
can be amazing what can be done with a couple functions.
These pages and i built http://www.beckswelding.com also with it, and a gallery script i wrote. i may add to here at some point. just upload pictures, it makes the thumb nails and displays them.
The site graphics i did with adobe photo shop.

If you want to edit pages online. can use this EasyPHPEdit
Code

<?php 
//fix for old site page names.
if($_GET['main_page'])
    
$_GET['Page'] = $_GET['main_page'];

//advatage of this page loader is you dont have to edit themed pages, just the content.
//is not login, no DB, edit, upload via FTP, all done
// no trailing slash , best below http server root.
define('CONTENT_DIR','./static/content'); 
define('DEFAULT_PAGE','Home'); 
define('EDIT_PASSWORD','demo'); 

//added for highlight_file
//?Page=Name_in_conetent_dir = code.Name_in_conetent_dir.txt
//adds to bottom page after page display, content page must exist.


//when calling the get_links('header',' -|- ') function.
//when calling the get_links('left','<br>') function.
//?Page=Name_in_conetent_dir = content.Name_in_conetent_dir.txt
//can also get_links('left','<br>',' |-- ') for sub links
//'display_name'=>'URL'
$LINKS['left'] = array(
'Home'=>'?Page=Home',
'EasyPHPNews'=>'?Page=EasyPHPNews',
'EasyPHPTabs'=>'?Page=EasyPHPTabs',
'EasyPHPTemplate'=>'?Page=EasyPHPTemplate',
'EasyPHPEdit'=>'?Page=EasyPHPEdit',
'Flat_file CMS'=>'?Page=Flat_file_Site',
'EasyPHPCashe'=>'?Page=EasyPHPCashe',
'EasyPHPNews_Discussions'=>'?Page=EasyPHPNews_Discussions'
);
//sub cat of page $LINKS['page_name'], and other links and bottom the page.
//has to be the same name...spaces not prefered, use underscore will change them to a space when displayed.
$LINKS['EasyPHPNews'] = array('EasyPHPNews_Discussions'=>'?Page=EasyPHPNews_Discussions');

$LINKS['header'] = array('Downlaods'=>'http://www.easyphpscripts.com/downloads');
//$LINKS['footer'] = array();


function get_links($links,$EL='',$SUB_beg='',$SUB_end=''){
  global 
$LINKS;
  if(
is_array($LINKS[''.$links.'']))
  foreach (
$LINKS[''.$links.''] as $pagename => $URL){
      if(isset(
$_GET['Edit']) && eregi('Page=',$URL)) $Edit '&Edit';
      
$link_list1 .= '<a href="'.$URL.$Edit.'">'.str_replace('_',' ',$pagename).'</a>'.$EL;
      if(
is_array($LINKS[''.$pagename.'']))
      foreach (
$LINKS[''.$pagename.''] as $subname => $subURL){
      
//echo ' in array=('.$_GET['Page'].','.$pagename.') = '.in_array($_GET['Page'],array_keys($LINKS[''.$pagename.'']));
      
if($_GET['Page'] == $pagename || in_array($_GET['Page'],array_keys($LINKS[''.$pagename.''])))
        
$sub_list .= $SUB_beg.'<a href="'.$subURL.'">'.str_replace('_',' ',$subname).'</a>'.$SUB_end.$EL;
      }
      
$link_list .= $link_list1.$sub_list;
      unset(
$link_list1); unset($sub_list);
  }
  
//return the link list and remove last ocurance of the end line.
  
return(rtrim($link_list,$EL));
}

function 
save_content($content){
  
//clean out everything exept alhpa,numeric,underscore and space.
  // many reasons for this, security is most important.
  
$contenteregi_replace("[^A-Z,0-9_ ]"''urldecode($content));
  if(
eregi_replace("[^A-Z,0-9_ ]"''$_POST['password']) == eregi_replace("[^A-Z,0-9_ ]"''EDIT_PASSWORD)){
    if(
$_POST['post_content'] && $_POST['page_content']){
      
file_put_contents(CONTENT_DIR.'/content.'.$content.'.txt',stripslashes($_POST['page_content']));
    }
    elseif(
$_POST['code_content'] && $_POST['post_code']){
      
file_put_contents(CONTENT_DIR.'/code.'.$content.'.txt',stripslashes($_POST['code_content']));
    }
    
    
  }
}

if(isset(
$_GET['Edit']) && $_POSTsave_content($_GET['Page']);

function 
edit_content($content){
  
//clean out everything exept alhpa,numeric,underscore and space.
  // many reasons for this, security is most important.
  
$contenteregi_replace("[^A-Z,0-9_ ]"''urldecode($content));
  echo 
'<table align="center" width="100%" height="100%" border="1">';
  if(
is_file(CONTENT_DIR.'/code.'.$content.'.txt'))
    echo 
'<tr><td colspan="2" align="center">Do NOT Edit both at the same time, one or the other.</td></tr>';
  echo 
'<tr><form method="post"><td colspan="2" align="center">';
  echo 
'Content<br><textarea name="page_content" rows="50" cols="120">'.htmlentities(@file_get_contents(CONTENT_DIR.'/content.'.$content.'.txt')).'</textarea>
  <br>Password:<input type="password" name="password"> <input type="submit" name="post_content" value="Update Content"></td></form></tr>'
;
  if(
is_file(CONTENT_DIR.'/code.'.$content.'.txt'))
    echo 
'<tr><form method="post"><td colspan="2" align="center">Code<br><textarea name="code_content" rows="80" cols="120">'.htmlentities(@file_get_contents(CONTENT_DIR.'/code.'.$content.'.txt')).'</textarea><br>Password:<input type="password" name="password"> <input type="submit" name="post_code" value="Update Code"></td></form></tr>';
  echo 
'</table>';
}

function 
get_content($content){
  
//clean out everything exept alhpa,numeric,underscore and space.
  // many reasons for this, security is most important.
  
$contenteregi_replace("[^A-Z,0-9_ ]"''urldecode($content));
  
// we have 2 places to add extra stuff, tables, theme
  //here and the 2 functions
  //usually i add a border in table untill debug is completed.
  
echo '<table align="center" width="100%" height="100%" border="0">';
  
// colspan=2 for a left colm
  
echo '<tr><td colspan="2" align="center" height="22"><h2>Main Pages</h2></td></tr>';
  
$header get_links('header',' -|- ');
  if(
$header)
    echo 
'<tr><td colspan=2 align="right" height="22">'.$header.'</td></tr>';
  
//no end table row till after content,but start a table data
  
$left get_links('left','<br>',' |-- ','<br>');
  if(
$left)
    echo 
'<tr><td align="left" width="20%" valign="top"><blockquote>'.$left.'</blockquote></td>';
  
  echo 
'<td align="left" valign="top">';

  
//content pages will run php, they are included.
  //if the file is not found, using custom page name display an error.
  
if(is_file(CONTENT_DIR.'/content.'.$content.'.txt')){
    include 
CONTENT_DIR.'/content.'.$content.'.txt';
  } else  echo 
'<h2>404 Content Not found</h2>';
  
//added for EasyPHPScripts.com site to display code
  
if(is_file(CONTENT_DIR.'/code.'.$content.'.txt')){
    echo 
'<b>Code</b><blockquote><textarea>'.htmlentities(file_get_contents(CONTENT_DIR.'/code.'.$content.'.txt')).'</textarea></blockquote><hr>';
    
highlight_file(CONTENT_DIR.'/code.'.$content.'.txt');
    echo 
'<hr>';
  }  
  
//can even load links based on the page name.$content
  //just add the dir under the links dir same name as the page, put link files their.
  
if($other_links get_links($content,' -|- '))
    echo 
'<br> Other Links '.$other_links.'<br>';
  echo 
'</td></tr>';
  if(isset(
$_GET['Edit']))
    
edit_content($content);
  
  
//add footer or theme end here
  
$footer get_links('footer',' -|- ');
  if(
$footer)
    echo 
'<tr><td align="center" colspan=2 height="22">'.$footer.'</td></tr>';
  echo 
'<tr><td colspan=2 align="center" height="22"><a href="index.php?cat_select=Other&show=Dynamic_Content">Powered By PHP</s></td></tr>';
  
  echo 
'</table>';
}


//page to display by default. or get the page asked for.
//using $_GET['Page'] URL would be ?Page=page name
if(!$_GET['Page']){
  
get_content(DEFAULT_PAGE);
} else {
  
get_content($_GET['Page']);
}

?>

Downlaods
Powered By PHP
 
Powered by: PHP & centOS