Guest User

Untitled

a guest
Jun 23rd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.66 KB | None | 0 0
  1. <?class cms{function _setup(){function _parsePanel($r,$str_in,&$o){$o=array();preg_match_all($r,$str_in,$i);array_shift($i);for($a=0;$a < count($i[0]);$a++){$n=trim((($i[0][$a])?strtolower($i[0][$a]):$a));$o[$n]=trim($i[1][$a]);}}function _parseWebsite($r,&$o){_parsePanel($r,$o,$o);$opt_default=array(missing=>'missing',theme=>'cimus',template=>'index.html');$opt=array();foreach($o as $a=>$b){if($a!=='opts'){$opt[$a]=$b;if($a!=='name'){unset($o[$a]);}}}$o['opts']=array_merge($opt_default,$opt);$o['page']=strtolower((($_GET['p'])?$_GET['p']:'index'));if($o['opts']['index']){$o['index']=$o['opts']['index'];unset($o['opts']['index']);}else{$o['index']='index';}}function _parseNavigation($r,&$p){$website=&$p['website'];$o=&$p['sitemap'];preg_match_all($r,$o,$i);array_shift($i);$o=array();$y_deep=array();for($a=0;$a < count($i[0]);$a++){$l=$i[1][$a];$deep=strlen($i[0][$a]);$n=trim(preg_replace('/\[.*?\]/','',$l));$page=strtolower(str_replace(array(0=>' ',1=>'.'),array(0=>'-',1=>''),$n));preg_match_all('/\[(.*?):(.*?)\]|\[(.*?)\]/',$l,$opts);if(count($opts[0])){$opts_=array();for($b=0;$b < count($opts[0]);$b++){if($opts[1][$b]=='url'){$page=trim($opts[2][$b]);}else{$opts_[trim($opts[1][$b])]=trim($opts[2][$b]);}}$opts=$opts_;}else{$opts=array();}if($a==0){$page='index';if($website['page']==$page){$website['opts'][$page]=$page;}}$opts=array_merge(array(name=>$n),$opts);$y_deep[$deep]=$page;$o_=&$o;for($b=0;$b < $deep;$b++){$opts=array_merge($o_[$y_deep[$b]]['opts'],$opts);$o_=&$o_[$y_deep[$b]]['kids'];}if($o_['name']){if(!$o_['kids']){$o_['kids']=array();}$y_write=&$o_['kids'];}else{$y_write=&$o_;}$y_write[$page]=array(name=>$n,deep=>$deep,opts=>$opts);if($page==$website['page']){$y_write[$page]['current']=true;}}}function _parsePage(&$sitemap,&$current){foreach($sitemap as &$a){if($a['kids']){$is_selected=_parsePage($a['kids'],$current);if($is_selected){$a['selected']=true;return true;}}if($a['current']){$a['selected']=true;$current=$a;return true;}}return false;}function _htmlAllNavigation(&$p){$index=$p['website']['index'];$sitemap=$p['sitemap'];$p['html']=array('navigation-sitemap'=>_htmlNavigationSitemap($sitemap,$index),'navigation-breadcrumb'=>_htmlNavigationBreadcrumb($sitemap,$index));$hold=true;$deep=1;while($hold){$hold=false;foreach($sitemap as &$b){if($b['selected']){$hold=true;$p['html']['navigation-level-'.$deep]= _htmlNavigation($sitemap,$index,$deep);$sitemap=$b['kids'];$deep++;break;}}if($sitemap){$p['html']['navigation-siblings']=$p['html']['navigation-level-'.($deep - 1)];$p['html']['navigation-children']=$p['html']['navigation-level-'.$deep]=_htmlNavigation($sitemap,$index,$deep);}else{$hold=false;}}}function _htmlNavigationSitemap(&$sitemap,$index,$deep=1){$h='<ul class="level-'.$deep.'">';foreach($sitemap as $a=>$b){$a_=&$sitemap[$a];$c='level-'.$deep.(($a_['selected'])?' selected':'').(($a_['current'])?' current':'');$h_='<li class="'.$c.'"><a class="'.$c.'" href="./'.(($a!==$index)?$a:'').'"><span>'.$a_['name'].'</span></a>';if($a_['kids']){$h_.=_htmlNavigationSitemap($a_['kids'],$index,$deep + 1);}$h_.='</li>';if(!$a_['hidden']){$h.=$h_;}}$h.='</ul>';return $h;}function _htmlNavigation(&$sitemap,$index,$deep=1){$h='<ul class="level-'.$deep.'">';foreach($sitemap as $a=>$b){$a_=&$sitemap[$a];$c='level-'.$deep.(($a_['selected'])?' selected':'').(($a_['current'])?' current':'');if(!$a_['hidden']){$h.='<li class="'.$c.'"><a class="'.$c.'" href="./'.(($a!==$index)?$a:'').'"><span>'.$a_['name'].'</span></a>';}}$h.='</ul>';return $h;}function _htmlNavigationBreadcrumb(&$sitemap,$index,$deep=1){$h=false;foreach($sitemap as $a=>$b){$a_=&$sitemap[$a];if($a_['selected']){$c='level-'.$deep.' selected'.(($a_['current'])?' current':'');$h='<a class="'.$c.'" href="./'.(($a!==$index)?$a:'').'"><span>'.$a_['name'].'</span></a>';if($a_['current']){return $h;}elseif($a_['kids']){$return=_htmlNavigationBreadcrumb($a_['kids'],$index,$deep + 1);if($return){return $h.'&nbsp;>&nbsp;'.$return;}}}}return $h;}_parsePanel('/\/\*\s{0,}-+\s{0,}(.*?)\s{0,}-+\s{0,}\*\/([^\/]+)/',trim(file_get_contents('cms.txt')),$p);_parseWebsite('/(.*?):(.+)/',$p['website']);_parseNavigation('/(\t{0,})(.+?)(\n|$)/sm',$p);_parsePage($p['sitemap'],$p['current']);$p['current']['opts']=array_merge($p['website']['opts'],$p['current']['opts']);_htmlAllNavigation($p);return $p;}function _theme(&$p){function _commentCompression($str){$str=preg_replace('/<!-- BEGIN:(.*?) -->.*?<!-- END:\1 -->/s','##$1##',$str);$str=preg_replace('/##BEGIN:(.*?)##.*?##END:\1##/s','##$1##',$str);return $str;}function _replace($replace,$with,&$inside){$inside=str_ireplace('<!-- '.$replace.' -->',$with,$inside);$inside=str_ireplace('##'.$replace.'##',$with,$inside);}function _include($u,$a){foreach($a as $b){if(file_exists($u.$b)){ob_start();include $u.$b;$u=ob_get_contents();ob_end_clean();return _commentCompression($u);}}return false;}$current=$p['current'];if(!$current){$current=$p['website'];}$theme=_include('themes/'.$current['opts']['theme'].'/templates/'.$current['opts']['template'],array(0=>'',1=>'.php',2=>'.html',3=>'.txt'));$page=_include('pages/'.$p['website']['page'],array(0=>'.php',1=>'.html',2=>'.txt'));if(!$page){$page=_include('pages/'.$current['opts']['missing'],array(0=>'.php',1=>'.html',2=>'.txt'));}_replace('content',$page,$theme);$theme=preg_replace('/(href|src)="\.\./','$1="'.'themes/'.$current['opts']['theme'],$theme);foreach($p['html'] as $a=>$b){_replace($a,$b,$theme);}if($current['opts']){foreach($current['opts'] as $a=>$b){if(is_string($b)){_replace($a,$b,$theme);}}}foreach($p['website']['opts'] as $a=>$b){if(is_string($b)){_replace('site-'.$a,$b,$theme);}}$theme=preg_replace('/(<!--\s|##).*?(\s-->|##)/','',$theme);echo $theme;}function __construct(){$t=$this;$p=$t->_setup();$theme=$t->_theme($p);}}$site=new cms();?>
Add Comment
Please, Sign In to add comment