if (!defined('INTERNAL_FLAG')) {
die("Not internal call");
}
//Прогрузим языки
$array_lang = array();
$SQL = "select abr from sys_lang where enabled='1' order by lang_id asc";
$qRS = mysql_query ($SQL) or die('
Error:'.$SQL.'
'.mysql_error());
if (mysql_num_rows($qRS)) {
$enabled_lang_version = true;
while($row = mysql_fetch_object($qRS)) {
array_push($array_lang, strtolower($row->abr));
}
} else {
$enabled_lang_version = false;
}
?>
if (!defined('INTERNAL_FLAG')) {
die("Not internal call");
}
//Языковые константы
if (defined('SEL_LANG')) {
$w_lang .= " and lang = '".SEL_LANG."'";
} else {
//Языковые константы
if (!empty($_SESSION['adm_ses']["lang"])) {
$w_lang .= " and lang = '".$_SESSION['adm_ses']["lang"]."'";
}
}
// Константы
$sys_const = array();
$SQL = "select * from sys_const where 1=1 ".$w_lang ." and flag_delete = '0' order by const_id asc";
$qRS = mysql_query ($SQL) or die('
Error:'.$SQL.'
'.mysql_error());
if (mysql_num_rows($qRS)) {
while($row = mysql_fetch_object($qRS)) {
if (!defined($row->name)) {
define($row->name, stripslashes(trim($row->value)));
$sys_const[$row->name] = stripslashes(trim($row->value));
}
}
}
$SQL = "select * from info_block where 1=1 ".$w_lang ." order by info_block_id asc";
$qRS = mysql_query ($SQL) or die('
Error:'.$SQL.'
'.mysql_error());
if (mysql_num_rows($qRS)) {
while($row = mysql_fetch_object($qRS)) {
if (!defined($row->const_name)) {
define($row->const_name, stripslashes(trim($row->information)));
}
}
}
?>
function convert_prefix_www($site) {
if (!empty($site) && $site != "нет данных") {
if (substr($site,0,7) != "http://") {
$site = "http://".$site;
}
}
/*
if (substr($site,0,3) == "www") {
$site = "http://".$site;
}
*/
return $site;
}
function words_substr($in_str, $cnt_chars) {
$flag_big = false;
$str_word = "";
$page_word = array();
$page_word = explode(" ", $in_str);
if (sizeof($page_word)) {
foreach($page_word as $num => $p_w) {
$len = strlen($str_word)+strlen($p_w);
//$str_word .= " ".strlen($p_w)." ".$cnt_chars;
if ($len <= $cnt_chars) {
$str_word .= " ".$p_w;
} else {
$flag_big = true;
break;
}
}
}
if ($flag_big) {
$str_word .= "...";
}
return trim($str_word);
}
function get_r_date($ts=0, $lang='ru') {
if ($lang == 'en') {
$mon_arr = array(1 => "January ", 2 => "February ", 3 => "March ", 4 => "April ", 5 => "May ", 6 => "June ", 7 => "July ", 8 => "August ", 9 => "September ", 10 => "October ", 11 => "November ", 12 => "December");
} else {
$mon_arr = array(1 => "января", 2 => "февраля", 3 => "марта", 4 => "апреля", 5 => "мая", 6 => "июня", 7 => "июля", 8 => "августа", 9 => "сентября", 10 => "октября", 11 => "ноября", 12 => "декабря");
}
$s = date("j", $ts)." ".$mon_arr[date("n", $ts)]." ".date("Y", $ts);
return $s;
}
function get_r_date_min($ts=0, $lang='ru') {
if ($lang == 'en') {
$mon_arr = array(1 => "January ", 2 => "February ", 3 => "March ", 4 => "April ", 5 => "May ", 6 => "June ", 7 => "July ", 8 => "August ", 9 => "September ", 10 => "October ", 11 => "November ", 12 => "December");
} else {
$mon_arr = array(1 => "Январь", 2 => "Февраль", 3 => "Март", 4 => "Апрель", 5 => "Май", 6 => "Июнь", 7 => "Июль", 8 => "Август", 9 => "Сентябрь", 10 => "Октябрь", 11 => "Ноябрь", 12 => "Декабрь");
}
$s = $mon_arr[date("n", $ts)]." ".date("Y", $ts);
return $s;
}
function get_date_small($ts=0) {
if (date("j", $ts) < 10) {
$s = "0".date("j", $ts).".".date("m", $ts);
} else {
$s = date("j", $ts).".".date("m", $ts);
}
return $s;
}
function get_r_date_time($ts=0) {
$mon_arr = array(1 => "января", 2 => "февраля", 3 => "марта", 4 => "апреля", 5 => "мая", 6 => "июня", 7 => "июля", 8 => "августа", 9 => "сентября", 10 => "октября", 11 => "ноября", 12 => "декабря");
//$mon_arr = array(1 => "Января", 2 => "Февраля", 3 => "Марта", 4 => "Апреля", 5 => "Мая", 6 => "Июня", 7 => "Июля", 8 => "Августа", 9 => "Сентября", 10 => "Октября", 11 => "Ноября", 12 => "Декабря");
//$s = date("j", $ts)." ".$mon_arr[date("n", $ts)]." ".date("Y", $ts)." ".date("H", $ts).":".date("i", $ts);
$s = date("j", $ts)." ".$mon_arr[date("n", $ts)].", ".date("H", $ts).":".date("i", $ts);
return $s;
}
function get_r_time($ts=0) {
$s = date("H", $ts).":".date("i", $ts);
return $s;
}
function get_time($ts=0) {
$s = date("H", $ts).":".date("i", $ts);
return $s;
}
function get_ext_file($file_name) {
$pos_dot = strrpos($file_name, ".");
$ext = substr($file_name, $pos_dot+1);
return $ext;
}
function get_lang_date_time($ts = 0, $lang = 'ru') {
if ($lang == 'en') {
$mon_arr = array(1 => "January ", 2 => "February ", 3 => "March ", 4 => "April ", 5 => "May ", 6 => "June ", 7 => "July ", 8 => "August ", 9 => "September ", 10 => "October ", 11 => "November ", 12 => "December");
} else if ($lang == 'kz') {
$mon_arr = array(1 => "қаңтар ", 2 => "ақпан ", 3 => "наурыз ", 4 => "сәуір ", 5 => "мамыр ", 6 => "маусым ", 7 => "шілде ", 8 => "тамыз ", 9 => "қыркүйек ", 10 => "қазан ", 11 => "қараша ", 12 => "желтоқсан");
} else {
$mon_arr = array(1 => "января", 2 => "февраля", 3 => "марта", 4 => "апреля", 5 => "мая", 6 => "июня", 7 => "июля", 8 => "августа", 9 => "сентября", 10 => "октября", 11 => "ноября", 12 => "декабря");
}
$s = date("j", $ts)." ".$mon_arr[date("n", $ts)]." ".date("Y", $ts).", ".date("H", $ts).":".date("i", $ts);;
return $s;
}
function get_name_not_ext($file_name) {
$path_parts = pathinfo($file_name);
$pos_dot = strrpos($path_parts["basename"], ".");
$name = substr($file_name, 0, $pos_dot);
return $name;
}
function my_resize($in_file, $new_name, $ext, $max_size) {
$error_code = 1;
$size = getimagesize($in_file);
$in_width = $size[0];
$in_height = $size[1];
if (!$in_width || !$in_height) {
return $error_code;
}
//echo("
Orig size:".$in_width."x".$in_height."");
if ($in_width > $max_size || $in_height > $max_size) {
if ($in_width > $in_height) {
$new_width = $max_size;
$new_height = ($new_width / $in_width) * $in_height;
} else {
$new_height = $max_size;
$new_width = ($new_height / $in_height) * $in_width;
}
} else {
//echo $in_file.">>>".$new_name;
copy($in_file, $new_name);
return 0;
/*
$new_width = $in_width;
$new_height = $in_height;
*/
}
switch($ext) {
case 'gif':
$im1 = imagecreatefromgif($in_file);
break;
case 'jpg':
$im1 = imagecreatefromjpeg($in_file);
break;
case 'png':
$im1 = imagecreatefrompng($in_file);
break;
}
//imagegif($im1,$new_name);
//$im1 = @imagecreatefromstring($in_file);
$im2 = @imagecreatetruecolor($new_width, $new_height);
if (!$im1 || !$im2) {
return $error_code;
}
$res = imagecopyresampled($im2, $im1, '0', '0', '0', '0', $new_width, $new_height, $in_width, $in_height);
if (!$res) {
return $error_code;
}
switch($ext) {
case 'gif':
imagegif($im2,$new_name);
break;
case 'jpg':
imagejpeg($im2,$new_name);
break;
case 'png':
imagepng($im2,$new_name);
break;
}
}
//Специальный ресайз, стреч по max_size_w и обрезает снизу по max_size_h
function my_resize_special($in_file, $new_name, $ext, $max_size_w, $max_size_h) {
$error_code = 1;
$size = getimagesize($in_file);
$in_width = $size[0];
$in_height = $size[1];
if (!$in_width || !$in_height) {
return $error_code;
}
//echo("
Orig size:".$in_width."x".$in_height."");
if ($in_width == $max_size_w && $in_height == $max_size_h) {
copy($in_file, $new_name);
return 0;
} else {
$new_width = $max_size_w;
$new_height = ($new_width / $in_width) * $in_height;
}
switch($ext) {
case 'gif':
$im1 = imagecreatefromgif($in_file);
break;
case 'jpg':
$im1 = imagecreatefromjpeg($in_file);
break;
case 'png':
$im1 = imagecreatefrompng($in_file);
break;
}
$im2 = @imagecreatetruecolor($new_width, $new_height);
$im3 = @imagecreatetruecolor($max_size_w, $max_size_h);
if (!$im1 || !$im2 || !$im3) {
return $error_code;
}
//Стречем сделаем нужный п ширине
$res = imagecopyresampled($im2, $im1, '0', '0', '0', '0', $new_width, $new_height, $in_width, $in_height);
if (!$res) {
return $error_code;
}
//Скопируем нужный верхний кусочек картинки отбросив нижнюю часть
$res = imagecopy($im3, $im2, 0, 0, 0, 0, $max_size_w, $max_size_h);
if (!$res) {
return $error_code;
}
$handle = fopen($new_name, 'w');
fclose($handle);
switch($ext) {
case 'gif':
imagegif($im3,$new_name);
break;
case 'jpg':
imagejpeg($im3,$new_name);
break;
case 'png':
imagepng($im3,$new_name);
break;
}
}
function check_input_email($email = '') {
$mes = "";
if ($email != "") {
if (!preg_match ("/(\S+)\@(\S+)\.(\S+)/",$email)) {
$mes .= "Неверный синтаксис email.";
} elseif (strchr ($email,"'") || strchr ($email,'"') || strchr ($email,"/") || strchr ($email,"&") || strchr ($email,",") || strchr ($email,";") || strchr ($email,"\\")) {
$mes .= "Запрещенный символ в строке E-mail.";
}
} else {
$mes .= "E-mail отсутствует.";
}
return $mes;
}
function is_parsed($body) {
$tree_xml = "".stripslashes($body)."";
$xsl_file = str_replace("//", "/", $_SERVER["DOCUMENT_ROOT"]."/_symp/_xslt/_adm/head_adm.xsl");
$xsl = new DOMDocument;
$xsl->load($xsl_file);
// Load the XML source
//set_error_handler('HandleXmlError');
$xml = new DOMDocument;
$res = $xml->loadXML($tree_xml);
if (!$res) {
return false;
}
restore_error_handler();
// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
$valid_html = $proc->transformToXML($xml);
if ($valid_html === false) {
return false;
} else {
return true;
}
}
/*
function HandleXmlError($errno, $errstr, $errfile, $errline) {
if ($errno==E_WARNING && (substr_count($errstr,"DOMDocument::loadXML()")>0)) {
return true;
} else {
return false;
}
}
function is_parsed($body) {
$xml = "".stripslashes($body)."";
$xslt = "/_symp/_xslt/_adm/head_adm.xsl";
$xslt = str_replace("//", "/", $_SERVER["DOCUMENT_ROOT"] . $xslt);
$xslt_filename = basename($xslt);
$xslt_basedir = "file://".dirname($xslt)."/";
$xh = xslt_create();
xslt_set_base($xh, $xslt_basedir); // XSL Path
$arguments = array("/_xml" => $xml);
$valid_html = @xslt_process($xh, "arg:/_xml", $xslt_basedir."/".$xslt_filename, NULL, $arguments);
if ($valid_html) {
return true;
} else {
return false;
}
}
*/
/*
function mailer($to, $subject, $message) {
$message = str_replace('№', 'No', $message);
$message = str_replace('«', '«', $message);
$message = str_replace('»', '»', $message);
$message = '
'.convert_cyr_string($message,"w","k").'
';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=KOI8-R\r\n";
$headers .= "From: ".P_HEAD_MAIL." <".P_HEAD_MAIL.">\r\n";
//print $message;
return @mail($to, convert_cyr_string($subject,"w","k"), $message, $headers);
}
*/
function mailer($to, $subject, $message) {
$message = '
'.$message.'
';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";
$headers .= "From: ".P_HEAD_MAIL." <".P_HEAD_MAIL.">\r\n";
//print wordwrap($message, 76, "\r\n", 0);
return @mail($to, $subject, wordwrap($message, 76, "\r\n", 0), $headers);
}
function mailer_no_wordwrap($to, $subject, $message) {
$message = '
'.$message.'
';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";
$headers .= "From: ".P_HEAD_MAIL." <".P_HEAD_MAIL.">\r\n";
//print wordwrap($message, 76, "\r\n", 0);
return @mail($to, $subject, $message, $headers);
}
/*
function my_chunk_split($in_str) {
$size = 75;
$out_str = "";
$start_pos = 0;
$stop_pos = 0;
while ($start_pos <= strlen($in_str)) {
$temp_str = "";
$new_size = $size;
$temp_str = substr($in_str, $start_pos, $new_size);
$space_pos = strrpos($temp_str, " ");
if ($space_num !== false) {
$new_size = $space_pos;
$temp_str = substr($in_str, $start_pos, $new_size);
}
$out_str .= $temp_str."\r\n";
$start_pos = $new_size + 1;
}
return $out_str;
}
*/
function get_x_ip() {
if (getenv('HTTP_X_FORWARDED_FOR')) {
$str_ip = getenv('HTTP_X_FORWARDED_FOR');
} else if (getenv('HTTP_X_FORWARDED')) {
$str_ip = getenv('HTTP_X_FORWARDED');
} else if (getenv('HTTP_FORWARDED_FOR')) {
$str_ip = getenv('HTTP_FORWARDED_FOR');
} else if (getenv('HTTP_FORWARDED')) {
$str_ip = getenv('HTTP_FORWARDED');
} else {
$str_ip = "";
}
return $str_ip;
}
function select_url($text, $class = '') {
$lower_text = strtolower($text);
$orign_text = $text;
if ($class){
$css = ' class="'.$css.'"';
} else {
$css = '';
}
$sfind[] = 'http://';
$sfind[] = 'ftp://';
$spec = "href=";
$efind[] = "\n";
$efind[] = "\t";
$efind[] = "\r";
$efind[] = "<"; //tag
$efind[] = " ";
$flag_find = 1;
$last_p2 = 0;
while ($flag_find == 1){
//найдем первый символ
$p1 = strlen($lower_text);
$pos = 0;
foreach($sfind as $value){
$plus_next = 0;
do {
$back = false;
$pos = strpos($lower_text, $value, $last_p2 + $plus_next);
if ($pos !== false && $pos <= $p1){
$sback = substr($lower_text, $pos-strlen($spec)-2, strlen($spec)+2);
//echo 'sback = "'.$sback.'"
';
$back = strpos($sback, $spec);
//echo 'back = '.$back.'
';
if ($back === false){
$p1 = $pos;
}
}
// echo 'back = '.$back.'
';
$plus_next = $pos - $last_p2 + 1;
} while($back !== false);
}
//echo 'p1 = '.$p1.'
';
//найдем последний символ
$p2 = strlen($lower_text);
$pos = 0;
foreach($efind as $value){
$pos = strpos($lower_text, $value, $p1);
if ($pos !== false && $pos <= $p2)
{
$p2 = $pos;
}
}
//echo 'p2 = '.$p2.'
';
if ($p1 == strlen($lower_text)){
$flag_find = 0;
} else {
$one_flag = 1;
if ($p2 == 0 || $p2 === false){
$p2 = strlen($lower_text);
}
$out_text .= substr($orign_text, $last_p2, $p1-$last_p2);
$href = substr($orign_text, $p1, $p2-$p1);
// echo 'href - '.$href.'
';
$out_text .= ''.trim($href).'';
//$in_text = substr($in_text, $p2);
//echo $in_text.'
';
$flag_find = 1;
$last_p2 = $p2;
}
}
if ($one_flag)
{
$out_text .= substr($orign_text, $last_p2);
} else {
$out_text = $text;
}
return trim($out_text);
}
function cyr_to_en($str) {
$in_str = strtolower($str);
$in_str = str_replace("а", "a", $in_str);
$in_str = str_replace("б", "b", $in_str);
$in_str = str_replace("в", "v", $in_str);
$in_str = str_replace("г", "g", $in_str);
$in_str = str_replace("д", "d", $in_str);
$in_str = str_replace("е", "e", $in_str);
$in_str = str_replace("ё", "io", $in_str);
$in_str = str_replace("ж", "j", $in_str);
$in_str = str_replace("з", "z", $in_str);
$in_str = str_replace("и", "i", $in_str);
$in_str = str_replace("й", "ii", $in_str);
$in_str = str_replace("к", "k", $in_str);
$in_str = str_replace("л", "l", $in_str);
$in_str = str_replace("м", "m", $in_str);
$in_str = str_replace("н", "n", $in_str);
$in_str = str_replace("о", "o", $in_str);
$in_str = str_replace("п", "p", $in_str);
$in_str = str_replace("р", "r", $in_str);
$in_str = str_replace("с", "s", $in_str);
$in_str = str_replace("т", "t", $in_str);
$in_str = str_replace("у", "u", $in_str);
$in_str = str_replace("ф", "f", $in_str);
$in_str = str_replace("х", "h", $in_str);
$in_str = str_replace("ц", "c", $in_str);
$in_str = str_replace("ч", "ch", $in_str);
$in_str = str_replace("ш", "sh", $in_str);
$in_str = str_replace("щ", "sh", $in_str);
$in_str = str_replace("ъ", "", $in_str);
$in_str = str_replace("ы", "i", $in_str);
$in_str = str_replace("ь", "", $in_str);
$in_str = str_replace("э", "e", $in_str);
$in_str = str_replace("ю", "ju", $in_str);
$in_str = str_replace("я", "ja", $in_str);
return $in_str;
}
function str2mail($str) {
return '=?utf-8?B?'.base64_encode($str).'?=';
}
function replace_links($text) {
$text = ereg_replace("[a-zA-Z]+://([.]?[a-zA-Z0-9_/-])*", "\\0", $text);
$text = ereg_replace("(^| )(www([.]?[a-zA-Z0-9_/-])*)", "\\1\\2", $text);
return $text;
}
function cyr_count($in_number, $cyr_type1, $cyr_type2, $cyr_type3) {
if (intval(substr($in_number,-2,2)) >= 10 && intval(substr($in_number,-2,2)) <= 14) {
$cnt_des = 0;
} else {
$cnt_des = intval(substr($in_number,-1,1));
}
switch ($cnt_des) {
case 1:
$cnt_str = $cyr_type1;
break;
case 2:
case 3:
case 4:
$cnt_str = $cyr_type2;
break;
case 5:
case 6:
case 7:
case 8:
case 9:
case 0:
$cnt_str = $cyr_type3;
break;
default:
$cnt_str = "";
}
return $cnt_str;
}
function date_i18n($format, $timestamp, $sel_lang = 'en') {
$translation_ru = array(
"am" => "дп",
"pm" => "пп",
"AM" => "ДП",
"PM" => "ПП",
"Monday" => "Понедельник",
"Mon" => "Пн",
"Tuesday" => "Вторник",
"Tue" => "Вт",
"Wednesday" => "Среда",
"Wed" => "Ср",
"Thursday" => "Четверг",
"Thu" => "Чт",
"Friday" => "Пятница",
"Fri" => "Пт",
"Saturday" => "Суббота",
"Sat" => "Сб",
"Sunday" => "Воскресенье",
"Sun" => "Вс",
"January" => "Январь",
"Jan" => "янв",
"February" => "Февраль",
"Feb" => "фев",
"March" => "Март",
"Mar" => "мар",
"April" => "Апрель",
"Apr" => "апр",
"May" => "Май",
"May" => "Май",
"June" => "Июнь",
"Jun" => "июн",
"July" => "Июль",
"Jul" => "июл",
"August" => "Август",
"Aug" => "авг",
"September" => "Сентябрь",
"Sep" => "сен",
"October" => "Октябрь",
"Oct" => "окт",
"November" => "Ноябрь",
"Nov" => "ноя",
"December" => "Декабрь",
"Dec" => "дек",
"st" => "ое",
"nd" => "ое",
"rd" => "е",
"th" => "ое",
);
$translation_kz = array(
"am" => "тд",
"pm" => "тк",
"AM" => "ТД",
"PM" => "ТК",
"Monday" => "Дүйсенбі",
"Mon" => "Дс",
"Tuesday" => "Бейсенбі",
"Tue" => "Бс",
"Wednesday" => "Сәрсенбі",
"Wed" => "Ср",
"Thursday" => "Сейсенбі",
"Thu" => "Сс",
"Friday" => "Жұма",
"Fri" => "Жм",
"Saturday" => "Сенбі",
"Sat" => "Сн",
"Sunday" => "Жексенбі",
"Sun" => "Жк",
"January" => "қаңтар",
"Jan" => "қаң",
"February" => "ақпан",
"Feb" => "ақп",
"March" => "наурыз",
"Mar" => "нау",
"April" => "сәуір",
"Apr" => "сәу",
"May" => "мамыр",
"May" => "мамыр",
"June" => "маусым",
"Jun" => "мау",
"July" => "шілде",
"Jul" => "шіл",
"August" => "тамыз",
"Aug" => "там",
"September" => "қыркүйек",
"Sep" => "қырк",
"October" => "қазан",
"Oct" => "қаз",
"November" => "қараша",
"Nov" => "қар",
"December" => "желтоқсан",
"Dec" => "желт",
"st" => "ші",
"nd" => "ші",
"rd" => "ші",
"th" => "ші",
);
switch ($sel_lang) {
default:
return date($format, $timestamp);
break;
case 'ru':
case 'Ru':
case 'RU':
case 'rus':
case 'Rus':
case 'RUS':
return strtr(date($format, $timestamp), $translation_ru);
break;
case 'kz':
case 'Kz':
case 'Kz':
case 'kaz':
case 'Kaz':
case 'KAZ':
return strtr(date($format, $timestamp), $translation_kz);
break;
}
} // date_i18n
function date_i18n_2($format, $timestamp, $sel_lang = 'en') {
$translation_ru = array(
"am" => "дп",
"pm" => "пп",
"AM" => "ДП",
"PM" => "ПП",
"Monday" => "Понедельник",
"Mon" => "Пн",
"Tuesday" => "Вторник",
"Tue" => "Вт",
"Wednesday" => "Среда",
"Wed" => "Ср",
"Thursday" => "Четверг",
"Thu" => "Чт",
"Friday" => "Пятница",
"Fri" => "Пт",
"Saturday" => "Суббота",
"Sat" => "Сб",
"Sunday" => "Воскресенье",
"Sun" => "Вс",
"January" => "Января",
"Jan" => "янв",
"February" => "Февраля",
"Feb" => "фев",
"March" => "Марта",
"Mar" => "мар",
"April" => "Апреля",
"Apr" => "апр",
"May" => "Май",
"May" => "Май",
"June" => "Июня",
"Jun" => "июн",
"July" => "Июля",
"Jul" => "июл",
"August" => "Августа",
"Aug" => "авг",
"September" => "Сентября",
"Sep" => "сен",
"October" => "Октября",
"Oct" => "окт",
"November" => "Ноября",
"Nov" => "ноя",
"December" => "Декабря",
"Dec" => "дек",
"st" => "ое",
"nd" => "ое",
"rd" => "е",
"th" => "ое",
);
$translation_kz = array(
"am" => "тд",
"pm" => "тк",
"AM" => "ТД",
"PM" => "ТК",
"Monday" => "Дүйсенбі",
"Mon" => "Дс",
"Tuesday" => "Бейсенбі",
"Tue" => "Бс",
"Wednesday" => "Сәрсенбі",
"Wed" => "Ср",
"Thursday" => "Сейсенбі",
"Thu" => "Сс",
"Friday" => "Жұма",
"Fri" => "Жм",
"Saturday" => "Сенбі",
"Sat" => "Сн",
"Sunday" => "Жексенбі",
"Sun" => "Жк",
"January" => "қаңтар",
"Jan" => "қаң",
"February" => "ақпан",
"Feb" => "ақп",
"March" => "наурыз",
"Mar" => "нау",
"April" => "сәуір",
"Apr" => "сәу",
"May" => "мамыр",
"May" => "мамыр",
"June" => "маусым",
"Jun" => "мау",
"July" => "шілде",
"Jul" => "шіл",
"August" => "тамыз",
"Aug" => "там",
"September" => "қыркүйек",
"Sep" => "қырк",
"October" => "қазан",
"Oct" => "қаз",
"November" => "қараша",
"Nov" => "қар",
"December" => "желтоқсан",
"Dec" => "желт",
"st" => "ші",
"nd" => "ші",
"rd" => "ші",
"th" => "ші",
);
switch ($sel_lang) {
default:
return date($format, $timestamp);
break;
case 'ru':
case 'Ru':
case 'RU':
case 'rus':
case 'Rus':
case 'RUS':
return strtr(date($format, $timestamp), $translation_ru);
break;
case 'kz':
case 'Kz':
case 'Kz':
case 'kaz':
case 'Kaz':
case 'KAZ':
return strtr(date($format, $timestamp), $translation_kz);
break;
}
} // date_i18n_2
/**
* Получает инфоблоки по $const_name и возвращает в массив. Если такой константы нет, возвращает массив с одним пустым полем или с $tmp_str
* @param string $const_name Имя константы
* @param string $lang Язык блока
* @param string $tmp_str Строка, если константы нет. По умолчанию ""
* @param int $shuffle Перемешивать ли массив. По умолчанию 1
* @return array Массив со значениями
* */
function shuffle_blocks($const_name, $lang="ru", $tmp_str = "", $shuffle = 1) {
$array = array();
$infoSQL = "SELECT * FROM info_block WHERE const_name LIKE '{$const_name}' and lang = '{$lang}' and flag_delete = '0'";
$info_qRS = mysql_query($infoSQL);
if( mysql_num_rows($info_qRS) ) {
while($info_row = mysql_fetch_object($info_qRS)) {
$array[] = $info_row;
}
} else {
$array[] = $tmp_str;
}
if( $shuffle == 1 ) shuffle($array);
return $array;
}
?>
//Откомпилировать в Zend
require_once($_SERVER["DOCUMENT_ROOT"]."/_symp/_function/blowfish_class.php");
function code_password($password) {
while (strlen($password) < 12) {
$password .= "-";
}
$key = md5("KapExMi7tsN721har");
$res = base64_encode(encrypt($password, $key));
return $res;
}
function encode_password($password) {
$key = md5("KapExMi7tsN721har");
$res = decrypt(base64_decode($password), $key);;
$res = trim(str_replace("-", " ", $res));
return $res;
}
function encrypt($data, $secret) {
$cipher = new blowfish;
$encrypt = '';
for ($i = 0; $i < strlen($data); $i+=8) {
$block = substr($data, $i, 8);
if (strlen($block) < 8) {
$block = full_str_pad($block, 8, "", 1);
}
$encrypt .= $cipher->encryptBlock($block, $secret);
}
return $encrypt;
}
function decrypt($data, $secret) {
$cipher = new blowfish;
$decrypt = '';
for ($i = 0; $i < strlen($data); $i+=8) {
$decrypt .= $cipher->decryptBlock(substr($data, $i, 8), $secret);
}
return trim($decrypt);
}
function full_str_pad($input, $pad_length, $pad_string = '', $pad_type = 0) {
$str = '';
$length = $pad_length - strlen($input);
if ($length > 0) { // str_repeat doesn't like negatives
if ($pad_type == STR_PAD_RIGHT) { // STR_PAD_RIGHT == 1
$str = $input.str_repeat($pad_string, $length);
} elseif ($pad_type == STR_PAD_BOTH) { // STR_PAD_BOTH == 2
$str = str_repeat($pad_string, floor($length/2));
$str .= $input;
$str .= str_repeat($pad_string, ceil($length/2));
} else { // defaults to STR_PAD_LEFT == 0
$str = str_repeat($pad_string, $length).$input;
}
} else { // if $length is negative or zero we don't need to do anything
$str = $input;
}
return $str;
}
?>
function rubricator_is_access($rubricator_id) {
$SQL = "select flag_access from rubricator where rubricator_id='".intval($rubricator_id)."'";
$qRS = mysql_query($SQL) or die('
Error:'.$SQL.'
'.mysql_error());
if (mysql_num_rows($qRS)) {
$row = mysql_fetch_object($qRS);
return $row->flag_access;
} else {
return 0;
}
}
function rubricator_is_user_access($rubricator_id) {
$SQL = "select flag_user_access from rubricator where rubricator_id='".intval($rubricator_id)."'";
$qRS = mysql_query($SQL) or die('
Error:'.$SQL.'
'.mysql_error());
if (mysql_num_rows($qRS)) {
$row = mysql_fetch_object($qRS);
return $row->flag_user_access;
} else {
return 0;
}
}
?>
/*
remotetypograf.php
PHP-implementation of ArtLebedevStudio.RemoteTypograf class (web-service client)
Copyright (c) Art. Lebedev Studio | http://www.artlebedev.ru/
Typograf homepage: http://typograf.artlebedev.ru/
Web-service address: http://typograf.artlebedev.ru/webservices/typograf.asmx
WSDL-description: http://typograf.artlebedev.ru/webservices/typograf.asmx?WSDL
Default charset: UTF-8
Version: 1.0 (August 30, 2005)
Author: Andrew Shitov (ash@design.ru)
Example:
include "remotetypograf.php";
$remoteTypograf = new RemoteTypograf();
// $remoteTypograf = new RemoteTypograf ('Windows-1251');
print $remoteTypograf->processText ('"Вы все еще кое-как верстаете в "Ворде"? - Тогда мы идем к вам!"');
*/
class RemoteTypograf
{
var $_entityType = 4;
var $_useBr = 1;
var $_useP = 1;
var $_maxNobr = 3;
var $_encoding = 'UTF-8';
function RemoteTypograf ($encoding)
{
if ($encoding) $this->_encoding = $encoding;
}
function htmlEntities()
{
$this->_entityType = 1;
}
function xmlEntities()
{
$this->_entityType = 2;
}
function mixedEntities()
{
$this->_entityType = 4;
}
function noEntities()
{
$this->_entityType = 3;
}
function br ($value)
{
$this->_useBr = $value ? 1 : 0;
}
function p ($value)
{
$this->_useP = $value ? 1 : 0;
}
function nobr ($value)
{
$this->_maxNobr = $value ? $value : 0;
}
function processText ($text)
{
$original_text = $text;
$text = str_replace ('&', '&', $text);
$text = str_replace ('<', '<', $text);
$text = str_replace ('>', '>', $text);
$SOAPBody = '_encoding . '"?>
' . $text . '
' . $this->_entityType . '
' . $this->_useBr . '
' . $this->_useP . '
' . $this->_maxNobr . '
';
$host = 'typograf.artlebedev.ru';
$SOAPRequest = 'POST /webservices/typograf.asmx HTTP/1.1
Host: typograf.artlebedev.ru
Content-Type: text/xml
Content-Length: ' . strlen ($SOAPBody). '
SOAPAction: "http://typograf.artlebedev.ru/webservices/ProcessText"
'.
$SOAPBody;
$remoteTypograf = @fsockopen ($host, 80, $errno, $errstr, 30);
if (!$remoteTypograf) {
echo "Типограф: $errstr ($errno)"."
\n";
return $original_text;
} else {
fwrite ($remoteTypograf, $SOAPRequest);
$typografResponse = '';
while (!feof ($remoteTypograf))
{
$typografResponse .= fread ($remoteTypograf, 8192);
}
fclose ($remoteTypograf);
$startsAt = strpos ($typografResponse, '') + 19;
$endsAt = strpos ($typografResponse, '');
$typografResponse = substr ($typografResponse, $startsAt, $endsAt - $startsAt - 1);
$typografResponse = str_replace ('&', '&', $typografResponse);
$typografResponse = str_replace ('<', '<', $typografResponse);
$typografResponse = str_replace ('>', '>', $typografResponse);
return $typografResponse;
}
}
}
?>
function pack_doc($in_page, $level_pack = 3) {
if (headers_sent() || connection_aborted()){
return $in_page;
}
if ($compress_page = gzencode($in_page, $level_pack)) {
header("Content-Encoding: gzip");
$out_page = $compress_page;
return $out_page;
} else {
return $in_page;
}
}
?>
/*$dbHost = 'localhost';
$dbUser = 'root';
$dbPass = '';
$dbName = 'pricer';
$charset = 'utf8';
mysql_connect($dbHost, $dbUser, $dbPass);
mysql_select_db($dbName);
mysql_query("set names '".$charset."'");*/
?>
define("LOD_QUERIES","alod__queries");
define("LOD_QUERIES_IPS","alod__queries_ips");
define("LOD_COMPANYS","alod__companies");
define("LOD_GOODS","alod__goods");
define("LOD_CATALOG","alod__catalog");
define("LOD_CITY","alod__citys");
// general functions
function declOfNum($number, $titles)
{
$cases = array (2, 0, 1, 1, 1, 2);
return $number." ".$titles[ ($number%100>4 && $number%100<20)? 2 : $cases[min($number%10, 5)] ];
}
function getCatalogs($kws) {
if (count($kws)>0) {
$sql = "SELECT id FROM ".LOD_CATALOG." WHERE name IN (";
for ($i=0; $iid;
}
return $cats;
}
}
return false;
}
function getIp() {
$ip=0;
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { //check ip from share internet
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from proxy
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip=$_SERVER['REMOTE_ADDR'];
}
return ip2long($ip);
}
function saveQuery($city, $cats, $q, $nq, $res) {
$fq = "'".addslashes($q)."'";
$fnq = "'".addslashes($nq)."'";
$catsStr = "'".implode($cats,',')."'";
$sql = 'SELECT query FROM '.LOD_QUERIES.' WHERE cityId = '.$city.' AND cats = '.$catsStr.' AND query = '.$fq;
$msql = mq($sql);
if (mnr($msql)) {
$sql = 'UPDATE '.LOD_QUERIES.' SET nquery = '.$fnq.', qres = '.$res.', qcnt = qcnt+1 WHERE cityId = '.$city.' AND cats = '.$catsStr.' AND query = '.$fq;
mq($sql);
} else {
$sql = 'INSERT INTO '.LOD_QUERIES.' (cityId, cats, query, nquery, qres) VALUES ('.$city.', '.$catsStr.', '.$fq.', '.$fnq.', '.$res.')';
mq($sql);
}
$sql = 'INSERT INTO '.LOD_QUERIES_IPS.' (ip, cityId, cats, query, nquery, qres) VALUES ('.getIp().','.$city.', '.$catsStr.', '.$fq.', '.$fnq.', '.$res.')';
mq($sql);
}
function getResult($id, $q, $sx, $i) {
$sql = "SELECT ".LOD_COMPANYS.".name as comp, ".LOD_COMPANYS.".mcu, ".LOD_GOODS.".name, ".LOD_GOODS.".price, ".LOD_GOODS.".priceOpt, ".LOD_CITY.".name as city_name FROM ".LOD_CITY.", ".LOD_GOODS." left join ".LOD_COMPANYS." on ".LOD_COMPANYS.".id = ".LOD_GOODS.".companyId WHERE ".LOD_GOODS.".id = ".$id." and ".LOD_COMPANYS.".city = ".LOD_CITY.".id";
$obj = mfo(mq($sql));
$txt = $obj->name;
$ex = $sx->BuildExcerpts(array($txt), $i, $q, array());
$ex[0] = $ex[0];
$ex[1] = $obj->comp;
$ex[2] = $obj->price;
$ex[3] = $obj->priceOpt;
$ex[4] = $obj->mcu;
$ex[5] = $obj->city_name;
return $ex;
}
function getResults($ids, $q, $sx, $index) {
$inq = "(";
for ($i=0; $iid] = $obj;
// $txts[] = $obj->name;
$txts[] = $obj->name;
}
$exts = $sx->BuildExcerpts($txts, $index, $q, array());
$i = 0;
foreach ($objs as $obj) {
// $obj->name = $exts[$i++];
$obj->name = $exts[$i++];
}
return $objs;
}
function mnr($mysql_result) {
if ($mysql_result) return mysql_num_rows($mysql_result);
else return 0;
}
function mq($sql) {
return mysql_query($sql);
}
function mfo($mysql_result) {
if ($mysql_result) {
return mysql_fetch_object($mysql_result);
}
}
function mf($mysql_result) {
return mysql_fetch_array($mysql_result);
}
function vd($vr) { // Выдает свойства объекта
echo '';
var_dump($vr);
echo '
';
}
function gvd($vr) { // Выдает свойства объекта
ob_start();
echo '';
var_dump($vr);
echo '
';
$retVal .= ob_get_contents();
ob_end_clean();
return $retVal;
}
function gv($var, $htmlspecicalchars = false) {
$var = $_GET[$var] ? $_GET[$var] : ($_POST[$var] ? $_POST[$var] : NULL);
if ($htmlspecicalchars)
$var = htmlspecialchars($var);
return $var;
}
function gen_sid() {
srand((double) microtime( ) * 1000000);
return substr(uniqid(rand( )).uniqid(rand( )), 0, 36);
}
function ads($data) { // Ставит у объектов, массивов или просто строк слешу перед апострофами
if (is_array($data) || is_object($data)) {
foreach($data as $k=>$v) {
$result[$k] = addslashes($v);
}
}
else {
$result = addslashes($data);
}
return $result;
}
function daysBetween($date1, $date2) { // Показывает количество дней прошедших по этим датам
$result = false;
if ($date1 && $date2) {
$d1 = explode("-", $date1);
$d2 = explode("-", $date2);
$year1 = $d1[0];
$month1 = $d1[1];
$day1 = $d1[2];
$year2 = $d2[0];
$month2 = $d2[1];
$day2 = $d2[2];
$deadline1 = mktime(0, 0, 0, $month1, $day1, $year1, 0);
$deadline2 = mktime(0, 0, 0, $month2, $day2, $year2, 0);
$result = round( ($deadline2 - $deadline1) / (60 * 60 * 24) );
}
return $result;
}
function hoursBetween($date1, $date2) { // Показывает количество часов прошедших по этим датам
$result = false;
if ($date1 && $date2) {
$d1 = explode("-", $date1);
$d2 = explode("-", $date2);
$h1 = explode(" ", $d1[2]);
$h2 = explode(" ", $d2[2]);
$d1[2] = $h1[0];
$d2[2] = $h2[0];
$h1 = explode(":", $h1[1]);
$h2 = explode(":", $h2[1]);
$year1 = $d1[0];
$month1 = $d1[1];
$day1 = $d1[2];
$hour1 = $h1[0];
$min1 = $h1[1];
$sec1 = $h1[2];
$year2 = $d2[0];
$month2 = $d2[1];
$day2 = $d2[2];
$hour2 = $h2[0];
$min2 = $h2[1];
$sec2 = $h2[2];
$deadline1 = mktime($hour1, $min1, $sec1, $month1, $day1, $year1);
$deadline2 = mktime($hour2, $min2, $sec2, $month2, $day2, $year2);
$result = round(($deadline2 - $deadline1) / (60 * 60));
}
return $result;
}
function check_email($email) { // Проверка email адреса
if (eregi('^([a-z0-9_]|\\-|\\.)+'.'@'.'(([a-z0-9_]|\\-)+\\.)+'.'[a-z0-9]{2,4}$', $email)) {
return true;
}
else {
return false;
}
}
function check_url($url) { // Проверка url
if (eregi('^(([a-z0-9_]|\\-)+\\.)+'.'[a-z0-9]{2,4}$', $url)) {
return true;
}
else {
return false;
}
}
function check_broser($braus) { // Выдает тип браузера
if (eregi("Opera", $braus))
{$broser = "Opera";}
else
if (eregi("MSIE", $braus))
{$broser = "Explorer";}
else
if (eregi("Mozilla", $braus))
$broser = "Netscape";
if($broser == '')
$broser = 'Robot';
return $broser;
}
?>
Error:SELECT * FROM rubricator AS r WHERE r.hide=0 AND r.rubricator_parent_id= order by priority
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'order by priority' at line 1