Guest User

Untitled

a guest
Apr 10th, 2022
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 30.48 KB | None | 0 0
  1. <?php
  2.     header('Content-Type: text/html; charset=utf-8');
  3.     define('INCLUDE_CHECK',true);
  4.     if(isset ($_POST['action'])) {
  5.         include("connect.php");
  6.         include_once("loger.php");
  7.         include_once("uuid.php");
  8.         $x  = $_POST['action'];
  9.         $x = str_replace(" ", "+", $x);
  10.         $yd = Security::decrypt($x, $key2);
  11.         if($yd==null) {
  12.             echo 'errorlauncher';
  13.             exit;
  14.         }
  15.         @list($action, $client, $login, $postPass, $launchermd5, $ctoken) = explode(':', $yd);
  16.     } else {
  17.         exit;
  18.     }
  19.  
  20.     try {
  21.        
  22.     if (!preg_match("/^[a-zA-Z0-9_-]+$/", $login) || !preg_match("/^[a-zA-Z0-9_-]+$/", $postPass) || !preg_match("/^[a-zA-Z0-9_-]+$/", $action)) {
  23.    
  24.         exit(Security::encrypt("errorLogin<$>", $key1));
  25.     }
  26.     if(!file_exists($uploaddirs)) die ("Путь к скинам не является папкой! Укажите в настройках правильный путь.");
  27.     if(!file_exists($uploaddirp)) die ("Путь к плащам не является папкой! Укажите в настройках правильный путь.");
  28.    
  29.  
  30.     if($ctoken == "null") {
  31.  
  32.  
  33.     if($crypt === 'hash_md5' || $crypt === 'hash_authme' || $crypt === 'hash_xauth' || $crypt === 'hash_cauth' || $crypt === 'hash_joomla' || $crypt === 'hash_joomla_new' || $crypt === 'hash_wordpress' || $crypt === 'hash_dle' || $crypt === 'hash_launcher' || $crypt === 'hash_drupal' || $crypt === 'hash_smf' || $crypt === 'hash_imagecms') {
  34.         $stmt = $db->prepare("SELECT $db_columnUser,$db_columnPass FROM $db_table WHERE BINARY $db_columnUser= :login");
  35.         $stmt->bindValue(':login', $login);
  36.         $stmt->execute();
  37.         $stmt->bindColumn($db_columnPass, $realPass);
  38.         $stmt->bindColumn($db_columnUser, $realUser);
  39.         $stmt->fetch();
  40.         if($crypt === 'hash_smf')
  41.         $salt = $realUser;
  42.     } else if ($crypt === 'hash_ipb' || $crypt === 'hash_vbulletin' || $crypt === 'hash_punbb') {
  43.        
  44.         $stmt = $db->prepare("SELECT $db_columnUser,$db_columnPass,$db_columnSalt FROM $db_table WHERE BINARY $db_columnUser= :login");
  45.         $stmt->bindValue(':login', $login);
  46.         $stmt->execute();
  47.         $stmt->bindColumn($db_columnPass, $realPass);
  48.         $stmt->bindColumn($db_columnSalt, $salt);
  49.         $stmt->bindColumn($db_columnUser, $realUser);
  50.         $stmt->fetch();
  51.     } else if($crypt == 'hash_xenforo') {
  52.  
  53.         $stmt = $db->prepare("SELECT scheme_class, $db_table.$db_columnId,$db_table.$db_columnUser,$db_tableOther.$db_columnId,$db_tableOther.$db_columnPass FROM $db_table, $db_tableOther WHERE BINARY $db_table.$db_columnId = $db_tableOther.$db_columnId AND $db_table.$db_columnUser= :login");
  54.         $stmt->bindValue(':login', $login);
  55.         $stmt->execute();
  56.         $stmt->bindColumn($db_columnUser, $realUser);
  57.         $stmt->bindColumn($db_columnPass, $rPass);
  58.         $stmt->bindColumn('scheme_class', $scheme_class);
  59.         $stmt->fetch();
  60.         $pass = unserialize($rPass);
  61.         $realPass = $pass['hash'];
  62.         if($scheme_class==='XenForo_Authentication_Core') {
  63.             $salt = $pass['salt'];
  64.         } else $salt = false;
  65.     } else die(Security::encrypt("badhash<$>", $key1));
  66.  
  67.     $checkPass = hash_name($crypt, $realPass, $postPass, @$salt);
  68.  
  69.     if($useantibrut) {
  70.         $ip  = getenv('REMOTE_ADDR');  
  71.         $time = time();
  72.         $bantime = $time+(10);
  73.         $stmt = $db->prepare("Select sip,time From sip Where sip='$ip' And time>'$time'");
  74.         $stmt->execute();
  75.         $row = $stmt->fetch(PDO::FETCH_ASSOC);
  76.         $real = $row['sip'];
  77.         if($ip == $real) {
  78.             $stmt = $db->prepare("DELETE FROM sip WHERE time < '$time';");
  79.             $stmt->execute();
  80.             exit(Security::encrypt("temp<$>", $key1));
  81.         }
  82.        
  83.         if ($login != $realUser) {
  84.             $stmt = $db->prepare("INSERT INTO sip (sip, time)VALUES ('$ip', '$bantime')");
  85.             $stmt->execute();
  86.             exit(Security::encrypt("errorLogin<$>", $key1));
  87.         }
  88.         if(!strcmp($realPass,$checkPass) == 0 || !$realPass) {
  89.             $stmt = $db->prepare("INSERT INTO sip (sip, time)VALUES ('$ip', '$bantime')");
  90.             $stmt->execute();
  91.             exit(Security::encrypt("errorLogin<$>", $key1));
  92.         }
  93.  
  94.     } else {
  95.         if($checkPass !=  $realPass)  die(Security::encrypt('errorLogin<$>', $key1));
  96.     }}
  97.  
  98.         if($ctoken == "null") {
  99.             $acesstoken = token();
  100.         } else {
  101.             $acesstoken = $postPass;
  102.         }
  103.         $sessid = token();
  104.         $stmt = $db->prepare("SELECT user, token FROM usersession WHERE user= :login");
  105.         $stmt->bindValue(':login', $login);
  106.         $stmt->execute();
  107.         $rU = $stmt->fetch(PDO::FETCH_ASSOC);
  108.         if($rU['user'] != null) {
  109.             $realUser = $rU['user'];
  110.         }
  111.  
  112.         if($ctoken != "null") {
  113.  
  114.             if($rU['token'] != $acesstoken || $login != $realUser) {
  115.                 exit(Security::encrypt("errorLogin<$>", $key1));
  116.             }
  117.         }
  118.         if($login == $rU['user']) {
  119.             if($ctoken == "null") {
  120.                 $stmt = $db->prepare("UPDATE usersession SET session = '$sessid', token = :token WHERE user= :login");
  121.                 $stmt->bindValue(':token', $acesstoken);
  122.             }
  123.             else {
  124.                 $stmt = $db->prepare("UPDATE usersession SET session = '$sessid' WHERE user= :login");
  125.             }
  126.             $stmt->bindValue(':login', $login);
  127.             $stmt->execute();
  128.         }
  129.         else if($ctoken == "null" || $login != $rU['user']) {
  130.             $stmt = $db->prepare("INSERT INTO usersession (user, session, md5, token) VALUES (:login, '$sessid', :md5, '$acesstoken')");
  131.             $stmt->bindValue(':login', $realUser);
  132.             $stmt->bindValue(':md5', str_replace('-', '', uuidConvert($realUser)));
  133.             $stmt->execute();
  134.         }
  135.    
  136.     if($useban) {
  137.         $time = time();
  138.         $tipe = '2';
  139.         $stmt = $db->prepare("Select name From $banlist Where name= :login And type<'$tipe' And temptime>'$time'");
  140.         $stmt->bindValue(':login', $login);
  141.         $stmt->execute();
  142.         if($stmt->rowCount()) {
  143.             $stmt = $db->prepare("Select name,temptime From $banlist Where name= :login And type<'$tipe' And temptime>'$time'");
  144.             $stmt->bindValue(':login', $login);
  145.             $stmt->execute();
  146.             $row = $stmt->fetch(PDO::FETCH_ASSOC);
  147.             exit(Security::encrypt('Временный бан до '.date('d.m.Yг. H:i', $row['temptime'])." по времени сервера", $key1));
  148.         }
  149.             $stmt = $db->prepare("Select name From $banlist Where name= :login And type<'$tipe' And temptime='0'");
  150.             $stmt->bindValue(':login', $login);
  151.             $stmt->execute();
  152.         if($stmt->rowCount()) {
  153.           exit(Security::encrypt("Вечный бан", $key1));
  154.         }
  155.     }
  156.     if($action == 'getpersonal' && !$usePersonal) die("Использование ЛК выключено");
  157.     if($action == 'uploadskin' && !$canUploadSkin) die("Функция недоступна");
  158.     if($action == 'uploadcloak' && !$canUploadCloak) die("Функция недоступна");
  159.     if($action == 'buyvip' && !$canBuyVip) die("Функция недоступна");
  160.     if($action == 'buypremium' && !$canBuyPremium) die("Функция недоступна");
  161.     if($action == 'buyunban' && !$canBuyUnban) die("Функция недоступна");
  162.     if($action == 'exchange' && !$canExchangeMoney) die("Функция недоступна");
  163.     if($action == 'activatekey' && !$canActivateVaucher) die("Функция недоступна");
  164.  
  165.     if($action == 'exchange' || $action == 'getpersonal') {
  166.             $stmt = $db->prepare("SELECT username,balance FROM iConomy WHERE username= :login");
  167.             $stmt->bindValue(':login', $login);
  168.             $stmt->execute();
  169.             $rowicon = $stmt->fetch(PDO::FETCH_ASSOC);
  170.             $iconregistered = true;
  171.        
  172.         if(!$rowicon['balance']) {
  173.             $stmt = $db->prepare("INSERT INTO `iConomy` (`username`, `balance`, `status`) VALUES (:login, '$initialIconMoney.00', '0');");
  174.             $stmt->bindValue(':login', $login);
  175.             $stmt->execute();
  176.             $iconregistered = false;
  177.         }
  178.     }
  179.    
  180.     if($action == 'auth') {
  181.  
  182.     if($checklauncher) {
  183.     if($launchermd5 != null) {
  184.     if($launchermd5 == @$md5launcherexe) {
  185.             $check = "1";
  186.             }
  187.             if($launchermd5 == @$md5launcherjar) {
  188.                $check = "1";
  189.             }
  190.         }
  191.         if(!@$check == "1") {
  192.             exit(Security::encrypt("badlauncher<$>_$masterversion", $key1));
  193.         }
  194.     }
  195.  
  196.         if($assetsfolder)
  197.         { $z = "/"; } else { $z = ".zip"; }
  198.  
  199.         if(
  200.         !file_exists("clients/assets".$z)||
  201.         !file_exists("clients/".$client."/bin/")||
  202.         !file_exists("clients/".$client."/mods/")||
  203.         !file_exists("clients/".$client."/coremods/")||
  204.         !file_exists("clients/".$client."/natives/")||
  205.         !file_exists("clients/".$client."/config.zip")
  206.         )
  207.         die(Security::encrypt("client<$> $client", $key1));
  208.  
  209.         $md5user  = strtoint(xorencode(str_replace('-', '', uuidConvert($realUser)), $protectionKey));
  210.         $md5zip   = @md5_file("clients/".$client."/config.zip");
  211.         $md5ass   = @md5_file("clients/assets.zip");
  212.         $sizezip  = @filesize("clients/".$client."/config.zip");
  213.         $sizeass  = @filesize("clients/assets.zip");
  214.         $usrsessions = "$masterversion<:>$md5user<:>".$md5zip."<>".$sizezip."<:>".$md5ass."<>".$sizeass."<br>".$realUser.'<:>'.strtoint(xorencode($sessid, $protectionKey)).'<br>'.$acesstoken.'<br>';
  215.  
  216.         function hashc($assetsfolder,$client) {
  217.             if($assetsfolder) {
  218.                 $hash_md5    = str_replace("\\", "/",checkfiles('clients/'.$client.'/bin/').checkfiles('clients/'.$client.'/mods/').checkfiles('clients/'.$client.'/coremods/').checkfiles('clients/'.$client.'/natives/').checkfiles('clients/assets')).'<::>assets/indexes<:b:>assets/objects<:b:>assets/virtual<:b:>'.$client.'/bin<:b:>'.$client.'/mods<:b:>'.$client.'/coremods<:b:>'.$client.'/natives<:b:>';
  219.             } else {
  220.                 $hash_md5    = str_replace("\\", "/",checkfiles('clients/'.$client.'/bin/').checkfiles('clients/'.$client.'/mods/').checkfiles('clients/'.$client.'/coremods/').checkfiles('clients/'.$client.'/natives/')).'<::>'.$client.'/bin<:b:>'.$client.'/mods<:b:>'.$client.'/coremods<:b:>'.$client.'/natives<:b:>';
  221.             }
  222.             return $hash_md5;
  223.         }
  224.  
  225.         if($temp) {
  226.             $filecashe = 'temp/'.$client;
  227.             if (file_exists($filecashe)) {
  228.                  $fp = fopen($filecashe, "r");
  229.                  $hash_md5 = fgets($fp);
  230.                  fclose($fp);
  231.             } else {
  232.                 $hash_md5 = hashc($assetsfolder,$client);
  233.                 $fp = fopen($filecashe, "w");
  234.                 fwrite($fp, $hash_md5);
  235.                 fclose($fp);
  236.             }
  237.         } else {
  238.             $hash_md5 = hashc($assetsfolder,$client);
  239.         }
  240.  
  241.         echo Security::encrypt($usrsessions.$hash_md5, $key1);
  242.  
  243.  
  244.     } else if($action == 'getpersonal') {
  245.         $stmt = $db->prepare("SELECT user,realmoney FROM usersession WHERE user= :login");
  246.         $stmt->bindValue(':login', $login);
  247.         $stmt->execute();
  248.         $row = $stmt->fetch(PDO::FETCH_ASSOC);
  249.         $realmoney = $row['realmoney'];
  250.  
  251.         if($iconregistered) {  
  252.             $stmt = $db->prepare("SELECT username,balance FROM iConomy WHERE username= :login");
  253.             $stmt->bindValue(':login', $login);
  254.             $stmt->execute();
  255.             $row = $stmt->fetch(PDO::FETCH_ASSOC);
  256.             $iconmoney = $row['balance'];
  257.         } else $iconmoney = "0.0";
  258.        
  259.         if($canBuyVip || $canBuyPremium) {
  260.            
  261.             $stmt = $db->prepare("SELECT name,permission,value FROM permissions WHERE name= :login");
  262.             $stmt->bindValue(':login', $login);
  263.             $stmt->execute();
  264.             $row = $stmt->fetch(PDO::FETCH_ASSOC);
  265.             $datetoexpire = 0;
  266.             if(!$stmt) $ugroup = 'User'; else {
  267.                 $group = $row['permission'];
  268.                 if($group == 'group-premium-until')
  269.                 {
  270.                     $ugroup = 'Premium';
  271.                     $datetoexpire = $row['value'];
  272.                 } else if($group == 'group-vip-until')
  273.                 {
  274.                     $ugroup = 'VIP';
  275.                     $datetoexpire = $row['value'];
  276.                 } else $ugroup = 'User';
  277.             }
  278.         } else {
  279.             $datetoexpire = 0;
  280.             $ugroup = 'User';
  281.         }
  282.    
  283.         if($canUseJobs) {
  284.             $stmt = $db->prepare("SELECT job FROM jobs WHERE username= :login");
  285.             $stmt->bindValue(':login', $login);
  286.             $stmt->execute();
  287.             $sql = $stmt->fetch(PDO::FETCH_ASSOC);
  288.             $query = $sql['job'];
  289.             if($query == '') { $jobname = "Безработный"; $joblvl = 0; $jobexp = 0; } else {
  290.                 $stmt = $db->prepare("SELECT * FROM jobs WHERE username= :login");
  291.                 $stmt->bindValue(':login', $login);
  292.                 $stmt->execute();
  293.                
  294.                 while($data = $stmt->fetch(PDO::FETCH_ASSOC))
  295.                 {
  296.                     if ($data["job"] === 'Miner') $data["job"] = 'Шахтер';
  297.                     if ($data["job"] === 'Woodcooter') $data["job"] = 'Лесоруб';
  298.                     if ($data["job"] === 'Builder') $data["job"] = 'Строитель';
  299.                     if ($data["job"] === 'Digger') $data["job"] = 'Дигер';
  300.                     if ($data["job"] === 'Farmer') $data["job"] = 'Фермер';
  301.                     if ($data["job"] === 'Hunter') $data["job"] = 'Охотник';
  302.                     if ($data["job"] === 'Fisherman') $data["job"] = 'Рыбак';
  303.                     if ($data["job"] === 'Weaponsmith') $data["job"] = 'Оружейник';
  304.                    
  305.                     $jobname = $data['job'];
  306.                     $joblvl = $data["level"];
  307.                     $jobexp = $data["experience"];
  308.                 }
  309.             }
  310.         } else { $jobname = "nojob"; $joblvl = -1; $jobexp = -1; }
  311.        
  312.         $canUploadSkin      = (int)$canUploadSkin;
  313.         $canUploadCloak     = (int)$canUploadCloak;
  314.         $canBuyVip          = (int)$canBuyVip;
  315.         $canBuyPremium      = (int)$canBuyPremium;
  316.         $canBuyUnban        = (int)$canBuyUnban;
  317.         $canActivateVaucher = (int)$canActivateVaucher;
  318.         $canExchangeMoney   = (int)$canExchangeMoney;
  319.    
  320.         if($canBuyUnban == 1) {
  321.             $ty = 2;
  322.             $stmt = $db->prepare("SELECT name,type FROM $banlist WHERE name= :login and type<'$ty'");
  323.             $stmt->bindValue(':login', $login);
  324.             $stmt->execute();
  325.             $sql2 = $stmt->fetch(PDO::FETCH_ASSOC);
  326.             $query2 = $sql2['name'];
  327.             if(strcasecmp($query2, $login) == 0) $ugroup = "Banned";
  328.         }
  329.        
  330.         echo "$canUploadSkin$canUploadCloak$canBuyVip$canBuyPremium$canBuyUnban$canActivateVaucher$canExchangeMoney<:>$iconmoney<:>$realmoney<:>$cloakPrice<:>$vipPrice<:>$premiumPrice<:>$unbanPrice<:>$exchangeRate<:>$ugroup<:>$datetoexpire<:>$jobname<:>$joblvl<:>$jobexp";
  331.     } else
  332. //============================================Функции ЛК====================================//
  333.  
  334.     if($action == 'activatekey') {
  335.         $key = $_POST['key'];
  336.         $stmt = $db->prepare("SELECT * FROM `sashok724_launcher_keys` WHERE `key` = :k");
  337.         $stmt->bindValue(':k', $key);
  338.         $stmt->execute();
  339.         $row = $stmt->fetch(PDO::FETCH_ASSOC);
  340.         $amount = $row['amount'];
  341.         if($amount) {
  342.             $stmt = $db->prepare("UPDATE usersession SET realmoney = realmoney + $amount WHERE user= :login");
  343.             $stmt->bindValue(':login', $login);
  344.             $stmt->execute();
  345.             $stmt = $db->prepare("DELETE FROM `sashok724_launcher_keys` WHERE `key` = :k");
  346.             $stmt->bindValue(':k', $key);
  347.             $stmt->execute();  
  348.             $stmt = $db->prepare("SELECT user,realmoney FROM usersession WHERE user= :login");
  349.             $stmt->bindValue(':login', $login);
  350.             $stmt->execute();
  351.             $row = $stmt->fetch(PDO::FETCH_ASSOC); 
  352.             $money = $row['realmoney'];
  353.             echo "success:".$money;
  354.         } else echo "keyerr";
  355.     } else if($action == 'uploadskin') {
  356.         $sk = base64_decode($_POST['ufile']);
  357.         if($sk==null) die("nofile");
  358.         $image = imagecreatefromstring($sk);
  359.         if(imagestype($sk) != 'image/png' || imagesx($image) != '64' || imagesy($image) != '32') die("skinerr");
  360.         imagesavealpha($image, true);
  361.         $uploadfile = "".$uploaddirs."/".$login.".png";
  362.         if(imagepng($image,$uploadfile)) echo "success";
  363.         else exit("fileerr");
  364.     } else if($action == 'uploadcloak') {
  365.         $stmt = $db->prepare("SELECT user,realmoney FROM usersession WHERE user= :login");
  366.         $stmt->bindValue(':login', $login);
  367.         $stmt->execute();
  368.         $row = $stmt->fetch(PDO::FETCH_ASSOC);
  369.         $query = $row['realmoney']; if($query < $cloakPrice) die("moneyno");
  370.         $sk = base64_decode($_POST['ufile']);
  371.         if($sk==null) die("nofile");
  372.         $image = imagecreatefromstring($sk);
  373.         if(imagestype($sk) != 'image/png' || imagesx($image) != '64' || imagesy($image) != '32') die("cloakerr");
  374.         imagesavealpha($image, true);
  375.         $uploadfile = "".$uploaddirp."/".$login.".png";
  376.         if(imagepng($image,$uploadfile));
  377.         else exit("fileerr");
  378.         $stmt = $db->prepare("UPDATE usersession SET realmoney = realmoney - $cloakPrice WHERE user= :login");
  379.         $stmt->bindValue(':login', $login);
  380.         $stmt->execute();
  381.         $stmt = $db->prepare("SELECT user,realmoney FROM usersession WHERE user= :login");
  382.         $stmt->bindValue(':login', $login);
  383.         $stmt->execute();
  384.         $row = $stmt->fetch(PDO::FETCH_ASSOC);
  385.         echo "success:".$row['realmoney'];
  386.     } else if($action == 'buyvip') {
  387.         $stmt = $db->prepare("SELECT user,realmoney FROM usersession WHERE user= :login");
  388.         $stmt->bindValue(':login', $login);
  389.         $stmt->execute();
  390.         $row = $stmt->fetch(PDO::FETCH_ASSOC);
  391.         $query = $row['realmoney']; if($query < $vipPrice) die("moneyno");
  392.         $stmt = $db->prepare("SELECT name,permission FROM permissions WHERE name= :login");
  393.         $stmt->bindValue(':login', $login);
  394.         $stmt->execute();
  395.         $row = $stmt->fetch(PDO::FETCH_ASSOC);
  396.         $group = $row['permission'];
  397.         $pexdate = time() + 2678400;
  398.         if($group == 'group-vip-until') {  
  399.             $stmt = $db->prepare("UPDATE usersession SET realmoney=realmoney-$vipPrice WHERE user= :login");
  400.             $stmt->bindValue(':login', $login);
  401.             $stmt->execute();
  402.             $stmt = $db->prepare("UPDATE permissions SET value=value+2678400 WHERE name= :login");
  403.             $stmt->bindValue(':login', $login);
  404.             $stmt->execute();
  405.         } else {
  406.             $stmt = $db->prepare("INSERT INTO permissions (id, name, type, permission, world, value) VALUES (NULL, :login, '1', 'group-vip-until', ' ', '$pexdate')");
  407.             $stmt->bindValue(':login', $login);
  408.             $stmt->execute();  
  409.             $stmt = $db->prepare("INSERT INTO permissions_inheritance (id, child, parent, type, world) VALUES (NULL, :login, 'vip', '1', NULL)");
  410.             $stmt->bindValue(':login', $login);
  411.             $stmt->execute();
  412.             $stmt = $db->prepare("UPDATE usersession SET realmoney=realmoney-$vipPrice WHERE user= :login");
  413.             $stmt->bindValue(':login', $login);
  414.             $stmt->execute();
  415.         }
  416.             $stmt = $db->prepare("SELECT user,realmoney FROM usersession WHERE user= :login");
  417.             $stmt->bindValue(':login', $login);
  418.             $stmt->execute();
  419.             $row = $stmt->fetch(PDO::FETCH_ASSOC);
  420.             echo "success:".$row['realmoney'].":";
  421.             $stmt = $db->prepare("SELECT name,permission,value FROM permissions WHERE name= :login");
  422.             $stmt->bindValue(':login', $login);
  423.             $stmt->execute();
  424.             $row = $stmt->fetch(PDO::FETCH_ASSOC);
  425.             echo $row['value'];
  426.     } else if($action == 'buypremium') {
  427.         $stmt = $db->prepare("SELECT user,realmoney FROM usersession WHERE user= :login");
  428.         $stmt->bindValue(':login', $login);
  429.         $stmt->execute();
  430.         $row = $stmt->fetch(PDO::FETCH_ASSOC);
  431.         $query = $row['realmoney']; if($query < $premiumPrice) die("moneyno");
  432.         $stmt = $db->prepare("SELECT name,permission FROM permissions WHERE name= :login");
  433.         $stmt->bindValue(':login', $login);
  434.         $stmt->execute();
  435.         $row = $stmt->fetch(PDO::FETCH_ASSOC);
  436.         $group = $row['permission'];
  437.         $pexdate = time() + 2678400;
  438.         if($group == 'group-premium-until') {
  439.             $stmt = $db->prepare("UPDATE usersession SET realmoney=realmoney-$premiumPrice WHERE user= :login");
  440.             $stmt->bindValue(':login', $login);
  441.             $stmt->execute();
  442.             $stmt = $db->prepare("UPDATE permissions SET value=value+2678400 WHERE name= :login");
  443.             $stmt->bindValue(':login', $login);
  444.             $stmt->execute();
  445.         } else {
  446.             $stmt = $db->prepare("INSERT INTO permissions (id, name, type, permission, world, value) VALUES (NULL, :login, '1', 'group-premium-until', ' ', '$pexdate')");
  447.             $stmt->bindValue(':login', $login);
  448.             $stmt->execute();
  449.             $stmt = $db->prepare("INSERT INTO permissions_inheritance (id, child, parent, type, world) VALUES (NULL, :login, 'premium', '1', NULL)");
  450.             $stmt->bindValue(':login', $login);
  451.             $stmt->execute();
  452.             $stmt = $db->prepare("UPDATE usersession SET realmoney=realmoney-$premiumPrice WHERE user= :login");
  453.             $stmt->bindValue(':login', $login);
  454.             $stmt->execute();
  455.         }
  456.             $stmt = $db->prepare("SELECT user,realmoney FROM usersession WHERE user= :login");
  457.             $stmt->bindValue(':login', $login);
  458.             $stmt->execute();
  459.             $row = $stmt->fetch(PDO::FETCH_ASSOC);
  460.             echo "success:".$row['realmoney'].":";
  461.             $stmt = $db->prepare("SELECT name,permission,value FROM permissions WHERE name= :login");
  462.             $stmt->bindValue(':login', $login);
  463.             $stmt->execute();
  464.             $row = $stmt->fetch(PDO::FETCH_ASSOC);
  465.             echo $row['value'];
  466.     } else if($action == 'buyunban') {
  467.         $stmt = $db->prepare("SELECT user,realmoney FROM usersession WHERE user= :login");
  468.         $stmt->bindValue(':login', $login);
  469.         $stmt->execute();
  470.         $sql1 = $stmt->fetch(PDO::FETCH_ASSOC);
  471.         $query1 = $sql1['realmoney'];
  472.         $stmt = $db->prepare("SELECT name FROM $banlist WHERE name= :login");
  473.         $stmt->bindValue(':login', $login);
  474.         $stmt->execute();
  475.         $sql2 = $stmt->fetch(PDO::FETCH_ASSOC);
  476.         $query2 = $sql2['name'];
  477.         if(strcasecmp($query2, $login) == 0) {
  478.             if($query1 >= $unbanPrice) {
  479.                 if($canBuyVip || $canBuyPremium) {
  480.                     $stmt = $db->prepare("SELECT name,permission,value FROM permissions WHERE name= :login");
  481.                     $stmt->bindValue(':login', $login);
  482.                     $stmt->execute();
  483.                     $row = $stmt->fetch(PDO::FETCH_ASSOC);
  484.                     $group = $row['permission'];
  485.                     if(!$stmt) $ugroup = 'User'; else {
  486.                         if($group == 'group-premium-until') $ugroup = 'Premium';
  487.                         else if($group == 'group-vip-until') $ugroup = 'VIP';
  488.                         else $ugroup = 'User';
  489.                     }
  490.                 } else $ugroup = 'User';
  491.                     $stmt = $db->prepare("DELETE FROM $banlist WHERE name= :login");
  492.                     $stmt->bindValue(':login', $login);
  493.                     $stmt->execute();
  494.                     $stmt = $db->prepare("UPDATE usersession SET realmoney=realmoney-$unbanPrice WHERE user= :login");
  495.                     $stmt->bindValue(':login', $login);
  496.                     $stmt->execute();
  497.                     $stmt = $db->prepare("SELECT $db_columnUser,realmoney FROM usersession WHERE user= :login");
  498.                     $stmt->bindValue(':login', $login);
  499.                     $stmt->execute();
  500.                     $row = $stmt->fetch(PDO::FETCH_ASSOC);
  501.                 echo "success:".$row['realmoney'].":".$ugroup;
  502.             } else die('moneyno');
  503.         } else die("banno");
  504.     } else if($action == 'exchange') {
  505.         $wantbuy =$_POST ['buy'];
  506.         $gamemoneyadd = ($wantbuy * $exchangeRate);
  507.         $stmt = $db->prepare("SELECT user,realmoney FROM usersession WHERE user= :login");
  508.         $stmt->bindValue(':login', $login);
  509.         $stmt->execute();
  510.         $row = $stmt->fetch(PDO::FETCH_ASSOC);
  511.         $query = $row['realmoney'];
  512.         if($wantbuy == '' || $wantbuy < 1) die("ecoerr");
  513.         if(!$iconregistered) die("econo");
  514.         if($query < $wantbuy) die("moneyno");
  515.         $stmt = $db->prepare("UPDATE iConomy SET balance = balance + :gamemoneyadd WHERE username= :login");
  516.         $stmt->bindValue(':login', $login);
  517.         $stmt->bindValue(':gamemoneyadd', $gamemoneyadd);
  518.         $stmt->execute();
  519.         $stmt = $db->prepare("UPDATE usersession SET realmoney = realmoney - :wantbuy WHERE user= :login");
  520.         $stmt->bindValue(':login', $login);
  521.         $stmt->bindValue(':wantbuy', $wantbuy);
  522.         $stmt->execute();
  523.         $stmt = $db->prepare("SELECT user,realmoney FROM usersession WHERE user= :login");
  524.         $stmt->bindValue(':login', $login);
  525.         $stmt->execute();
  526.         $row = $stmt->fetch(PDO::FETCH_ASSOC);
  527.         $money = $row['realmoney'];
  528.         $stmt = $db->prepare("SELECT username,balance FROM iConomy WHERE username= :login");
  529.         $stmt->bindValue(':login', $login);
  530.         $stmt->execute();
  531.         $row = $stmt->fetch(PDO::FETCH_ASSOC);
  532.         $iconmoney = $row['balance'];
  533.         echo "success:".$money.":".$iconmoney;
  534.     } else echo "Запрос составлен неверно";
  535.    
  536.     } catch(PDOException $pe) {
  537.         die(Security::encrypt("errorsql<$>", $key1).$logger->WriteLine($log_date.$pe));  //вывод ошибок MySQL в m.log
  538.     }
  539.     //===================================== Вспомогательные функции ==================================//
  540.  
  541.     function xorencode($str, $key) {
  542.         while(strlen($key) < strlen($str)) {
  543.             $key .= $key;
  544.         }
  545.         return $str ^ $key;
  546.     }
  547.  
  548.     function strtoint($text) {
  549.         $res = "";
  550.         for ($i = 0; $i < strlen($text); $i++) $res .= ord($text{$i}) . "-";
  551.         $res = substr($res, 0, -1);
  552.         return $res;
  553.     }
  554.  
  555.     function strlen_8bit($binary_string) {
  556.         if (function_exists('mb_strlen')) {
  557.             return mb_strlen($binary_string, '8bit');
  558.         }
  559.         return strlen($binary_string);
  560.     }
  561.    
  562.     function substr_8bit($binary_string, $start, $length) {
  563.         if (function_exists('mb_substr')) {
  564.             return mb_substr($binary_string, $start, $length, '8bit');
  565.         }
  566.         return substr($binary_string, $start, $length);
  567.     }
  568.    
  569.     function pass_get_info($hash) {
  570.         $return = true;
  571.         if (substr_8bit($hash, 0, 4) == '$2y$' && strlen_8bit($hash) == 60) {
  572.             $return = false;
  573.         }
  574.         return $return;
  575.     }
  576.    
  577.     function pass_verify($password, $hash) {
  578.         $ret = crypt($password, $hash);
  579.        
  580.         if (!is_string($ret) || strlen_8bit($ret) != strlen_8bit($hash) || strlen_8bit($ret) <= 13) {
  581.             return false;
  582.         }
  583.         $status = 0;
  584.         for ($i = 0; $i < strlen_8bit($ret); $i++) {
  585.             $status |= (ord($ret[$i]) ^ ord($hash[$i]));
  586.         }
  587.         return $status === 0;
  588.     }
  589.    
  590.     function hash_name($ncrypt, $realPass, $postPass, $salt) {
  591.         $cryptPass = false;
  592.        
  593.         if ($ncrypt === 'hash_xauth') {
  594.                 $saltPos = (strlen($postPass) >= strlen($realPass) ? strlen($realPass) : strlen($postPass));
  595.                 $salt = substr($realPass, $saltPos, 12);
  596.                 $hash = hash('whirlpool', $salt . $postPass);
  597.                 $cryptPass = substr($hash, 0, $saltPos) . $salt . substr($hash, $saltPos);
  598.         }
  599.  
  600.         if ($ncrypt === 'hash_md5' or $ncrypt === 'hash_launcher') {
  601.                 $cryptPass = md5($postPass);
  602.         }
  603.  
  604.         if ($ncrypt === 'hash_dle') {
  605.             if(pass_get_info($realPass)) {
  606.                 $cryptPass = md5(md5($postPass));
  607.             } else {
  608.                 if(pass_verify($postPass, $realPass)) {
  609.                     $cryptPass = $realPass;
  610.                 } else {
  611.                     $cryptPass = "0";
  612.                 }
  613.             }
  614.         }
  615.  
  616.         if ($ncrypt === 'hash_cauth') {
  617.                 if (strlen($realPass) < 32) {
  618.                         $cryptPass = md5($postPass);
  619.                         $rp = str_replace('0', '', $realPass);
  620.                         $cp = str_replace('0', '', $cryptPass);
  621.                         (strcasecmp($rp,$cp) == 0 ? $cryptPass = $realPass : $cryptPass = false);
  622.                 }
  623.                 else $cryptPass = md5($postPass);
  624.         }
  625.  
  626.         if ($ncrypt === 'hash_authme') {
  627.                 $ar = preg_split("/\\$/",$realPass);
  628.                 $salt = $ar[2];
  629.                 $cryptPass = '$SHA$'.$salt.'$'.hash('sha256',hash('sha256',$postPass).$salt);
  630.         }
  631.  
  632.         if ($ncrypt === 'hash_joomla') {
  633.                 $parts = explode( ':', $realPass);
  634.                 $salt = $parts[1];
  635.                 $cryptPass = md5($postPass . $salt) . ":" . $salt;
  636.         }
  637.                
  638.         if ($ncrypt === 'hash_imagecms') {
  639.                 $majorsalt = '';
  640.                 if ($salt != '') {
  641.                     $_password = $salt . $postPass;
  642.                 } else {
  643.                     $_password = $postPass;
  644.                 }
  645.                
  646.                 $_pass = str_split($_password);
  647.                
  648.                 foreach ($_pass as $_hashpass) {
  649.                     $majorsalt .= md5($_hashpass);
  650.                 }
  651.                
  652.                 $cryptPass = crypt(md5($majorsalt), $realPass);
  653.         }
  654.  
  655.         if($ncrypt === 'hash_smf') {
  656.                 $cryptPass = sha1(strtolower($salt) . $postPass);
  657.         }
  658.  
  659.         if ($ncrypt === 'hash_joomla_new' or $ncrypt === 'hash_wordpress' or $ncrypt === 'hash_xenforo') {
  660.        
  661.                 if($ncrypt === 'hash_xenforo' and $salt!==false) {
  662.                     return $cryptPass = hash('sha256', hash('sha256', $postPass) . $salt);
  663.                 }
  664.                
  665.                 $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  666.                 $cryptPass = '*0';
  667.                 if (substr($realPass, 0, 2) == $cryptPass)
  668.                     $cryptPass = '*1';
  669.  
  670.                 $id = substr($realPass, 0, 3);
  671.                 if ($id != '$P$' && $id != '$H$')
  672.                     return $cryptPass = crypt($postPass, $realPass);
  673.  
  674.                 $count_log2 = strpos($itoa64, $realPass[3]);
  675.                 if ($count_log2 < 7 || $count_log2 > 30)
  676.                     return $cryptPass = crypt($postPass, $realPass);
  677.  
  678.                 $count = 1 << $count_log2;
  679.  
  680.                 $salt = substr($realPass, 4, 8);
  681.                 if (strlen($salt) != 8)
  682.                     return $cryptPass = crypt($postPass, $realPass);
  683.  
  684.                     $hash = md5($salt . $postPass, TRUE);
  685.                     do {
  686.                         $hash = md5($hash . $postPass, TRUE);
  687.                     } while (--$count);
  688.  
  689.                 $cryptPass = substr($realPass, 0, 12);
  690.                
  691.                 $encode64 = '';
  692.                 $i = 0;
  693.                 do {
  694.                     $value = ord($hash[$i++]);
  695.                     $encode64 .= $itoa64[$value & 0x3f];
  696.                     if ($i < 16)
  697.                         $value |= ord($hash[$i]) << 8;
  698.                     $encode64 .= $itoa64[($value >> 6) & 0x3f];
  699.                     if ($i++ >= 16)
  700.                         break;
  701.                     if ($i < 16)
  702.                         $value |= ord($hash[$i]) << 16;
  703.                     $encode64 .= $itoa64[($value >> 12) & 0x3f];
  704.                     if ($i++ >= 16)
  705.                         break;
  706.                     $encode64 .= $itoa64[($value >> 18) & 0x3f];
  707.                 } while ($i < 16);
  708.                
  709.                 $cryptPass .= $encode64;
  710.  
  711.                 if ($cryptPass[0] == '*')
  712.                     $cryptPass = crypt($postPass, $realPass);
  713.         }
  714.        
  715.         if ($ncrypt === 'hash_ipb') {
  716.                 $cryptPass = md5(md5($salt).md5($postPass));
  717.         }
  718.        
  719.         if ($ncrypt === 'hash_punbb') {
  720.                 $cryptPass = sha1($salt.sha1($postPass));
  721.         }
  722.  
  723.         if ($ncrypt === 'hash_vbulletin') {
  724.                 $cryptPass = md5(md5($postPass) . $salt);
  725.         }
  726.  
  727.         if ($ncrypt === 'hash_drupal') {
  728.                 $setting = substr($realPass, 0, 12);
  729.                 $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  730.                 $count_log2 = strpos($itoa64, $setting[3]);
  731.                 $salt = substr($setting, 4, 8);
  732.                 $count = 1 << $count_log2;
  733.                 $input = hash('sha512', $salt . $postPass, TRUE);
  734.                 do $input = hash('sha512', $input . $postPass, TRUE);
  735.                 while (--$count);
  736.  
  737.                 $count = strlen($input);
  738.                 $i = 0;
  739.          
  740.                 do {
  741.                         $value = ord($input[$i++]);
  742.                         $cryptPass .= $itoa64[$value & 0x3f];
  743.                         if ($i < $count) $value |= ord($input[$i]) << 8;
  744.                         $cryptPass .= $itoa64[($value >> 6) & 0x3f];
  745.                         if ($i++ >= $count) break;
  746.                         if ($i < $count) $value |= ord($input[$i]) << 16;
  747.                         $cryptPass .= $itoa64[($value >> 12) & 0x3f];
  748.                         if ($i++ >= $count) break;
  749.                         $cryptPass .= $itoa64[($value >> 18) & 0x3f];
  750.                 } while ($i < $count);
  751.                 $cryptPass =  $setting . $cryptPass;
  752.                 $cryptPass =  substr($cryptPass, 0, 55);
  753.         }
  754.        
  755.         return $cryptPass;
  756.     }
  757.  
  758.         function checkfiles($path) {
  759.         $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
  760.         $massive = "";
  761.             foreach($objects as $name => $object) {
  762.                 $basename = basename($name);
  763.                 $isdir = is_dir($name);
  764.                 if ($basename!="." and $basename!=".." and !is_dir($name)){
  765.                     $str = str_replace('clients/', "", str_replace($basename, "", $name));
  766.                     $massive = $massive.$str.$basename.':>'.md5_file($name).':>'.filesize($name).'<:>';
  767.                 }
  768.             }
  769.             return $massive;
  770.         }
  771.  
  772.         function token() {
  773.         $chars="0123456789abcdef";
  774.         $max=64;
  775.         $size=StrLen($chars)-1;
  776.         $password=null;
  777.         while($max--)
  778.         $password.=$chars[rand(0,$size)];
  779.           return $password;
  780.         }
  781.  
  782.     function imagestype($binary) {
  783.         if (
  784.             !preg_match(
  785.                 '/\A(?:(\xff\xd8\xff)|(GIF8[79]a)|(\x89PNG\x0d\x0a)|(BM)|(\x49\x49(?:\x2a\x00|\x00\x4a))|(FORM.{4}ILBM))/',
  786.                 $binary, $hits
  787.             )
  788.         ) {
  789.             return 'application/octet-stream';
  790.         }
  791.         static $type = array (
  792.             1 => 'image/jpeg',
  793.             2 => 'image/gif',
  794.             3 => 'image/png',
  795.             4 => 'image/x-windows-bmp',
  796.             5 => 'image/tiff',
  797.             6 => 'image/x-ilbm',
  798.         );
  799.         return $type[count($hits) - 1];
  800.     }
Add Comment
Please, Sign In to add comment