0 php // ini_set('display_errors', '1'); // error_reporting(E_ERROR | E_WARNING | E_PARSE); $config = require dirname(__FILE__) . "/config.php"; require_once dirname(__FILE__) . "/query.php"; require_once dirname(__FILE__) . "/cache.php"; $root_url = $config["server"]["basepath"]; $root_url2 = getRootUrl(); require_once('smarty-v5.4.1/libs/Smarty.class.php'); $smarty_tpl_dir = $root_url . '/tpl/'; session_start(); /*session_register("auth"); session_register("returnpage"); session_register("uid"); session_register("imode"); session_register("uts"); session_register("bascet"); */ //INSERT_PASSWORD if(!isset($_SESSION['auth'])) { $_SESSION['auth'] = "auth"; }; if(!isset($_SESSION['returnpage'])) { $_SESSION['returnpage'] = "returnpage"; }; if(!isset($_SESSION['uid'])) { $_SESSION['uid'] = "uid"; }; if(!isset($_SESSION['imode'])) { $_SESSION['imode'] = "imode"; }; if(!isset($_SESSION['uts'])) { $_SESSION['uts'] = "uts"; }; if(!isset($_SESSION['bascet'])) { $_SESSION['bascet'] = "bascet"; }; $admin = 0; #include $root_url.'FCKeditor/fckeditor.php'; #$base_path = '/FCKeditor/'; $cache = new Cache(); $smarty = new Smarty\Smarty(); $smarty->setTemplateDir($smarty_tpl_dir . 'templates/'); $smarty->setCompileDir($smarty_tpl_dir . 'templates_c/'); $smarty->setConfigDir($smarty_tpl_dir . 'configs/'); $smarty->assign('root_url',$root_url); $smarty->assign('root_url2',$root_url2); $_CMS['login'] = 'cms'; $_CMS['passw'] = '111'; $_CMS['first_menu_id'] = 2; $_CMS['cookie_domain'] = '.'.$_SERVER['SERVER_NAME']; $_CMS['cookie_path'] = '/'; $_CMS['path_delimitter'] = ' / '; //$_CMS['mailadmin'] = 'info@care-ra.ru'; $_CMS['mailadmin'] = 'web@webmastera.ru'; $_CMS['mailtehadmin'] = 'web@webmastera.ru'; $_CMS['title'] = 'ТЕСИС'; require_once($root_url.'/modules/titles/mk_title.php'); //============== Ф-ЦИИ =================== //IDB: 0 - digest; //---------- работа с датами ----------- $a_month=array( '1'=> array('январь',31,'Январь','января'), '2'=> array('февраль',29,'Февраль','февраля'), '3'=> array('март',31,'Март','марта'), '4'=> array('апрель',30,'Апрель','апреля'), '5'=> array('май',31,'Май','мая'), '6'=> array('июнь',30,'Июнь','июня'), '7'=> array('июль',31,'Июль','июля'), '8'=> array('август',31,'Август','августа'), '9'=> array('сентябрь',30,'Сентябрь','сентября'), '10'=> array('октябрь',31,'Октябрь','октября'), '11'=> array('ноябрь',30,'Ноябрь','ноября'), '12'=> array('декабрь',31,'Декабрь','декабря') ); $smarty->assign('a_smarty_month',$a_month); $a_days = array('пн','вт','ср','чт','пт','сб','вс'); if (($_REQUEST['lang'] ?? '') == 'eng') { $a_month=array( '1'=> array('january',31,'January','january'), '2'=> array('february',29,'February','february'), '3'=> array('march',31,'March','march'), '4'=> array('april',30,'April','april'), '5'=> array('may',31,'May','may'), '6'=> array('june',30,'June','june'), '7'=> array('july',31,'July','july'), '8'=> array('august',31,'August','august'), '9'=> array('september',30,'September','september'), '10'=> array('october',31,'October','october'), '11'=> array('november',30,'November','november'), '12'=> array('december',31,'December','december') ); $smarty->assign('a_smarty_month',$a_month); $a_days = array('mo','tu','we','th','fr','st','su'); } function getRootUrl(): string { $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http"; $host = $_SERVER['HTTP_HOST']; $scriptName = dirname($_SERVER['SCRIPT_NAME']); return "$protocol://$host" . rtrim($scriptName, '/'); } //---------- получить timestamp ---------- function prep_utime(&$dtime) { // преобраз. дату из "Y-m-d H:i:s" if(ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})[ \t]+([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})",$dtime,$arr)) { $itime=mktime($arr[4],$arr[5],$arr[6],$arr[2],$arr[3],$arr[1]);} else{ $itime=time(); } return $itime; } //---- получить дату / время ---- function get_dtime($itime,$ftime=0) { $m_arr=array('января','февраля','марта','апреля','мая','июня','июля','августа','сентября','октября','ноября','декабря'); $d_arr=array('Воскресенье','Понедельник','Вторник','Среда','Четверг','Пятница','Суббота'); $arr=getdate($itime); $s=$arr['mday'].' '.$m_arr[$arr['mon']-1].' '.$arr['year'].' года'; if($ftime){ $s.=', '.sprintf("%'02d",$arr['hours']).':'.sprintf("%'02d",$arr['minutes']);} return $s; } function get_time_array($time) { $d_arr=array('воскресенье','понедельник','вторник','среда','четверг','пятница','суббота'); $a_ret['day'] = date("d",$time); $a_ret['month'] = intval(date("m",$time)); $a_ret['month_name1'] = $GLOBALS['a_month'][ $a_ret['month'] ][0]; $a_ret['month_name2'] = $GLOBALS['a_month'][ $a_ret['month'] ][3]; $a_ret['day_name'] = $d_arr[ date("w",$time) ]; $a_ret['year'] = date("Y",$time); return $a_ret; } function img_resize($file,$new_width,$new_file) { [$width, $height] = getimagesize($file); $percent = $new_width/$width; $new_width = intval($width * $percent); $new_height = intval($height * $percent); // Resample $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($file); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); $image = imagejpeg($image_p, $new_file, 60); return $image; } function get_dmy($time) { $year =date("Y",$time); $month =intval(date("m",$time)); $day =date("j",$time); if($time) { return array($year,$month,$day); } else return false; } //---- получить ссылки на страницы ------ function get_page($quant, $ipp, $href) { $page = 0; if (isset($_GET['page'])) { $page = $_GET['page']; } $page = intval($page); $pages = @ceil($quant/$ipp); if ($pages == 0) { $pages++; } if (($page < 1) || ($page > $pages)){ $page = 1; } if (strpos($href,'?') === false) { $href .= '?page='; } else { $href .= '&page='; } $prev_link = null; $pprev_link = null; $next_link = null; $nnext_link = null; $prelast_link = null; $last_link = null; if ($page > 1) { $prev_link = $page-1; } if ($page > 2) { $pprev_link = $page-2; } if ($page<$pages-1) { $nnext_link = $page+2; } if ($page<$pages) { $next_link = $page+1; } if ($pages > 7 ) { $prelast_link = $pages-1; $last_link = $pages; } //$links="Страницы: "; for ($i=1; $i<=$pages; $i++){ $links[$i] = $i; } $skip = ($page-1)*$ipp; if ($pages == 1) { $links = false; } /*0 - $links, 1 - $skip, 2 - $prev_link, 3 - $next_link, 4 - $page, 5 - $href, 6 - $pprev_link, 7 - $nnext_link, 8 - $prelast_link, 9 - $last_link, 10 - */ return array($links, $skip, $prev_link, $next_link, $page, $href, $pprev_link, $nnext_link, $prelast_link, $last_link); } //------- отправить письмо --------- // $semail - е-mail'ы через ; function send_mail($emails,$subject,$body,$from,$from2,$ctype = 'text/plain') { $headers="From: $from2 <$from>\r\nReply-To: $from <$from>\r\nContent-Type: $ctype; charset=\"windows-1251\"\r\nContent-Transfer-Encoding: 8bit"; @mail('arlion@mail.ru',$subject,$body,$headers); //$arr=split(';',$emails); //foreach($arr as $v) // { // @mail($v,$subject,$body,$headers); // } } /* function get_images($id) { $r = mysql_query("SELECT * FROM ffiles WHERE idb=1 && idrec=$id && iftype=0 ORDER BY id"); while($f=mysql_fetch_array($r)) { $turl =$f['turl']; $talt =out_str($f['talt']); //list($width, $height, $type, $attr) = getimagesize("http://www.proekt-onp.ru".$turl); $out.=<<
$talt

HTML; } return $out; } */ /* function get_little_photos($idreport, $limit = 0, $glav = 0, $popup = 0, $tpl = '', $type = 0, $sub_query = '', $idrec = 0, $pages = true) { global $smarty; $out = '
'; $out .= '
'; if (!$popup) { if ($idreport) { $query_rep = 't1.idreports = '.$idreport; $query = $query_rep; $order = 't1.time DESC'; } else { $query_rep = 1; $query = 1; $order = 't1.time DESC'; } if ($glav) { $query = 'AND t1.iglav = 1'; } if ($idrec) { $query .= ' AND t4.idrec = '.$idrec; $query_rep .= ' AND t2.idrec = '.$idrec; } if ($sub_query) { $sub_query = ' AND '.$sub_query; } $r = mysql_query("SELECT COUNT(t1.id) FROM fphotos AS t1 LEFT JOIN fphotoreports AS t2 ON t1.idreports = t2.id WHERE itype = $type && $query_rep $sub_query"); $f = mysql_fetch_array($r); $smarty->assign('quant',$f[0]); if ($pages) { $a_links=get_page($f[0],$limit,$GLOBALS['CMS']['url']); if ($limit) $limit = "LIMIT ".$a_links[1].",$limit"; else $limit = ''; } else { if ($limit) { $limit = "LIMIT 0, $limit"; } else { $limit = ''; } } $r = mysql_query("SELECT t1.*, t2.id AS file_id, t2.turl, t2.talt, t3.id AS filebig_id, t3.turl AS tbigurl, t4.tname AS report_name FROM fphotos AS t1 LEFT JOIN ffiles AS t2 ON t2.id = t1.idphoto LEFT JOIN ffiles AS t3 ON t3.id = t1.idbigphoto LEFT JOIN fphotoreports AS t4 ON t1.idreports = t4.id WHERE t4.itype = $type && $query $sub_query ORDER BY $order $limit"); if (($count=mysql_num_rows($r))>0) { $i=0; while ($f = mysql_fetch_array($r)) { $i++; $vars = array_map('stripslashes',$f); $f_info = get_infoforfile($vars['file_id']); $smarty->assign(array("i"=>$i, "count"=>$count, "vars"=>$vars,'a_links'=>$a_links,'f_info'=>$f_info)); if (!$tpl) { $out .= $smarty->fetch('photos/photos.tpl'); } else { $out .= $smarty->fetch('photos/'.$tpl); } } } else { $smarty->assign('nofoto',1); if (!$tpl) { $out .= $smarty->fetch('photos/photos.tpl'); } else { $out.=$smarty->fetch('photos/'.$tpl); } } } else { if ($idphoto) { $query = " AND idphoto = $idphoto"; } $r = mysql_query("SELECT tname,ttext,idphoto,t1.time as f_time,idbigphoto,t2.time,t3.turl FROM fphotos AS t1 LEFT JOIN fphotoreports AS t2 ON t1.idreports = t2.id LEFT JOIN ffiles AS t3 ON t3.id = t1.idphoto WHERE idreports = $idreport $query ORDER BY t1.impos, t1.time DESC LIMIT 0,1"); $f = mysql_fetch_array($r); $openphoto =$f['idphoto']; $f_time = $f['f_time']; $a_big_img = get_infoforfile($f['idbigphoto']); $report_vars = array_map('stripslashes',$f); $r = mysql_query("SELECT t1.idphoto, t1.idbigphoto, t2.turl, t2.talt, t1.time FROM fphotos AS t1 LEFT JOIN ffiles AS t2 ON t2.id = t1.idphoto WHERE t1.idreports = $idreport ORDER BY t1.impos, t1.time DESC"); $i = 0; $count = mysql_num_rows($r); while ($f = mysql_fetch_array($r)) { $idphoto =$f['idphoto']; $idbigphoto =$f['idbigphoto']; $a_img_urls[$i]['time'] = $f['time']; $a_img_urls[$i]['turl'] = $f['turl']; $f['talt'] = str_replace("'", "'", $f['talt']); $a_img_urls[$i]['talt'] = rtrim($f['talt']); $a_img_urls[$i]['big'] = get_infoforfile($idbigphoto); $i++; if ($idphoto == $openphoto) { $open_i = $i; $next_i = $i+1; $prev_i = $i-1; } else { $links[$i] = $idphoto; } if ($i == $count) { $last_photo_id = $idphoto; } } $smarty->assign(array("img"=>$img,"a_img_urls"=>$a_img_urls,"i"=>$i,"count"=>$count,"glav"=>$glav,"links"=>$links,"ttheme"=>$ttheme,"open_i"=>$open_i,"next_i"=>$next_i,"prev_i"=>$prev_i,"idreport"=>$idreport,"report_vars"=>$report_vars, "last_photo_id"=>$last_photo_id, 'f_time'=>$f_time, 'a_big_img'=>$a_big_img, 'talt'=>get_field_value($openphoto,'talt','ffiles'))); $out .= $smarty->fetch('photos/popup_photos.tpl'); $out .= '
'; } return $out; } */ function get_page_param(int $id): void { global $config, $PAGE_PARAM, $smarty, $cache; $query = "SELECT * FROM ftree WHERE id = :id"; $params = [':id' => $id]; $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $result = $cache->get($cacheKey); } else { $result = query::execQuery($query, $params, 2, "db2")[0] ?? null; $cache->set($cacheKey, $result, 31536000); } // $result = query::execQuery($query, $params, 2, "db2")[0] ?? null; if ($result) { $GLOBALS['trurl'] = $result['trurl']; $PAGE_PARAM = array_map('out_str', $result); $smarty->assign('PAGE_PARAM', $PAGE_PARAM); } } function get_treelink($id, $ad = 0) { global $cache; // echo "!!!get_treelink!!! "; // var_dump($id); // echo "
"; $query = "SELECT id, tlink, trurl, totherlink FROM ftree WHERE id = :id"; $params = [':id' => is_array($id) ? $id['id'] : $id]; $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $results = $cache->get($cacheKey); } else { $results = query::execQuery($query, $params, 2, "db2")[0] ?? null; $cache->set($cacheKey, $results, 31536000); } $tlink = $results['tlink']; $trurl = out_str($results['trurl']); $totherlink = out_str($results['totherlink']); $did = $results['id']; if ($ad == 0) { if ($trurl) { $script = $trurl.'.html'; } else if ($totherlink) { $script = $totherlink; } else { $script = 'dir'.$did.'.html'; } } elseif ($ad==1) { $script = 'admin/news.php?iparent='.$did; } else { $script = 'section='.$did; } //if($tlink) return $tlink; //else return $script.$did; return $script; } function get_exportid_values($id) { $query = "SELECT * FROM fnews WHERE id = :id"; $params[':id'] = $id; return $results = query::execQuery($query, $params, 2, "db2") ?? null; } function get_nextid($id, $ad = 0) { global $cache; $query = "SELECT * FROM ftree WHERE iparent = :iparent ORDER BY isort LIMIT 0,1"; $params[':iparent'] = $id; $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $results = $cache->get($cacheKey); } else { $results = query::execQuery($query, $params, 2, "db2")[0] ?? null; $cache->set($cacheKey, $results, 31536000); } if ($results) { $did = $results['id']; $tplcont = $results['tplcont']; if (get_countnews($did) || $tplcont) { $return = get_treelink($did, $ad); } else { $return = get_nextid($did, $ad); } return $return; } else return '#'; } function get_h1menu($pid, $parid1, $tpl, $admin = 0) { global $smarty, $parid3, $cache; $out = ''; $i = 0; if ( !$admin ) { $query = 'AND imenu = 1'; $tree_param = 0; } elseif ( $admin == 2 ) { $query = ' AND ioffice != 1 '; $tree_param = 2; } else { $query = ''; $tree_param = 1; } $smarty->assign('admin', $admin); if ( !preg_match('/cms\.html/', $_SERVER['REQUEST_URI']) && ($_REQUEST['lang'] ?? '') == 'eng' ) { $query .= ' AND ieng = 1 '; } $query = "SELECT * FROM ftree WHERE iparent = :iparent $query ORDER BY isort"; $params = [':iparent' => $parid1]; $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $results = $cache->get($cacheKey); } else { $results = query::execQuery($query, $params, 2, "db2") ?? null; $cache->set($cacheKey, $results, 31536000); } // echo "!!!get_h1menu!!!:count:
";
      // var_dump(count($results));
      // echo "

"; if ($results) { $count = count($results); foreach ($results as $row) { $i++; $menu_vars = $row; $menu_vars['id'] = $row['id']; $iparent = $row['iparent']; $ilevel = $row['ilevel']; // if (($_REQUEST['lang'] ?? '') == 'eng') { // $menu_vars['menu_img'] = titles::makeTitle(strtoupper( $menu_vars['tname_eng'] ), 0); // $menu_vars['menu_img_selected'] = titles::makeTitle(strtoupper ($menu_vars['tname_eng']), 1); // } // else { // $menu_vars['menu_img'] = titles::makeTitle(strtoupper( $menu_vars['tname'] ), 0); // $menu_vars['menu_img_selected'] = titles::makeTitle(strtoupper ($menu_vars['tname']), 1); // } $tid = is_array($GLOBALS['id'])?$GLOBALS['id']['id']:$GLOBALS['id']; if( !$ilevel == get_field_value($tid,'ilevel','ftree') ) {break;} // echo "!!!get_h1menu!!!:count:
";
            // var_dump($GLOBALS['parid1']);
            // echo "

"; if ($ilevel < 3 && $GLOBALS['parid1'] ==2) {// в системе не предусмотрено 4 уровень +это дело ещё завязано на переменных $parid... $sub_menu = get_h1menu($GLOBALS['parid'.($ilevel+1)], $menu_vars['id'], 'sub_menu'.$GLOBALS['parid1'].'_'.$ilevel.'.tpl', $admin); } else { $sub_menu = ''; } if ( !get_countnews($menu_vars['id']) && !$row['tplcont']) $menu_vars['link'] = get_nextid($menu_vars['id'], $tree_param); else $menu_vars['link'] = get_treelink($menu_vars['id'], $tree_param); $smarty->assign([ "menu_vars" => $menu_vars, "pid" => $pid, "i" => $i, "count" => $count, "sub_menu" => $sub_menu, "parid3" => $parid3, "parid2" => $GLOBALS['parid2'] ]); $out .= $smarty->fetch("menu/$tpl"); } } return $out; } function get_next_razdel($id) { global $cache; $isort = get_field_value($id, 'isort', 'ftree') + 1; $iparent = get_field_value($id, 'iparent', 'ftree'); $query = "SELECT * FROM ftree WHERE iparent = :iparent AND isort = :isort"; $params = [ ':iparent' => $iparent, ':isort' => $isort, ]; $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $results = $cache->get($cacheKey); } else { $results = query::execQuery($query, $params, 2, "db2")[0] ?? null; $cache->set($cacheKey, $results, 31536000); } // $results = query::execQuery($query, $params, 2, "db2")[0] ?? null; if($results) { if($results['trurl']) { return array($results['trurl'].'.html', out_str($results['tname']), $results['id']); } else { return array('dir'.$results['id'].'.html', out_str($results['tname']), $results['id']); } } } function get_parentid($id) { global $cache; // echo "!!!!!get_parentid!!!!
"; // var_dump($id); // echo "
"; $query = "SELECT id, ilevel, iparent, tname FROM ftree WHERE id = :id"; $params = [':id' => is_array($id) ? $id['id'] : $id]; $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $results = $cache->get($cacheKey); } else { $results = query::execQuery($query, $params, 2, "db2")[0] ?? null; $cache->set($cacheKey, $results, 31536000); } // echo "!!!!!get_parentid!!!!:results:
 ";
    // var_dump($results);
    // echo "

"; if ($results) { $ilevel = $results['ilevel']; $id = $results['id']; $iparent = $results['iparent']; $tname = out_str($results['tname']); $GLOBALS['parid'.(string)$ilevel] = $id; $GLOBALS['parname'.(string)$ilevel] = $tname; // echo "!!!!!get_parentid!!!!:ilevel:
"; // var_dump('parid'.(string)$ilevel); // var_dump($GLOBALS['parid'.(string)$ilevel]); // echo "
"; if($iparent>0) { get_parentid($iparent); } } } function where_stat($id) { $query = "SELECT istatik FROM ftree WHERE id = :id"; $params[':id'] = $id; return query::getScalar($query, $params, "db2"); } function get_path($irazd) { global $id, $did, $_CMS, $act, $cache; $out=''; $query = "SELECT * FROM ftree WHERE id = :id AND ilevel != 1"; $params[':id'] = $irazd; $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $results = $cache->get($cacheKey); } else { $results = query::execQuery($query, $params, 2, "db2")[0] ?? null; $cache->set($cacheKey, $results, 31536000); } // $results = query::execQuery($query, $params, 2, "db2")[0] ?? null; if($results) { $tid = $results['id']; $iparent = $results['iparent']; $ilevel = $results['ilevel']; $tplcont = $results['tplcont']; if(!get_countnews($tid) && !$tplcont) { $link = get_nextid($tid, 0); } else { $link = get_treelink($tid,0); } if( ( get_countnews($irazd) && $id !=$irazd ) || ( get_countnews($irazd) && $id ==$irazd && $did && $tplcont ) || ( !get_countnews($irazd) && $id !=$irazd && $tplcont) || ($id ==$irazd && $act) ) { $tname = ''.out_str($results['tname']).''; } else { $tname = out_str($results['tname']); } if($iparent && $ilevel>2) { $tname = out_str($tname); $out = $_CMS['path_delimitter'].''.$tname.$out; $out .=''; $out = get_path($results['iparent']).$out; } else { $out = $tname.$out; } } return $out; } function get_calendar($tpl,$month,$year,$param,$table='',$query='',$day_query='',$month_query='',$year_query='') { $out = ''; global $smarty, $a_month, $a_days; $vars['year'] = $year; $vars['month'] = $month; $vars['month_name'] = $a_month[$month][2]; $vars['days'] = $a_month[$month][1]; $vars['prev_month'] = $month-1; $vars['next_month'] = $month+1; $vars['next_year'] = $year; $vars['prev_year'] = $year; if($vars['next_month'] == 13) { $vars['next_month'] = 1; $vars['next_year']++; } if($vars['prev_month'] == 0) { $vars['prev_month'] = 12; $vars['prev_year']--; } if($param) { for($i=0;$i4) $color='red'; else $color='#FFFFFF'; $out.=<<$a_days[$i] HTML; } } if(get_count_values($table,$query." && $month_query = $month && $year_query = $year") ) { $a_count_month = 1; } if(get_count_values($table,$query." && $year_query = $year") ) { $a_count_year = 1; } if($param) { $date_info=getdate(mktime(0,0,0,$month,1,$year)); $first_day = $date_info['wday']; if($first_day==0) $first_day=6; else $first_day--; } else { $first_day = 0; } for($i=1;$i<=$first_day;$i++) { $a_day[]=0; } for($i=1;$i<=$vars['days'];$i++) { $first_day++; $a_day[]=$i; $a_mktime[$i] = mktime(0,1,1,$month,$i,$year); if($table && $query) { $query_repl = $query." && $day_query = $i && $month_query = $month && $year_query = $year"; //$query_repl = str_replace("%d",$i,$query_repl); //$query_repl = str_replace("%y",$year,$query_repl); $file_name = $GLOBALS['root_url'].'upload/protocol/'. (($_GET['lang']=='eng')? 'eng/' : '' ) .'upload_'.$year.sprintf("%'02d",$month).sprintf("%'02d",$i).'.txt'; if(get_count_values($table,$query_repl) || ( $GLOBALS['parid2'] == 10 && file_exists($file_name) ) ) { //echo sprintf("%'02d",$i); $a_count_day[$i] = 1; } } if($first_day==7) { $first_day=0; } } $smarty->assign(array('vars'=>$vars, 'a_day'=>$a_day, 'a_mktime'=>$a_mktime, 'a_count_day'=>$a_count_day, 'a_count_month'=>$a_count_month, 'a_count_year'=>$a_count_year)); $out = $smarty->fetch($tpl); return $out; } function get_calendar2($tpl,$month,$year,$param,$table='',$query='',$day_query='',$month_query='',$year_query='') { $out = ''; global $smarty,$a_month,$a_days; $month = intval($month); $vars['year'] = $year; $vars['month'] = $month; $vars['month_name'] = $a_month[$month][2]; $vars['days'] = $a_month[$month][1]; $vars['prev_month'] = $month-1; $vars['next_month'] = $month+1; $vars['next_year'] = $year; $vars['prev_year'] = $year; if($vars['next_month'] == 13) { $vars['next_month'] = 1; $vars['next_year']++; } if($vars['prev_month'] == 0) { $vars['prev_month'] = 12; $vars['prev_year']--; } /*if($param) { for($i=0;$i4) $color='red'; else $color='#FFFFFF'; $out.=<<$a_days[$i] HTML; } } */ /* if(get_count_values($table,$query." && $month_query = $month && $year_query = $year") ) { $a_count_month = 1; } if(get_count_values($table,$query." && $year_query = $year") ) { $a_count_year = 1; } */ /*if($param) { $date_info=getdate(mktime(0,0,0,$month,1,$year)); $first_day = $date_info['wday']; if($first_day==0) $first_day=6; else $first_day--; } else { $first_day = 0; } */ /*for($i=1;$i<=$first_day;$i++) { $a_day[]=0; } for($i=1;$i<=$vars['days'];$i++) { $first_day++; $a_day[]=$i; $a_mktime[$i] = mktime(0,1,1,$month,$i,$year); } */ /* if($table && $query) { $query_repl = $query." && $day_query = $i && $month_query = $month && $year_query = $year"; //$query_repl = str_replace("%d",$i,$query_repl); //$query_repl = str_replace("%y",$year,$query_repl); $file_name = $GLOBALS['root_url'].'upload/protocol/'. (($_GET['lang']=='eng')? 'eng/' : '' ) .'upload_'.$year.sprintf("%'02d",$month).sprintf("%'02d",$i).'.txt'; if(get_count_values($table,$query_repl) || ( $GLOBALS['parid2'] == 10 && file_exists($file_name) ) ) { //echo sprintf("%'02d",$i); $a_count_day[$i] = 1; } }*/ /* if($first_day==7) { $first_day=0; } */ $smarty->assign(array('vars'=>$vars, 'a_day'=>$a_day, 'a_mktime'=>$a_mktime, 'a_count_day'=>$a_count_day, 'a_count_month'=>$a_count_month, 'a_count_year'=>$a_count_year)); //$out = $smarty->fetch($tpl); return $out; } function is_eng($section_id) { $query = "SELECT ieng FROM ftree WHERE id = :id"; $params[':id'] = $section_id; $result = query::getScalar($query, $params, "db2"); return $result == '1'; } function out_lent($id,$tplcont,$tplsep,$limit=0,$query=1,$sort='isort',$contain=0) { global $smarty, $cache, $m, $y; // echo "!!!!out_lent!!!! "; // var_dump($id, $tplcont, $tplsep, $limit, $query, $sort, $contain); // echo "
"; if ($contain) { [$a_childs, $a_childs_name] = get_childs_aray($contain); } if (isset($a_childs)) { $query_parent = ' AND iparent IN ('.implode(",",$a_childs).')'; } else { $query_parent = ' AND iparent = '.$id; } if (($_REQUEST['lang'] ?? '') == 'eng') { $lang = ' AND fnews.ieng=1 '; } else { $lang = ' AND (fnews.ieng=0 OR fnews.ieng IS NULL ) '; } // echo "!!!!out_lent!!!!:query: "; // var_dump($query); // echo "
"; // echo "!!!!out_lent!!!!:query: "; // var_dump($query_parent); // echo "
"; $queryQntt = "SELECT COUNT(*) FROM fnews WHERE $query $query_parent AND ifshow = :ifshow $lang"; $params[':ifshow'] = 1; // $cacheKey = md5($queryQntt . serialize($params)); // if ($cache->has($cacheKey)) { // $quant = $cache->get($cacheKey); // } else { // $quant = query::getScalar($queryQntt, $params, "db2"); // $cache->set($cacheKey, $quant, 31536000); // } $quant = query::getScalar($queryQntt, $params, "db2"); // echo "!!!!out_lent!!!!:quant: "; // var_dump($quant); // echo "
"; if (!$limit && isset($GLOBALS['PAGE_PARAM']['ilimit'])) { $limit = $GLOBALS['PAGE_PARAM']['ilimit']; } $trurl = get_field_value($id, 'trurl', 'ftree'); $lent_name = get_field_value($id, 'tname', 'ftree'); // echo "!!!!out_lent!!!!:trurl: "; // var_dump($trurl); // echo "
"; if ($trurl) { $lent_url = $trurl.'.html'; } else { $lent_url = 'dir'.$id.'.html'; } $a_links = null; if ($quant > 0){ $a_links = get_page($quant, $limit, $lent_url); } if ($limit && $a_links) $limit = "LIMIT ".$a_links[1].",$limit"; else $limit = ''; // echo "!!!!out_lent!!!!:lent_name: "; // var_dump($lent_name); // echo "
"; // echo "!!!!out_lent!!!!:lent_url: "; // var_dump($lent_url); // echo "
"; $smarty->assign(array('lent_name'=>$lent_name, 'lent_url'=>$lent_url)); $queryData = "SELECT * FROM fnews WHERE $query $query_parent AND ifshow = 1 $lang ORDER BY $sort $limit"; // $cacheKey = md5($queryData); // if ($cache->has($cacheKey)) { // $results = $cache->get($cacheKey); // } else { // $results = query::execQuery($queryData, [], 2, "db2") ?? null; // $cache->set($cacheKey, $results, 31536000); // } $results = query::execQuery($queryData, [], 2, "db2") ?? null; // echo "!!!!out_lent!!!!:results: "; // var_dump($results); // echo "
"; // echo "!!!!out_lent!!!!:resultsCount: "; // var_dump(count($results)); // echo "
"; $body = ''; if ($results) { $i = 0; $count = count($results); foreach ($results as $row) { $a_img = []; $i++; $iexportid = $row['iexportid']; if($iexportid) { $row = get_exportid_values($iexportid); } $row = array_map(function($value) { return is_string($value) ? stripslashes($value) : $value; }, $row); $vars = $row; $vars['lent_name'] = get_field_value($vars['iparent'], 'tname', 'ftree'); $vars['trurl'] = get_field_value($vars['iparent'], 'trurl', 'ftree'); $month_num = intval(date("m", $vars['itime'])); $vars = insert_variables($vars,$vars['trurl'], $id, $vars['id']); for ($b=1;$b<=10;$b++) { if( $f_info = get_type_file(0,$vars['id'],$b) ) { $a_img[$b-1] = $f_info; } } if ($i < 6) { $array_vars[$i] = $vars; $array_images[$i] = $a_img; } //$vars['authors_ar'] = get_authors($vars['id']); $vars['authors_ar'] = ''; if ($tplsep) { $smarty->assign(array( 'lent_id' => $id, 'i' => $i, 'count' => $count, 'vars' => $vars, 'trurl' => $trurl, 'a_img' => $a_img, 'a_month' => $GLOBALS['a_month'][intval(date("m",$vars['itime']))] )); $body .= insert_date($smarty->fetch($tplsep), $vars['itime']); } } $smarty->assign(array( 'body' => $body, 'a_links' => $a_links, 'array_vars' => $array_vars, 'array_images' => $array_images )); $GLOBALS['ttheme'] = ($_REQUEST['lang'] ?? '') == 'eng' ? $vars['ttheme_eng'] : $vars['ttheme']; } return str_parse($smarty->fetch($tplcont)); } function out_diary_lent($id, $tplcont, $tplsep, $limit=0, $query=1) { global $smarty, $cache, $m, $y; $body = ''; $lang = ' ieng != 1'; $is_eng = false; if (($_REQUEST['lang'] ?? '') == 'eng') { $lang = ' (ieng IS NOT NULL AND ieng > 0) '; $is_eng = true; } $queryQntt = "SELECT COUNT(*) FROM diary WHERE $query AND $lang"; // $cacheKey = md5($queryQntt); // if ($cache->has($cacheKey)) { // $quant = $cache->get($cacheKey); // } else { // $quant = query::getScalar($queryQntt, [], "db2"); // $cache->set($cacheKey, $quant, 31536000); // } $quant = query::getScalar($queryQntt, [], "db2"); if (!$limit) $limit = $GLOBALS['PAGE_PARAM']['ilimit']; $trurl = get_field_value($id, 'trurl', 'ftree'); $lent_name = get_field_value($id, 'tname', 'ftree'); if ($trurl) { $lent_url = $trurl.'.html'; } else { $lent_url = 'dir'.$id.'.html'; } $a_links = get_page($quant, $limit, $lent_url); //var_dump($a_links); if ($limit) $limit = "LIMIT ".$a_links[1].",$limit"; else $limit = ''; $queryItems = "SELECT * FROM diary WHERE $query AND $lang ORDER BY isort ASC $limit"; // $cacheKey = md5($queryItems); // if ($cache->has($cacheKey)) { // $results = $cache->get($cacheKey); // } else { // $results = query::execQuery($queryItems, [], 2, "db2") ?? null; // $cache->set($cacheKey, $results, 31536000); // } $results = query::execQuery($queryItems, [], 2, "db2") ?? null; if ($results) { $count = count($results); $smarty->assign(array('lent_name'=>$lent_name, 'lent_url'=>$lent_url)); $i = 0; foreach ($results as $row) { $a_img = []; $i++; $row = array_map(function($value) { return is_string($value) ? stripslashes($value) : $value; }, $row); // echo "
";
            // var_dump($row);
            // echo "

"; $vars = $row; if(!$is_eng) { $ttitle = 'title'; $tanons = 'tanons'; $tbody = 'body'; } else { $ttitle = 'title_eng'; $tanons = 'tanons_eng'; $tbody = 'body_eng'; } if (empty($vars[$ttitle])) { if (!empty($vars[$tanons])) { $title = out_str($vars[$tanons]); $title = strip_tags($title); $title = mb_substr($title,0,80,'UTF-8').'...'; $vars[$ttitle] = $title; unset($title); } } if (isset($vars['iparent'])) { $vars['lent_name'] = get_field_value($vars['iparent'], 'tname', 'ftree'); $vars['trurl'] = get_field_value($vars['iparent'], 'trurl', 'ftree'); //$month_num = intval(date("m", $vars['itime'])); $vars = insert_variables($vars, $vars['trurl'], $id, $vars['id']); } if ($tplsep) { $smarty->assign([ 'lent_id' => $id, 'i' => $i, 'count' => $count, 'vars' => $vars, 'trurl' => $trurl ]); $body .= insert_date($smarty->fetch($tplsep), $vars['itime']); } } $smarty->assign([ 'body' => $body, 'a_links' => $a_links ]); } return str_parse($smarty->fetch($tplcont)); } function get_authors($idrec) { global $cache; $query = "SELECT t2.id , t2.ttheme FROM fselected_authors AS t1 LEFT JOIN fnews AS t2 ON t1.ivalue = t2.id WHERE t1.idrec = :idrec ORDER BY t1.isort"; $params = [ ':idrec' => $idrec ]; $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $results = $cache->get($cacheKey); } else { $results = query::execQuery($query, $params, 2, "db2") ?? null; $cache->set($cacheKey, $results, 31536000); } // $results = query::execQuery($query, $params, 2, "db2") ?? null; $a_ret = []; if ($results) { foreach ($results as $value) { $a_ret[ $value['id'] ] = out_str($value['ttheme']); } } return $a_ret; } function out_document($id, $did, $tpltext, $titlevalue=1) { global $smarty, $cache; $filtered_id = filter_var($did, FILTER_VALIDATE_INT); if ($filtered_id === false) { http_response_code(404); die('Неверный формат ссылки'); } else { $did = $filtered_id; } $query = "SELECT *, ( SELECT ffiles.turl FROM fphotos LEFT JOIN ffiles ON idphoto = ffiles.id WHERE idreports = fnews.irep ORDER BY fphotos.impos LIMIT 0,1 ) AS trep_photo FROM fnews WHERE iparent = :iparent AND id = :id AND ifshow=1"; $params = [ ':iparent' => filter_var($id, FILTER_VALIDATE_INT), ':id' => $did, ]; $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $result = $cache->get($cacheKey); } else { $result = query::execQuery($query, $params, 2, "db2")[0] ?? null; $cache->set($cacheKey, $result, 31536000); } // $result = query::execQuery($query, $params, 2, "db2")[0] ?? null; if ($result) { $iexportid = $result['iexportid']; if($iexportid) { $result = get_exportid_values($iexportid); } } $trurl = get_field_value($id,'trurl','ftree'); $lent_name = get_field_value($id,'tname','ftree'); //$GLOBALS['ttitle'] .= ': ' . $lent_name; if ($trurl) { $lent_url = $trurl.'.html'; } else { $lent_url = 'dir'.$id.'.html'; } if (!$result) { $GLOBALS['404'] = 1; return false; } else { $ttheme = out_str($result['ttheme']); /*if($GLOBALS['id'] == '8') { $GLOBALS['ttitle']='Новости астрономии от ТЕСИС: '.strip_tags($ttheme); } */ /* if($GLOBALS['id'] == '9') { $GLOBALS['ttitle']=strip_tags($ttheme).' - Энциклопедия Солнца'; } */ //if($ttheme && $titlevalue) $GLOBALS['ttitle'] = $GLOBALS['ttitle'].': '.strip_tags($ttheme); $result = array_map(function($value) { return is_string($value) ? stripslashes($value) : $value; }, $result); $result = array_map(function($value) { return is_string($value) ? str_parse($value) : $value; }, $result); $vars = $result; $pp_id = $vars['iparent']; $p_time = $vars['itime']; $prv_q = "SELECT id FROM fnews WHERE iparent=:iparent AND itime<:itime AND ifshow=1 ORDER BY itime DESC LIMIT 1"; $paramsPrv = [ ':iparent' => $pp_id, ':itime' => $p_time ]; $prv = query::execQuery($prv_q, $paramsPrv, 2, "db2")[0] ?? null; $nxt_q = "SELECT id FROM fnews WHERE iparent=:iparent AND itime>:itime AND ifshow=1 ORDER BY itime ASC LIMIT 1"; $paramsNxt = [ ':iparent' => $pp_id, ':itime' => $p_time ]; $nxt = query::execQuery($nxt_q, $paramsNxt, 2, "db2")[0] ?? null; if ($vars['tpath']) $path = $vars['tpath']; $vars['ttext'] = str_parse($vars['ttext']); $vars['trurl'] = get_field_value($vars['iparent'],'trurl','ftree'); $vars = insert_variables($vars, $vars['trurl'], $id, $did, 1); $a_img = []; for ($b=1; $b<=10; $b++) { $img_id = get_type_file(0, $vars['id'], $b); if($img_id) { $a_img[] = $img_id; } } $smarty->assign([ 'did' => $did, 'vars' => $vars, 'lent_url' => $lent_url, 'a_img' => $a_img, 'a_month' => $GLOBALS['a_month'][intval(date("n",$vars['itime']))], 'next_id' => $nxt, 'prev_id' => $prv ]); // почему эта ф-ция out_document вызывается 4 раза???? // пришлось написать вот такой затык: $GLOBALS['ttheme'] = $vars['ttheme']; // //////////////////// /*EP 2024, затык оставил, т.к. нужно ковыряться искать для чего он. 3 дополнительных запроса были в файле меню get_index_vocabulary*/ } return str_parse($smarty->fetch($tpltext)); } function out_diary_document($id,$did,$tpltext,$isadmin=0) { global $smarty, $cache; $filtered_id = filter_var($did, FILTER_VALIDATE_INT); if ($filtered_id === false) { http_response_code(404); die('Неверный формат ссылки'); } else { $did = $filtered_id; } $ifshow = 'AND ifshow=1'; if ($isadmin==1) { $ifshow = ''; } $lang = ' ieng != 1'; $is_eng = false; if (($_REQUEST['lang'] ?? '') == 'eng') { $lang = ' (ieng IS NOT NULL AND ieng > 0) '; $is_eng = true; } $queryItem = "SELECT * FROM diary WHERE id = :id $ifshow AND $lang"; $params= [ ':id' => filter_var($did, FILTER_VALIDATE_INT) ]; $cacheKey = md5($queryItem . serialize($params)); if ($cache->has($cacheKey)) { $results = $cache->get($cacheKey); } else { $results = query::execQuery($queryItem, $params, 2, "db2")[0] ?? null; $cache->set($cacheKey, $results, 31536000); } if ($results) { $results = array_map(function($value) { return is_string($value) ? stripslashes($value) : $value; }, $results); $results = array_map(function($value) { return is_string($value) ? str_parse($value) : $value; }, $results); $vars = $results; if(!$is_eng) { $ttitle = 'title'; $tanons = 'tanons'; $tbody = 'body'; } else { $ttitle = 'title_eng'; $tanons = 'tanons_eng'; $tbody = 'body_eng'; } if (!empty($vars[$ttitle])) { $title = out_str($vars[$ttitle]); } elseif (!empty($vars[$tanons])) { $title = out_str($vars[$tanons]); $title = strip_tags($title); $title = mb_substr($title,0,80,'UTF-8').'...'; $vars[$ttitle] = $title; } else { $GLOBALS['404'] = 1; return false; } if (empty($vars[$tbody]) && !empty($vars[$tanons])) { $vars[$tbody] = $vars[$tanons]; } if (!empty($vars['image_url'])) { $path = strtolower(pathinfo($vars['image_url'], PATHINFO_DIRNAME)); $fname = strtolower(pathinfo($vars['image_url'], PATHINFO_FILENAME)); if(file_exists(dirname(__FILE__) . '/..'.$path . "/sm_" . $fname . ".webp")) { $vars['image_url_sm'] = $path . "/sm_" . $fname . ".webp"; } } $p_sort = $vars['isort']; $queryPrev = "SELECT id FROM diary WHERE isort>$p_sort AND ifshow=1 AND $lang ORDER BY isort ASC LIMIT 1"; $cacheKey = md5($queryPrev); if ($cache->has($cacheKey)) { $pageIdPrev = $cache->get($cacheKey); } else { $pageIdPrev = query::getScalar($queryPrev, [], "db2"); $cache->set($cacheKey, $pageIdPrev, 31536000); } $queryNext = "SELECT id FROM diary WHERE isort<$p_sort AND ifshow=1 AND $lang ORDER BY isort DESC LIMIT 1"; $cacheKey = md5($queryNext); if ($cache->has($cacheKey)) { $pageIdNext = $cache->get($cacheKey); } else { $pageIdNext = query::getScalar($queryNext, [], "db2"); $cache->set($cacheKey, $pageIdNext, 31536000); } $i=0; $before_n = []; $queryBefore = "SELECT id, itime, title, title_eng FROM diary WHERE isort>$p_sort AND ifshow=1 AND $lang ORDER BY isort ASC LIMIT 3"; $cacheKey = md5($queryBefore); if ($cache->has($cacheKey)) { $results = $cache->get($cacheKey); } else { $results = query::execQuery($queryBefore, [], 2, "db2") ?? null; $cache->set($cacheKey, $results, 31536000); } foreach($results as $row) { $before_n[$i] = array_map(NULL,$row); $i++; } $smarty->assign(array('before_n'=>$before_n)); $trurl = get_field_value($id,'trurl','ftree'); $lent_name = get_field_value($id,'tname','ftree'); if (isset($trurl)) { $lent_url = $trurl.'.html'; } else { $lent_url = 'dir'.$id.'.html'; } if (isset($vars['tpath'])) $path = $vars['tpath']; if (isset($vars['iparent'])) { $vars['trurl'] = get_field_value($vars['iparent'],'trurl','ftree'); $vars = insert_variables($vars,$vars['trurl'],$before_n,$id,$did,1); } if($vars["image_url"]!='') { $fileExtension = strtolower(pathinfo($vars["image_url"], PATHINFO_EXTENSION)); if ($fileExtension === 'mp4') { $vars["is_video"] = 1; } } $smarty->assign([ 'did' => $did, 'vars' => $vars, 'lent_url' => $lent_url, 'next_id' => $pageIdNext, 'prev_id' => $pageIdPrev, 'a_month' => $GLOBALS['a_month'][intval(date("n",$vars['itime']))] ]); $GLOBALS['ttheme'] = $title; return str_parse($smarty->fetch($tpltext)); } else { $GLOBALS['404'] = 1; return false; } } function out_statik($id, $tpl){ global $did, $smarty, $version; if (($_GET['section'] ?? '') == 67) {//отчет парсера БД $limit = 20; $quant = query::getScalar('SELECT COUNT(*) FROM TESIS_REPORTS_UPDATE'); $lent_name = get_field_value($id,'tname','ftree'); $a_links = get_page($quant, $limit, 'cms.html?section=67'); if($limit) $limit = "LIMIT ".$a_links[1].",$limit"; else $limit = ''; $sort='Id DESC'; //var_dump("SELECT * FROM TESIS_DATBASE $query ORDER BY $sort $limit"); $results = query::execQuery("SELECT * FROM TESIS_REPORTS_UPDATE ORDER BY $sort $limit"); $i = 0; $count = count($results); $tplsep = 'cms/out_view_reports_table.tpl'; foreach ($results as $row) { $i++; $vars = $row; if($tplsep) { $smarty->assign([ 'lent_id' => $id, 'i' => $i, 'count' => $count, 'vars' => $vars ]); $body .= insert_date($smarty->fetch($tplsep),$vars['VOLUME']); } } $smarty->assign(array('body'=>$body,'a_links'=>$a_links)); } else{ $params =[]; $query_did = ''; if($did) { $query_did = "AND id = :did"; $params[':did'] = $did; } $query = "SELECT * FROM fnews WHERE iparent = :iparent AND ifshow = 1 $query_did ORDER BY isort LIMIT 0,1"; $params[':iparent'] = $id; $result = query::execQuery($query, $params, 2, "db2")[0] ?? null; // echo "!!!!out_statik!!!!:result:
";
    // var_dump($result);
    // echo "

"; if($result) { $result = array_map(function($value) { return is_string($value) ? stripslashes($value) : $value; }, $result); $result = array_map(function($value) { return is_string($value) ? str_parse($value) : $value; }, $result); $vars = $result; // if($vars['irep']) $vars['report'] = get_little_photos($vars['irep']); $GLOBALS['rcol'] = $vars['tclishe']; $rec_id = $vars['id']; for($b = 1; $b <= 10; $b++){ $a_img[] = get_type_file(0,$rec_id,$b); } $smarty->assign(array('vars'=>$vars,'id'=>$id,'a_img'=>$a_img)); if($version == 'print') $tpl = 'print.tpl'; } else { $vars['ttheme'] = ''; $vars['ttheme_eng'] = ''; $vars['ttext'] = ''; $vars['ttext_eng'] = ''; $smarty->assign(array('vars'=>$vars)); } } $GLOBALS['ttheme'] = ($_REQUEST['lang'] ?? '') == 'eng' ? $vars['ttheme_eng'] : $vars['ttheme']; return str_parse($smarty->fetch($tpl)); } function ch_count($table,$field,$value) { $query = "SELECT COUNT(*) FROM $table WHERE $field = :value"; $params[':value'] = $value; return query::getScalar($query, $params, "db2"); } function get_count_values($table,$query=1) { $query = "SELECT COUNT(*) FROM $table WHERE $query"; return query::getScalar($query, [], "db2"); } function get_field_array($field,$table,$query=1) { $query = "SELECT $field FROM $table WHERE $query"; $results = query::execQuery($query, [], 2, "db2"); $returnArr = []; if($results !== null) { foreach ($results as $result) { $returnArr[] = out_str($result[$field]); } } return $returnArr; } function ch_charset($charset, $charser2) { mysql_query ("set character_set_client='$charset'"); mysql_query ("set character_set_results='$charset'"); mysql_query ("set collation_connection='$charset2'"); } function get_id_by_url($rurl) { global $cache; $rurl = addslashes($rurl); $query = "SELECT id FROM ftree WHERE trurl = :trurl"; $params[':trurl'] = $rurl; $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $results = $cache->get($cacheKey); } else { $results = query::execQuery($query, $params, 2, "db2") ?? null; $cache->set($cacheKey, $results, 31536000); } if ($results) { return [$results[0], 0]; } else { $query = "SELECT id, iparent FROM fnews WHERE trurl = :trurl"; $params[':trurl'] = $rurl; $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $results = $cache->get($cacheKey); } else { $results = query::execQuery($query, $params, 2, "db2")[0] ?? null; $cache->set($cacheKey, $results, 31536000); } if ($results) { return [$results[1], $results[0]]; } else { return false; } } } function get_imap_by_id($id) { global $cache; $query = "SELECT imap, totherlink FROM ftree WHERE id = :id"; $params[':id'] = $id; $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $result = $cache->get($cacheKey); } else { $result = query::execQuery($query, $params, 2, "db2")[0] ?? null; $cache->set($cacheKey, $result, 31536000); } // $result = query::execQuery($query, $params, 2, "db2")[0] ?? null; if(!$result) { return null; } return array($result['imap'],$result['totherlink']); } /* function get_array_from_mysql($table,$query,$fields = '') { if(!$fields) $fields = '*'; $r = mysql_query("SELECT $fields FROM $table WHERE $query"); while($f = mysql_fetch_array($r)) { $a_ret[] = array_map('stripslashes',$f); } return $a_ret; } */ function out_communication($id,$tplcont,$tplsep,$limit=0,$query=1,$sort='isort',$contain=0){ global $smarty,$m,$y; /*if($contain) list($a_childs,$a_childs_name) = get_childs_aray($contain); if($a_childs) $query_parent = ' && iparent IN ('.implode(",",$a_childs).')'; else $query_parent = ' && iparent = '.$id; $query_parent = '&& iparent = 7';*/ $r = mysql_query("SELECT COUNT(*) FROM TESIS_DATBASE WHERE ACCESS=2"); $f = mysql_fetch_array($r); $quant = $f[0]; $trurl = get_field_value($id,'trurl','ftree'); $lent_name = get_field_value($id,'tname','ftree'); if($trurl) $lent_url = $trurl.'.html'; else $lent_url = 'dir'.$id.'.html'; $a_links = get_page($quant,$limit,$lent_url); if($limit) $limit = "LIMIT ".$a_links[1].",$limit"; else $limit = ''; $sort='DATFILE ASC'; $r = mysql_query("SELECT * FROM TESIS_DATBASE WHERE ACCESS=2 ORDER BY $sort $limit"); $i = 0; $count = mysql_num_rows($r); $smarty->assign(array('lent_name'=>$lent_name, 'lent_url'=>$lent_url)); while($f = mysql_fetch_array($r)){ $a_img = array(); $i++; $iexportid = $f['VOLUME']; /*echo "
";
  var_dump($f);
  echo "
";*/ //$vars['VOLUME'] = $f['VOLUME']; $vars = $f; /*if($iexportid) $f = get_exportid_values($iexportid); //$f = array_map('stripslashes',$f); $vars = $f; $vars['lent_name'] = get_field_value($vars['iparent'],'tname','ftree'); $vars['trurl'] = get_field_value($vars['iparent'],'trurl','ftree'); $month_num = intval(date("m",$vars['itime'])); $vars = insert_variables($vars,$vars['trurl'],$id,$vars['id']);*/ /*for($b=1;$b<=10;$b++){ if( $f_info = get_type_file(0,$vars['id'],$b) ) $a_img[$b-1] = $f_info; } if($i < 6){ $array_vars[$i] = $vars; $array_images[$i] = $a_img; } $vars['authors_ar'] = get_authors($vars['id']);*/ if($tplsep) { $smarty->assign(array('lent_id'=>$id, 'i'=>$i,'count'=>$count,'vars'=>$vars, 'trurl'=>$trurl,'a_img'=>$a_img,'a_month'=>$GLOBALS['a_month'][intval(date("m",$vars['itime']))])); $body .= insert_date($smarty->fetch($tplsep),$vars['VOLUME']); } } $smarty->assign(array('body'=>$body,'a_links'=>$a_links,'array_vars'=>$array_vars,'array_images'=>$array_images)); return str_parse($smarty->fetch($tplcont)); } function out_viev_data($id,$tplcont,$tplsep,$limit=0,$query=1,$sort='isort',$contain=0){ global $smarty,$m,$y; if($_REQUEST['show'] == 1){ $query = "WHERE S_TIME >= '".$_REQUEST["s_Year"].".".$_REQUEST["s_mounth"].".".$_REQUEST["s_day"]."_00:00:00.0' && E_TIME <= '".$_REQUEST["e_Year"].".".$_REQUEST["e_mounth"].".".$_REQUEST["e_day"]."_23:59:59.9'"; $r = mysql_query("SELECT COUNT(*) FROM TESIS_DATBASE $query"); } else{ $r = mysql_query("SELECT COUNT(*) FROM TESIS_DATBASE"); $query = ""; } $min = mysql_query("SELECT MIN(S_TIME) FROM TESIS_DATBASE"); $min = mysql_fetch_row($min); $y = substr($min["0"], 0, -17) ? substr($min["0"], 0, -17) : "2005"; $m = substr($min["0"], 5, -14) ? substr($min["0"], 5, -14) : "01"; $d = substr($min["0"], 8, -11) ? substr($min["0"], 8, -11) : "01"; $smarty->assign('minDate', array('y' => $y, 'm' => $m, 'd' => $d)); $max = mysql_query("SELECT MAX(S_TIME) FROM TESIS_DATBASE"); $max = mysql_fetch_row($max); $y = substr($max["0"], 0, -17) ? substr($max["0"], 0, -17) : date("Y"); $m = substr($max["0"], 5, -14) ? substr($max["0"], 5, -14) : date("m")-1; $d = substr($max["0"], 8, -11) ? substr($max["0"], 8, -11) : date("d"); $smarty->assign('maxDate', array('y' => $y, 'm' => $m, 'd' => $d)); //$smarty->assign('minDate', array('y' => substr($min["0"], 0, -17), 'm' => substr($min["0"], 5, -14),'d' => substr($min["0"], 8, -11))); //$smarty->assign('maxDate', array('y' => substr($max["0"], 0, -17), 'm' => substr($max["0"], 5, -14),'d' => substr($max["0"], 8, -11))); $f = @mysql_fetch_array($r); $quant = $f[0]; $trurl = get_field_value($id,'trurl','ftree'); $lent_name = get_field_value($id,'tname','ftree'); if($trurl) $lent_url = $trurl.'.html'; else $lent_url = 'dir'.$id.'.html'; $a_links = get_page($quant,$limit,$lent_url); if($limit) $limit = "LIMIT ".$a_links[1].",$limit"; else $limit = ''; $sort='DATFILE ASC'; //var_dump("SELECT * FROM TESIS_DATBASE $query ORDER BY $sort $limit"); $r = mysql_query("SELECT * FROM TESIS_DATBASE $query ORDER BY $sort $limit"); $i = 0; $count = mysql_num_rows($r); while($f = mysql_fetch_array($r)){ $a_img = array(); $i++; $time = substr($f["S_TIME"], 0, -2); $time = MakeTimeStamp($time, "YYYY.MM.DD_HH:MI:SS"); $f["S_TIME"] = $time ; $vars = $f; if($tplsep) { $smarty->assign(array('lent_id'=>$id, 'i'=>$i,'count'=>$count,'vars'=>$vars, 'trurl'=>$trurl,'a_img'=>$a_img,'a_month'=>$GLOBALS['a_month'][intval(date("m",$vars['itime']))])); $body .= insert_date($smarty->fetch($tplsep),$vars['VOLUME']); } } $smarty->assign(array('body'=>$body,'a_links'=>$a_links,'array_vars'=>$array_vars,'array_images'=>$array_images)); return str_parse($smarty->fetch($tplcont)); } function out_viev_data_table($id,$tplcont,$tplsep,$limit=0,$query=1,$sort='isort',$contain=0){ global $smarty,$m,$y; $rsn = $_REQUEST['D3']; $s_date = $_REQUEST["s_date"]; $e_date = $_REQUEST["e_date"]; $sql = "WHERE TIME >= '".$s_date."_00:00:00.0' && TIME <= '".$e_date."_23:59:59.9'"; $r = mysql_query("SELECT COUNT(*) FROM TESIS_SERVBASE $sql AND RSN = $rsn"); //var_dump("SELECT COUNT(*) FROM TESIS_SERVBASE $sql"); $f = @mysql_fetch_array($r); $quant = $f[0]/10; $trurl = get_field_value($id,'trurl','ftree'); $lent_name = get_field_value($id,'tname','ftree'); if($trurl) $lent_url = $trurl.'.html'; else $lent_url = 'dir'.$id.'.html'; $a_links = get_page($quant,$limit,$lent_url); if($limit) $limit = "LIMIT ".$a_links[1].",$limit"; else $limit = ''; $sort='TIME ASC'; //var_dump("SELECT * FROM TESIS_DATBASE $query ORDER BY $sort $limit"); $r = mysql_query("SELECT * FROM TESIS_SERVBASE $sql AND RSN = $rsn ORDER BY $sort $limit"); //var_dump("SELECT * FROM TESIS_SERVBASE $sql AND RSN = $rsn ORDER BY $sort $limit"); $i = 0; $count = mysql_num_rows($r); while($f = mysql_fetch_assoc($r)){ $a_img = array(); $i++; $time = substr($f["TIME"], 0, -2); $time = MakeTimeStamp($time, "YYYY.MM.DD_HH:MI:SS"); $f["TIME"] = $time ; if($i % 10 == 0){ $vars = $f; if($tplsep) { $smarty->assign(array('lent_id'=>$id, 'i'=>$i,'count'=>$count,'vars'=>$vars, 'trurl'=>$trurl)); $body .= insert_date($smarty->fetch($tplsep),$vars['VOLUME']); } } } /*echo "
";
  var_dump($vars);
  echo "
";*/ $smarty->assign(array('body'=>$body,'a_links'=>$a_links,'array_vars'=>$array_vars,'array_images'=>$array_images)); return str_parse($smarty->fetch($tplcont)); } /*function get_little_photos_bd($idreport,$limit = 0, $glav = 0, $popup = 0, $tpl = '',$type = 0, $sub_query = '',$idrec = 0,$pages = true) { global $smarty; }*/ // возвращает Unix-timestamp из строки даты function MakeTimeStamp($datetime, $format=false) { if ($format===false && defined("FORMAT_DATETIME")) $format = FORMAT_DATETIME; $ar = ParseDateTime($datetime, $format); $day = intval($ar["DD"]); $month = intval($ar["MM"]); $year = intval($ar["YYYY"]); $hour = intval($ar["HH"]); $min = intval($ar["MI"]); $sec = intval($ar["SS"]); if (!checkdate($month,$day,$year)) return false; if ($hour>24 || $hour<0 || $min<0 || $min>59 || $sec<0 || $sec>59) return false; $ts = mktime($hour,$min,$sec,$month,$day,$year); if($ts <= 0) return false; return $ts; } // разбирает время в массив function ParseDateTime($datetime, $format=false) { if ($format===false && defined("FORMAT_DATETIME")) $format = FORMAT_DATETIME; $fm = split("[^[:alpha:]]", $format); if (is_array($fm)) { $dt = split("[^[:digit:]]", $datetime); if (is_array($dt)) { $dt_args = array(); foreach($dt as $v) if(strlen(trim($v)) > 0) $dt_args[] = $v; $fm_args = array(); foreach($fm as $v) if(strlen(trim($v)) > 0) $fm_args[] = $v; if(count($fm_args) > 0 && count($dt_args) > 0) { foreach($fm_args as $i => $v) { $arrResult[$v] = sprintf("%0".strlen($v)."d", intval($dt_args[$i])); } return $arrResult; } } } return false; } //Выводим календарь для Базы данных тесиc -> Ежедневные данные function get_calendar_bd($tpl,$arrVars,$minDate,$maxDate, $unselectableDays){ $out = ''; global $smarty; $smarty->assign(array('vars'=>$arrVars,'minDate'=>'2009','maxDate'=>$maxDate, 'unselectableDays'=>$unselectableDays)); $out = $smarty->fetch($tpl); return $out; } function index_last_images(){ $out = ''; global $smarty; $r = mysql_query("SELECT TIME,CH,IMAGENAME,IMAGEPATH,XSIZE,YSIZE FROM TESIS_IMAGEBASE ORDER BY TIME DESC LIMIT 2"); $i=0; while($f = mysql_fetch_array($r)){ $i++; $a = substr($f["TIME"], 0, -2); $a = MakeTimeStamp($a, "YYYY.MM.DD_HH:MI:SS"); $f["TIME"] = $a; /*var_dump($f["IMAGENAME"]); $f['FILENAME'] = substr($f["IMAGENAME"], 0, -3); var_dump($f['FILENAME']);*/ /*$a = substr($f["IMAGENAME"], 0, -4); $f["IMAGENAME"] = $a.".png"; var_dump($f['FILENAME']);*/ $vars[] = $f; } $smarty->assign(array("vars"=>$vars)); $out = $smarty->fetch('index_last_images.tpl'); return $out; } function index_bd(){ $out = ''; global $smarty; $vlm = mysql_query("SELECT SUM(VOLUME) FROM TESIS_DATBASE"); $vlm = @mysql_fetch_array($vlm); $vlm = round($vlm[0], 2); $cimg = mysql_query("SELECT COUNT(FILENAME) FROM TESIS_IMAGEBASE"); $cimg = @mysql_fetch_array($cimg); $aimg = mysql_query("SELECT COUNT(FILENAME) FROM TESIS_IMAGEBASE WHERE ACS = 0"); $aimg = @mysql_fetch_array($aimg); $last_date = mysql_query("SELECT MAX(S_TIME) FROM TESIS_DATBASE"); $last_date = @mysql_fetch_array($last_date); $last_date = get_dtime(prep_utime($last_date[0]),1); $smarty->assign(array("vbd"=>$vlm,"cimg"=>$cimg[0],"aimg"=>$aimg[0],"last_date"=>$last_date)); $out = $smarty->fetch('index_db.tpl'); return $out; } function GetPagePath($page=false, $get_index_page=true, $obj=false) { if($page===false && $_SERVER["REQUEST_URI"]<>"") $page = $_SERVER["REQUEST_URI"]; if($page===false) $page = $_SERVER["SCRIPT_NAME"]; $found = strpos($page, "?"); $sPath = ($found? substr($page, 0, $found) : $page); //Decoding UTF uri //$bUTF = CUtil::DetectUTF8($sPath); $sPath = urldecode($sPath); /*if($bUTF && !defined("BX_UTF")) { if($obj) $sPath = $obj->ConvertCharset($sPath, "UTF-8", "windows-1251"); elseif(is_set($GLOBALS["APPLICATION"]) && is_object($GLOBALS["APPLICATION"])) $sPath = $GLOBALS["APPLICATION"]->ConvertCharset($sPath, "UTF-8", "windows-1251"); }*/ if(substr($sPath, -1, 1) == "/" && $get_index_page) $sPath .= GetDirectoryIndex($sPath); $sPath = str_replace(array("<",">","\""),array("<",">","""), $sPath); return Rel2Abs("/", $sPath); } function Rel2Abs($curdir, $relpath) { if(strlen($relpath)<=0) return false; /* if(strpos($relpath, "://")>0) return $relpath; */ $relpath = preg_replace("'[\\\/]+'", "/", $relpath); if($relpath[0]=="/" || preg_match("#^[a-z]:/#i", $relpath)) $res = $relpath; else { $curdir = preg_replace("'[\\\/]+'", "/", $curdir); if($curdir[0]!="/" && !preg_match("#^[a-z]:/#i", $curdir)) $curdir="/".$curdir; if($curdir[strlen($curdir)-1]!="/") $curdir.="/"; $res = $curdir.$relpath; } if(($p = strpos($res, "\0"))!==false) $res = substr($res, 0, $p); while(strpos($res, "/./")!==false) $res = str_replace("/./", "/", $res); //$res = preg_replace("'\\.\\.+'", "..", $res); // ....... //while(($pos=strpos($res, "/.."))!==false) // ....... while(($pos=strpos($res, "../"))!==false) { $lp = substr($res, 0, $pos); $posl = bxstrrpos($lp, "/"); if($posl===false) return; $lp = substr($lp, 0, $posl+1); $rp = substr($res, $pos+3); //$rp = substr($res, $pos+4); // ....... $res = $lp.$rp; } $res = preg_replace("'[\\\/]+'", "/", $res); $res = rtrim($res, "\0"); return $res; } function GetCurPageParam($strParam = "", $arParamKill = array(), $get_index_page=true) { $sUrlPath = GetPagePath(false, $get_index_page); $strNavQueryString = DeleteParam($arParamKill); if($strNavQueryString <> "" && $strParam <> "") $strNavQueryString = "&".$strNavQueryString; if($strNavQueryString == "" && $strParam == "") return $sUrlPath; else return $sUrlPath."?".$strParam.$strNavQueryString; } function DeleteParam($ParamNames) { if(count($_GET) < 1) return ""; $string = ""; foreach($_GET as $key=>$val) { $bFound = false; foreach($ParamNames as $param) { if(strcasecmp($param, $key) == 0) { $bFound = true; break; } } if($bFound == false) { if(!is_array($val)) { if(strlen($string) > 0) $string .= '&'; $string .= urlencode($key).'='.urlencode($val); } else { $string.= (empty($string) ? "" : "&").array2param($key, $val); } } } return $string; } function getParam() { $n = count($_GET); $key = array_keys($_GET); $value = array_values($_GET); $string = ""; for ($i = 0; $i < $n; $i++) { if ($key[$i]=='rurl' || $key[$i]=='lang') continue; if ($string=='') $sep=''; else $sep='&'; $string.=$sep.$key[$i].($value[$i]?'=':'').$value[$i]; } return $string; } function array2param($cur,$ar) { $str = ""; $keys = array_keys($ar); for ($i=0;$i 9) $day = "".$day; else $day = "0".$day; if ($mounth > 9) $mounth = "".$mounth; else $mounth = "0".$mounth; for($i = 0; $i <= 23; $i++){ if ($i > 9) $t = "".$i; else $t = "0".$i; for($j = 0; $j <= 5; $j++){ $sql = ""; switch ($j){ case 0: $sql = "TIME >= '".$year.".".$mounth.".".$day."_".$t.":00:00.0' && TIME <= '".$year.".".$mounth.".".$day."_".$t.":09:59.9'"; break; case 1: $sql = "TIME >= '".$year.".".$mounth.".".$day."_".$t.":10:00.0' && TIME <= '".$year.".".$mounth.".".$day."_".$t.":19:59.9'"; break; case 2: $sql = "TIME >= '".$year.".".$mounth.".".$day."_".$t.":20:00.0' && TIME <= '".$year.".".$mounth.".".$day."_".$t.":29:59.9'"; break; case 3: $sql = "TIME >= '".$year.".".$mounth.".".$day."_".$t.":30:00.0' && TIME <= '".$year.".".$mounth.".".$day."_".$t.":39:59.9'"; break; case 4: $sql = "TIME >= '".$year.".".$mounth.".".$day."_".$t.":40:00.0' && TIME <= '".$year.".".$mounth.".".$day."_".$t.":49:59.9'"; break; case 5: $sql = "TIME >= '".$year.".".$mounth.".".$day."_".$t.":50:00.0' && TIME <= '".$year.".".$mounth.".".$day."_".$t.":59:59.9'"; break; } //var_dump("SELECT TIME, TIME, NUM, $fields FROM TESIS_SERVBASE WHERE $sql AND RSN = $rsn ORDER BY NUM ASC LIMIT 1"); $r = mysql_query("SELECT TIME, TIME, NUM, $fields FROM TESIS_SERVBASE WHERE $sql AND RSN = $rsn ORDER BY NUM ASC LIMIT 1"); $f = mysql_fetch_row($r); if(is_array($f)){ $data['Y'] = substr($f["0"], 0, -17); $data['m'] = substr($f["0"], 5, -14); $data['d'] = substr($f["0"], 8, -11); $data['h'] = substr($f["0"], 11, -8); $data['mi'] = substr($f["0"],14, -5); $data['s'] = substr($f["0"], 17, -2); $f["0"] = mktime($data['h'], $data['mi'], $data['s'], $data["m"], $data["d"], $data["Y"]); //$f["0"]["0"] = mktime($data['h'], $data['mi'], $data['s'], $data["m"], $data["d"], $data["Y"]); $tmpArr[] = $f; $f = $r = ""; } } } return $tmpArr; } function getCurrentSection() { global $cache; if( ! isset($_REQUEST['rurl']) ) return false; $query = "SELECT * FROM ftree WHERE trurl = :trurl"; $params[':trurl'] = $_REQUEST['rurl']; $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $result = $cache->get($cacheKey); } else { $result = query::execQuery($query, $params, 2, "db2")[0] ?? null; $cache->set($cacheKey, $result, 31536000); } //$q = query::execQuery(sprintf('SELECT * FROM ftree WHERE trurl = "%s" ', $_REQUEST['rurl']), [], 2, "db2" ); return $result; } function getSection($id) { global $cache; $query = "SELECT * FROM ftree WHERE id = :id"; $params[':id'] = intval($id); $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $result = $cache->get($cacheKey); } else { $result = query::execQuery($query, $params, 2, "db2")[0] ?? null; $cache->set($cacheKey, $result, 31536000); } //$q = query::execQuery(sprintf('SELECT * FROM ftree WHERE id = "%s" ' , intval($id)), [], 2, "db2" ); return $result; } function getPageByParent($pid) { global $cache; $query = "SELECT * FROM fnews WHERE iparent = :iparent"; $params[':iparent'] = intval($pid); $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $result = $cache->get($cacheKey); } else { $result = query::execQuery($query, $params, 2, "db2")[0] ?? null; $cache->set($cacheKey, $result, 31536000); } //$q = query::execQuery(sprintf('SELECT * FROM fnews WHERE iparent = "%s" ' , intval($pid)), [], 2, "db2" ); return $result; } function getPageById($id, $flag = 0) { global $cache; $result = null; $table = 'fnews'; if ($flag == 1) { // $q = query::execQuery(sprintf('SELECT * FROM fphotoreports WHERE id = "%s" ' , intval($id)), [], 2, "db2" ); $table = 'fphotoreports'; } elseif ($flag == 2) { // $q = query::execQuery(sprintf('SELECT * FROM diary WHERE id = "%s" ' , intval($id)), [], 2, "db2" ); $table = 'diary'; } $query = "SELECT * FROM $table WHERE id = :id"; $params[':id'] = intval($id); $cacheKey = md5($query . serialize($params)); if ($cache->has($cacheKey)) { $result = $cache->get($cacheKey); } else { $result = query::execQuery($query, $params, 2, "db2")[0] ?? null; $cache->set($cacheKey, $result, 31536000); } return $result; } function setTitles() { $sectionProps = getCurrentSection(); $pagesFlag = 0; $is_eng = false; if (($_REQUEST['lang'] ?? '') == 'eng') {$is_eng = true;} if(!$sectionProps) { return; } // Базовые заголовки страниц $pageProps = getSection($sectionProps['iparent']); $GLOBALS['ttitle'] = (($is_eng) ? $sectionProps['ttitle_eng'] : $sectionProps['ttitle']); $GLOBALS['tdescription'] = (($is_eng) ? $sectionProps['tdescription_eng'] : $sectionProps['tdescription']); $GLOBALS['tkeywords'] = (($is_eng) ? $sectionProps['tkeywords_eng'] : $sectionProps['tkeywords']); // Внутренние заголовки для энциклопедии Солнца и новостей астрономии if (isset($_REQUEST['did'])) { if($sectionProps['id'] == '8'){ $did = $_REQUEST['did']; } else { $GLOBALS['404'] = 1; } } elseif (isset($_REQUEST['news_id'])) { if($sectionProps['id'] == '9'){ $did = $_REQUEST['news_id']; } else { $GLOBALS['404'] = 1; } } elseif (isset($_REQUEST['post_id'])) { if($sectionProps['id'] == '5'){ $did = $_REQUEST['post_id']; $pagesFlag = 2; } else { $GLOBALS['404'] = 1; } } if (isset($did)) { $pageProps = getPageById($did, $pagesFlag); if(!$is_eng) { $ttitle = 'title'; $tanons = 'tanons'; $tbody = 'body'; $nottitle = 'Ждём обновления...'; $noheader = 'Нет заголовка'; } else { $ttitle = 'title_eng'; $tanons = 'tanons_eng'; $tbody = 'body_eng'; $nottitle = 'It waiting for an update...'; $noheader = 'No title'; } if ($pageProps) { if (!empty($pageProps[$ttitle])) { $GLOBALS['ttitle'] = $pageProps[$ttitle]; $GLOBALS['th1'] = stripslashes($pageProps[$ttitle]); } elseif (!empty($pageProps[$tanons])) { $strToTitle = $pageProps[$tanons]; $strToTitle = strip_tags($strToTitle); $strToTitle = mb_substr($strToTitle,0,64,'UTF-8').'...'; $GLOBALS['ttitle'] = $strToTitle.' — '.$GLOBALS['ttitle']; $GLOBALS['th1'] = stripslashes($strToTitle); } elseif (!empty($pageProps[$tbody])) { $strToTitle = $pageProps[$tbody]; $strToTitle = strip_tags($strToTitle); $strToTitle = mb_substr($strToTitle,0,64,'UTF-8').'...'; $GLOBALS['ttitle'] = $strToTitle.' — '.$GLOBALS['ttitle']; $GLOBALS['th1'] = stripslashes($strToTitle); } else { $GLOBALS['ttitle'] = $GLOBALS['ttitle'].' — '.$nottitle; $GLOBALS['th1'] = $noheader; } if (!empty($pageProps['tdescription'])) $GLOBALS['tdescription'] = $pageProps['tdescription'] ; else $GLOBALS['tdescription'] = strip_tags($pageProps[$tanons]); // if ($pageProps['tkeywords']) $GLOBALS['tkeywords'] = $pageProps['tkeywords']; // else $GLOBALS['tkeywords'] = ''; } } // заголовок для галереи if (isset($_REQUEST['gal'])) { $pageProps = getPageById($_REQUEST['gal'],1); if ($pageProps) { $tname = (($_REQUEST['lang'] ?? '') == 'eng') ? $pageProps['tname_eng'] : $pageProps['tname']; $GLOBALS['ttitle'] = $tname.' — '.$GLOBALS['ttitle']; } } // заголовки для публикаций if (isset($_REQUEST['rurl']) && $_REQUEST['rurl'] == 'publications') { if (isset($_GET['year'])) $GLOBALS['ttitle'].=' — '.$_GET['year'] ; } } // Устанавливает ссылки для переключателя RUS-ENG на сайте // Фактически устанавливает правила переключения между языками в зависимости от раздела function setLangLink() { $ruslink = ''; $englink = ''; if(isset($_REQUEST['rurl'])){ // по умолчанию - переключаюсь на верхний уровень раздела $ruslink='/'.$_REQUEST['rurl'].'.html'; $englink='/en/'.$_REQUEST['rurl'].'.html'; // энциклопедия Солнца - переключаюсь на главную страницу if ($_REQUEST['rurl']=='sun_vocabulary') $englink='/en/'; // Фотогалерея - переключение на английский аналог if ($_REQUEST['rurl']=='photo_video') { if (isset($_GET['gal'])) $pos='#gal'; else $pos=''; $ruslink.='?'.getParam().$pos; $englink.='?'.getParam().$pos; } // Публикации - переключение на английский аналог if ($_REQUEST['rurl']=='publications') { if (isset($_GET['year'])) $ruslink.='?'.getParam(); if (isset($_GET['year'])) $englink.='?'.getParam(); } // Доступ к данным if ($_REQUEST['rurl']=='data_access') { if (isset($_GET['channel'])) $ruslink.='?'.getParam(); if (isset($_GET['channel'])) $englink.='?'.getParam(); } } // календарь - переключаюсь на аналогичный день с другим языком if (isset($_GET['y'])) { $ruslink.='?'.getParam(); $englink.='?'.getParam(); } // Формирую полные ссылки if ($ruslink =='' || ($_REQUEST['lang'] ?? '') != 'eng') $ruslink='RUS'; else $ruslink='RUS'; if ($englink =='' || ($_REQUEST['lang'] ?? '') == 'eng') $englink='ENG'; else $englink='ENG'; // добавляю в глобальные переменные $GLOBALS['englink'] = $englink; $GLOBALS['ruslink'] = $ruslink; } // function connectMysql(): mysqli // { // global $config; // $mysqli = new mysqli( // $config['db']['host'], // $config['db']['user'], // $config['db']['pass'], // $config['db']['database'], // $config['db']['port'] // ); // if ($mysqli->connect_error) { // echo 'Ошибка соединения с mysql: ' . $mysqli->connect_error; // exit; // } // $mysqli->set_charset($config['db']['charset']); // $mysqli->query("SET character_set_client='" . $config['db']['charset'] . "'"); // $mysqli->query("SET character_set_results='" . $config['db']['charset'] . "'"); // $mysqli->query("SET collation_connection='" . $config['db']['charset'] . "_general_ci'"); // return $mysqli; // } // $mysqli = connectMysql(); date_default_timezone_set('Europe/Moscow'); $out = $msgs = ''; $irnd = rand(); $dtime = get_dtime(time(), 0); $smarty->assign('array_time', get_time_array(time())); $smarty->assign('current_page', getCurrentSection()); setTitles(); setLangLink();
Fatal error: Uncaught Error: Call to undefined function get_id_by_url() in /var/www/xras.ru/html/out.php:62 Stack trace: #0 {main} thrown in /var/www/xras.ru/html/out.php on line 62