Файл: inc/functions.php
Строк: 195
<?php
if (function_exists('ini_set'))
{
ini_set('register_globals', false); // вырубаем глобальные переменные
ini_set('arg_separator.output', ";"); // разделитель переменных в url (для соответствия с xml)
}
// принудительно вырубаем глобальные переменные
if (ini_get('register_globals')) {
$allowed = array('_ENV' => 1, '_GET' => 1, '_POST' => 1, '_COOKIE' => 1, '_FILES' => 1, '_SERVER' => 1, '_REQUEST' => 1, 'GLOBALS' => 1);
foreach ($GLOBALS as $key => $value) {
if (!isset($allowed[$key])) {
unset($GLOBALS[$key]);
}
}
}
#------- Проверка GET данных
foreach ($_GET as $cheked_Space)
{
if (is_array($cheked_Space) and !preg_match('#^(?:[a-z0-9_-/]+|.+(?!/))*$#i', $cheked_Space))
{
header ("Location: index.php");
exit;
}
}
/* Функция отфильтровки чисел */
function int($int)
{
return abs((int)$int);
}
///функция обработки смайлов и bb тегов
function displaysmileys($variables){
$variables = htmlspecialchars($variables);
$modified = strtr($variables, array(
';D'=>'<img src="smile/acute.gif" alt="smiley" />',
'>:o'=>'<img src="smile/aggressive.gif" alt="smiley" />',
':STOP:'=>'<img src="smile/agree.gif" alt="smiley" />',
':KISSED:'=>'<img src="smile/air_kiss.gif" alt="smiley" />',
':-!'=>'<img src="smile/bad.gif" alt="smiley" />',
':-/'=>'<img src="smile/beee.gif" alt="smiley" />',
':BUMP:'=>'<img src="smile/black_eye.gif" alt="smiley" />',
':-P'=>'<img src="smile/blum2.gif" alt="smiley" />',
':-['=>'<img src="smile/blush.gif" alt="smiley" />',
':BOAST:'=>'<img src="smile/boast.gif" alt="smiley" />',
':BOREDOM:'=>'<img src="smile/boredom.gif" alt="smiley" />',
':CENSORED:'=>'<img src="smile/censored.gif" alt="smiley" />',
':BRAVO:'=>'<img src="smile/clapping.gif" alt="smiley" />',
':CRAY:'=>'<img src="smile/cray.gif" alt="smiley" />',
':DANCE:'=>'<img src="smile/dance.gif" alt="smiley" />',
':DANCE2:'=>'<img src="smile/dance2.gif" alt="smiley" />',
':DANCE3:'=>'<img src="smile/dance3.gif" alt="smiley" />',
':DANCE4:'=>'<img src="smile/dance4.gif" alt="smiley" />',
':DECLARE:'=>'<img src="smile/declare.gif" alt="smiley" />',
':DERISIVE:'=>'<img src="smile/derisive.gif" alt="smiley" />',
'8-)'=>'<img src="smile/dirol.gif" alt="smiley" />',
':DONT_KNOW:'=>'<img src="smile/dntknw.gif" alt="smiley" />',
':MENTION:'=>'<img src="smile/don-t_mention.gif" alt="smiley" />',
':DOWNLOAD:'=>'<img src="smile/download.gif" alt="smiley" />',
':DRINK:'=>'<img src="smile/drinks.gif" alt="smiley" />',
'FOOL'=>'<img src="smile/fool.gif" alt="smiley" />',
':FRIENDS:'=>'<img src="smile/friends.gif" alt="smiley" />',
':GOOD:'=>'<img src="smile/good.gif" alt="smiley" />',
':GOOD2:'=>'<img src="smile/good2.gif" alt="smiley" />',
':-D'=>'<img src="smile/grin.gif" alt="smiley" />',
':D'=>'<img src="smile/grin.gif" alt="smiley" />',
':HEAT:'=>'<img src="smile/heat.gif" alt="smiley" />',
':HELP:'=>'<img src="smile/help.gif" alt="smiley" />',
':HAPPY:'=>'<img src="smile/i-m_so_happy.gif" alt="smiley" />',
':IREFUL:'=>'<img src="smile/ireful1.gif" alt="smiley" />',
':LAUGH:'=>'<img src="smile/laugh1.gif" alt="smiley" />',
':ASSASSIN:'=>'<img src="smile/assassin.gif" alt="smiley" />',
':BUTCHER:'=>'<img src="smile/butcher.gif" alt="smiley" />',
':DWARF:'=>'<img src="smile/dwarf.gif" alt="smiley" />',
':WEREWOLF:'=>'<img src="smile/girl_werewolf.gif" alt="smiley" />',
':JESTER:'=>'<img src="smile/jester.gif" alt="smiley" />',
':KING:'=>'<img src="smile/king.gif" alt="smiley" />',
':KING2:'=>'<img src="smile/king2.gif" alt="smiley" />',
':ORC:'=>'<img src="smile/orc.gif" alt="smiley" />',
':PALADIN:'=>'<img src="smile/paladin.gif" alt="smiley" />',
':QUEEN:'=>'<img src="smile/queen.gif" alt="smiley" />',
':VAMPIRE:'=>'<img src="smile/vampire.gif" alt="smiley" />',
':WIZARD:'=>'<img src="smile/wizard.gif" alt="smiley" />'
));
$modified = preg_replace("#(https?|ftp)://S+[^s.,> )];'"!?]#",'<del class="hide"><![CDATA[<noindex>]]></del><a href="\0" target="_blank" rel="nofollow">\0</a><del class="hide"><![CDATA[</noindex>]]></del>',$modified);
$modified = preg_replace('#[b](.*?)[/b]#si', '<span style="font-weight: bold;">1</span>', $modified);
$modified = preg_replace('#[i](.*?)[/i]#si', '<span style="font-style:italic;">1</span>', $modified);
$modified = preg_replace('#[u](.*?)[/u]#si', '<span style="text-decoration:underline;">1</span>', $modified);
$modified = preg_replace('#[s](.*?)[/s]#si', '<span style="text-decoration: line-through;">1</span>', $modified);
$modified = preg_replace('#[red](.*?)[/red]#si', '<span style="color:red">1</span>', $modified);
$modified = preg_replace('#[green](.*?)[/green]#si', '<span style="color:green">1</span>', $modified);
$modified = preg_replace('#[blue](.*?)[/blue]#si', '<span style="color:blue">1</span>', $modified);
$modified = preg_replace('#[c](.*?)[/c]#si', '<div class="quote">1</div>', $modified);
$modified = preg_replace('#[code](.*?)[/code]#si', '<div class="quote">1</div>', $modified);
$modified = preg_replace('#rn#si', '<br />', $modified);
///$modified = preg_replace('#>#si', '>', $modified);
return $modified;
}
function my_htmlspecialchats($input, $sql=false) {
$input = mysql_real_escape_string ($input);
$input=str_replace ("rn","rn", $input);
//обрабатываем переводы строки.
return $input;
}
function my_htmlspecialchats_vivod($document)
{
$search = array ("']*?>.*?'si",
"'<[/!]*?[^<>]*?>'si",
"'([rn])[s]+'",
"'&(quot|#34);'i",
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&#(d+);'e");
$replace = array ("",
"",
"\1",
""",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169),
"chr(\1)");
$text = preg_replace ($search, $replace, $document);
return $text;
}
function my_date($variables)
{
$modified = strtr($variables, array(
'January'=>'Янв',
'February'=>'Фев',
'March'=>'Мар',
'April'=>'Апр',
'May'=>'Май',
'June'=>'Июн',
'July'=>'Июл',
'August'=>'Авг',
'September'=>'Сен',
'October'=>'Окт',
'November'=>'Ноя',
'December'=>'Дек'
));
return $modified;
}
function pagenav($base_url, $start, $max_value, $num_per_page) {
////////////////////////////////////////////////////////////
// Функция постраничной навигации //
////////////////////////////////////////////////////////////
// За основу взята аналогичная функция от форума SMF2.0 //
////////////////////////////////////////////////////////////
$pgcont = 4;
$pgcont = (int)($pgcont - ($pgcont % 2)) / 2;
if ($start >= $max_value)
$start = max(0, (int)$max_value - (((int)$max_value % (int)$num_per_page) == 0 ? $num_per_page : ((int)$max_value % (int)$num_per_page)));
else
$start = max(0, (int)$start - ((int)$start % (int)$num_per_page));
$base_link = '<a class="si" href="' . strtr($base_url, array ('%' => '%%')) . 'start=%d' . '">%s</a> ';
$pageindex = $start == 0 ? '' : sprintf($base_link, $start - $num_per_page, '<<');
if ($start > $num_per_page * $pgcont)
$pageindex .= sprintf($base_link, 0, '1');
if ($start > $num_per_page * ($pgcont + 1))
$pageindex .= '<span style="font-weight: bold;"> ... </span>';
for ($nCont = $pgcont; $nCont >= 1; $nCont--)
if ($start >= $num_per_page * $nCont) {
$tmpStart = $start - $num_per_page * $nCont;
$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
}
$pageindex .= '[<b>' . ($start / $num_per_page + 1) . '</b>] ';
$tmpMaxPages = (int)(($max_value - 1) / $num_per_page) * $num_per_page;
for ($nCont = 1; $nCont <= $pgcont; $nCont++)
if ($start + $num_per_page * $nCont <= $tmpMaxPages) {
$tmpStart = $start + $num_per_page * $nCont;
$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
}
if ($start + $num_per_page * ($pgcont + 1) < $tmpMaxPages)
$pageindex .= '<span style="font-weight: bold;"> ... </span>';
if ($start + $num_per_page * $pgcont < $tmpMaxPages)
$pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1);
if ($start + $num_per_page < $max_value) {
$display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page);
$pageindex .= sprintf($base_link, $display_page, '>>');
}
return $pageindex;
}
?>