Орла
Области
Компаний
Пользователи
Галерея
Фиксированные новости
Орла
Отзывы о фирмах
Тарифы
Пользователи
Области
Банкоматы
Торговые точки
Доска объявлений
Курсы валют
Скидки
организации Орла
организации области
товары
сайты
сайты Орел
Данные
Разделы
Поиск
Поиск запросы
Статистика
Показы каталога организаций
Статистика клиенты
Пользователи
Сайты
Управление сайтом
Анкета
Аптеки
Афиша
Афиша новая
Баннеры
Бизнес >
Викторина
Голосование
Гость на сайте
Истории
Календарь событий
Каталоги >
Конкурс красоты
Конкурс аудио
Консультации
Меню
Новое на сайте
Новости >
Организации >
Программа ТВ
Публикации
Разделы сайта
Рассылка
Рестораны
Секрет фирмы >
Сервисы >
Ссылки
Тесты
Файловый менеджер
Форум
Фотогалерея
Обратная связь
Недвижимость
Новый год
Тексты
Пользователи
Юридический рейтинг
Отзывы на товары
Бан пользователей
Жалобы
Новые тесты
Коронавирус
Файловый менеджер
Имя файла
func.php
Содержимое
<?php require_once("config.inc.php"); require_once('Smarty.class.php'); require_once dirname(__FILE__)."/forum/stopwords.php"; define('ABSPATH', dirname(__FILE__) . '/'); $smarty = new Smarty; $smarty->cache_dir = ABSPATH . "template/smarty/cache"; $smarty->template_dir = ABSPATH . "template/smarty"; $smarty->compile_dir = ABSPATH. "template/smarty/templates_c"; include('mailsock.php'); $ms_email = 'admin@infoorel.ru'; //ваш e-mail адрес $ms_address = 'smtp.yandex.ru'; // адрес smtp-сервера $ms_port = 25; // РїРѕСЂС‚ (стандартный smtp - 25) $ms_login = 'admin@infoorel.ru'; // логин Рє ящику $ms_pwd = 'admin123'; // пароль Рє ящику $ms_codepage = 'utf-8'; //РєРѕРґРёСЂРѕРІРєР° РІ которой Р±СѓРґСѓС‚ уходить РїРёСЃСЊРјР°, utf-8, Windows-1251, итд... function db_connect() { global $mysql_host, $mysql_user, $mysql_pass,$mysql_dbName; $l=MYSQL_CONNECT($mysql_host, $mysql_user, $mysql_pass) OR DIE ("РќРµ РјРѕРіСѓ создать соединение "); mysql_select_db($mysql_dbName) or die("РќРµ РјРѕРіСѓ выбрать базу данных "); mysql_query("set names cp1251"); return $l; } function db_connect_strana() { global $mysql_host_strana, $mysql_user_strana, $mysql_pass_strana,$mysql_dbName_strana; $l2=MYSQL_CONNECT($mysql_host_strana, $mysql_user_strana, $mysql_pass_strana) OR DIE ("РќРµ РјРѕРіСѓ создать соединение "); mysql_select_db($mysql_dbName_strana) or die("РќРµ РјРѕРіСѓ выбрать базу данных "); // mysql_query("set names cp1251"); return $l2; } function db_connect_strana1() { global $mysql_host_strana1, $mysql_user_strana1, $mysql_pass_strana1,$mysql_dbName_strana1; $l2=MYSQL_CONNECT($mysql_host_strana1, $mysql_user_strana1, $mysql_pass_strana1) OR DIE ("РќРµ РјРѕРіСѓ создать соединение "); mysql_select_db($mysql_dbName_strana1) or die("РќРµ РјРѕРіСѓ выбрать базу данных "); // mysql_query("set names cp1251"); return $l2; } function db_connect_strana2() { global $mysql_host_strana2, $mysql_user_strana2, $mysql_pass_strana2,$mysql_dbName_strana2; $l2=MYSQL_CONNECT($mysql_host_strana2, $mysql_user_strana2, $mysql_pass_strana2) OR DIE ("РќРµ РјРѕРіСѓ создать соединение "); mysql_select_db($mysql_dbName_strana2) or die("РќРµ РјРѕРіСѓ выбрать базу данных "); mysql_query("set names cp1251"); return $l2; } function db_connect_afisha() { global $mysql_host_strana, $mysql_user_strana, $mysql_pass_strana,$mysql_dbName_strana; $l2=MYSQL_CONNECT($mysql_host_strana, $mysql_user_strana, $mysql_pass_strana) OR DIE (""); mysql_select_db($mysql_dbName_strana) or die(""); // mysql_query("set names cp1251"); return $l2; } function db_connect_afisha1() { global $mysql_host_strana1, $mysql_user_strana1, $mysql_pass_strana1,$mysql_dbName_strana1; $l2=MYSQL_CONNECT($mysql_host_strana1, $mysql_user_strana1, $mysql_pass_strana1) OR DIE (""); mysql_select_db($mysql_dbName_strana1) or die(""); mysql_query("set names cp1251"); return $l2; } function db_connect_afisha2() { global $mysql_host_strana, $mysql_user_strana, $mysql_pass_strana,$mysql_dbName_strana; $l2=MYSQL_CONNECT($mysql_host_strana, $mysql_user_strana, $mysql_pass_strana) OR DIE (""); //mysql_query("set names cp1251"); return $l2; } function db_connect_restoran() { global $mysql_host_restoran, $mysql_user_restoran, $mysql_pass_restoran,$mysql_dbName_restoran; $l=MYSQL_CONNECT($mysql_host_restoran, $mysql_user_restoran, $mysql_pass_restoran) OR DIE ("РќРµ РјРѕРіСѓ создать соединение "); mysql_select_db($mysql_dbName_restoran) or die("РќРµ РјРѕРіСѓ выбрать базу данных "); //mysql_query("set names cp1251"); return $l2; } function db_connect_restoran2() { global $mysql_host_restoran, $mysql_user_restoran, $mysql_pass_restoran,$mysql_dbName_restoran; $l=MYSQL_CONNECT($mysql_host_restoran, $mysql_user_restoran, $mysql_pass_restoran) OR DIE ("РќРµ РјРѕРіСѓ создать соединение "); mysql_select_db($mysql_dbName_restoran) or die("РќРµ РјРѕРіСѓ выбрать базу данных "); //mysql_query("set names cp1251"); return $l2; } function db_connect_orel() { global $mysql_host_orel, $mysql_user_orel, $mysql_pass_orel,$mysql_dbName_orel; $l2=MYSQL_CONNECT($mysql_host_orel, $mysql_user_orel, $mysql_pass_orel) OR DIE ("РќРµ РјРѕРіСѓ создать соединение "); mysql_select_db($mysql_dbName_orel) or die("РќРµ РјРѕРіСѓ выбрать базу данных "); mysql_query("set names cp1251"); return $l2; } function db_connect_mail() { global $mysql_host_mail, $mysql_user_mail, $mysql_pass_mail,$mysql_dbName_mail; $l=MYSQL_CONNECT($mysql_host_mail, $mysql_user_mail, $mysql_pass_mail) OR DIE ("РќРµ РјРѕРіСѓ создать соединение "); mysql_select_db($mysql_dbName_mail) or die("РќРµ РјРѕРіСѓ выбрать базу данных "); // mysql_query("set names cp1251"); return $l; } function db_connect_sph() { global $sph_host, $sph_port, $mysql_pass,$mysql_dbName; $link_sph = mysql_connect("{$sph_host}:{$sph_port}", '', ''); if (!$link_sph) { die('Ошибка соединения sphinx: ' . mysql_error()); } return $link_sph; } function sql($a, $l = "") { if ($l == "") return mysql_query($a); else return mysql_query($a, $l); } function sqlget($a) { return @mysql_fetch_array($a); } function sqlval($a, $l = "") { if ($l == "") return sqlget(sql($a)); else return sqlget(sql($a,$l)); } function sql_strana($a) { global $l; $l2=db_connect_strana2(); $r2=mysql_query($a, $l2); $l=db_connect_strana(); $r=mysql_query($a, $l); return $r; } function fetchAll( $query ) { $entry = array(); $result = mysql_query( $query ); if ($result == false) { return []; } while ( $row = mysql_fetch_assoc( $result ) ) { foreach ( $row as $key => $value ) { $temp[$key] = $value; } $entry[] = $temp; } return $entry; } function fetchAllIndex( $query, $index ) { $entry = array(); $result = mysql_query( $query ); while ( $row = mysql_fetch_assoc( $result ) ) { foreach ( $row as $key => $value ) { $temp[$key] = $value; } $entry[$row[$index]] = $temp; } return $entry; } function _my3_ ($n) { global $my_c; if ($my_c>20) return "*"; $my_c++; return '<img src=../img/s/s'.$n.'.gif>'; } //======================================================= function _myf_ ($n, $abs = 0) { global $my_c,$base_url, $abs_url; if ($my_c>20) return "*"; $my_c++; if ($abs == 1) return '<img src='.$abs_url.'img/sforum/'.$n.'.gif>'; else return '<img src='.$base_url.'img/sforum/'.$n.'.gif>'; } //======================================================= function _myf2_ ($n) { return '*0'.$n.'*'; } //======================================================= //function _my_url_topic ($s) { // $tmp=""; // if (strpos($s,"http://")===false && strpos($s,"ftp://")===false) $tmp="http://"; // return "<a href=\"".$tmp.$s."\" target=_blank>$s</a>"; //} function _my_url_topic ($s) { $tmp=""; if (strpos($s,"http://")===false && strpos($s,"ftp://")===false) $tmp="http://"; if (strpos($s, 'youtube.com/watch') === false) { return "<a href=\"" . $tmp . $s . "\" target=_blank>$s</a>"; } else { return $s; } } //======================================================= function _my_img ($img_src) { $tmp=""; $tmp2=""; $img_src=trim($img_src); $img_src=str_replace("javascript", "", $img_src); $img_src=str_replace("'", "", $img_src); $img_src=str_replace("\"", "", $img_src); // $img_src=str_replace("(", "", $img_src); // $img_src=str_replace(")", "", $img_src); // $img_src=str_replace("&", "", $img_src); //$img_src=str_replace("?", "", $img_src); // $img_src=str_replace(".php", "", $img_src); if (strpos($img_src,"http://")===false && strpos($img_src,"ftp://")===false && strpos($img_src, "https://") === false) $tmp="http://"; // if (strpos($img_src,".jpg")===false && strpos($img_src,".jpeg")===false && strpos($img_src,".gif")===false && strpos($img_src,".png")===false) $tmp2=".jpeg"; return "<img src=\"".$tmp.$img_src.$tmp2."\" border=0 class=\"img_upl\">"; } //======================================================= function slowoform($q_affix,$q_dictionary,$text) { $text=str_replace("'","",$text); $text=str_replace("\"","",$text); $text_mas=explode(" ",trim($text)); $cnt_n_mas=count($text_mas); for ($i=0;$i<$cnt_n_mas;$i++) { if (trim($text_mas[$i]) <> "") { $aff = new Affix($q_affix,$q_dictionary); $result = $aff->getWordform($text_mas[$i]); $cnt=count($result); $search_word_name[]=strtoupper($text_mas[$i]); for ($j=1;$j < $cnt;$j++) { if (trim($result[$j]) <> "") { $search_word_name[]=$result[$j]; } } } } return $search_word_name; } //======================================================== function error() { //global $admlist, $_SESSION; //if ($admlist($_SESSION[$login]) == 1000) //echo htmlspecialchars(mysql_error()); // echo "Ошибка"; } //======================================================== function getIp() { global $REMOTE_ADDR; global $HTTP_X_FORWARDED_FOR, $HTTP_X_FORWARDED, $HTTP_FORWARDED_FOR, $HTTP_FORWARDED; global $HTTP_VIA, $HTTP_X_COMING_FROM, $HTTP_COMING_FROM; global $HTTP_SERVER_VARS, $HTTP_ENV_VARS; // Get some server/environment variables values if (empty($REMOTE_ADDR)) { if (!empty($_SERVER) && isset($_SERVER['REMOTE_ADDR'])) { $REMOTE_ADDR = $_SERVER['REMOTE_ADDR']; } else if (!empty($_ENV) && isset($_ENV['REMOTE_ADDR'])) { $REMOTE_ADDR = $_ENV['REMOTE_ADDR']; } else if (!empty($HTTP_SERVER_VARS) && isset($HTTP_SERVER_VARS['REMOTE_ADDR'])) { $REMOTE_ADDR = $HTTP_SERVER_VARS['REMOTE_ADDR']; } else if (!empty($HTTP_ENV_VARS) && isset($HTTP_ENV_VARS['REMOTE_ADDR'])) { $REMOTE_ADDR = $HTTP_ENV_VARS['REMOTE_ADDR']; } else if (@getenv('REMOTE_ADDR')) { $REMOTE_ADDR = getenv('REMOTE_ADDR'); } } // end if if (empty($HTTP_X_FORWARDED_FOR)) { if (!empty($_SERVER) && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $HTTP_X_FORWARDED_FOR = $_SERVER['HTTP_X_FORWARDED_FOR']; } else if (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED_FOR'])) { $HTTP_X_FORWARDED_FOR = $_ENV['HTTP_X_FORWARDED_FOR']; } else if (!empty($HTTP_SERVER_VARS) && isset($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) { $HTTP_X_FORWARDED_FOR = $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']; } else if (!empty($HTTP_ENV_VARS) && isset($HTTP_ENV_VARS['HTTP_X_FORWARDED_FOR'])) { $HTTP_X_FORWARDED_FOR = $HTTP_ENV_VARS['HTTP_X_FORWARDED_FOR']; } else if (@getenv('HTTP_X_FORWARDED_FOR')) { $HTTP_X_FORWARDED_FOR = getenv('HTTP_X_FORWARDED_FOR'); } } // end if if (empty($HTTP_X_FORWARDED)) { if (!empty($_SERVER) && isset($_SERVER['HTTP_X_FORWARDED'])) { $HTTP_X_FORWARDED = $_SERVER['HTTP_X_FORWARDED']; } else if (!empty($_ENV) && isset($_ENV['HTTP_X_FORWARDED'])) { $HTTP_X_FORWARDED = $_ENV['HTTP_X_FORWARDED']; } else if (!empty($HTTP_SERVER_VARS) && isset($HTTP_SERVER_VARS['HTTP_X_FORWARDED'])) { $HTTP_X_FORWARDED = $HTTP_SERVER_VARS['HTTP_X_FORWARDED']; } else if (!empty($HTTP_ENV_VARS) && isset($HTTP_ENV_VARS['HTTP_X_FORWARDED'])) { $HTTP_X_FORWARDED = $HTTP_ENV_VARS['HTTP_X_FORWARDED']; } else if (@getenv('HTTP_X_FORWARDED')) { $HTTP_X_FORWARDED = getenv('HTTP_X_FORWARDED'); } } // end if if (empty($HTTP_FORWARDED_FOR)) { if (!empty($_SERVER) && isset($_SERVER['HTTP_FORWARDED_FOR'])) { $HTTP_FORWARDED_FOR = $_SERVER['HTTP_FORWARDED_FOR']; } else if (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED_FOR'])) { $HTTP_FORWARDED_FOR = $_ENV['HTTP_FORWARDED_FOR']; } else if (!empty($HTTP_SERVER_VARS) && isset($HTTP_SERVER_VARS['HTTP_FORWARDED_FOR'])) { $HTTP_FORWARDED_FOR = $HTTP_SERVER_VARS['HTTP_FORWARDED_FOR']; } else if (!empty($HTTP_ENV_VARS) && isset($HTTP_ENV_VARS['HTTP_FORWARDED_FOR'])) { $HTTP_FORWARDED_FOR = $HTTP_ENV_VARS['HTTP_FORWARDED_FOR']; } else if (@getenv('HTTP_FORWARDED_FOR')) { $HTTP_FORWARDED_FOR = getenv('HTTP_FORWARDED_FOR'); } } // end if if (empty($HTTP_FORWARDED)) { if (!empty($_SERVER) && isset($_SERVER['HTTP_FORWARDED'])) { $HTTP_FORWARDED = $_SERVER['HTTP_FORWARDED']; } else if (!empty($_ENV) && isset($_ENV['HTTP_FORWARDED'])) { $HTTP_FORWARDED = $_ENV['HTTP_FORWARDED']; } else if (!empty($HTTP_SERVER_VARS) && isset($HTTP_SERVER_VARS['HTTP_FORWARDED'])) { $HTTP_FORWARDED = $HTTP_SERVER_VARS['HTTP_FORWARDED']; } else if (!empty($HTTP_ENV_VARS) && isset($HTTP_ENV_VARS['HTTP_FORWARDED'])) { $HTTP_FORWARDED = $HTTP_ENV_VARS['HTTP_FORWARDED']; } else if (@getenv('HTTP_FORWARDED')) { $HTTP_FORWARDED = getenv('HTTP_FORWARDED'); } } // end if if (empty($HTTP_VIA)) { if (!empty($_SERVER) && isset($_SERVER['HTTP_VIA'])) { $HTTP_VIA = $_SERVER['HTTP_VIA']; } else if (!empty($_ENV) && isset($_ENV['HTTP_VIA'])) { $HTTP_VIA = $_ENV['HTTP_VIA']; } else if (!empty($HTTP_SERVER_VARS) && isset($HTTP_SERVER_VARS['HTTP_VIA'])) { $HTTP_VIA = $HTTP_SERVER_VARS['HTTP_VIA']; } else if (!empty($HTTP_ENV_VARS) && isset($HTTP_ENV_VARS['HTTP_VIA'])) { $HTTP_VIA = $HTTP_ENV_VARS['HTTP_VIA']; } else if (@getenv('HTTP_VIA')) { $HTTP_VIA = getenv('HTTP_VIA'); } } // end if if (empty($HTTP_X_COMING_FROM)) { if (!empty($_SERVER) && isset($_SERVER['HTTP_X_COMING_FROM'])) { $HTTP_X_COMING_FROM = $_SERVER['HTTP_X_COMING_FROM']; } else if (!empty($_ENV) && isset($_ENV['HTTP_X_COMING_FROM'])) { $HTTP_X_COMING_FROM = $_ENV['HTTP_X_COMING_FROM']; } else if (!empty($HTTP_SERVER_VARS) && isset($HTTP_SERVER_VARS['HTTP_X_COMING_FROM'])) { $HTTP_X_COMING_FROM = $HTTP_SERVER_VARS['HTTP_X_COMING_FROM']; } else if (!empty($HTTP_ENV_VARS) && isset($HTTP_ENV_VARS['HTTP_X_COMING_FROM'])) { $HTTP_X_COMING_FROM = $HTTP_ENV_VARS['HTTP_X_COMING_FROM']; } else if (@getenv('HTTP_X_COMING_FROM')) { $HTTP_X_COMING_FROM = getenv('HTTP_X_COMING_FROM'); } } // end if if (empty($HTTP_COMING_FROM)) { if (!empty($_SERVER) && isset($_SERVER['HTTP_COMING_FROM'])) { $HTTP_COMING_FROM = $_SERVER['HTTP_COMING_FROM']; } else if (!empty($_ENV) && isset($_ENV['HTTP_COMING_FROM'])) { $HTTP_COMING_FROM = $_ENV['HTTP_COMING_FROM']; } else if (!empty($HTTP_COMING_FROM) && isset($HTTP_SERVER_VARS['HTTP_COMING_FROM'])) { $HTTP_COMING_FROM = $HTTP_SERVER_VARS['HTTP_COMING_FROM']; } else if (!empty($HTTP_ENV_VARS) && isset($HTTP_ENV_VARS['HTTP_COMING_FROM'])) { $HTTP_COMING_FROM = $HTTP_ENV_VARS['HTTP_COMING_FROM']; } else if (@getenv('HTTP_COMING_FROM')) { $HTTP_COMING_FROM = getenv('HTTP_COMING_FROM'); } } // end if // Gets the default ip sent by the user if (!empty($REMOTE_ADDR)) { $direct_ip = $REMOTE_ADDR; } // Gets the proxy ip sent by the user $proxy_ip = ''; if (!empty($HTTP_X_FORWARDED_FOR)) { $proxy_ip = $HTTP_X_FORWARDED_FOR; } else if (!empty($HTTP_X_FORWARDED)) { $proxy_ip = $HTTP_X_FORWARDED; } else if (!empty($HTTP_FORWARDED_FOR)) { $proxy_ip = $HTTP_FORWARDED_FOR; } else if (!empty($HTTP_FORWARDED)) { $proxy_ip = $HTTP_FORWARDED; } else if (!empty($HTTP_VIA)) { $proxy_ip = $HTTP_VIA; } else if (!empty($HTTP_X_COMING_FROM)) { $proxy_ip = $HTTP_X_COMING_FROM; } else if (!empty($HTTP_COMING_FROM)) { $proxy_ip = $HTTP_COMING_FROM; } // end if... else if... // Returns the true IP if it has been found, else FALSE if (empty($proxy_ip)) { // True IP without proxy return $direct_ip; } else { $is_ip = ereg('^([0-9]{1,3}\.){3,3}[0-9]{1,3}', $proxy_ip, $regs); if ($is_ip && (count($regs) > 0)) { // True IP behind a proxy return $regs[0]; } else { // Can't define IP: there is a proxy but we don't have // information about the true IP return FALSE; } } } function top_tovar($kolich) { global $base_url, $abs_url; $cnt_best=sqlval("select count(*) from tovar,firma where tovar.id_firm=firma.id and pokaz_foto='1' and registr='1' and registr_price='1'"); srand ((float)microtime()*1000000); shuffle ($cnt_best); $best_goods=mt_rand(0, $cnt_best[0]-$kolich); $r_best_goods=sql("select tovar.id,tovar.id_firm as id_firm,tovar.name as name,firma.name as fname, grtovar_new.name as gname, grtovar_new.id as grid from tovar,firma,grtovar_new, rubrik_tovar where tovar.id_firm=firma.id and grtovar_new.id=id_rubrik and id_tovar=tovar.id and pokaz_foto='1' and firma.registr='1' and firma.registr_price='1' limit ".$best_goods.",".$kolich); if (!$r_best_goods) error(); while ($rs_best=sqlget($r_best_goods)) { $fname=strip_tags($rs_best[fname]); echo "<a href='".$abs_url."price_firm.php?id=".$rs_best['id_firm']."&id_group=".$rs_best['grid']."' target='_blank' class=\"nik\"><img src='".$abs_url."view.php?sm=true&id=".$rs_best['id']."' width=100 border=0 alt='".$rs_best['gname']." : ".$rs_best['name']." РѕС‚ ".$fname."' class=\"ramka\"><br>".$rs_best['gname']."</a><br><br>"; } } //============================================================================== function list_all_search($total,$link,$kol_page,$page,$perpage,$name_ofs, $end_list = 0, $name_page = "page"){ $min=$page-$kol_page; $max=$page+$kol_page; $ofs=intval($ofs); if(isset($_GET['like']) and $_GET['like']!=''){ $like = $_GET['like']; }else{ $like=''; } if ($min < 1) $min=1; if ($max >= ceil($total/$perpage)) $max = ceil($total/$perpage); //echo $max; if (($min) > 1) { if ($end_list == 1) { echo " <a href='".$link."&{$name_ofs}=0&{$name_page}=1&like={$like}' title='Первая'><font class='page_unsel'>1</font></a> "; } $min=$min-1; if ($min < 1) $min=1; $ofs=($min-1)*$perpage; echo " <a href='".$link."&{$name_ofs}=".$ofs."&{$name_page}=".$min."&like={$like}' title='Предыдущая'><font class='page'>...</font></a> "; $min=$min+1; } for ($i=$min; $i<=$max; $i++) { $ofs=($i - 1)*$perpage; if ($i != $page) { if ( $i == 1 ) { if ( $link == '?list=1' ) { echo " <a href='{$_SERVER['PHP_SELF']}'><font class='page_unsel'>$i</font></a> "; } else { echo " <a href='{$link}&like={$like}'><font class='page_unsel'>$i</font></a> "; } } else { echo " <a href='{$link}&{$name_ofs}=".$ofs."&{$name_page}=".$i."&like={$like}'><font class='page_unsel'>$i</font></a> "; } } else { echo "<b> <font class='page_sel'> $i </font> </b>"; } } if ($max < ceil($total/$perpage)) { $ofs=$max*$perpage; $max=$max+1; echo " <a href='".$link."&$name_ofs=".$ofs."&$name_page=".$max."&like={$like}' title='Следующая'><font class='page'>...</font></a> "; } if ($end_list == 1) { if ($max < ceil($total/$perpage)) { $ofs=(ceil($total/$perpage) - 1)*$perpage; echo " <a href='".$link."&$name_ofs=".$ofs."&$name_page=".ceil($total/$perpage)."&like={$like}' title='Последняя'><font class='page_unsel'>".ceil($total/$perpage)."</font></a> "; } } } //============================================================================== function list_all($total,$link,$kol_page,$page,$perpage,$name_ofs, $end_list = 0, $name_page = "page") { $min=$page-$kol_page; $max=$page+$kol_page; $ofs=intval($ofs); if ($min < 1) $min=1; if ($max >= ceil($total/$perpage)) $max = ceil($total/$perpage); //echo $max; if (($min) > 1) { if ($end_list == 1) { echo "<li><span><a href='".$link."&{$name_ofs}=0&{$name_page}=1' title='Первая'>1</a></span></li>"; } $min=$min-1; if ($min < 1) $min=1; $ofs=($min-1)*$perpage; echo "<li><span><a href='".$link."&{$name_ofs}=".$ofs."&{$name_page}=".$min."' title='Предыдущая'>...</a></span></li>"; $min=$min+1; } for ($i=$min; $i<=$max; $i++) { $ofs=($i - 1)*$perpage; if ($i != $page) { if ( $i == 1 ) { if ( $link == '?list=1' ) { echo "<li><span><a href='{$link}&{$name_ofs}=".$ofs."&{$name_page}=".$i."'>$i</a></span></li>"; } else { echo "<li><span><a href='{$link}'>$i</a></span></li>"; } } else { echo "<li><span><a href='{$link}&{$name_ofs}=".$ofs."&{$name_page}=".$i."'>$i</a></span></li>"; } } else { echo "<li class='active'><span><a href='#'>$i</a></span></li>"; } } if ($max < ceil($total/$perpage)) { $ofs=$max*$perpage; $max=$max+1; echo "<li><span><a href='".$link."&$name_ofs=".$ofs."&$name_page=".$max."' title='Следующая'>...</a></span></li>"; } if ($end_list == 1) { if ($max < ceil($total/$perpage)) { $ofs=(ceil($total/$perpage) - 1)*$perpage; echo "<li><span><a href='".$link."&$name_ofs=".$ofs."&$name_page=".ceil($total/$perpage)."' title='Последняя'>".ceil($total/$perpage)."</a></span></li>"; } } } function list_all_forum($total,$link,$kol_page,$page,$perpage,$name_ofs, $end_list = 0, $name_page = "page") { $min=$page-$kol_page; $max=$page+$kol_page; $ofs=intval($ofs); if ($min < 1) $min=1; if ($max >= ceil($total/$perpage)) $max = ceil($total/$perpage); $str = ''; $str.= '<div class="page-navigate"><div class="page-numbers">'; if($page>1){ $p = $page - 1; $o = $perpage*($p-1); $str.= "<div class='btn-back hidden-xs'><span><a href='".$link."&{$name_ofs}={$o}&{$name_page}={$p}'>Назад</a></span></div>";} $str.= '<ul class="page-numbers-list">'; if (($min) > 1) { if ($end_list == 1) { $str.= "<li><a href='".$link."&{$name_ofs}=0&{$name_page}=1' title='Первая'>1</a></li>"; } $min=$min-1; if ($min < 1) $min=1; $ofs=($min-1)*$perpage; $str.= "<li><a href='".$link."&{$name_ofs}=".$ofs."&{$name_page}=".$min."' title='Предыдущая'>...</a></li>"; $min=$min+1; } for ($i=$min; $i<=$max; $i++) { $ofs=($i - 1)*$perpage; if ($i != $page) { if ( $i == 1 ) { if ( $link == '?list=1' ) { $str.= "<li><a href='{$link}&{$name_ofs}=".$ofs."&{$name_page}=".$i."'>$i</a></li>"; } else{ $cl = !$page ? " class='active'" : ""; $str.= "<li $cl><a href='{$link}'>$i</a></li>"; } } else { $str.= "<li><a href='{$link}&{$name_ofs}=".$ofs."&{$name_page}=".$i."'>$i</a></li>"; } } else { $str.= "<li class='active'><a href='#'>$i</a></li>"; } } if ($max < ceil($total/$perpage)) { $ofs=$max*$perpage; $max=$max+1; $str.= "<li><a href='".$link."&$name_ofs=".$ofs."&$name_page=".$max."' title='Следующая'>...</a></li>"; } if ($end_list == 1) { if ($max < ceil($total/$perpage)) { $ofs=(ceil($total/$perpage) - 1)*$perpage; $str.= "<li><a href='".$link."&$name_ofs=".$ofs."&$name_page=".ceil($total/$perpage)."' title='Последняя'>".ceil($total/$perpage)."</a></li>"; } } $str.= "</ul>"; if($page<ceil($total/$perpage)){ if(!$page){$p1 = 2;$o1 = $perpage*($p1-1);}else{ $p1 = $page + 1; $o1 = $perpage*($p1-1);} $str.= "<div class='btn-forward hidden-xs'> <span><a href='".$link."&{$name_ofs}={$o1}&{$name_page}={$p1}'>Вперёд</a></span></div>";} $str.= '</div></div>'; return $str; } function list_all_smarty($total,$link,$kol_page,$page,$perpage,$name_ofs, $end_list = 0, $name_page = "page") { $min=$page-$kol_page; $max=$page+$kol_page; $ofs=intval($ofs); if ($min < 1) $min=1; if ($max >= ceil($total/$perpage)) $max = ceil($total/$perpage); $str = ''; if (($min) > 1) { if ($end_list == 1) { $str.= "<li><a href='".$link."&{$name_ofs}=0&{$name_page}=1' title='Первая'>1</a></li>"; } $min=$min-1; if ($min < 1) $min=1; $ofs=($min-1)*$perpage; $str.= "<li><a href='".$link."&{$name_ofs}=".$ofs."&{$name_page}=".$min."' title='Предыдущая'>...</a></li>"; $min=$min+1; } for ($i=$min; $i<=$max; $i++) { $ofs=($i - 1)*$perpage; if ($i != $page) { if ( $i == 1 ) { if ( $link == '?list=1' ) { $str.= "<li><a href='{$link}&{$name_ofs}=".$ofs."&{$name_page}=".$i."'>$i</a></li>"; } else { $str.= "<li><a href='{$link}'>$i</a></li>"; } } else { $str.= "<li><a href='{$link}&{$name_ofs}=".$ofs."&{$name_page}=".$i."'>$i</a></li>"; } } else { $str.= "<li class='active'><a href='#'>$i</a></li>"; } } if ($max < ceil($total/$perpage)) { $ofs=$max*$perpage; $max=$max+1; $str.= "<li><a href='".$link."&$name_ofs=".$ofs."&$name_page=".$max."' title='Следующая'>...</a></li>"; } if ($end_list == 1) { if ($max < ceil($total/$perpage)) { $ofs=(ceil($total/$perpage) - 1)*$perpage; $str.= "<li><a href='".$link."&$name_ofs=".$ofs."&$name_page=".ceil($total/$perpage)."' title='Последняя'>".ceil($total/$perpage)."</a></li>"; } } return $str; } //============================================================================== function list_all_new( $total, $kol_page, $page, $perpage, $end_list = 0 ) { $uri = explode("/", $_SERVER['REQUEST_URI']); foreach ( $uri as $key => $param ) { if ( preg_match("/page[0-9]+/", $param) ) { unset($uri[$key]); } } $base_link = implode('/',$uri); $min = $page - $kol_page; $max = $page + $kol_page; $ofs=intval($ofs); if ($min < 1) $min=1; if ($max >= ceil($total/$perpage)) $max = ceil( $total/$perpage ); if (($min) > 1) { if ($end_list == 1) { echo " <a href='{$base_link}' title='Первая'><font class='page_unsel'>1</font></a> "; } $min=$min-1; if ($min < 1) $min=1; $ofs=($min-1)*$perpage; echo " <a href=\"{$base_link}page{$min}/\" title='Предыдущая'><font class='page'>...</font></a> "; $min=$min+1; } for ($i=$min; $i<=$max; $i++) { $ofs=($i - 1)*$perpage; if ($i != $page) { if ( $i == 1 ) { echo " <a href='{$base_link}'><font class='page_unsel'>{$i}</font></a> "; } else { echo " <a href=\"{$base_link}page{$i}/\"><font class='page_unsel'>$i</font></a> "; } } else { echo "<b> <font class='page_sel'> {$i} </font> </b>"; } } if ($max < ceil($total/$perpage)) { $ofs=$max*$perpage; $max=$max+1; echo " <a href=\"{$base_link}page{$max}/\" title='Следующая'><font class='page'>...</font></a> "; } if ($end_list == 1) { if ($max < ceil($total/$perpage)) { $ofs=(ceil($total/$perpage) - 1)*$perpage; $last = ceil($total/$perpage); echo " <a href=\"{$base_link}page{$last}/\" title='Последняя'><font class='page_unsel'>{$last}</font></a> "; } } } //======================================================================================= function list_all_obr($total,$link,$kol_page,$page,$perpage,$name_ofs, $end_list = 0) { $min=$page-$kol_page; $max=$page+$kol_page; $ofs=intval($ofs); if ($min < 1) $min=1; if ($max >= ceil($total/$perpage)) $max = ceil($total/$perpage); //echo $max; if (($min) > 1) { if ($end_list == 1) { echo " <a href='".$link."&$name_ofs=0&page=1' title='Первая'><font class='page_unsel'>1</font></a> "; } $min=$min-1; if ($min < 1) $min=1; $ofs=($min-1)*$perpage; echo " <a href='".$link."&$name_ofs=".$ofs."&page=".$min."' title='Предыдущая'><font class='page'>...</font></a> "; $min=$min+1; } for ($i=$min; $i<=$max; $i++) { $ofs=($i - 1)*$perpage; if ($i <> $page) echo " <a href='".$link."&$name_ofs=".$ofs."&page=".$i."'><font class='page_unsel'>$i</font></a> "; else echo "<b> <font class='page_sel'> $i </font> </b>"; } if ($max < ceil($total/$perpage)) { $ofs=$max*$perpage; $max=$max+1; echo " <a href='".$link."&$name_ofs=".$ofs."&page=".$max."' title='Следующая'><font class='page'>...</font></a> "; } if ($end_list == 1) { if ($max < ceil($total/$perpage)) { $ofs=(ceil($total/$perpage) - 1)*$perpage; echo " <a href='".$link."&$name_ofs=".$ofs."&page=".ceil($total/$perpage)."' title='Последняя'><font class='page_unsel'>".ceil($total/$perpage)."</font></a> "; } } } //====================================================================================== function check_user($sidp) { global $_SESSION, $ip, $ip2, $_SERVER, $login, $_POST, $_REQUEST; //$sidp=mysql_real_escape_string($sidp); $r_ses_user=sqlval("select *, DATEDIFF( CURDATE( ), `date_registr` ) AS DiffDate from user where md5(CONCAT(name,pass,'jflksadjjdseswaa')) = '".mysql_real_escape_string($sidp)."'"); $r_ses_user['id']= intval($r_ses_user['id']); /*if ( $r_ses_user['id'] > 0 && $r_ses_user['active'] == 0) { unset($login); unset($pass); return '-1'; }*/ if ($r_ses_user['id'] == 0 || $r_ses_user['id'] == '') { unset($login); unset($pass); return '0'; } else { $_SESSION['login']=$r_ses_user['name']; $_SESSION['fio']=$r_ses_user['name_full']; $login = $r_ses_user['name']; $_SESSION['sidp'] = $sidp; if (($_SESSION['login'] <> "") and ($r_ses_user['ip_last'] <> "") && $_POST['login1'] == "" && $r_ses_user['dinamic_ip'] == 0) { $ip_pods=substr($ip,0,strrpos($ip,".")); $ip_pods_pr=substr($ip2,0,strrpos($ip2,".")); $ip_sess=substr($r_ses_user['ip_last'],0,strrpos($r_ses_user['ip_last'],".")); $ip_sess2=substr($r_ses_user['ip2_last'],0,strrpos($r_ses_user['ip2_last'],".")); if (($ip_sess <> $ip_pods) or ($ip_sess2 <> $ip_pods_pr)) { $_SESSION=Array(); unset($_REQUEST['sidp']); unset($_COOKIE['sidp']); setcookie("sidp","",time()); $r_upd_ip=sql("update user set ip_last = '".$ip."', ip2_last = '".$ip2."' where id= '".$r_ses_user['id']."'"); header("Location: http://".$_SERVER['HTTP_HOST']); exit; } } $r_last_data=sql("update user set data_last = '".date('Y-m-d H:i:s')."', ip_last='".$ip."', ip2_last='".$ip2."' where id='".$r_ses_user['id']."'"); return $r_ses_user['id']; } } function upload_foto_crop($foto, $wnew = 250, $width_new=600, $sm = 1, $long = 1, $katalog_foto = "user_foto", $orig = 0,$for_crop=0,$hcrop=0) { global $login, $base_url, $name_foto_sm, $data_source, $abs_url, $sub_domen_cfg; if ($long == 0) $sm =1; if ($sm == 0) $long =1; if (trim($foto)<>'none') { $size=getimagesize($foto); $type=""; if ( $size[2]==1) $type="gif"; if ( $size[2]==2) $type="jpeg"; if ( $size[2]==3) $type="png"; //if ( $size[2]==6) $type="bmp"; if ($type == "") { echo "<script>alert('Внимание! Р’С‹ пытаетесь добавить фотку РЅРµ поддерживаемого формата. Формат фото должен быть gif, jpg, png! -".$size[2]."')</script>"; return ""; } // if ( $size[2]==6) $type="bmp"; //if ( $size[2]==7) $type="tif"; if ($type=="") $type=substr($foto_name,strrpos($foto_name,".")+1,4); if (!$file=fopen($foto, "rb")) echo "Невозможно открыть файл"; else { $blob_foto=fread($file, filesize($foto)); // чтение preg_match_all("/[0-9]{4}\:[0-9]{2}\:[0-9]{2} [0-9]{2}\:[0-9]{2}\:[0-9]{2}/",$blob_foto,$data_source1); $cnt=count($data_source1); $data_source=$data_source1[0][$cnt]; $name_foto=md5(microtime()); if ($orig == 1) { // оригинальное фото $b_orig=move_uploaded_file($foto, $katalog_foto."/".$name_foto."_orig.".$type); if (!$b_orig) echo "Оригинальное фото РЅРµ сохранено"; } if ( $size[2]==1) $name_foto_gif=$name_foto; if ( $size[2]==6) $name_foto_bmp=$name_foto; $name_foto_sm=$name_foto."_sm3.".$type; // маленькое РёРјСЏ $name_foto_sm2=$name_foto."_sm2.".$type; $name_foto.=".".$type; $imgfile=fopen($katalog_foto."/".$name_foto,"wb"); if (!$imgfile) echo "Файл РЅРµ создан"; fwrite($imgfile,$blob_foto); //записать большой fclose($imgfile); $width=$size[0]; $height=$size[1]; $w_preview = (int)$wnew; $h_preview = (int)$hcrop; if($width < $wnew or $hcrop > $height){ echo $width_new; exit(); } /////////////////// /////////////////////////////////// if ($type == "jpeg") { $im_in = ImageCreateFromJpeg($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); $black=imagecolorallocate($im_in,30,30,30); //imagestring($im_in, 3, 5,5,"(c) ".$sub_domen_cfg,$black); unlink($katalog_foto."/".$name_foto); imageJpeg($im_out,$katalog_foto."/".$name_foto, 85); ImageDestroy($im_out); }else{ $b_orig=move_uploaded_file($foto, $katalog_foto."/".$name_foto); } //////////////// маленькую if ($sm == 1) { if($for_crop == 0){ $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); }}else{ $koef = $size[0]/$size[1]; if($koef > 1){ $h_new = $hcrop; $wnew=round($h_new*$koef); if($wnew < $w_preview){ $wnew = $w_preview; $h_new = round($wnew/$koef); } } if($koef < 1){ $wnew = $wnew; $h_new=round($wnew/$koef); if($h_new < $h_preview){ $h_new = $h_preview; $wnew=round($h_new*$koef); } } if($koef == 1){ if($wnew > $hcrop){ $wnew = $wnew; $h_new = $wnew;}else{ $wnew = $hcrop; $h_new = $hcrop; } } } $im_out = @imagecreatetruecolor($wnew,$h_new); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imageJpeg($im_out,$katalog_foto."/".$name_foto_sm, 90); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } if ($type == "gif") { $im_in = @ImageCreateFromGif($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); $black=imagecolorallocate($im_in,30,30,30); unlink($katalog_foto."/".$name_foto); imagegif($im_out,$katalog_foto."/".$name_foto_gif.".gif"); ImageDestroy($im_out); $name_foto=$name_foto_gif.".gif"; }else{ $b_orig=move_uploaded_file($foto, $katalog_foto."/".$name_foto); } //////////////// маленькую if ($sm == 1) { if($for_crop == 0){ $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); }}else{ $koef = $size[0]/$size[1]; if($koef > 1){ $h_new = $hcrop; $wnew=round($h_new*$koef); if($wnew < $w_preview){ $wnew = $w_preview; $h_new = round($wnew/$koef); } } if($koef < 1){ $wnew = $wnew; $h_new=round($wnew/$koef); if($h_new < $h_preview){ $h_new = $h_preview; $wnew=round($h_new*$koef); } } if($koef == 1){ if($wnew > $hcrop){ $wnew = $wnew; $h_new = $wnew;}else{ $wnew = $hcrop; $h_new = $hcrop; } } } $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagegif($im_out,$katalog_foto."/".$name_foto_gif."_sm.gif"); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; $name_foto_sm=$name_foto_gif."_sm.gif"; } } /////////////////////////////////////////// /////////////////////////////////////////// if ($type == "png") { $im_in = ImageCreateFromPng($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); //imageantialias ($im_out, true); imageAlphaBlending($im_out, false); imageSaveAlpha($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_out, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); //imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagePng($im_out,$katalog_foto."/".$name_foto); ImageDestroy($im_out); }else{ $b_orig=move_uploaded_file($foto, $katalog_foto."/".$name_foto); } //////////////// маленькую if ($sm==1) { if($for_crop == 0){ $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); }}else{ $koef = $size[0]/$size[1]; if($koef > 1){ $h_new = $hcrop; $wnew=round($h_new*$koef); if($wnew < $w_preview){ $wnew = $w_preview; $h_new = round($wnew/$koef); } } if($koef < 1){ $wnew = $wnew; $h_new=round($wnew/$koef); if($h_new < $h_preview){ $h_new = $h_preview; $wnew=round($h_new*$koef); } } if($koef == 1){ if($wnew > $hcrop){ $wnew = $wnew; $h_new = $wnew;}else{ $wnew = $hcrop; $h_new = $hcrop; } } } $im_out = @imagecreatetruecolor($wnew,$h_new); imageAlphaBlending($im_out, false); imageSaveAlpha($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagePng($im_out,$katalog_foto."/".$name_foto_sm); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } // } ////////////////////////////////////// fclose($file); } return $name_foto; }} function upload_foto_url($foto, $wnew = 250, $width_new=600, $sm = 1, $long = 1, $katalog_foto = "user_foto", $orig = 0) { global $login, $base_url, $name_foto_sm, $data_source, $abs_url, $sub_domen_cfg; if ($long == 0) $sm =1; if ($sm == 0) $long =1; if (trim($foto)<>'') { $size=getimagesize($foto); $type=""; if ( $size[2]==1) $type="gif"; if ( $size[2]==2) $type="jpeg"; if ( $size[2]==3) $type="png"; if ($type == "") { echo "<script>alert('Внимание! Р’С‹ пытаетесь добавить фотку РЅРµ поддерживаемого формата. Формат фото должен быть gif, jpg, png! -".$size[2]."')</script>"; return ""; } if ($type=="") $type=substr($foto_name,strrpos($foto_name,".")+1,4); $name_foto=md5(microtime()); if ( $size[2]==1) $name_foto_gif=$name_foto; if ( $size[2]==6) $name_foto_bmp=$name_foto; $name_foto_sm=$name_foto."_sm.".$type; // маленькое РёРјСЏ $name_foto.=".".$type; $width=$size[0]; $height=$size[1]; if ($type == "jpeg") { $im_in = ImageCreateFromJpeg($foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) ".$sub_domen_cfg,$black); //unlink($katalog_foto."/".$name_foto); imageJpeg($im_out,$katalog_foto."/".$name_foto, 90); ImageDestroy($im_out); }else{@copy($foto,$katalog_foto."/".$name_foto);} //////////////// маленькую if ($sm == 1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imageJpeg($im_out,$katalog_foto."/".$name_foto_sm, 90); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } if ($type == "gif") { $im_in = @ImageCreateFromGif($foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_out, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagegif($im_out,$katalog_foto."/".$name_foto_gif.".gif"); ImageDestroy($im_out); $name_foto=$name_foto_gif.".gif"; } //////////////// маленькую if ($sm == 1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagegif($im_out,$katalog_foto."/".$name_foto_gif."_sm.gif"); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; $name_foto_sm=$name_foto_gif."_sm.gif"; } } /////////////////////////////////////////// /////////////////////////////////////////// if ($type == "png") { $im_in = ImageCreateFromPng($foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_out, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagePng($im_out,$katalog_foto."/".$name_foto); ImageDestroy($im_out); } //////////////// маленькую if ($sm==1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($wnew,$h_new); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagePng($im_out,$katalog_foto."/".$name_foto_sm); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } // } ////////////////////////////////////// //fclose($file); } return $name_foto; } function upload_foto($foto, $wnew = 250, $width_new=600, $sm = 1, $long = 1, $katalog_foto = "user_foto", $orig = 0) { global $login, $base_url, $name_foto_sm, $data_source, $abs_url, $sub_domen_cfg; if ($long == 0) $sm =1; if ($sm == 0) $long =1; if (trim($foto)<>'none') { $size=getimagesize($foto); $type=""; if ( $size[2]==1) $type="gif"; if ( $size[2]==2) $type="jpeg"; if ( $size[2]==3) $type="png"; //if ( $size[2]==6) $type="bmp"; if ($type == "") { echo "<script>alert('Внимание! Р’С‹ пытаетесь добавить фотку РЅРµ поддерживаемого формата. Формат фото должен быть gif, jpg, png! -".$size[2]."')</script>"; return ""; } // if ( $size[2]==6) $type="bmp"; //if ( $size[2]==7) $type="tif"; if ($type=="") $type=substr($foto_name,strrpos($foto_name,".")+1,4); if (!$file=fopen($foto, "rb")) echo "Невозможно открыть файл"; else { $blob_foto=fread($file, filesize($foto)); // чтение preg_match_all("/[0-9]{4}\:[0-9]{2}\:[0-9]{2} [0-9]{2}\:[0-9]{2}\:[0-9]{2}/",$blob_foto,$data_source1); $cnt=count($data_source1); $data_source=$data_source1[0][$cnt]; $name_foto=md5(microtime()); if ($orig == 1) { // оригинальное фото //$b_orig=move_uploaded_file($foto, $katalog_foto."/".$name_foto."_orig.".$type); $b_orig=move_uploaded_file($foto, $katalog_foto."/".$name_foto.$type); if (!$b_orig) echo "Оригинальное фото РЅРµ сохранено "; // echo $katalog_foto."/".$name_foto."_orig.".$type; } if ( $size[2]==1) $name_foto_gif=$name_foto; if ( $size[2]==6) $name_foto_bmp=$name_foto; $name_foto_sm=$name_foto."_sm.".$type; // маленькое РёРјСЏ $name_foto.=".".$type; $imgfile=fopen($katalog_foto."/".$name_foto,"wb"); if (!$imgfile) echo "Файл РЅРµ создан"; fwrite($imgfile,$blob_foto); //записать большой fclose($imgfile); $width=$size[0]; $height=$size[1]; /////////////////// /////////////////////////////////// if ($type == "jpeg") { $im_in = ImageCreateFromJpeg($katalog_foto."/".$name_foto); ////////////////большую if (($width >= $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); // $im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); // imageCopy($im_in, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) ".$sub_domen_cfg,$black); unlink($katalog_foto."/".$name_foto); imageJpeg($im_out,$katalog_foto."/".$name_foto, 81); ImageDestroy($im_out); } //////////////// маленькую if ($sm == 1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imageJpeg($im_out,$katalog_foto."/".$name_foto_sm, 81); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } if ($type == "gif") { $im_in = @ImageCreateFromGif($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_out, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagegif($im_out,$katalog_foto."/".$name_foto_gif.".gif"); ImageDestroy($im_out); $name_foto=$name_foto_gif.".gif"; } //////////////// маленькую if ($sm == 1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagegif($im_out,$katalog_foto."/".$name_foto_gif."_sm.gif"); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; $name_foto_sm=$name_foto_gif."_sm.gif"; } } /////////////////////////////////////////// /////////////////////////////////////////// if ($type == "png") { $im_in = ImageCreateFromPng($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagePng($im_out,$katalog_foto."/".$name_foto,9); ImageDestroy($im_out); } //////////////// маленькую if ($sm==1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($wnew,$h_new); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagePng($im_out,$katalog_foto."/".$name_foto_sm,9); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } // } ////////////////////////////////////// fclose($file); } return $name_foto; } } function upload_foto1($foto, $wnew = 250, $width_new=600, $sm = 1, $long = 1, $katalog_foto = "user_foto", $orig = 0) { global $login, $base_url, $name_foto_sm, $data_source, $abs_url, $sub_domen_cfg; if ($long == 0) $sm =1; if ($sm == 0) $long =1; if (trim($foto)<>'none') { $size=getimagesize($foto); $type=""; if ( $size[2]==1) $type="gif"; if ( $size[2]==2) $type="jpeg"; if ( $size[2]==3) $type="png"; //if ( $size[2]==6) $type="bmp"; if ($type == "") { echo "<script>alert('Внимание! Р’С‹ пытаетесь добавить фотку РЅРµ поддерживаемого формата. Формат фото должен быть gif, jpg, png! -".$size[2]."')</script>"; return ""; } // if ( $size[2]==6) $type="bmp"; //if ( $size[2]==7) $type="tif"; if ($type=="") $type=substr($foto_name,strrpos($foto_name,".")+1,4); if (!$file=fopen($foto, "rb")) echo "Невозможно открыть файл"; else { $blob_foto=fread($file, filesize($foto)); // чтение preg_match_all("/[0-9]{4}\:[0-9]{2}\:[0-9]{2} [0-9]{2}\:[0-9]{2}\:[0-9]{2}/",$blob_foto,$data_source1); $cnt=count($data_source1); $data_source=$data_source1[0][$cnt]; $name_foto=md5(microtime()); if ($orig == 1) { // оригинальное фото //$b_orig=move_uploaded_file($foto, $katalog_foto."/".$name_foto."_orig.".$type); $b_orig=move_uploaded_file($foto, $katalog_foto."/".$name_foto.$type); if (!$b_orig) echo "Оригинальное фото РЅРµ сохранено "; // echo $katalog_foto."/".$name_foto."_orig.".$type; } if ( $size[2]==1) $name_foto_gif=$name_foto; if ( $size[2]==6) $name_foto_bmp=$name_foto; $name_foto_sm=$name_foto."_sm.".$type; // маленькое РёРјСЏ $name_foto.=".".$type; $imgfile=fopen($katalog_foto."/".$name_foto,"wb"); if (!$imgfile) echo "Файл РЅРµ создан"; fwrite($imgfile,$blob_foto); //записать большой fclose($imgfile); $width=$size[0]; $height=$size[1]; /////////////////// /////////////////////////////////// if ($type == "jpeg") { $im_in = ImageCreateFromJpeg($katalog_foto."/".$name_foto); ////////////////большую /*if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); // $im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); // imageCopy($im_in, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) ".$sub_domen_cfg,$black); unlink($katalog_foto."/".$name_foto); imageJpeg($im_out,$katalog_foto."/".$name_foto, 100); ImageDestroy($im_out); }*/ //////////////// маленькую if ($sm == 1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imageJpeg($im_out,$katalog_foto."/".$name_foto_sm, 90); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } if ($type == "gif") { $im_in = @ImageCreateFromGif($katalog_foto."/".$name_foto); ////////////////большую /*if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_out, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagegif($im_out,$katalog_foto."/".$name_foto_gif.".gif"); ImageDestroy($im_out); $name_foto=$name_foto_gif.".gif"; }*/ //////////////// маленькую if ($sm == 1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagegif($im_out,$katalog_foto."/".$name_foto_gif."_sm.gif"); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; $name_foto_sm=$name_foto_gif."_sm.gif"; } } /////////////////////////////////////////// /////////////////////////////////////////// if ($type == "png") { $im_in = ImageCreateFromPng($katalog_foto."/".$name_foto); ////////////////большую /* if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_out, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagePng($im_out,$katalog_foto."/".$name_foto, 9); ImageDestroy($im_out); }*/ //////////////// маленькую if ($sm==1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($wnew,$h_new); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagePng($im_out,$katalog_foto."/".$name_foto_sm, 9); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } // } ////////////////////////////////////// fclose($file); } return $name_foto; } } function upload_foto2($foto, $wnew = 250, $width_new=600, $sm = 1, $long = 1, $katalog_foto = "user_foto", $orig = 0,$width_new1 = 600) { global $login, $base_url, $name_foto_sm, $data_source, $abs_url, $sub_domen_cfg; if ($long == 0) $sm =1; if ($sm == 0) $long =1; if (trim($foto)<>'none') { $size=getimagesize($foto); $type=""; if ( $size[2]==1) $type="gif"; if ( $size[2]==2) $type="jpeg"; if ( $size[2]==3) $type="png"; //if ( $size[2]==6) $type="bmp"; if ($type == "") { echo "<script>alert('Внимание! Р’С‹ пытаетесь добавить фотку РЅРµ поддерживаемого формата. Формат фото должен быть gif, jpg, png! -".$size[2]."')</script>"; return ""; } // if ( $size[2]==6) $type="bmp"; //if ( $size[2]==7) $type="tif"; if ($type=="") $type=substr($foto_name,strrpos($foto_name,".")+1,4); if (!$file=fopen($foto, "rb")) echo "Невозможно открыть файл"; else { $blob_foto=fread($file, filesize($foto)); // чтение preg_match_all("/[0-9]{4}\:[0-9]{2}\:[0-9]{2} [0-9]{2}\:[0-9]{2}\:[0-9]{2}/",$blob_foto,$data_source1); $cnt=count($data_source1); $data_source=$data_source1[0][$cnt]; $name_foto=md5(microtime()); /*if ($orig == 1) { // оригинальное фото $b_orig=move_uploaded_file($foto, $katalog_foto."/".$name_foto."_orig.".$type); if (!$b_orig) echo "Оригинальное фото РЅРµ сохранено "; // echo $katalog_foto."/".$name_foto."_orig.".$type; }*/ if ( $size[2]==1) $name_foto_gif=$name_foto; if ( $size[2]==6) $name_foto_bmp=$name_foto; $name_foto_sm=$name_foto."_sm.".$type; // маленькое РёРјСЏ $name_foto.=".".$type; $imgfile=fopen($katalog_foto."/".$name_foto,"wb"); if (!$imgfile) echo "Файл РЅРµ создан"; fwrite($imgfile,$blob_foto); //записать большой fclose($imgfile); $width=$size[0]; $height=$size[1]; /////////////////// /////////////////////////////////// if ($type == "jpeg") { $im_in = ImageCreateFromJpeg($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new1) && ($long == 1)) { $prop2=$size[0]/$width_new1; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new1) { $h_new2=$width_new1; $prop=$size[1]/$h_new2; $width_new1=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new1,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new1,$h_new2, $size[0], $size[1]); // $im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); // imageCopy($im_in, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) ".$sub_domen_cfg,$black); unlink($katalog_foto."/".$name_foto); imageJpeg($im_out,$katalog_foto."/".$name_foto, 90); ImageDestroy($im_out); } //////////////// маленькую if ($sm == 1) { /*$prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); }*/ $im_out = @imagecreatetruecolor($width_new,$wnew); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$wnew, $size[0], $size[1]); imageJpeg($im_out,$katalog_foto."/".$name_foto_sm, 90); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } if ($type == "gif") { $im_in = @ImageCreateFromGif($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new1) && ($long == 1)) { $prop2=$size[0]/$width_new1; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new1) { $h_new2=$width_new1; $prop=$size[1]/$h_new2; $width_new1=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new1,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new1,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_out, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagegif($im_out,$katalog_foto."/".$name_foto_gif.".gif"); ImageDestroy($im_out); $name_foto=$name_foto_gif.".gif"; } //////////////// маленькую if ($sm == 1) { /*$prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); }*/ $im_out = @imagecreatetruecolor($width_new,$wnew); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$wnew, $size[0], $size[1]); imagegif($im_out,$katalog_foto."/".$name_foto_gif."_sm.gif"); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; $name_foto_sm=$name_foto_gif."_sm.gif"; } } /////////////////////////////////////////// /////////////////////////////////////////// if ($type == "png") { $im_in = ImageCreateFromPng($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new1) && ($long == 1)) { $prop2=$size[0]/$width_new1; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new1) { $h_new2=$width_new1; $prop=$size[1]/$h_new2; $width_new1=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new1,$h_new2); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new1,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_out, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagePng($im_out,$katalog_foto."/".$name_foto, 9); ImageDestroy($im_out); } //////////////// маленькую if ($sm==1) { /*$prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); }*/ $im_out = @imagecreatetruecolor($width_new,$wnew); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$wnew, $size[0], $size[1]); imagePng($im_out,$katalog_foto."/".$name_foto_sm, 9); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } // } ////////////////////////////////////// fclose($file); } return $name_foto; } } function upload_foto3($foto, $wnew,$h_new, $name, $sm = 1, $long = 1, $katalog_foto = "user_foto", $orig = 0) { global $login, $base_url, $name_foto_sm, $data_source, $abs_url, $sub_domen_cfg; if ($long == 0) $sm =1; if ($sm == 0) $long =1; if (trim($foto)<>'none') { $size=getimagesize($foto); $type=""; if ( $size[2]==1) $type="gif"; if ( $size[2]==2) $type="jpeg"; if ( $size[2]==3) $type="png"; //if ( $size[2]==6) $type="bmp"; if ($type == "") { echo "<script>alert('Внимание! Р’С‹ пытаетесь добавить фотку РЅРµ поддерживаемого формата. Формат фото должен быть gif, jpg, png! -".$size[2]."')</script>"; return ""; } // if ( $size[2]==6) $type="bmp"; //if ( $size[2]==7) $type="tif"; if ($type=="") $type=substr($foto_name,strrpos($foto_name,".")+1,4); if (!$file=fopen($foto, "rb")) echo "Невозможно открыть файл"; else { $blob_foto=fread($file, filesize($foto)); // чтение preg_match_all("/[0-9]{4}\:[0-9]{2}\:[0-9]{2} [0-9]{2}\:[0-9]{2}\:[0-9]{2}/",$blob_foto,$data_source1); $cnt=count($data_source1); $data_source=$data_source1[0][$cnt]; $name_foto=$name; if ($orig == 1) { // оригинальное фото $b_orig=move_uploaded_file($foto, $katalog_foto."/".$name_foto."_orig.".$type); if (!$b_orig) echo "Оригинальное фото РЅРµ сохранено "; // echo $katalog_foto."/".$name_foto."_orig.".$type; } if ( $size[2]==1) $name_foto_gif=$name_foto; if ( $size[2]==6) $name_foto_bmp=$name_foto; $name_foto_sm=$name_foto."_sm.".$type; // маленькое РёРјСЏ $name_foto.=".".$type; $imgfile=fopen($katalog_foto."/".$name_foto,"wb"); if (!$imgfile) echo "Файл РЅРµ создан"; fwrite($imgfile,$blob_foto); //записать большой fclose($imgfile); $width=$size[0]; $height=$size[1]; /////////////////// /////////////////////////////////// if ($type == "jpeg") { $im_in = ImageCreateFromJpeg($katalog_foto."/".$name_foto); ////////////////большую /* if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); // $im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); // imageCopy($im_in, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) ".$sub_domen_cfg,$black); unlink($katalog_foto."/".$name_foto); imageJpeg($im_out,$katalog_foto."/".$name_foto, 100); ImageDestroy($im_out); }*/ //////////////// маленькую if ($sm == 1) { /*$prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); }*/ $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imageJpeg($im_out,$katalog_foto."/".$name_foto_sm, 90); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } if ($type == "gif") { $im_in = @ImageCreateFromGif($katalog_foto."/".$name_foto); ////////////////большую /*if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_out, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagegif($im_out,$katalog_foto."/".$name_foto_gif.".gif"); ImageDestroy($im_out); $name_foto=$name_foto_gif.".gif"; }*/ //////////////// маленькую if ($sm == 1) { /*$prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); }*/ $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagegif($im_out,$katalog_foto."/".$name_foto_gif."_sm.gif"); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; $name_foto_sm=$name_foto_gif."_sm.gif"; } } /////////////////////////////////////////// /////////////////////////////////////////// if ($type == "png") { $im_in = ImageCreateFromPng($katalog_foto."/".$name_foto); ////////////////большую /*if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_out, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagePng($im_out,$katalog_foto."/".$name_foto, 9); ImageDestroy($im_out); }*/ //////////////// маленькую if ($sm==1) { /*$prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new > $wnew) { $h_new=$wnew; $prop=$size[1]/$h_new; $wnew=round($size[0]/$prop); }*/ $im_out = @imagecreatetruecolor($wnew,$h_new); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagePng($im_out,$katalog_foto."/".$name_foto_sm, 9); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } // } ////////////////////////////////////// fclose($file); } return $name_foto; } } ///================================================================= function upload_foto_tovar($foto, $wnew = 250, $width_new=600, $sm = 1, $long = 1, $katalog_foto = "user_foto") { global $login, $base_url, $name_foto_sm, $abs_url; if ($long == 0) $sm =1; if ($sm == 0) $long =1; if (trim($foto)<>'none') { $size=getimagesize($foto); $type=""; if ( $size[2]==1) $type="gif"; if ( $size[2]==2) $type="jpeg"; if ( $size[2]==3) $type="png"; if ($type == "") { echo "<script>alert('Внимание! Р’С‹ пытаетесь добавить фотку РЅРµ поддерживаемого формата. Формат фото должен быть gif, jpg, png!')</script>"; return ""; } // if ( $size[2]==6) $type="bmp"; //if ( $size[2]==7) $type="tif"; if ($type=="") $type=substr($foto_name,strrpos($foto_name,".")+1,4); if (!$file=fopen($foto, "rb")) echo "Невозможно открыть файл"; else { $blob_foto=fread($file, filesize($foto)); // чтение $name_foto=md5(microtime()); if ( $size[2]==1) $name_foto_gif=$name_foto; $name_foto_sm=$name_foto."_sm.".$type; // маленькое РёРјСЏ $name_foto.=".".$type; $imgfile=fopen($katalog_foto."/".$name_foto,"wb"); if (!$imgfile) echo "Файл РЅРµ создан"; fwrite($imgfile,$blob_foto); //записать большой fclose($imgfile); $width=$size[0]; $height=$size[1]; /////////////////// /////////////////////////////////// if ($type == "jpeg") { $im_in = ImageCreateFromJpeg($katalog_foto."/".$name_foto); ////////////////большую if (($width >= $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_in, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imageJpeg($im_out,$katalog_foto."/".$name_foto, 82); ImageDestroy($im_out); } //////////////// маленькую if ($sm == 1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imageJpeg($im_out,$katalog_foto."/".$name_foto_sm, 82); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } if ($type == "gif") { $im_in = @ImageCreateFromGif($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); // imageCopy($im_in, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagegif($im_out,$katalog_foto."/".$name_foto_gif.".gif"); ImageDestroy($im_out); $name_foto=$name_foto_gif.".gif"; } //////////////// маленькую if ($sm == 1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagegif($im_out,$katalog_foto."/".$name_foto_gif."_sm.gif"); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; $name_foto_sm=$name_foto_gif."_sm.gif"; } } /////////////////////////////////////////// /////////////////////////////////////////// if ($type == "png") { $im_in = ImageCreateFromPng($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); $im_out = @imagecreatetruecolor($width_new,$h_new2); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); // $im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_in, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagePng($im_out,$katalog_foto."/".$name_foto, 9); ImageDestroy($im_out); } //////////////// маленькую if ($sm==1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); $im_out = @imagecreatetruecolor($wnew,$h_new); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagePng($im_out,$katalog_foto."/".$name_foto_sm, 9); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } // } ////////////////////////////////////// fclose($file); } return $name_foto; } } function upload_foto_tovar1($foto, $wnew = 250, $width_new=600, $sm = 1, $long = 1, $katalog_foto = "user_foto") { global $login, $base_url, $name_foto_sm, $abs_url; if ($long == 0) $sm =1; if ($sm == 0) $long =1; if (trim($foto)<>'none') { $size=getimagesize($foto); $type=""; if ( $size[2]==1) $type="gif"; if ( $size[2]==2) $type="jpeg"; if ( $size[2]==3) $type="png"; if ($type == "") { echo "<script>alert('Внимание! Р’С‹ пытаетесь добавить фотку РЅРµ поддерживаемого формата. Формат фото должен быть gif, jpg, png!')</script>"; return ""; } // if ( $size[2]==6) $type="bmp"; //if ( $size[2]==7) $type="tif"; if ($type=="") $type=substr($foto_name,strrpos($foto_name,".")+1,4); if (!$file=fopen($foto, "rb")) echo "Невозможно открыть файл"; else { $blob_foto=fread($file, filesize($foto)); // чтение $name_foto=md5(microtime()); if ( $size[2]==1) $name_foto_gif=$name_foto; $name_foto_sm=$name_foto."_sm.".$type; // маленькое РёРјСЏ $name_foto.=".".$type; $imgfile=fopen($katalog_foto."/".$name_foto,"wb"); if (!$imgfile) echo "Файл РЅРµ создан"; fwrite($imgfile,$blob_foto); //записать большой fclose($imgfile); $width=$size[0]; $height=$size[1]; /////////////////// /////////////////////////////////// if ($type == "jpeg") { $im_in = ImageCreateFromJpeg($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { //$prop2=$size[0]/$width_new; // $h_new2=round($size[1]/$prop2); $h_new2 = $wnew; $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_in, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imageJpeg($im_out,$katalog_foto."/".$name_foto, 85); ImageDestroy($im_out); } //////////////// маленькую if ($sm == 1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imageJpeg($im_out,$katalog_foto."/".$name_foto_sm, 85); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } if ($type == "gif") { $im_in = @ImageCreateFromGif($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { //$prop2=$size[0]/$width_new; //$h_new2=round($size[1]/$prop2); $h_new2 = $wnew; $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); // imageCopy($im_in, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagegif($im_out,$katalog_foto."/".$name_foto_gif.".gif"); ImageDestroy($im_out); $name_foto=$name_foto_gif.".gif"; } //////////////// маленькую if ($sm == 1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagegif($im_out,$katalog_foto."/".$name_foto_gif."_sm.gif"); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; $name_foto_sm=$name_foto_gif."_sm.gif"; } } /////////////////////////////////////////// /////////////////////////////////////////// if ($type == "png") { $im_in = ImageCreateFromPng($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { //$prop2=$size[0]/$width_new; //$h_new2=round($size[1]/$prop2); $h_new2 = $wnew; $im_out = @imagecreatetruecolor($width_new,$h_new2); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); // $im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_in, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagePng($im_out,$katalog_foto."/".$name_foto, 9); ImageDestroy($im_out); } //////////////// маленькую if ($sm==1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); $im_out = @imagecreatetruecolor($wnew,$h_new); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagePng($im_out,$katalog_foto."/".$name_foto_sm, 9); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } // } ////////////////////////////////////// fclose($file); } return $name_foto; } } //================================================================== function imageCopyResampleBicubic($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) { $scaleX = ($src_w - 1) / $dst_w; $scaleY = ($src_h - 1) / $dst_h; $scaleX2 = $scaleX / 2.0; $scaleY2 = $scaleY / 2.0; $tc = imageistruecolor($src_img); for ($y = $src_y; $y < $src_y + $dst_h; $y++) { $sY = $y * $scaleY; $siY = (int) $sY; $siY2 = (int) $sY + $scaleY2; for ($x = $src_x; $x < $src_x + $dst_w; $x++) { $sX = $x * $scaleX; $siX = (int) $sX; $siX2 = (int) $sX + $scaleX2; if ($tc) { $c1 = imagecolorat($src_img, $siX, $siY2); $c2 = imagecolorat($src_img, $siX, $siY); $c3 = imagecolorat($src_img, $siX2, $siY2); $c4 = imagecolorat($src_img, $siX2, $siY); $r = (($c1 + $c2 + $c3 + $c4) >> 2) & 0xFF0000; $g = ((($c1 & 0xFF00) + ($c2 & 0xFF00) + ($c3 & 0xFF00) + ($c4 & 0xFF00)) >> 2) & 0xFF00; $b = ((($c1 & 0xFF) + ($c2 & 0xFF) + ($c3 & 0xFF) + ($c4 & 0xFF)) >> 2); imagesetpixel($dst_img, $dst_x + $x - $src_x, $dst_y + $y - $src_y, $r+$g+$b); } else { $c1 = imagecolorsforindex($src_img, imagecolorat($src_img, $siX, $siY2)); $c2 = imagecolorsforindex($src_img, imagecolorat($src_img, $siX, $siY)); $c3 = imagecolorsforindex($src_img, imagecolorat($src_img, $siX2, $siY2)); $c4 = imagecolorsforindex($src_img, imagecolorat($src_img, $siX2, $siY)); $r = ($c1['red'] + $c2['red'] + $c3['red'] + $c4['red'] ) << 14; $g = ($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) << 6; $b = ($c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue'] ) >> 2; imagesetpixel($dst_img, $dst_x + $x - $src_x, $dst_y + $y - $src_y, $r+$g+$b); } } } } function kartochka($id, $small = 0, $lang = "") { global $id_otrasl, $rname, $ip, $abs_url, $base_url,$w, $h, $_SERVER, $_GET, $podrobno, $name_gorod,$name_gorod2, $_REQUEST; if ($_GET['ukr'] == 1) $rinfo=sqlval("select name, adress, home, telefon, znak, registr, registr_price, info,url, email, id_home from firma_ukr where id = '".intval($id)."'"); else $rinfo=sqlval("select * from firma where id = '".intval($id)."'"); if ($_GET['ukr'] == 1 && $rinfo['name'] == "") $rinfo=sqlval("select name, adress, home, telefon, znak, registr, registr_price, info,url, email, id_home from firma where id = '".intval($id)."'"); $id_otr=sqlval("select * from rubrik2 where id_firm='".intval($id)."'"); $rname=sqlval("select * from otrasl2 where id='{$id_otr['id_rubrik']}'"); $r_parent=sqlval("select * from otrasl2 where id='".$rname['id_parent']."'"); $otrasl="<a href=\"".$abs_url."katalog_firm.php\">Весь каталог РіРѕСЂРѕРґР° ".$name_gorod2."</a> > "; if ($r_parent['id'] <> '') $otrasl.="<a href=\"{$abs_url}industry/{$r_parent['id']}/{$r_parent['translit_name']}/\">{$r_parent['name_otrsl']}</a> > "; $otrasl.="<a href=\"{$abs_url}industry/{$id_otr['id_rubrik']}/{$rname['translit_name']}/\">".$rname['name_otrsl']."</a>"; ////////////////////////////// stat $id_otrasl=$id_otr['id_rubrik']; //if ($small == 0) ins_stat(2, intval($id)); ///////////////////////// if (mysql_num_rows(sql("select id from tovar where id_firm='".intval($id)."' limit 0,1")) < 1) $price_tovar=""; else $price_tovar = 1; $karta_href="<a href=\"".$abs_url."maps/?iz=".$id."&tz=3\" title=\"Посмотреть РЅР° карте РіРѕСЂРѕРґР°\">"; $karta_href2="</a>"; $addr = ''; if ($rinfo['registr'] == 1 and (date("Y-m-d") <= $rinfo['tarif_end'] and date("Y-m-d") >= $rinfo['tarif_begin'])) $name="<b>".$rinfo['name']."</b>"; else $name = $rinfo['name']; //$name = htmlspecialchars($name); if ($rinfo['sub_adm_area_id']!=17 || $rinfo['locality_id']!=2158) { $rs_sub_adm_area = sqlval("select * from sub_admn_area where id='{$rinfo['sub_adm_area_id']}'"); $addr .= $rs_sub_adm_area['name'] . ', '; $rs_locality = sqlval("select * from locality where id='{$rinfo['locality_id']}'"); $addr .= $rs_locality['name'] . ', '; $name_gorod = 'Орловская область'; } $addr .= $rinfo['street']; if ( $rinfo['house'] != '' && $rinfo['house'] > 0 ) $addr .= ', ' . $rinfo['house']; if ( $rinfo['house_add'] != '' ) if (is_numeric($rinfo['house_add'])) $addr .= '/' . $rinfo['house_add']; else $addr .= $rinfo['house_add']; if ( $rinfo['corps'] != '' ) $addr .= ', РєРѕСЂРїСѓСЃ ' . $rinfo['corps']; if ( $rinfo['build'] != '' ) $addr .= ', строение ' . $rinfo['build']; if ( $rinfo['address_add'] != '' ) $addr .= ', ' . $rinfo['address_add']; //$address=$karta_href." ".$rinfo['adress'].", ".$rinfo['home'].$karta_href2; $address=$karta_href." ".$name_gorod.", ".$addr.$karta_href2; if ($_GET['full_phone'] <> 1) { $telefon="тел.: ".substr($rinfo['telefon'] ,0,200); if (strlen($rinfo['telefon'] ) > 200) $telefon.="<br><a href='".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&full_phone=1'>далее ...</a>"; } else $telefon = $rinfo['telefon'] ; if ($rinfo['registr'] == 1 and (date("Y-m-d") <= $rinfo['tarif_end'] and date("Y-m-d") >= $rinfo['tarif_begin'])) { if ($rinfo['email'] <> "") $email = "Email: <a href=\"mailto:".$rinfo['email']."\"><font class=\"url\">".$rinfo['email']."</font></a>"; } if($rinfo['regim']){ $regim ="<p class=\"TextMainNews\">Режим работы: ".$rinfo['regim']."</p>";} else{ $regim = ''; } if ($rinfo['registr'] == 1 and (date("Y-m-d") <= $rinfo['tarif_end'] and date("Y-m-d") >= $rinfo['tarif_begin'])) { if ($rinfo['url'] != "") { require_once('Net/IDNA2.php'); $idn = Net_IDNA2::getInstance(); $url = "Сайт: <a href=\"".$abs_url."url.php?url=". $idn->encode(iconv("WINDOWS-1251", "UTF-8", $rinfo['url']))."\" target='_blank'>".$rinfo['url']."</a>"; } } if ($rinfo['registr_price'] == 1 && $price_tovar ==1) $price = "<a href=\"".$abs_url."price_firm.php?id=".$id."\"><b>Посмотреть каталог товаров (услуг)</b></a>"; $phones_result = fetchAll("select * from firma_phone where id_firma='{$id}' order by type"); $phone_types_array = array(1=>'Телефон', 2=>'Факс', 3=>'Телефон Рё факс'); foreach ($phones_result as $phone) $phone_array[$phone['type']][$phone['id']] = array('number'=>$phone['number'], 'ext'=>$phone['ext'], 'info'=>$phone['info']); foreach ( $phone_array as $type => $phone_data ) { foreach ( $phone_data as $phone ) { $phone_table .= "{$phone_types_array[$type]}: {$phone['number']}"; if ($phone['ext']!='') $phone_table .= " (РґРѕР±. {$phone['ext']})"; if ($phone['info']!='') $phone_table .= " - {$phone['info']}"; $phone_table .= "<br />"; } } if ($small == 1) echo xparse($base_url."template/kartochka.html","", get_defined_vars()); else { $r_type=sql("select * from search_type order by id"); if (!$r_type) error(); while ($rs_type = sqlget($r_type)) { if ($rs_type['id'] == 1) $sel_obj=" selected "; else $sel_obj=""; $razdel_search.="<option value=\"".$rs_type['id']."\" ".$sel_obj.">".$rs_type['name']."</option>"; } echo xparse($base_url."template/kartochka_big.html","", get_defined_vars()); } } function dir_size($dir) { $totalsize=0; if ($dirstream = @opendir($dir)) { while (false !== ($filename = readdir($dirstream))) { if ($filename!="." && $filename!="..") { if (is_file($dir."/".$filename)) $totalsize+=filesize($dir."/".$filename); if (is_dir($dir."/".$filename)) $totalsize+=dir_size($dir."/".$filename); } } } closedir($dirstream); return $totalsize; } //============================================================= function ip2int($ip) { $a=explode(".",$ip); return $a[0]*256*256*256+$a[1]*256*256+$a[2]*256+$a[3]; } //============================================================= function int2ip($i) { $d[0]=(int)($i/256/256/256); $d[1]=(int)(($i-$d[0]*256*256*256)/256/256); $d[2]=(int)(($i-$d[0]*256*256*256-$d[1]*256*256)/256); $d[3]=$i-$d[0]*256*256*256-$d[1]*256*256-$d[2]*256; return "$d[0].$d[1].$d[2].$d[3]"; } //============================================================= function deldir($dir){ $current_dir = opendir($dir); while($entryname = readdir($current_dir)){ if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")){ deldir("${dir}/${entryname}"); }elseif($entryname != "." and $entryname!=".."){ unlink("${dir}/${entryname}"); } } closedir($current_dir); rmdir(${dir}); } //============================================================== function del_foto($id_foto) { global $base_url, $id_user_sess; $rdf=sqlval("select path from dom_allfoto where id='".intval($_GET['id_foto'])."' and id_user='".$id_user_sess."'"); if (!$rdf) { error(); return false; } if ($rdf['path'] <> "") { $smal_foto=substr($rdf['path'],0,strrpos($rdf['path'],"."))."_sm".substr($rdf['path'],strrpos($rdf['path'],"."), strlen($rdf['path']) - strrpos($rdf['path'],".")); $b=unlink($base_url."dom/".$rdf['path']); $b2=unlink($base_url."dom/".$smal_foto); if ($b) { $rd=sql("delete from dom_allfoto where id='".intval($_GET['id_foto'])."' and id_user='".$id_user_sess."'"); if (!$rd) { error(); return false; } return true; } } } //================================================= function podrubrik($id_rubrik, $vlog) { $r2=sql("select * from grtovar_new where id_parent='".intval($id_rubrik)."' order by name"); while ($rs2=sqlget($r2)) { echo "<option value='$rs2[id]'>"; for ($i=0; $i < $vlog; $i++) { echo " "; } echo $rs2['name']."<br>"; $r3=sqlval("select count(*) from grtovar_new where id_parent='$rs2[id]'"); if ($r3[0] > 0) podrubrik($rs2['id'], $vlog+1); } } function podrubrik_view($id_rubrik, $vlog) { global $sql_price_firm, $id_firm,$base_url; $r2=sql("select * from grtovar_new where id_parent='".intval($id_rubrik)."'"); if (!$r2) "f1".error(); // echo "<br>"; while ($rs2=sqlget($r2)) { //echo "<br>"; $kol_tovar=sqlval("select count(*) from tovar, rubrik_tovar, firma where tovar.id=rubrik_tovar.id_tovar and id_rubrik='".$rs2[id]."' and firma.id=id_firm and registr='1' ".$sql_price_firm); if (!$kol_tovar) "f2".error(); $cnt_podr=sqlval("select count(*) from grtovar_new where id_parent='".$rs2['id']."'"); if (!$cnt_podr) "f3".error(); for ($i=0; $i < $vlog; $i++) { echo " "; } if ($cnt_podr[0] == 0) echo "<img src=\"".$base_url."images/znak_pusto.gif\" border=0 > "; if ($cnt_podr[0] > 0) echo "<img src=\"".$base_url."images/znak_open.gif\" border=0 > "; if ($kol_tovar[0] > 0) { if ($sql_price_firm == "") echo "<a href='out_grtovar.php?id_group=".$rs2['id']."' title=\"Показать товары\">"; else echo "<a href='price_firm.php?id_group=".$rs2['id']."&id=".$id_firm."'>"; } echo $rs2['name']; if ($kol_tovar[0] > 0) { if ($sql_price_firm == "") echo " <font color='#999999'>(".$kol_tovar[0].")</font></a>"; else echo " <font color='#999999'>(".$kol_tovar[0].")</font></a>"; } echo "<br> "; $r3=sqlval("select count(*) from grtovar_new where id_parent='".$rs2['id']."'"); if (!$r3) "f4".error(); if ($r3[0] > 0) podrubrik_view($rs2['id'], $vlog+1); } } /////\================= poisk function slova($text) { $text=str_replace("<br>"," ", $text); $text=str_replace("<BR>"," ", $text); $text=strip_tags($text); $repl_symbol=array(".",",",";",":","!","?","\"","\'","\`","-","_","В»","В«" ," ", ""","\\",")","(","/","}" ,"{","*","+","=","^","%","#","<","&qt","•","|", "<br>", "\"","—", "&",">","В°"); $mas_stop=array("Р°","без","Р±С‹", "РІ","Р·Р°","Рё","РёР·","или","РЅР°","РЅРѕ","РїРѕ","СЃ"); $text=strtolower(str_replace($repl_symbol," ", $text)); preg_match_all('/([a-zA-ZР°-СЏРђ-РЇ0-9]+)/',$text,$ok); //for ($i=0; $i<count($ok[1]); $i++) $mas_temp[]=$ok[1][$i]." //$text=preg_replace("/ +/"," ",$text); //$mas_temp=explode(" ",$text); // sleep(1); $cnt_stop_word=count($mas_stop); $cnt=count($ok[1]); for($j=0;$j < $cnt_stop_word; $j++) { $del=0; for($i=0;$i < $cnt_stop_word; $i++) { if ($ok[1][$j] == $mas_stop[$i]) $del=1; } if ($del == 1) { unset($ok[1][$j]); } } return $ok[1]; } //\================== читаем слова РІ файлах function contents_file($path) { if ($f=fopen($path,"r")) { $contents = fread ($f, filesize ($path)); fclose($f); return $contents; } { echo "Not open: ".$path; return; } } //====================== читаем файлы РІ директории function read_dir($dir, $weight = 1,$l, $koef_firm = 1) { global $base_url, $_SERVER, $abs_url_search; $host=$_SERVER['HTTP_HOST']; if ($handle = opendir($base_url.$dir)) { while ($file = readdir($handle)) { $i++; if($file=='.'||$file=='..'||$file=='_index.html'||$file=='index.html'||$file=='index.htm') continue; //if (is_int(strpos($file,"index."))) continue; if ((substr($file,strlen($file)-3,3) == "htm") || (substr($file,strlen($file)-4,4) == "html") || (substr($file,strlen($file)-3,3) == "php")) { $content=contents_file($base_url.$dir."/".$file); if (preg_match("!<title>(.*?)</title>!si",$content,$ok)) { $title_obj=$ok[1]; } else { if (preg_match("!title=\"(.*?)\"\;!si",$content,$ok)) $title_obj=$ok[1]; } $mas_slow=slova($content); $name_obj=$abs_url_search.$dir."/".$file; $date_time = date('Y-m-d H:i:s'); $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('".$name_obj."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); // вес для title if (is_int(strpos($dir, "klient"))) { $mas_slow_t=slova($title_obj); $cnt_mnt=count($mas_slow_t); for ($i=0; $i < $cnt_mnt; $i++) { $mas_slow_t[$i]=trim($mas_slow_t[$i]); if ($mas_slow_t[$i] <> "") { $weight_obj_firm=$koef_firm*150; $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_slow_t[$i]."', '150')"); } } } //\=============== if ($title_obj == "") $title_obj=$name_obj; $r_ins_obj_name=sql("insert into search_obj_title (id_obj, title) values ('".$id_obj."', '".addslashes(strip_tags($title_obj))."')"); if (!$r_ins_obj_name) error(); $cnt_mn=count($mas_slow); for ($i=0; $i < $cnt_mn; $i++) { $mas_slow[$i]=trim($mas_slow[$i]); if ($mas_slow[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_slow[$i]."', '".$weight."')"); } } } } closedir($handle); } } //====================== читаем файл function read_file($path, $weight = 1,$l) { global $base_url, $abs_url_search; $host=$_SERVER['HTTP_HOST']; $mas_slow=slova(contents_file($base_url.$path)); $name_obj=$abs_url_search.$path; $date_time = date('Y-m-d H:i:s'); $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('".$name_obj."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); $cnt_mn=count($mas_slow); for ($i=0; $i < $cnt_mn; $i++) { $mas_slow[$i]=trim($mas_slow[$i]); if ($mas_slow[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_slow[$i]."', '".$weight."')"); } } } //====================== читаем файл РїРѕ ссылке ссылку function read_url($path, $weight = 1,$l) { global $base_url; //$content=file_get_contents($path); $handle = fopen(trim($path), "rb"); $contents = ''; while (!feof($handle)) { $contents .= fread($handle, 8192); } fclose($handle); //\============ if (preg_match("!<title>(.*?)</title>!si",$contents,$ok)) $title_obj=$ok[1]; //\================ echo $title_obj."<br>"; $mas_slow=slova($title_obj); $name_obj=$path; $date_time = date('Y-m-d H:i:s'); $r_pred_obj=sqlval("select id from search_object where name = '".$name_obj."'"); if (!$r_pred_obj) echo mysql_error(); if ($r_pred_obj[0] > 0) { $r_del=sql("delete from search_index where id_obj = '".$r_pred_obj[0]."'"); if (!$r_del) echo mysql_error(); $r_del=sql("delete from search_object where id = '".$r_pred_obj[0]."'"); if (!$r_del) echo mysql_error(); $r_del=sql("delete from search_obj_title where id_obj = '".$r_pred_obj[0]."'"); if (!$r_del) echo mysql_error(); } $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('".$name_obj."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); //\========== вставляем РёРјСЏ объекта title // if ($title_obj == "") $title_obj=$name_obj; $r_ins_obj_name=sql("insert into search_obj_title (id_obj, title) values ('".$id_obj."', '".addslashes(strip_tags($title_obj))."')"); if (!$r_ins_obj_name) error(); //\================================ $cnt_mn=count($mas_slow); for ($i=0; $i < $cnt_mn; $i++) { $mas_slow[$i]=trim($mas_slow[$i]); if ($mas_slow[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_slow[$i]."', '".$weight."')"); } } } function menu_indexator($path_to_file_menu = "menu/div/for_poisk_spisok.html") { global $l, $base_url; if ($handle = fopen($path_to_file_menu, "r")) { while (!feof($handle)) { $contents = fgets($handle, 1024); if ($contents <> "") read_url(trim($contents), 200,$l); } fclose($handle); } } //\==================================indexator firm function firm_indexator($id, $l) { global $base_url, $abs_url_search, $sph_idx; $tarifs = fetchAll("select * from firma_tarif"); foreach ($tarifs as $tarif) { $tarif_map[$tarif['id']] = $tarif['koef']; } if ($id == 0) { /*$del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://firma/%'"); if (!$del_obj_news) error(); $r_f=sql("select domen from firma where domen <> ''"); if (!$r_f) error(); while ($rs_f=sqlget($r_f)) { $d_f=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like '".$abs_url_search."klient/".$rs_f['domen']."/%'"); if (!$d_f) error(); }*/ $r=sql("select id, name, name_ur, adress, home, telefon, email, url, info, domen, path, registr, id_tarif, keyword from firma"); while ($row = sqlget($r)) { $sph_id = $row['id'] * 100 + 1; $row['name'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['name'])); $row['name_ur'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['name_ur'])); $row['info'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['info'])); $row['keyword'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['keyword'])); $l = db_connect(); $rubriks = sql("select * from rubrik2 where id_firm={$row['id']}"); $row['id'] = $row['id'] * 100 + 1; $rubrik_array = array(); while ( $rubrik = sqlget($rubriks)) { $rs_otrasl = sqlval("select * from otrasl2 where id='{$rubrik['id_rubrik']}'"); $rubrik_array[] = $rs_otrasl['name_otrsl']; } $groups = iconv("windows-1251", "utf-8", implode(', ',$rubrik_array)); $weight = $row['registr'] * $tarif_map[$row['id_tarif']]; db_connect_sph(); sql("replace into {$sph_idx['company']} values ('{$row['id']}', '{$row['name']}', '{$row['name_ur']}', '', '{$row['info']}', '{$row['keyword']}', '{$groups}', '{$row['registr']}', '{$weight}')"); } } elseif ($id <> "") { /*$del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://firma/".$id."'"); if (!$del_obj_news) error(); $r_f=sql("select domen from firma where domen <> '' and id='".$id."'"); if (!$r_f) error(); while ($rs_f=sqlget($r_f)) { $d_f=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like '".$abs_url_search."klient/".$rs_f['domen']."/%'"); if (!$d_f) error(); }*/ $r=sql("select id, name, name_ur, adress, home, telefon, email, url, info, domen, path, registr, id_tarif, keyword from firma where id='".intval($id)."'"); //sph indexator $row = sqlval("select * from firma where id='{$id}'"); db_connect_sph(); if ( $row['id'] != '' ) { //replace $sph_id = $row['id'] * 100 + 1; $row['name'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['name'])); $row['name_ur'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['name_ur'])); $row['info'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['info'])); $row['keyword'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['keyword'])); $l = db_connect(); $rubriks = sql("select * from rubrik2 where id_firm={$row['id']}"); $row['id'] = $row['id'] * 100 + 1; $rubrik_array = array(); while ( $rubrik = sqlget($rubriks)) { $rs_otrasl = sqlval("select * from otrasl2 where id='{$rubrik['id_rubrik']}'"); $rubrik_array[] = $rs_otrasl['name_otrsl']; } $groups = iconv("windows-1251", "utf-8", implode(', ',$rubrik_array)); $weight = $row['registr'] * $tarif_map[$row['id_tarif']]; db_connect_sph(); sql("replace into {$sph_idx['company']} values ('{$row['id']}', '{$row['name']}', '{$row['name_ur']}', '', '{$row['info']}', '{$row['keyword']}', '{$groups}', '{$row['registr']}', '{$weight}')"); } else { //delete $sph_id = $id * 100 + 1; sql("delete from {$sph_idx['company']} where id={$sph_id}"); } db_connect(); } } //============================ indexator news function news_indexator($id_news, $l) { global $sph_idx; $id_news=intval($id_news); if ($id_news == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://news/%'"); if (!$del_obj_news) error(); $r=sql("select id, news_header, news_short, news_full, razdel from news "); db_connect_sph(); while ($row=sqlget($r)) { $sph_id = $row['id'] * 100 + 5; $row['news_header'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['news_header'])); $row['news_short'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['news_short'])); $row['news_full'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['news_full'])); sql("replace into {$sph_idx['news']} values ('{$sph_id}', '{$row['news_header']}', '{$row['news_short']}', '{$row['news_full']}', '{$row['razdel']}', '{$row['id_rubrik']}', '{$row['status']}', '{$row['tms']}')"); } } elseif ($id_news <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://news/".$id_news."'"); if (!$del_obj_news) error(); $r=sql("select id, news_header, news_short, news_full, razdel from news where id='".$id_news."'"); //sph indexator $row = sqlval("select *, UNIX_TIMESTAMP(`data`) tms from news where id='{$id_news}'"); db_connect_sph(); if ( $row['id'] != '' ) { //replace $sph_id = $row['id'] * 100 + 5; $row['news_header'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['news_header'])); $row['news_short'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['news_short'])); $row['news_full'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['news_full'])); sql("replace into {$sph_idx['news']} values ('{$sph_id}', '{$row['news_header']}', '{$row['news_short']}', '{$row['news_full']}', '{$row['razdel']}', '{$row['id_rubrik']}', '{$row['status']}', '{$row['tms']}')"); } else { //delete $sph_id = $id_news * 100 + 5; sql("delete from {$sph_idx['news']} where id={$sph_id}"); } db_connect(); //.sph indexator } } //============================ indexator news company function news_company_indexator($id_news, $l) { if ($id_news == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://news_company/%'"); if (!$del_obj_news) error(); $r=sql("select id, news_header, news_short, news_full from news_company"); } elseif ($id_news <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://news_company/".$id_news."'"); if (!$del_obj_news) error(); $r=sql("select id, news_header, news_short, news_full from news_company where id='".$id_news."'"); } if (!$r) error(); //$r_lock=sql("LOCK TABLES search_object WRITE"); while ($rs=sqlget($r)) { $date_time = date('Y-m-d H:i:s'); $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('db://news_company/".$rs['id']."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); //========== news_header $mas_news_header=slova($rs['news_header']); $cnt_mn=count($mas_news_header); $weight=5; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_header[$i]=trim($mas_news_header[$i]); if ($mas_news_header[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_header[$i]."', '".$weight."')"); } } //========== news_short $mas_news_short=slova($rs['news_short']); $cnt_mn=count($mas_news_short); $weight=4; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_short[$i]=trim($mas_news_short[$i]); if ($mas_news_short[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_short[$i]."', '".$weight."')"); } } //========== news_full $mas_news_full=slova($rs['news_full']); $cnt_mn=count($mas_news_full); $weight=4; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_full[$i]=trim($mas_news_full[$i]); if ($mas_news_full[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_full[$i]."', '".$weight."')"); } } } //$r_lock=sql("UNLOCK TABLES"); //del_empty(); } //============================ indexator public function public_indexator($id_news = 0, $l) { global $sph_idx; if ($id_news == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://public/%'"); if (!$del_obj_news) error(); $r=sql("select id, news_header, news_short, news_full from public where status='3' or status = '4'"); db_connect_sph(); while ($row=sqlget($r)) { $sph_id = $row['id'] * 100 + 8; $row['news_header'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['news_header'])); $row['news_short'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['news_short'])); $row['news_full'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['news_full'])); sql("replace into {$sph_idx['public']} values ('{$sph_id}', '{$row['news_header']}', '{$row['news_short']}', '{$row['news_full']}', '{$row['id_razdel']}', '{$row['status']}', '{$row['tms']}')"); } } elseif ($id_news <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://public/".$id_news."'"); if (!$del_obj_news) error(); $r=sql("select id, news_header, news_short, news_full from public where (status='3' or status = '4') and id='".$id_news."'"); //sph indexator $row = sqlval("select *, UNIX_TIMESTAMP(`data`) tms from public where id='{$id_news}'"); db_connect_sph(); if ( $row['id'] != '' ) { //replace $sph_id = $row['id'] * 100 + 8; $row['news_header'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['news_header'])); $row['news_short'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['news_short'])); $row['news_full'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['news_full'])); sql("replace into {$sph_idx['public']} values ('{$sph_id}', '{$row['news_header']}', '{$row['news_short']}', '{$row['news_full']}', '{$row['id_razdel']}', '{$row['status']}', '{$row['tms']}')"); } else { //delete $sph_id = $id_news * 100 + 8; sql("delete from {$sph_idx['public']} where id={$sph_id}"); } db_connect(); //.sph indexator } } function faq_indexator($id_news = 0, $l) { if ($id_news == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://faq/%'"); if (!$del_obj_news) error(); $r=sql("select id, vopros, otvet from faq where status='3' or status = '4'"); } elseif ($id_news <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://faq/".$id_news."'"); if (!$del_obj_news) error(); $r=sql("select id, vopros, otvet from faq where (status='3' or status = '4') and id='".$id_news."'"); } } //\====================== indexator home, street function home_indexator($id = 0, $l) { if ($id == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://map_home/%'"); if (!$del_obj_news) error(); $r=sql("select map_home.id as id, name_street, number from map_street, map_home where map_street.id=map_home.id_street and map_home.x > 0"); } elseif ($id <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://map_home/".$id."'"); if (!$del_obj_news) error(); $r=sql("select map_home.id as id, name_street, number from map_street, map_home where map_street.id=map_home.id_street and map_home.id='".$id."'"); } if (!$r) error(); //$r_lock=sql("LOCK TABLES search_object WRITE"); while ($rs=sqlget($r)) { $date_time = date('Y-m-d H:i:s'); $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('db://map_home/".$rs['id']."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); //========== street $mas_news_header=slova($rs['name_street']); $cnt_mn=count($mas_news_header); $weight=15; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_header[$i]=trim($mas_news_header[$i]); if ($mas_news_header[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_header[$i]."', '".$weight."')"); } } //========== home $mas_news_header=slova($rs['number']); $cnt_mn=count($mas_news_header); $weight=15; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_header[$i]=trim($mas_news_header[$i]); if ($mas_news_header[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_header[$i]."', '".$weight."')"); } } } //$r_lock=sql("UNLOCK TABLES"); //del_empty(); } //\====================== indexator street function street_indexator($id = 0, $l) { if ($id == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://street/%'"); if (!$del_obj_news) error(); $r=sql("select id, name_street from map_street where x > 0"); } elseif ($id <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://street/".$id."'"); if (!$del_obj_news) error(); $r=sql("select id, name_street from map_street where id='".$id."'"); } if (!$r) error(); //$r_lock=sql("LOCK TABLES search_object WRITE"); while ($rs=sqlget($r)) { $date_time = date('Y-m-d H:i:s'); $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('db://map_street/".$rs['id']."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); //========== street $mas_news_header=slova($rs['name_street']); $cnt_mn=count($mas_news_header); $weight=31; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_header[$i]=trim($mas_news_header[$i]); if ($mas_news_header[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_header[$i]."', '".$weight."')"); } } } //$r_lock=sql("UNLOCK TABLES"); //del_empty(); } //\====================== indexator tovar function tovar_indexator($id, $l) { global $sph_idx; if ($id == "") return; if ($id == "0") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://tovar/%'"); if (!$del_obj_news) error(); $r=sql("select tovar.id as id, tovar.name as name, price_ot, note_small, tovar.note as note, foto_small from tovar, firma where id_firm=firma.id and firma.registr_price='1' "); } elseif ($id <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://tovar/".$id."'"); if (!$del_obj_news) error(); $r=sql("select tovar.id as id, tovar.name as name, price_ot, note_small, tovar.note as note, foto_small from tovar, firma where id_firm=firma.id and firma.registr_price='1' and tovar.id='".$id."'"); } //$r_lock=sql("UNLOCK TABLES"); //del_empty(); } //\====================== indexator forum function forum_indexator($id_news = 0, $l) { global $sph_idx; if ($id_news == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://articl/%'"); if (!$del_obj_news) error(); $r=sql("select articl.id as id, articl.tema as tema, body, UNIX_TIMESTAMP(`data`) tms, id_forum from articl"); db_connect_sph(); while ($row=sqlget($r)) { $sph_id = $row['id'] * 100 + 6; $row['tema'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['tema'])); $row['body'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['body'])); sql("replace into sph_forum values ('{$sph_id}', '{$row['tema']}', '{$row['body']}', '{$row['id_forum']}', '{$row['tms']}')"); } } elseif ($id_news <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://articl/".$id_news."'"); if (!$del_obj_news) error(); $r=sql("select articl.id as id, id_parent, articl.tema as tema from articl where articl.id='".$id_news."'"); //sph indexator $row = sqlval("select id, tema, body, id_forum, UNIX_TIMESTAMP(`data`) tms from articl where articl.id='{$id_news}'"); db_connect_sph(); if ( $row['id'] != '' ) { //replace $sph_id = $row['id'] * 100 + 6; $row['tema'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['tema'])); $row['body'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['body'])); sql("replace into sph_forum values ('{$sph_id}', '{$row['tema']}', '{$row['body']}', '{$row['id_forum']}', '{$row['tms']}')"); } else { //delete $sph_id = $id_news * 100 + 6; sql("delete from sph_forum where id={$sph_id}"); } db_connect(); //.sph indexator } } //\====================== indexator afisha function afisha_indexator($id = 0, $l) { if ($id == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://afisha/%'"); if (!$del_obj_news) error(); $r=sql("select id, name, note, begin, price from afisha where data_do >= curdate()"); } elseif ($id <> 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://afisha/".$id."'"); if (!$del_obj_news) error(); $r=sql("select id, name, note, begin, price from afisha where data_do >= curdate() and id='".$id."'"); } if (!$r) error(); //$r_lock=sql("LOCK TABLES search_object WRITE"); while ($rs=sqlget($r)) { $date_time = date('Y-m-d H:i:s'); $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('db://afisha/".$rs['id']."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); //========== name for ($k=1; $k<=4; $k ++) { $mas_news_header=slova($rs[$k]); $cnt_mn=count($mas_news_header); $weight=3; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_header[$i]=trim($mas_news_header[$i]); if ($mas_news_header[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_header[$i]."', '".$weight."')"); } } } } //$r_lock=sql("UNLOCK TABLES"); //del_empty(); } //\====================== doska function fbb_indexator($id = 0, $l) { global $sph_idx; if ($id == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://bb_data/%'"); if (!$del_obj_news) error(); $r=sql("select id, name, note, email, phone, price from bb_data where data_end >= curdate()"); } elseif ($id <> 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://bb_data/".$id."'"); if (!$del_obj_news) error(); $r=sql("select id, name, note, email, phone, price from bb_data where data_end >= curdate() and id='".$id."'"); //sph indexator $row = sqlval("select *, UNIX_TIMESTAMP(`data`) tms from bb_data where data_end >= curdate() and status=3 and id='{$id}'"); db_connect_sph(); if ( $row['id'] != '' ) { //replace $sph_id = $row['id'] * 100 + 9; $row['name'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['name'])); $row['note'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['note'])); sql("replace into sph_bb values ('{$sph_id}', '{$row['name']}', '{$row['note']}', '{$row['id_razdel']}', '{$row['status']}', '{$row['tms']}')"); } else { //delete $sph_id = $id * 100 + 9; sql("delete from sph_bb where id={$sph_id}"); } db_connect(); //.sph indexator } } //\====================== indexator afisha function programma_indexator($id = 0, $l) { if ($id == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://tv/%'"); if (!$del_obj_news) error(); $r=sql("select id, kanal, programma, data from tv where data >= curdate()"); } elseif ($id <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://tv/".$id."'"); if (!$del_obj_news) error(); $r=sql("select id, kanal, programma, data from tv where data >= curdate() and id='".$id."'"); } if (!$r) error(); //$r_lock=sql("LOCK TABLES search_object WRITE"); while ($rs=sqlget($r)) { $date_time = date('Y-m-d H:i:s'); $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('db://tv/".$rs['id']."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); //========== kanal for ($k=1; $k<=3; $k ++) { $mas_news_header=slova($rs[$k]); $cnt_mn=count($mas_news_header); $weight=3; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_header[$i]=trim($mas_news_header[$i]); if ($mas_news_header[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_header[$i]."', '".$weight."')"); } } } } //$r_lock=sql("UNLOCK TABLES"); //del_empty(); } //\====================== indexator diary function diary_indexator($id_news = 0, $l) { if ($id_news == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://diary/%'"); if (!$del_obj_news) error(); $r=sql("select diary.id as id, diary.body as dbody from diary where alo_view='1'"); } elseif ($id_news <> 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://diary/".$id_news."'"); if (!$del_obj_news) error(); $r=sql("select diary.id as id, diary.body as dbody from diary where alo_view='1' and diary.id='".$id_news."'"); } if (!$r) error(); ////$r_lock=sql("LOCK TABLES search_object WRITE"); while ($rs=sqlget($r)) { $date_time = date('Y-m-d H:i:s'); $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('db://diary/".$rs['id']."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); //========== dbody $mas_news_header=slova($rs['dbody']); $cnt_mn=count($mas_news_header); $weight=1; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_header[$i]=trim($mas_news_header[$i]); if ($mas_news_header[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_header[$i]."', '".$weight."')"); } } //========== kbody $r_koment=sql("select body from diary_koment where id_parent='".$rs['id']."'"); if (!$r_koment) error(); while ($rs_kom=sqlget($r_koment)) { $mas_news_header=slova($rs_kom['body']); $cnt_mn=count($mas_news_header); $weight=1; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_header[$i]=trim($mas_news_header[$i]); if ($mas_news_header[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_header[$i]."', '".$weight."')"); } } } } ////$r_lock=sql("UNLOCK TABLES"); //del_empty(); } //\====================== indexator katol сайтов function yand_indexator($id = 0, $l) { if ($id == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://yand_katalog/%'"); if (!$del_obj_news) error(); $r=sql("select id, href, note from yand_katalog "); } elseif ($id <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://yand_katalog/".$id."'"); if (!$del_obj_news) error(); $r=sql("select id, href, note from yand_katalog where id='".$id."'"); } if (!$r) error(); //$r_lock=sql("LOCK TABLES search_object WRITE"); while ($rs=sqlget($r)) { $date_time = date('Y-m-d H:i:s'); $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('db://yand_katalog/".$rs['id']."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); //========== kanal for ($k=1; $k<=3; $k ++) { $mas_news_header=slova($rs[$k]); $cnt_mn=count($mas_news_header); $weight=3; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_header[$i]=trim($mas_news_header[$i]); if ($mas_news_header[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_header[$i]."', '".$weight."')"); } } } } //$r_lock=sql("UNLOCK TABLES"); //del_empty(); } //\====================== indexator otrasl function otrasl_indexator($id = 0, $l) { if ($id == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://otrasl/%'"); if (!$del_obj_news) error(); $r=sql("select distinct name_otrsl, otrasl.id as id from otrasl, rubrik where id_rubrik=otrasl.id"); } elseif ($id <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://otrasl/".$id."'"); if (!$del_obj_news) error(); $r=sql("select distinct name_otrsl, otrasl.id as id from otrasl, rubrik where id_rubrik=otrasl.id and otrasl.id='".$id."'"); } if (!$r) error(); //$r_lock=sql("LOCK TABLES search_object WRITE"); while ($rs=sqlget($r)) { $date_time = date('Y-m-d H:i:s'); $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('db://otrasl/".$rs['id']."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); //========== kanal for ($k=0; $k<=0; $k ++) { $mas_news_header=slova($rs[$k]); $cnt_mn=count($mas_news_header); $weight=1000; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_header[$i]=trim($mas_news_header[$i]); if ($mas_news_header[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_header[$i]."', '".$weight."')"); } } } } //$r_lock=sql("UNLOCK TABLES"); //del_empty(); } function public_razdel_indexator($id = 0, $l) { if ($id == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://public_razdel/%'"); if (!$del_obj_news) error(); $r=sql("select distinct id, name, note from public_razdel"); } elseif ($id <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://public_razdel/".$id."'"); if (!$del_obj_news) error(); $r=sql("select distinct name, note from public_razdel where id='".$id."'"); } if (!$r) error(); //$r_lock=sql("LOCK TABLES search_object WRITE"); while ($rs=sqlget($r)) { $date_time = date('Y-m-d H:i:s'); $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('db://public_razdel/".$rs['id']."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); for ($k=0; $k<=1; $k ++) { $mas_news_header=slova($rs[$k]); $cnt_mn=count($mas_news_header); $weight=260; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_header[$i]=trim($mas_news_header[$i]); if ($mas_news_header[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_header[$i]."', '".$weight."')"); } } } } } //\====================== indexator grtovar_new function grtovar_new_indexator($id = 0, $l) { if ($id == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://grtovar_new/%'"); if (!$del_obj_news) error(); $r=sql("select distinct grtovar_new.name as name, grtovar_new.id from grtovar_new, rubrik_tovar, tovar, firma where id_firm=firma.id and rubrik_tovar.id_tovar = tovar.id and grtovar_new.id=id_rubrik"); } elseif ($id <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://grtovar_new/".$id."'"); if (!$del_obj_news) error(); $r=sql("select distinct grtovar_new.name as name, grtovar_new.id from grtovar_new, rubrik_tovar, tovar, firma where id_firm=firma.id and rubrik_tovar.id_tovar = tovar.id and grtovar_new.id=id_rubrik grtovar_new.id='".$id."'"); } if (!$r) error(); //$r_lock=sql("LOCK TABLES search_object WRITE"); while ($rs=sqlget($r)) { $date_time = date('Y-m-d H:i:s'); $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('db://grtovar_new/".$rs['id']."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); //========== kanal for ($k=0; $k<=0; $k ++) { $mas_news_header=slova($rs[$k]); $cnt_mn=count($mas_news_header); $weight=155; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_header[$i]=trim($mas_news_header[$i]); if ($mas_news_header[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_header[$i]."', '".$weight."')"); } } } } //$r_lock=sql("UNLOCK TABLES"); //del_empty(); } function restoran_indexator($id = 0, $l) { global $sph_idx; if ( $id == 0 ) { $del_obj_restoran = sql("DELETE `search_object`.*, `search_index`.* FROM `search_object`, `search_index` WHERE `id_obj`=`search_object`.`id` AND `name` LIKE 'db://restoran/%'"); if ( !$del_obj_restoran ) { error(); } $l2 = db_connect_restoran(); $r=sql("SELECT *, UNIX_TIMESTAMP(`date`) tms FROM `restoran`"); db_connect_sph(); while ($row=sqlget($r)) { $sph_id = $row['id'] * 100 + 13; $row['name'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['name'])); $row['info'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['info'])); sql("replace into sph_restoran values ('{$row['id']}', '{$row['name']}', '{$row['info']}', '{$row['status']}', '{$row['tms']}')"); } $l = db_connect(); } elseif ($id != 0) { $del_obj_restoran = sql("DELETE `search_object`.*, `search_index`.* FROM `search_object`, `search_index` WHERE `id_obj`=`search_object`.`id` AND `name` = 'db://restoran/{$id}'"); if (!$del_obj_restoran) { error(); } $l2 = db_connect_restoran(); //$r=sql("SELECT `id`, `name` FROM `restoran` WHERE status='3' and `id`='{$id}'", $l2); //sph indexator $row = sqlval("select *, UNIX_TIMESTAMP(`date`) tms from restoran where status=3 and id='{$id}'", $l2); db_connect_sph(); if ( $row['id'] != '' ) { //replace $sph_id = $row['id'] * 100 + 13; $row['name'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['name'])); $row['info'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['info'])); sql("replace into sph_restoran values ('{$row['id']}', '{$row['name']}', '{$row['info']}', '{$row['status']}', '{$row['tms']}')"); } else { //delete $sph_id = $id * 100 + 13; sql("delete from sph_restoran where id={$sph_id}"); } db_connect(); //.sph indexator } } //\=================== raspisanie //\=================== horoskop function horoskop_indexator($weight,$l) { $host=$_SERVER['HTTP_HOST']; $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'http://".$host."/horoscop/spisok.php'"); if (!$del_obj_news) error(); read_url("http://".$host."/horoscop/spisok.php",1,$l); } //\================ удаляем пустые function del_empty() { // $r_del_empty=sql("delete search_object.* from search_object left join search_index on search_object.id=id_obj where id_obj is null"); // if (!$r_del_empty) error(); } //\=================== разбираем строку ссылку function parse_link($link) { if (substr($link, 0, 3) == "db:") { $link_parse[0] = "db"; $link_parse[1] = substr($link, 5, strrpos($link, "/")-5); $link_parse[2] = substr($link, strrpos($link, "/")+1, 14); } if (substr($link, 0, 4) == "http") { $link_parse[0] = "http"; $link=substr($link, 7, strlen($link)); $link_parse[1] = substr($link, 0, strpos($link, "/")); $link_parse[2] = substr($link, strpos($link, "/") +1, strlen($link)); } return $link_parse; } //\=================== разбираем текст function xparse($fn,$text="",$LOCALS=array()) { if (empty($text)) $text=contents_file($fn); $text=preg_replace("!^ *(#|//).*[\r\n]*!m","",$text); $text=preg_replace("!^ +!m"," ",$text); if (strpos($text,"\\=")!==false) $text=preg_replace("![\\\\]=([a-f0-9]{2})!e","chr(hexdec('\\1'))",$text); return preg_replace("!\{\\\$([a-z_][a-z0-9_]*)(\[([a-z0-9_-]+)\])?(\[([a-z0-9_-]+)\])?\}!ie","xparse_('\\1','\\3','\\5',\$LOCALS,\$fn)",$text); } function xparse_($n1,$n2,$n3,$LOCALS,$fn) { if ($n2=="") { if (isset($LOCALS[$n1])) return $LOCALS[$n1]; if (isset($GLOBALS[$n1])) return $GLOBALS[$n1]; return ""; } if ($n3=="") { if (isset($LOCALS[$n1][$n2])) return $LOCALS[$n1][$n2]; if (isset($GLOBALS[$n1][$n2])) return $GLOBALS[$n1][$n2]; return ""; } if (isset($LOCALS[$n1][$n2][$n3])) return $LOCALS[$n1][$n2][$n3]; if (isset($GLOBALS[$n1][$n2][$n3])) return $GLOBALS[$n1][$n2][$n3]; return ""; } function cssparse($fn) { $text=myfile($fn); $text=preg_replace("!^#.*[\r\n]*!m","",$text); $text=preg_replace("! +!"," ",$text); $text=preg_replace("![\r\n]!","",$text); $text=str_replace("\r","",$text); $text=str_replace("\n","",$text); $text=str_replace(": ",":",$text); $text=str_replace(" :",":",$text); $text=str_replace(" {","{",$text); $text=str_replace("{ ","}",$text); $text=str_replace(" ;",";",$text); $text=str_replace("; ",";",$text); return xparse("",$text); } function jsparse($fn) { $text=xparse($fn); $text=preg_replace("!^ +!m","",$text); $text=preg_replace("!^ *//.*!m","",$text); $text=preg_replace("!^ *#[^#]*!m","",$text); return $text; } //\============ banner function echo_banner($type, $kol = 1, $keyw, $script = 0) { global $id_user_sess, $base_url, $abs_url, $admlist, $login; if ($admlist[$login] == 1000) { echo "test"; } if ($keyw <> "") { // ключевое слово $sql_keyw = " and keyw like '%".mysql_real_escape_string($keyw)."%'"; } if ($type == "rand") { // случайно if ($id_user_sess == "") { // $r_count=sqlval("select count(*) from bannercl where status='3' and curdate() between data and data_end ".$sql_keyw.""); // $ofs_rand=rand(0, $r_count[0]-1); $r=sql("select bannercl.*,banner_type.template as template from bannercl, banner_type where banner_type.id=type and status='3' and (curdate() between data and data_end) ".$sql_keyw." order by rand() limit 0, ".$kol); } else { //$r_count=sqlval("select count(*) from bannercl where (status='3' or status='4') and (curdate() between data and data_end) ".$sql_keyw.""); //$ofs_rand=rand(0, $r_count[0]-1); $r=sql("select bannercl.*,banner_type.template as template from bannercl, banner_type where banner_type.id=type and (status='3' or status='4') and (curdate() between data and data_end) ".$sql_keyw." order by rand() limit 0, ".$kol); } } if ($type == "plain") { // планомерно if ($id_user_sess == "") { $r=sql("select bannercl.*,banner_type.template as template, type from bannercl, banner_type where banner_type.id=type and status='3' and (curdate() between data and data_end) ".$sql_keyw." order by pozis, bannercl.id limit 0, ".$kol); } else { $r=sql("select bannercl.*,banner_type.template as template from bannercl, banner_type where banner_type.id=type and (status='3' or status='4') and (curdate() between data and data_end) ".$sql_keyw." order by pozis, bannercl.id limit 0, ".$kol); } } if ($type == "next") { // планомерно if ($id_user_sess == "") { $r=sql("select bannercl.*,banner_type.template as template, type from bannercl, banner_type where banner_type.id=type and status='3' and (curdate() between data and data_end) ".$sql_keyw." order by pozis, bannercl.id limit 0, ".$kol); } else { $r=sql("select bannercl.*,banner_type.template as template from bannercl, banner_type where banner_type.id=type and (status='3' or status='4') and (curdate() between data and data_end) ".$sql_keyw." order by pozis, bannercl.id limit 0, ".$kol); } } if (!$r) error(); while ($res=sqlget($r)) { $r_templ=sqlval("select template from banner_razdel where keyw like '%".$keyw."%'"); if (!$r_templ) error(); $template=stripslashes($r_templ['template']); if ($res['type'] == 2) $link=urlencode($abs_url."click_b.php?id=".$res['id']); else $link=$abs_url."click_b.php?id=".$res['id']; $link2=$abs_url."click_b.php?id=".$res['id']; $src_banner="/view_b.php?id=".$res['id']."&link1=".$link; $src_banner2=$abs_url."view_b.php?id=".$res['id']."&baner=2"; $banner_width=$res['width']; $banner_height=$res['height']; $alt=$res['alt']; $target=$res['target']; $u_s=$_COOKIE["u_s"]; $source=xparse("",$res['template'], get_defined_vars()); if ($r_templ['template'] <> "") { if ($script == 0) echo xparse("",$template, get_defined_vars()); if ($script == 1) return xparse("",$template, get_defined_vars()); } else { if ($script == 0) echo $source; if ($script == 1) return $source; } /* if ($res['file'] == "" && $res['file2'] == "") { $r_ins=sql("insert into banner_stat (id_ban, status, data, time) values ('".$res['id']."', '0', curdate(), '".date('H')."')"); if (!$r_ins) error(); } */ //setcookie($type, $res['id'], time()+86400); } } ///// банеры function echo_banner_pokaz($menu_page,$id_vid, $type = "plain", $id_pr = 0, $kol = 1, $script = 0) { global $id_user_sess, $base_url, $abs_url, $admlist, $login; // if ($ip == "") $ip=getenv("REMOTE_ADDR"); $sql_podr = ''; $str_not_id = ''; if ($id_pr > 0) {//$sql_podr = " and `banner_mesto`.`id_pr` = '".$id_pr."'"; $sql_podr = " and `banner_mesto`.`id_pr` in ($id_pr) "; } // $str_not_id="("; if (isset($_COOKIE['bv']) && count($_COOKIE['bv']) > 0) { foreach ($_COOKIE['bv'] as $key => $value) { if ($value > 20) { $str_not_id.=" and bannercl.id <> '".$key."'"; } } } //$str_not_id.=")"; if ($type == "rand") { // случайно $r=sql("select bannercl.*,banner_type.template as template, banner_mesto.id as id_mesto from bannercl, banner_type, banner_razdel2, banner_mesto where `banner_mesto`.`id_razdel`=`banner_razdel2`.`id` and `banner_mesto`.`id_banner` = `bannercl`.`id` and (banner_razdel2.menu_page='".$menu_page."' or banner_razdel2.menu_page='all') and id_vid='".intval($id_vid)."' and banner_type.id=type and status='3' and ((curdate() >= data and balance > 0) or (curdate() between data and data_end and balance = '-1.00')) ".$sql_podr." ".$str_not_id." order by rand() limit 0, ".$kol); if ($admlist[$login] == 1000) { /* echo "select bannercl.*,banner_type.template as template, banner_mesto.id as id_mesto from bannercl, banner_type, banner_razdel2, banner_mesto where `banner_mesto`.`id_razdel`=`banner_razdel2`.`id` and `banner_mesto`.`id_banner` = `bannercl`.`id` and (banner_razdel2.menu_page='".$menu_page."' or banner_razdel2.menu_page='all') and id_vid='".intval($id_vid)."' and banner_type.id=type and status='3' and ((curdate() >= data and balance > 0) or (curdate() between data and data_end and balance = '-1.00')) ".$sql_podr." ".$str_not_id." order by rand() limit 0, ".$kol;*/ } /*if($_SESSION['login']=='sanshan'){ echo "select bannercl.*,banner_type.template as template, banner_mesto.id as id_mesto from bannercl, banner_type, banner_razdel2, banner_mesto where `banner_mesto`.`id_razdel`=`banner_razdel2`.`id` and `banner_mesto`.`id_banner` = `bannercl`.`id` and (banner_razdel2.menu_page='".$menu_page."' or banner_razdel2.menu_page='all') and id_vid='".intval($id_vid)."' and banner_type.id=type and status='3' and ((curdate() >= data and balance > 0) or (curdate() between data and data_end and balance = '-1.00')) ".$sql_podr." ".$str_not_id." order by rand() limit 0,1"; }*/ // if ($id_user_sess == 1) echo "select bannercl.*,banner_type.template as template, banner_mesto.id as id_mesto from bannercl, banner_type, banner_razdel2, banner_mesto where `banner_mesto`.`id_razdel`=`banner_razdel2`.`id` and `banner_mesto`.`id_banner` = `bannercl`.`id` and (banner_razdel2.menu_page='".$menu_page."' or banner_razdel2.menu_page='all') and id_vid='".intval($id_vid)."' and banner_type.id=type and status='3' and curdate() >= data and (balance > 0 or balance = '-1.00') ".$sql_podr." order by rand() limit 0, ".$kol; } if ($type == "plain") { // планомерно $r=sql("select bannercl.*,banner_type.template as template, banner_mesto.id as id_mesto from bannercl, banner_type, banner_razdel2, banner_mesto where id_razdel=banner_razdel2.id and `banner_mesto`.`id_banner` = `bannercl`.`id` and (menu_page='".$menu_page."' or menu_page='all') and id_vid='".intval($id_vid)."' and banner_type.id=type and status='3' and ((curdate() >= data and balance > 0) or (curdate() between data and data_end and balance = '-1.00')) ".$sql_podr." ".$str_not_id." limit 0, ".$kol); } //echo "select bannercl.*,banner_type.template as template, banner_mesto.id as id_mesto from bannercl, banner_type, banner_razdel2, banner_mesto where `banner_mesto`.`id_razdel`=`banner_razdel2`.`id` and (banner_razdel2.menu_page='".$menu_page."' or banner_razdel2.menu_page='all') and id_vid='".intval($id_vid)."' and banner_type.id=type and status='3' and curdate() >= data and (balance > 0 or balance = '-1.00') order by rand() limit 0, ".$kol; while ($res=sqlget($r)) { $r_templ=sqlval("select * from banner_vid where id='".$id_vid."'"); if (!$r_templ) error(); $template=stripslashes($r_templ['template']); if ($res['type'] == 2) $link=urlencode($abs_url."click_b.php?id=".$res['id']); else $link=$abs_url."click_b.php?id=".$res['id']; $link2=$abs_url."click_b.php?id=".$res['id']; $src_banner="/view_b.php?id_mesto=".$res['id_mesto']."&ncr=".rand(0,10000)."&id=".$res['id']."&link1=".$link; $src_banner2=$abs_url."view_b.php?id_mesto=".$res['id_mesto']."&ncr=".rand(0,10000)."&id=".$res['id']."&baner=2"; $banner_width=$r_templ['width']; $banner_height=$r_templ['height']; $alt=$res['alt']; $u_s = (isset($_COOKIE["u_s"])) ? $_COOKIE["u_s"] : ''; $source=xparse("",$res['template'], get_defined_vars()); if ($r_templ['template'] <> "") { if ($script == 0) echo xparse("",$template, get_defined_vars()); if ($script == 1) return xparse("",$template, get_defined_vars()); } else { if ($script == 0) echo $source; if ($script == 1) return $source; } if ($res['file'] == "" && $res['file2'] == "") { $r_ins=sql("insert into `banner_stat` set `id_ban`='".$res['id']."' , `data`=curdate() , `time`='".date('H')."' , `min`='".date('i')."' , `ip` = '".getenv("REMOTE_ADDR")."' , `id_mesto` = '".$res['id_mesto']."' "); // if (!$r_ins) echo mysql_error(); } //setcookie($type, $res['id'], time()+86400); } } function banner_balance($data = "") { if ($data == "") $data=date('Y-m-d'); $r_ban=sql("select bannercl.*, banner_vid.crm as crm, banner_razdel2.koef as koef, banner_mesto.id as id_mesto, banner_razdel2.name as name_razdel, banner_mesto.id_pr as id_pr from bannercl, banner_vid, banner_razdel2, banner_mesto where bannercl.id_vid=banner_vid.id and banner_mesto.id_razdel=banner_razdel2.id and banner_mesto.id_banner=bannercl.id and bannercl.balance > 0"); while ($rs=sqlget($r_ban)) { if ($rs['id_pr'] > 0) { $r_podrazdel=sqlval("select name_otrsl from otrasl2 where id = '".$rs['id_pr']."'"); $rs['name_razdel'].=" :: ".$r_podrazdel['name_otrsl']; } $r_stat=sqlval("select count(*) from banner_stat where id_ban='".$rs['id']."' and data = '".$data."' and id_mesto='".$rs['id_mesto']."'"); $balance=$r_stat[0]/1000*($rs['crm']*$rs['koef']); $r_unik_record=sql("delete from banner_balance where id_banner='".$rs['id']."' and `razdel` = '".$rs['name_razdel']."' and `data` = '".$data."' "); // if ($r_unik_record[0] == 0) { $rbalance=sql("insert into banner_balance set `data` = '".$data."' , `id_banner` = '".$rs['id']."' , `summa` = '-".$balance."' , `count_pokaz` = '".$r_stat[0]."' , `razdel` = '".$rs['name_razdel']."' "); $balance=sqlval("select sum(summa) from banner_balance where id_banner='".$rs['id']."'"); $r_upd_banner=sql("update bannercl set balance='".$balance[0]."' where id='".$rs['id']."' "); // } } } function banner_napominal() { $data_oldday=date('Y-m-d', mktime(0, 0, 0, date("m") , date("d")-1, date("Y"))); //include('/usr/local/www/info-city.su/html/infocrm/lib/scripts/webicqlite.class.php'); $r_ban=sql("select bannercl.* from bannercl where bannercl.balance > 0"); while ($rs_ban=sqlget($r_ban)) { $r_balance_sred=sqlval("select sum(summa) from banner_balance where id_banner='".$rs_ban['id']."' and data = '".$data_oldday."' and summa < 0"); if (intval(abs($r_balance_sred[0])) <= 0) $r_balance_sred[0]=1; $count_day_next=round($rs_ban['balance']/abs($r_balance_sred[0])); if ($count_day_next < 5) { $r_icq=sqlval("SELECT `infocity`.`info_sotrudnik`.`id` FROM `infocity`.`info_scheta` , `infocity`.`info_sotrudnik` , infoorel.banner_balance WHERE banner_balance.id_banner = '".$rs_ban['id']."' AND infoorel.banner_balance.id_scheta = `infocity`.`info_scheta`.`id` AND `infocity`.`info_scheta`.`id_manager` = `infocity`.`info_sotrudnik`.`id` "); $message="Баннеру www.infoorel.ru/view_b.php?id=".$rs_ban['id']."&admin=1 осталось размещаться примерно ".$count_day_next." РґРЅСЏ."; $r_ins=sql("insert into `infocity`.`info_napominal` set id_sotrudnik='".$r_icq['id']."' , data=curdate() , tim=curtime() , note='".$message."' "); } } $r_ban=sql("SELECT bannercl. * , ( unix_timestamp( data_end ) - unix_timestamp( curdate( ) ) ) AS razn FROM bannercl WHERE bannercl.balance = '-1.00' AND ( unix_timestamp( data_end ) - unix_timestamp( curdate( ) ) ) >0 AND ( unix_timestamp( data_end ) - unix_timestamp( curdate( ) ) ) < 345600"); while ($rs = sqlget($r_ban)) { $count_day_next=round($rs['razn']/86400); $message="Баннеру www.infoorel.ru/view_b.php?id=".$rs['id']."&admin=1 осталось размещаться примерно ".$count_day_next." РґРЅСЏ."; $r_icq=sql("SELECT user.id as id FROM user, banner_user WHERE id_banner = '".$rs['id']."' id_user=user.id "); while ($rs_icq=sqlget($r_icq)) { $r_ins=sql("insert into rpl_incoming set id_sender='16' , id_recipient='".$rs_icq['id']."' , message='".$message."' "); } } } //\============================================ Голосования function echo_vote($pap = 20, $rand = false, $id_poll = 0, $all = false, $bgcolor = "", $razdel = 1, $text) { global $id_user_sess, $user_right, $_GET, $PHPSESSID, $ip, $ip2, $base_url, $forum_global, $page, $admlist, $login; //$uagent=getenv(http_user_agent); //$uinmd=md5($ip.$ip2.$uagent); if ($id_poll != 0) { $qr_id_poll = " and id= '".intval($id_poll)."'"; } else $qr_id_poll= ""; $_GET['ofs']=intval($_GET['ofs']); if ($id_user_sess == "") { if ($rand) { $rcount=sqlval("select count(*) from pollf_name where status='3' and if(data_end<>'0000-00-00',curdate(),'0') <= data_end and razdel='".intval($razdel)."'"); if (!$rcount) error(); $_GET['ofs']=rand(0,$rcount[0]-$pap); } if ($id_poll == 0) $rf=sql("select SQL_CALC_FOUND_ROWS id, name, data, link, desc_name, data_end, log_mode from pollf_name where status='3' ".$qr_id_poll." and if(data_end<>'0000-00-00',curdate(),'0') <= data_end and razdel='".intval($razdel)."' order by data desc limit ".$_GET['ofs'].", ".$pap); else $rf=sql("select SQL_CALC_FOUND_ROWS id, name, data, link, desc_name, data_end, log_mode from pollf_name where status='3' ".$qr_id_poll." order by data desc limit ".$_GET['ofs'].", ".$pap); } else { if ($rand) { $rcount=sqlval("select count(*) from pollf_name where (status='3' or status='4') and if(data_end<>'0000-00-00',curdate(),'0') <= data_end and razdel='".intval($razdel)."'"); if (!$rcount) error(); $_GET['ofs']=rand(0,$rcount[0]-$pap); } if ($id_poll == 0) { if (!$all) { $rf=sql("select SQL_CALC_FOUND_ROWS id, name, data, link, desc_name, data_end, log_mode from pollf_name where (status='3' or status='4') and if(data_end<>'0000-00-00',curdate(),'0') <= data_end and razdel='".intval($razdel)."' ".$qr_id_poll." order by data desc limit ".$_GET['ofs'].", ".$pap); } else { $rf=sql("select SQL_CALC_FOUND_ROWS id, name, data, link, desc_name, data_end, log_mode from pollf_name where (status='3' or status='4') and razdel='".intval($razdel)."' order by data desc limit ".$_GET['ofs'].", ".$pap); } } else $rf=sql("select SQL_CALC_FOUND_ROWS id, name, data, link, desc_name, data_end, log_mode from pollf_name where (status='3' or status='4') ".$qr_id_poll." order by data desc limit ".$_GET['ofs'].", ".$pap); } if (!$rf) { error(); } // if ($_SERVER['REMOTE_ADDR'] == '195.19.92.92'){ $query = "select * from pollf_name where status=3".$qr_id_poll; $vote_data = sqlval($query); $video =""; if ($vote_data['link'] !== ""){ $link = "//".$vote_data['link']; // $vote_data['link'] = preg_replace("/\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i","<iframe width=\"560\" height=\"315\" src=\"//www.youtube.com/embed/$1\" frameborder=\"0\" allowfullscreen></iframe>", $vote_data['link'] ); $video = '<iframe width=\"560\" height=\"315\" src="'.$link.'" frameborder=\"0\" allowfullscreen></iframe>'; } // } $kol=sqlval("SELECT FOUND_ROWS()"); // echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" >"; while ($rsf=sqlget($rf)) { $r_count=sqlval("select count(*) from pollf_data where id_poll='{$rsf['id']}'"); if (!$r_count) error(); $pol_data_len=sqlval("select avg(length(name)) as name from pollf_data where id_poll='".$rsf['id']."' order by mx desc limit 0, 1"); //$cnt_golos=sqlval("select count(*) from poll_log, poll_data where uinmd='".$uinmd."' and poll_data.id=id_data and id_poll='".$rsf['id']."'"); //if (!$cnt_golos) error(); //if ($cnt_golos[0] == 0) $koef_golos=18; //else $koef_golos=42; //$koef=(ceil($pol_data_len['name']/10)+2)*$koef_golos; $height=($r_count[0]+4)*$koef_golos; echo "<div height=\"".$height."\" align=\"left\">".prepare_post($text). "<p class='uk-margin-top uk-margin-bottom'>".$vote_data ['desc_name']."</p>". $video. "<iframe name=\"golos_frame\" src=\"".$base_url."vote_frame.php?id_vote=".$rsf['id']."&forum=".$forum_global."&all=".$all."&r=" . uniqid() . "\" width=\"100%\" height=\"".$height."\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" allowtransparency=\"true\"></iframe> </div>"; } if (($kol[0] > $pap) && ($pap <> 1)) { echo "<div align=\"center\"> "; if (empty($page)) $page=1; list_all($kol[0],"?archiv=".$_GET['archiv'],8,$page,$pap,"ofs",1); echo "</div>"; } //echo "</table>"; } ///============================ разделы function index_razdel($id_razdel, $id_user, $status) { if ($id_user <> "" && $id_razdel <> "") { $r_exist=sqlval("select id from index_razdel where id_razdel = '".$id_razdel."' and id_user= '".$id_user."'"); if ($r_exist['id'] <> "") { $r_u=sql("update index_razdel set status = '".$status."' where id = '".$r_exist['id']."'"); if (!$r_u) error(); } else { $r_u=sql("insert into index_razdel (id_user, id_razdel, status) values ('".$id_user."', '".$id_razdel."', '".$status."')"); if (!$r_u) error(); } } } ///============================== авторизация function authorize() { global $_SESSION, $_COOKIE, $_REQUEST, $id_user_sess, $b_sess, $ip, $ip2,$uagent, $uinmd; require(__DIR__ . "/inc/authorize.inc.php"); } /// function forum_mail($id_forum, $id, $id_parent, $id_user, $moder = 0) { global $tema,$body_moder, $mail_from, $abs_url; $user=sqlval("select `name` from `user` where id = '".intval($id_user)."'"); if ($moder == 1) { // РїРёСЃСЊРјРѕ модератору $moder_mail=sql("select mail from user, forum_moder where id_user=user.id and id_forum='".intval($id_forum)."' and forum_moder.mail_send = '1'"); $mail = new \app\core\models\Mail(); while ($rs=sqlget($moder_mail)) { $mail->send( 'info@infoorel.ru', 'Р�нфоОрел', $rs['mail'], "Форум ".$abs_url, "Доброе время суток, МОДЕРАТОР!<br>Р’ вашем форуме появилась новая тема <br><br>\"".$tema."\"<br>Написал: ".$user['name']."<br>Содержание:<br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>".$body_moder."<br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>Данное сообщение находится РїРѕ адресу: <br><br> ".$abs_url."/forum/forum_read.php?f=".$id_forum."&id=".$id_parent."&newpost=true <br><br>" ); } } else { // РїРёСЃСЊРјР° пользователям $tema_parent=sqlval("select tema from articl where id='".intval($id_parent)."'"); $rmail=sql("select distinct user.mail as email, name, user.id as uid from user, articl where articl.id_author=user.id and articl.id_parent='".$id_parent."' and articl.email='1' and user.id <> '".intval($id_user)."'"); if (!$rmail) error(); while ($resmail=sqlget($rmail)) { $send_mail = 0; $r_send=sqlval("select data from forum_esend where id_user = '".$resmail['uid']."' and id_parent = '".intval($id_parent)."'"); if (!$r_send) error(); if ($r_send['data'] <> "") { // РїРёСЃСЊРјР° отправляли СѓР¶Рµ $r_read=sqlval("select count(*) from forum_read where id_user='".$resmail['uid']."' and id_parent = '".intval($id_parent)."' and unix_timestamp(data) < ".$r_send['data']); if (!$r_read) error(); if ($r_read[0] > 0) $send_mail = 0; else $send_mail = 1; } else $send_mail = 1; if ($send_mail == 1) { $mail = new \app\core\models\Mail(); $mail->send( "info@infoorel.ru", "Р�нфоОрел", $resmail['email'], 'РќРѕРІРѕРµ сообщенеи РЅР° форуме', "Форум ".$abs_url,"Доброе время суток, ".$resmail['name']."!<br>Р’ теме \"".$tema_parent['tema']."\" появилось РЅРѕРІРѕРµ сообщение. <br>Автор: ".$user['name']."<br>Содержание:<br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>".$body_moder."<br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br><br>Данное сообщение находится РїРѕ адресу: <br><br> ".$abs_url."forum/forum_read.php?f=".$id_forum."&id=".$id_parent."&newpost=true <br><br><br><br> Отказаться РѕС‚ данной рассылки РјРѕР¶РЅРѕ РїРѕ адресу ".$abs_url."forum/otpis.php?id_user=".$resmail['uid']."&id_parent=".$id_parent ); sql("delete from forum_esend where id_user = '".$resmail['uid']."' and id_parent = '".intval($id_parent)."'"); sql("insert into forum_esend (id_user, id_parent, data, email) values ('".$resmail['uid']."', '".intval($id_parent)."', unix_timestamp('".date('Y-m-d H:i:s')."'), '".$resmail['email']."')"); } } } } function forum_mail_moder($id_forum, $id, $id_parent, $id_user) { global $tema,$body_moder, $mail_from, $abs_url; $moder_mail=sql("select mail from user, forum_moder where id_user=user.id"); while ($rs=sqlget($moder_mail)) { $ml=mail($rs['mail'],"Форум ".$abs_url,"Доброе время суток, МОДЕРАТОР!\nР’ вашем форуме появилась новая тема \n\n\"".$tema."\"\nНаписал: ".$user['name']."\nСодержание:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n".$body_moder."\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nДанное сообщение находится РїРѕ адресу: \n\n ".$abs_url."/forum/forum_read.php?f=".$id_forum."&id=".$id_parent."&newpost=true\n\n\n\n", "From: $mail_from\r\n" ."MIME-Version: 1.0\r\n" ."Content-type: text/plain; charset=utf-8\r\n" ."Reply-To: $mail_from\r\n" ."X-Mailer: PHP/" . phpversion()."\r\n"); } } ///////////////////=============================================== function prepare_post_icq($body) { global $admlist,$id_user_sess, $img_insert, $_POST; if ($admlist[$login] >= 500) {} else { $body=htmlspecialchars($body); $body=str_replace("<b>","<b>",$body); $body=str_replace("</b>","</b>",$body); $body=str_replace("<i>","<b>",$body); $body=str_replace("</i>","</b>",$body); } $kol_q1=substr_count ($body, "[quote]"); $kol_q2=substr_count ($body, "[/quote]"); if (is_int(strpos($body,"[quote]"))) { if (!is_int(strpos($body,"[/quote]"))) { $body.="[/quote]"; } } if (is_int(strpos($body,"[/quote]"))) { if (!is_int(strpos($body,"[quote]"))) { $body="[quote]".$body; } } if ($kol_q1 <> $kol_q2) { $body=str_replace("[quote]","",$body); $body=str_replace("[/quote]","",$body); } $body=str_replace("[img]","[IMG]",$body); $body=str_replace("[/img]","[/IMG]",$body); if (is_int(strpos($body,"[IMG]"))) { if (!is_int(strpos($body,"[/IMG]"))) { $body=str_replace("[IMG]","",$body); } else { $body=preg_replace("/\[IMG\](.*)\[\/IMG\]/e","_my_img('\\1')",$body); } } $body=str_replace("[email]","[EMAIL]",$body); $body=str_replace("[/email]","[/EMAIL]",$body); if (is_int(strpos($body,"[EMAIL]"))) { if (!is_int(strpos($body,"[/EMAIL]"))) { $body=str_replace("[EMAIL]","",$body); } else { $body=eregi_replace("\[EMAIL\](.*)\[/EMAIL\]","<a href=\"mailto:\\1\" target=_blank>\\1</a>",$body); } } if (is_int(strpos($body,"[b]"))) { if (!is_int(strpos($body,"[/b]"))) { $body=str_replace("[b]","",$body); } } $body=str_replace("[quote]","<span class=\"small\">",$body); $body=str_replace("[/quote]","</span>",$body); $body=str_replace("[b]","<b>",$body); $body=str_replace("[/b]","</b>",$body); $body=str_replace("[i]","<i>",$body); $body=str_replace("[/i]","</i>",$body); if (strstr($body,'*0')) $body=preg_replace("/\*0([0-9]{1,3})\*/e","_myicq_('\\1')",$body); if ($img_insert <> 'none' and $img_insert <> "") { $name_foto=upload_foto($img_insert,250,600,0,1); $body="<img src='user_foto/".$name_foto."' border=0 class='img_upl'><br>".$body; } // удаляем сессии $body=preg_replace("!(".session_name()."=)[a-f0-9]{32}!i","\\1"."FEDCBA9876543210FEDCBA9876543210",$body); $body=preg_replace("!http://[a-f0-9]{32}:[a-z0-9]{12}@!i","http://login:pass@",$body); //парсим СѓСЂР» //$body=preg_replace("~([ '\"[(<,!])(((?:https?|ftp|telnet|irc|icq)://(?:[a-z0-9_-]{1,32}(?::[a-z0-9_-]{1,32})?@)?)?((?:[a-z0-9-]{1,128}\.)+(?:com|net|org|mil|inc|edu|gov|biz|info|aero|name|pro|coop|museum|arpa|[a-z]{2})|(?!0)((?!0[^.]|255)[0-9]{1,3}\.){3}(?!0|255)[0-9]{1,3})(?::[0-9]{1,5})?(?:/[a-z0-9._()@%&!?^+=/\~-]*)?(?:#[^ &%\"'\\\\]*)?)(?=\.*[] )>!,:-])~ies","'\\1'._my_url_topic('\\2')"," ".$body." "); $body=preg_replace("~([]\r\n\t '\"[(),!<>])(((?:https?|ftp|telnet)://(?:[a-z0-9_-]{1,32}(?::[a-z0-9_-]{1,32})?@)?)?((?:[a-z0-9-]{1,128}\.)+(?:com|net|org|mil|edu|arpa|gov|biz|info|aero|name|pro|coop|museum|[a-z]{2})|(?!0)((?!0[^.]|255)[0-9]{1,3}\.){3}(?!0|255)[0-9]{1,3})(?:/[a-z0-9._@%&?+=/-]*)?(?:#[^ ]*)?)(?=\.*[]\r\n\t [()<>!,-])~ies","'\\1'._my_url_topic('\\2')"," ".$body." "); if (strstr($body,':')) { //$body=preg_replace("/(:[0-9]{1,3})\*/e","_myf_sm_('\\1')",$body); } $body=nl2br($body); $body=str_replace("\n","",$body); $body=str_replace("\r","",$body); return $body; } //////// РІС‹ РІРѕРґРёРј СЃРїРёСЃРѕРє icq пользователей function echo_activ_user() { global $base_url,$id_user_sess, $activ_name, $collocutor, $status_src; $activ_user ="<table width=\"100%\" height=\"25\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#efefef\"><tr><td><table width=\"100%\" height=\"25\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>"; $r_activ2=sql("select status, user.name as name, user_activ, user.id as id from icq_activ, user where id_user = '".$id_user_sess."' and user_activ = user.id"); if (!$r_activ2) error(); while ($rs=sqlget($r_activ2)) { $r_online=sqlval("select count(*) from user_onl where name like '".$rs['name']."'"); if ($r_online[0] > 0) { $r_options=sqlval("select * from icq_options, icq_status where id_user = '".$rs['id']."' and status = icq_status.id"); if (!$r_options) error(); if ($r_options['pict'] <> "") { $status_src = $r_options['pict']; $status="<img src=\"".$r_options['pict']."\" id=\"status_".$rs['name']."\" border=\"0\" width=\"16\" alt=\"".$r_options['name']."\">"; } else { $status_src = "pict/online.gif"; $status="<img id=\"status_".$rs['name']."\" src=\"pict/online.gif\" border=\"0\" width=\"16\" alt=\"РЇ здесь\">"; } } else { $status_src = "pict/offline.gif"; $status="<img id=\"status_".$rs['name']."\" src=\"pict/offline.gif\" border=\"0\" width=\"16\" alt=\"Нет меня\">"; } $wudth_column=strlen($rs['name'])*12+36; if ($rs['status'] == 1) { $activ_user.="<td bgcolor=\"#cccccc\" width=\"1\"></td><td align=\"left\" valign=\"middle\" background=\"pict/bg_activ_user.gif\" width=\"".$wudth_column."\"> ".$status." <a href=\"user_activ.php?id_user=".$rs['user_activ']."&status=1\" target=\"user_activ\"><font color=\"white\"><b>".$rs['name']."</b></font></a> <a href=\"user_activ.php?id_user=".$rs['user_activ']."&status=0\" target=\"user_activ\"><img src=\"pict/close.gif\" border=\"0\" height=\"10\" width=\"10\" hspace=\"2\" vspace=\"2\" alt=\"Закрыть\"></a> </td><td bgcolor=\"#cccccc\" width=\"1\"></td>"; $collocutor=$rs['user_activ']; $activ_name=$rs['name']; } else $activ_user.="<td bgcolor=\"#cccccc\" width=\"1\"></td><td align=\"left\" valign=\"middle\" background=\"pict/bg_inactiv_user.gif\" width=\"".$wudth_column."\"> ".$status." <a href=\"user_activ.php?id_user=".$rs['user_activ']."&status=1\" target=\"user_activ\"><font color=\"black\"><b>".$rs['name']."</b></font></a> <a href=\"user_activ.php?id_user=".$rs['user_activ']."&status=0\" target=\"user_activ\"><img src=\"pict/close.gif\" border=\"0\" height=\"10\" width=\"10\" hspace=\"2\" vspace=\"2\" alt=\"Закрыть\"></a> </td><td bgcolor=\"#cccccc\" width=\"1\"></td>"; } //echo $activ_user; $activ_user.= " <td> </td></tr> </table> </td> </tr> </table>"; return $activ_user; } function _myicq_ ($n, $abs = 0) { global $my_c,$base_url, $abs_url; if ($my_c>20) return "*"; $my_c++; if ($abs == 1) return '<img src='.$abs_url.'icq/pict/smile1/'.$n.'.gif>'; else return '<img src='.$base_url.'icq/pict/smile1/'.$n.'.gif>'; } function _mychat_ ($n, $abs = 0) { global $my_c,$base_url, $abs_url; if ($my_c>3) return "*"; $my_c++; if ($abs == 1) return '<img src='.$abs_url.'chat/smile/'.$n.'.gif>'; else return '<img src=smile/'.$n.'.gif>'; } ///////////////////=============================================== function prepare_post_chat($body) { global $admlist,$id_user_sess, $img_insert, $_POST; if ($admlist[$login] >= 500) {} else { $body=htmlspecialchars($body); $body=str_replace("<b>","<b>",$body); $body=str_replace("</b>","</b>",$body); $body=str_replace("<i>","<b>",$body); $body=str_replace("</i>","</b>",$body); } $body=str_replace("[email]","[EMAIL]",$body); $body=str_replace("[/email]","[/EMAIL]",$body); if (is_int(strpos($body,"[EMAIL]"))) { if (!is_int(strpos($body,"[/EMAIL]"))) { $body=str_replace("[EMAIL]","",$body); } else { $body=eregi_replace("\[EMAIL\](.*)\[/EMAIL\]","<a href=\"mailto:\\1\" target=_blank>\\1</a>",$body); } } if (is_int(strpos($body,"[b]"))) { if (!is_int(strpos($body,"[/b]"))) { $body=str_replace("[b]","",$body); } } $body=str_replace("[quote]","<span class=\"small\">",$body); $body=str_replace("[/quote]","</span>",$body); $body=str_replace("[b]","<b>",$body); $body=str_replace("[/b]","</b>",$body); $body=str_replace("[i]","<i>",$body); $body=str_replace("[/i]","</i>",$body); if (strstr($body,'*0')) $body=preg_replace("/\*0([a-z]{1,10}\/[0-9]{1,3})\*/e","_mychat_('\\1')",$body); // удаляем сессии $body=preg_replace("!(".session_name()."=)[a-f0-9]{32}!i","\\1"."FEDCBA9876543210FEDCBA9876543210",$body); $body=preg_replace("!http://[a-f0-9]{32}:[a-z0-9]{12}@!i","http://login:pass@",$body); $body=preg_replace("~([]\r\n\t '\"[(),!<>])(((?:https?|ftp|telnet)://(?:[a-z0-9_-]{1,32}(?::[a-z0-9_-]{1,32})?@)?)?((?:[a-z0-9-]{1,128}\.)+(?:com|net|org|mil|edu|arpa|gov|biz|info|aero|name|pro|coop|museum|[a-z]{2})|(?!0)((?!0[^.]|255)[0-9]{1,3}\.){3}(?!0|255)[0-9]{1,3})(?:/[a-z0-9._@%&?+=/-]*)?(?:#[^ ]*)?)(?=\.*[]\r\n\t [()<>!,-])~ies","'\\1'._my_url_topic('\\2')"," ".$body." "); if (strstr($body,':')) { //$body=preg_replace("/(:[0-9]{1,3})\*/e","_myf_sm_('\\1')",$body); } $body=nl2br($body); $body=str_replace("\n","",$body); $body=str_replace("\r","",$body); return $body; } //////////////////////////////////////////////// maps function incr($num_old, $point_x, $point_y, $x_old, $y_old, $w, $h) { //увеличение global $x,$y; $num=$num_old*2; if ($num>=8) $num=8; switch ($num) { case 1 : $koef=1; $x=$point_x*$koef; $y=$point_y*$koef; break; case 2 : $koef=2; $x=($point_x+$x_old)*$koef-$w/2; $y=($point_y+$y_old)*$koef-$h/2; break; case 4 : $koef=2; $x=($point_x+$x_old)*$koef-$w/2; $y=($point_y+$y_old)*$koef-$h/2; break; case 8 : $koef=2; $x=($point_x+$x_old)*$koef-$w/2; $y=($point_y+$y_old)*$koef-$h/2; break; } if ($num_old==8) { $x=($point_x+$x_old)-$w/2; $y=($point_y+$y_old)-$h/2; } if ($x<0) $x=0; if ($y<0) $y=0; return $num; } function decr($num_old,$point_x,$point_y,$x_old,$y_old, $w, $h) { //уменьшение global $x,$y; $num=$num_old/2; if ($num<=1) $num=1; switch ($num) { case 1 : $koef=2; $x=($point_x+$x_old)/$koef-$w/2; $y=($point_y+$y_old)/$koef-$h/2; break; case 2 : $koef=2; $x=($point_x+$x_old)/$koef-$w/2; $y=($point_y+$y_old)/$koef-$h/2; break; case 4 : $koef=2; $x=($point_x+$x_old)/$koef-$w/2; $y=($point_y+$y_old)/$koef-$h/2; break; case 8 : $koef=2; $x=($point_x+$x_old)/$koef-$w/2; $y=($point_y+$y_old)/$koef-$h/2; break; } if ($num_old==1) { $x=($point_x+$x_old)-$w/2; $y=($point_y+$y_old)-$h/2; } if ($x<0) $x=0; if ($y<0) $y=0; return $num; } function centr($num_old,$point_x,$point_y,$x_old,$y_old, $w, $h) { //центрировать global $x,$y; $num=$num_old; $x=($point_x+$x_old)-$w/2; $y=($point_y+$y_old)-$h/2; if ($x<0) $x=0; if ($y<0) $y=0; return $num; } function navig_sh($koef_sg) { global $file,$num,$koef,$x,$y,$num_old,$shem_x,$shem_y, $w, $h; $num=$num_old; $file="$num.png"; $koef=$num*$koef_sg; $x=$shem_x*$koef-$w/2; $y=$shem_y*$koef-$h/2; if ($x<0) $x=0; if ($y<0) $y=0; } function navig() { global $file,$num,$koef,$x,$y,$num_old,$nav_up,$nav_down,$nav_left,$nav_right,$nav_nw,$nav_ne,$nav_se,$nav_sw,$x_old,$y_old, $w, $h; $num=$num_old; $file="$num.png"; if (!empty($nav_up)) { $x=$x_old; $y=$y_old-$nav_up; if ($x<0) $x=0; if ($y<0) $y=0; } if (!empty($nav_down)) { $x=$x_old; $y=$y_old+$nav_down; if ($x<0) $x=0; if ($y<0) $y=0; } if (!empty($nav_left)) { $x=$x_old-$nav_left; $y=$y_old; if ($x<0) $x=0; if ($y<0) $y=0; } if (!empty($nav_right)) { $x=$x_old+$nav_right; $y=$y_old; if ($x<0) $x=0; if ($y<0) $y=0; } if (!empty($nav_nw)) { $x=$x_old-($w/2-20); $y=$y_old-($h/2-20); if ($x<0) $x=0; if ($y<0) $y=0; } if (!empty($nav_ne)) { $x=$x_old+($w/2-20); $y=$y_old-($h/2-20); if ($x<0) $x=0; if ($y<0) $y=0; } if (!empty($nav_sw)) { $x=$x_old-($w/2-20); $y=$y_old+($h/2-20); if ($x<0) $x=0; if ($y<0) $y=0; } if (!empty($nav_se)) { $x=$x_old+($w/2-20); $y=$y_old+($h/2-20); if ($x<0) $x=0; if ($y<0) $y=0; } } function scale() { global $file,$num,$x,$y,$num_old,$x_old,$y_old, $w, $h; //echo "num=$num,x=$x,y=$y,num_old=$num_old,x_old=$x_old,y_old=$y_old<br>"; $k=$num/$num_old; $x=(($x_old+($w/2))*$k)-($w/2); $y=(($y_old+($h/2))*$k)-($h/2); //echo "num=$num,x=$x,y=$y,num_old=$num_old,x_old=$x_old,y_old=$y_old,k=$k,offset_x=$offset_x,offset_y=$offset_y"; } function znak_firm($x_zn,$y_zn,$id,$znak,$poisk_slova) { global $x,$y,$num, $otst_menu, $otst_left, $w, $h; //$poisk_slova=urldecode($poisk_slova); $koef=$num/8; $x_pos_karta=$otst_left+$w; $x_zn=$otst_left+($x_zn*$koef-$x); $y_zn=0+($y_zn*$koef-$y)-10; $x_zn=intval($x_zn); $y_zn=intval($y_zn); //if ($koef<>1) $y_zn+=20; //echo $x_zn,$y_zn; //db_connect(); $ip=getenv(remote_addr); //$q="insert into stat_brows values (null,'$ip',1,now(),'$id')"; $q="update firma set views=views+1 where id=".$id; $r=sql($q); if (!$r) echo mysql_error(); $res=mysql_query("select name,dop_znak, adress, home from firma where id='$id'"); $dop_znak=mysql_result($res,0,"dop_znak"); $name=mysql_result($res,0,"name"); $adress=mysql_result($res,0,"adress"); $home=mysql_result($res,0,"home"); //$name=addslashes($name); /////для РЅРѕРІРѕРіРѕ дизайна if ($otst_menu == "") $otst_menu=180; $y_zn+=$otst_menu; /////////////// $otst=$otst_menu+4; //echo "<div class=sm id='note' style='position:absolute; left: 41px; top:".$otst.".px; width:500px; height:20px; z-index:111; background-color:#eeeeee; layer-background-color:#eeeeee; border: 1px none #979f7f; visibility:visible; overflow: visible'> //Для просмотра РїРѕРґСЂРѕР±РЅРѕР№ информации РѕР± объекте кликните РїРѕ значку объекта</div>"; if ($x_zn<$x_pos_karta and $x_zn>$otst_left and $y_zn<(248+$otst_menu) and $y_zn>(-10+$otst_menu)) { if ($dop_znak<>'0') echo " <div id='$id' style='position:absolute; left:".$x_zn." px; top:".$y_zn." px; width:200px; height:200px; z-index:21; border: 1px none #000000; overflow: hidden; visibility: hidden'> <img src='img/".$dop_znak."' class='zn1' onMouseOut=\"MM_showHideLayers('".$id."','','hide')\" onClick=\"okn=window.open('firma.php?id=".$id."&poisk_slova=".$poisk_slova."', '".$id."');okn.focus()\"></div> "; if ($dop_znak == '0') echo " <div id='1' style='position:absolute; width:5px; height:5px;left: ".$x_zn." px; top:".$y_zn." px; z-index:10'> <input type='image' class='zn' src='img/".$znak."' title='".strip_tags($name)." ".$adress." ".$home."' onClick=\"okn=window.open('firma.php?id=".$id."&poisk_slova=".$poisk_slova."', '".$idfirma."');okn.focus()\" > </div> "; else if ($dop_znak <> '0') echo " <div id='1' style='position:absolute; width:5px; height:5px;left: ".$x_zn." px; top:".$y_zn." px; z-index:10'> <input type='image' class='zn' src='img/".$znak."' width='16' height='16' onClick=\"okn=window.open('firma.php?id=".$id."&poisk_slova=".$poisk_slova."', '".$id."');okn.focus()\" onMouseOver=\"MM_showHideLayers('".$id."','','show')\" > </div> "; } //mysql_close(); } function object_map($id_object, $type, $x, $y, $num, $d='') { global $base_url; $id_object=intval($id_object); $type=intval($type); $x=intval($x); $y=intval($y); $num=intval($num); $koef=$num/8; $template=contents_file($base_url."template/map_object.html"); if ($type == 1) { // показываем улицу $r=sqlval("select * from map_street where id='".$id_object."'"); $x_zn=intval(($r['x']*$koef - $x)); $y_zn=intval(($r['y']*$koef - $y))-42; $text_znak="<div id=\"object_1\" style=\"position:absolute;z-index:6; left:".$x_zn."px; top:".$y_zn."px;\">"; $id_object="object_1"; $name_object=$r['name_street']; $text_znak.=xparse("",$template, get_defined_vars()); $text_znak.="</div>"; return $text_znak; } if ($type == 2) { // показываем РґРѕРј $r=sqlval("select number, name_street, map_home.x as x, map_home.y as y, image from map_home, map_street where id_street=map_street.id and map_home.id='".$id_object."'"); $x_zn=intval(($r['x']*$koef - $x)); $y_zn=intval(($r['y']*$koef - $y))-42; $text_znak="<div id=\"object_1\" style=\"position:absolute;z-index:6; left:".$x_zn."px; top:".$y_zn."px;\">"; if (file_exists($r['image'])) { $foto_object="<img src=\"images/maps_home_foto.gif\" border=\"0\" width=\"12\" height=\"11\" vspace=\"0\" hspace=\"4\" onclick=\"window.open('home_image.php?id=".$id_object."', 'hmi', 'width=400, height=400')\" style=\"cursor: hand\" alt=\"Фото здания\" />"; } $id_object="object_1"; $name_object=$r['name_street'].", Рґ. ".$r['number']; $text_znak.=xparse("",$template, get_defined_vars()); $text_znak.="</div>"; return $text_znak; } if ($type == 3 && $d == 'r') { //Показываем ресторан $l2 = db_connect_restoran(); $rs_restoran = sqlval("select `name`, `id_home` FROM `restoran` WHERE `id`={$id_object}", $l2); $l = db_connect(); $r=sqlval("select x, y, map_home.image as image, map_home.id as id_home from map_home where map_home.id='{$rs_restoran['id_home']}'"); $x_zn=intval(($r['x']*$koef - $x)); $y_zn=intval(($r['y']*$koef - $y))-42; $text_znak="<div id=\"object_1\" style=\"position:absolute;z-index:6; left:".$x_zn."px; top:".$y_zn."px;\">"; if (file_exists($r['image'])) { $foto_object="<img src=\"images/maps_home_foto.gif\" border=\"0\" width=\"12\" height=\"11\" vspace=\"0\" hspace=\"4\" onclick=\"window.open('home_image.php?id=".$r['id_home']."', 'hmi', 'width=400, height=400')\" style=\"cursor: hand\" alt=\"Фото здания\" />"; } $id_object="object_1"; $name_object=$rs_restoran['name']; $text_znak.=xparse("",$template, get_defined_vars()); $text_znak.="</div>"; return $text_znak; } elseif ($type == 3) { // показываем организацию $r=sqlval("select x, y, name, map_home.image as image, map_home.id as id_home from map_home, firma where id_home=map_home.id and firma.id='".$id_object."'"); $x_zn=intval(($r['x']*$koef - $x)); $y_zn=intval(($r['y']*$koef - $y))-42; $text_znak="<div id=\"object_1\" style=\"position:absolute;z-index:6; left:".$x_zn."px; top:".$y_zn."px;\">"; if (file_exists($r['image'])) { $foto_object="<img src=\"images/maps_home_foto.gif\" border=\"0\" width=\"12\" height=\"11\" vspace=\"0\" hspace=\"4\" onclick=\"window.open('home_image.php?id=".$r['id_home']."', 'hmi', 'width=400, height=400')\" style=\"cursor: hand\" alt=\"Фото здания\" />"; } $id_object="object_1"; $name_object=$r['name']; $text_znak.=xparse("",$template, get_defined_vars()); $text_znak.="</div>"; return $text_znak; } if ($type == 4) { // показываем слой } } function ins_stat($what, $id_firm) { global $_REQUEST, $uinmd; //1 - подробная информация //2 - карточка //3 - показ РЅР° карте //4 - прайс лист //5 - информация Рѕ товаре //6 - новости $ip=getenv("REMOTE_ADDR"); if ($_REQUEST['sid'] == "") { if ($uinmd == "") { $ip2=getIp(); $user_agent=getenv(http_user_agent); $uin=md5($ip.$ip2.$user_agent); } else $uin=$uinmd; } else $uin=$_REQUEST['sid']; $rstat=sql("insert into stat_brows (ip, what, data, id_firm, uin) values ('".$ip."','".$what."', now(), '".$id_firm."', '".$uin."')"); //sql("update firma set views=views+1 where id=".$id_firm); } function articl_hot() { $rh=sql("SELECT SQL_NO_CACHE articl.id_parent,articl.id_author, max(articl.data) as mdata FROM articl, forum where view_index = 1 and id_forum=forum.id group by articl.id_parent order by mdata desc limit 0,25"); $r_trunc=sql("delete from articl_hot");// where data < date_sub(data,INTERVAL 10 DAY "); while ($rsf=sqlget($rh)) { $tema=sqlval("select tema, id_forum from articl where articl.id='".$rsf['id_parent']."'"); $forum_name=sqlval("select name from forum where id = '".$tema['id_forum']."' limit 0,1"); $id_user=sqlval("select id_author from articl where id_parent='".$rsf['id_parent']."' order by data desc limit 0,1"); $user=sqlval("select name from user where id='".$id_user['id_author']."'"); $r_ins_hot=sql("replace into articl_hot set user_name='".$user['name']."', tema='".$tema['tema']."', forum_name='".$forum_name['name']."', id_parent='".$rsf['id_parent']."', id_forum='".$tema['id_forum']."', data='".$rsf['mdata']."'"); } } function echo_polosa_razdel($razdel, $polosa, $id_user_sess, $template, $reklama_blok = 0) { global $menu_page, $class_razdel, $_SERVER, $_REQUEST, $base_url, $abs_url, $dom_domen_cfg,$link_sms_mega, $link_sms_mts, $link_sms_bee, $abs_url_auto, $job_domen_cfg, $sub_domen_cfg, $name_gorod, $name_gorod2, $name_gorod3, $mail_from, $w, $h, $abs_url_orel; $title=""; if ($id_user_sess > 0) { $sql_status=" (status='3' or status='4') "; } else $sql_status=" (status='3') "; $r_razdel=sql("select index_name.* from index_name where ".$sql_status." and razdel='".$razdel."' and polosa_razdel='".$polosa."' order by posiz_polosa"); if ($class_razdel <> "") $class_razdel_cl=" class=\"".$class_razdel."\""; while ($rsr=sqlget($r_razdel)) { /*$rsr['name']=xparse("",$rsr['name'], get_defined_vars()); $rsr['link']=trim(xparse("",$rsr['link']." ", get_defined_vars())); if ($rsr['link'] <> "" && strpos($rsr['link'], "http") === false) $title_razdel="<a href=\"".$base_url.$rsr['link']."\" ".$class_razdel_cl.">".stripslashes($rsr['name'])."</a>"; if ($rsr['link'] == "") $title_razdel=stripslashes($rsr['name']); if (is_int(strpos($rsr['link'], "http"))) $title_razdel="<a href=\"".$rsr['link']."\" ".$class_razdel_cl.">".stripslashes($rsr['name'])."</a>"; */ if ($id_user_sess <= 0) $ropen=sqlval("select status from index_razdel where id_razdel='".$rsr['id']."' and sid = '".$_REQUEST['sid']."'"); else $ropen=sqlval("select status from index_razdel where id_razdel='".$rsr['id']."' and id_user='".$id_user_sess."'"); if ($rsr['nohide'] == 0) { if ($ropen[0] <= 1) $title_razdel2="<td align=\"right\"><a href=\"".$_SERVER['PHP_SELF']."?id_razdel_index=".$rsr['id']."&status=2\"><img src=\"".$base_url."images/razdel_open.gif\" border=\"0\" width=\"14\" height=\"13\" alt=\"Свернуть\" /></a> </td>"; if ($ropen[0] == 2) $title_razdel2="<td align=\"right\"><a href=\"".$_SERVER['PHP_SELF']."?id_razdel_index=".$rsr['id']."&status=1\"><img src=\"".$base_url."images/razdel_close.gif\" border=\"0\" width=\"14\" height=\"13\" alt=\"Развернуть\" /></a> </td>"; } if ($reklama_blok == 1) { echo ''; } echo xparse("","{\$an}", get_defined_vars()); $count_element=$rsr['count']; if ($count_element <=0) $count_element=1; if ($ropen[0] <= 1) include $base_url."template/razdel/".$rsr['template']; if ($reklama_blok == 1) { echo ''; } //echo '<br><br>'; $title_razdel2=""; } } function echo_spolosa_razdel($razdel, $polosa, $id_user_sess, $template, $reklama_blok = 0) { global $menu_page, $class_razdel, $_SERVER, $_REQUEST, $base_url, $abs_url, $dom_domen_cfg,$link_sms_mega, $link_sms_mts, $link_sms_bee, $abs_url_auto, $job_domen_cfg, $sub_domen_cfg, $name_gorod, $name_gorod2, $name_gorod3, $mail_from, $w, $h, $abs_url_orel; if ($id_user_sess > 0) { $sql_status=" (status='3' or status='4') "; } else $sql_status=" (status='3') "; $r_razdel=sql("select sindex_name.* from sindex_name where ".$sql_status." and id_razdel='".intval($razdel)."' and polosa_razdel='".$polosa."' order by posiz_polosa"); if ($class_razdel <> "") $class_razdel_cl=" class=\"".$class_razdel."\""; while ($rsr=sqlget($r_razdel)) { if ($rsr['link'] <> "" && strpos($rsr['link'], "http") === false) $title_razdel="<a href=\"".$base_url.$rsr['link']."\" ".$class_razdel_cl.">".stripslashes($rsr['name'])."</a>"; if ($rsr['link'] == "") $title_razdel=stripslashes($rsr['name']); if (is_int(strpos($rsr['link'], "http"))) $title_razdel="<a href=\"".$rsr['link']."\" ".$class_razdel_cl.">".stripslashes($rsr['name'])."</a>"; /*if ($id_user_sess <= 0) $ropen=sqlval("select status from public_razdel where id_razdel='".$rsr['id']."' and sid = '".$_REQUEST['sid']."'"); else $ropen=sqlval("select status from public_razdel where id_razdel='".$rsr['id']."' and id_user='".$id_user_sess."'");*/ if ($rsr['nohide'] == 0) { if ($ropen[0] <= 1) $title_razdel2="<td align=\"right\"><a href=\"".$_SERVER['PHP_SELF']."?id_razdel_index=".$rsr['id']."&status=2\"><img src=\"".$base_url."images/razdel_open.gif\" border=\"0\" width=\"14\" height=\"13\" alt=\"Свернуть\" /></a> </td>"; if ($ropen[0] == 2) $title_razdel2="<td align=\"right\"><a href=\"".$_SERVER['PHP_SELF']."?id_razdel_index=".$rsr['id']."&status=1\"><img src=\"".$base_url."images/razdel_close.gif\" border=\"0\" width=\"14\" height=\"13\" alt=\"Развернуть\" /></a> </td>"; } if ($reklama_blok == 1) { echo ''; } echo xparse("",$template, get_defined_vars()); $count_element=$rsr['count']; if ($count_element <=0) $count_element=1; if ($ropen[0] <= 1) include $base_url."template/razdel/".$rsr['template']; if ($reklama_blok == 1) { echo ''; } echo '<br><br>'; $title_razdel2=""; } } function check_new_pochta($name_login) { global $l; $lm=db_connect_mail(); $ru_mail=sqlval("select id_user, user_mail from bm60_infoorel where info_name like '".$name_login."'"); if ($ru_mail['id_user'] > 0) { $r_new_mail=sqlval("select count(*) from bm60_mails where user like '".$ru_mail['user_mail']."' and gelesen like 'no' "); if ($r_new_mail[0] > 0) { echo "<a href=\"http://mail.orelinfo.ru/\" class=\"registraciya\" target=\"_blank\"><b>".$r_new_mail[0]."</b> непрочитанных писем</a>"; } } mysql_close(); $l=db_connect(); } function znak_zodiak($month, $day) { global $znak_zodiac; if ($month==3) { if ($day >= 21) { $znak="oven"; $znak_zodiac="Овен"; } if ($day <= 19) { $znak="ryba"; $znak_zodiac="Рыбы"; } } if ($month==4) { if ($day <= 20) { $znak="oven"; $znak_zodiac="Овен"; } if ($day >= 21) { $znak="telec"; $znak_zodiac="Телец"; } } if ($month==5) { if ($day <= 20) { $znak="telec"; $znak_zodiac="Телец"; } if ($day >= 21) { $znak="bliznec"; $znak_zodiac="Близнецы"; } } if ($month==6) { if ($day >= 22) { $znak="rak"; $znak_zodiac="Рак"; } if ($day <= 21) { $znak="bliznec"; $znak_zodiac="Близнецы"; } } if ($month==7) { if ($day <= 22) { $znak="rak"; $znak_zodiac="Рак"; } if ($day >= 23) { $znak="lev"; $znak_zodiac="Лев"; } } if ($month==8) { if ($day >= 24) { $znak="deva"; $znak_zodiac="Дева"; } if ($day <= 23) { $znak="lev"; $znak_zodiac="Лев"; } } if ($month==9) { if ($day >= 24) { $znak="vesy"; $znak_zodiac="Весы"; } if ($day <= 23) { $znak="deva"; $znak_zodiac="Дева"; } } if ($month==10) { if ($day <= 23) { $znak="vesy"; $znak_zodiac="Весы"; } if ($day >= 24) { $znak="scorpion"; $znak_zodiac="РЎРєРѕСЂРїРёРѕРЅ"; } } if ($month==11) { if ($day >= 23) { $znak="strelec"; $znak_zodiac="Стрелец"; } if ($day <= 22) { $znak="scorpion"; $znak_zodiac="РЎРєРѕСЂРїРёРѕРЅ"; } } if ($month==12) { if ($day <= 21) { $znak="strelec"; $znak_zodiac="Стрелец"; } if ($day >= 22) { $znak="kozerog"; $znak_zodiac="Козерог"; } } if ($month==1) { if ($day >= 21) { $znak="vodoley"; $znak_zodiac="Водолей"; } if ($day <= 20) { $znak="kozerog"; $znak_zodiac="Козерог"; } } if ($month==2) { if ($day <= 20) { $znak="vodoley"; $znak_zodiac="Водолей"; } if ($day >= 21) { $znak="ryba"; $znak_zodiac="Рыбы"; } } if ($month==0) { $znak="all"; } return $znak_zodiac; } function guest_indexator($id = 0, $l) { if ($id == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://guest/%'"); if (!$del_obj_news) error(); $r=sql("select guest.name as name,guest.note as note, guest.id as id from guest where status='3'"); } elseif ($id <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://guest/".$id."'"); if (!$del_obj_news) error(); $r=sql("select guest.name as name,guest.note as note, guest.id as id from guest where status='3' and id='".$id."'"); } if (!$r) error(); //$r_lock=sql("LOCK TABLES search_object WRITE"); while ($rs=sqlget($r)) { $date_time = date('Y-m-d H:i:s'); $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('db://guest/".$rs['id']."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); //========== kanal for ($k=0; $k<=1; $k ++) { $mas_news_header=slova($rs[$k]); $cnt_mn=count($mas_news_header); $weight=555; for ($i=0; $i < $cnt_mn; $i++) { $mas_news_header[$i]=trim($mas_news_header[$i]); if ($mas_news_header[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_news_header[$i]."', '".$weight."')"); } } } } //$r_lock=sql("UNLOCK TABLES"); //del_empty(); } function antiSpamProtect($enc_name, $dec_name){ $dec_num = $_POST[$dec_name]; $enc_num = $_POST[$enc_name]; $enc_num=doubleval(substr($enc_num,3,strlen($enc_num)-3)); $enc_num = floor(sqrt(($enc_num - 10) / M_2_PI / M_E)); if (intval($enc_num) == intval($dec_num)) return true; else return false; } function upload_file($file, $type, $katalog_file = "user_file"){ global $name_file; if (!$upload_file=fopen($file, "rb")) echo "Невозможно открыть файл"; else { $blob_file=fread($upload_file, filesize($file)); $name_file=md5(microtime()); $name_file .= $type; $uploaded_file=fopen($katalog_file."/".$name_file,"wb"); if (!$uploaded_file) echo "Файл РЅРµ создан"; fwrite($uploaded_file, $blob_file); fclose($uploaded_file); return $name_file; } } function download_file($file = NULL, $speed_limit = 1024, $resume = true, $send_errors = false, $new_filename = NULL){ //return:: 0 - ok \ 1 - $file is_null \ 2 - forbidden \ 3 - 404 Error if(is_null($file)){ return 1; }else{ if ($new_filename == NULL ) $file_name = basename($file); else $file_name = $new_filename; $speed_limit = intval($speed_limit); if($speed_limit<0) $speed_limit = 1024; $running_time = 0; $begin_time = time(); set_time_limit(3600); if(file_exists($file)) { if( false !== ($file_hand = fopen($file, "rb")) ) { $file_size = filesize($file); $file_date = date("D, d M Y H:i:s T",filemtime($file)); $offset = 0; if (isset($_SERVER['HTTP_RANGE'])) { if(preg_match("/bytes=(\d+)-/", $_SERVER["HTTP_RANGE"],$range) && $resume == true) { header("HTTP/1.1 206 Partial Content"); $offset = $file_size - intval($range[1]); }else{ header("HTTP/1.1 200 OK"); $offset = 0; } } $data_start = $offset; $data_end = $file_size - 1; $etag = md5($file.$file_size.$file_date); fseek($file_hand, $data_start); header("Content-Disposition: attachment; filename=".$file_name); header("Last-Modified: ".$file_date); header("ETag: \"".$etag."\""); if($resume == true) header("Accept-Ranges: bytes"); header("Content-Length: ".($file_size-$data_start)); header("Content-Range: bytes ".$data_start."-".$data_end."/".$file_size); header("Content-type: application/octet-stream"); while(!feof($file_hand) && (connection_status()==0)) { print fgets($file_hand,$speed_limit); flush(); usleep(1); // 1000 $running_time = time() - $begin_time; if($running_time>240) { $begin_time = time(); } } fclose ($file_hand); return 0; } else { if($send_errors == true) header ("HTTP/1.0 403 Forbidden"); return 2; } }else{ if($send_errors == true) header("HTTP/1.0 404 Not Found"); return 3; } } } function eval_file_size($size){ if ($size>=1048576)return strval(round($size/1048576,1))." РњР‘"; else if ($size>=1024)return strval(round($size/1024,1))." РљР‘"; else return strval($size)." Р‘"; } function kartochka_oblast($id, $type = "otrasl", $small = 0, $lang = "") { global $ip, $abs_url, $base_url,$w, $h, $_SERVER, $_GET, $podrobno, $name_gorod,$name_gorod2, $_REQUEST; $rinfo=sqlval("select address, name, phone, oblast_rayon.id as id_rayon, name_rayon, oblast_otrasl.id as id_otrasl, name_otrasl from oblast_firma, oblast_rayon, oblast_otrasl where oblast_firma.id = '".$id."' and oblast_rayon.id = id_rayon and oblast_otrasl.id = id_otrasl"); if ($type == "otrasl"){ $otrasl="<a href=\"".$abs_url."/oblast/katalog_firm.php?type=otrasl\" class=\"big\">Весь каталог Орловской области</a> ><a href=\"otrasl.php?id_otrasl=".$rinfo['id_otrasl']."\">".$rinfo['name_otrasl']."</a>"; }else if ($type == "rayon"){ $otrasl="<a href=\"".$abs_url."oblast/katalog_firm.php?type=rayon\" class=\"big\">Весь каталог Орловской области</a> ><a href=\"rayon.php?id_rayon=".$rinfo['id_rayon']."\">".$rinfo['name_rayon']."</a>"; } $address = $rinfo['address']; $name = $rinfo['name']; $phone = $rinfo['phone']; $rayon = $rinfo['name_rayon']; //$otrasl = $rinfo['name_otrasl']; ////////////////////////////// stat echo xparse($base_url."template/kartochka_oblast.html","", get_defined_vars()); } function firm_oblast_indexator($id, $l) { if ($id == 0) { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name like 'db://firma_oblast/%'"); if (!$del_obj_news) error(); $r=sql("select id, id_rayon, address, name, phone, id_otrasl from oblast_firma"); } elseif ($id <> "") { $del_obj_news=sql("delete search_object.*, search_index.* from search_object, search_index where id_obj=search_object.id and name = 'db://firma_oblast/".$id."'"); if (!$del_obj_news) error(); $r=sql("select id, id_rayon, address, name, phone, id_otrasl from oblast_firma where id='".intval($id)."'"); } if (!$r) error(); //$r_lock=sql("LOCK TABLES search_object WRITE"); while ($rs=sqlget($r)) { $date_time = date('Y-m-d H:i:s'); $r_ins_sl=sql("insert into search_object (name, idate, tag) values ('db://firma_oblast/".$rs['id']."', '".$date_time."', '1')"); if (!$r_ins_sl) error(); $id_obj=mysql_insert_id($l); //========== название $mas_name=slova($rs['name']); $cnt_mn=count($mas_name); $weight = 150; for ($i=0; $i < $cnt_mn; $i++) { $mas_name[$i]=trim($mas_name[$i]); if ($mas_name[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_name[$i]."', '".$weight."')"); } } //============ адрес $mas_adress=slova($rs['address']); $cnt_mn=count($mas_adress); $weight=2; for ($i=0; $i < $cnt_mn; $i++) { $mas_adress[$i]=trim($mas_adress[$i]); if ($mas_adress[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_adress[$i]."', '".$weight."')"); } } //============ телефон $mas_telefon=slova($rs['phone']); $cnt_mn=count($mas_telefon); $weight=1; for ($i=0; $i < $cnt_mn; $i++) { $mas_telefon[$i]=trim($mas_telefon[$i]); if ($mas_telefon[$i] <> "") { $r_ins_sl=sql("insert into search_index (id_obj, word, weight) values ('".$id_obj."', '".$mas_telefon[$i]."', '".$weight."')"); } } //$r_lock=sql("UNLOCK TABLES"); // del_empty(); } } function echo_message($mes) { echo "<font color=\"red\"><b>".$mes."</b></font>"; } function echo_discount($kol, $id_razdel = 0, $template="../template/discount_template.html") { global $page, $pap, $w, $h, $_REQUEST, $abs_url; if ($_REQUEST['ofs'] == "") $_REQUEST['ofs'] =0; if ($kol == "") $pap=10; else $pap=$kol; if ($id_razdel > 0) { $sql_razdel = " id_razdel='".$id_razdel."' "; } $r_discount = sql("SELECT SQL_CALC_FOUND_ROWS `firma`.`id`, `firma`.`name`, `firma`.`adress`,`firma`.`home`, `firma`.`id_home`, `firma`.`telefon`, `firma`.`email`, `firma_discount`.`id` as id_discount, `firma_discount`.`contact`, `firma_discount`.`site`, `firma_discount`.`logo`, `firma_discount`.`date_begin`, `firma_discount`.`date_end`, `firma_discount`.`size`, `firma_discount`.`coupon`, `firma_discount`.`size`, `firma_discount`.`condition` FROM `firma_discount`, `firma` WHERE `firma_discount`.`id_firma` = `firma`.`id` AND `status`='3' and firma_discount.date_end >= curdate() ORDER BY `firma_discount`.`date` DESC LIMIT ".$_REQUEST['ofs'].", ".$pap); if (!$r_discount) { error(); } $koln = sqlval("SELECT FOUND_ROWS()"); while ($rs_discount = sqlget($r_discount)) { $id = $rs_discount['id']; $name = $rs_discount['name']; $address = $rs_discount['adress']; $home = $rs_discount['home']; $phone = $rs_discount['telefon']; $email = $rs_discount['email']; $contact = $rs_discount['contact']; $site = $rs_discount['site']; $logo = $rs_discount['logo']; $logo_big = str_replace('_sm', '', $rs_discount['logo']); $date_begin = $rs_discount['date_begin']; $date_end = $rs_discount['date_end']; $coupon = $rs_discount['coupon']; $coupon_big = str_replace('_sm', '', $rs_discount['coupon']); $size = $rs_discount['size']; $condition = $rs_discount['condition']; if ($rs_discount['id_home'] > 0) { $rhome=sqlval("select x, y from map_home where id='".$rs_discount['id_home']."'"); if ($rhome['x'] > 0) { $x=ceil($rhome['x']-($w/2)); $y=ceil($rhome['y']-($h/2)); } } echo " <div class=\"ShtrihBottom\">"; if ($logo != ''){ echo "<img src=\"../{$logo}\" vspace=\"5\" /><br>"; } echo " <h3 style=\"margin-top:10px;\">{$name}</h3> <table border=\"0\" cellspacing=\"3\" cellpadding=\"0\" > <tr> <td valign=\"top\"> Адрес:</td> <td valign=\"top\"><a href=\"".$abs_url."maps/?x=".$x."&y=".$y."&num=8&iz=".$id."&tz=3\" title=\"Посмотреть РЅР° карте РіРѕСЂРѕРґР°\" target=\"_blank\">$address, $home</a></td> </tr>"; if ($contact != ''){ echo "<tr> <td valign=\"top\"> Контактное лицо: </td> <td valign=\"top\">$contact</td> </tr>"; } if ($site != ''){ echo "<tr> <td valign=\"top\"> Сайт:</td> <td valign=\"top\"><a href=\"http://$site\" target=\"_blank\">$site</a></td> </tr>"; } if ($email != ''){ echo "<tr> <td valign=\"top\"> E-mail:</td> <td valign=\"top\"><a href=\"mailto:{$email}\">{$email}</a></td> </tr>"; } echo "<tr> <td valign=\"top\"> Телефон:</td> <td valign=\"top\">$phone</td> </tr> <tr> <td valign=\"top\"> РЎСЂРѕРє действия СЃРєРёРґРєРё:</td> <td valign=\"top\" style=\"font-size:80%\">СЃ $date_begin РґРѕ $date_end</td> </tr>"; if ($size != '') { echo "<tr><td valign=\"top\"> Размер СЃРєРёРґРєРё:</td> <td valign=\"top\" style=\"font-size:110%;\" class=\"p_green\"><strong>$size</strong></td> </tr>"; } if ($coupon != '') { echo "<tr> <td valign=\"top\"> РљСѓРїРѕРЅ СЃРєРёРґРєРё:</td> <td valign=\"top\"><img src=\"../{$coupon}\" alt=\"\" hspace=\"0\" vspace=\"0\" border=\"0\" /><BR><a href=\"discount_print.php?id=" . $rs_discount['id_discount'] . "\" target=\"_blank\">Распечатать РєСѓРїРѕРЅ</td> </tr>"; } if ($condition != ''){ echo "<tr> <td valign=\"top\"> Условия предоставления: </td> <td valign=\"top\">{$condition}</td> </tr>"; } echo "</table></div>"; } if ($koln[0] > $pap) { echo "<div align=\"center\"><b>Страницы: </b>"; if (empty($page)) $page=1; list_all($koln[0],"?list=1",8,$page,$pap,"ofs",1); echo "</div>"; } } function echo_discount_note($id, $template="../template/discount_template.html") { global $w, $h, $_REQUEST, $abs_url; $id = intval($id); $rs_discount = sqlval("SELECT `firma`.`id`, `firma`.`name`, `firma`.`adress`,`firma`.`home`, `firma`.`id_home`, `firma`.`telefon`, `firma`.`email`, `firma_discount`.`contact`, `firma_discount`.`site`, `firma_discount`.`logo`, `firma_discount`.`date_begin`, `firma_discount`.`date_end`, `firma_discount`.`size`, `firma_discount`.`coupon`, `firma_discount`.`size`, `firma_discount`.`condition` FROM `firma_discount`, `firma` WHERE `firma_discount`.`id_firma` = `firma`.`id` AND `status`='3' AND `firma_discount`.`id` = '" . $id . "'" ); if (!$rs_discount) { error(); } $id = $rs_discount['id']; $name = $rs_discount['name']; $address = $rs_discount['adress']; $home = $rs_discount['home']; $phone = $rs_discount['telefon']; $email = $rs_discount['email']; $contact = $rs_discount['contact']; $site = $rs_discount['site']; $logo = $rs_discount['logo']; $logo_big = str_replace('_sm', '', $rs_discount['logo']); $date_begin = $rs_discount['date_begin']; $date_end = $rs_discount['date_end']; $coupon = $rs_discount['coupon']; $coupon_big = str_replace('_sm', '', $rs_discount['coupon']); $size = $rs_discount['size']; $condition = $rs_discount['condition']; if ($rs_discount['id_home'] > 0) { $rhome=sqlval("select x, y from map_home where id='".$rs_discount['id_home']."'"); if ($rhome['x'] > 0) { $x=ceil($rhome['x']-($w/2)); $y=ceil($rhome['y']-($h/2)); } } echo " <table width=\"100%\" border=\"0\" cellspacing=\"7\" cellpadding=\"0\"> <tr> <td class=\"afisha_all\">"; if ($logo != ''){ echo "<img src=\"../{$logo}\" vspace=\"5\" /><br>"; } echo "<h2>$name</h2> <table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"0\" align=\"center\"> <tr> <td colspan=\"2\" valign=\"top\"></td> </tr> <tr> <td width=\"30%\" valign=\"top\"> Адрес:</td> <td valign=\"top\"><a href=\"".$abs_url."maps/?x=".$x."&y=".$y."&num=8&iz=".$id."&tz=3\" title=\"Посмотреть РЅР° карте РіРѕСЂРѕРґР°\" target=\"_blank\">$address, $home</a></td> </tr>"; if ($contact != ''){ echo "<tr> <td valign=\"top\"> Контактное лицо: </td> <td valign=\"top\">$contact</td> </tr>"; } if ($site != ''){ echo "<tr> <td valign=\"top\"> Сайт:</td> <td valign=\"top\"><a href=\"http://$site\" target=\"_blank\">$site</a></td> </tr>"; } if ($email != ''){ echo "<tr> <td valign=\"top\"> E-mail:</td> <td valign=\"top\"><a href=\"mailto:{$email}\">{$email}</a></td> </tr>"; } echo "<tr> <td valign=\"top\"> Телефон:</td> <td valign=\"top\">$phone</td> </tr> <tr> <td valign=\"top\"> РЎСЂРѕРє действия СЃРєРёРґРєРё:</td> <td valign=\"top\" style=\"font-size:70%\">СЃ $date_begin РґРѕ $date_end</td> </tr>"; if ($size != '') { echo "<tr><td valign=\"top\"> Размер СЃРєРёРґРєРё:</td> <td valign=\"top\" style=\"color:Red; font-size:90%;\"><strong>$size</strong></td> </tr>"; } if ($coupon != '') { echo "<tr> <td valign=\"top\"> РљСѓРїРѕРЅ СЃРєРёРґРєРё:</td> <td valign=\"top\"><img src=\"../{$coupon}\" alt=\"\" hspace=\"0\" vspace=\"0\" border=\"0\" />"; echo "</td> </tr>"; } if ($condition != ''){ echo "<tr> <td valign=\"top\"> Условия предоставления: </td> <td valign=\"top\">{$condition}</td> </tr>"; } echo "</table></td></tr></table>"; echo "<div align=\"center\"><a href=\"index.php\">Р’СЃРµ СЃРєРёРґРєРё</a></div>"; } /*function echo_news_rubrikator($kol, $archiv) { global $page, $pap, $_REQUEST; if ($_REQUEST['ofs'] == "") $_REQUEST['ofs'] =0; $pap=10; $template=contents_file("../template/news_template_rubrikator.html"); if ($archiv == 1) { $sql_archiv = " archiv='1' "; } else $sql_archiv = " archiv='0' or archiv = '' "; $r = sql("SELECT SQL_CALC_FOUND_ROWS t1.*, t2.id sec_id, t2.name sec_name FROM news t1 LEFT JOIN news_razdel t2 ON t1.razdel = t2.id where (".$sql_archiv.") and t1.status='3' order by t1.data desc limit ".$_REQUEST['ofs'].", ".$pap); $koln=sqlval("SELECT FOUND_ROWS()"); $news=""; while ($rs=sqlget($r)) { $data=$rs['data']; $id_news=$rs['id']; $img_index=$rs['img_index']; $sec_id = $rs['sec_id']; $sec_name = $rs['sec_name']; if ($rs['img_index'] <> "" && !file_exists($rs['img_index'])) { $img_index="http://www.infoorel.ru/".$rs['img_index']; } if ($rs['img_index'] == "") $img_index="http://www.infoorel.ru/images/transpar10.gif"; $zagolovok=stripslashes($rs['news_header']); $news_short=stripslashes($rs['news_short']); if ($rs['news_full'] <> "") { $href="<a href=\"news_echo.php?id=".$id_news."\" class=\"podrobnee\">"; $end_href="</a>"; $podrobnee="Подробнее"; } $news.=xparse("",$template, get_defined_vars()); } echo $news; if ($koln[0] > $pap) { echo "<div align=\"center\"><b>Страницы: </b>"; if (empty($page)) $page=1; list_all($koln[0],"?archiv=".$archiv,8,$page,$pap,"ofs",1); echo "</div>"; } }*/ function echo_news_rubrikator($kol, $id_razdel= '', $archiv = 0) { global $page, $pap, $_REQUEST; require_once('Smarty.class.php'); if ($_REQUEST['ofs'] == "") $_REQUEST['ofs'] =0; $pap=10; //$template=contents_file("../template/news_template_rubrikator.html"); if ($archiv == 1) { $sql_archiv = " archiv='1' "; } else $sql_archiv = " archiv='0' or archiv = '' "; if ($id_razdel != '' ) { $sql_razdel = " and t1.razdel='{$id_razdel}' "; } $result = sql("select sql_calc_found_rows t1.*, t2.id sec_id, t2.name sec_name from news t1 left join news_razdel t2 on t1.razdel = t2.id where (".$sql_archiv.") {$sql_razdel} and t1.status='3' order by t1.data desc limit ".$_REQUEST['ofs'].", ".$pap); $koln=sqlval("select found_rows()"); $smarty = new Smarty; $smarty->cache_dir = "../template/cache"; $smarty->template_dir = "../template"; $smarty->compile_dir = "../template/templates_c"; $smarty->debug_tpl = true; $smarty->debugging = true; $r_razdel = sql("SELECT * FROM news_razdel ORDER BY name"); while ( $rs_razdel = sqlget( $r_razdel ) ) { $db_data_razdel[ $rs_razdel['id'] ] = array( "id" => $rs_razdel['id'], "name"=> $rs_razdel['name'] ); //if ( $rs_razdel['id'] == $_GET['section_id'] ) $sel = 'selected'; else $sel = ''; //echo "<option value=\"{$rs_razdel['id']}\" {$sel}>{$rs_razdel['name']}</option>"; } $smarty->assign( 'db_data_section', $db_data_razdel ); while ($row = sqlget($result)) { if ($rs['img_index'] <> "" && !file_exists($rs['img_index'])) { $img_index="http://www.infoorel.ru/".$rs['img_index']; } if ($rs['img_index'] == "") $img_index="http://www.infoorel.ru/images/transpar10.gif"; $db_data[ $row['id'] ] = array( "id" => $row['id'], "date" => $row['data'], "title" => stripslashes( $row['news_header'] ), "img_index" => $img_index, "section_id" => $row['sec_id'], "section_name" => $row['sec_name'], "news_short" => stripslashes($row['news_short'])); } if ( $id_razdel != '' ) { $smarty->assign( 'id_razdel', $id_razdel ); } $smarty->assign( 'abs_url', "http://www.infoorel.ru/" ); $smarty->assign( 'db_data', $db_data ); $template = "../template/news_template_rubrikator.tpl"; $smarty->display( $template ); $smarty->clear_all_assign(); if ($koln[0] > $pap) { echo "<div align=\"center\"><b>Страницы: </b>"; if (empty($page)) $page=1; list_all($koln[0],"?archiv=".$archiv,8,$page,$pap,"ofs",1); echo "</div>"; } } function ShowTree($tree, $pid = 0, $spliter = '', $sel_key) { foreach ( $tree as $id => $root ) { if ($pid != $id) continue; if (count ( $root )) { foreach ( $root as $key => $title ) { if ( is_array($sel_key) ) { $sel = ( !(array_search($key, $sel_key) === false) ) ? 'selected' : ''; } elseif ($sel_key == $key) { $sel = "selected"; } else { $sel = ""; } if (isset($title['is_disabled'])) { ($title['is_disabled'] == 1) ? $disable = ' disabled="disabled"' : $disable = ''; } if (isset($title['count'])) { echo "<option value=\"" . $key . "\" " . $sel . " {$disable}><b>{$spliter}{$title['name']} ({$title['count']}) </b></option>"; } else { echo "<option value=\"" . $key . "\" " . $sel . " {$disable}><b>{$spliter}{$title['name']} </b></option>"; } if (array_key_exists ( $key, $tree )) { $spliter .= ' '; ShowTree ( $tree, $key, $spliter, $sel_key ); $spliter = substr($spliter, 0, strlen($spliter) - 24); } } } } } function ShowMenu($tree, $selected, $pid=0){ echo "<ul>"; foreach( $tree as $id=>$root){ if($pid!=$id)continue; if(count($root)){ foreach($root as $key => $title){ if (isset($title['is_disabled'])) ($title['is_disabled'] == 1) ? $style = ' style="color:#ff0000"' : $style = ''; echo "<li><span {$style}>{$title['name']}</span>"; if(count($tree[$key]))ShowMenu($tree, $selected, $key); } } } echo "</ul>"; } function ShowMenuProducts($tree, $selected, $pid=0){ echo "<ul>"; foreach( $tree as $id=>$root){ if($pid!=$id)continue; if(count($root)){ foreach($root as $key => $title){ echo "<li><span>{$title['name']} ({$title['count']})</span>"; if(count($tree[$key]))ShowMenuProducts($tree, $selected, $key); } } } echo "</ul>"; } function ftp_write($remote_file, $file) { global $ftp_host, $ftp_user, $ftp_pass, $ftp_puth; $conn_id = ftp_connect($ftp_host); $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass); if ((!$conn_id) || (!$login_result)) { die("РќРµ удалось подключиться Рє FTP серверу!"); } ftp_chdir ($conn_id, $ftp_puth) or die("Невозможно сменить директорию"); if (ftp_put($conn_id, $remote_file, $file, FTP_BINARY)) { } else { echo "РќРµ удалось загрузить ".$remote_file." РЅР° сервер\n"; exit; } ftp_close($conn_id); } function ftp_del($remote_file) { global $ftp_host, $ftp_user, $ftp_pass, $ftp_puth; $conn_id = ftp_connect($ftp_host); $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass); if ((!$conn_id) || (!$login_result)) { die("РќРµ удалось подключиться Рє FTP серверу!"); } ftp_chdir ($conn_id, $ftp_puth); if (ftp_delete($conn_id, $remote_file)) { } else { echo "РќРµ удалось удалить ".$remote_file." СЃ сервера\n"; exit; } ftp_close($conn_id); } function translit($string) { $string = strtr($string,"абвгдеёзийклмнопрстуфхыэ-", "abvgdeeziyklmnoprstufhiei"); $string = strtr($string,"АБВГДЕЁЗР�ЙКЛМНОПРСТУФХЫР_", "ABVGDEEZIYKLMNOPRSTUFHIEI"); $string = strtr($string, array( "Р¶"=>"zh", "С†"=>"ts", "С‡"=>"ch", "С€"=>"sh", "С‰"=>"shch","СЊ"=>"", "СЉ"=>"", "СЋ"=>"yu", "СЏ"=>"ya", "Р–"=>"ZH", "Р¦"=>"TS", "Р§"=>"CH", "РЁ"=>"SH", "Р©"=>"SHCH","Р¬"=>"", "РЄ"=>"", "Р®"=>"YU", "РЇ"=>"YA", "С—"=>"i", "Р‡"=>"Yi", "С”"=>"ie", "Р„"=>"Ye", "&" => "and", "?" => "quest", " " => "_", "," => "", "."=>"." ) ); return $string; } function detect_mobile_device(){ // check if the user agent value claims to be windows but not windows mobile if (stristr(@$_SERVER['HTTP_USER_AGENT'],'windows')&&!stristr(@$_SERVER['HTTP_USER_AGENT'],'windows ce')) return false; // check if the user agent gives away any tell tale signs it's a mobile browser if (eregi('up.browser|up. link |windows ce|Windows Mobile|iemobile|mini|mmp|symbian|midp|wap|phone|pocket|mobile|pda|psp|mobi|SymbOS',@$_SERVER['HTTP_USER_AGENT'])) return true; // check the http accept header to see if wap.wml or wap.xhtml support is claimed if (isset($_SERVER['HTTP_ACCEPT'])&&(stristr($_SERVER['HTTP_ACCEPT'],'text/vnd.wap.wml')||stristr($_SERVER['HTTP_ACCEPT'],'application/vnd.wap.xhtml xml'))) return true; // check if there are any tell tales signs it's a mobile device from the server headers if (isset($_SERVER['HTTP_X_WAP_PROFILE'])|| isset($_SERVER['HTTP_PROFILE'] )|| isset($_SERVER['X-OperaMini-Features']) || isset($_SERVER['UA-pixels'])) return true; // build an array with the first four characters from the most common mobile user agents $a = array ('acs-','alav','alca','amoi','audi','aste','avan','benq','bird','blac','bla z','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno','ipaq','java', 'jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-','maui','maxo','midp','mi ts','mmef','mobi','mot-','moto','mwbp','nec-','newt','noki','opwv','palm','pana' ,'pant','pdxg','phil','play','pluc','port','prox','qtek','qwap','sage','sams','s any','sch-','sec-','send','seri','sgh-','shar','sie-','siem','smal','smar','sony ','sph-','symb','t-mo','teli','tim-','tosh','tsm-','upg1','upsi','vk-v','voda',' w3c ','wap-','wapa','wapi','wapp','wapr','webc','winw','winw','xda','xda-'); // check if the first four characters of the current user agent are set as a key in the array if (isset($a[ substr (@$_SERVER['HTTP_USER_AGENT'],0,4)])) return true; return false; } function auto_price_nacional($id_cur, $price) { if ($id_cur == 1) $price_nacional = $price; if ($id_cur == 2) { $r_usd=sqlval("select kurs from currency where ticker = 'USD' and id_bank = 0 order by data desc limit 0,1"); $price_nacional = intval($price*$r_usd['kurs']); } if ($id_cur == 3) { $r_eur=sqlval("select kurs from currency where ticker = 'EUR' and id_bank = 0 order by data desc limit 0,1"); $price_nacional = intval($price*$r_eur['kurs']); } return $price_nacional; } class PaginationHelper { private static function label($utf8) { $cs = strtolower((string)ini_get('default_charset')); if ($cs === 'windows-1251' || $cs === 'cp1251') { $out = @iconv('UTF-8', 'WINDOWS-1251//IGNORE', $utf8); return $out !== false ? $out : $utf8; } return $utf8; } public static function display( $total, $perpage, $end_list = true, $link_count = 8 ) { $l_pages = self::label('Страницы:'); $l_first = self::label('Первая'); $l_prev = self::label('Предыдущая'); $l_next = self::label('Следующая'); $l_last = self::label('Последняя'); $uri = explode("&", $_SERVER['QUERY_STRING']); foreach ( $uri as $key => $param ) { if ( preg_match("/page=[0-9]+/", $param) ) { unset($uri[$key]); } } echo '<div align="center"><b>'.$l_pages.'</b> '; $base_link = implode('&',$uri); if ($base_link != '') $base_link .= '&'; ( !isset($_REQUEST['page'] ) ) ? $page = 1 : $page = $_REQUEST['page']; $min = $page - $link_count; $max = $page + $link_count; if ($min < 1) $min=1; if ($max >= ceil($total/$perpage)) $max = ceil( $total/$perpage ); if (($min) > 1) { if ( $end_list ) { if ($base_link != '') { $tmp = substr($base_link, 0, strlen($base_link)-1); echo " <a href='{$_SERVER['SCRIPT_NAME']}?{$tmp}' title='".$l_first."'>1</a> "; } else { echo " <a href='{$_SERVER['SCRIPT_NAME']}' title='".$l_first."'>1</a> "; } } $min = $min-1; if ( $min < 1 ) $min=1; $ofs = ( $min-1 ) * $perpage; echo " <a href=\"{$_SERVER['SCRIPT_NAME']}?{$base_link}page={$min}\" title='".$l_prev."'>...</a> "; $min=$min+1; } for ($i = $min; $i <= $max; $i++) { $ofs = ($i - 1) * $perpage; if ($i != $page) { if ( $i == 1 ) { if ($base_link != '') { $tmp = substr($base_link, 0, strlen($base_link)-1); echo " <a href='{$_SERVER['SCRIPT_NAME']}?{$tmp}'>{$i}</a> "; } else { echo " <a href='{$_SERVER['SCRIPT_NAME']}'>{$i}</a> "; } } else { echo " <a href=\"{$_SERVER['SCRIPT_NAME']}?{$base_link}page={$i}\">{$i}</a> "; } } else { echo " <b>{$i}</b> "; } } if ($max < ceil($total/$perpage)) { $ofs=$max*$perpage; $max=$max+1; echo " <a href=\"{$_SERVER['SCRIPT_NAME']}?{$base_link}page={$max}\" title='".$l_next."'>...</a> "; } if ( $end_list ) { if ($max < ceil($total/$perpage)) { $ofs=(ceil($total/$perpage) - 1)*$perpage; $last = ceil($total/$perpage); echo " <a href=\"{$_SERVER['SCRIPT_NAME']}?{$base_link}page={$last}\" title='".$l_last."'>{$last}</a> "; } } echo '</div>'; } public static function display1( $total, $perpage, $end_list = true, $link_count = 2 ) { $uri = explode("&", $_SERVER['QUERY_STRING']); foreach ( $uri as $key => $param ) { if ( preg_match("/page=[0-9]+/", $param) ) { unset($uri[$key]); } } $pagination = ''; $pagination.= '<div class="page-navigate"><div class="page-numbers">'; $base_link = implode('&',$uri); if ($base_link != '') $base_link .= '&'; $base_url = preg_replace("/(&.+)|(\?.+)/i","",$_SERVER['REQUEST_URI']); ( !isset($_REQUEST['page'] ) ) ? $page = 1 : $page = $_REQUEST['page']; $min = $page - $link_count; $max = $page + $link_count; if ($min < 1) $min=1; if ($max >= ceil($total/$perpage)) $max = ceil( $total/$perpage ); if($page>1){ $p = $page - 1; $pagination.= "<div class='btn-back hidden-xs'><span><a href='{$base_url}?{$base_link}page={$p}'>Назад</a></span></div>";} $pagination.= '<ul class="page-numbers-list">'; if (($min) > 1) { if ( $end_list ) { if ($base_link != '') { $tmp = substr($base_link, 0, strlen($base_link)-1); $pagination.= "<li><a href='{$base_url}?{$tmp}' title='Первая'>1</a></li>"; } else { $pagination.= "<li><a href='{$base_url}' title='Первая'>1</a></li>"; } } $min = $min-1; if ( $min < 1 ) $min=1; $ofs = ( $min-1 ) * $perpage; $pagination.= "<li><a href=\"{$base_url}?{$base_link}page={$min}\" title='Предыдущая'>...</a></li>"; $min=$min+1; } for ($i = $min; $i <= $max; $i++) { $ofs = ($i - 1) * $perpage; if ($i != $page) { if ( $i == 1 ) { if ($base_link != '') { $tmp = substr($base_link, 0, strlen($base_link)-1); $pagination.= "<li><a href='{$base_url}?{$tmp}'>{$i}</a></li>"; } else { $pagination.= "<li><a href='{$base_url}'>{$i}</a></li>"; } } else { $pagination.= "<li><a href=\"{$base_url}?{$base_link}page={$i}\">{$i}</a></li>"; } } else { $pagination.= "<li class='active'><a href='#'>{$i}</a></li>"; } } if ($max < ceil($total/$perpage)) { $ofs=$max*$perpage; $max=$max+1; $pagination.= "<li><a href=\"{$base_url}?{$base_link}page={$max}\" title='Следующая'>...</a></li>"; } if ( $end_list ) { if ($max < ceil($total/$perpage)) { $ofs=(ceil($total/$perpage) - 1)*$perpage; $last = ceil($total/$perpage); $pagination.= "<li><a href=\"{$base_url}?{$base_link}page={$last}\" title='Последняя'>{$last}</a></li>"; } } $pagination.= "</ul>"; if($page<ceil($total/$perpage)){ $p1 = $page + 1; $pagination.= "<div class='btn-forward hidden-xs'> <span><a href='{$base_url}?{$base_link}page={$p1}'>Вперёд</a></span></div>";} $pagination.= '</div></div>'; echo "<pre>"; print_r($pagination); echo "</pre>"; } } function obfuscate_email( $email, $text = null ) { if ($text == null) $text = $email; $string = 'document.write(\'<a href="mailto:' . $email . '">' . $text . '</a>\')'; $split = preg_split('||', $string); $out = '<script type="text/javascript"> // <!-- ' . PHP_EOL . "eval(unescape('"; foreach ( $split as $c ) { if ( !empty($c) ) { $out .= '%' . dechex(ord($c)); } } $out .= "'))" . PHP_EOL . '// --> </script>'; return $out; } function array_strip_tags(&$elem) { $elem = strip_tags($elem); } function array_trim(&$elem) { $elem = trim($elem); } function array_mysql_real_escape_string(&$elem) { $elem = mysql_real_escape_string($elem); } function human_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) { if ($length == 0) return ''; if (strlen($string) > $length) { $length -= min($length, strlen($etc)); if (!$break_words && !$middle) { $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1)); } if(!$middle) { return substr($string, 0, $length) . $etc; } else { return substr($string, 0, $length/2) . $etc . substr($string, -$length/2); } } else { return $string; } } function BBCode2Html($text) { $text = trim($text); // BBCode [code] if (!function_exists('escape')) { function escape($s) { global $text; $text = strip_tags($text); $code = $s[1]; $code = htmlspecialchars($code); $code = str_replace("[", "[", $code); $code = str_replace("]", "]", $code); return '<pre><code>'.$code.'</code></pre>'; } } $text = preg_replace_callback('/\[code\](.*?)\[\/code\]/ms', "escape", $text); // Smileys to find... $smiles_in = array('1' => 'O:-', ':-)', ':-(', ';-)', ':-P', '8-)', ':-D', ':-[', '=-O', '*KISSED*', ':\'(', '*DONT_KNOW*', '', ':-|', ':-\\', '', ']:->', '', '', ':-!', '', '*STOP*', ':-*', '@}->--', '*THUMBS UP*', '*DRINK*', '*IN LOVE*', '@=', '*HELP*', '\\m/', '%)', '*OK*', '*WASSUP*', '*SORRY*', '*BRAVO*' ); $smiles_out = array(); for ($i = 1; $i < 36; $i++) { $smiles_out[$i] = '<img src="/chat/smile/anim/' . $i . '.gif" border="0" />'; } $text = str_replace($smiles_in, $smiles_out, $text); // BBCode to find... $in = array( '/\[b\](.*?)\[\/b\]/ms', '/\*0anim\/([0-9]+)\*/ms', '/\*0linx\/([0-9]+)\*/ms', '/\[i\](.*?)\[\/i\]/ms', //'/\[u\](.*?)\[\/u\]/ms', '/\[img\](.*?)\[\/img\]/ms', '/\[email\](.*?)\[\/email\]/ms', '/\[url\](.*?)\[\/url\]/ms', '/\[url\="?(.*?)"?\](.*?)\[\/url\]/ms', /*'/\[size\="?(.*?)"?\](.*?)\[\/size\]/ms', '/\[color\="?(.*?)"?\](.*?)\[\/color\]/ms',*/ '/\[quote](.*?)\[\/quote\]/ms', '/\[u\](.*?)\[\/u\]/ms', '/\[s\](.*?)\[\/s\]/ms', /*'/\[list\=(.*?)\](.*?)\[\/list\]/ms', '/\[list\](.*?)\[\/list\]/ms', '/\[\*\]\s?(.*?)\n/ms'*/ ); // And replace them by... $out = array( '<strong>\1</strong>', '<img src="/chat/smile/anim/\1.gif" />', '<img src="/chat/smile/linx/\1.gif" />', '<em>\1</em>', //'<u>\1</u>', '<img src="\1" alt="\1" />', '<a href="mailto:\1" rel="nofollow">\1</a>', '<a href="\1" target="_blank" rel="nofollow">\1</a>', '<a href="\1" target="_blank" rel="nofollow">\2</a>', /*'<span style="font-size:\1%">\2</span>', '<span style="color:\1">\2</span>',*/ '<table width="550" border="0" cellspacing="1" cellpading="1"><tr><td width="30"> </td><td class="small"><b>Цитата:</b><br /><table border="0" width="100%" cellpading="1"><tr><td bgcolor="#efefef"><table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#ffffff"><tr><td class="small">\1</td></tr></table></td></tr></table></td></tr></table>', '<span style="text-decoration: underline">\1</span>', '<s>\1</s>' /*'<ol start="\1">\2</ol>', '<ul>\1</ul>', '<li>\1</li>'*/ ); $text = preg_replace($in, $out, $text); // paragraphs $text = str_replace("\r", "", $text); $text = "<p>".preg_replace("/(\n){2,}/", "</p><p>", $text)."</p>"; $text = nl2br($text); // clean some tags to remain strict // not very elegant, but it works. No time to do better ;) if (!function_exists('removeBr')) { function removeBr($s) { return str_replace("<br />", "", $s[0]); } } $text = preg_replace_callback('/<pre>(.*?)<\/pre>/ms', "removeBr", $text); $text = preg_replace('/<p><pre>(.*?)<\/pre><\/p>/ms', "<pre>\\1</pre>", $text); $text = preg_replace_callback('/<ul>(.*?)<\/ul>/ms', "removeBr", $text); $text = preg_replace('/<p><ul>(.*?)<\/ul><\/p>/ms', "<ul>\\1</ul>", $text); return $text; } function getCompanyAddress($company_id) { $address_parts = array(); $company = sqlval("select * from firma where id='{$company_id}'"); $rs_locality = sqlval("select * from locality where id='{$company['locality_id']}'"); if (!preg_match('/РіРѕСЂРѕРґ/', $rs_locality['name'])) { $rs_sub_adm_area = sqlval("select * from sub_admn_area where id='{$company['sub_adm_area_id']}'"); $address_parts[] = $rs_sub_adm_area['name']; } $address_parts[] = $rs_locality['name']; if ($company['street']!='') $address_parts[] = $company['street']; if ( $company['house'] != '' && $company['house'] > 0 ) { if ( $company['house_add'] != '' ) { if (is_numeric($company['house_add'])) $address_parts[] = $company['house'].'/'.$company['house_add']; else $address_parts[] = $company['house'].$company['house_add']; } else $address_parts[] = $company['house']; } if ( $company['corps'] != '' ) $address_parts[] = 'РєРѕСЂРїСѓСЃ ' . $company['corps']; if ( $company['build'] != '' ) $address_parts[] = 'строение ' . $company['build']; if ( $company['address_add'] != '' ) $address_parts[] = $company['address_add']; return implode(', ', $address_parts); } function getCompanyAddressShort($company_id) { $address_parts = array(); $company = sqlval("select * from firma where id='{$company_id}'"); $rs_locality = sqlval("select * from locality where id='{$company['locality_id']}'"); if (!preg_match('/РіРѕСЂРѕРґ/', $rs_locality['name'])) { $rs_sub_adm_area = sqlval("select * from sub_admn_area where id='{$company['sub_adm_area_id']}'"); $address_parts[] = $rs_sub_adm_area['name']; } $address_parts[] = $rs_locality['name']; return implode(', ', $address_parts); } function getCompanyPhones($company_id, $separator='<br />') { $phone_table = array(); $phones_result = fetchAll("select * from firma_phone where id_firma='{$company_id}' order by type"); $phone_types_array = array(1=>'Телефон', 2=>'Факс', 3=>'Телефон Рё факс'); foreach ($phones_result as $phone) $phone_array[$phone['type']][$phone['id']] = array('number'=>$phone['number'], 'ext'=>$phone['ext'], 'info'=>$phone['info']); foreach ( $phone_array as $type => $phone_data ) { foreach ( $phone_data as $phone ) { $temp_phone = ''; $temp_phone .= "{$phone_types_array[$type]}: {$phone['number']}"; if ($phone['ext']!='') $temp_phone .= " (РґРѕР±. {$phone['ext']})"; if ($phone['info']!='') $temp_phone .= " - {$phone['info']}"; $phone_table[] = $temp_phone; } } return implode($separator, $phone_table); } function echo_seo_text($id) { global $smarty; $row = sqlval( "select * from seo_text where id='{$id}'" ); $smarty->assign( 'name', $row['name'] ); $smarty->assign( 'note', $row['note'] ); $smarty->display( 'seo_text.tpl' ); $smarty->clear_all_assign(); } function getCompanyCurrenRating($id){ $id = (int) $id; $rs_company = sqlval("select * from firma_rate where firma_id='{$id}'"); return ($rs_company['voters'] > 0) ? @round($rs_company['rate'] / $rs_company['voters'],1) : 0; } function getCompanyIsRated($id) { $ip=$_SERVER['REMOTE_ADDR']; $ip2=getIp(); $uagent=$_SERVER['HTTP_USER_AGENT']; $uinmd=md5($ip.$ip2.$uagent); $sid = $_REQUEST['sid']; $rs_is_voted=sqlval("SELECT COUNT(*) FROM `firma_rate_stat` WHERE `firma_id` = '{$id}' AND (`sid`='{$sid}' OR (`ipUser`='{$ip}' AND `ipProxy`='{$ip2}' AND ((UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`date`)) < 60)))"); return ($rs_is_voted[0] == 0) ? 0 : 1; } function prepare_post($body) { global $admlist,$id_user_sess,$f,$login,$id_author, $tema, $_POST, $r_moder, $stopwords; $id_author=sqlval("select id, note from user where id='".$id_user_sess."'"); //$r_moder=sqlval("select rightf from forum_moder where id_user='".$id_user_sess."'"); if (($admlist[$login] >= 500) or ($r_moder[0] >= 500)) {} else { //$body=htmlspecialchars($body); $body=str_replace("<b>","<b>",$body); $body=str_replace("</b>","</b>",$body); $body=str_replace("<i>","<b>",$body); $body=str_replace("</i>","</b>",$body); //$tema=htmlspecialchars($tema); } $kol_q1=substr_count ($body, "[quote"); $kol_q2=substr_count ($body, "[/quote]"); if (is_int(strpos($body,"[quote"))) { if (!is_int(strpos($body,"[/quote]"))) { $body.="[/quote]"; } } if (is_int(strpos($body,"[/quote]"))) { if (!is_int(strpos($body,"[quote"))) { $body="[quote]".$body; } } if ($kol_q1 <> $kol_q2) { $body=str_replace("[quote]","",$body); $body=str_replace("[/quote]","",$body); } $body = preg_replace('/\[url\="?(.*?)"?\](.*?)\[\/url\]/msi', '<!--noindex--><a href="\1" target="_blank">\2</a><!--/noindex-->', $body); if (!is_int(stripos($body,"[URL]")) && !is_int(stripos($body,"[IMG]")) && !is_int(stripos($body,"<object")) && !is_int(stripos($body,"[quote"))) { $body=preg_replace(" ~([]\r\n\t [(),!<>])(((?:ftp|telnet)://(?:[a-z0-9_-]{1,32}(?::[a-z0-9_-]{1,32})?@)?)?((?:[a-z0-9-]{1,128}\.)+(?:com|net|org|mil|edu|arpa|gov|biz|info|aero|name|pro|coop|museum|[a-z]{2})|(?!0)((?!0[^.]|255)[0-9]{1,3}\.){3}(?!0|255)[0-9]{1,3})(?:/[a-z0-9._@%&?+=/-]*)?(?:#[^ ]*)?)(?=\.*[]\r\n\t [()<>!,-])~ies","'\\1'._my_url_topic('\\2')"," ".$body." "); //$body = preg_replace("#(https?|ftp)://\S+[^\s.,>)\];'\"!?]#", '<a href="\\0">\\0</a>', $body); } $body=str_replace("[img]","[IMG]",$body); $body=str_replace("[/img]","[/IMG]",$body); if (is_int(strpos($body,"[IMG]"))) { if (!is_int(strpos($body,"[/IMG]"))) { $body=str_replace("[IMG]","",$body); } else { //$img=substr($body,strpos("[IMG]",$body)+5,strpos("[/IMG]",$body)-(strpos("[/IMG]",$body)+5)); $body=preg_replace("/\[IMG\](.*)\[\/IMG\]/e","_my_img('\\1')",$body); } } $body=str_replace("[url]","[URL]",$body); $body=str_replace("[/url]","[/URL]",$body); if (is_int(strpos($body,"[URL]"))) { if (!is_int(strpos($body,"[/URL]"))) { $body=str_replace("[URL]","",$body); } else { //$img=substr($body,strpos("[IMG]",$body)+5,strpos("[/IMG]",$body)-(strpos("[/IMG]",$body)+5)); //$body=eregi_replace("\[[ ]*URL[ ]*\]([A-Za-z0-9_\/\-\.\:]*)\[[ ]*/URL[ ]*\]","<a href=\"http://\\1\" target=_blank>\\1</a>",$body); $body=preg_replace("/\[URL\]http\:\/\/([A-Za-z0-9_\/\-\.\:\?\&\=\%]+)\[\/URL\]/U","<a href=\"http://\\1\" target=_blank>\\1</a>",$body); $body=preg_replace("/\[URL\]([A-Za-z0-9_\/\-\.\:\?\&\=\%]+)\[\/URL\]/U","<a href=\"http://\\1\" target=_blank>\\1</a>",$body); $body=preg_replace("/\[URL\]http\:\/\/(.*)\[\/URL\]/U","<a href=\"http://\\1\" target=_blank>\\1</a>",$body); $body=preg_replace("/\[URL\](.*)\[\/URL\]/U","<a href=\"http://\\1\" target=_blank>\\1</a>",$body); //$body=preg_replace("/\[URL\](http:\/\/){0,1}([A-Za-z0-9_\/\-\.\:\?\&\=\%]+)\[\/URL\]/U","<a href=\"\\1\\2\" target=_blank>\\2</a>",$body); } } $body=str_replace("[email]","[EMAIL]",$body); $body=str_replace("[/email]","[/EMAIL]",$body); if (is_int(strpos($body,"[EMAIL]"))) { if (!is_int(strpos($body,"[/EMAIL]"))) { $body=str_replace("[EMAIL]","",$body); } else { $body=eregi_replace("\[EMAIL\](.*)\[/EMAIL\]","<a href=\"mailto:\\1\" target=_blank>\\1</a>",$body); } } if (is_int(strpos($body,"[b]"))) { if (!is_int(strpos($body,"[/b]"))) { $body=str_replace("[b]","",$body); } } $count = 1; do { $body = preg_replace("/\[quote=?([A-zРђ-СЏ0-9\s\)\-\!\@\$\&\%\!\*\.\,\"\'\~]*)\](.+)\[\/quote\]/siUu", "<div class='forum-quote-begin'><strong>Цитата <i>\\1</i>:</strong><div class='forum-quote'>\\2</div></div>", $body, -1, $count); } while ($count != 0 ); $body = preg_replace("/\[\/quote\]/", "", $body); $body=str_replace("[b]","<strong>",$body); $body=str_replace("[/b]","</strong>",$body); $body=str_replace("[i]","<i>",$body); $body=str_replace("[/i]","</i>",$body); $body=str_replace("[s]","<s>",$body); $body=str_replace("[/s]","</s>",$body); $body=str_replace("[u]","<u>",$body); $body=str_replace("[/u]","</u>",$body); $body=str_replace("[92]","\\",$body); $body=nl2br($body); //$body = str_replace_once('<br>', '', $body); // $body = preg_replace('/<br>/', '', $body, 1, $totalCount); $body = str_replace("<div class='forum-quote'><br />", "<div class='forum-quote'>", $body); $body = str_replace("</div><br />", "</div>", $body); if (strstr($body,'*0')) $body=preg_replace("/\*0([a-z]{1,10}\/[0-9]{1,3})\*/e","_mychat_('\\1',1)",$body); $body=str_replace("\n","",$body); $body=str_replace("\r","",$body); // удаляем сессии $body=preg_replace("!(".session_name()."=)[a-f0-9]{32}!i","\\1"."FEDCBA9876543210FEDCBA9876543210",$body); $body=preg_replace("!http://[a-f0-9]{32}:[a-z0-9]{12}@!i","http://login:pass@",$body); //парсим СѓСЂР» //$body=preg_replace("~([ '\"[(<,!])(((?:https?|ftp|telnet|irc|icq)://(?:[a-z0-9_-]{1,32}(?::[a-z0-9_-]{1,32})?@)?)?((?:[a-z0-9-]{1,128}\.)+(?:com|net|org|mil|inc|edu|gov|biz|info|aero|name|pro|coop|museum|arpa|[a-z]{2})|(?!0)((?!0[^.]|255)[0-9]{1,3}\.){3}(?!0|255)[0-9]{1,3})(?::[0-9]{1,5})?(?:/[a-z0-9._()@%&!?^+=/\~-]*)?(?:#[^ &%\"'\\\\]*)?)(?=\.*[] )>!,:-])~ies","'\\1'._my_url_topic('\\2')"," ".$body." "); //$body=preg_replace(" ~([]\r\n\t '\"[(),!<>])(((?:https?|ftp|telnet)://(?:[a-z0-9_-]{1,32}(?::[a-z0-9_-]{1,32})?@)?)?((?:[a-z0-9-]{1,128}\.)+(?:com|net|org|mil|edu|arpa|gov|biz|info|aero|name|pro|coop|museum|[a-z]{2})|(?!0)((?!0[^.]|255)[0-9]{1,3}\.){3}(?!0|255)[0-9]{1,3})(?:/[a-z0-9._@%&?+=/-]*)?(?:#[^ ]*)?)(?=\.*[]\r\n\t [()<>!,-])~ies","'\\1'._my_url_topic('\\2')"," ".$body." "); if (strstr($body,':')) { //$body=preg_replace("/(:[0-9]{1,3})\*/e","_myf_sm_('\\1')",$body); } /* if ($_POST['id_obj'] <> "" && $_POST['tip_obj']) { if ($_POST['tip_obj'] == "news") { // обсуждение новостей $r_news=sqlval("select * from news where id='".$_POST['id_obj']."'"); if (!$r_news) error(); if ($r_news['news_full'] <> "") $zagolovok_aktiv="<a href=\"".$base_url."news.php?news_id=".$r_news['id']."\">".$r_news['news_header']."</a>"; else $zagolovok_aktiv=$r_news['news_header']; $src=$r_news['src']; $data_news=$r_news['data']; $body_discuss="<br>".$zagolovok_aktiv."<br>".$r_news['news_short']; $body="<table width=\"100%\" cellpading=0 cellspacing=0><tr bgcolor=\"#EEEFEB\"><td>"."<img src=\"".$base_url."pict/blok_red.gif\" width=8 height=8 border=0 hspace=5><b>".$data_news."</b> [".$src."]</td></tr><tr bgcolor=\"".$color_table_sel."\"><td>".$zagolovok_aktiv."<br>".$r_news['news_short']."</td></table><br>".$body; } } */ //$body=addslashes($body); $body = preg_replace_callback( $stopwords, create_function( '$matches', 'return "***";' ), $body ); $body = str_replace('<br /> ', '', $body); // удалим iframe, для тех, кто РёС… вставляет $body = \app\core\helpers\Youtube::replaceIframeToLink($body); // конвертируем youtube ссылки РІ iframe $body = \app\core\helpers\Youtube::prepareLinks($body); return $body; } function stop_mat($text) { global $base_url, $stopwords; $text = preg_replace_callback( $stopwords, create_function( '$matches', 'return "***";' ), $text ); return $text; } function d($el){ echo '<pre>'; print_r($el); echo '</pre>'; exit(); } function upload_foto_css1($foto, $name, $wnew = 250, $width_new=600, $sm = 1, $long = 1, $katalog_foto = "user_foto", $orig = 0, $visible_h = 90) { global $login, $base_url, $name_foto_sm, $data_source, $abs_url, $sub_domen_cfg; if ($long == 0) $sm =1; if ($sm == 0) $long =1; if (trim($foto)<>'none') { $size=getimagesize($foto); $type=""; if ( $size[2]==1) $type="gif"; if ( $size[2]==2) $type="jpeg"; if ( $size[2]==3) $type="png"; //if ( $size[2]==6) $type="bmp"; if ($type == "") { echo "<script>alert('Внимание! Р’С‹ пытаетесь добавить фотку РЅРµ поддерживаемого формата. Формат фото должен быть gif, jpg, png! -".$size[2]."')</script>"; return ""; } // if ( $size[2]==6) $type="bmp"; //if ( $size[2]==7) $type="tif"; if ($type=="") $type=substr($foto_name,strrpos($foto_name,".")+1,4); if (!$file=fopen($foto, "rb")) echo "Невозможно открыть файл"; else { /*$blob_foto=fread($file, filesize($foto)); // чтение preg_match_all("/[0-9]{4}\:[0-9]{2}\:[0-9]{2} [0-9]{2}\:[0-9]{2}\:[0-9]{2}/",$blob_foto,$data_source1); $cnt=count($data_source1); $data_source=$data_source1[0][$cnt]; $name_foto=md5(microtime()); if ($orig == 1) { // оригинальное фото $b_orig=move_uploaded_file($foto, $katalog_foto."/".$name_foto."_orig.".$type); if (!$b_orig) echo "Оригинальное фото РЅРµ сохранено "; // echo $katalog_foto."/".$name_foto."_orig.".$type; } if ( $size[2]==1) $name_foto_gif=$name_foto; if ( $size[2]==6) $name_foto_bmp=$name_foto; $name_foto_sm=$name_foto."_sm.".$type; // маленькое РёРјСЏ $name_foto.=".".$type; $imgfile=fopen($katalog_foto."/".$name_foto,"wb"); if (!$imgfile) echo "Файл РЅРµ создан"; fwrite($imgfile,$blob_foto); //записать большой fclose($imgfile);*/ $width=$size[0]; $height=$size[1]; /////////////////// $name_foto = $name.$type; /////////////////////////////////// if ($type == "jpeg") { $im_in = ImageCreateFromJpeg($foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); // $im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); // imageCopy($im_in, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) ".$sub_domen_cfg,$black); unlink($katalog_foto."/".$name_foto); imageJpeg($im_out,$katalog_foto."/".$name_foto, 85); ImageDestroy($im_out); } //////////////// маленькую /*if ($sm == 1) { $prop=$size[0]/$wnew; // пропорция $h_new=round($size[1]/$prop); if ($h_new < $visible_h) { $prop2=$prop*$h_new/$visible_h; // измененная пропорция для сохранения высоты $h_new2=round($size[1]/$prop2); $wnew2=round($size[0]/$prop2); $raznica=($wnew2-$wnew)*$prop2; // разница РІ пикселях РїРѕ ширине надо отступить СЃ РґРІСѓС… сторон //d($raznica); $im_out = @imagecreatetruecolor($wnew,$h_new2); $sizew2=$size[0] - $raznica; imageCopyResampled($im_out, $im_in, 0, 0, $raznica/2, 0, $wnew,$h_new2, $sizew2, $size[1]); imageJpeg($im_out,'1.jpg', 100); ImageDestroy($im_out); exit(); } else { $im_out = @imagecreatetruecolor($wnew,$h_new); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); } imageJpeg($im_out,$katalog_foto."/".$name_foto_sm, 100); ImageDestroy($im_out); }*/ ImageDestroy($im_in); /*if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; }*/ } if ($type == "gif") { $im_in = @ImageCreateFromGif($foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_out, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagegif($im_out,$katalog_foto."/".$name_foto_gif.".gif"); ImageDestroy($im_out); $name_foto=$name_foto_gif.".gif"; } //////////////// маленькую /*if ($sm == 1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new < $visible_h) { $prop2=$prop*$h_new/$visible_h; // измененная пропорция для сохранения высоты $h_new2=round($size[1]/$prop2); $wnew2=round($size[0]/$prop2); $raznica=($wnew2-$wnew)*$prop2; // разница РІ пикселях РїРѕ ширине надо отступить СЃ РґРІСѓС… сторон $im_out = @imagecreatetruecolor($wnew,$h_new2); $sizew2=$size[0] - $raznica; imageCopyResampled($im_out, $im_in, 0, 0, $raznica/2, 0, $wnew,$h_new2, $sizew2, $size[1]); } else { $im_out = @imagecreatetruecolor($wnew,$h_new); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); } imagegif($im_out,$katalog_foto."/".$name_foto_gif."_sm.gif"); ImageDestroy($im_out); }*/ ImageDestroy($im_in); /*if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; $name_foto_sm=$name_foto_gif."_sm.gif"; }*/ } /////////////////////////////////////////// /////////////////////////////////////////// if ($type == "png") { $im_in = ImageCreateFromPng($foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_out, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagePng($im_out,$katalog_foto."/".$name_foto, 9); ImageDestroy($im_out); } //////////////// маленькую /*if ($sm==1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new < $visible_h) { $prop2=$prop*$h_new/$visible_h; // измененная пропорция для сохранения высоты $h_new2=round($size[1]/$prop2); $wnew2=round($size[0]/$prop2); $raznica=($wnew2-$wnew)*$prop2; // разница РІ пикселях РїРѕ ширине надо отступить СЃ РґРІСѓС… сторон $im_out = @imagecreatetruecolor($wnew,$h_new2); $sizew2=$size[0] - $raznica; imageCopyResampled($im_out, $im_in, 0, 0, $raznica/2, 0, $wnew,$h_new2, $sizew2, $size[1]); } else { $im_out = @imagecreatetruecolor($wnew,$h_new); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); } imagePng($im_out,$katalog_foto."/".$name_foto_sm, 9); ImageDestroy($im_out); }*/ ImageDestroy($im_in); /*if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; }*/ } // } ////////////////////////////////////// //fclose($file); } return $name_foto; } } function upload_foto_css($foto, $wnew = 250, $width_new=600, $sm = 1, $long = 1, $katalog_foto = "user_foto", $orig = 0, $visible_h = 90) { global $login, $base_url, $name_foto_sm, $data_source, $abs_url, $sub_domen_cfg; if ($long == 0) $sm =1; if ($sm == 0) $long =1; if (trim($foto)<>'none') { $size=getimagesize($foto); $type=""; if ( $size[2]==1) $type="gif"; if ( $size[2]==2) $type="jpeg"; if ( $size[2]==3) $type="png"; //if ( $size[2]==6) $type="bmp"; if ($type == "") { echo "<script>alert('Внимание! Р’С‹ пытаетесь добавить фотку РЅРµ поддерживаемого формата. Формат фото должен быть gif, jpg, png! -".$size[2]."')</script>"; return ""; } // if ( $size[2]==6) $type="bmp"; //if ( $size[2]==7) $type="tif"; if ($type=="") $type=substr($foto_name,strrpos($foto_name,".")+1,4); if (!$file=fopen($foto, "rb")) echo "Невозможно открыть файл"; else { $blob_foto=fread($file, filesize($foto)); // чтение preg_match_all("/[0-9]{4}\:[0-9]{2}\:[0-9]{2} [0-9]{2}\:[0-9]{2}\:[0-9]{2}/",$blob_foto,$data_source1); $cnt=count($data_source1); $data_source=$data_source1[0][$cnt]; $name_foto=md5(microtime()); if ($orig == 1) { // оригинальное фото $b_orig=move_uploaded_file($foto, $katalog_foto."/".$name_foto."_orig.".$type); if (!$b_orig) echo "Оригинальное фото РЅРµ сохранено "; // echo $katalog_foto."/".$name_foto."_orig.".$type; } if ( $size[2]==1) $name_foto_gif=$name_foto; if ( $size[2]==6) $name_foto_bmp=$name_foto; $name_foto_sm=$name_foto."_sm.".$type; // маленькое РёРјСЏ $name_foto.=".".$type; $imgfile=fopen($katalog_foto."/".$name_foto,"wb"); if (!$imgfile) echo "Файл РЅРµ создан"; fwrite($imgfile,$blob_foto); //записать большой fclose($imgfile); $width=$size[0]; $height=$size[1]; /////////////////// /////////////////////////////////// if ($type == "jpeg") { $im_in = ImageCreateFromJpeg($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); // $im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); // imageCopy($im_in, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) ".$sub_domen_cfg,$black); unlink($katalog_foto."/".$name_foto); imageJpeg($im_out,$katalog_foto."/".$name_foto, 85); ImageDestroy($im_out); } //////////////// маленькую if ($sm == 1) { $prop=$size[0]/$wnew; // пропорция $h_new=round($size[1]/$prop); if ($h_new < $visible_h) { $prop2=$prop*$h_new/$visible_h; // измененная пропорция для сохранения высоты $h_new2=round($size[1]/$prop2); $wnew2=round($size[0]/$prop2); $raznica=($wnew2-$wnew)*$prop2; // разница РІ пикселях РїРѕ ширине надо отступить СЃ РґРІСѓС… сторон $im_out = @imagecreatetruecolor($wnew,$h_new2); $sizew2=$size[0] - $raznica; imageCopyResampled($im_out, $im_in, 0, 0, $raznica/2, 0, $wnew,$h_new2, $sizew2, $size[1]); } else { $im_out = @imagecreatetruecolor($wnew,$h_new); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); } imageJpeg($im_out,$katalog_foto."/".$name_foto_sm, 85); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } if ($type == "gif") { $im_in = @ImageCreateFromGif($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_out, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagegif($im_out,$katalog_foto."/".$name_foto_gif.".gif"); ImageDestroy($im_out); $name_foto=$name_foto_gif.".gif"; } //////////////// маленькую if ($sm == 1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new < $visible_h) { $prop2=$prop*$h_new/$visible_h; // измененная пропорция для сохранения высоты $h_new2=round($size[1]/$prop2); $wnew2=round($size[0]/$prop2); $raznica=($wnew2-$wnew)*$prop2; // разница РІ пикселях РїРѕ ширине надо отступить СЃ РґРІСѓС… сторон $im_out = @imagecreatetruecolor($wnew,$h_new2); $sizew2=$size[0] - $raznica; imageCopyResampled($im_out, $im_in, 0, 0, $raznica/2, 0, $wnew,$h_new2, $sizew2, $size[1]); } else { $im_out = @imagecreatetruecolor($wnew,$h_new); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); } imagegif($im_out,$katalog_foto."/".$name_foto_gif."_sm.gif"); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; $name_foto_sm=$name_foto_gif."_sm.gif"; } } /////////////////////////////////////////// /////////////////////////////////////////// if ($type == "png") { $im_in = ImageCreateFromPng($katalog_foto."/".$name_foto); ////////////////большую if (($width > $width_new) && ($long == 1)) { $prop2=$size[0]/$width_new; $h_new2=round($size[1]/$prop2); if ($h_new2 > $width_new) { $h_new2=$width_new; $prop=$size[1]/$h_new2; $width_new=round($size[0]/$prop); } $im_out = @imagecreatetruecolor($width_new,$h_new2); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width_new,$h_new2, $size[0], $size[1]); //$im_logo = ImageCreateFromPng($abs_url."/image/foto_logo.png"); //imageCopy($im_out, $im_logo, $width - 51, $height - 36, 0, 0, 51, 36); $black=imagecolorallocate($im_in,30,30,30); imagestring($im_in, 3, 5,5,"(c) InfoOrel.ru",$black); unlink($katalog_foto."/".$name_foto); imagePng($im_out,$katalog_foto."/".$name_foto, 9); ImageDestroy($im_out); } //////////////// маленькую if ($sm==1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); if ($h_new < $visible_h) { $prop2=$prop*$h_new/$visible_h; // измененная пропорция для сохранения высоты $h_new2=round($size[1]/$prop2); $wnew2=round($size[0]/$prop2); $raznica=($wnew2-$wnew)*$prop2; // разница РІ пикселях РїРѕ ширине надо отступить СЃ РґРІСѓС… сторон $im_out = @imagecreatetruecolor($wnew,$h_new2); $sizew2=$size[0] - $raznica; imageCopyResampled($im_out, $im_in, 0, 0, $raznica/2, 0, $wnew,$h_new2, $sizew2, $size[1]); } else { $im_out = @imagecreatetruecolor($wnew,$h_new); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); } imagePng($im_out,$katalog_foto."/".$name_foto_sm, 9); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } // } ////////////////////////////////////// fclose($file); } return $name_foto; } } function isNotEmptyArray($array){ if($array and is_array($array) and count($array)>0){return true;}else{return false;} } function issetVar($var){ if(isset($var) and $var!=''){ return true; }else{ return false; } } function detWeightForCriteriy($max_weight,$table,$field,$where){ $max_value_arr = sqlval("SELECT {$field} FROM {$table} ORDER BY {$field} DESC LIMIT 1"); if(isNotEmptyArray($max_value_arr)){ $max_value = $max_value_arr[$field]; $cur_value_arr = sqlval("SELECT {$field} FROM {$table} WHERE {$where} LIMIT 1"); if(isNotEmptyArray($cur_value_arr)){ $cur_value = $cur_value_arr[$field]; if($max_value == 0){return 0;} $cur_weight = ($cur_value * $max_weight)/$max_value; return $cur_weight; }else{return 0;} }else{return 0;} } function detWeightForCriteriyWithCount($max_weight,$table,$field,$having){ $max_value_arr = sqlval("SELECT count($field) as count FROM $table GROUP BY $field ORDER BY count DESC LIMIT 1"); if(isNotEmptyArray($max_value_arr)){ $max_value = $max_value_arr['count']; $cur_value_arr = sqlval("SELECT count($field) as count FROM $table GROUP BY $field HAVING $having LIMIT 1"); if(isNotEmptyArray($cur_value_arr)){ $cur_value = $cur_value_arr['count']; if($max_value == 0){return 0;} $cur_weight = ($cur_value * $max_weight)/$max_value; return $cur_weight; }else{return 0;} }else{return 0;} } function detWeightForFaq($max_weight,$firma){ $sql = "SELECT count(`id_razdel`) AS count,status,otvet FROM faq WHERE otvet <>'' AND status = 3 GROUP BY id_razdel HAVING id_razdel IN ( SELECT fr.id FROM firma_superuser AS fs INNER JOIN faq_razdel AS fr ON fs.user_id = fr.id_moder INNER JOIN firma AS f ON f.id = fs.firma_id WHERE fr.status = 3 AND UNIX_TIMESTAMP(curdate()) BETWEEN UNIX_TIMESTAMP(f.tarif_begin) AND UNIX_TIMESTAMP(f.tarif_end) AND f.id IN ( SELECT id_firm FROM law_rating_firm)) ORDER BY count DESC LIMIT 1"; $max_value_arr = sqlval($sql); if(isNotEmptyArray($max_value_arr)){ $max_value = $max_value_arr['count']; $sql1 = "SELECT fr.id FROM firma_superuser AS fs INNER JOIN faq_razdel AS fr ON fs.user_id = fr.id_moder INNER JOIN firma AS f ON f.id = fs.firma_id WHERE fr.status = 3 AND UNIX_TIMESTAMP(curdate()) BETWEEN UNIX_TIMESTAMP(f.tarif_begin) AND UNIX_TIMESTAMP(f.tarif_end) AND f.id = {$firma} LIMIT 1"; $kons_arr = sqlval($sql1); if(isNotEmptyArray($kons_arr)){ $cur_value_arr = sqlval("SELECT count(id) AS count FROM faq WHERE id_razdel = {$kons_arr['id']} AND otvet <>'' AND status = 3"); if(isNotEmptyArray($cur_value_arr)){ $cur_value = $cur_value_arr['count']; if($max_value == 0){return 0;} $cur_weight = ($cur_value * $max_weight)/$max_value; return $cur_weight; } else{return 0;}}else{return 0;} }else{return 0;} } function detWeightForOtziv($max_weight,$firma,$karma){ $sql = "SELECT count(`id_firm`) AS count FROM firma_otzyv WHERE karma=$karma AND status=3 GROUP BY id_firm HAVING id_firm IN ( SELECT id_firm FROM law_rating_firm) ORDER BY count DESC LIMIT 1"; $max_value_arr = sqlval($sql); if(isNotEmptyArray($max_value_arr)){ $max_value = $max_value_arr['count']; $cur_value_arr = sqlval("SELECT count(*) as count FROM firma_otzyv WHERE id_firm = {$firma} and karma=$karma and status=3"); if(isNotEmptyArray($cur_value_arr)){ $cur_value = $cur_value_arr['count']; if($max_value == 0){return 0;} $cur_weight = ($cur_value * $max_weight)/$max_value; return $cur_weight; } else{return 0;} }else{return 0;} } function detRating($id_firm){ $result = detWeightForCriteriy(6,'law_rating_firm','stag',"id_firm=$id_firm") + detWeightForCriteriy(6,'law_rating_firm','shtat',"id_firm=$id_firm") + detWeightForCriteriy(6,'law_rating_firm','privlek',"id_firm=$id_firm") + detWeightForCriteriy(6,'law_rating_firm','oborot',"id_firm=$id_firm") + detWeightForCriteriy(6,'law_rating_firm','dela',"id_firm=$id_firm") + /*detWeightForCriteriyWithCount(6,'law_uslug_firm','id_firm',"id_firm=$id_firm") + */ detWeightForCriteriyWithCount(6,'law_practic_firm','id_firm',"id_firm=$id_firm") + detWeightForFaq(10,$id_firm) + detWeightForOtziv(10,$id_firm,1) - detWeightForOtziv(10,$id_firm,-1); if($result < 0){ return 0; }else{ return str_replace(',','.',round($result/11.2,1)); } } function allVisits($id_firm){ $id = (int)$id_firm; if(preg_match('/^[\d]{1,}$/i',$id)){ $count_array = sqlval("SELECT count(uin) AS allvisits FROM statistika WHERE (script_name = '/firma.php' AND script_param = 'id={$id}') OR (script_name = '/black-white/read.php' AND script_param = 'id_firm={$id}')"); if(isNotEmptyArray($count_array)){ return $count_array['allvisits']; } else return 0; } } ///////////////////Количество посещений уникальных////////////////////// function uniqueVisits($id_firm){ $id = (int)$id_firm; if(preg_match('/^[\d]{1,}$/i',$id)){ $count_array = sqlval("SELECT(SELECT count(DISTINCT uin) FROM statistika WHERE script_name = '/firma.php' AND script_param = 'id={$id}') + (SELECT count(DISTINCT uin) FROM statistika WHERE script_name = '/black-white/read.php' AND script_param = 'id_firm={$id}') as total"); if(isNotEmptyArray($count_array)){ return $count_array['total']; } else return 0; } } /////////////////////////////Просмотры СЃ карты///////////////////////// function allViewFromMap($id_firm){ $id = (int)$id_firm; if(preg_match('/^[\d]{1,}$/i',$id)){ $count_array = sqlval("SELECT count(uin) as viewmap FROM statistika WHERE script_name = '/maps/index.php' and script_param LIKE '%iz={$id}&tz=3%'"); if(isNotEmptyArray($count_array)){ return $count_array['viewmap']; } else return 0; } } //////////////////////////Уникальные просмотры СЃ карты//////////////////////////// /*function uniqueViewFromMap($id_firm){ $id = (int)$id_firm; if(preg_match('/^[\d]{1,}$/i',$id)){ $count_array = sqlval("SELECT count(DISTINCT uin) as viewmap FROM statistika WHERE script_name = '/maps/index.php' and script_param = 'iz={$id}&tz=3'"); if(isNotEmptyArray($count_array)){ return $count_array['viewmap']; } else return 0; } }*/ ///////////////////////////просмотры каталога товаров организации//////////////////////// function viewKatalog($id_firm){ $id = (int)$id_firm; if(preg_match('/^[\d]{1,}$/i',$id)){ $count_array = sqlval("SELECT count(uin) as viewkatalog FROM statistika WHERE script_name = '/price_firm.php' and script_param = 'id={$id}'"); if(isNotEmptyArray($count_array)){ return $count_array['viewkatalog']; } else return 0; } } ///////////////////////количество просмотров товаров организации////////////////// function viewTovars($id_firm){ $id = (int)$id_firm; if(preg_match('/^[\d]{1,}$/i',$id)){ $count_array = sqlval("SELECT COUNT(uin) AS viewtovars FROM statistika WHERE script_name = '/info_goods.php' AND script_param IN (SELECT CONCAT('id=',tovar.id) FROM tovar, firma WHERE firma.id=tovar.id_firm AND firma.registr=1 AND firma.id={$id})"); if(isNotEmptyArray($count_array)){ return $count_array['viewtovars']; } else return 0; } } function viewNews($id_firm){ $id = (int)$id_firm; if(preg_match('/^[\d]{1,}$/i',$id)){ $news_arr = sqlval("SELECT count(id) as count FROM news WHERE firma_id = {$id} AND status=3"); if(isNotEmptyArray($news_arr) and $news_arr['count']>0){ $count_array = sqlval("SELECT count(uin) AS viewnew FROM statistika WHERE script_name = '/news/news.php' AND script_param IN (SELECT CONCAT('news_id=',id) FROM news WHERE firma_id = {$id} AND status=3)"); if(isNotEmptyArray($count_array)){ return $count_array['viewnew']; } }else{return -1;} } } function upload_foto_tovar_new($foto, $wnew = 250, $width_new=600, $sm = 1, $long = 1, $katalog_foto = "user_foto") { global $login, $base_url, $name_foto_sm, $abs_url; if ($long == 0) $sm =1; if ($sm == 0) $long =1; if (trim($foto)<>'none') { $size=getimagesize($foto); $type=""; if ( $size[2]==1) $type="gif"; if ( $size[2]==2) $type="jpeg"; if ( $size[2]==3) $type="png"; if ($type == "") { echo "<script>alert('Внимание! Р’С‹ пытаетесь добавить фотку РЅРµ поддерживаемого формата. Формат фото должен быть gif, jpg, png!')</script>"; return ""; } // if ( $size[2]==6) $type="bmp"; //if ( $size[2]==7) $type="tif"; if ($type=="") $type=substr($foto_name,strrpos($foto_name,".")+1,4); if (!$file=fopen($foto, "rb")) echo "Невозможно открыть файл"; else { $blob_foto=fread($file, filesize($foto)); // чтение $name_foto=md5(microtime()); if ( $size[2]==1) $name_foto_gif=$name_foto; $name_foto_sm=$name_foto."_sm.".$type; // маленькое РёРјСЏ $name_foto.=".".$type; $imgfile=fopen($katalog_foto."/".$name_foto,"wb"); if (!$imgfile) echo "Файл РЅРµ создан"; fwrite($imgfile,$blob_foto); //записать большой fclose($imgfile); $width=$size[0]; $height=$size[1]; /////////////////// @copy($foto,$katalog_foto.'/'.$name_foto); /////////////////////////////////// if ($type == "jpeg") { $im_in = ImageCreateFromJpeg($katalog_foto."/".$name_foto); //////////////// маленькую if ($sm == 1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imageJpeg($im_out,$katalog_foto."/".$name_foto_sm, 85); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } if ($type == "gif") { $im_in = @ImageCreateFromGif($katalog_foto."/".$name_foto); //////////////// маленькую if ($sm == 1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); $im_out = @imagecreatetruecolor($wnew,$h_new); // imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagegif($im_out,$katalog_foto."/".$name_foto_gif."_sm.gif"); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; $name_foto_sm=$name_foto_gif."_sm.gif"; } } /////////////////////////////////////////// /////////////////////////////////////////// if ($type == "png") { $im_in = ImageCreateFromPng($katalog_foto."/".$name_foto); //////////////// маленькую if ($sm==1) { $prop=$size[0]/$wnew; $h_new=round($size[1]/$prop); $im_out = @imagecreatetruecolor($wnew,$h_new); //imageantialias ($im_out, true); imageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $wnew,$h_new, $size[0], $size[1]); imagePng($im_out,$katalog_foto."/".$name_foto_sm, 9); ImageDestroy($im_out); } ImageDestroy($im_in); if ($long == 0) { unlink($katalog_foto."/".$name_foto); $name_foto=""; } } // } ////////////////////////////////////// fclose($file); } return $name_foto; } } function _sph_indexator_product($id,$l) { if($id == 0){ $result = fetchAll("select tovar.* from tovar, firma where id_firm=firma.id and firma.registr_price='1'"); $last = sqlval("select tovar.id from tovar, firma where id_firm=firma.id and firma.registr_price='1' ORDER BY id DESC LIMIT 1"); $end = $last['id']; $mas = array(); for($i=1;$i<=$end;$i++){ $mas[] = $i*100 +2; } $set = implode(",",$mas); db_connect_sph(); sql("DELETE FROM sph_product WHERE id IN($set)"); foreach ($result as $row) { $row['id'] = $row['id'] * 100 + 2; $row['name'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['name'])); $row['note_small'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['note_small'])); $row['note'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['note'])); sql("replace into sph_product values ('{$row['id']}', '{$row['name']}', '{$row['note_small']}', '{$row['note']}')"); echo mysql_error(); } }else{ $row = sqlval("select tovar.* from tovar, firma where id_firm=firma.id and firma.registr_price='1' and tovar.id=$id"); db_connect_sph(); if(is_array($row) and count($row)>0){ $row['id'] = $row['id'] * 100 + 2; $row['name'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['name'])); $row['note_small'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['note_small'])); $row['note'] = mysql_real_escape_string(iconv("windows-1251", "utf-8", $row['note'])); sql("replace into sph_product values ('{$row['id']}', '{$row['name']}', '{$row['note_small']}', '{$row['note']}')"); echo mysql_error(); } } $l = db_connect(); } function autoloadFirm($className){ require_once("class.".$className.".php"); } function dlina($str,&$smarty){ return strlen($str); } function calculate_age($birthday) { $birthday_timestamp = strtotime($birthday); $age = date('Y') - date('Y', $birthday_timestamp); if (date('md', $birthday_timestamp) > date('md')) { $age--; } return $age; } $smarty->register_function('Slength', 'dlina'); function dataРЎhecking($daterange){ foreach($daterange as $k => $v) { // Разбиваем интервал $date = explode("~", $v); if (count($date) !== 2) { exit("Неверный формат"); } // Проверка РЅР° соответствие формату $startDate = $date[0];//строка $endDate = $date[1];//строка $start = strtotime($startDate);//миллисекунды $end = strtotime($endDate);//миллисекунды if ($startDate == "" || $endDate == "") { exit("Неверный формат: нет даты начала или нет даты окончания"); } if ($start > $end) { exit("Неверный формат: дата начала меньше даты окончания"); } try { $startDate = new DateTime($startDate); $endDate = new DateTime($endDate); } catch (Exception $e) { // echo $e->getMessage(); // echo 'Неверный формат'; exit("Неверный формат2"); } } return 1; } ?>
/
Имя
Дата
Размер
..
2026-10-02
.well-known
2022-05-24
0419be9f6cf559b70d22f61f9fc82f38
2013-06-02
FirmClasses
2015-12-22
PHPMailer
2014-06-23
adadurov
2013-04-27
admin
2026-10-02
afisha
2023-12-27
ajax
2018-07-13
api
2018-01-23
app
2026-10-01
auth
2016-12-20
banner
2020-08-31
bootstrap
2019-02-07
busines
2020-01-15
captcha
2013-04-27
chat
2013-04-27
cron
2026-10-02
css
2019-12-13
error
2013-04-27
feedback
2017-01-27
filechange
2017-06-02
firma
2020-04-06
fonts
2020-04-06
forum
2026-10-01
fotogal
2019-04-15
friends
2017-02-13
fstat
2026-10-02
horoscop
2016-02-15
iframe_banners
2023-11-01
images
2023-12-26
img
2024-09-23
imgprivat
2013-04-27
inc
2026-10-01
job
2023-12-21
js
2019-02-14
kcaptcha
2015-12-30
klient
2018-10-18
konkurs
2016-04-14
konsult
2016-02-15
less
2015-09-25
lib
2013-04-27
library
2010-05-05
life
2024-01-25
maps
2017-11-10
news
2024-04-27
oblast
2017-02-02
partners
2018-05-08
photo_loop
2016-03-01
php_sess
2016-12-23
plugins
2016-02-17
pogoda
2026-10-02
politics
2026-05-25
private
2026-10-01
public
2013-04-27
realty
2017-03-15
realty2
2016-04-11
realty_old
2016-05-05
restoran
2017-07-13
saplnk
2018-10-15
scripts
2013-04-27
search
2019-03-04
sitemaps
2024-09-20
stat
2016-03-01
task
2017-02-14
temp
2015-04-04
template
2016-11-18
tests
2020-02-11
user
2017-08-17
user_file
2020-03-10
user_foto
2026-10-02
vendor
2020-02-07
vendor_old
2020-02-11
viktorina
2017-03-21
visitka
2020-02-26
widgets
2016-11-18
.ftpaccess
2025-04-01
322 байт
.ftpaccess~
2024-10-07
323 байт
.htaccess
2026-05-25
2 кб.
.htaccess~
2024-03-21
2 кб.
403.html
2011-08-08
532 байт
404.php
2017-02-16
42 байт
Class.firma.php
2015-12-22
2 кб.
SimpleImage.php
2016-02-18
43 кб.
_firma.php
2015-12-22
11 кб.
add_moder.php
2016-02-15
426 байт
ajax.php
2016-01-18
3 кб.
app.js
2016-11-23
2 кб.
autoloader.php
2026-10-02
8 кб.
autoloader.php.bak_hostallow
2020-02-04
8 кб.
autoloader_back.php
2019-04-02
7 кб.
autoloader_cli.php
2020-02-07
4 кб.
ban_site.php
2017-02-17
787 байт
banlist.php
2019-01-28
2 кб.
banner_klient.php
2017-03-20
14 кб.
banner_right.inc
2010-05-03
101 байт
bridge.swf
2014-10-17
308 байт
change_password_all.php
2022-04-11
1 кб.
change_password_all.php~
2020-03-05
930 байт
check_iframe.php
2018-05-29
324 байт
check_test.html
2018-06-08
467 байт
class.upload.php
2015-11-02
267 кб.
click_b.php
2017-03-21
652 байт
click_banner.php
2017-02-14
365 байт
composer.json
2020-02-07
528 байт
composer.lock
2020-02-07
46 кб.
config.inc.php
2026-10-02
9 кб.
config.inc.php.bak.cutover
2026-10-01
9 кб.
config.inc.php.bak_mysql_host_20261001213242
2026-10-01
9 кб.
config.inc.php.bak_mysql_host_20261001213307
2026-10-01
9 кб.
config.inc.php.bak_prod_urls
2024-01-09
9 кб.
config.inc.php~
2022-03-03
9 кб.
config_lang.php
2016-11-18
195 байт
confirm.php
2016-12-23
503 байт
confirm_wait.php
2019-05-07
3 кб.
count.php
2017-03-01
6 кб.
custom_user_login.php
2021-09-08
362 байт
da4020760cc057069ee2048b32378410.flv
2016-03-23
19443 кб.
example.php
2016-03-21
32 кб.
favicon.ico
2006-05-11
1 кб.
fb.php
2015-12-14
2 кб.
fb_reg.php
2015-12-14
3 кб.
firm_indexator.php
2017-08-18
303 байт
firma.php
2024-08-23
5 кб.
firma.php~
2020-04-10
5 кб.
firma_back.php
2019-04-03
5 кб.
forma_firm.php
2026-05-25
11 кб.
forma_firm.php~
2023-11-10
11 кб.
forum_reindex.php
2017-09-12
245 байт
func.php
2026-10-02
286 кб.
func.php.bak.authorize_20261002
2026-10-02
286 кб.
func.php.bak.pagination_20261002
2026-10-02
286 кб.
func.php.bak.setnames_20261002
2022-03-03
286 кб.
func.php~
2021-03-15
286 кб.
func_new.php
2019-08-08
12 кб.
go_to_site.php
2017-03-24
674 байт
google3734f948a59c1f00.html
2017-10-10
53 байт
index.php
2026-01-14
13 кб.
index.php~
2024-03-14
12 кб.
index1.html
2015-09-25
70 кб.
index2.html
2023-11-14
62 кб.
index2.html~
2023-05-11
62 кб.
index_back.php
2023-11-14
14 кб.
index_back.php~
2023-09-13
14 кб.
index_old.php
2018-07-11
6 кб.
industry.php
2026-05-25
14 кб.
industry.php~
2021-01-14
15 кб.
industry_03.02.php
2017-02-07
2 кб.
ins_user.php
2015-12-18
15 кб.
katalog_firm.php
2023-12-22
3 кб.
katalog_firm.php~
2019-03-17
3 кб.
katalog_firm_new.php
2018-01-16
3 кб.
katalog_firm_old.php
2016-04-11
3 кб.
katalog_search.php
2016-01-21
9 кб.
katalog_tovar.php
2015-11-09
6 кб.
live-597cb0d9.txt
2018-05-15
22 байт
logout.php
2015-12-14
1 кб.
mailsock.php
2012-12-18
3 кб.
md5ttt.php
2017-03-07
56 байт
mechta.jpg
2020-09-04
121 кб.
modifier.length.php
2015-12-23
745 байт
modifier.length.php~
2026-07-24
745 байт
news.rss
2026-10-02
72 кб.
news.rss~
2026-09-12
97 кб.
oauth_user_confirm.php
2017-07-03
762 байт
odkl.php
2015-12-08
2 кб.
odkl_reg.php
2015-12-14
3 кб.
otrasl.php
2017-02-07
452 байт
out_password.php
2015-12-14
4 кб.
password.php
2015-12-15
3 кб.
phpunit.xml.dist
2020-02-11
386 байт
politics.php
2026-05-25
621 байт
products.php
2020-04-28
2 кб.
quote_test.php
2017-02-17
636 байт
realdb.php
2016-12-29
108 байт
register_finish.php
2017-07-05
3 кб.
registration.php
2026-05-25
5 кб.
registration.php~
2015-12-10
5 кб.
registrationfb.php
2015-12-14
4 кб.
registrationok.php
2015-12-14
4 кб.
registrationvk.php
2015-12-11
4 кб.
restoran_indexator.php
2017-08-01
997 байт
robots.txt
2026-10-02
2 кб.
robots.txt.bak_prod
2026-01-14
2 кб.
robots.txt.stand_noindex
2026-10-02
88 байт
robots.txt~
2024-10-21
2 кб.
schet.png
2017-03-01
686 байт
schetchik.inc
2019-04-18
441 байт
search.php
2019-04-01
40 кб.
search_back.php
2019-03-20
39 кб.
sitemap_generator.php
2024-10-21
34 кб.
sitemap_generator.php~
2024-01-25
34 кб.
smtpEmailValidation.php
2015-12-09
7 кб.
ta.php
2015-12-11
2 кб.
ta_reg.php
2015-12-14
3 кб.
test.php
2020-04-06
67 кб.
user_form.inc.php
2012-05-28
11 кб.
user_info.php
2017-09-04
1 кб.
view_b.php
2014-06-16
2 кб.
view_banner.php
2009-10-26
820 байт
vote_frame.php
2019-03-21
7 кб.
vote_frame_back.php
2017-08-17
7 кб.
watermark.php
2014-08-19
1015 байт
yandex_60dbd5831b8ec85b.html
2019-04-25
161 байт
yandex_60dbd5831b8ec85b.html~
2026-07-24
161 байт
yb.php
2016-03-09
2 кб.
yesno.php
2014-01-17
1 кб.
Политика конфиденциальности.docx
2024-08-30
25 кб.
Политика конфиденциальности.docx~
2024-02-15
20 кб.
Согласие_на_обработку_персональных_данных_с_помощью_сервиса_«Яндекс.docx
2025-04-01
18 кб.
Загрузить файлы
Файл 1
Файл 2
Файл 3