ExecQuery('SELECT * FROM '.$lang_pret.'tuning'); while($res=$my->FetchObject()) $tuning[$res->par] = $res->val; define('DEBUG',false); $query = $_SERVER['QUERY_STRING']!='index.php'?$_SERVER['QUERY_STRING']:$_SERVER['REDIRECT_QUERY_STRING']; //check login if(!isset($_COOKIE['user'])||empty($_COOKIE['user'])||empty($_COOKIE['hash'])) { header('Location: /'); exit(0); } //check outdated list($skoka) = $my->FetchRow('SELECT count(*) FROM personal WHERE hash="'.mysql_real_escape_string($_COOKIE['hash']).'" AND active=1'); if(!$skoka) { header('Location: /'); exit(0); } if(!empty($query)) { if(strpos($query,'=')) { parse_str($query); echo _WriteLine($table,false,$tid,$cid,$rid,$top,(int)$page); }elseif(strpos($query,'html')) { //news most likely preg_match('|(\d{4})\/(\d{2})\/(\d{2})\/(\d{2})(\d{2})(\d{2})|',$query,$m); //by date right now $my->ExecQuery('SELECT * FROM '.$lang_pret.'materials WHERE date="'.$m[1].'-'.$m[2].'-'.$m[3].' '.$m[4].':'.$m[5].':'.$m[6].'" AND dateNumRows()) echo _WriteNews($my->FetchObject()); else echo file_get_contents('../404.html'); }else { //maybe region? $qu = 'SELECT id FROM '.$lang_pret.'region WHERE name_en="'.mysql_real_escape_string($query).'" LIMIT 1'; $my->ExecQuery($qu); if($my->Error()) { if(DEBUG) echo $my->Error(); }else { if($my->NumRows()) list($rid) = $my->FetchRow(); } echo _WriteLine($table,false,$tid,$cid,$rid,$top,(int)$page); } }else { echo _WriteLine('materials'); } function _WriteNews($res) { global $root_path,$types,$pak_text,$lang; $html = _geTempl('empty','htm'); if($res->img&&file_exists($root_path.'/img/'.$res->img)) { $_img = str_replace('', '/img/'.$res->img, str_replace('', $res->foto_alt, _geTempl('news_image'))); }else $_img = ''; $contenta = explode('',$res->content); $s_r = array( '' => $res->id, '' => 'partinform', '' => 'Партинформ', '' => ' - '._get_region_name($res->region_country).'', '' => $_img, '' => _PrTime($res->date), '' => _PrDate($res->date,'d.m.Y'), '' => $res->author?$res->author:'GreensUA', '' => $res->title, '' => $res->subtitle, '' => $res->subtitle, '' => $res->content, ); $data = str_replace(array_keys($s_r),array_values($s_r),$html); $head = preg_replace('|(.*)<\/title>|im','<title>Партинформ » '.$pak_text['main_title'][$lang].'', _geTempl('head')); return replInc($head.$data._geTempl('foot')); } function _WriteLine($table,$by_date=false,$type=10,$chid=0,$reid=0,$top=false,$page=1) { //it's for lenta global $root_path,$my,$chapters,$types,$tuning,$lang_pret,$pak_text,$lang; if(empty($table)) $table = 'materials'; $table = mysql_real_escape_string($table); $typedir = $types->typetree[$type]->dir; $typename = $types->typetree[$type]->name; $limit = $tuning[$type==10?'line_news':'line_accent']; if(empty($limit)) $limit = 10; $where = 'type=31 AND m.dateFetchRow('SELECT count(*) as skoka FROM '.$lang_pret.$table.' m WHERE '.$where); $page = $page ? (int)$page : 1; if(empty($html_full)) $html_full = _geTempl('line','htm'); list($_tpl,$_div,$_img) = explode('',_geTempl('newsl')); if(empty($_tpl)) list($_tpl,$_div,$_img) = explode('',_geTempl('line')); if($skoka>$limit) $navbar = navigate($skoka,$limit,$page,'/partinform/?tid='.(int)$type.'&cid='.(int)$chid.'&rid='.(int)$reid.'&'); $qu = 'SELECT m.*,b.title as b_name,b.img as b_img FROM '.$lang_pret.$table.' m LEFT JOIN '.$lang_pret.'blogger b ON b.id=m.blogger WHERE '.$where.' ORDER BY m.date DESC'.($by_date?false:' LIMIT '.(($page-1)*$limit).','.$limit); $my->ExecQuery($qu); $ii = 0; while($res=$my->FetchObject()) { if($res->type==12 && $res->b_img && file_exists($root_path.'/blogger/imgthumb/'.$res->b_img)) { $img = str_replace('', '/blogger/imgthumb/'.$res->b_img, str_replace('', htmlspecialchars(strip_tags($res->b_name)), $_img)); }elseif($res->img&&file_exists($root_path.'/imgthumb/'.$res->img)) { //$size = getimagesize($root_path.'/imgthumb/'.$res->img); $img = str_replace('', '/imgthumb/'.$res->img, str_replace('', htmlspecialchars(strip_tags($res->foto_alt)), str_replace('', '', str_replace('', '', $_img)))); }else $img = ''; //'< ?=REGION_LINK? >' => '/catastrophe/?tid='.$res->type.($res->chapter?'&cid='.$res->chapter:'').($res->region_country?'&rid='.$res->region_country:''), $s_r = array( '' => $img, '' => $res->id, '' => _PrTime($res->date), '' => _PrDate($res->date,'d.m.Y'), '' => _get_region_dir($res->region_country), '' => _get_region_name($res->region_country), '' => '/partinform'._GetUrl($res->date), '' => strip_tags($res->title), '' => strip_tags($res->subtitle?$res->subtitle:$res->title,'
'), '' => $res->konspekt, '' => truncate($res->anons?strip_tags($res->anons):strip_tags($res->content),150), '' => 'partinform', '' => $chapters->chaptree[$res->chapter]->dir, '' => $chapters->chaptree[$res->chapter]->name, ); $html_all[] = str_replace(array_keys($s_r),array_values($s_r),$_tpl); } $items = sizeof($html_all) ? implode($_div,$html_all) : ''; if($reid) { list($subj) = $my->FetchRow('SELECT content FROM '.$lang_pret.'info WHERE id=11'); preg_match_all('|'._get_region_dir($reid).'\\s-->(?:.*?)\/h3>(.*?)