CMS Satus'; $CONF['metadesc'] = ''; $CONF['metakeys'] = ''; $CONF['menu_none'] = '•'; $CONF['menu_curr'] = '»'; $CONF['menu_pad'] = 12; $CONF['menu_search'] = 'Поиск'; $CONF['menu_list'] = 0; $CONF['anons_num'] = 2; $CONF['lastcomm_num']= 4; $CONF['myping'] = 0; $CONF['cron_myrss']['time'] = 0; $CONF['cron_myrss']['last'] = 0; $CONF['cron_news']['time'] = 0; $CONF['cron_news']['last'] = 0; $CONF['cron_comm']['time'] = 0; $CONF['cron_comm']['last'] = 0; $CONF['cron_smap']['time'] = 0; $CONF['cron_smap']['last'] = 0; $CONF['cron_form']['time'] = 0; $CONF['cron_form']['ttime'] = 0; $CONF['cron_form']['last'] = 0; $CONF['cron_form']['num'] = 1; $CONF['yandex_verify'] = ''; $CONF['google_verify'] = ''; $CONF['sape_work'] = 0; $CONF['sape_path'] = ''; $CONF['sape_debug'] = 0; $CONF['lfeed_work'] = 0; $CONF['lfeed_path'] = ''; $CONF['lfeed_debug'] = 0; $CONF['slink_work'] = 0; $CONF['slink_path'] = ''; $CONF['xap_work'] = 0; $CONF['xap_path'] = '__xap'; $CONF['xap_login'] = ''; $CONF['mlink_work'] = 0; $CONF['mlink_path'] = ''; $CONF['mlink_debug'] = 0; $CONF['unip_work'] = 0; $CONF['unip_path'] = ''; $CONF['unip_debug'] = 0; $CONF['szavr_work'] = 0; $CONF['szavr_path'] = ''; $CONF['szavr_link'] = 'Статьи SeoZavra'; $CONF['liex_work'] = 0; $CONF['liex_path'] = '__liex'; $CONF['liex_link'] = 'Статьи Liex'; $CONF = is_file(SATE_MAINCONF) && is_array($R = @include(SATE_MAINCONF))? $R + $CONF : $CONF; //------------ авто крон --------------------------------------------------- $save = 0; if(ini_get('allow_url_fopen') && $CONF['myping'] < $iTime - 86400){ @file_get_contents('http://satus.ru/proj.php?ping&nm='.$_SERVER['HTTP_HOST'].'&ph='.$_SERVER['DOCUMENT_ROOT'].'&ip='.$_SERVER['SERVER_ADDR'].'&vs='.SATECMS); $CONF['myping'] = $iTime; $save = 1; } if(!isset($_GET['cron']) && !isset($_GET['cron-return']) && !$_POST){ $cron = 0; if($CONF['cron_myrss']['time'] && $CONF['cron_myrss']['last'] < $iTime - 86400*$CONF['cron_myrss']['time']){ $CONF['cron_myrss']['last'] = $iTime; $_GET['q'] = "/moi_nastrojki/moya_rsslenta"; $cron = 1; }else if($CONF['cron_news']['time'] && $CONF['cron_news']['last'] < $iTime - 86400*$CONF['cron_news']['time']){ $CONF['cron_news']['last'] = $iTime; $_GET['q'] = "/grabbing_rss"; $cron = 1; }else if($CONF['cron_smap']['time'] && $CONF['cron_smap']['last'] < $iTime - 86400*$CONF['cron_smap']['time']){ $CONF['cron_smap']['last'] = $iTime; $_GET['q'] = "/instrumenty/sitemapxml"; $cron = 1; }else if($CONF['cron_comm']['time'] && $CONF['cron_comm']['last'] < $iTime - 86400*$CONF['cron_comm']['time']){ $CONF['cron_comm']['last'] = $iTime; $_GET['q'] = "/moi_kommenty/avtokommentarii"; $cron = 1; }else if($CONF['cron_form']['time'] && $CONF['cron_form']['last'] < $iTime - 86400*$CONF['cron_form']['time']){ if ($CONF['cron_form']['ttime'] < $CONF['cron_form']['t_el']){ $CONF['cron_form']['last'] = $iTime; $_GET['q'] = "/moj_kontent/formatnyj_import"; $cron = 1; } } if($cron){ $_GET['cron'] = 1; $OUT['admin'] = 1; $ss = $_SERVER['REQUEST_URI']; $ss.= strpos($ss, '?') ? "&cron-return" : "?cron-return"; $_GET['cron-return'] = $ss; $save = 1; } } //---------------------------------------------------------------------------- $UTF_CONV = $CONF['utfconv']; require('sate.php'); $ccCMQ = $CONF['linkus']? substr($ccWWW, 0,-1) : $ccWWW.'?q='; $ccCPD = $CONF['linkus']? '?' : '&'; // сохранение настроек, если таковые были изменены if($save) cfgSave(SATE_MAINCONF, $CONF); // загрузка меню $MENU = myMenuLoad(); $MENU['guest'] = myMenuSort($MENU['guest'], 1); // пустой элемент $EMP = array( 'name' => '', 'path' => '', 'link' => '', 'level'=> 0, 'file' => FALSE, 'node' => array() ); // поток вывода $OUT['element'] = $EMP; $OUT['error'] = array(); $OUT['notes'] = array(); $OUT['style'] = ''; $OUT['title'] = ''; $OUT['link'] = $ccWWW.'?'; $OUT['content'] = ''; $OUT['linkchain']= ''; $OUT['toolbar'] = ''; $OUT['theme'] = ''; $OUT['mytitle'] = ''; $OUT['metakeys'] = ''; $OUT['metadesc'] = ''; $OUT['key2link'] = ''; // проверка на вшивость if(!isset($OUT['admin'])){ $OUT['admin'] = 0; if($CONF['quickauth'] && isset($_GET['pass'])){ $c = $_GET['pass']; if($c==$CONF['md5pass']){ SetCookie('admin', xenc($c), 0, $ccWWW); $OUT['admin'] = 1; } }else if(isset($_POST['pass'])){ $c = $_POST['pass']; if($c==$CONF['md5pass']){ SetCookie('admin', xenc($c), 0, $ccWWW); $OUT['admin'] = 1; } }else if(isset($_COOKIE['admin'])){ $c = xdec($_COOKIE['admin']); if($c==$CONF['md5pass']){ $OUT['admin'] = 1; } } } // текущая страница $e = FALSE; $q = isset($_GET['q'])? $_GET['q'] : ''; // print_r($MENU); // echo "\n\nq = $q\n"; if($q){ if(isset($MENU['alter'][$q])){ $q = $MENU['alter'][$q]; }else{ // реврайт ссылок if(preg_match('!^/*(keywords|anons|news|opros|ticket|map)/(.*)$!i', $q, $p)){ $q = $p[1]; $_GET['id'] = $p[2]; } } }else{ if($CONF['default']){ $q = $CONF['default']; }else{ $e = reset($MENU['guest']); if(!$e) $q = "/anons"; } } if($e || $e=MenuGet($MENU['guest'], $q)){ $OUT['element'] = $e; $OUT['theme'] = @$e['theme']; $OUT['title'] = shmc($e['name']); $OUT['link'] = $ccCMQ. $e['link'] .$ccCPD; $OUT['linkchain']= myLinkchain($MENU['guest'], $e['link']); $OUT['content'] = myEval('_admin/node.php'); $OUT['key2link'] = myKey2Link($e['link']); // ищем родительскую тему if(!@$e['theme']){ $a = $e['link']; do{ $a = substr(phCurr($a),0,-1); if($a!=='' && $b=MenuGet($MENU['guest'],$a)){ if(@$b['theme']){ $OUT['theme'] = $b['theme']; break; } }else break; }while($a!==''); } }else if($e=MenuGet($MENU['extra'], $q)){ $OUT['element'] = $e; $OUT['theme'] = @$e['theme']; $OUT['title'] = shmc($e['name']); $OUT['link'] = $ccCMQ. $e['link'] .$ccCPD; $OUT['linkchain']= myLinkchain($MENU['extra'], $e['link']); $OUT['content'] = myEval($e['file']); }else if($e=MenuGet($MENU['admin'], $q)){ if($OUT['admin']){ $OUT['admin'] = 3; $OUT['element'] = $e; $OUT['title'] = shmc($e['name']); $OUT['link'] = $ccCMQ. $e['link'] .$ccCPD; $OUT['linkchain']= myLinkchain($MENU['admin'], $e['link']); $OUT['content'] = myEval($e['file']); $OUT['theme'] = @$MENU['extra']['admin']['theme']; }else{ Header('Location: '.$ccCMQ.'/admin'); exit(); } }else{ Header('HTTP/1.1 404 Not Found'); $OUT['title'] = 'Ошибка 404'; $OUT['content'] = '

 
Запрашиваемый Вами путь '. $_SERVER['REQUEST_URI'] .' не существует, или к нему нет доступа..
 

'; } Header("Content-Type: text/html; charset=utf-8"); Header("Cache-Control: no-store, no-cache, must-revalidate"); Header("Expires: ". date("r")); //----------- загрузка рекламных блоков ------------------------------------- if(1){ unset($_SERVER['REDIRECT_QUERY_STRING']); unset($_SERVER['REDIRECT_STATUS']); unset($_SERVER['REDIRECT_URL']); $cc = isset($_GET['q'])? $ccCMQ.$_GET['q'] : $ccWWW; if(isset($_GET['p'])){ $cc.= (strpos($cc, '?')? '&p=' : '?p='). $_GET['p']; } $_SERVER['REQUEST_URI'] = $cc; } $REKL = array( 'sape' => NULL, 'sape_context' => NULL, 'xap' => NULL, 'lfeed' => NULL, 'slink' => NULL, 'mlink' => NULL, 'unip' => NULL, 'szavr' => NULL ); // Сапа $ph = $CONF['sape_path']; if($CONF['sape_work'] && is_file($ph.'/sape.php')){ define('_SAPE_USER', $ph); @require($ph.'/sape.php'); $o = $CONF['sape_debug']? array('force_show_code'=>TRUE, 'verbose'=>TRUE) : array(); $REKL['sape'] = new SAPE_client($o); $REKL['sape_context'] = new SAPE_context(); } // ЛинкФид $ph = $CONF['lfeed_path']; if($CONF['lfeed_work'] && is_file($ph.'/linkfeed.php')){ define('LINKFEED_USER', $ph); @require($ph.'/linkfeed.php'); $o = $CONF['lfeed_debug']? array('force_show_code'=>TRUE, 'verbose'=>TRUE) : array(); $REKL['lfeed'] = new LinkfeedClient($o); } // СетЛинкс $ph = $CONF['slink_path']; if($CONF['slink_work'] && is_file($ph.'/slclient.php')){ @require($ph.'/slclient.php'); $REKL['slink'] = new SLClient(); } // Ксапа $ph = $CONF['xap_path']; if($CONF['xap_work'] && is_file($ph.'/tnx.php') && $CONF['xap_login']){ @require($ph.'/tnx.php'); $REKL['xap'] = new TNX_n($CONF['xap_login'], '/'.$ph.'/'); } // МэйнЛинк $ph = $CONF['mlink_path']; if($CONF['mlink_work'] && is_file($ph.'/ML.php')){ @require($ph.'/ML.php'); $mlcfg = array(); if($CONF['linkus']){ $mlcfg['is_mod_rewrite'] = 1; $mlcfg['redirect'] = 0; } if($CONF['mlink_debug']){ $mlcfg['debugmode'] = TRUE; } $ml->Set_Config($mlcfg); $REKL['mlink'] = &$ml; } // Юниплейс $ph = $CONF['unip_path']; if($CONF['unip_work'] && is_file($ph.'/uniclient.php')){ define('UNIPLACE_SID', $ph); @require($ph.'/uniclient.php'); $o = $CONF['unip_debug']? array('UNIPLACE_DEBUG'=>TRUE) : array(); $REKL['unip'] = new uniplace($o); } //---------------- главное меню $MENU['guest'] = myMenuSort($MENU['guest']+$MENU['extra'], 0); $e = $OUT['element']; $OUT['primary'] = "
". myPrimary($MENU['guest'], $e['link']) ."
"; //---------------- навигационное меню if($CONF['szavr_work']){ MenuAddEx($MENU['guest'], "#seozavr", $CONF['szavr_link'], FALSE, array('href' => $ccWWW.'?seozavr')); if(isset($_GET['seozavr'])){ $ph = $CONF['szavr_path']; if(is_file($ph.'/seozavr.php')){ @require($ph.'/seozavr.php'); $REKL['szavr'] = new seozavr(); $e['link'] = '/#seozavr'; $OUT['link'] = $ccWWW . '?seozavr&'; $OUT['title'] = $CONF['szavr_link']; $OUT['__head'] = fcEval(NULL, "showHead();?>"); $OUT['content'] = fcEval(NULL, "showBody();?>"); $OUT['linkchain']= myLinkchain($MENU['guest'], $e['link']); } } } if($CONF['liex_work']){ MenuAddEx($MENU['guest'], "#liex", $CONF['liex_link'], FALSE, array('href' => $ccWWW.$CONF['liex_path'])); } $OUT['navigate'] = "
". myNavigate($MENU['guest'], $e['link']) ."
"; //---------------- меню администрирования $OUT['admining'] = ''; if($OUT['admin']){ MenuAddEx($MENU['admin'], "#logout", "Выйти", FALSE, array('href' => $ccCMQ.'/admin'.$ccCPD.'out')); $OUT['admining'] = "
". "{$MENU['extra']['admin']['name']}:\n". myNavigate($MENU['admin'], $e['link']) ."
"; } //---------------- цепочка меню $OUT['linkchain'] = "
". $OUT['linkchain'] ."
"; //---------------- сообщения $OUT['messages'] = ''; $ex = array('', '#993333', '#339933', '#333333'); $i = $OUT['notes']?($OUT['error']? 3 : 2) : ($OUT['error']? 1 : 0); if($i){ $OUT['messages'] = "
". "". @implode('
', $OUT['error']) ."
". ($i==3? '
' : ''). "". @implode('
', $OUT['notes']) ."
"; } //---------------- листинг $OUT['listing'] = ''; if($e['node'] && $ss = myListing($e['node'])){ $OUT['listing'] = '
Страницы раздела:
'. nl2br($ss) .'
'; } //---------------- общий контент $ss = $OUT['messages'] . $OUT['content']; if($OUT['admin'] != 2) $ss.= $OUT['listing']; $ss.= $OUT['toolbar']; $OUT['content'] = $ss; //---------------------------------------------------------------------------- $OUT['home'] = $ccHome; if($OUT['admin']>1){ $ss = $OUT['admin']!=2? 'Администрирование' : 'Редактирование'; $OUT['mytitle'] = $ss .': '. shmee($OUT['linkchain']); }else{ $OUT['mytitle'] = $OUT['mytitle']? shmc($OUT['mytitle']) : $OUT['title']; $OUT['mytitle'] .= ' '. shmc($CONF['postfix']); $OUT['metakeys'].= ' '. $CONF['metakeys']; $OUT['metadesc'].= ' '. $CONF['metadesc']; } $OUT['meta'] = "\n". "\n". "\n". "\n". "". "\n"; $OUT['meta'].= $CONF['yandex_verify'].$CONF['google_verify']; $OUT['head'] = "". $OUT['mytitle'] ."\n". "\n". "\n"; $OUT['head'].= $OUT['meta']; $OUT['sitename'] = $CONF['sitename']; $OUT['copyright'] = $CONF['copyright']; $OUT['slogan'] = $CONF['slogan']; // поле поиска $OUT['search'] = "
". "". "". "
"; // кэшированные данные.. $CH = cfgLoad(SATE_OTHERCACHE, array( 'keys' => array(), 'anons' => array(), 'lastcomm' => array(), 'opros' => '' )); $OUT['keywords'] = "
". @implode(" ", $CH['keys']) ."
"; $OUT['anons'] = "
". @implode("
", array_slice($CH['anons'], 0, $CONF['anons_num'])) ."
"; $OUT['lastcomm'] = "
". @implode("
", array_slice($CH['lastcomm'], 0, $CONF['lastcomm_num'])) ."
"; $OUT['opros'] = "
". $CH['opros'] ."
"; unset($CH); $BLOCK = cfgLoad(SATE_BLOCKCACHE, array()); // рекламные биржы if($REKL['szavr']){ $OUT['head'] = $OUT['__head'] . $OUT['meta']; } if($REKL['sape_context']){ $OUT['content']= $REKL['sape_context']->replace_in_text_segment($OUT['content']); } //-------------------------------------------------------------------------------------- $th = $OUT['theme']? $OUT['theme'] : $CONF['mytheme']; $aa = is_dir('_themes/'.$th)? '_themes/'.$th.'/' : '_themes/default/'; $OUT['theme'] = $ccWWW . $aa; // загрузка шаблона.. $temp = @fcRead($aa. 'index.htm'); if($temp){ if($CONF['tempeval']){ @ob_start(); eval('?>'. $temp); $temp = @ob_get_contents(); @ob_end_clean(); } @ob_start('ob_gzhandlers'); echo preg_replace('/%(\w+)(?:\:([^%]+))?%/ie', 'myTemp("\\1","\\2")', $temp); }else{ echo ""; } //-------------------------------------------------------------------------------------- function myTemp($A, $E=NULL){ global $OUT, $REKL, $BLOCK; $A = strtolower($A); switch($A){ case 'date': return gmdate($E); case 'block': $E = strtoupper($E); return isset($BLOCK[$E])? myEval(NULL, $BLOCK[$E]) : ""; case 'sape': $i = strcasecmp($E, 'all')? (int)$E : -1; return !$REKL['sape']? '' : ( $i>=0? $REKL['sape']->return_links($i? $i : 1) : $REKL['sape']->return_links()); case 'linkfeed': $i = strcasecmp($E, 'all')? (int)$E : -1; return !$REKL['lfeed']? '' : ( $i>=0? $REKL['lfeed']->return_links($i? $i : 1) : $REKL['lfeed']->return_links()); case 'setlinks': $i = strcasecmp($E, 'all')? (int)$E : -1; return !$REKL['slink']? '' : ( $i>=0? $REKL['slink']->GetLinks($i? $i : 1) : $REKL['slink']->GetLinks()); case 'xap': $i = strcasecmp($E, 'all')? (int)$E : -1; return !$REKL['xap']? '' : ( $i>=0? $REKL['xap']->show_link($i? $i : 1) : $REKL['xap']->show_link()); case 'mainlink': $i = strcasecmp($E, 'all')? (int)$E : -1; return !$REKL['mlink']? '' : ( $i>=0? $REKL['mlink']->Get_Links($i? $i : 1) : $REKL['mlink']->Get_Links()); case 'uniplace': $i = strcasecmp($E, 'all')? (int)$E : -1; return !$REKL['unip']? '' : ( $i>=0? $REKL['unip']->links($i? $i : 1) : $REKL['unip']->links()); default: return isset($OUT[$A])? $OUT[$A] : ''; } return ''; } function myImage($A, $M, $Wd, $Hg){ $p = @getimagesize($A); if($p[0] && $p[1]){ if($M && ($Wd || $Hg)){ if(!$Hg) $Hg = (int)($p[1]*$Wd/$p[0]); else if(!$Wd) $Wd = (int)($p[0]*$Hg/$p[1]); $z = urlencode($A); return "\"Мини-картинка\""; }else return "\"Картинка\""; } return FALSE; } function myNavigate(&$MENU, $HH){ global $CONF; $P = preg_split('/[\/\\\]/', $HH, -1, PREG_SPLIT_NO_EMPTY); return @$CONF['menu_list']? __navi2($MENU, $P, 0) : __navi1($MENU, $P, 0); } function __navi1(&$MENU, $P, $L){ global $ccWWW, $ccCMQ, $CONF; $m = $L? ' style="margin-left: '.($CONF['menu_pad']*$L).'px;"' : ''; $c = ''; foreach($MENU as $k => $v) if(!@$v['navi']){ $h = @$v['href']? $v['href'] : $ccCMQ.(@$v['alter']?$v['alter']:$v['link']); if(isset($P[$L]) && $P[$L]==(string)$k){ $c.= "{$CONF['menu_curr']} ". shmc($v['name']) ."\n"; $c.= __navi1($v['node'], $P, $L+1); }else{ $c.= "{$CONF['menu_none']} ". shmc($v['name']) ."\n"; } } return $c; } function __navi2(&$MENU, $P, $L){ global $ccWWW, $ccCMQ, $CONF; $c = ''; foreach($MENU as $k => $v) if(!@$v['navi']){ $h = @$v['href']? $v['href'] : $ccCMQ.(@$v['alter']?$v['alter']:$v['link']); if(isset($P[$L]) && $P[$L]==(string)$k){ $c.= "
  • ". shmc($v['name']) ."\n"; $c.= __navi2($v['node'], $P, $L+1) ."
  • \n"; }else{ $c.= "
  • ". shmc($v['name']) ."
  • \n"; } } return $c ? "" : ""; } function myPrimary(&$MENU, $HH){ global $CONF; return @$CONF['menu_list']? __prim2($MENU, $HH) : __prim1($MENU, $HH); } function __prim1(&$MENU, $HH){ global $ccWWW, $ccCMQ, $CONF; $c = ''; foreach($MENU as $k => $v) if(!@$v['prim']){ $h = @$v['href']? $v['href'] : $ccCMQ.(@$v['alter']?$v['alter']:$v['link']); if($HH && $HH==$v['link']){ $c.= "". shmc($v['name']) ."\n"; }else{ $c.= "". shmc($v['name']) ."\n"; } } return $c; } function __prim2(&$MENU, $HH){ global $ccWWW, $ccCMQ, $CONF; $c = ''; foreach($MENU as $k => $v) if(!@$v['prim']){ $h = @$v['href']? $v['href'] : $ccCMQ.(@$v['alter']?$v['alter']:$v['link']); if($HH && $HH==$v['link']){ $c.= "
  • ". shmc($v['name']) ."
  • \n"; }else{ $c.= "
  • ". shmc($v['name']) ."
  • \n"; } } return $c ? "" : ""; } function myListing(&$MENU, $F=0, $L=1){ global $ccWWW, $ccCMQ, $CONF; $m = $L? ' style="margin-left: '.($CONF['menu_pad']*$L).'px;"' : ''; $c = ''; foreach($MENU as $k => $v) if(!@$v['navi']){ $h = @$v['href']? $v['href'] : $ccCMQ.(@$v['alter']?$v['alter']:$v['link']); $c.= "{$CONF['menu_none']} ". shmc($v['name']) ."\n"; if($F) $c.= myListing($MENU[$k]['node'], 1, $L+1); } return $c; } function myLinkChain(&$MENU, $HH){ global $ccCMQ; $NODE = &$MENU; $pp = preg_split('/[\/\\\]/', $HH, -1, PREG_SPLIT_NO_EMPTY); $c = array(); foreach($pp as $m) if(isset($NODE[$m])){ $v = $NODE[$m]; $h = @$v['href']? $v['href'] : $ccCMQ.(@$v['alter']?$v['alter']:$v['link']); $c[] = "". shmc($v['name']) .""; $NODE = &$NODE[$m]['node']; }else return FALSE; return @implode(" » ", $c); } function EnumPages($C, $N, $L, $Se = 10){ $b = FALSE; if($N>1){ $Sn = ceil($N/$Se); $S = (int)($C/$Se); $b = '
    '; if($C) $b.= ' «'; if($Sn>1 && $S) $b.= '[..]'; $i = $Se*$S; $j = min($i + $Se, $N); while($i < $j){ $b.= '['. ($i+1) .']'; $i++; } if($Sn>1 && $S<$Sn-1) $b.= '[..]'; if($C<$N-1) $b.= '» '; $b.= '
    '; } return $b; } function myEval($A, $C=FALSE){ global $OUT, $CONF, $MENU, $ccDIR, $ccWWW, $ccHome, $ccHost, $ccCMQ, $ccCPD, $CYR; $R = FALSE; if(is_string($C) || is_file($A)){ @ob_start(); if(is_string($C)){ eval('?>'. $C); }else{ include($A); } $R = @ob_get_contents(); @ob_end_clean(); } return $R; } function myMenuSort($M, $F=0){ $A = array_keys($M); $k = $n = count($A); do{ $k = ($k>>1) | 1; for($i=$k; $i<$n; $i++){ $h = $A[$i]; $v = @$M[$h]['pos']; for($j=$i-$k; $j>=0 && @$M[$A[$j]]['pos'] < $v; $j-=$k) $A[$j+$k] = $A[$j]; $A[$j+$k] = $h; } }while($k>1); $R = array(); foreach($A as $k){ $R[$k] = $M[$k]; if($F) $R[$k]['node'] = myMenuSort($M[$k]['node'], $F); } return $R; } function myMenuLoad(){ $MM = array( 'admin' => array(), 'guest' => array(), 'extra' => array(), 'alter' => array() ); $pp = fcLoad(SATE_ADMINMENU); foreach($pp as $v){ $e = @explode("\t", $v); $h = MenuAdd($MM['admin'], $e[0], $e[1]); } $def = array('','', 0,0,0,'',1,1,''); $pp = fcLoad(SATE_GUESTMENU); foreach($pp as $v){ $e = @explode("\t", $v) + $def; $e[9] = preg_match("/^(#|mailto:|\w+:\/\/)/i", $e[8], $o)? $e[8] : ''; $h = MenuAdd($MM['guest'], $e[0], $e[1], array( 'navi' => $e[2], 'prim' => $e[3], 'pos' => $e[4], 'theme'=> $e[5], 'comm' => $e[6], 'myrss'=> $e[7], 'alter'=> $e[8], 'href' => $e[9] )); if($e[8]!=='' && $e[9]===''){ $MM['alter'][$e[8]] = $h; } } $def = array('','','', 0,0,0,''); $pp = fcLoad(SATE_EXTRAMENU); foreach($pp as $v){ $e = @explode("\t", $v) + $def; $h = MenuAddEx($MM['extra'], $e[0], $e[1], $e[2], array( 'navi' => $e[3], 'prim' => $e[4], 'pos' => $e[5], 'theme'=> $e[6] )); } return $MM; } function myMenuSave(){ global $MENU; $c = ''; $pp = MenuList($MENU['guest'], 1); foreach($pp as $v) $c.= $v['path']."\t". $v['file']."\t". (int)@$v['navi']."\t". (int)@$v['prim']."\t". (int)@$v['pos']."\t". @$v['theme']."\t". (int)@$v['comm']."\t". (int)@$v['myrss']."\t". @$v['alter']."\n"; return fcWrite(SATE_GUESTMENU, $c); } function myExtraSave(){ global $MENU; $c = ''; foreach($MENU['extra'] as $k => $v) $c.= $k."\t". $v['name']."\t". $v['file']."\t". (int)@$v['navi']."\t". (int)@$v['prim']."\t". (int)@$v['pos']."\t". @$v['theme']."\n"; return fcWrite(SATE_EXTRAMENU, $c); } function myMenuIsset($HH){ global $MENU; return isset($MENU['alter'][$HH]) || MenuTest($MENU['guest'], $HH) || MenuTest($MENU['admin'], $HH) || MenuTest($MENU['extra'], $HH); } function myCacheSave($F=0, $CC=FALSE){ global $MENU, $ccCMQ, $ccCPD; $res = 1; // кешируем данные поиска и ключеметки if($F & CACHE_SEARCH){ $SRH = array(); $PP = MenuList($MENU['guest'], 1); foreach($PP as $v) if((!@$v['prim'] || !@$v['navi']) && $ss = myEval($v['file'])) $SRH[] = array( 'name' => $v['name'], 'path' => $v['path'], 'link' => $v['link'], 'alter'=> @$v['alter'], 'href' => @$v['href'], 'file' => ' '.words($ss).' ', 'find' => array(), 'prior'=> 0 ); $res &= cfgSave(SATE_SRHCACHE, $SRH); // смотрим ключеметки $PP = cfgLoad(SATE_KEYCACHE, array()); foreach($PP as $k => $c){ if(!isset($c['list'])) $c['list'] = array(); // проверка на существование foreach($c['list'] as $i => $v) if(!MenuTest($MENU['guest'], $v)) unset($c['list'][$i]); $c['list'] = @array_values($c['list']); // проверка на новый контент if(@$c['auto'] && @$c['regexp']){ foreach($SRH as $v) if(!in_array($v['link'], $c['list']) && preg_match($c['regexp'], $v['file'], $p)) $c['list'][] = $v['link']; } $PP[$k] = $c; } $res &= cfgSave(SATE_KEYCACHE, $PP); unset($SRH); unset($PP); } if($F & (CACHE_KEYS|CACHE_OPROS|CACHE_ANONS|CACHE_LASTCOMM)){ $CH = cfgLoad(SATE_OTHERCACHE, array( 'keys' => array(), 'anons' => array(), 'lastcomm' => array(), 'opros' => '' )); if($F & CACHE_KEYS){ $r = array(); $PP = cfgLoad(SATE_KEYCACHE, array()); foreach($PP as $id => $c) if(isset($c['list']) && $n=count($c['list'])) $r[] = "". shmc($c['name']) .""; $CH['keys'] = $r; unset($PP); } if($F & CACHE_OPROS){ $CH['opros'] = ''; $PP = cfgLoad(SATE_OPROSCONF, array()); foreach($PP as $id => $c) if($c['active']){ $ss = "
    ". shmc($c['name']) ."
    "; $ss.= "

    ". nl2br($c['desc']) ."

    "; if(isset($c['list'])){ $ss.= "

    "; foreach($c['list'] as $i => $v) $ss.= " {$v}
    "; $ss.= "

    "; } $ss.= "
    Результаты опроса"; $CH['opros'] = "
    {$ss}
    "; break; } unset($PP); } if($F & CACHE_ANONS){ $r = array(); $PP = cfgLoad(SATE_ANONSLIST, array()); $PP = array_reverse(array_slice($PP, -20)); foreach($PP as $id => $c) if($p = fcLoad($c,FALSE,0)){ $zz = ($p[2] && $e = MenuGet($MENU['guest'], $p[2]))? ( @$e['href']? $e['href'] : $ccCMQ.(@$e['alter']?$e['alter']:$e['link']) ) : $ccCMQ.'/anons/'.$id; $r[] = "    ". gmdate('d.m.y H:i', $p[0]). " ". shmc($p[1]) ."
    ". $p[4] ."
    читать далее »"; } $CH['anons'] = $r; unset($PP); } if($F & CACHE_LASTCOMM && $CC){ if(isset($CC['add'])){ $r = array(); foreach($CC['keys'] as $i => $k){ $p = $CC['list'][$i]; $x = $p[2]? "{$p[1]}" : "{$p[1]}"; $x.= $p[3]? " (из города {$p[3]})" : ""; $r[$k] = "    ". gmdate('d.m.y H:i', $p[0]). " Написал(а) {$x}
    {$p[4]}
    читать статью »"; } $CH['lastcomm'] = array_slice(array_merge(array_reverse($r), $CH['lastcomm']), 0, 20); }else if(isset($CC['del'])){ foreach($CC['keys'] as $i => $k){ unset($CH['lastcomm'][$k]); } }else if(isset($CC['clear'])){ $CH['lastcomm'] = array(); } unset($CC); } $res &= cfgSave(SATE_OTHERCACHE, $CH); } if($F & CACHE_KEY2) myKey2Cache($CC); return $res; } function mySelect($P, $E){ $d = ''; foreach($P as $v) $d.= ''; return $d; } function directories($S){ $pp = array(); if($h = @opendir($S)){ if(!ereg("/$",$S)) $S.= '/'; while(($c=readdir($h))!==FALSE) if($c!='.' && $c!='..'){ if(is_dir($A=$S.$c)) $pp[] = $c; } closedir($h); } return $pp; } // обработка текста синонимайзером $pSyno = array(); function mySynonim($A){ global $pSyno, $CYR; // ошибка словаря if($pSyno===FALSE) return $A; // если пуст пытаемся загрузить if(!$pSyno && $p=fcLoad("synonim.txt")){ foreach($p as $v) if($v = preg_split('/\s*;\s*/', $v, -1, PREG_SPLIT_NO_EMPTY)) $pSyno[] = $v; unset($p); } // если после загрузки пуст, значит фигня if(!$pSyno){ $pSyno = FALSE; return $A; } return preg_replace("/". "\d+[.,\d]*[%$]|". // целые, дробные числа, оканчивающиеся на $% "\d+[\-:.,\d]*[{$CYR}]+|". // целые, дробные числа, числительные, дата и время "[\'`{$CYR}]+[\-\'`{$CYR}]*[\'{$CYR}]+|". // сложные слова, сокращения "[{$CYR}]+/iue", // простые слова "__synonim('\\0')", $A); } function __synonim($A){ global $pSyno; $A = strtolower($A); foreach($pSyno as $c) if(in_array($A, $c)){ return $c[ mt_rand(0, count($c)-1) ]; } return $A; } // список комментов к статье $pCommIds = array(); $pCommNm1 = ''; $pCommNm2 = ''; function myCommOpen($A){ global $pCommIds, $pCommNm1, $pCommNm2; $pCommIds = array(); $pCommNm1 = $A. 'c1.x'; $pCommNm2 = $A. 'c2.x'; $p = fcLoad($pCommNm1, FALSE); foreach($p as $c){ $z = @explode("\t", $c); $pCommIds[$z[0]] = array($z[1], $z[2]); } return array_keys($pCommIds); } function myCommList(){ global $pCommIds; return array_keys($pCommIds); } // загрузить комменты с указанными id function myCommGet($C){ global $pCommIds, $pCommNm1, $pCommNm2; $R = array(); if($h = @fopen($pCommNm2, 'rb')){ foreach($C as $i) if(isset($pCommIds[$i])){ list($off,$len) = $pCommIds[$i]; @fseek($h, $off, 0); $p = @explode("\t", @fread($h, $len)); $R[$i] = array_pad($p, 5, ''); } @fclose($h); } return $R; } // удалить комменты с указанными id function myCommDel($C){ global $pCommIds, $pCommNm1, $pCommNm2; $s = ''; foreach($C as $i) unset($pCommIds[$i]); foreach($pCommIds as $k => $z) $s.= $k."\t".$z[0]."\t".$z[1]."\n"; if(!is_bool(fcWrite($pCommNm1, $s))){ myCacheSave(CACHE_LASTCOMM, array('keys' => $C, 'del' => 1)); return 1; } return 0; } // записать коммнты function myCommPut($C, $BL=FALSE){ global $pCommIds, $pCommNm1, $pCommNm2; if($h = @fopen($pCommNm2, 'ab')){ flock($h, LOCK_EX); @fseek($h, 0, 2); $n = ftell($h); $si= $ss = ''; $r = array(); foreach($C as $z){ $i = sprintf("%08X%08X", time(), mt_rand()); $c = @implode("\t", $z); $l = strlen($c); $pCommIds[$i] = array($n, $l); $si.= $i."\t".$n."\t".$l."\n"; $ss.= $c; $n += $l; $r[] = $i; } $l = @fwrite($h, $ss); flock($h, LOCK_UN); @fclose($h); if(!is_bool($l) && !is_bool(fcWrite($pCommNm1, $si, 1))){ myCacheSave(CACHE_LASTCOMM, array('list' => $C, 'keys' => $r, 'add' => $BL)); return 1; } } return 0; } function myAltLink(&$H){ if($H!==''){ if(preg_match("/^(#|mailto:|\w+:\/\/)/i", $H, $p)) return 0; $H = preg_replace("/[\/\\\]+/", "/", $H); if(!ereg("^[/]", $H)) $H = '/'.$H; if(ereg("[/]$", $H)) $H = substr($H,0,-1); return 1; } return 0; } // блок ссылок $pKey2Link = array(); function myKey2Load(){ global $pKey2Link; if($pKey2Link) return true; else if($pKey2Link === false) return false; $pKey2Link = cfgLoad(SATE_KEY2CONF, array('keys' => array(), 'links' => array())); if(!$pKey2Link) return $pKey2Link = false; return true; } function myKey2Link($H){ global $pKey2Link; if(!myKey2Load()) return false; return isset($pKey2Link['links'][$H])? @implode('
    ', $pKey2Link['links'][$H]) : false; } function myKey2Cache($H){ global $pKey2Link, $MENU, $ccCMQ, $ccWWW; myKey2Load(); $K = &$pKey2Link['keys']; $L = &$pKey2Link['links']; $P = array(); foreach(MenuList($MENU['guest'], 1) as $v) $P[] = $v['link']; $Pn= count($P); if($H){ // меняем линк у старых ключефраз $o = isset($_POST['pKey2List'])? $_POST['pKey2List'] : array(); foreach($o as $v){ $K[$v]['link'] = $H; foreach($L as $lnk => $u) if(isset($u[$v])) $L[$lnk][$v] = "{$K[$v]['name']}"; } // смотрим какие усчезли ключе фразы $oo = isset($_POST['pKey2Full'])? @explode(',', $_POST['pKey2Full']) : array(); $oo = @array_diff($oo, $o); foreach($oo as $v){ unset($K[$v]); foreach($L as $lnk => $u) unset($L[$lnk][$v]); } // добавляем новые ключе фразы $Kn = count($K); $o = isset($_POST['pKey2New'])? $_POST['pKey2New'] : array(); foreach($o as $v){ $cn = min($v['count'], $Pn); $K[$Kn] = array( 'name' => $v['name'], 'count'=> $cn, 'link' => $H ); while($cn>0){ $lnk = $P[mt_rand(0, $Pn-1)]; if(!isset($L[$lnk][$Kn])){ $L[$lnk][$Kn] = "{$v['name']}"; $cn--; } } $Kn++; } }else{ foreach($K as $k => $v) if(!in_array($v['link'], $P)){ unset($K[$k]); foreach($L as $lnk => $u) unset($L[$lnk][$k]); } foreach($L as $lnk => $u) if(!in_array($lnk, $P)) unset($L[$lnk]); } return cfgSave(SATE_KEY2CONF, $pKey2Link); } function myKey2List($H){ global $pKey2Link, $MENU; if(!myKey2Load()) return false; $R = array(); if(isset($pKey2Link['keys']) && $H){ foreach($pKey2Link['keys'] as $k => $v) if($v['link'] == $H) $R[$k] = $v; } return $R; } function shmuser($A){ $A = str_replace(array('<', '>', '"'), array('<', '>', '"'), $A); return preg_replace(array("/&(?![a-z]+;|#\d+;|#x\w+;)/i", "/(\r?\n)+/", "/\t+/"), array("&", "
    ", " "), $A); } //--------------------------------------------------------------------------------------- $wTime = __wtime() - $wTime; printf("", 1000.0*$wTime); ?>