denverkurt

Encoded_decoed.php

Feb 27th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.60 KB | None | 0 0
  1. <?php
  2.  
  3. function xorcoding($text, $key, $shift = 0, $type = "")
  4. {
  5.     if ($type == "decode") {
  6.         $text = base64_decode($text);
  7.     }
  8.  
  9.     if (!is_array($shift)) {
  10.         $shift = array($shift);
  11.     }
  12.  
  13.     $v = (int) $v;
  14.     $output = "";
  15.     $klng = strlen($key);
  16.     $tlng = strlen($text);
  17.     $shlng = sizeof($shift);
  18.  
  19.     if ($type == "encode") {
  20.         $i = 0;
  21.         $j = 0;
  22.  
  23.         while ($i < $tlng) {
  24.             if ($shlng <= $j) {
  25.                 $j = 0;
  26.             }
  27.  
  28.             $code = ord($text[$i]) + $shift[$j];
  29.  
  30.             if (255 < $code) {
  31.                 $code -= 256;
  32.             }
  33.  
  34.             if ($code < 0) {
  35.                 $code += 256;
  36.             }
  37.  
  38.             $text[$i] = chr($code);
  39.             ++$i;
  40.             ++$j;
  41.         }
  42.     }
  43.  
  44.     $i = 0;
  45.     $j = 0;
  46.  
  47.     while ($i < $tlng) {
  48.         if ($klng <= $j) {
  49.             $j = 0;
  50.         }
  51.  
  52.         $output .= chr(ord($key[$j]) ^ ord($text[$i]));
  53.         ++$i;
  54.         ++$j;
  55.     }
  56.  
  57.     if ($type == "decode") {
  58.         $i = 0;
  59.         $j = 0;
  60.  
  61.         while ($i < $tlng) {
  62.             if ($shlng <= $j) {
  63.                 $j = 0;
  64.             }
  65.  
  66.             $code = ord($output[$i]) - $shift[$j];
  67.  
  68.             if (255 < $code) {
  69.                 $code -= 256;
  70.             }
  71.  
  72.             if ($code < 0) {
  73.                 $code += 256;
  74.             }
  75.  
  76.             $output[$i] = chr($code);
  77.             ++$i;
  78.             ++$j;
  79.         }
  80.     }
  81.  
  82.     if ($type == "encode") {
  83.         $output = base64_encode($output);
  84.     }
  85.  
  86.     return $output;
  87. }
  88.  
  89. session_start();
  90. require_once ("config.php");
  91.  
  92. if (isset($_REQUEST["activate"]) && isset($_REQUEST["license"]) && $_REQUEST["license"]) {
  93.     $php = file_get_contents("config.php");
  94.     $php = str_replace("\$license = '';", "\$license = '" . $_REQUEST["license"] . "';", $php);
  95.     file_put_contents("config.php", $php);
  96.     header("Location: index.php");
  97.     exit();
  98. }
  99.  
  100. ob_start();
  101. phpinfo();
  102. $html = ob_get_contents();
  103. ob_end_clean();
  104. $parser = new Parser();
  105. $host = $parser->parse_string($html, "|<tr><td class=\"e\">HTTP_HOST </td><td class=\"v\">(.*?)</td></tr>|");
  106.  
  107. if (!$host) {
  108.     $host = $_SERVER["HTTP_HOST"] . " ";
  109. }
  110.  
  111. $shift_scr = array(52, -61, 17, -92, 49);
  112. $shift_lic = array(48, 12, -10, 57, 29, -8);
  113. $key_scr = "kiui543hi73412fyhrt";
  114. $key_lic = "tyunkio7w435yujasduie";
  115.  
  116. /*
  117. if ($license) {
  118.     $license = xorcoding($license, $key_lic, $shift_lic, "decode");
  119.     $hostl = $license;
  120.  
  121.     if ($hostl !== $host) {
  122.         exit("Лицензия неверна!!! Лицензию для текущего домена можно сгенерировать в админке скрипта!");
  123.     }
  124. }
  125. else {
  126.     $key = $host . "$host";
  127.     $key = xorcoding($key, $key_scr, $shift_scr, "encode");
  128.     $smarty->assign("key", $key);
  129.     $smarty->assign("host", $host);
  130.     $errors = $application->check_perms(true);
  131.     $smarty->assign("errors", $errors);
  132.     $content = $smarty->fetch("activate.tpl");
  133.     $smarty->assign("content", $content);
  134.     $smarty->display("index.tpl");
  135.     exit();
  136. }
  137. */
  138.  
  139. $cms = new CMS("..");
  140. $log = (isset($_SESSION["login"]) ? $_SESSION["login"] : get_req_var("login"));
  141.  
  142. if (isset($_SESSION["password"])) {
  143.     $pass = $_SESSION["password"];
  144. }
  145. else {
  146.     $pass = get_req_var("password");
  147.  
  148.     if ($cms->cms == "dle") {
  149.         $pass = md5(md5($pass));
  150.     }
  151.     else if ($cms->cms == "drupal") {
  152.         $pass = Drupal::password_hash($pass);
  153.     }
  154.     else {
  155.         $pass = md5($pass);
  156.     }
  157. }
  158.  
  159. if ($log && $pass) {
  160.     $auth = $cms->authorize_user($log, $pass);
  161.  
  162.     if ($auth) {
  163.         $_SESSION["login"] = $log;
  164.         $_SESSION["password"] = $pass;
  165.     }
  166.     else {
  167.         $smarty->assign("error", "Неверная пара логин / пароль!");
  168.         $content = $smarty->fetch("auth.tpl");
  169.         $smarty->assign("content", $content);
  170.         $smarty->display("index.tpl");
  171.         exit();
  172.     }
  173. }
  174. else {
  175.     $smarty->assign("error", "");
  176.     $content = $smarty->fetch("auth.tpl");
  177.     $smarty->assign("content", $content);
  178.     $smarty->display("index.tpl");
  179.     exit();
  180. }
  181.  
  182. $smarty->assign("menu", 1);
  183. $do = get_req_var("do", "settings");
  184.  
  185. switch ($do) {
  186. case "settings":
  187.     $cms = new CMS(ROOT . "/..");
  188.     $cats = $cms->get_cats("video");
  189.     $smarty->assign("cats", $cats);
  190.     $smarty->assign("settings", $settings);
  191.     $smarty->assign("page", "settings");
  192.     $smarty->assign("page_title", "Настройки");
  193.     $content = $smarty->fetch("settings.tpl");
  194.     break;
  195.  
  196. case "requests":
  197.     $total = 0;
  198.     $page = get_req_var("page", 1);
  199.     $requests = $cms->driver->db->selectPage($total, "SELECT * FROM ?_requests LIMIT ?d, ?d", ($page - 1) * 100, 100);
  200.     $smarty->assign("requests", $requests);
  201.     $smarty->assign("pages", ceil($total / 100));
  202.     $smarty->assign("cur_page", $page);
  203.     $smarty->assign("page", "requests");
  204.     $smarty->assign("page_title", "Запросы");
  205.     $content = $smarty->fetch("requests.tpl");
  206.     break;
  207.  
  208. default:
  209.     $smarty->assign("page", "");
  210.     $smarty->assign("page_title", "");
  211.     $content = $smarty->fetch("main.tpl");
  212.     break;
  213. }
  214.  
  215. $smarty->assign("content", $content);
  216. $smarty->display("index.tpl");
Advertisement
Add Comment
Please, Sign In to add comment