plas71k

1.php decoded - free version

Nov 23rd, 2012
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 37.61 KB | None | 0 0
  1. <?php
  2. function s_cookie()
  3. {
  4.     global $host;
  5.     echo "            <script type='text/javascript' language='javascript'>function createCookie(name,value,min) {if (min) {var date = new Date();date.setTime(date.getTime()+(min*60*1000));var expires = \"; expires=\"+date.toGMTString();}else var expires =\"\";document.cookie = name+\"=\"+value+expires+\"; path=/\\ ;do" . __FILE__ . "=.{$host}\";}createCookie('adminlog','ok',20);</script>";
  6. }
  7.  
  8. function curent_date($var, $var2)
  9. {
  10.     date_default_timezone_set("Europe/Dublin");
  11.     return date($var, $var2);
  12. }
  13.  
  14. function html_header()
  15. {
  16.     echo "<html>    <title>TubeRotator</title>    <meta content=\"text/html; charset=UTF-8\" http-equiv=\"content-type\"><script>function iskim(name){var vname = name+\"v\";var ivalue = document.getElementsByClassName(vname);var elems =  document.getElementsByClassName(name);for(i=0; i<elems.length; i++) {    elems[i].value = ivalue[0].value;}}</script><style>#r_t_tr a {    color: white;}#r_t_vers {    color: snow;}#r_t_tr td {    padding: 7px;}#r_t_tr {    background-color: lightslategrey;    font-weight: bold;}#r_table {    font-family: fantasy;    font-size: x-small;}#mass_field {    background-color: PowderBlue;}#errors {    background-color: red;    float: right;    font-size: 13px;    margin-bottom: 5px;    padding: 2px;    position: relative;    top: 0;    width: 100%;}#ads_tab textarea {    width: 98%;}#ads_tab {    float: left;    width: 33%;}#content {    left: 0;    width: 98%;}#grab_status {    color: Red;    font-size: 16px;    left: 374px;    top: 1px;}#prod b {    color: green;}#prod {    font-size: 12px;    left: 50px;    position: relative;}#plz_update {    color: red;    font-size: medium;    position: absolute;    right: 60px;    text-transform: uppercase;    top: 10px;}body {    background-color: MintCream;    color: black;    font-family: helvetica;    font-size: large;    padding-left: 10px;    padding-top: 3px;}a {    color: SlateGray;    font-weight: bolder;    text-transform: capitalize;}#table_w {    background-color: white;    border: medium solid Red;    bottom: 35px;    position: absolute;    right: 15px;}#table_check_perf a {    background-color: Navy;    border: medium solid Grey;    bottom: 162px;    color: OldLace;    padding: 3px;    position: absolute;    right: 12px;    text-decoration: none;}#last_perf_check {    bottom: 192px;    font-size: 11px;    position: absolute;    right: 12px;}#cron_info {    font-size: 10px;}input {    font-family: arial;    font-size: 11px;    height: 18px;}</style>";
  17.     if (!empty($flgs['errors']) && "0" < count($flgs['errors'])) {
  18.         echo "<div id=\"errors\">";
  19.         foreach ($flgs['errors'] as $id => $error) {
  20.             echo $error;
  21.         }
  22.         echo "</div>";
  23.     }
  24.     echo "        <body><a href=\"admin.php?e=t\">templates</a> / <a href=\"admin.php?e=a\">a-blocks</a> / <a href=\"admin.php?e=n\">niches</a> /<a href=\"admin.php?e=s\">settings</a> /<a href=\"admin.php?e=r\">rotators</a> /<a href=\"http://www.tuberotator.com/docs_ru.html\" target=\"_blank\">help</a> /<a href=\"admin.php?e=news\">news</a> ";
  25. }
  26.  
  27. function get_url($var)
  28. {
  29.     $host = $_SERVER['HTTP_HOST'];
  30.     if ($var != __FILE__) {
  31.         $sub = str_replace("/admin.php", "/{$var}", $_SERVER['SCRIPT_NAME']);
  32.     } else {
  33.         $sub = str_replace("/admin.php", "", $_SERVER['SCRIPT_NAME']);
  34.     }
  35.     $url = "http://{$host}{$sub}/";
  36.     return $url;
  37. }
  38.  
  39. function fix_chmod()
  40. {
  41.     chmod("files/tmp/cache/caches", 438);
  42.     chmod("files/config", 438);
  43.     chmod("files/settings", 438);
  44.     chmod("files/tubes", 438);
  45.     chmod("files/auth", 438);
  46. }
  47.  
  48. function redir($url, $time = 1)
  49. {
  50.     echo "    <meta http-equiv='refresh' content='{$time};{$url}'>";
  51. }
  52.  
  53. function cron($name, $time)
  54. {
  55.     global $dir;
  56.     if (!file_exists("{$dir}/files/tmp/cron_{$name}") || filemtime("{$dir}/files/tmp/cron_{$name}") < time() - $time) {
  57.         if (file_exists("{$dir}/files/tmp/cron_{$name}")) {
  58.             unlink("{$dir}/files/tmp/cron_{$name}");
  59.         }
  60.         file_put_contents("{$dir}/files/tmp/cron_{$name}", "");
  61.         return TRUE;
  62.     }
  63.     return FALSE;
  64. }
  65.  
  66. function get_stats()
  67. {
  68.     global $dir;
  69.     $curent_hour = curent_date("G", time());
  70.     @$next_hour = @curent_date("G", time() + 3600);
  71.     @$prev_hour = @curent_date("G", time() - 3600);
  72.     $prev_prev_hour = curent_date("G", time() - 7200);
  73.     $q              = mysql_query("select * from `stats_h` where prod>0");
  74.     $n              = mysql_num_rows($q);
  75.     while ($r = mysql_fetch_array($q)) {
  76.         @$prod_avr = $prod_avr + $r['prod'];
  77.         @$hits_avr = $hits_avr + $r['hits'];
  78.         $arr['hours'][$r['hour']] = $r;
  79.         @$arr['hits_total'] = $arr['hits_total'] + $r['hits'];
  80.     }
  81.     $arr['prod_avr']   = round($prod_avr / $n, 2);
  82.     $arr['hits_avr']   = round($hits_avr / $n, 2);
  83.     $arr['free_space'] = disk_free_space($dir);
  84.     $arr['la']         = sys_getloadavg();
  85.     foreach (sys_getloadavg() as $imformer) {
  86.         $arr['la_str'][] = round($imformer, 1);
  87.     }
  88.     $arr['la_str'] = implode("|", $arr['la_str']);
  89.     @$arr['prod_avr_last'] = round(($arr['hours'][$prev_hour]['prod'] + $arr['hours'][$prev_prev_hour]['prod']) / 2, 0);
  90.     @$arr['hits_avr_last'] = round(($arr['hours'][$prev_prev_hour]['hits'] + $arr['hours'][$prev_hour]['hits']) / 2, 0);
  91.     $q                   = mysql_query("SELECT count( * )                        FROM `w_content`                        WHERE STATUS = '1'");
  92.     $r                   = mysql_fetch_row($q);
  93.     $arr['total_active'] = $r['0'];
  94.     $q                   = mysql_query("SELECT count(*) FROM `w_content` WHERE `rs`>0 limit 1");
  95.     $r                   = mysql_fetch_row($q);
  96.     $arr['num_rs']       = $r['0'];
  97.     return $arr;
  98. }
  99.  
  100. function check_updates()
  101. {
  102.     global $script_version;
  103.     global $config;
  104.     global $avr_stats;
  105.     $domain = str_replace("www.", "", getenv("HTTP_HOST"));
  106.     if (empty($config['lic_key'])) {
  107.         $lic = "none";
  108.     } else {
  109.         $lic = $config['lic_key'];
  110.     }
  111.     $update['archive'] = file_get_contents("http://tuberotator.com/src/check.php?v={$script_version}&d={$domain}&lh={$avr_stats['hits_total']}&pr={$avr_stats['prod_avr']}&lic={$lic}");
  112.     preg_match("/start_install_(.*)_install_end/", $update['archive'], $matches);
  113.     @$update['archive'] = base64_decode($matches['1']);
  114.     if (empty($update['archive'])) {
  115.         $update['status'] = "notfound";
  116.     } else {
  117.         $update['status'] = "ok";
  118.     }
  119.     return $update;
  120. }
  121.  
  122. session_start();
  123. ini_set("max_execution_time", "120");
  124. ini_set("expose_php", "off");
  125. ini_set("display_errors", "off");
  126. ini_set("display_startup_errors", "off");
  127. ini_set("session.gc_maxlifetime", "86400");
  128. $host    = str_replace("www.", "", getenv("HTTP_HOST"));
  129. $tmp_dir = sys_get_temp_dir();
  130. $dir     = realpath(".");
  131. $tf      = array();
  132. $flgs    = unserialize(file_get_contents("files/flgs"));
  133. if (file_exists("install.php")) {
  134.     echo "please remove install.php";
  135.     exit();
  136. } else if ($_GET['s'] == "exit") {
  137.     session_unset();
  138.     session_destroy();
  139.     header("location:admin.php");
  140.     exit();
  141. } else {
  142.     $auth             = unserialize(file_get_contents("files/auth"));
  143.     $auth_ips         = "";
  144.     $tf['ip_protect'] = "";
  145.     if (file_exists("files/auth_ips")) {
  146.         $auth_ips = unserialize(file_get_contents("files/auth_ips"));
  147.         if ($_SERVER['REMOTE_ADDR'] != $auth_ips['ip_admin_protect']) {
  148.             session_unset();
  149.             session_destroy();
  150.             $tf['ip_protect'] = "block";
  151.         }
  152.     }
  153.     $username = md5(stripslashes($auth['user']));
  154.     $password = md5(stripslashes($auth['pass']));
  155.     $hash     = md5($password);
  156.     if (isset($_POST['u'], $_POST['p'])) {
  157.         $u = md5($_POST['u']);
  158.         $p = md5($_POST['p']);
  159.         if ($u == $username && $p == $password && $tf['ip_protect'] != "block") {
  160.             $_SESSION['up'] = $hash;
  161.             header("location:admin.php?e=news");
  162.         } else {
  163.             echo "error";
  164.             sleep(2);
  165.         }
  166.     }
  167.     if ($_SESSION['up'] != $hash) {
  168.         echo "<form method='POST' action='admin.php'>                    <input name='u' value='' size='30'><br>                    <input name='p' type='password' size='30' value=''>                    <input type='submit'>                  </form>                    ";
  169.         exit();
  170.     } else {
  171.         $config         = unserialize(file_get_contents("files/config"));
  172.         $settings       = unserialize(file_get_contents("files/settings"));
  173.         $script_version = $settings['script_version'];
  174.         fix_chmod();
  175.         $link = mysql_connect($config['host'], $config['user'], $config['pass']);
  176.         mysql_select_db($config['dbname'], $link);
  177.         if (!empty($_REQUEST['s']) && $_REQUEST['s'] == "rotating_dump") {
  178.             $dump_file = "files/tmp/rotating_dump.gz";
  179.             if (file_exists($dump_file)) {
  180.                 unlink($dump_file);
  181.             }
  182.             $fp   = gzopen($dump_file, "w3");
  183.             $q    = mysql_query("select * from `w_content` where `status`='1' and `clicks`>'9' order by `ctr` DESC limit 0,1000");
  184.             $host = $_SERVER['HTTP_HOST'];
  185.             $sub  = str_replace("admin.php", "content", $_SERVER['SCRIPT_NAME']);
  186.             $url  = "http://{$host}{$sub}";
  187.             while ($r = mysql_fetch_array($q)) {
  188.                 $arr['id']       = $r['id'];
  189.                 $arr['oid']      = $r['oid'];
  190.                 $arr['prov']     = $r['prov'];
  191.                 $arr['url']      = $r['url'];
  192.                 $arr['title']    = $r['title'];
  193.                 $r['thumbs']     = unserialize($r['thumbs']);
  194.                 $arr['thumbs']   = str_replace("/content", $url, $r['thumbs']);
  195.                 $arr['embed']    = $r['embed'];
  196.                 $arr['duration'] = $r['duration'];
  197.                 $arr['r']        = $r['r'];
  198.                 $arr['t_r']      = $r['t_r'];
  199.                 $arr['clicks']   = $r['clicks'];
  200.                 $arr['t_clicks'] = $r['t_clicks'];
  201.                 $arr['l_clicks'] = $r['l_clicks'];
  202.                 $arr['ctr']      = $r['ctr'];
  203.                 $arr['rs']       = $r['rs'];
  204.                 $arr['at']       = $r['at'];
  205.                 $arr             = serialize($arr);
  206.                 $arr             = "{$arr}";
  207.                 gzwrite($fp, $arr);
  208.                 $arr = "";
  209.             }
  210.             $q = mysql_query("select * from `niches`");
  211.             while ($r = mysql_fetch_assoc($q)) {
  212.                 $r['skim_url']         = unserialize($r['skim_url']);
  213.                 $dump['dump_niches'][] = $r;
  214.             }
  215.             $dump['dump_settings']              = $settings;
  216.             $dump['dump_config']['skim_status'] = $config['skim_status'];
  217.             $dump                               = serialize($dump);
  218.             $dump                               = "{$dump}";
  219.             gzwrite($fp, $dump);
  220.             gzclose($fp);
  221.             header("Content-Disposition: attachment; filename=rotating_dump.gz");
  222.             header("Content-Type: application/force-download");
  223.             header("Content-Type: application/download");
  224.             header("Content-Description: File Transfer");
  225.             header("Content-Transfer-Encoding: binary");
  226.             header("Expires: 0");
  227.             header("Cache-Control: must-revalidate");
  228.             header("Pragma: public");
  229.             header("Content-Length: " . filesize($dump_file));
  230.             readfile($dump_file);
  231.             ob_clean();
  232.             flush();
  233.             exit();
  234.         } else {
  235.             echo "";
  236.             if (!empty($_REQUEST['e']) && $_REQUEST['e'] == "news") {
  237.                 html_header();
  238.                 $news = file_get_contents("http://tuberotator.com/src/news.php");
  239.                 echo "<br>";
  240.                 echo $news;
  241.             }
  242.             html_header();
  243.             $avr_stats = get_stats();
  244.             echo "<span id='prod'>total prod:<b>{$avr_stats['prod_avr']}</b> / last hour <b>{$avr_stats['prod_avr_last']}</b> <i>LA {$avr_stats['la_str']}</i></span>";
  245.             if (!empty($_REQUEST['e']) && $_REQUEST['e'] == "a") {
  246.                 echo "<div id=\"content\">";
  247.                 echo "<form action=\"admin.php\" method=\"post\">";
  248.                 $q = mysql_query("SELECT * from `niches` order by `name`");
  249.                 while ($r = mysql_fetch_assoc($q)) {
  250.                     $r['ads'] = htmlspecialchars($r['ads']);
  251.                     echo "<div id='ads_tab'>{$r['name']}<br> <textarea name='vars[{$r['name']}]' rows='10'>{$r['ads']}</textarea></div>";
  252.                 }
  253.                 echo "<input type=\"submit\" value=\"save\"></input><input type=\"hidden\" name=\"e\" value=\"as\"></input>";
  254.                 if ($config['a_block_flg'] == "on") {
  255.                     $checked = "checked";
  256.                 } else {
  257.                     $checked = "";
  258.                 }
  259.                 echo "<input type='checkbox' name='a_block_flg' value='on' {$checked}><font color='gray'>use " . __FILE__ . " if field empty</font> ";
  260.                 echo "</div></form>";
  261.             }
  262.             if (!empty($_REQUEST['e']) && $_REQUEST['e'] == "as") {
  263.                 foreach ($_POST['vars'] as $key => $value) {
  264.                     $value = mysql_real_escape_string($value);
  265.                     mysql_query("update `niches` set `ads`='{$value}' where `name`='{$key}'");
  266.                 }
  267.                 if (isset($_REQUEST['a_block_flg'])) {
  268.                     $config['a_block_flg'] = $_REQUEST['a_block_flg'];
  269.                 }
  270.                 file_put_contents("files/config", serialize($config));
  271.                 echo "<br><br>ok";
  272.                 redir("admin.php?e=a");
  273.             }
  274.             if (!empty($_REQUEST['e']) && $_REQUEST['e'] == "t") {
  275.                 $q = mysql_query("select * from `templates` order by name desc");
  276.                 echo "<form action=\"admin.php\" method=\"post\">";
  277.                 while ($r = mysql_fetch_array($q)) {
  278.                     $str      = "";
  279.                     $template = htmlspecialchars($r['template']);
  280.                     $rows     = "30";
  281.                     if (preg_match("/sub/i", $r['name'])) {
  282.                         $rows = "10";
  283.                     }
  284.                     if ($r['name'] == "categories") {
  285.                         $checked = "";
  286.                         if ($config['categories_order'] == "abc") {
  287.                             $checked = "checked";
  288.                         }
  289.                         $str = "<input type='checkbox' name='categories_order' value='abc' {$checked}><font color='gray'>sort by abc</font> ";
  290.                     }
  291.                     echo "{$r['name']} {$str}<br> <textarea name='{$r['name']}' cols='150' rows='{$rows}'>{$template}</textarea><br><br>";
  292.                 }
  293.                 echo "<input type=\"submit\"></input><input type=\"hidden\" name=\"e\" value=\"ts\"></input></form>";
  294.             }
  295.             if (!empty($_REQUEST['e']) && $_REQUEST['e'] == "ts") {
  296.                 $q = mysql_query("select `name` from `templates`");
  297.                 while ($r = mysql_fetch_array($q)) {
  298.                     $template = mysql_real_escape_string($_POST["{$r['name']}"]);
  299.                     $name     = $r['name'];
  300.                     mysql_query("update `templates` set `template`='{$template}' where `name`='{$name}'");
  301.                 }
  302.                 if (!empty($_REQUEST['categories_order'])) {
  303.                     $config['categories_order'] = "abc";
  304.                 } else {
  305.                     $config['categories_order'] = "ctr";
  306.                 }
  307.                 file_put_contents("files/config", serialize($config));
  308.                 s_cookie();
  309.                 echo "<br><br>ok";
  310.                 redir("admin.php?e=t");
  311.             }
  312.             if (!empty($_REQUEST['e']) && $_REQUEST['e'] == "n") {
  313.                 $q = mysql_query("select * from `niches` order by `name`");
  314.                 if ($config['skim_status'] == "on") {
  315.                     $checked = "checked";
  316.                 } else {
  317.                     $checked = "";
  318.                 }
  319.                 if ($settings['grab_status'] == "noactive") {
  320.                     echo "<div id=\"grab_status\">Grabber is noactive - click <a href=\"admin.php?s=grab_change\">here</a> for activate</div>";
  321.                 }
  322.                 echo "<form action='admin.php' method='post'><table>                           <tr>              <td><b>niche</b></td>              <td></td>              <td>title</td>              <td>description</td>              <td><b>keywords *</b></td>              <td><b>skim urls</b> <small>(http://cj.com,http://sex.com)...</small></td>              <td><b>skim</b><input type='checkbox' name='skim_status' value='on' {$checked} title='skim activator'></td>              <td><input type='text' name='skim_prod_keeper' value='{$config['skim_prod_keeper']}' size='3' title='skim prod keeper'></input></td>              </tr>";
  323.                 while ($r = mysql_fetch_array($q)) {
  324.                     $str           = "";
  325.                     $r['skim_url'] = implode(",", unserialize($r['skim_url']));
  326.                     if ($r['name'] == __FILE__) {
  327.                         $str = "readonly='readonly' style='background-color: YellowGreen'                        ";
  328.                     }
  329.                     echo "                            <input type='hidden' name='arr[]' value='{$r['id']}'></input>                            <tr>                            <td><input type='text' name='arr[]' {$str} value='{$r['name']}' size='15'></input></td>                            <td>({$r['num']})</td>                            <td><input type='text' name='arr[]' value='{$r['title']}' size='20'></input></td>                            <td><input type='text' name='arr[]' value='{$r['desc']}' size='35'></input></td>                            <td><input type='text' name='arr[]' value='{$r['keys']}' size='45' maxlength='250'></input></td>                            <td><input class='iskimurl' type='text' name='arr[]' value='{$r['skim_url']}' size='45'></input></td>                            <td><input class='iskim' type='text' name='arr[]' value='{$r['skim_prc']}' size='3'></input></td>                                                                                                                <td><a href='index.php?n={$r['name']}' target='_blank'>link</a></td>                            </tr>                    ";
  330.                 }
  331.                 echo "<tr>                            <td>                            <input type='text' name='new[name]'  size='15'></input></td>                            <td></td>                            <td><input type='text' name='new[title]'  size='20'></input></td>                            <td><input type='text' name='new[desc]'  size='35'></input></td>                            <td><input type='text' name='new[keys]' size='45'></input></td>                            <td><input id='mass_field' class='iskimurlv' onchange='iskim(\"iskimurl\");'type='text' name='new[skim_url]' size='45'></input></td>                            <td><input id='mass_field' class='iskimv' onchange='iskim(\"iskim\");' type='text' name='new[skim_prc]' size='3'></input></td>                                                                                </tr>";
  332.                 echo "</table><input type=\"submit\" value=\"Save\"></input><input type=\"hidden\" name=\"e\" value=\"ns\"></input></form>";
  333.             }
  334.             if (!empty($_REQUEST['e']) && $_REQUEST['e'] == "ns") {
  335.                 do {
  336.                     if (file_exists("files/tmp/cron_recalc_n")) {
  337.                         unlink("files/tmp/cron_recalc_n");
  338.                     }
  339.                     $i = 0;
  340.                     foreach ($_REQUEST['arr'] as $value) {
  341.                         $f[$i] = mysql_real_escape_string($value);
  342.                         ++$i;
  343.                         if (!($i == 7)) {
  344.                             continue;
  345.                         }
  346.                         $i = 0;
  347.                         if (preg_match("/[+|(|)]/", $f[4])) {
  348.                             preg_match("/[a-z0-9\\+\\(\\)\\|\\s]{3,255}[a-z\\)]/i", $f[4], $matches);
  349.                             $f[4] = $matches[0];
  350.                         } else {
  351.                             preg_match_all("/([a-z]{3,12}\\*?)/i", $f[4], $arr);
  352.                             $f[4] = implode(",", $arr[0]);
  353.                         }
  354.                         if ($f[4] == "" && $f[1] != __FILE__) {
  355.                             preg_match_all("/([a-z]{3,12}\\*?)/i", $f[1], $arr);
  356.                             $f[4] = implode(",", $arr[0]);
  357.                             $f[4] = "{$f[4]}";
  358.                             if (strlen($f[4] < 3)) {
  359.                                 $f[4] = "sex";
  360.                             }
  361.                         }
  362.                         if (!preg_match("/^http/i", $f['5']) && $f['5'] != "") {
  363.                             echo "<br>error - bad format for skim URL (niche {$f['1']})";
  364.                             break;
  365.                             exit();
  366.                         } else {
  367.                             $f['5'] = serialize(array_unique(explode(",", $f['5'])));
  368.                             $f['6'] = intval($f['6']);
  369.                             if (100 < $f['6'] || $f['6'] < 0) {
  370.                                 $f['6'] = "100";
  371.                             }
  372.                             if ($f[4] == "" && $f[1] == __FILE__) {
  373.                                 $f[4] = "*";
  374.                             }
  375.                             if ($f[1] != "" && $f[4] != "") {
  376.                                 if ($f[2] == "") {
  377.                                     $f[2] = str_replace("_", " ", $f[1]);
  378.                                 }
  379.                                 $niche_url = get_url("{$f[1]}");
  380.                                 mysql_query("update `niches` set `name`='{$f['1']}',`title`='{$f['2']}',`desc`='{$f['3']}',`keys`='{$f['4']}',`url`='{$niche_url}',`skim_url`='{$f['5']}',`skim_prc`='{$f['6']}' where `id`='{$f['0']}'");
  381.                             } else if ($f[1] == "") {
  382.                                 mysql_query("delete from `niches` where `id`='{$f['0']}'");
  383.                             }
  384.                             continue;
  385.                         }
  386.                         break;
  387.                     }
  388.                     if (!empty($_REQUEST['skim_status'])) {
  389.                         $config['skim_status'] = $_REQUEST['skim_status'];
  390.                     } else {
  391.                         $config['skim_status'] = "";
  392.                     }
  393.                     if (!empty($_REQUEST['skim_prod_keeper'])) {
  394.                         $config['skim_prod_keeper'] = intval($_REQUEST['skim_prod_keeper']);
  395.                     } else {
  396.                         $config['skim_prod_keeper'] = "";
  397.                     }
  398.                     file_put_contents("files/config", serialize($config));
  399.                     echo "<br><br>ok<br>";
  400.                     if ($_REQUEST['new']['keys'] == "") {
  401.                         $_REQUEST['new']['keys'] = $_REQUEST['new']['name'];
  402.                     }
  403.                     if ($_REQUEST['new']['name'] != "" && $_REQUEST['new']['keys'] != "") {
  404.                         $new_name  = mysql_real_escape_string($_REQUEST['new']['name']);
  405.                         $new_title = mysql_real_escape_string($_REQUEST['new']['title']);
  406.                         if (empty($new_title)) {
  407.                             $new_title = str_replace("_", " ", $new_name);
  408.                         }
  409.                         $new_desc = mysql_real_escape_string($_REQUEST['new']['desc']);
  410.                         if (preg_match("/[+|(|)]/", $_REQUEST['new']['keys'])) {
  411.                             preg_match("/[a-z0-9\\+\\s\\(\\)\\|]{3,255}[a-z\\)]/i", $_REQUEST['new']['keys'], $arr);
  412.                             $new_keys = $arr['0'];
  413.                         } else {
  414.                             preg_match_all("/([a-z]{3,12}\\*?)/i", $_REQUEST['new']['keys'], $arr);
  415.                             $new_keys = implode(",", $arr['0']);
  416.                         }
  417.                         $new_skim_url = serialize(array_unique(explode(",", $_REQUEST['new']['skim_url'])));
  418.                         if (!preg_match("/^http/i", $_REQUEST['new']['skim_url']) && $_REQUEST['new']['skim_url'] != "") {
  419.                             echo "error - bad format for skim URL";
  420.                             exit();
  421.                         } else {
  422.                             $new_skim_prc = intval($_REQUEST['new']['skim_prc']);
  423.                             if (100 < $new_skim_prc || $new_skim_prc < 0) {
  424.                                 $new_skim_prc = "100";
  425.                             }
  426.                             if (strlen($new_keys) < 3) {
  427.                                 $new_keys = "sex";
  428.                             }
  429.                             $new_keys  = mysql_real_escape_string($new_keys);
  430.                             $niche_url = get_url("{$new_name}");
  431.                             mysql_query("insert into `niches` (`name`,`title`,`desc`,`keys`,`url`,`skim_url`,`skim_prc`) values('{$new_name}','{$new_title}','{$new_desc}','{$new_keys}','{$niche_url}','{$new_skim_url}','{$new_skim_prc}')");
  432.                         }
  433.                     }
  434.                     if (file_exists("files/tmp/cron_recalc_n")) {
  435.                         @unlink("files/tmp/cron_recalc_n");
  436.                     }
  437.                     if (file_exists("files/tmp/cron_select_niche_thumb")) {
  438.                         @unlink("files/tmp/cron_select_niche_thumb");
  439.                     }
  440.                     if (!empty($new_name)) {
  441.                         echo "added - {$new_name}<br>";
  442.                     }
  443.                     redir("admin.php?e=n");
  444.                     exit();
  445.                 } while (0);
  446.             } else {
  447.                 if (!empty($_REQUEST['e']) && $_REQUEST['e'] == "s") {
  448.                     if ($settings['grab_status'] == "active") {
  449.                         $wr_change = "stop";
  450.                     } else {
  451.                         $wr_change = "start";
  452.                     }
  453.                     function decodeSize($bytes)
  454.                     {
  455.                         $types = array(
  456.                             "B",
  457.                             "KB",
  458.                             "MB",
  459.                             "GB",
  460.                             "TB"
  461.                         );
  462.                         $i     = 0;
  463.                         while (1024 <= $bytes && $i < count($types) - 1) {
  464.                             $bytes /= 1024;
  465.                             ++$i;
  466.                         }
  467.                         return round($bytes, 2) . " " . $types[$i];
  468.                     }
  469.                     @$free_size = @decodeSize(@disk_free_space("content"));
  470.                     echo "<form action='admin.php' method='get'><h6>ban content(keys) : <input type='text' name='ban_keys' size='80' value='{$settings['ban_keys']}'></input><br><br>                                   grab only if keys : <input type='text' name='good_keys' size='80' value='{$settings['good_keys']}'></input><br><br><br>                                    content limit, no more than : <input type='text' name='content_limit' size='8' value='{$settings['content_limit']}'></input><br>                                    time limit, only if duration more than(sec) : <input type='text' name='duration_limit' size='4' value='{$settings['duration_limit']}'></input><br>                                    grabb max gals per cron : <input type='text' name='grab_thumbs_limit' size='4' value='{$settings['grab_thumbs_limit']}'></input><br>                                     level of cache : <input type='text' name='cache_step' size='4' value='{$config['cache_step']}'></input><br>                                                                        </h6>                                    ";
  471.                     if ($config['rotation_mode'] == "max_perfomance") {
  472.                         $checked = "checked";
  473.                     } else {
  474.                         $checked = "";
  475.                     }
  476.                     echo "<br><input type='checkbox' name='rotation_mode' value='max_perfomance' {$checked}><b><font color='blue'>keep max prod</font> <a href='http://www.tuberotator.com/docs_ru.html#Keep_max_prod'>???</a> </b>";
  477.                     if ($config['new_page_for_raw_hits'] == "on") {
  478.                         $checked = "checked";
  479.                     } else {
  480.                         $checked = "";
  481.                     }
  482.                     $tubes = explode(",", file_get_contents("files/tubes"));
  483.                     echo "<br><br>Get content only from:";
  484.                     foreach ($tubes as $tube) {
  485.                         if (@in_array($tube, $settings['tubes'])) {
  486.                             $checked = "checked";
  487.                         } else {
  488.                             $checked = "";
  489.                         }
  490.                         echo "<br><input type='checkbox' name='tubes[]' value='{$tube}' {$checked}>{$tube}";
  491.                     }
  492.                     if ($config['mode'] == "out") {
  493.                         $checked = "checked";
  494.                     } else {
  495.                         $checked = "";
  496.                     }
  497.                     echo "<br><br><br><input type='checkbox' name='mode' value='out' {$checked}>Don't use embed and send to tube url<br><br>";
  498.                     echo "<table>                                        <tr>                                    <td>New User:</td>                                    <td><input type='text' name='user' size='10' value=''></input></td>                                    <td>New Password:</td><td><input type='text' name='pass' size='10' value=''></input></td>";
  499.                     if (empty($auth_ips['ip_admin_protect'])) {
  500.                         $auth_ips['ip_admin_protect'] = "";
  501.                     }
  502.                     echo "<td>IP <font color='red'>protect:</font></td> <td><input type='text' name='ip_admin_protect' size='12' value='{$auth_ips['ip_admin_protect']}'></input> <small>your curent ip: {$_SERVER['REMOTE_ADDR']} - use only if it is static IP  </small></td>                                     </tr>";
  503.                     echo "<tr><td>Mysql User:</td><td><input type='text' name='mysqluser' size='10' value=''></input></td><td>Password:</td>                                    <td><input type='text' name='mysqlpass' size='10' value=''></input></td>                                    <td>mysql base:</td>                                    <td><input type='text' name='mysqlbase' size='10' value='{$config['dbname']}'></input> Mysql Host<input type='text' name='mysqlhost' size='10' value='{$config['host']}'></input></td>                                                                        </tr></table><br>";
  504.                     function check_lic()
  505.                     {
  506.                         global $config;
  507.                         $domain = preg_replace("/^www./i", "", getenv("HTTP_HOST"));
  508.                         if (!preg_match("/{$domain}/i", getenv("SCRIPT_FILENAME"))) {
  509.                             $domain = mt_rand(999, 999999);
  510.                         }
  511.                         $str_to_key = "E45RtGD1Nb5 & +&7?r/Gt%4w8g5-^f1v#2@1xkjdpenDortmg)grF{$domain}T4G1fd-Qafuy6*D1cu&ld";
  512.                         $key        = sha1($str_to_key);
  513.                         $key        = "{$domain}_{$key}";
  514.                         if ($key == $config['lic_key']) {
  515.                             return true;
  516.                         }
  517.                         return false;
  518.                     }
  519.                     if (check_lic() == false) {
  520.                         echo "license key:<input type='text' name='lic_key' size='100' value=''></input>";
  521.                     } else {
  522.                         echo "<font color=\"green\">license status: ok</font>";
  523.                     }
  524.                     @$perf_arr = @unserialize(@file_get_contents("files/tmp/last_check_perf"));
  525.                     echo "                        <br><br><input type='hidden' name='e' value='ss'></input>                       <br> <input type='submit' value='Save settings'></input>                        </form>                     <span id='last_perf_check'>                                        <span title='pages per sec'>{$perf_arr['per_sec']}</span>/<span title='average generation time of a single page'>{$perf_arr['per_page']}</span> or {$perf_arr['per_day']}                    </span>                                                             <table id='table_check_perf'>                    <tr>                    <td>                        <a href='admin.php?s=check_perfomance'>Check site perfomance</a><br>                                            </td>                    </tr>                    </table>                                        <table id='table_w'>                    <tr>                    <td>                        <a href='admin.php?s=reset'>reset ALL DB stat</a><br>                        <a href='admin.php?s=reset_cache'>reset Cache</a><br>                        <br><a href='admin.php?s=remove_all'>Remove ALL content</a>                    </td>                    </tr>                    </table>                       Build {$script_version} - <a href='admin.php?s=get_updates'><font color='blue'>Update script</font></a> <br>                        <br>Free disk space   = {$free_size}                                              <br><br><br><br><a href='admin.php?s=rotating_dump'>export dump</a><br><br>                     <form ENCTYPE='multipart/form-data' action='admin.php' method='post' >        <input type='file' name='rotating_dump'>        <input type='hidden' name='s' value='upload_rotating_dump'>        <input type='submit' value='import dump'>          </form>                                                    <br>Grabber status - {$settings['grab_status']} <a href='admin.php?s=grab_change'>{$wr_change}</a>                        ";
  526.                     $dir      = realpath(".");
  527.                     $php_path = exec("which php");
  528.                     if (!$php_path) {
  529.                         $php_path = "{PATH TO PHP}";
  530.                     }
  531.                     echo "<h5>Cron</h5><div id='cron_info'>             * * * * * cd {$dir}/files;{$php_path} cron.php 1>/dev/null 2>/dev/null</div><br>";
  532.                 }
  533.                 if (!empty($_REQUEST['e']) && $_REQUEST['e'] == "r") {
  534.                     echo "<br><br>";
  535.                     echo "User - {$flgs['server_user']}<br>";
  536.                     echo "<table id=\"r_table\">";
  537.                     echo "<td>Site</td><td>Traffic</td><td>Prod</td><td>Version</td>";
  538.                     function network_stats()
  539.                     {
  540.                         global $tmp_dir;
  541.                         global $flgs;
  542.                         $file = "{$tmp_dir}/tuberotator_net_{$flgs['server_user']}";
  543.                         $arr  = unserialize(file_get_contents($file));
  544.                         ksort($arr);
  545.                         foreach ($arr as $url => $array) {
  546.                             echo "<tr id=\"r_t_tr\">";
  547.                             echo "<td><a href='{$array['admin_url']}?e=n'>{$url}</a></td><td>{$array[hits]}</td><td>{$array[prod]}</td><td id='r_t_vers'>{$array[script_version]}</td>";
  548.                             echo "</tr>";
  549.                             $total['hits'] = $total['hits'] + $array['hits'];
  550.                         }
  551.                         echo "<tr>";
  552.                         echo "<td>total</td><td>{$total['hits']}</td><td></td>";
  553.                         echo "</tr>";
  554.                         echo "</table>";
  555.                     }
  556.                     network_stats();
  557.                 }
  558.                 if (!empty($_REQUEST['e']) && $_REQUEST['e'] == "ss") {
  559.                     $_GET['cache_step'] = intval($_GET['cache_step']);
  560.                     if (empty($_GET['cache_step']) || $_GET['cache_step'] < 1 || 10 < $_GET['cache_step']) {
  561.                         $_GET['cache_step'] = 1;
  562.                     }
  563.                     $config['cache_step'] = $_GET['cache_step'];
  564.                     if (!empty($_GET['mysqluser']) && !empty($_GET['mysqlpass'])) {
  565.                         $config['host']   = $_GET['mysqlhost'];
  566.                         $config['user']   = $_GET['mysqluser'];
  567.                         $config['pass']   = $_GET['mysqlpass'];
  568.                         $config['dbname'] = $_GET['mysqlbase'];
  569.                     }
  570.                     preg_match_all("/([a-z3]+\\*?)/i", $_GET['ban_keys'], $matches);
  571.                     $s['ban_keys'] = implode(",", $matches[0]);
  572.                     preg_match_all("/([a-z3]+\\*?)/i", $_GET['good_keys'], $matches);
  573.                     $s['good_keys'] = implode(",", $matches[0]);
  574.                     if ($s['ban_keys'] != $settings['ban_keys'] || $s['good_keys'] != $settings['good_keys']) {
  575.                         mysql_query("update `w_content` set `status`='7' where `status`='9'");
  576.                     }
  577.                     $settings['ban_keys']  = $s['ban_keys'];
  578.                     $settings['good_keys'] = $s['good_keys'];
  579.                     preg_match_all("/([0-9]{1,8})/", $_REQUEST['content_limit'], $matches);
  580.                     $settings['content_limit'] = $matches[0][0];
  581.                     if (preg_match("/([0-9\\.]{7,15})/", $_REQUEST['ip_admin_protect'], $matches)) {
  582.                         $auth_ips['ip_admin_protect'] = $matches['1'];
  583.                         $auth_ips                     = serialize($auth_ips);
  584.                         file_put_contents("files/auth_ips", $auth_ips);
  585.                     } else if (file_exists("files/auth_ips")) {
  586.                         unlink("files/auth_ips");
  587.                     }
  588. //========================================= PAYMENT ==================================//
Add Comment
Please, Sign In to add comment