Файл: o5on.ru/inc/functions.inc.php
Строк: 109
<?php
$moy_sute_ru = "http://".$_SERVER["HTTP_HOST"]."/";
// ============================= ФУНКЦИИ ==================================
//Фильтрация переменных
function northwest($value){
$value=eregi_replace ("['#$%^><&*%]","",$value);
return $value;}
function formes($value){
$value=eregi_replace ("'","'",$value);
//$value=eregi_replace ("&","&",$value);
//$value=eregi_replace ("#","#",$value);
//$value=eregi_replace ("%","%",$value);
//$value=eregi_replace ("+","+",$value);
$value=eregi_replace (">",">",$value);
$value=eregi_replace ("<","<",$value);
$value=eregi_replace ("
","<br/>",$value);
$value=wordwrap($value,100,' ',1);
return $value;}
function latin($value){
if (!preg_match("/^[0-9A-Z@._-]{0,45}$/i", $value))
{
$value = '';
}
return $value;}
function dig($value){
if (!preg_match("/^[0-9]{1,15}$/i", $value))
{
$value = '';
}
return $value;}
function connect_to_db()
{
// настройка доступа к базе
$dbh = @mysql_connect ("localhost", USER_DB, PASS_DB) or die ('Error mysql connect');
@mysql_select_db (DB) or die ('Error select db');
@mysql_query("SET NAMES utf8");
}
### Запрос
function query ()
{
return (!empty($_SERVER['QUERY_STRING'])? '?'.str_replace("&", "&", $_SERVER['QUERY_STRING']) : '?');
}
// функция отпереления поддержки Реалтонов по марке и можели телефона
function realton_supported($vendor, $model)
{
$support_phone = array(
'Alcatel' => array ('556', '557', '715', '735i', '735', '756'),
'LG' => array ('B2000', 'M4410' ),
'Motorola' => array ('C380', 'C390', 'C650', 'E398', 'Mpx220', 'V180', 'V3', 'V300', 'V400', 'V500', 'V525', 'V535', 'V547', 'V600', 'V620', 'V635' ),
'Nokia' => array ('3220', '3230', '3300', '3650', '3660', '5140i', '6021', '6060', '6170', '6220', '6230', '6230i', '6260', '6600', '6670', '6680', '6681', '6822', '6822a', '7260', '7270', '7610', '8800', 'N70' ),
'Pantech' => array ('PG3200' ),
'Sagem' => array ('MyC5-2', 'MyV-55' ),
'Samsung' => array ('D500', 'D500e', 'E350', 'E350e', 'E530', 'E620', 'E720', 'E730', 'E760', 'X480', 'Z130' ),
'Siemens' => array ('С65', 'С75', 'СF75', 'CL75', 'CX65', 'CX70', 'CX75', 'M65', 'M75', 'S65', 'Sk65', 'SL65', 'SX1' ),
'Sony Ericsson' => array ('J300i', 'K300i', 'K500i', 'K600i', 'K700i', 'K750i', 'P800', 'P900', 'S700i', 'T290i', 'T610', 'T630', 'Z800i')
);
foreach ($support_phone as $phone_vendor => $models_array)
{
if (strtoupper($phone_vendor) == strtoupper($vendor))
foreach ($models_array as $phone_model)
if (strtoupper($phone_model) == strtoupper($model))
return true;
}
return false;
}
// функция отпереления поддержки ВИДЕО по марке и можели телефона
function video_supported($vendor, $model)
{
$support_phone = array(
'Alcatel' => array ('556', '557', '565', '756', '757', 'C651'),
'Motorola' => array ('A1000', 'A780', 'A830', 'A835', 'C975', 'E1000', 'E398', 'E680', 'V3', 'V600', 'V620', 'V635' ),
'Nokia' => array ('3220', '3230', '3650', '3660', '5140', '6101', '6170', '6230', '6230i', '6255', '6260', '6600', '6620', '6630', '6670', '6680', '6681', '6820', '7200', '7600', '7610', '7700', '9300', '9500', 'N-Gage', 'N-Gage QD', 'N70', 'N90', 'N91', 'N92' ),
'Pantech' => array ('PG3500', 'PG3600', 'PG8000' ),
'Sharp' => array ('GX-25', 'V-902' ),
'Samsung' => array ('SGH-D500', 'SGH-E720', 'SGH-i700' ),
'SIEMENS' => array ('CX65', 'CXT65', 'CXT70', 'CX75', 'S75', 'CXV65', 'M65', 'MT65', 'S65', 'S65V', 'SK65', 'SL65', 'SX1' ),
'Sony Ericsson' => array ('F500i', 'K300', 'K300i', 'K500', 'K500i', 'K600', 'K600i', 'K600c', 'K700', 'K700i', 'K750i', 'K750', 'P800', 'P900', 'P910', 'P910i', 'S700', 'S700i', 'V800', 'W800i' )
);
foreach ($support_phone as $phone_vendor => $models_array)
{
if (strtoupper($phone_vendor) == strtoupper($vendor))
foreach ($models_array as $phone_model)
if (strtoupper($phone_model) == strtoupper($model))
return true;
}
return false;
}
// функция определения папки с поддерживаемым контентом для бесплат игр
function free_game_group($tel_data)
{
global $vendor, $model;
$rows = explode("n", $tel_data);
foreach ($rows as $row_data)
{
$tel_group_data = explode("::", $row_data);
if ( strtoupper($tel_group_data[1]) == strtoupper($vendor) )
{
$group_models = explode(" ", $tel_group_data[2]);
foreach ($group_models as $group_model)
{
if ( strtoupper($group_model) == strtoupper($model) )
return $tel_group_data[0];
}
}
}
return false;
}
### функция перекодировки
function utf8_win ($s)
{
$out="";
$c1="";
$byte2=false;
for ($c=0;$c<strlen($s);$c++){
$i=ord($s[$c]);
if ($i<=127) $out.=$s[$c];
if ($byte2){
$new_c2=($c1&3)*64+($i&63);
$new_c1=($c1>>2)&5;
$new_i=$new_c1*256+$new_c2;
if ($new_i==1025){
$out_i=168;
}else{
if ($new_i==1105){
$out_i=184;
}else {
$out_i=$new_i-848;
}
}
$out.=chr($out_i);
$byte2=false;
}
if (($i>>5)==6) {
$c1=$i;
$byte2=true;
}
}
return $out;
}
### функция проверки мыла
function verify_addr ($address) {
$return = false;
if (preg_match ('/^[w.-]+@([w.-]+).[a-z]{2,6}$/i', $address, $domain)) {
$domain = explode ('.', $domain[0]);
// Split the domain into sections wherein the last element is either 'co', 'org', or the likes, or the primary domain name
foreach ($domain as $part) { // Iterate through the parts
if (substr ($part, 0, 1) == '_' || substr ($part, strlen ($part) - 1, 1) == '_')
$return = false; // The first or last character is _
else
$return = true; // The parts are fine. The address seems syntactically valid
}
}
return $return;
}
function utf8_strlen($s)
{
return preg_match_all('/./u', $s, $tmp);
}
?>