=mysqli_num_rows($result)) return false; if (is_string($field) && !(strpos($field,".")===false)) { $t_field=explode(".",$field); $field=-1; $t_fields=mysqli_fetch_fields($result); for ($id=0;$idtable==$t_field[0] && $t_fields[$id]->name==$t_field[1]) { $field=$id; break; } } if ($field==-1) return false; } mysqli_data_seek($result,$row); $line=mysqli_fetch_array($result); return isset($line[$field])?$line[$field]:false; } function safe_text($text){ global $con; //$text=htmlspecialchars($text); //$text=htmlentities($text, ENT_QUOTES | ENT_IGNORE, "UTF-8"); //$text=mysqli_real_escape_string($con,$text); $text=mysqli_real_escape_string($con,trim(htmlentities($text, ENT_QUOTES, 'UTF-8'))); return $text; } function msg($status,$txt) { return '{"status":'.$status.',"txt":"'.$txt.'"}'; } function gen_text2(){ return md5(uniqid(rand(), true)); } //функция возвращает IP адрес function getIP(){ if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; } function gen_text(){ return md5(uniqid(rand(), true)); } function convert_time($timestamp,$how=1) { if($how==1)return date('d-m-Y H:i', $timestamp); if($how==2)return date('d-m-Y', $timestamp); if($how==10)return date('Y-m-d H:i:s', $timestamp); if($how==3){setlocale(LC_TIME, 'ro');return date("d-F-Y", $timestamp);} return date('H:i:s', $timestamp); } function convert_smiles($text){ $smiles_codes=array('[smile]','[grin]','[shocked]','[cry]','[embarassed]','[undecided]','[sealedlips]','[sad]','[cool]','[angry]','[angel]','[tongue]','[sosi]','[poshol_nahui]'); $smiles=array("","","","","","","","","","","","","",""); return str_replace($smiles_codes,$smiles,$text); } function reverse_escape($str){ $str=htmlspecialchars_decode($str); $search=array("\\\\","\\0","\\n","\\r","\Z","\'",'\"'); $replace=array("\\","\0","\n","\r","\x1a","'",'"'); $str=str_replace($search,$replace,$str); $str=str_replace("javascript","",$str); $str=str_replace("jar:","",$str); return $str; } function remove_html($text){ return str_replace( array( '<', '>', '"', '\'', '\\', ), array( '<', '>', '"', ''', '\', ), $text ); } function un_remove_html($text){ return str_replace( array( '<', '>', '"', ''', '\', ), array( '<', '>', '"', '\'', '\\', ), $text ); } function _substr($str, $length, $minword = 3) { $sub = ''; $len = 0; foreach (explode(' ', $str) as $word) { $part = (($sub != '') ? ' ' : '') . $word; $sub .= $part; $len += strlen($part); if (strlen($word) > $minword && strlen($sub) >= $length) { break; } } return $sub . (($len < strlen($str)) ? '...' : ''); } /****************************************** arata pagini variabilele: $page - pagina curenta $count - cite pagini sunt $href - link la pagina formeaza html code de tipul: << 1 ... 10 11 12 ... 59 >> ******************************************/ function pager($page, $count, $href) { $pages = $count; $mp = $pages - 1; $pager='
Pagini: '; $pager2=''; if (($page) >= 2) { $pager .= " << "; } if ($page < $mp-1 && $mp >= 0) { $pager2 .= " >>"; } if ($count >1) { $pagerarr = array(); $dotted = 0; $dotspace = 1; $dotend = $pages - 1; $curdotend = $page - 2; $curdotstart = $page + 2; for ($i = 1; $i <=$pages; $i++) { if (($i >= 2 && $i <= $curdotend) || ($i >= $curdotstart && $i < $dotend)) { if (!$dotted)$pagerarr[] = " ... "; $dotted = 1; continue; } $dotted = 0; if ($i != $page){ $pagerarr[] = " $i "; }else $pagerarr[] = " $i "; } $pagerstr = join("", $pagerarr); $pagerbottom = "$pager $pagerstr $pager2
"; }else{ $pagerbottom = ""; } return $pagerbottom; } function translit($str) { $tr = array( "А"=>"A","Б"=>"B","В"=>"V","Г"=>"G", "Д"=>"D","Е"=>"E","Ж"=>"J","З"=>"Z","И"=>"I", "Й"=>"Y","К"=>"K","Л"=>"L","М"=>"M","Н"=>"N", "О"=>"O","П"=>"P","Р"=>"R","С"=>"S","Т"=>"T", "У"=>"U","Ф"=>"F","Х"=>"H","Ц"=>"TS","Ч"=>"CH", "Ш"=>"SH","Щ"=>"SCH","Ъ"=>"","Ы"=>"YI","Ь"=>"", "Э"=>"E","Ю"=>"YU","Я"=>"YA","а"=>"a","б"=>"b", "в"=>"v","г"=>"g","д"=>"d","е"=>"e","ж"=>"j", "з"=>"z","и"=>"i","й"=>"y","к"=>"k","л"=>"l", "м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r", "с"=>"s","т"=>"t","у"=>"u","ф"=>"f","х"=>"h", "ц"=>"ts","ч"=>"ch","ш"=>"sh","щ"=>"sch","ъ"=>"y", "ы"=>"yi","ь"=>"","э"=>"e","ю"=>"yu","я"=>"ya"," "=>"_","\""=>"",'–'=>'','%'=>'' ); return strtr($str,$tr); } function win_urf8($str) # Функция перекодировки windows-1251 -> UTF-8 { $win_urf8 = array( 'А' => '%D0%90','Б' => '%D0%91','В' => '%D0%92','Г' => '%D0%93', 'Д' => '%D0%94','Ж' => '%D0%96','З' => '%D0%97','Е' => '%D0%95', 'Ё' => '%D0%81','И' => '%D0%98','Й' => '%D0%99','К' => '%D0%9A', 'Л' => '%D0%9B','М' => '%D0%9C','Н' => '%D0%9D','О' => '%D0%9E', 'П' => '%D0%9F','Р' => '%D0%A0','С' => '%D0%A1','Т' => '%D0%A2', 'У' => '%D0%A3','Ф' => '%D0%A4','Х' => '%D0%A5','Ц' => '%D0%A6', 'Ч' => '%D0%A7','Ш' => '%D0%A8','Щ' => '%D0%A9','Ь' => '%D0%AC', 'Ы' => '%D0%AB','Ъ' => '%D0%AA','Э' => '%D0%AD','Ю' => '%D0%AE', 'Я' => '%D0%AF','а' => '%D0%B0','б' => '%D0%B1','в' => '%D0%B2', 'г' => '%D0%B3','д' => '%D0%B4','ж' => '%D0%B6','з' => '%D0%B7', 'е' => '%D0%B5','ё' => '%D1%91','и' => '%D0%B8','й' => '%D0%B9', 'к' => '%D0%BA','л' => '%D0%BB','м' => '%D0%BC','н' => '%D0%BD', 'о' => '%D0%BE','п' => '%D0%BF','р' => '%D1%80','с' => '%D1%81', 'т' => '%D1%82','у' => '%D1%83','ф' => '%D1%84','х' => '%D1%85', 'ц' => '%D1%86','ч' => '%D1%87','ш' => '%D1%88','щ' => '%D1%89', 'ь' => '%D1%8C','ы' => '%D1%8B','ъ' => '%D1%8A','э' => '%D1%8D', 'ю' => '%D1%8E','я' => '%D1%8F',' ' => '+'); return strtr($str, $win_urf8); } function utf8_win($s) # Функция перекодировки UTF-8 -> windows-1251 { $s=strtr($s,array("%D0%B0"=>"а", "%D0%90"=>"А", "%D0%B1"=>"б", "%D0%91"=>"Б", "%D0%B2"=>"в", "%D0%92"=>"В", "%D0%B3"=>"г", "%D0%93"=>"Г", "%D0%B4"=>"д", "%D0%94"=>"Д", "%D0%B5"=>"е", "%D0%95"=>"Е", "%D1%91"=>"ё", "%D0%81"=>"Ё", "%D0%B6"=>"ж", "%D0%96"=>"Ж", "%D0%B7"=>"з", "%D0%97"=>"З", "%D0%B8"=>"и", "%D0%98"=>"И", "%D0%B9"=>"й", "%D0%99"=>"Й", "%D0%BA"=>"к", "%D0%9A"=>"К", "%D0%BB"=>"л", "%D0%9B"=>"Л", "%D0%BC"=>"м", "%D0%9C"=>"М", "%D0%BD"=>"н", "%D0%9D"=>"Н", "%D0%BE"=>"о", "%D0%9E"=>"О", "%D0%BF"=>"п", "%D0%9F"=>"П", "%D1%80"=>"р", "%D0%A0"=>"Р", "%D1%81"=>"с", "%D0%A1"=>"С", "%D1%82"=>"т", "%D0%A2"=>"Т", "%D1%83"=>"у", "%D0%A3"=>"У", "%D1%84"=>"ф", "%D0%A4"=>"Ф", "%D1%85"=>"х", "%D0%A5"=>"Х", "%D1%86"=>"ц", "%D0%A6"=>"Ц", "%D1%87"=>"ч", "%D0%A7"=>"Ч", "%D1%88"=>"ш", "%D0%A8"=>"Ш", "%D1%89"=>"щ", "%D0%A9"=>"Щ", "%D1%8A"=>"ъ", "%D0%AA"=>"Ъ", "%D1%8B"=>"ы", "%D0%AB"=>"Ы", "%D1%8C"=>"ь", "%D0%AC"=>"Ь", "%D1%8D"=>"э", "%D0%AD"=>"Э", "%D1%8E"=>"ю", "%D0%AE"=>"Ю", "%D1%8F"=>"я", "%D0%AF"=>"Я")); return $s; }; /* mode: exact, textareas class: если больше текстарея то выдаём через класс elelemts: конкретный элемент */ function load_tinytmce($mode,$class,$elements='',$how=0){ echo ' '; } /** * Человекопонятная русская дата (и время) * * @param string $date_input Что-то хоть как-то похожее на дату * @param bool $time Показывать время * @return string * ex: echo date_smart('2008-09-14 23:34:59'); */ function date_smart($date_input, $time=true) { $monthes_ru = array( '', 'января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря' ); $monthes = array( '', 'ianuarie', 'februarie', 'martie', 'aprilie', 'mai', 'iunie', 'iulie', 'august', 'septembrie', 'octombrie', 'noiembrie', 'decembrie' ); $date = strtotime($date_input); /* //Время if($time) $time = ' G:i'; else $time = ''; //Сегодня, вчера, завтра if(date('Y') == date('Y',$date)) { if(date('z') == date('z', $date)) { $result_date = date('\A\z\i '.$time, $date); } elseif(date('z') == date('z',mktime(0,0,0,date('n',$date),date('j',$date)+1,date('Y',$date)))) { $result_date = date('\I\e\r\i'.$time, $date); } elseif(date('z') == date('z',mktime(0,0,0,date('n',$date),date('j',$date)-1,date('Y',$date)))) { $result_date = date('\M\i\i\n\e'.$time, $date); } if(isset($result_date)) return $result_date; } */ //Месяца $month = $monthes[date('n',$date)]; //Года if(date('Y') != date('Y', $date)) $year = 'Y'; else $year = 'Y'; $result_date = date('j ',$date).$month.' '.date($year.$time, $date); return $result_date; } /** * Множественное число * * @param int $howmuch * @param array $input Например: [0] - комментариев, [1] - комментарий, [2] - комментария * @return string * ex: echo Plural(41, array('комментариев', 'комментарий', 'комментария')); */ function Plural($howmuch,$input) { $howmuch = (int)$howmuch; $l2 = substr($howmuch,-2); $l1 = substr($howmuch,-1); if($l2 > 10 && $l2 < 20) return $input[0]; else switch ($l1) { case 0: return $input[0]; break; case 1: return $input[1]; break; case 2: case 3: case 4: return $input[2]; break; default: return $input[0]; break; } return false; } // Функция осуществляет автоматический вход на сайт function autoLogin() { global $con; // Если не установлены cookie, содержащие логин и пароль if ( !isset( $_COOKIE['user_id'] ) or !isset( $_COOKIE['password'] ) ) { $tmppos = strrpos( $_SERVER['PHP_SELF'], '/' ) + 1; if ( isset( $_COOKIE['user_id'] ) ) setcookie( 'user_id', '', time() - 1,'/'); if ( isset( $_COOKIE['password'] ) ) setcookie( 'password', '', time() - 1,'/'); if ( isset( $_COOKIE['autologin'] ) ) setcookie( 'autologin', '', time() - 1,'/'); return false; } // Проверяем переменные cookie на недопустимые символы $user_id = (int)$_COOKIE['user_id']; // Т.к. пароль зашифрован с помощью md5, то он представляет собой // 32-значное шестнадцатеричное число $password = substr( $_COOKIE['password'], 0, 32 ); $password = preg_replace( "#[^0-9a-f]#i", '', $password ); // Выполняем запрос на получение данных пользователя из БД $query = "SELECT * FROM accounts WHERE Id='".$user_id."' AND password='".mysqli_real_escape_string($con, $password )."' LIMIT 1"; $res = mysqli_query($con, $query ); if ( !$res ) {return 'Ошибка при авторизации пользователя';} // Если пользователь с таким логином и паролем не найден - // значит данные неверные и надо их удалить if ( mysqli_num_rows( $res ) == 0 ) { $tmppos = strrpos( $_SERVER['PHP_SELF'], '/' ) + 1; $path = substr( $_SERVER['PHP_SELF'], 0, $tmppos ); setcookie( 'autologin', '', time() - 1, $path,'/'); setcookie( 'user_id', '', time() - 1, $path,'/'); setcookie( 'password', '', time() - 1, $path,'/'); return false; } $user = mysqli_fetch_array( $res ); $_SESSION['user']['user_id'] = $user['Id']; //$_SESSION['user']['login'] = $user['login']; $_SESSION['user']['password'] = $user['password']; return true; } function editor_init($div){ echo '$("'.$div.'").sceditorBBCodePlugin({style: "../minified/jquery.sceditor.default.min.css",height:200});'; } define('BBEDIT_TYPE_BOTH', 0); define('BBEDIT_TYPE_TAG', 1); define('BBEDIT_TYPE_SMILEY', 2); /** * Convert bbcode to HTML * * @param string $text The text to convert. * @param int $type The type of bbcode. * @param string $smileyUrl The URL path of smiley icons. * @return string */ function bbedit($text, $type = BBEDIT_TYPE_BOTH, $smileyUrl = '/images/smiley'){ $search = array( '/\[b\]([^(\[\/b\])]+)\[\/b\]/i', '/\[i\]([^(\[\/i\])]+)\[\/i\]/i', '/\[u\]([^(\[\/u\])]+)\[\/u\]/i', '/\[s\]([^(\[\/s\])]+)\[\/s\]/i', '/\[code\]([^(\[\/code\])]+)\[\/code\]/i', '/\[quote\]([^(\[\/quote\])]+)\[\/quote\]/i', //'/\[img\]([^(\[\/img\])]+)\[\/img\]/i', ); $replace = array( '$1', '$1', '$1', '$1', '$1', '
$1
', //'', ); $smilies = array('biggrin', 'cry', 'dizzy', 'funk', 'huffy', 'lol', 'loveliness', 'mad', 'sad', 'shocked', 'shy', 'sleepy', 'smile', 'sweat', 'titter', 'tongue'); if ($type != BBEDIT_TYPE_SMILEY) { $text = preg_replace($search, $replace, $text); echo $text; $text = preg_replace_callback( '/\[url(=([^\]]+))?\]([^(\[\/url\])]+)\[\/url\]/i', create_function( '$matches', '$text = $matches[3]; $url = !empty($matches[2]) ? $matches[2] : $text; return "$text";' ), $text ); } if ($type != BBEDIT_TYPE_TAG) { $search2 = $replace2 = array(); for ($i = 0, $len = count($smilies); $i < $len; $i++) { $search2[$i] = sprintf('/\[:Q%s\]/', $smilies[$i]); $replace2[$i] = sprintf('%s', $smileyUrl, $smilies[$i], $smilies[$i]); } $text = preg_replace($search2, $replace2, $text); } $text = preg_replace('/\[[^\]]*\]/', '', $text); return $text; } function bb_parse($string) { $smileyUrl = '/images/smiley'; $tags = 'b|i|u|s|size|color|font|center|quote|url|img|code|sup|sub|right|left|justify'; while (preg_match_all('`\[('.$tags.')=?(.*?)\](.+?)\[/\1\]`', $string, $matches)) foreach ($matches[0] as $key => $match) { list($tag, $param, $innertext) = array($matches[1][$key], $matches[2][$key], $matches[3][$key]); switch ($tag) { case 'b': $replacement = "$innertext"; break; case 'i': $replacement = "$innertext"; break; case 'u': $replacement = "$innertext"; break; case 's': $replacement = "$innertext"; break; case 'code': $replacement = "$innertext"; break; case 'sub': $replacement = "$innertext"; break; case 'sup': $replacement = "$innertext"; break; case 'left': $replacement = "

$innertext

"; break; case 'right': $replacement = "

$innertext

"; break; case 'center': $replacement = "
$innertext
"; break; case 'justify': $replacement = "

$innertext

"; break; case 'size': $sizes=array(1=>'xx-small',2=>'x-small',3=>'small',4=>'medium',5=>'large',6=>'x-large',7=>'xx-large');$replacement = "$innertext"; break; case 'color': $replacement = "$innertext"; break; case 'font': $replacement = "$innertext"; break; case 'center': $replacement = "
$innertext
"; break; //case 'quote': $replacement = "
$innertext
" . $param? "$param" : ''; break; //case 'quote': $replacement = "
$innertext
"; break; case 'quote': $replacement = "
Цитата$innertext
"; break; case 'url': $replacement = '$innertext"; break; case 'img': list($width, $height) = preg_split('`[Xx]`', $param); $replacement = "'; break; case 'video': $videourl = parse_url($innertext); parse_str($videourl['query'], $videoquery); if (strpos($videourl['host'], 'youtube.com') !== FALSE) $replacement = ''; if (strpos($videourl['host'], 'google.com') !== FALSE) $replacement = ''; break; } $string = str_replace($match, $replacement, $string); } $smilies2=array(":)"=>"smile.png",":angel:"=>"angel.png",":angry:"=>"angry.png","8-)"=>"cool.png",":kry:"=>"cwy.png",":ermm:"=>"ermm.png",":D"=>"grin.png",":heart:"=>"heart.png",":("=>"sad.png",":O"=>"shocked.png",":P"=>"tongue.png",";)"=>"wink.png",":alien:"=>"alien.png",":blink:"=>"blink.png",":blush:"=>"blush.png",":cheerful:"=>"cheerful.png",":devil:"=>"devil.png",":dizzy:"=>"dizzy.png",":getlost:"=>"getlost.png",":happy:"=>"happy.png",":kissing:"=>"kissing.png",":ninja:"=>"ninja.png",":pinch:"=>"pinch.png",":pouty:"=>"pouty.png",":sick:"=>"sick.png",":sideways:"=>"sideways.png",":silly:"=>"silly.png",":sleeping:"=>"sleeping.png",":unsure:"=>"unsure.png",":woot:"=>"w00t.png",":wassat:"=>"wassat.png"); foreach($smilies2 as $smile=>$simg){ $string=str_replace($smile,''.$smile.'',$string); } /* $smilies=array('biggrin', 'cry', 'dizzy', 'funk', 'huffy', 'lol', 'loveliness', 'mad', 'sad', 'shocked', 'shy', 'sleepy', 'smile', 'sweat', 'titter', 'tongue'); $search2 = $replace2 = array(); for ($i = 0, $len = count($smilies); $i < $len; $i++) { $search2[$i] = sprintf('/\[:Q%s\]/', $smilies[$i]); $replace2[$i] = sprintf('%s', $smileyUrl, $smilies[$i], $smilies[$i]); } $string = preg_replace($search2, $replace2, $string); */ $string = str_replace('[hr]','
', $string); $string = str_replace(array('[li]','[/li]'),array('
  • ','
  • '),preg_replace('#((?:\[li\].+(?!/li\])\[/li\]\s*)+)#', '', $string)); //$html = str_replace(array('[li]','[/li]'),array('
  • ','
  • '),preg_replace('#((?:\[li\].+(?!/li\])\[/li\]\s*)+)#', '', $html)); $string = str_replace(array('[ul]','[/ul]'),'', $string); return $string; } function CurrentPageURL(){ $currenturl="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; return $currenturl; } function translit_text($string){ $rus = array("/а/", "/б/", "/в/", "/г/", "/ґ/", "/д/", "/е/", "/ё/", "/ж/", "/з/", "/и/", "/й/", "/к/", "/л/", "/м/", "/н/", "/о/", "/п/", "/р/", "/с/", "/т/", "/у/", "/ф/", "/х/", "/ц/", "/ч/", "/ш/", "/щ/", "/ы/", "/э/", "/ю/", "/я/", "/ь/", "/ъ/", "/і/", "/ї/", "/є/", "/А/", "/Б/", "/В/", "/Г/", "/ґ/", "/Д/", "/Е/", "/Ё/", "/Ж/", "/З/", "/И/", "/Й/", "/К/", "/Л/", "/М/", "/Н/", "/О/", "/П/", "/Р/", "/С/", "/Т/", "/У/", "/Ф/", "/Х/", "/Ц/", "/Ч/", "/Ш/", "/Щ/", "/Ы/", "/Э/", "/Ю/", "/Я/", "/Ь/", "/Ъ/", "/І/", "/Ї/", "/Є/"); $lat = array("a", "b", "v", "g", "g", "d", "e", "e", "zh", "z", "i", "j", "k", "l", "m", "n", "o", "p", "r", "s", "t", "u", "f", "h", "c", "ch", "sh", "sh'", "y", "e", "yu", "ya", "'", "'", "i", "i", "e", "A", "B", "V", "G", "G", "D", "E", "E", "ZH", "Z", "I", "J", "K", "L", "M", "N", "O", "P", "R", "S", "T", "U", "F", "H", "C", "CH", "SH", "SH'", "Y", "E", "YU", "YA", "'", "'", "I", "I", "E"); return preg_replace($rus, $lat, $string); } function create_url($title,$id=0){ global $scoala; global $con; $normalizeChars = array( 'Š'=>'S', 'š'=>'s', 'Ð'=>'Dj','Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E', 'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ń'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss','à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ń'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o', 'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ü'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y', 'ƒ'=>'f', 'ă'=>'a', 'î'=>'i', 'â'=>'a', 'ș'=>'s', 'ț'=>'t', 'Ă'=>'A', 'Î'=>'I', 'Â'=>'A', 'Ș'=>'S', 'Ț'=>'T', ); $title=strtr($title, $normalizeChars); $title=strtolower(translit_text($title)); $string=$title; $string=preg_replace('`&(amp;)?#?[a-z0-9]+;`i','-',$string); $string=htmlentities($string, ENT_COMPAT,"utf-8"); $string=preg_replace("`&([a-z]+);`i", "",$string); $string=preg_replace("`['\[\]]`","",$string); $tmp=$string; $string=preg_replace(array("/[^A-Za-z0-9]/", "`[_]+`"), "-",$string); $string=preg_replace('/-{2,}/','-',$string); $string=trim($string,'-'); $string=trim($string); $ok=false; $n=0; while(!$ok){ if($n!=0){$str_tmp=$string.'-'.$n;}else{$str_tmp=$string;} $res=mysqli_query($con,"SELECT * FROM pages WHERE url='{$str_tmp}' AND Id!={$id} AND scoala={$scoala}"); if(!@mysqli_num_rows($res)){$ok=true;$string=$str_tmp;} $n++; } return $string; } function defender_xss($arr){ $filter = array("<", ">","="," (",")",";","/"); $find = array ('/data:/i', '/about:/i', '/vbscript:/i', '/onclick/i', '/onload/i', '/onunload/i', '/onabort/i', '/onerror/i', '/onblur/i', '/onchange/i', '/onfocus/i', '/onreset/i', '/onsubmit/i', '/ondblclick/i', '/onkeydown/i', '/onkeypress/i', '/onkeyup/i', '/onmousedown/i', '/onmouseup/i', '/onmouseover/i', '/onmouseout/i', '/onselect/i', '/javascript/i', '/javascript/i' ); $replace = array ("data:", "about:", "vbscript:", "onclick", "onload", "onunload", "onabort", "onerror", "onblur", "onchange", "onfocus", "onreset", "onsubmit", "ondblclick", "onkeydown", "onkeypress", "onkeyup", "onmousedown", "onmouseup", "onmouseover", "onmouseout", "onselect", "javascript" ); foreach($arr as $num=>$xss){ $arr[$num]=str_replace ($filter, "|", $xss); $arr[$num]=preg_replace( $find, $replace,$arr[$num]); $arr[$num]=preg_replace( "#", "?>",$arr[$num]); } return $arr; } function defender_xss_one($txt){ $filter = array("<", ">","="," (",")",";","/"); $find = array ('/data:/i', '/about:/i', '/vbscript:/i', '/onclick/i', '/onload/i', '/onunload/i', '/onabort/i', '/onerror/i', '/onblur/i', '/onchange/i', '/onfocus/i', '/onreset/i', '/onsubmit/i', '/ondblclick/i', '/onkeydown/i', '/onkeypress/i', '/onkeyup/i', '/onmousedown/i', '/onmouseup/i', '/onmouseover/i', '/onmouseout/i', '/onselect/i', '/javascript/i', '/javascript/i' ); $replace = array ("data:", "about:", "vbscript:", "onclick", "onload", "onunload", "onabort", "onerror", "onblur", "onchange", "onfocus", "onreset", "onsubmit", "ondblclick", "onkeydown", "onkeypress", "onkeyup", "onmousedown", "onmouseup", "onmouseover", "onmouseout", "onselect", "javascript" ); $txt=str_replace ($filter, "|", $txt); $txt=preg_replace( $find, $replace,$txt); $txt=preg_replace( "#", "?>",$txt); return $txt; } function strtolower_utf8($inputString) { $outputString = utf8_decode($inputString); $outputString = strtolower($outputString); $outputString = utf8_encode($outputString); return $outputString; } function set_headers($title='',$bar_text='',$url=''){ ?> = 1073741824) { $bytes = number_format($bytes / 1073741824, 2) . ' GB'; } elseif ($bytes >= 1048576) { $bytes = number_format($bytes / 1048576, 2) . ' MB'; } elseif ($bytes >= 1024) { $bytes = number_format($bytes / 1024, 2) . ' KB'; } elseif ($bytes > 1) { $bytes = $bytes . ' bytes'; } elseif ($bytes == 1) { $bytes = $bytes . ' byte'; } else { $bytes = '0 bytes'; } return $bytes; } function trasnformBB($text) { // BBcode array $find = array( '~\[file\](.*?)\[/file\]~s','~\[pdf\](.*?)\[/pdf\]~s' ); $replace = array( '|||$1|||','===$1===' ); $text=preg_replace($find,$replace,$text); $t=explode('|||',$text); if(isset($t[1])){ $k=0;$text=''; foreach($t as $e){ if($k%2==0){ $text.=$e; }else{ $text.='
    '.formatSizeUnits(filesize($_SERVER['DOCUMENT_ROOT'].$e)).'
    '; } $k++; } } $t=explode('===',$text); if(isset($t[1])){ $k=0;$text=''; foreach($t as $e){ if($k%2==0){ $text.=$e; }else{ $text.='