LINE: {$line}
MESS: {$message}"; SendMail(_DEBUG_EMAIL, "error on site:". getenv("HTTP_HOST"), $body); } } include_once(_JANEAIR_ROOT."/core/done.php"); } /** * Enter description here... * * @param string $file * @param int $line */ function ShowCode($file, $line, $end = 3) { $f = file($file); $loop = true; $i = 0; $start = $line - $end ; while ($loop) { $f[$start] = htmlspecialchars($f[$start]); $f[$start] = str_replace("\t", "    ", $f[$start]); if( $start != ($line-1) ) { $return .= "
". ($start+1) ." ". $f[$start] ."
"; } else { $return .= "
". ($start+1) ." ". $f[$start] ."
"; } $start++; if( $start > ($line + $end) ) { $loop = false; } } return $return; } /** * Inform users that he requested non-existen controller * * @param null */ function unexists_controller() { if( _DEBUG == "true" ) { error_messages::Show_Error(__FILE__,__LINE__,"Controller {$_GET['controller']} does not exists"); } else { header("Location: /"); die(); } } function unexists_sub_controller() { if( defined("_DEBUG") ) { die("Controller {$_GET['controller']}/{$_GET['action']} does not exists"); } else { header("Location: /"); die(); } } function UnexistenDomain($host) { global $template; $arr['domain'] = str_replace("www.","","".$_SERVER['SERVER_NAME'].""); echo $template -> Assign("common", "janeair", $arr); die(); } function suspended() { global $template; $arr['domain'] = str_replace("www.","","".$_SERVER['SERVER_NAME'].""); echo $template -> Assign("common", "suspended", $arr); die(); } function forbiden() { echo "Forbiden: {$_SERVER['REQUEST_URI']}"; die(); } } function MD($f, $l) { error_messages::Show_Error($f, $l, sql::err()); } function MDC($l) { echo "\n---------------------ERROR--------------------\nLINE:{$l}\nMESS:".mysql_error()."\n"; die(); } ?> $link)); } /** * Create form element "; foreach ($arr as $var_name => $var_value) { $result .= ""; } $result .= ""; return $result; } function select2($arr, $name, $default=null, $js = null) { if( !is_array($arr) ) { return "Nothing to select"; } return $arr[$default]; } /** * Create form element * * @param sql $sql * @param field1 $f1 * @param field2 $f2 * @param name $name * @param default_value $default */ function FastSelect($sql, $f1, $f2, $name, $default = null, $js=null) { $r = sql::query($sql) or MD(__FILE__,__LINE__); $arr = array(); if( defined("_SELCT_FIRST_NULL") ) { $arr['0'] = _SELCT_FIRST_NULL; } if( defined("_SECOND_NULL") ) { $arr['0'] = _SECOND_NULL; } while ($f = sql::fetch($r)) { $arr[$f[$f1]] = $f[$f2]; } if( count($arr) == 0 ) { define("_SELECT_NULL_".$name, "TRUE"); } return HTMLForms::select($arr, $name, $default, $js); } /** * Create form checkbox * * @param sql $sql * @param field1 $f1 * @param field2 $f2 * @param name $name * @param default_value $default */ function FastCheckbox($sql, $f1, $f2, $name, $default = null, $js=null, $nl = "
") { $r = sql::query($sql) or MD(__FILE__,__LINE__); $arr = array(); while ($f = sql::fetch($r)) { $arr[$f[$f1]] = $f[$f2]; } return HTMLForms::checkbox($arr, $name, $default, $nl); } /** * Create form element * * @param array $arr * @param string $name * @param string $default */ function checkbox($arr, $name, $default=null, $del = "
") { if( !is_array($arr) ) { return "Nothing to select"; } foreach ($arr as $var_name => $var_value) { if( is_array($default ) ) { if( in_array($var_name, $default) ) { $sel = true; } else { $sel = false; } } else { $sel = false; } $result .= "".$del; } return $result; } /** * Create form element * * @param sql $sql * @param field1 $f1 * @param field2 $f2 * @param name $name * @param default_value $default */ function FastRadio($sql, $f1, $f2, $name, $default = null, $js=null, $nl = "
") { $r = sql::query($sql) or MD(__FILE__,__LINE__); $arr = array(); while ($f = sql::fetch($r)) { $arr[$f[$f1]] = $f[$f2]; } return HTMLForms::radio($arr, $name, $default, $nl); } /** * Create form element * * @param array $arr * @param string $name * @param string $default */ function radio($arr, $name, $default=null, $del = "
") { if( !is_array($arr) ) { return "Nothing to select"; } $i = 0; $pre = mt_rand(100,100000); foreach ($arr as $var_name => $var_value) { $i++; $result .= "".$del; } return $result; } /** * Enter description here... * * @param int $asid * @return HTML code with flv player */ function getPlayer($uid, $asid) { $arr = array( "uid" => $uid, "asid" => $asid ); $html = template::Assign("common", "player", $arr); return $html; } } ?> $var_value) { if($var_value == $_SESSION['group']) { return true; } } } } } $sessions = new sessions(); ?>1"; } else { for( $i=0;$i<$count;$i++ ) { if( $_GET['start'] == $i*$limit ) { $return .= "".($i+1)." "; } else { //z/openspec-(.*)/(.*).html $return .= "".($i+1)." "; } } } } else { $start2 = round($_GET[$var_name]/5); $start2 = round($_GET[$var_name]/$limit) - 1; if( ($start2 - 10) < 0 ) { $s = 0; $end = 15; $start_sym = "... "; $end_sym = "... "; } else { $s = $start2 - 10; $end = $s + 15; $start_sym = "... "; $end_sym = "... "; if( $end > $count ) { $end = $count; $end_sym = ""; } } $return .= "Начало "; $return .= $start_sym; for( $i = $s; $i<$end;$i++ ) { if( $_GET['start'] == $i*$limit ) { $return .= "".($i+1)." "; } else { //a/(.*)/b/(.*).html $return .= "".($i+1)." "; } } $return .= $end_sym; $return .= "Конец "; } if( $return == "" ) { $return = "1"; } $lim = " limit ". intval($_GET[$var_name]).", ".$limit; $re = array( 'pages' => $return, 'lim' => $lim ); return $re; } function PrettySize($file_size) { if($file_size >= 1073741824) {$file_size = round($file_size / 1073741824 * 100) / 100 . " Gb";} elseif($file_size >= 1048576) {$file_size = round($file_size / 1048576 * 100) / 100 . " Mb";} elseif($file_size >= 1024) {$file_size = round($file_size / 1024 * 100) / 100 . " Kb";} else{$file_size = $file_size . " b";} return $file_size; } function BB($source) { $source = str_replace("\n", "
", $source); $source = preg_replace( "#\[code\](.+?)\[/code\]#is", "
\\1
", $source ); $source = preg_replace( "#\[b\](.+?)\[/b\]#is", "\\1", $source); $source = preg_Replace( "#\[i\](.+?)\[/i\]#is", "\\1", $source); $source = preg_replace( "#\[u\](.+?)\[/u\]#is", "\\1", $source); $source = preg_Replace( "#\[left\](.+?)\[/left\]#is", "
\\1
", $source); $source = preg_Replace( "#\[center\](.+?)\[/center\]#is", "
\\1
", $source); $source = preg_Replace( "#\[right\](.+?)\[/right\]#is", "
\\1
", $source); $source = preg_replace( "#\[url=(.+?)\](.+?)\[/url\]#is", "\\2", $source); $source = preg_Replace( "#\[img](.+?)\[/img\]#is", "", $source); $source = preg_Replace( "#\[color=(.+?)\](.+?)\[/color\]#is", "\\2", $source); $source = preg_Replace( "#\[font=(.+?)\](.+?)\[/font\]#is", "\\2", $source); $source = str_replace("\t", "    ", $source); //$source = preg_replace( "#\[video\](.+?)\[/video\]/e", "strings::video('\\1')", $source); return $source; } function forbiden() { if( defined("_DEBUG") ) { echo "
Check ./cache/access.php"; } else { error_messages::Forbiden(); } include(_JANEAIR_ROOT."/core/done.php"); } function video($s) { return $s; } function html($s) { $s = str_replace("\n", "
", $s); $s = str_replace("\t", "   ", $s); return $s; } function suggest($s) { $arr = explode(",", $s); $count = 0; foreach ($arr as $var_name => $var_value) { if( intval($var_value) > 0 ) { $otc += intval($var_value); $count++; } } if( $count > 0 ) { $otc = round($otc/$count); return $otc; } else { return ""; } } function WeekTime($curent) { $day_seconds = 60*60*24; $dW = date("D", $curent); switch ($dW) { case "Sun": $d = 7; break; case "Mon": $d = 1; break; case "Tue": $d = 2; break; case "Wed": $d = 3; break; case "Thu": $d = 4; break; case "Fri": $d = 5; break; case "Sat": $d = 6; break; } $start = $curent; if( $d > 1 ) { $start -= ($d-1)*$day_seconds; } $start = $start - (date("H", $start)*60*60); $start = $start - (date("i", $start)*60); $start = $start - (date("s", $start)); $end = $curent; if( $d < 6 ) { $end += (7-$d)*$day_seconds; } $end += (((24-date("H", $end))+date("H", $end)) * 60*60); $dim = (date("H") * 60*60)+(date("i", $end)*60)+date("s", $end)+1; $end -= $dim; return array("s" => $start, "e" => $end); } function mkPasswd($len = 6) { return base_convert(mt_rand(999999999,999999999999), 10, 32); } /** * Get teacher info block * * @param schools id $uid * @param teachers id $id * @param teachers name $name */ function tInfo($uid, $id, $name) { if( file_exists("../public/uploads/teachers/{$uid}/{$id}.jpg") ) { $return = "
{$name}
"; } else { $return = "
{$name}
"; } return $return; } function MkTime($t = 0) { $date = explode(" ", $t); $date_date = explode("/", $date[0]); $date_time = explode(":", $date[1]); $time = mktime($date_time[0], $date_time[1], $date_time[2], $date_date[1], $date_date[0], $date_date[2]); return $time; } function CreateMainMenu($text, $route, $replace = false) { if( $replace ) {$text = strip_tags($text); } $text = preg_replace("/(\[(.*?)\])/e", "strings::make_links('\\1', '{$route}')", $text); return $text; } function make_links($s, $route) { $s = str_replace("[", "", $s); $s = str_replace("]", "", $s); $link = strings::decode2latin($s); $link = strip_tags($link); return "$s"; } /** * Setting up the flash message * * @param unknown_type $message */ function SetFlash($message) { $_SESSION['_flash_message'] .= $message; } function month2($m) { switch ($m) { case "1": $m=l("Января"); break; case "2": $m=l("Февраля"); break; case "3": $m=l("Марта"); break; case "4": $m=l("Апреля"); break; case "5": $m=l("Мая"); break; case "6": $m=l("Июня"); break; case "7": $m=l("Июля"); break; case "8": $m=l("Августа"); break; case "9": $m=l("Сентября"); break; case "10": $m=l("Октября"); break; case "11": $m=l("Ноября"); break; case "12": $m=l("Декабря"); break; } return $m; } function month($m) { switch ($m) { case "1": $m=l("Январь"); break; case "2": $m=l("Февраль"); break; case "3": $m=l("Март"); break; case "4": $m=l("Апрель"); break; case "5": $m=l("Май"); break; case "6": $m=l("Июнь"); break; case "7": $m=l("Июль"); break; case "8": $m=l("Август"); break; case "9": $m=l("Сентябрь"); break; case "10": $m=l("Октябрь"); break; case "11": $m=l("Ноябрь"); break; case "12": $m=l("Декабрь"); break; } return $m; } function weekday($w) { switch ($w) { case "1": $w = l("Пн"); break; case "2": $w = l("Вт"); break; case "3": $w = l("Ср"); break; case "4": $w = l("Чт"); break; case "5": $w = l("Пт"); break; case "6": $w = l("Сб"); break; case "0": $w = l("Вс"); break; } return $w; } function weekday2($w) { switch ($w) { case "1": $w = l("Понедельник"); break; case "2": $w = l("Вторник"); break; case "3": $w = l("Среда"); break; case "4": $w = l("Четверг"); break; case "5": $w = l("Пятница"); break; case "6": $w = l("Суббота"); break; case "7": $w = l("Воскресение"); break; } return $w; } function weekday3($w) { switch ($w) { case "1": $w = l("Понедельник"); break; case "2": $w = l("Вторник"); break; case "3": $w = l("Среда"); break; case "4": $w = l("Четверг"); break; case "5": $w = l("Пятница"); break; case "6": $w = l("Суббота"); break; case "0": $w = l("Воскресение"); break; } return $w; } function GetFlash() { if( $_SESSION['_flash_message'] == null ) { return ; } $arr = array("message" => $_SESSION['_flash_message']); $html = template::Assign("common", "std_message", $arr); $_SESSION['_flash_message'] = null; return $html; } function decode2latin($s,$slashes=true) { $s = str_replace("\n", "", $s); $s = str_replace("\r", "", $s); $s = str_replace("а", "a", $s); $s = str_replace("б", "b", $s); $s = str_replace("в", "v", $s); $s = str_replace("г", "g", $s); $s = str_replace("д", "d", $s); $s = str_replace("е", "e", $s); $s = str_replace("ё", "e", $s); $s = str_replace("ж", "zj", $s); $s = str_replace("з", "z", $s); $s = str_replace("и", "i", $s); $s = str_replace("й", "j", $s); $s = str_replace("к", "k", $s); $s = str_replace("л", "l", $s); $s = str_replace("м", "m", $s); $s = str_replace("н", "n", $s); $s = str_replace("о", "o", $s); $s = str_replace("п", "p", $s); $s = str_replace("р", "r", $s); $s = str_replace("с", "s", $s); $s = str_replace("т", "t", $s); $s = str_replace("у", "y", $s); $s = str_replace("ф", "f", $s); $s = str_replace("х", "x", $s); $s = str_replace("ц", "c", $s); $s = str_replace("ш", "sh", $s); $s = str_replace("щ", "sh", $s); $s = str_replace("ъ", "", $s); $s = str_replace("ы", "i", $s); $s = str_replace("ь", "", $s); $s = str_replace("э", "e", $s); $s = str_replace("ю", "u", $s); $s = str_replace("я", "a", $s); $s = str_replace("№", "", $s); $s = str_replace("«", "", $s); $s = str_replace("»", "", $s); $s = str_replace("/", "", $s); $s = str_replace("А", "a", $s); $s = str_replace("Б", "b", $s); $s = str_replace("В", "v", $s); $s = str_replace("Г", "g", $s); $s = str_replace("Д", "d", $s); $s = str_replace("Е", "e", $s); $s = str_replace("Ё", "e", $s); $s = str_replace("Ж", "zj", $s); $s = str_replace("З", "z", $s); $s = str_replace("И", "i", $s); $s = str_replace("Й", "j", $s); $s = str_replace("К", "k", $s); $s = str_replace("Л", "l", $s); $s = str_replace("М", "m", $s); $s = str_replace("Н", "n", $s); $s = str_replace("О", "o", $s); $s = str_replace("П", "p", $s); $s = str_replace("Р", "r", $s); $s = str_replace("С", "s", $s); $s = str_replace("Т", "t", $s); $s = str_replace("У", "y", $s); $s = str_replace("Ф", "f", $s); $s = str_replace("Х", "x", $s); $s = str_replace("Ц", "c", $s); $s = str_replace("Ш", "sh", $s); $s = str_replace("Щ", "sh", $s); $s = str_replace("Ъ", "", $s); $s = str_replace("Ы", "i", $s); $s = str_replace("Ь", "", $s); $s = str_replace("Э", "e", $s); $s = str_replace("Ю", "u", $s); $s = str_replace("Я", "a", $s); $s = str_replace("ч", "ch", $s); $s = str_replace("Ч", "ch", $s); $s = str_replace("Қ", "k", $s); $s = str_replace("қ", "k", $s); $s = str_replace("Ғ", "g", $s); $s = str_replace("ғ", "g", $s); $s = str_replace("Ә", "a", $s); $s = str_replace("ә", "a", $s); $s = str_replace("Ң", "n", $s); $s = str_replace("ң", "n", $s); $s = str_replace("Ө", "o", $s); $s = str_replace("ө", "o", $s); $s = str_replace("Ұ", "y", $s); $s = str_replace("ұ", "y", $s); $s = str_replace("Һ", "h", $s); $s = str_replace("һ", "h", $s); $s = str_replace("І", "i", $s); $s = str_replace("і", "i", $s); $s = str_replace("ү", "y", $s); $s = str_replace("Ү", "y", $s); $s = preg_replace('/\s\s+/', ' ', $s); $s = str_replace(" ", "_", $s); if( $slashes ) { $s = str_replace("/", "_", $s); } $s = str_replace("\\", "_", $s); $s = str_replace("'", "_", $s); $s = str_Replace('"', "", $s); $s = str_replace("!", "_", $s); $s = str_replace("?", "_", $s); $s = str_replace("#", "_", $s); $s = str_replace("@", "_", $s); $s = str_replace("$", "_", $s); $s = str_replace("%", "_", $s); $s = str_replace("^", "_", $s); $s = str_replace("&", "_", $s); $s = str_replace("*", "_", $s); $s = str_replace("(", "_", $s); $s = str_replace(")", "_", $s); $s = str_replace("-", "_", $s); $s = str_replace(",", "_", $s); # $s = str_replace("-", "_", $s); return $s; } function decode2rus($st) { $sL1 = "abvgdeeziyklmnoprstufh'iei"; $sL2 = "Абвгдеёзийклмнопрстуфхъыэ_"; for($i=0;$i $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; } } } ?> _params['title'] = ""; $this -> _params['html'] = ""; $this -> _params['template'] = ""; $this -> _params['description'] = ""; $this -> _params['keywords'] = ""; } function set_param($name, $value) { global $template; $template -> _params[$name] = $value; } function add($name, $value) { global $template; $template -> _params[$name] .= _TITLE_DELEMITER.$value; } /** * Assign array with template * * @param string $controller * @param string $action * @param array $fields */ function Assign($controller, $action, $fields = array()) { global $template; $fileName_orig = "./views/{$controller}/{$action}.html"; if(_BEHAVIOUR == "CMS") { $fileName_cms = _JANEAIR_ROOT_CMS."views/{$controller}/{$action}.html"; } if( !file_exists($fileName_orig) and !file_exists($fileName_cms)) { error_messages::Show_Error(__FILE__,__LINE__, "View {$fileName_orig} does not exists!"); } if( !file_exists($fileName_orig) ) { $fileName = $fileName_cms; } else { $fileName = $fileName_orig; } if( $template -> loaded[$controller."-".$action] == null ) { $fHandle = fopen($fileName, "r"); $fContent = @fread($fHandle, filesize($fileName)); fclose($fHandle); $template -> loaded[$controller."-".$action] = $fContent; $fContent = preg_replace("/{inc}(.*)-(.*){endinc}/e", "template::Assign('\\1', '\\2')", $fContent); } else { $fContent = $template -> loaded[$controller."-".$action]; } $fContent = preg_replace("/:val:(.*):/e", "template::validator('\\1')", $fContent); $fContent = preg_replace("/{php}(.*){endphp}/e", "template::php_eval('\\1')", $fContent); $fContent = preg_replace("/{if:(.*):(.*):}(.*){endif}/e", "template::check_permissions('\\1','\\2', '\\3')", $fContent); $fn = "_form_".mt_rand(1,10000); $template -> js = "\n"; if( is_array($fields) ) { foreach ($fields as $var_name => $var_value) { if( is_array($fields[$var_name]) ) { continue; } $var_name = str_replace("[", "", $var_name); $var_name = str_replace("]", "", $var_name); $pattern = "#{@".$var_name."}#is"; $fContent = preg_replace($pattern, $var_value, $fContent); } } $fContent = preg_replace("#{@(.)*?}#is", "", $fContent); $fContent = preg_replace("#:form_validator_js:#is", $template->js, $fContent); $fContent = preg_replace("#:form_validator_server:#is", $template->server_validator, $fContent); $fContent = preg_replace("/{%(.*)%}/e", "template::language('\\1')", $fContent); $fContent = str_replace('\"', '"', $fContent); if( $_GET['tiny_MCE'] == "OFF" ) { $fContent = str_replace(":tiny_MCE:", '', $fContent); } else { $fContent = str_replace(":tiny_MCE:", ' ', $fContent); } return $fContent; } function validator($form) { global $vf; $hk = ""; if( key_exists($form, $vf) ) { foreach ($vf[$form] as $n => $key) { if( $key[0] == "not_empty" ) { $tmp = explode("-", $key[2]); $str1 .= " if( $('input[name={$n}]').attr('value') == '' ) { SetError('Заполните поле \"{$key[1]}\"'); return false; } "; $str1 .= " var fk_{$n} = $('input[name={$n}]').attr('value'); if( fk_{$n}.length < $tmp[0] ) { SetError('Поле {$key[1]} должно быть длиннее {$tmp[0]} символов'); return false; } if( fk_{$n}.length > $tmp[1] ) { SetError('Поле {$key[1]} должно быть короче {$tmp[1]} символов'); return false; } "; } if( $key[0] == "not_empty2" ) { $tmp = explode("-", $key[2]); $str1 .= " if( $('textarea[name={$n}]').attr('value') == '' ) { SetError('Заполните поле \"{$key[1]}\"'); return false; } "; $str1 .= " var fk_{$n} = $('textarea[name={$n}]').attr('value'); if( fk_{$n}.length < $tmp[0] ) { SetError('Поле {$key[1]} должно быть длиннее {$tmp[0]} символов'); return false; } if( fk_{$n}.length > $tmp[1] ) { SetError('Поле {$key[1]} должно быть короче {$tmp[1]} символов'); return false; } "; } if( $key[0] == "email" ) { $str1 .= "var fk_{$n} = $('input[name={$n}]').attr('value'); if( !is_email(fk_{$n})) { SetError('Поле {$key[1]} заполнено неверно!'); return false; } "; } } } $str = "{$hk}"; return $str; } function simple_editor($id) { return template::Assign("common", "simple_editor", array("id" => $id)); } function language($item) { global $language; if( $language[$item] == null ) { return $item; } else { return $language[$item]; } } function validate_date($value, $type) { global $template; $template -> _last_ID = "_elemID_". mt_rand(1,100000); $template -> tmp_js .= "\tif(!is_date(document.getElementById(\"{$this->_last_ID}\").value)){msg +='Правильность даты
\\n';ch_color(document.getElementById(\"{$this->_last_ID}\"));err++;}\n"; $template -> server_validator .= "\n"; return "id=\"{$this->_last_ID}\" onkeydown=\"__clean_up(this)\""; } function check_permissions($controller, $action, $text) { //echo "{$controller} - {$action} - {$text}
"; if( validator::Access($controller, $action) ) { return $text; } } function php_eval($s) { ob_start(); $s = str_replace('\"', '"', $s); eval($s); $content = ob_get_clean(); return $content; } function validate_email($email) { global $template; $template -> _last_ID = "_elemID_". mt_rand(1,100000); $template -> tmp_js .= "\tif(!is_email(document.getElementById(\"{$template->_last_ID}\").value)){msg +='Правильность e-mail
\\n';ch_color(document.getElementById(\"{$template->_last_ID}\"));err++;}\n"; $template -> server_validator .= "\n"; return "id=\"{$template->_last_ID}\" onkeydown=\"__clean_up(this)\""; } function login($m, $n) { global $template; $template -> _last_ID = "_elemID_". mt_rand(1,100000); $template -> tmp_js .= "\tif(document.getElementById(\"{$template->_last_ID}\").value==''){msg +='{$m}
\\n';ch_color(document.getElementById(\"{$template->_last_ID}\"));err++;}\n"; $template -> server_validator .= "\n"; return "id=\"{$template->_last_ID}\" onkeydown=\"__clean_up(this)\""; } function not_empty($m, $n) { global $template; $template -> _last_ID = "_elemID_". mt_rand(1,100000); $template -> tmp_js .= "\tif(document.getElementById(\"{$template->_last_ID}\").value==''){msg +='{$m}
\\n';ch_color(document.getElementById(\"{$template->_last_ID}\"));err++;}\n"; $template -> server_validator .= "\n"; return "id=\"{$template->_last_ID}\" onkeydown=\"__clean_up(this)\""; } function capthca() { global $template; $template -> _last_ID = "_elemID_". mt_rand(1,100000); $template -> tmp_js .= "\tif(document.getElementById(\"{$template->_last_ID}\").value==''){msg +='Проверочное число
\\n';ch_color(document.getElementById(\"{$template->_last_ID}\"));err++;}\n"; $template -> server_validator .= "\n"; return "id=\"{$template->_last_ID}\" onkeydown=\"__clean_up(this)\""; } } if( JVer != 2 ) { $template = new template(); } ?> $v) { if( $v[0] == "not_empty" or $v[0] == "not_empty2") { $tmp = explode("-", $v[2]); if(empty($_POST[$n]) or strlen($_POST[$n]) < $tmp[0] or strlen($_POST[$n]) > $tmp[1]) { strings::SetFlash("• Неправильно заполненое поле \"{$v[1]}\". Длинна этого поля должна быть короче {$tmp[1]} и не превышать {$tmp[0]} символов
"); $err++; } } } } } if($err == 0) { return true; } else { return false; } } function start() { global $validator, $err; //$_POST['__redir'] = null; if( !is_array($_POST['__validate']) ) { //return true; } else { foreach ($_POST['__validate'] as $var_name => $var_value) { //print_r($_POST['__validate']);die(); foreach ($var_value as $k => $v) { switch ($k) { case "not_empty": if( !validator::is_Not_Empty($var_name) ) { $_POST['__redir'] = null; $this->flash .= "{$v}
"; $err++; } break; case "email": if( !validator::is_email($var_name) ) { $_POST['__redir'] = null; $this->flash .= l("Правильность e-mail
"); $err++; } break; case "day": case "month": case "year": case "hour": case "minute": //echo $_POST[$var_name] ." {$k} - {$v}
"; $_POST[$var_name] = intval($_POST[$var_name]); if( !validator::date_time($_POST[$var_name], $k) ) { $_POST['__redir'] = null; $this->flash .= l("Даты
"); $err++; } break; case "capthca": if( !validator::capthca() ) { $_POST['__redir'] = null; $this->flash .= l("Проверочное число
"); $err++;} break; case "login": if( !validator::login($_POST[$var_name]) ) { $_POST['__redir'] = null; $this->flash .= l("Правильность") ." {$v}
"; $err++; } break; case "password": if( !validator::is_password($v) ) {$_POST['__redir'] == null; $err++;} break; } } } } if($err > 0) { $_SESSION['_flash_message'] .= $this -> flash; } return $err > 0 ? false:true; } function redir($URL) { $_POST['__redir'] = $URL; } function isLogined() { return $_SESSION['user_id'] == null ? false:true; } function CheckPermissions() { global $access; if( !$access[$_SESSION['group']][$_GET['controller']][$_GET['action']] ) { strings::Forbiden(); } } function Access($Controller, $Action) { global $access; $session = $_SESSION['group']; if( $access[$session][$Controller][$Action] ) { return true; } } function putFlash($mess) { //global $validator; $this -> flash .= "{$mess}
"; //die( $validator -> flash ); } function is_password($s) { $passwd = explode(",",$s); $model = $_POST[$passwd[0]]; foreach ($passwd as $var_name => $var_value) { if( $_POST[$var_value] != $model ) { $this->flash.=l("Пароль и его подтвержндение не совпадают
"); return false; } } if( strlen($model) < 6 ) { $this->flash.=l("Короткий пароль!
"); return false; } return true; } function capthca() { //die( $_POST['capthca'] ." - ". $_SESSION['capthca'] ); return $_POST['capthca'] == $_SESSION['capthca'] ? true:false; } function login($value) { if( strlen($value) < 3 ) { return false; } /* $dir = "([a-z])"; if( preg_match($dir, $value) ) { echo "NOl"; return false; }*/ return true; } function date_time( $value, $type ) { $value = intval($value); //echo " -- {$value}
"; switch ( $type ) { case "day": return ($value > 0 and $value <32) ? true:false; break; case "month": return ($value > 0 and $value <13) ? true:false; break; case "year": return ($value > 1 and $value <999999) ? true:false; // :) break; case "hour": return ($value >= 0 and $value <25 ) ? true:false; break; case "minute": return ($value >= 0 and $value <60 ) ? true:false; break; } } function get_Flash() { global $validator; $flash = array("message" => $this -> flash); $html = template::Assign("common", "flash", $flash); return $html; } function is_email($e) { $email = $_POST[$e]; if( (preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email)) || (preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)) ) { $host = explode('@', $email); if(checkdnsrr($host[1].'.', 'MX') ) return true; if(checkdnsrr($host[1].'.', 'A') ) return true; if(checkdnsrr($host[1].'.', 'CNAME') ) return true; } return false; } function is_email2($email) { if( (preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email)) || (preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)) ) { $host = explode('@', $email); if(checkdnsrr($host[1].'.', 'MX') ) return true; if(checkdnsrr($host[1].'.', 'A') ) return true; if(checkdnsrr($host[1].'.', 'CNAME') ) return true; } return false; } function is_get() { return getenv("REQUEST_METHOD") == "GET" ? true : false; } function check_access() { if( !sessions::cp("{$_GET['controller']}-{$_GET['action']}") ) { error_messages::forbiden(); } } function is_Not_Empty($name) { if( empty($_POST[$name]) ) { return false; } else {return true; } } function rpb($s) { $s = str_replace("'", "", $s); $s = htmlspecialchars($s); $s = trim($s); return $s; } function replace_bad( $type = 1 ) { foreach ($_POST as $var_name => $var_value) { if( is_array($var_value) ){ continue; } $_POST[$var_name] = str_replace("'", "", $_POST[$var_name]); $_POST[$var_name] = str_replace("\'", "", $_POST[$var_name]); $_POST[$var_name] = str_replace('\"', '"', $_POST[$var_name]); $_POST[$var_name] = str_replace('\x', '', $_POST[$var_name]); $_POST[$var_name] = str_replace('\X', '', $_POST[$var_name]); $_POST[$var_name] = trim($_POST[$var_name]); if( $type == 1 ) { $_POST[$var_name] = htmlspecialchars($_POST[$var_name]); $_POST[$var_name] = strip_tags($_POST[$var_name]); } } } function ForceError() { global $err; $err++; } function isImageType($mimeType) { $array = array(1 => "image/jpg", 2 => "image/jpeg", 3 => "image/pjpeg", 4=>"image/png"); if( $key = array_search( $mimeType, $array ) == "" ) { return false; } else { return true; } } } $validator = new validator(); ?> '{$time}' and `time` < '{$time2}'"; $first_of_month = mktime(0, 0, 0, $cal_month, 7, $cal_year); $maxdays = date('t', $first_of_month)+1; // 28-31 $prev_of_month = mktime(0, 0, 0, ($cal_month-1), 7, $cal_year); $next_of_month = mktime(0, 0, 0, ($cal_month+1), 7, $cal_year); $cal_day = 1; $weekday = date('w', $first_of_month); // 0-6 $date_link['prev'] = "«    "; $date_link['next'] = "    »    "; $buffer = '
'; $buffer = str_replace($f, $r, $buffer); for ($it=1; $it<6; $it++) { $buffer .= ''; } $buffer .= ''; $buffer .= ''; $buffer .= ''; if ($weekday > 0){$buffer .= '';} //***** BEGIN GET Recent changes $pages = array(); $r_pages = sql::query($sql) or MD(__FILE__,__LINE__); $cnt = 0; while( $f_pages = sql::fetch($r_pages) ) { $d = intval(date("d", $f_pages['time'])); $pages[$d] = "YES"; $cnt++; } $cal_day = 1; while($maxdays > $cal_day) { if ($weekday == 7) { $buffer .= ''; $weekday = 0; } if( $pages[$cal_day] == "YES" ) { $link = "{$cal_day}"; } else { if( $cal_day == $cd ) { $__cal_day = "{$cal_day}"; } else { $__cal_day = $cal_day; } $link = $__cal_day; } if ($weekday == "5" or $weekday == "6"){$buffer .= '';} else {$buffer .= '';} $cal_day++; $weekday++; } if ($weekday != 7){$buffer .= '';} $returnVal = $buffer . '
'.$date_link['prev'].strings::month(intVal(date("m",$time)))." ".date("Y",$time).$date_link['next'].'
'.strings::weekday($it).''.strings::weekday(6).''.strings::weekday(0).'
 
'.$link.'
'.$link.'
 

'; if( intval($_GET['d']) == 0 ){ $cal_day = intval ( date("d") ); } else { $cal_day = intval ( $_GET['d'] ); } $time = mktime(0, 0, 0, $cal_month, $cal_day, $cal_year); $time2 = mktime(23, 59, 59, $cal_month, $cal_day, $cal_year); return $returnVal; } ?> display = 'none'; $sql = "select `cid` , `title` , `desc`, `parent`, `url` from `category` where `parent` = 0 and `show`=0 order by `ordering` asc"; } else { $this->display = 'block'; $sql = "select `cid` , `title` , `desc`, `parent`, `url` from `category` where `cid` = ".PARENT." and `show`=0 order by `ordering` asc"; } $r = sql::query($sql) or MD(__FILE__,__LINE__); while ($f = sql::fetch($r)) { $this -> i = 0; $r2 = sql::query("select Count(*) as `cnt` from `category` where `parent` = '{$f['cid']}' and `show`=0") or MD(__FILE__,__LINE__); $f2 = sql::fetch($r2); if( $f2['cnt'] > 0 ) { $link = "/catalog/index/cid-"; } else { $link = "/catalog/index/cid-"; } if( $f['url'] != "" ) { $link = "/{$f['url']}#"; } $html .= ''; $this -> i = 0; $this -> j = 0; $this -> FetchSubCategory($f['cid']); $html .= $this -> select; $this -> select = ""; $this -> i = 0; } echo $html; } function FetchSubCategory($cid) { $r2 = sql::query("select * from `category` where `parent` = '{$cid}' and `show`=0 order by `ordering` asc") or MD(__FILE__,__LINE__); if( sql::num_rows($r2) == 0 ) { return ; } while ($f2 = sql::fetch($r2)) { //$add = @str_repeat(" ", ($this->i*6)) . "   "; $margin = $this->i * 30; $sub = true; $p = $f2['parent']; $i = 0; while ($sub) { $r = sql::query("select `parent` from `category` where `cid` = '{$p}' and `show`=0") or MD(__FILE__,__LINE__); $f = sql::fetch($r); if( $f['parent'] == 0 ) { $sub = false; } else { $i++; $p = $f['parent']; } if( $i > 10 ) { break;} } $margin = ($i * 15) + 15; $r22 = sql::query("select Count(*) as `cnt` from `category` where `parent` = '{$f2['cid']}' and `show`=0") or MD(__FILE__,__LINE__); $f22 = sql::fetch($r22); if( $f22['cnt'] > 0 ) { $link = "/catalog/index/cid-"; } else { $link = "/catalog/index/cid-"; } if( $f2['url'] != "" ) { $link = "/{$f2['url']}#"; } $this -> select .= "\t\t". '' . "\n"; $r3 = sql::query("select * from `category` where `parent` = '{$f2['cid']}'") or MD(__FILE__,__LINE__); if($this->prev_parent != $f2['parent']) { //$this -> i--; } if( sql::num_rows($r3) > 0 ) { $this -> j++; $this -> i++; $this->FetchSubCategory($f2['cid']); } else { if($this->i != 0 ) { $this -> i = $this -> i - $this -> j; $this -> j = 0; } } $this->prev_parent = $f2['parent']; } } } class MenuBuilderKAZ { function CategoryList() { template::add("title", "Список кетегорий"); if( !defined("PARENT")) { $this->display = 'none'; $sql = "select * from `category` where `parent` = 0 and `show`=0 order by `ordering` asc"; } else { $this->display = 'block'; $sql = "select * from `category` where `cid` = ".PARENT." and `show`=0 order by `ordering` asc"; } $r = sql::query($sql) or MD(__FILE__,__LINE__); while ($f = sql::fetch($r)) { $this -> i = 0; $r2 = sql::query("select Count(*) as `cnt` from `category` where `parent` = '{$f['cid']}' and `show`=0") or MD(__FILE__,__LINE__); $f2 = sql::fetch($r2); if( $f2['cnt'] > 0 ) { $link = "/catalog/index/cid-"; } else { $link = "/catalog/index/cid-"; } if( $f['url'] != "" ) { $link = "/{$f['url']}#"; } $html .= ''; $this -> i = 0; $this -> j = 0; $this -> FetchSubCategory($f['cid']); $html .= $this -> select; $this -> select = ""; $this -> i = 0; } echo $html; } function FetchSubCategory($cid) { $r2 = sql::query("select * from `category` where `parent` = '{$cid}' and `show`=0 order by `ordering` asc") or MD(__FILE__,__LINE__); if( sql::num_rows($r2) == 0 ) { return ; } while ($f2 = sql::fetch($r2)) { //$add = @str_repeat(" ", ($this->i*6)) . "   "; $margin = $this->i * 30; $sub = true; $p = $f2['parent']; $i = 0; while ($sub) { $r = sql::query("select * from `category` where `cid` = '{$p}' and `show`=0") or MD(__FILE__,__LINE__); $f = sql::fetch($r); if( $f['parent'] == 0 ) { $sub = false; } else { $i++; $p = $f['parent']; } if( $i > 10 ) { break;} } $margin = ($i * 15) + 15; $r22 = sql::query("select Count(*) as `cnt` from `category` where `parent` = '{$f2['cid']}' and `show`=0") or MD(__FILE__,__LINE__); $f22 = sql::fetch($r22); if( $f22['cnt'] > 0 ) { $link = "/catalog/index/cid-"; } else { $link = "/catalog/index/cid-"; } if( $f2['url'] != "" ) { $link = "/{$f2['url']}#"; } $this -> select .= "\t\t". '' . "\n"; $r3 = sql::query("select * from `category` where `parent` = '{$f2['cid']}'") or MD(__FILE__,__LINE__); if($this->prev_parent != $f2['parent']) { //$this -> i--; } if( sql::num_rows($r3) > 0 ) { $this -> j++; $this -> i++; $this->FetchSubCategory($f2['cid']); } else { if($this->i != 0 ) { $this -> i = $this -> i - $this -> j; $this -> j = 0; } } $this->prev_parent = $f2['parent']; } } } class MenuBuilderEN { function CategoryList() { template::add("title", "Список кетегорий"); if( !defined("PARENT")) { $this->display = 'none'; $sql = "select * from `category` where `parent` = 0 and `show`=0 order by `ordering` asc"; } else { $this->display = 'block'; $sql = "select * from `category` where `cid` = ".PARENT." and `show`=0 order by `ordering` asc"; } $r = sql::query($sql) or MD(__FILE__,__LINE__); while ($f = sql::fetch($r)) { $this -> i = 0; $r2 = sql::query("select Count(*) as `cnt` from `category` where `parent` = '{$f['cid']}' and `show`=0") or MD(__FILE__,__LINE__); $f2 = sql::fetch($r2); if( $f2['cnt'] > 0 ) { $link = "/catalog/index/cid-"; } else { $link = "/catalog/index/cid-"; } if( $f['url'] != "" ) { $link = "/{$f['url']}#"; } $html .= ''; $this -> i = 0; $this -> j = 0; $this -> FetchSubCategory($f['cid']); $html .= $this -> select; $this -> select = ""; $this -> i = 0; } echo $html; } function FetchSubCategory($cid) { $r2 = sql::query("select * from `category` where `parent` = '{$cid}' and `show`=0 order by `ordering` asc") or MD(__FILE__,__LINE__); if( sql::num_rows($r2) == 0 ) { return ; } while ($f2 = sql::fetch($r2)) { //$add = @str_repeat(" ", ($this->i*6)) . "   "; $margin = $this->i * 30; $sub = true; $p = $f2['parent']; $i = 0; while ($sub) { $r = sql::query("select * from `category` where `cid` = '{$p}' and `show`=0") or MD(__FILE__,__LINE__); $f = sql::fetch($r); if( $f['parent'] == 0 ) { $sub = false; } else { $i++; $p = $f['parent']; } if( $i > 10 ) { break;} } $margin = ($i * 15) + 15; $r22 = sql::query("select Count(*) as `cnt` from `category` where `parent` = '{$f2['cid']}' and `show`=0") or MD(__FILE__,__LINE__); $f22 = sql::fetch($r22); if( $f22['cnt'] > 0 ) { $link = "/catalog/index/cid-"; } else { $link = "/catalog/index/cid-"; } if( $f2['url'] != "" ) { $link = "/{$f2['url']}#"; } $this -> select .= "\t\t". '' . "\n"; $r3 = sql::query("select * from `category` where `parent` = '{$f2['cid']}'") or MD(__FILE__,__LINE__); if($this->prev_parent != $f2['parent']) { //$this -> i--; } if( sql::num_rows($r3) > 0 ) { $this -> j++; $this -> i++; $this->FetchSubCategory($f2['cid']); } else { if($this->i != 0 ) { $this -> i = $this -> i - $this -> j; $this -> j = 0; } } $this->prev_parent = $f2['parent']; } } } 0 ) { $ret = "
    "; while($f = sql::Fetch($r)) { if( $_SESSION['lng'] == 'kz' ) { $f['title'] = $f['title_kz']; } $ret .= "
  • {$f['title']}
  • "; } $ret .= "
"; return $ret; } } items as $n => $v) { echo "
{$v['title']} {$v['description']}
".date("d.m.Y",strtotime($v['pubdate']))."
"; } } "roll.gif", ":)" => "smile.gif", ":-D" => "fun.gif", ";-)" => "blink.gif", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", ); foreach ($smilyes as $n => $v) { $s = str_replace("{$n}", "", $s); } $s = strings::BB($s); return $s; }