Code: Select all
<?php
function getSlug( $page ) {
$page = strip_tags( $page );
preg_match_all( "/([a-z0-9A-Z-_]+)/", $page, $matches );
$matches = array_map( "ucfirst", $matches[0] );
$slug = implode( "-", $matches );
return $slug;
}
$page = $_REQUEST['page'];
if(!$page) $page = "Home";
$contentfile = $page = getSlug( $page );
$content[0] = @file_get_contents("files/$contentfile.txt");
$content[1] = @file_get_contents("files/$contentfile-right.txt");
$content[2] = @file_get_contents("files/$contentfile-left.txt");
$content[3] = @file_get_contents("files/$contentfile-top.txt");
$content[4] = @file_get_contents("files/$contentfile-bottom.txt");
if(!$content[0]) $content[0] = "Your page named <b>$page</b> is created.<br /><br />\n\nClick here to start editing your newly created page!";
if(!$content[1]) $content[1] = "Your section is created.<br /><br />\n\nClick here to start editing your newly created section!";
if(!$content[2]) $content[2] = "Your section is created.<br /><br />\n\nClick here to start editing your newly created section!";
if(!$content[3]) $content[3] = "Your section is created.<br /><br />\n\nClick here to start editing your newly created section!";
if(!$content[4]) $content[4] = "Your section is created.<br /><br />\n\nClick here to start editing your newly created section!";
function getSectionA( $sectA ) {
$sectA = strip_tags( $sectA );
preg_match_all( "/([a-z0-9A-Z-_]+)/", $sectA, $matches );
$matches = array_map( "ucfirst", $matches[0] );
$sectionA = implode( "-", $matches );
return $sectionA;
}
$sectA = $_REQUEST['sectA'];
if(!$sectA) $sectA = "A";
$sectionAfile = $sectA = getSectionA( $sectA );
$content[$sectA] = @file_get_contents("files/$sectionAfile.txt");
if(!$content[$sectA]) $content[$sectA] = "Your section <b>$sectA</b> is created.<br /><br />\n\nClick here to start editing your newly created section's content!";
function getSectionB( $sectB ) {
$sectB = strip_tags( $sectB );
preg_match_all( "/([a-z0-9A-Z-_]+)/", $sectB, $matches );
$matches = array_map( "ucfirst", $matches[0] );
$sectionB = implode( "-", $matches );
return $sectionB;
}
$sectB = $_REQUEST['sectB'];
if(!$sectB) $sectB = "B";
$sectionBfile = $sectB = getSectionB( $sectB );
$content[$sectB] = @file_get_contents("files/$sectionBfile.txt");
if(!$content[$sectB]) $content[$sectB] = "Your section <b>$sectB</b> is created.<br /><br />\n\nClick here to start editing your newly created section's content!";
function getSectionC( $sectC ) {
$sectC = strip_tags( $sectC );
preg_match_all( "/([a-z0-9A-Z-_]+)/", $sectC, $matches );
$matches = array_map( "ucfirst", $matches[0] );
$sectionC = implode( "-", $matches );
return $sectionC;
}
$sectC = $_REQUEST['sectC'];
if(!$sectC) $sectC = "C";
$sectionCfile = $sectC = getSectionC( $sectC );
$content[$sectC] = @file_get_contents("files/$sectionCfile.txt");
if(!$content[$sectC]) $content[$sectC] = "Your section <b>$sectC</b> is created.<br /><br />\n\nClick here to start editing your newly created section's content!";
function getSectionD( $sectD ) {
$sectD = strip_tags( $sectD );
preg_match_all( "/([a-z0-9A-Z-_]+)/", $sectD, $matches );
$matches = array_map( "ucfirst", $matches[0] );
$sectionD = implode( "-", $matches );
return $sectionD;
}
$sectD = $_REQUEST['sectD'];
if(!$sectD) $sectD = "D";
$sectionDfile = $sectD = getSectionD( $sectD );
$content[$sectD] = @file_get_contents("files/$sectionDfile.txt");
if(!$content[$sectD]) $content[$sectD] = "Your section <b>$sectD</b> is created.<br /><br />\n\nClick here to start editing your newly created section's content!";
$title = @file_get_contents('files/title.txt');
if(!$title) $title = "Your title here";
$slogan = @file_get_contents('files/slogan.txt');
if(!$slogan) $slogan = "- Your slogan over here!";
$menu = @file_get_contents('files/menu.txt');
if(!$menu) $menu = "Home";
$description = @file_get_contents('files/description.txt');
if(!$description) $description = "Enter your website description over here!";
$keywords = @file_get_contents('files/keywords.txt');
if(!$keywords) $keywords = "Enter, your, keywords, for, your, website, over, here";
$copyright = @file_get_contents('files/copyright.txt');
if(!$copyright) $copyright = "Your website (c) 2013";
$mess = 'Powered by <a href="http://iqcms.com/">IQ CMS</a> | Web Design by <a href="http://iqcms.com/owd/">Otismo</a>';
//config section
$hostname = $_SERVER['PHP_SELF'];
$hostname = str_replace('index.php', '', $hostname);
$hostname = str_replace($page, '', $hostname);
$theme = $_REQUEST['theme'];
if( !file_exists("$theme.php") ) $theme = "default";
$cookie = 'iqcms'; // cookie name
$expirytime = time()+86400; // expire time
if(isset($_REQUEST['logout']))
{
setcookie($cookie,'',time() - 84000); // remove cookie/
header('Location: ./');
exit;
}
$password = @file_get_contents("files/password");
if(!$password)
{
savePassword("admin");
}
if($_COOKIE[$cookie])
{
$lstatus = "<a href='$hostname?logout'>Logout</a>";
}
else $lstatus = "<a href='$hostname?login'>Login</a>";
if(isset($_REQUEST['login']))
{
getLoginForm();
}
require("$theme.php");
// Functions
function editTags()
{
global $cookie;
if(!$_COOKIE[$cookie]) return;
echo "<script type='text/javascript' src='./js/editInplace.js'></script>";
}
function displayMainContent()
{
global $cookie, $content, $page;
if($_COOKIE[$cookie])
{
echo "<div class='title'><div id='change'><span id='$page' class='editText'>$content[0]</span></div></div>";
}
else
{
echo $content[0];
}
}
// display section content
function displaySectionContents($cnum, $slug)
{
global $cookie, $content, $contentfile;
if($_COOKIE[$cookie])
{
echo "<div id='change'><span id='$contentfile-$slug' class='editText' style='display:block'>$content[$cnum]</span></div>";
}
else echo $content[$cnum];
}
// display section content A
function displaySectionAcontent($sectA)
{
global $cookie, $content, $sectA;
if($_COOKIE[$cookie])
{
echo "<div class='title'><div id='change'><span id='$sectA' class='editText'>$content[$sectA]</span></div></div>";
}
else echo $content[$sectA];
}
// display section content B
function displaySectionBcontent($sectB)
{
global $cookie, $content, $sectB;
if($_COOKIE[$cookie])
{
echo "<div class='title'><div id='change'><span id='$sectB' class='editText'>$content[$sectB]</span></div></div>";
}
else echo $content[$sectB];
}
// display section content C
function displaySectionCcontent($sectC)
{
global $cookie, $content, $sectC;
if($_COOKIE[$cookie])
{
echo "<div class='title'><div id='change'><span id='$sectC' class='editText'>$content[$sectC]</span></div></div>";
}
else echo $content[$sectC];
}
// display section content D
function displaySectionDcontent($sectD)
{
global $cookie, $content, $sectD;
if($_COOKIE[$cookie])
{
echo "<div class='title'><div id='change'><span id='$sectD' class='editText'>$content[$sectD]</span></div></div>";
}
else echo $content[$sectD];
}
function displayMenu($stags,$etags)
{
global $menu;
$mlist = explode("<br />",$menu);
$num = count($mlist);
for($ix=0;$ix<$num;$ix++)
{
$page = trim($mlist[$ix]);
if(!$page) continue;
if (strncmp($page, "[nomenu]", 8) != 0 ) {
echo "$stags href='$page'>$page $etags \n";
}
}
}
function getLoginForm()
{
global $content, $msg;
$msg = "";
if (isset($_POST['sub'])) loginSubmitted();
$content[0] = "
<center>
<form action='' method='POST'>
<h2>Password</h2>
<input type='password' name='password' /><br />
<input type='submit' name='login' value='Login'>
<h2>$msg</h2><br />
<script src='js/editInplace.js'></script>
<div class='all'>
<a href='javascript:showhide()'>Click to change your password</a> <br /><br />
<div id=hide style='display: none;'>
Type your <b>old</b> password above, and your new one in the field below.
<h2>New Password</h2>
<input type='password' name='new' /><br />
<input type='submit' name='login' value='Change'>
<input type='hidden' name='sub' value='sub'>
</div></div>
</form></center>";
}
function loginSubmitted()
{
global $cookie, $password, $msg, $expirytime, $submitted_pass;
$submitted_pass = md5($_POST['password']);
if ($submitted_pass<>$password)
{
$msg = "<b class='wrong'>Wrong Password</b>";
return;
}
if($_POST['new'])
{
savePassword($_POST['new']);
$msg = "Password changed!<br /><br />Please login again.";
return;
}
setcookie($cookie,$password,$expirytime);
header('Location: ./');
exit;
}
function savePassword($password)
{
$password = md5($password);
$file = @fopen("files/password", "w");
if(!$file)
{
echo "<h2 style='color:red'>*Error* - unable to access password</h2><h3>But don't panic!</h3>".
"Set the correct read/write permissions to the password file. <br />
Find the password file in the /files/ directory and CHMOD it to 640.";
exit;
}
fwrite($file, $password);
fclose($file);
}
function extraSettings()
{
global $description, $keywords, $title, $slogan, $copyright, $menu;
echo "<div class='settings'>
<h3>Extra Settings</h3>
<a href='javascript:showhide()'>Cick here to open/close Settings</a><br /><br />
<div id=hide style='display: none;'>
<ul class='linkss'>
<b>Add Page: (in a new row); Precede the Page Name with [nomenu] to create a page that does not display in the Menu (that you want to link to from another page); then <a href='javascript:location.reload(true);'><i>click here to refresh the page</i></a>.</b><br />
<div id='change'><span id='menu' class='editText'>$menu</span></div>
</ul>
<ul class='linkss'>
<b>Title:</b><br />
<div id='change'><span id='title' class='editText'>$title</span></div>
</ul>
<ul class='linkss'>
<b>Slogan:</b><br />
<div id='change'><span id='slogan' class='editText'>$slogan</span></div>
</ul>
<ul class='linkss'>
<b>Meta Description:</b><br />
<div id='change'><span id='description' class='editText'>$description</span></div>
</ul>
<ul class='linkss'>
<b>Meta Keywords:</b><br />
<div id='change'><span id='keywords' class='editText'>$keywords</span></div>
</ul>
<ul class='linkss'>
<b>Copyright:</b><br />
<div id='change'><span id='copyright' class='editText'>$copyright</span></div>
</ul>
<br />
If you want to use a copyright sign: © - Simply copy this into your footer: &copy;
</div></div>";
}
?>
master style sheet
----------------------
body {
margin:25px 0px; padding:0px;
text-align:center;
background: #279bd5 url(img/bg.gif) repeat-x;
color: #fff;
font-family: Trebuchet MS, Georgia, serif;
font-size: 1.3em;
line-height: 140%;
}
h1 {
font-size: 1.92em;
text-transform: uppercase;
position: absolute;
}
.slogan {
padding-top: 3.1em;
font-size: .89em;
color: #333;
}
a {
color: #000;
text-decoration:none;
}
a:hover {color: #fff; text-decoration:underline;}
.container {
width: 890px;
margin:0px auto;
text-align:left;
padding:15px;
}
.insider {width: 890px; float: left;}
.insiderTop {width: 890px; float: left;}
.insiderBtm {width: 890px; float: left;}
.insiderLeft {width: 620px; float: left;}
.insiderTopL {width: 620px; float: left;}
.insiderBtmL {width: 620px; float: left;}
.rightSidePanel {width: 250px; float: right;}
.insiderRight {width: 695px; float: right;}
.insiderTopR {width: 695px; float: right;}
.insiderBtmR {width: 695px; float: right;}
.leftSidePanel {width: 185px; float: left;}
#nav {
width: auto;
font-size: 0.70em;
list-style: none;
padding: 0;
margin-top: 3em;
float: right;
clear: both;
}
#nav li {
background-color: #0776a0;
text-align: left;
float: left;
text-transform: uppercase;
border-right: 2px solid #279bd5;
display: block;
}
#nav li a, #nav li a:visited {
display: block;
padding: 0.4em 4em 0.4em 0.4em;
color: #FFF;
text-decoration: none;
}
#nav li a:hover {
color: #000;
background-color: #279bd5;
text-decoration: underline;
}
#nav li a.current, #nav li a.current:visited, #nav li a.current:hover {
color: #FFF;
text-decoration: none;
}
.left {float: left;}
.footer {
width: 890px;
font-size: 0.8em;
text-align: right;
margin-top: 1em;
padding: 5px;
border-top: 2px solid #ccc;
float: left;
clear: both;
}
.settings {
clear: both;
margin: 15px;
border-top: 5px solid #65A5D1;
text-align: left;
}
.wrong {color: #FF4040;}
.top {
background: url("http://iqcms.com/sp/tech_02.jpg");
background-color: #EEE;
width: 890px;
height: 183px;
}