?? generatepage.php
字號:
<?PHP
include_once('functions_inc.php');
include('head_inc.php');
echo '<div id="nav">';
echo include('navbox.php');
echo '</div>';
echo '<div id="mainsolo">';?>
<h1><?=d('generatepageheader');?></h1>
<?PHP
$XML=load('../data/navigation.xml');
$lpage=$_POST['page']==''?$_GET['page']:$_POST['page'];
$easycmsbranding="\n<!--\n\tDocument: $lpage\n\tGenerated by EasyCMS (http://easycms.onlinetools.org)\n\tLast change: ".date ("M d Y H:i:s")."\n-->";
$backlink="<span style=\"color:#000;padding:3px;background:#eee;border:1px solid #333;font-family:verdana,arial,sans serif;font-size:10px\">Powered by <a href=\"http://easycms.onlinetools.org\" style=\"color:#336699;font-family:verdana,arial,sans serif;font-size:10px\">EasyCMS</a></span>";
if ($lpage=='' and $_GET['all']==''){
echo '<p>» <a href="generatepage.php?all=1">'.d('generatealllink').'</a></p>';
echo '<p>'.d('selecttogenerate').'</p>';
echo '<p>» <a href="generatepage.php?page='.untag($homedata,'url',0).'">'.untag($homedata,"name",0).'</a></p>';
if($meta[0]!=''){foreach ($meta as $m){
echo '<p>» <a href="generatepage.php?page='.untag($m,'url',0).'">'.untag($m,"name",0).'</a></p>';
}}
if($navitems[0]!=''){foreach ($navitems as $m){
echo '<p>» <a href="generatepage.php?page='.untag($m,'url',0).'">'.untag($m,"name",0).'</a></p>';
$subs=untag($m,"subitem",1);
if ($subs[0]!=''){foreach ($subs as $s){
echo '<p>   » <a href="generatepage.php?page='.untag($s,'suburl',0).'">'.untag($s,"subname",0).'</a></p>';
}}
}}
}
if ($lpage!=''){
$HTML=generate($lpage);
$home=untag($XML,'home',0);
$folder='html/';
if($lpage==untag($home,'url',0)){
$folder='';
$HTML=preg_replace('/\.\.\//','',$HTML);
}
if(preg_match('/<!-- branding -->/',$HTML)){$HTML=preg_replace('/<!-- branding -->/',$backlink,$HTML);}
else {$HTML=preg_replace('/<\/body>/si',$backlink.'</body>',$HTML);}
$HTML=preg_replace('/<html(.*?)>/si','<html\\1>'.$easycmsbranding."\n",$HTML);
$test=save('../'.$folder.$lpage,$HTML);
if ($test==0){echo str_replace('%%page%%',$lpage,d('pagegenerationmessage'));}
if ($test==1){echo str_replace('%%page%%',$lpage,d('pagesaveerror'));}
echo '<p>'.d('generatemore').'</p>';
echo '<p>'.d('backtoecms').'</p>';
}
if ($_GET['all']!=''){
$folder='html/';
$mains=untag($XML,'url',1);
$mains=array_merge($mains,untag($XML,'suburl',1));
foreach ($mains as $lpage){
if($lpage!=''){
$HTML=generate($lpage);
$home=untag($XML,'home',0);
$folder='html/';
if($lpage==untag($home,'url',0)){
$folder='';
$HTML=preg_replace('/\.\.\//','',$HTML);
}
if(preg_match('/<!-- branding -->/',$HTML)){$HTML=preg_replace('/<!-- branding -->/',$backlink,$HTML);}
else {$HTML=preg_replace('/<\/body>/si',$backlink.'</body>',$HTML);}
$HTML=preg_replace('/<html(.*?)>/si','<html\\1>'.$easycmsbranding."\n",$HTML);
$test=save('../'.$folder.$lpage,$HTML);
if ($test==0){echo str_replace('%%page%%',$lpage,d('pagegenerationmessage'));}
if ($test==1){echo str_replace('%%page%%',$lpage,d('pagesaveerror'));}
}
}
echo '<p>'.d('generatemore').'</p>';
echo '<p>'.d('backtoecms').'</p>';
}
function generate($lpage){
global $XML;
$page=load('../data/'.$lpage);
preg_match('/\[pagetemplate:(.*?)\]/si',$page,$template);
preg_match('/\[pagekeywords:(.*?)\]/si',$page,$keywords);
preg_match('/\[pagedescription:(.*?)\]/si',$page,$description);
preg_match('/\[pagetitle:(.*?)\]/si',$page,$title);
if($template[1]==''){$template[1]='template.html';}
$HTML=load('../templates/'.$template[1]);
$HTML=preg_replace('/%%title%%/',$title[1],$HTML);
$HTML=preg_replace('/%%keywords%%/',$keywords[1],$HTML);
$HTML=preg_replace('/%%description%%/',$description[1],$HTML);
$mains=untag($XML,'mainitem',1);
$metas=untag($XML,'meta',1);
$home=untag($XML,'home',0);
// If page is the homepage
if ($lpage==untag($home,'url',0)){
$HTML=nomain($HTML,$mains,1);
$HTML=preg_replace('/<!-- crumbs -->/',untag($home,'name',0),$HTML);
$HTML=preg_replace('/%%parent%%/',unfile(untag($home,'url',0)),$HTML);
$HTML=preg_replace('/%%child%%/','',$HTML);
$HTML=doeasycms($HTML,$page);
return $HTML;
}
// If page is a meta page
if($metas[0]!=''){foreach($metas as $m){
if($lpage==untag($m,'url',0)){
$HTML=nomain($HTML,$mains,0);
$HTML=preg_replace('/<!-- crumbs -->/','<a href="../'.untag($home,'url',0).'">'.untag($home,'name',0).'</a> > '.untag($m,'name',0),$HTML);
$HTML=preg_replace('/%%parent%%/',unfile(untag($m,'url',0)),$HTML);
$HTML=preg_replace('/%%child%%/','',$HTML);
$HTML=doeasycms($HTML,$page);
return $HTML;
}
}}
// If page is a main page
if($mains[0]!=''){foreach($mains as $k=>$m){
if($lpage==untag($m,'url',0)){$active=$k;}
$subs=untag($m,'subitem',1);
if($subs[0]!=''){foreach($subs as $f=>$s){
if($lpage==untag($s,'suburl',0)){$active=$k;$subactive=$f+1;}
}}
}}
if ($active>=0){
$subs=untag($mains[$active],'subitem',1);
preg_match('/<!-- start:leftnav -->(.*?)<!-- end:leftnav -->/msi',$HTML,$mainHTML);
$inc='';
if($subs[0]!=''){foreach ($subs as $f=>$s){
if ($f+1!=$subactive){
$mHTML=preg_replace("/<!-- start:active -->.*?<!-- end:active -->/msi",'',$mainHTML[1]);
$mHTML=preg_replace('/url/',untag($s,'suburl',0),$mHTML);
if (untag($s,'subimage',0)!=''){
$mHTML=preg_replace('/item/','<img src="../ecms_navimages/'.untag($s,'subimage',0).'" alt="'.untag($s,'subname',0).'" border="0" />',$mHTML);
}else{
$mHTML=preg_replace('/item/',untag($s,'subname',0),$mHTML);
}
}else{
$mHTML=preg_replace('/<!-- start:inactive -->.*?<!-- end:inactive -->/msi','',$mainHTML[1]);
$mHTML=preg_replace('/url/',untag($s,'suburl',0),$mHTML);
if (untag($s,'subimage',0)!=''){
$mHTML=preg_replace('/item/','<img src="../ecms_navimages/'.untag($s,'subimage',0).'" alt="'.untag($s,'subname',0).'" border="0" />',$mHTML);
}else{
$mHTML=preg_replace('/item/',untag($s,'subname',0),$mHTML);
}
}
$inc.=preg_replace('/<!--.*?:.*?-->/si','',$mHTML);
}}
$HTML=preg_replace('/<!-- start:leftnav -->(.*?)<!-- end:leftnav -->/msi',$inc,$HTML);
preg_match('/<!-- start:mainnav -->(.*?)<!-- end:mainnav -->/msi',$HTML,$mainHTML);
$inc='';
$active++;
foreach ($mains as $k=>$m){
if ($k+1!=$active){
$mHTML=preg_replace('/<!-- start:mainactive -->.*?<!-- end:mainactive -->/msi','',$mainHTML[1]);
$mHTML=preg_replace('/url/',untag($m,'url',0),$mHTML);
if (untag($m,'image',0)!=''){
$mHTML=preg_replace('/item/' , '<img src="../ecms_navimages/'.untag($m,'image',0).'" alt="'.untag($m,'name',0).'" border="0" />',$mHTML);
}else{
$mHTML=preg_replace('/item/',untag($m,'name',0),$mHTML);
}
$mHTML=preg_replace('/item/',untag($m,'name',0),$mHTML);
$inc.=preg_replace('/<!--.*?:.*?-->/si','',$mHTML);
}else{
$mHTML=preg_replace('/<!-- start:maininactive -->.*?<!-- end:maininactive -->/msi','',$mainHTML[1]);
$mHTML=preg_replace('/url/',untag($m,'url',0),$mHTML);
if (untag($m,'image',0)!=''){
$mHTML=preg_replace('/item/','<img src="../ecms_navimages/'.untag($m,'image',0).'" alt="'.untag($m,'name',0).'" border="0" />',$mHTML);
}else{
$mHTML=preg_replace('/item/',untag($m,'name',0),$mHTML);
}
$inc.=preg_replace('/<!--.*?:.*?-->/si','',$mHTML);
}
}
$HTML=preg_replace('/<!-- start:mainnav -->(.*?)<!-- end:mainnav -->/msi',$inc,$HTML);
$crumbs='<a href="../'.untag($home,'url',0).'">'.untag($home,'name',0).'</a> > ';
$crumbs.=$subactive>0?'<a href="'.untag($mains[$active-1],'url',0).'">'.untag($mains[$active-1],'name',0).'</a> > '.untag($subs[$subactive-1],'subname',0):untag($mains[$active-1],'name',0);
$HTML=preg_replace('/%%parent%%/',unfile(untag($mains[$active-1],'url',0)),$HTML);
$child=$subactive>0?unfile(untag($subs[$subactive-1],'suburl',0)):'';
$HTML=preg_replace('/%%child%%/',$child,$HTML);
$HTML=preg_replace('/<!-- crumbs -->/',$crumbs,$HTML);
$HTML=doeasycms($HTML,$page);
return $HTML;
}
}
/*
function doeasycms();
called by all generators
*/
function doeasycms($HTML,$page){
$page=stripslashes($page);
$page=preg_replace('/\[page.*?\]/','',$page);
$page=preg_replace("/\[startbr\](.*?)\[endbr\]/esi","nl2br('\\1')",$page);
$page=preg_replace("/\[startencode\](.*?)\[endencode\]/esi","htmlspecialchars('\\1')",$page);
$page=preg_replace("/\[startscramble\](.*?)\[endscramble\]/esi","scramble('\\1')",$page);
if (preg_match('/<!-- content -->/',$HTML)){
$HTML=preg_replace('/<!-- content -->/',$page,$HTML);
}else{
preg_match_all('/\[startsection:.*?\](.*?)\[endsection:.*?\]/smi',$page,$secdata);
foreach ($secdata[1] as $k=>$s){
$HTML=preg_replace('/<!-- content:'.($k+1).' -->/',$s,$HTML);
}
}
$HTML=preg_replace('/\[.*?\]/','',$HTML);
return stripslashes($HTML);
}
function scramble($email){
$email=stripslashes($email);
for($i=0;$i<strlen($email);$i++){
$scramble.="&#".ord($email{$i}).";";
}
return $scramble;
}
/*
function nomain();
called by meta and home page to populate main nav and delete subnav
*/
function nomain($HTML,$mains,$ishome){
$fold=$ishome==1?'html/':'';
$HTML=preg_replace('/<!-- start:leftnav -->(.*?)<!-- end:leftnav -->/msi','',$HTML);
preg_match('/<!-- start:mainnav -->(.*?)<!-- end:mainnav -->/msi',$HTML,$mainHTML);
$inc='';
if($mains[0]!=''){foreach ($mains as $m){
$mHTML=preg_replace('/<!-- start:mainactive -->.*?<!-- end:mainactive -->/msi','',$mainHTML[1]);
$mHTML=preg_replace('/url/',$fold.untag($m,'url',0),$mHTML);
if (untag($m,'image',0)!=''){
$mHTML=preg_replace('/item/','<img src="../ecms_navimages/'.untag($m,'image',0).'" alt="'.untag($m,'name',0).'" border="0" />',$mHTML);
}else{
$mHTML=preg_replace('/item/',untag($m,'name',0),$mHTML);
}
$inc.=preg_replace('/<!--.*?:.*?-->/si','',$mHTML);
}}
$HTML=preg_replace('/<!-- start:mainnav -->(.*?)<!-- end:mainnav -->/msi',$inc,$HTML);
return $HTML;
}
function unfile($file){
$file=explode('.',$file);
return $file[0];
}
?>
</div>
</div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -