<?PHP
# Счетчик
function TimerSet(){
list($seconds, $microSeconds) = explode(' ', microtime());
return $seconds + (float) $microSeconds;
}
$_timer_a = TimerSet();
# Старт сессии
@session_start();
# Старт буфера
@ob_start();
# Default
$_OPTIMIZATION = array();
$_OPTIMIZATION["title"] = "Главная";
$_OPTIMIZATION["description"] = "Смешарики!";
$_OPTIMIZATION["keywords"] = "Заработок на играх, вложения, заработать, ну погоди, денежная игра, заработать на онлайн играх";
# Константа для Include
define("CONST_RUFUS", true);
# Автоподгрузка классов
function __autoload($name){ include("classes/_class.".$name.".php");}
# Класс конфига
$config = new config;
# Функции
$func = new func;
# Установка REFERER
include("inc/_set_referer.php");
# База данных
$db = new db($config->HostDB, $config->UserDB, $config->PassDB, $config->BaseDB);
# Шапка
@include("inc/_header.php");
if(isset($_GET["menu"])){
$menu = strval($_GET["menu"]);
switch($menu){
case "404": include("pages/_404.php"); break; // Страница ошибки
case "rules": include("pages/_rules.php"); break; // Правила проекта
case "help": include("pages/_help.php"); break; // Вопросы
case "top": include("pages/_top.php"); break; // Топ
case "about": include("pages/_about.php"); break; // О проекте
case "contacts": include("pages/_contacts.php"); break; // Контакты
case "news": include("pages/_news.php"); break; // Новости
case "signup": include("pages/_signup.php"); break; // Регистрация
case "recovery": include("pages/_recovery.php"); break; // Восстановление пароля
case "account": include("pages/_account.php"); break; // Аккаунт
case "competition": include("pages/_competition.php"); break; // Конкурсы
case "users": include("pages/_users_list.php"); break; // Пользователи
case "payments": include("pages/_payments_list.php"); break; // Выплаты
case "admin4ik": include("pages/_admin.php"); break; // Админка
# Страница ошибки
default: @include("pages/_404.php"); break;
}
}else @include("pages/_index.php");
# Подвал
@include("inc/_footer.php");
# Заносим контент в переменную
$content = ob_get_contents();
# Очищаем буфер
ob_end_clean();
# Заменяем данные
$content = str_replace("{!TITLE!}",$_OPTIMIZATION["title"],$content);
$content = str_replace('{!DESCRIPTION!}',$_OPTIMIZATION["description"],$content);
$content = str_replace('{!KEYWORDS!}',$_OPTIMIZATION["keywords"],$content);
$content = str_replace('{!GEN_PAGE!}', sprintf("%.5f", (TimerSet() - $_timer_a)) ,$content);
# Вывод баланса
if(isset($_SESSION["user_id"])){
$user_id = $_SESSION["user_id"];
$db->Query("SELECT money_b, money_p FROM db_users_b WHERE id = '$user_id'");
$balance = $db->FetchArray();
$content = str_replace('{!BALANCE_B!}', sprintf("%.2f", $balance["money_b"]) ,$content);
$content = str_replace('{!BALANCE_P!}', sprintf("%.2f", $balance["money_p"]) ,$content);
}
// Выводим контент
echo $content;
?>
<?PHP
class func{
public $UserIP = "Undefined"; # IP пользователя
public $UserCode = "Undefined"; # Код от IP
public $TableID = -1; # ID таблицы
public $UserAgent = "Undefined"; // Браузер пользователя
/*======================================================================*\
Function: __construct
Output: Нет
Descriiption: Выполняется при создании экземпляра класса
\*======================================================================*/
public function __construct(){
$this->UserIP = $this->GetUserIp();
$this->UserCode = $this->IpCode();
$this->UserAgent = $this->UserAgent();
}
/*======================================================================*\
Function: __destruct
Output: Нет
Descriiption: Уничтожение объекта
\*======================================================================*/
public function __destruct(){
}
/*======================================================================*\
Function: IpToLong
Descriiption: Преобразует IP в целочисленное
\*======================================================================*/
public function IpToInt($ip){
$ip = ip2long($ip);
($ip < 0) ? $ip+=4294967296 : true;
return $ip;
}
/*======================================================================*\
Function: IpToLong
Descriiption: Преобразует целочисленное в IP
\*======================================================================*/
public function IntToIP($int){
return long2ip($int);
}
/*======================================================================*\
Function: GetUserIp
Output: UserIp
Descriiption: Определяет IP пользователя
\*======================================================================*/
public function GetUserIp(){
if($this->UserIP == "Undefined"){
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND !empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$client_ip = ( !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : ( ( !empty($_ENV['REMOTE_ADDR']) ) ? $_ENV['REMOTE_ADDR'] : "unknown" );
$entries = split('[, ]', $_SERVER['HTTP_X_FORWARDED_FOR']);
reset($entries);
while (list(, $entry) = each($entries))
{
$entry = trim($entry);
if ( preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $entry, $ip_list) )
{
$private_ip = array(
'/^0\./',
'/^127\.0\.0\.1/',
'/^192\.168\..*/',
'/^172\.((1[6-9])|(2[0-9])|(3[0-1]))\..*/',
'/^10\..*/');
$found_ip = preg_replace($private_ip, $client_ip, $ip_list[1]);
if ($client_ip != $found_ip)
{
$client_ip = $found_ip;
break;
}
}
}
$this->UserIP = $client_ip;
return $client_ip;
}else return ( !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : ( ( !empty($_ENV['REMOTE_ADDR']) ) ? $_ENV['REMOTE_ADDR'] : "unknown" );
}else return $this->UserIP;
}
/*======================================================================*\
Function: IsLogin
Output: True / False
Input: Строка логина, Маска, Длина ("10, 25") && ("10")
Descriiption: Проверяет правильность ввода логина
\*======================================================================*/
public function IsLogin($login, $mask = "^[a-zA-Z0-9]", $len = "{4,10}"){
return (is_array($login)) ? false : (preg_match("/{$mask}{$len}$/", $login)) ? $login : false;
}
/*======================================================================*\
Function: IsPassword
Output: True / False
Input: Строка пароля, Маска, Длина ("10, 25") && ("10")
Descriiption: Проверяет правильность ввода пароля
\*======================================================================*/
public function IsPassword($password, $mask = "^[a-zA-Z0-9]", $len = "{4,20}"){
return (is_array($password)) ? false : (preg_match("/{$mask}{$len}$/", $password)) ? $password : false;
}
/*======================================================================*\
Function: IsWM
Output: True / False
Input: Реквизит, TYPE: 0 - WMID, 1 - WMR, 2 - WMZ, 3 - WME, 4 - WMU
Descriiption: Проверяет правильность ввода пароля
\*======================================================================*/
public function IsWM($data, $type = 0){
$FirstChar = array( 1 => "R",
2 => "Z",
3 => "E",
4 => "U");
if(strlen($data) < 12 && strlen($data) > 12 && $type < 0 && $type > count($FirstChar)) return false;
if($type == 0) return (is_array($data)) ? false : ( preg_match("^[0-9]{12}$", $data) ? $data : false );
if( substr(strtoupper($data),0,1) != $FirstChar[$type] or !preg_match("^[0-9]{12}", substr($data,1)) ) return false;
return $data;
}
/*======================================================================*\
Function: IsMail
Output: True / False
Input: Email
Descriiption: Проверяет правильность ввода email адреса
\*======================================================================*/
public function IsMail($mail){
if(is_array($mail) && empty($mail) && strlen($mail) > 255 && strpos($mail,'@') > 64) return false;
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $mail)) ? false : strtolower($mail);
}
/*======================================================================*\
Function: IpCode
Output: String, Example 255025502550255
Input: -
Descriiption: Возвращает IP с замененными знаками "." на "0"
\*======================================================================*/
public function IpCode(){
$arr_mask = explode(".",$this->GetUserIp());
return $arr_mask[0].".".$arr_mask[1].".".$arr_mask[2].".0";
}
/*======================================================================*\
Function: GetTime
Descriiption: Возвращаер дату
\*======================================================================*/
public function GetTime($tis = 0, $unix = true, $template = "d.m.Y H:i:s"){
if($tis == 0){
return ($unix) ? time() : date($template,time());
}else return date($template,$unix);
}
/*======================================================================*\
Function: UserAgent
Descriiption: Возвращает браузер пользователя
\*======================================================================*/
public function UserAgent(){
return $this->TextClean($_SERVER['HTTP_USER_AGENT']);
}
/*======================================================================*\
Function: TextClean
Descriiption: Очистка текста
\*======================================================================*/
public function TextClean($text){
$array_find = array("`", "<", ">", "^", '"', "~", "\\");
$array_replace = array("`", "<", ">", "ˆ", """, "˜", "");
return str_replace($array_find, $array_replace, $text);
}
/*======================================================================*\
Function: ShowError
Descriiption: Выводит список ошибок строкой
\*======================================================================*/
public function ShowError($errorArray = array(), $title = "Исправьте следующие ошибки"){
if(count($errorArray) > 0){
$string_a = "<div class='Error'><div class='ErrorTitle'>".$title."</div><ul>";
foreach($errorArray as $number => $value){
$string_a .= "<li>".($number+1)." - ".$value."</li>";
}
$string_a .= "</ul></div><BR />";
return $string_a;
}else return "Неизвестная ошибка :(";
}
/*======================================================================*\
Function: ComissionWm
Descriiption: Возвращает комиссию WM
\*======================================================================*/
public function ComissionWm($sum, $com_payee, $com_payysys){
$a = ceil(ceil($sum * $com_payee * 100) / 10000*100) / 100;
$b = ceil(ceil($sum * str_replace("%","",$com_payysys) * 100) / 10000*100) / 100;
return $a+$b;
}
/*======================================================================*\
Function: md5Password
Descriiption: Возвращает md5_пароля
\*======================================================================*/
public function md5Password($pass){
$pass = strtolower($pass);
return md5("shark_md5"."-".$pass);
}
/*======================================================================*\
Function: ControlCode
Descriiption: Возвращает контрольное число
\*======================================================================*/
public function ControlCode($time = 0){
return ($time > 0) ? date("Ymd", $time) : date("Ymd");
}
/*======================================================================*\
Function: SumCalc
Descriiption: Возвращает сумму овощей
\*======================================================================*/
public function SumCalc($per_h, $sum_tree, $last_sbor){
if($last_sbor > 0){
if($sum_tree > 0 AND $per_h > 0){
$last_sbor = ($last_sbor < time()) ? (time() - $last_sbor) : 0;
$per_sec = $per_h / 3600;
return round( ($per_sec * $sum_tree) * $last_sbor);
}else return 0;
}else return 0;
}
/*======================================================================*\
Function: SellItems
Descriiption: Выводит сумму и остаток
\*======================================================================*/
public function SellItems($all_items, $for_one_coin){
if($all_items <= 0 OR $for_one_coin <= 0) return 0;
return sprintf("%.2f", ($all_items / $for_one_coin));
}
}
?>