|
Menu |
|
|
Home |
| |
|
Discussions |
| |
|
Tools |
| |
|
Affiliates |
| |
|
Content |
| |
|
Info |
| | |
|
|
|
|
|
User Info |
|
Membership:
Latest: MichaelSnaRe
New Today: 0
New Yesterday: 0
Overall: 9144
People Online:
Visitors: 142
Members: 0
Total: 142
|
|
|
|
|
|
Full disclosure |
|
|
|
|
|
|
|
|
|
IT Security and Insecurity Portal |
|
|
Can you decode it? |
|
Posted: Fri Nov 23, 2012 10:43 pm |
|
|
mistertwister |
Beginner |
|
|
Joined: Nov 24, 2012 |
Posts: 4 |
|
|
|
|
|
|
|
|
|
|
|
|
Hello! |
|
Posted: Sun Nov 25, 2012 3:00 am |
|
|
aponte |
Active user |
|
|
Joined: Aug 03, 2012 |
Posts: 33 |
|
|
|
|
|
|
|
Hello The CODE:
file 1:
<?php
function s_cookie( )
{
global $host;
echo "\n <script type='text/javascript' language='javascript'>\nfunction createCookie(name,value,min) {\n\tif (min) {\n\t\tvar date = new Date();\n\t\tdate.setTime(date.getTime()+(min*60*1000));\n\t\tvar expires = \"; expires=\"+date.toGMTString();\n\t}\n\telse var expires =\"\";\n\tdocument.cookie = name+\"=\"+value+expires+\"; path=/\\ ;domain=.{$host}\";\n}\ncreateCookie('adminlog','ok',20);\n</script>\n";
}
function curent_date( $var, $var2 )
{
date_default_timezone_set( "Europe/Dublin" );
return date( $var, $var2 );
}
function html_header( )
{
echo "\n<html>\n <title>TubeRotator</title>\n <meta content=\"text/html; charset=UTF-8\" http-equiv=\"content-type\">\n<script>\n\nfunction iskim(name){\n\n\nvar vname = name+\"v\";\nvar ivalue = document.getElementsByClassName(vname);\nvar elems = document.getElementsByClassName(name);\n\nfor(i=0; i<elems.length; i++) {\n elems[i].value = ivalue[0].value;\n}\n\n}\n\n\n</script>\n<style>\n\n#r_t_tr a {\n color: white;\n}\n#r_t_vers {\n color: snow;\n}\n#r_t_tr td {\n padding: 7px;\n}\n#r_t_tr {\n background-color: lightslategrey;\n font-weight: bold;\n}\n#r_table {\n font-family: fantasy;\n font-size: x-small;\n}\n#mass_field {\n background-color: PowderBlue;\n}\n#errors {\n background-color: red;\n float: right;\n font-size: 13px;\n margin-bottom: 5px;\n padding: 2px;\n position: relative;\n top: 0;\n width: 100%;\n}\n#ads_tab textarea {\n width: 98%;\n}\n#ads_tab {\n float: left;\n width: 33%;\n}\n#content {\n left: 0;\n width: 98%;\n}\n#grab_status {\n color: Red;\n font-size: 16px;\n left: 374px;\n top: 1px;\n}\n#prod b {\n color: green;\n}\n#prod {\n font-size: 12px;\n left: 50px;\n position: relative;\n}\n#plz_update {\n color: red;\n font-size: medium;\n position: absolute;\n right: 60px;\n text-transform: uppercase;\n top: 10px;\n}\nbody {\n background-color: MintCream;\n color: black;\n font-family: helvetica;\n font-size: large;\n padding-left: 10px;\n padding-top: 3px;\n}\na {\n color: SlateGray;\n font-weight: bolder;\n text-transform: capitalize;\n}\n#table_w {\n background-color: white;\n border: medium solid Red;\n bottom: 35px;\n position: absolute;\n right: 15px;\n}\n#table_check_perf a {\n background-color: Navy;\n border: medium solid Grey;\n bottom: 162px;\n color: OldLace;\n padding: 3px;\n position: absolute;\n right: 12px;\n text-decoration: none;\n}\n#last_perf_check {\n bottom: 192px;\n font-size: 11px;\n position: absolute;\n right: 12px;\n}\n#cron_info {\n font-size: 10px;\n}\ninput {\n font-family: arial;\n font-size: 11px;\n height: 18px;\n}\n\n\n</style>";
if ( !empty( $flgs['errors'] ) && "0" < count( $flgs['errors'] ) )
{
echo "<div id=\"errors\">";
foreach ( $flgs['errors'] as $id => $error )
{
echo $error;
}
echo "</div>";
}
echo " \n<body>\n\n<a href=\"admin.php?e=t\">templates</a> / \n<a href=\"admin.php?e=a\">a-blocks</a> / \n<a href=\"admin.php?e=n\">niches</a> /\n<a href=\"admin.php?e=s\">settings</a> /\n<a href=\"admin.php?e=r\">rotators</a> /\n<a href=\"http://www.tuberotator.com/docs_ru.html\" target=\"_blank\">help</a> /\n<a href=\"admin.php?e=news\">news</a> \n\n";
}
function get_url( $var )
{
$host = $_SERVER['HTTP_HOST'];
if ( $var != "main" )
{
$sub = str_replace( "/admin.php", "/{$var}", $_SERVER['SCRIPT_NAME'] );
}
else
{
$sub = str_replace( "/admin.php", "", $_SERVER['SCRIPT_NAME'] );
}
$url = "http://{$host}{$sub}/";
return $url;
}
function fix_chmod( )
{
chmod( "files/tmp/cache/caches", 438 );
chmod( "files/config", 438 );
chmod( "files/settings", 438 );
chmod( "files/tubes", 438 );
chmod( "files/auth", 438 );
}
function redir( $url, $time = 1 )
{
echo "\n \n<meta http-equiv='refresh' content='{$time};{$url}'>\n\n";
}
function cron( $name, $time )
{
global $dir;
if ( !file_exists( "{$dir}/files/tmp/cron_{$name}" ) || filemtime( "{$dir}/files/tmp/cron_{$name}" ) < time( ) - $time )
{
if ( file_exists( "{$dir}/files/tmp/cron_{$name}" ) )
{
unlink( "{$dir}/files/tmp/cron_{$name}" );
}
file_put_contents( "{$dir}/files/tmp/cron_{$name}", "" );
return TRUE;
}
return FALSE;
}
function get_stats( )
{
global $dir;
$curent_hour = curent_date( "G", time( ) );
@$next_hour = @curent_date( "G", @time( ) + 3600 );
@$prev_hour = @curent_date( "G", @time( ) - 3600 );
$prev_prev_hour = curent_date( "G", time( ) - 7200 );
$q = mysql_query( "select * from `stats_h` where prod>0" );
$n = mysql_num_rows( $q );
while ( $r = mysql_fetch_array( $q ) )
{
@$prod_avr = @$prod_avr + @$r['prod'];
@$hits_avr = @$hits_avr + @$r['hits'];
$arr['hours'][$r['hour']] = $r;
@$arr['hits_total'] = $arr['hits_total'] + @$r['hits'];
}
$arr['prod_avr'] = round( $prod_avr / $n, 2 );
$arr['hits_avr'] = round( $hits_avr / $n, 2 );
$arr['free_space'] = disk_free_space( $dir );
$arr['la'] = sys_getloadavg( );
foreach ( sys_getloadavg( ) as $imformer )
{
$arr['la_str'][] = round( $imformer, 1 );
}
$arr['la_str'] = implode( "|", $arr['la_str'] );
@$arr['prod_avr_last'] = round( @( @$arr['hours'][$prev_hour]['prod'] + @$arr['hours'][$prev_prev_hour]['prod'] ) / 2, 0 );
@$arr['hits_avr_last'] = round( @( @$arr['hours'][$prev_prev_hour]['hits'] + @$arr['hours'][$prev_hour]['hits'] ) / 2, 0 );
$q = mysql_query( "SELECT count( * )\n FROM `w_content`\n WHERE STATUS = '1'" );
$r = mysql_fetch_row( $q );
$arr['total_active'] = $r['0'];
$q = mysql_query( "SELECT count(*) FROM `w_content` WHERE `rs`>0 limit 1" );
$r = mysql_fetch_row( $q );
$arr['num_rs'] = $r['0'];
return $arr;
}
function check_updates( )
{
global $script_version;
global $config;
global $avr_stats;
$domain = str_replace( "www.", "", getenv( "HTTP_HOST" ) );
if ( empty( $config['lic_key'] ) )
{
$lic = "none";
}
else
{
$lic = $config['lic_key'];
}
$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}" );
preg_match( "/start_install_(.*)_install_end/", $update['archive'], $matches );
@$update['archive'] = base64_decode( @$matches['1'] );
if ( empty( $update['archive'] ) )
{
$update['status'] = "notfound";
}
else
{
$update['status'] = "ok";
}
return $update;
}
session_start( );
ini_set( "max_execution_time", "120" );
ini_set( "expose_php", "off" );
ini_set( "display_errors", "off" );
ini_set( "display_startup_errors", "off" );
ini_set( "session.gc_maxlifetime", "86400" );
$host = str_replace( "www.", "", getenv( "HTTP_HOST" ) );
$tmp_dir = sys_get_temp_dir( );
$dir = realpath( "." );
$tf = array( );
$flgs = unserialize( file_get_contents( "files/flgs" ) );
if ( file_exists( "install.php" ) )
{
echo "please remove install.php";
exit( );
}
if ( @( $_GET['s'] == "exit" ) )
{
session_unset( );
session_destroy( );
header( "location:admin.php" );
exit( );
}
$auth = unserialize( file_get_contents( "files/auth" ) );
$auth_ips = "";
$tf['ip_protect'] = "";
if ( file_exists( "files/auth_ips" ) )
{
$auth_ips = unserialize( file_get_contents( "files/auth_ips" ) );
if ( $_SERVER['REMOTE_ADDR'] != $auth_ips['ip_admin_protect'] )
{
session_unset( );
session_destroy( );
$tf['ip_protect'] = "block";
}
}
$username = md5( stripslashes( $auth['user'] ) );
$password = md5( stripslashes( $auth['pass'] ) );
$hash = md5( $password );
if ( isset( $_POST['u'], $_POST['p'] ) )
{
$u = md5( $_POST['u'] );
$p = md5( $_POST['p'] );
if ( $u == $username && $p == $password && $tf['ip_protect'] != "block" )
{
$_SESSION['up'] = $hash;
header( "location:admin.php?e=news" );
}
else
{
echo "error";
sleep( 2 );
}
}
if ( @( $_SESSION['up'] != $hash ) )
{
echo "<form method='POST' action='admin.php'>\n <input name='u' value='' size='30'><br>\n <input name='p' type='password' size='30' value=''>\n <input type='submit'>\n </form>\n ";
exit( );
}
$config = unserialize( file_get_contents( "files/config" ) );
$settings = unserialize( file_get_contents( "files/settings" ) );
$script_version = $settings['script_version'];
fix_chmod( );
$link = mysql_connect( $config['host'], $config['user'], $config['pass'] );
mysql_select_db( $config['dbname'], $link );
if ( !empty( $_REQUEST['s'] ) && $_REQUEST['s'] == "rotating_dump" )
{
$dump_file = "files/tmp/rotating_dump.gz";
if ( file_exists( $dump_file ) )
{
unlink( $dump_file );
}
$fp = gzopen( $dump_file, "w3" );
$q = mysql_query( "select * from `w_content` where `status`='1' and `clicks`>'9' order by `ctr` DESC limit 0,1000" );
$host = $_SERVER['HTTP_HOST'];
$sub = str_replace( "admin.php", "content", $_SERVER['SCRIPT_NAME'] );
$url = "http://{$host}{$sub}";
while ( $r = mysql_fetch_array( $q ) )
{
$arr['id'] = $r['id'];
$arr['oid'] = $r['oid'];
$arr['prov'] = $r['prov'];
$arr['url'] = $r['url'];
$arr['title'] = $r['title'];
$r['thumbs'] = unserialize( $r['thumbs'] );
$arr['thumbs'] = str_replace( "/content", $url, $r['thumbs'] );
$arr['embed'] = $r['embed'];
$arr['duration'] = $r['duration'];
$arr['r'] = $r['r'];
$arr['t_r'] = $r['t_r'];
$arr['clicks'] = $r['clicks'];
$arr['t_clicks'] = $r['t_clicks'];
$arr['l_clicks'] = $r['l_clicks'];
$arr['ctr'] = $r['ctr'];
$arr['rs'] = $r['rs'];
$arr['at'] = $r['at'];
$arr = serialize( $arr );
$arr = "{$arr}\n";
gzwrite( $fp, $arr );
$arr = "";
}
$q = mysql_query( "select * from `niches`" );
while ( $r = mysql_fetch_assoc( $q ) )
{
$r['skim_url'] = unserialize( $r['skim_url'] );
$dump['dump_niches'][] = $r;
}
$dump['dump_settings'] = $settings;
$dump['dump_config']['skim_status'] = $config['skim_status'];
$dump = serialize( $dump );
$dump = "{$dump}\n";
gzwrite( $fp, $dump );
gzclose( $fp );
header( "Content-Disposition: attachment; filename=rotating_dump.gz" );
header( "Content-Type: application/force-download" );
header( "Content-Type: application/download" );
header( "Content-Description: File Transfer" );
header( "Content-Transfer-Encoding: binary" );
header( "Expires: 0" );
header( "Cache-Control: must-revalidate" );
header( "Pragma: public" );
header( "Content-Length: ".filesize( $dump_file ) );
readfile( $dump_file );
ob_clean( );
flush( );
exit( );
}
echo "\n\n\n\n\n\n\n";
if ( !empty( $_REQUEST['e'] ) && $_REQUEST['e'] == "news" )
{
html_header( );
$news = file_get_contents( "http://tuberotator.com/src/news.php" );
echo "<br>";
echo $news;
}
html_header( );
$avr_stats = get_stats( );
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>";
if ( !empty( $_REQUEST['e'] ) && $_REQUEST['e'] == "a" )
{
echo "<div id=\"content\">";
echo "<form action=\"admin.php\" method=\"post\">";
$q = mysql_query( "SELECT * from `niches` order by `name`" );
while ( $r = mysql_fetch_assoc( $q ) )
{
$r['ads'] = htmlspecialchars( $r['ads'] );
echo "<div id='ads_tab'>{$r['name']}<br> <textarea name='vars[{$r['name']}]' rows='10'>{$r['ads']}</textarea></div>";
}
echo "<input type=\"submit\" value=\"save\"></input><input type=\"hidden\" name=\"e\" value=\"as\"></input>";
if ( $config['a_block_flg'] == "on" )
{
$checked = "checked";
}
else
{
$checked = "";
}
echo "<input type='checkbox' name='a_block_flg' value='on' {$checked}><font color='gray'>use main if field empty</font> ";
echo "</div></form>";
}
if ( !empty( $_REQUEST['e'] ) && $_REQUEST['e'] == "as" )
{
foreach ( $_POST['vars'] as $key => $value )
{
$value = mysql_real_escape_string( $value );
mysql_query( "update `niches` set `ads`='{$value}' where `name`='{$key}'" );
}
if ( isset( $_REQUEST['a_block_flg'] ) )
{
$config['a_block_flg'] = $_REQUEST['a_block_flg'];
}
file_put_contents( "files/config", serialize( $config ) );
echo "<br><br>ok";
redir( "admin.php?e=a" );
}
if ( !empty( $_REQUEST['e'] ) && $_REQUEST['e'] == "t" )
{
$q = mysql_query( "select * from `templates` order by name desc" );
echo "<form action=\"admin.php\" method=\"post\">";
while ( $r = mysql_fetch_array( $q ) )
{
$str = "";
$template = htmlspecialchars( $r['template'] );
$rows = "30";
if ( preg_match( "/sub/i", $r['name'] ) )
{
$rows = "10";
}
if ( $r['name'] == "categories" )
{
$checked = "";
if ( $config['categories_order'] == "abc" )
{
$checked = "checked";
}
$str = "<input type='checkbox' name='categories_order' value='abc' {$checked}><font color='gray'>sort by abc</font> ";
}
echo "{$r['name']} {$str}<br> <textarea name='{$r['name']}' cols='150' rows='{$rows}'>{$template}</textarea><br><br>";
}
echo "<input type=\"submit\"></input><input type=\"hidden\" name=\"e\" value=\"ts\"></input></form>";
}
if ( !empty( $_REQUEST['e'] ) && $_REQUEST['e'] == "ts" )
{
$q = mysql_query( "select `name` from `templates`" );
while ( $r = mysql_fetch_array( $q ) )
{
$template = mysql_real_escape_string( $_POST["{$r['name']}"] );
$name = $r['name'];
mysql_query( "update `templates` set `template`='{$template}' where `name`='{$name}'" );
}
if ( !empty( $_REQUEST['categories_order'] ) )
{
$config['categories_order'] = "abc";
}
else
{
$config['categories_order'] = "ctr";
}
file_put_contents( "files/config", serialize( $config ) );
s_cookie( );
echo "<br><br>ok";
redir( "admin.php?e=t" );
}
if ( !empty( $_REQUEST['e'] ) && $_REQUEST['e'] == "n" )
{
$q = mysql_query( "select * from `niches` order by `name`" );
if ( $config['skim_status'] == "on" )
{
$checked = "checked";
}
else
{
$checked = "";
}
if ( $settings['grab_status'] == "noactive" )
{
echo "<div id=\"grab_status\">Grabber is noactive - click <a href=\"admin.php?s=grab_change\">here</a> for activate</div>";
}
echo "<form action='admin.php' method='post'><table> \n \n <tr>\n <td><b>niche</b></td>\n <td></td>\n <td>title</td>\n <td>description</td>\n <td><b>keywords *</b></td>\n <td><b>skim urls</b> <small>(http://cj.com,http://sex.com)...</small></td>\n <td><b>skim</b><input type='checkbox' name='skim_status' value='on' {$checked} title='skim activator'></td>\n <td><input type='text' name='skim_prod_keeper' value='{$config['skim_prod_keeper']}' size='3' title='skim prod keeper'></input></td>\n </tr>";
while ( $r = mysql_fetch_array( $q ) )
{
$str = "";
$r['skim_url'] = implode( ",", unserialize( $r['skim_url'] ) );
if ( $r['name'] == "main" )
{
$str = "readonly='readonly' style='background-color: YellowGreen'\n ";
}
echo "\n <input type='hidden' name='arr[]' value='{$r['id']}'></input>\n <tr>\n <td><input type='text' name='arr[]' {$str} value='{$r['name']}' size='15'></input></td>\n <td>({$r['num']})</td>\n <td><input type='text' name='arr[]' value='{$r['title']}' size='20'></input></td>\n <td><input type='text' name='arr[]' value='{$r['desc']}' size='35'></input></td>\n <td><input type='text' name='arr[]' value='{$r['keys']}' size='45' maxlength='250'></input></td>\n <td><input class='iskimurl' type='text' name='arr[]' value='{$r['skim_url']}' size='45'></input></td>\n <td><input class='iskim' type='text' name='arr[]' value='{$r['skim_prc']}' size='3'></input></td>\n \n \n \n <td><a href='index.php?n={$r['name']}' target='_blank'>link</a></td>\n </tr>\n ";
}
echo "<tr>\n <td>\n <input type='text' name='new[name]' size='15'></input></td>\n <td></td>\n <td><input type='text' name='new[title]' size='20'></input></td>\n <td><input type='text' name='new[desc]' size='35'></input></td>\n <td><input type='text' name='new[keys]' size='45'></input></td>\n <td><input id='mass_field' class='iskimurlv' onchange='iskim(\"iskimurl\");'type='text' name='new[skim_url]' size='45'></input></td>\n <td><input id='mass_field' class='iskimv' onchange='iskim(\"iskim\");' type='text' name='new[skim_prc]' size='3'></input></td>\n \n \n </tr>";
echo "</table><input type=\"submit\" value=\"Save\"></input><input type=\"hidden\" name=\"e\" value=\"ns\"></input></form>";
}
if ( !empty( $_REQUEST['e'] ) && $_REQUEST['e'] == "ns" )
{
if ( file_exists( "files/tmp/cron_recalc_n" ) )
{
unlink( "files/tmp/cron_recalc_n" );
}
$i = 0;
foreach ( $_REQUEST['arr'] as $value )
{
$f[$i] = mysql_real_escape_string( $value );
++$i;
if ( $i == 7 )
{
$i = 0;
if ( preg_match( "/[+|(|)]/", $f[4] ) )
{
preg_match( "/[a-z0-9\\+\\(\\)\\|\\s]{3,255}[a-z\\)]/i", $f[4], $matches );
$f[4] = $matches[0];
}
else
{
preg_match_all( "/([a-z]{3,12}\\*?)/i", $f[4], $arr );
$f[4] = implode( ",", $arr[0] );
}
if ( $f[4] == "" && $f[1] != "main" )
{
preg_match_all( "/([a-z]{3,12}\\*?)/i", $f[1], $arr );
$f[4] = implode( ",", $arr[0] );
$f[4] = "{$f[4]}";
if ( strlen( $f[4] < 3 ) )
{
$f[4] = "sex";
}
}
if ( !preg_match( "/^http/i", $f['5'] ) && $f['5'] != "" )
{
echo "<br>error - bad format for skim URL (niche {$f['1']})";
exit( );
}
$f['5'] = serialize( array_unique( explode( ",", $f['5'] ) ) );
$f['6'] = intval( $f['6'] );
if ( 100 < $f['6'] || $f['6'] < 0 )
{
$f['6'] = "100";
}
if ( $f[4] == "" && $f[1] == "main" )
{
$f[4] = "*";
}
if ( $f[1] != "" && $f[4] != "" )
{
if ( $f[2] == "" )
{
$f[2] = str_replace( "_", " ", $f[1] );
}
$niche_url = get_url( "{$f[1]}" );
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']}'" );
}
else if ( $f[1] == "" )
{
mysql_query( "delete from `niches` where `id`='{$f['0']}'" );
}
continue;
break;
}
}
if ( !empty( $_REQUEST['skim_status'] ) )
{
$config['skim_status'] = $_REQUEST['skim_status'];
}
else
{
$config['skim_status'] = "";
}
if ( !empty( $_REQUEST['skim_prod_keeper'] ) )
{
$config['skim_prod_keeper'] = intval( $_REQUEST['skim_prod_keeper'] );
}
else
{
$config['skim_prod_keeper'] = "";
}
file_put_contents( "files/config", serialize( $config ) );
echo "<br><br>ok<br>";
if ( $_REQUEST['new']['keys'] == "" )
{
$_REQUEST['new']['keys'] = $_REQUEST['new']['name'];
}
if ( $_REQUEST['new']['name'] != "" && $_REQUEST['new']['keys'] != "" )
{
$new_name = mysql_real_escape_string( $_REQUEST['new']['name'] );
$new_title = mysql_real_escape_string( $_REQUEST['new']['title'] );
if ( empty( $new_title ) )
{
$new_title = str_replace( "_", " ", $new_name );
}
$new_desc = mysql_real_escape_string( $_REQUEST['new']['desc'] );
if ( preg_match( "/[+|(|)]/", $_REQUEST['new']['keys'] ) )
{
preg_match( "/[a-z0-9\\+\\s\\(\\)\\|]{3,255}[a-z\\)]/i", $_REQUEST['new']['keys'], $arr );
$new_keys = $arr['0'];
}
else
{
preg_match_all( "/([a-z]{3,12}\\*?)/i", $_REQUEST['new']['keys'], $arr );
$new_keys = implode( ",", $arr['0'] );
}
$new_skim_url = serialize( array_unique( explode( ",", $_REQUEST['new']['skim_url'] ) ) );
if ( !preg_match( "/^http/i", $_REQUEST['new']['skim_url'] ) && $_REQUEST['new']['skim_url'] != "" )
{
echo "error - bad format for skim URL";
exit( );
}
$new_skim_prc = intval( $_REQUEST['new']['skim_prc'] );
if ( 100 < $new_skim_prc || $new_skim_prc < 0 )
{
$new_skim_prc = "100";
}
if ( strlen( $new_keys ) < 3 )
{
$new_keys = "sex";
}
$new_keys = mysql_real_escape_string( $new_keys );
$niche_url = get_url( "{$new_name}" );
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}')" );
}
if ( file_exists( "files/tmp/cron_recalc_n" ) )
{
@unlink( "files/tmp/cron_recalc_n" );
}
if ( file_exists( "files/tmp/cron_select_niche_thumb" ) )
{
@unlink( "files/tmp/cron_select_niche_thumb" );
}
if ( !empty( $new_name ) )
{
echo "added - {$new_name}<br>";
}
redir( "admin.php?e=n" );
exit( );
}
if ( !empty( $_REQUEST['e'] ) && $_REQUEST['e'] == "s" )
{
if ( $settings['grab_status'] == "active" )
{
$wr_change = "stop";
}
else
{
$wr_change = "start";
}
function decodeSize( $bytes )
{
$types = array( "B", "KB", "MB", "GB", "TB" );
$i = 0;
while ( 1024 <= $bytes && $i < count( $types ) - 1 )
{
$bytes /= 1024;
++$i;
}
return round( $bytes, 2 )." ".$types[$i];
}
@$free_size = @decodeSize( @disk_free_space( "content" ) );
echo "\n <form action='admin.php' method='get'><h6>\n ban content(keys) : <input type='text' name='ban_keys' size='80' value='{$settings['ban_keys']}'></input><br><br>\n grab only if keys : <input type='text' name='good_keys' size='80' value='{$settings['good_keys']}'></input><br><br><br>\n content limit, no more than : <input type='text' name='content_limit' size='8' value='{$settings['content_limit']}'></input><br>\n time limit, only if duration more than(sec) : <input type='text' name='duration_limit' size='4' value='{$settings['duration_limit']}'></input><br>\n grabb max gals per cron : <input type='text' name='grab_thumbs_limit' size='4' value='{$settings['grab_thumbs_limit']}'></input><br>\n level of cache : <input type='text' name='cache_step' size='4' value='{$config['cache_step']}'></input><br>\n \n </h6>\n\n ";
if ( $config['rotation_mode'] == "max_perfomance" )
{
$checked = "checked";
}
else
{
$checked = "";
}
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>";
if ( $config['new_page_for_raw_hits'] == "on" )
{
$checked = "checked";
}
else
{
$checked = "";
}
$tubes = explode( ",", file_get_contents( "files/tubes" ) );
echo "<br><br>Get content only from:";
foreach ( $tubes as $tube )
{
if ( @in_array( @$tube, @$settings['tubes'] ) )
{
$checked = "checked";
}
else
{
$checked = "";
}
echo "<br><input type='checkbox' name='tubes[]' value='{$tube}' {$checked}>{$tube}";
}
if ( $config['mode'] == "out" )
{
$checked = "checked";
}
else
{
$checked = "";
}
echo "<br><br><br><input type='checkbox' name='mode' value='out' {$checked}>Don't use embed and send to tube url<br><br>";
echo "<table>\n <tr>\n <td>New User:</td>\n <td><input type='text' name='user' size='10' value=''></input></td>\n <td>New Password:</td><td><input type='text' name='pass' size='10' value=''></input></td>";
if ( empty( $auth_ips['ip_admin_protect'] ) )
{
$auth_ips['ip_admin_protect'] = "";
}
echo "\n <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>\n \n</tr>";
echo "<tr>\n <td>Mysql User:</td>\n <td><input type='text' name='mysqluser' size='10' value=''></input></td>\n <td>Password:</td>\n <td><input type='text' name='mysqlpass' size='10' value=''></input></td>\n <td>mysql base:</td>\n <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>\n \n </tr></table><br>";
function check_lic( )
{
global $config;
$domain = preg_replace( "/^www./i", "", getenv( "HTTP_HOST" ) );
if ( !preg_match( "/{$domain}/i", getenv( "SCRIPT_FILENAME" ) ) )
{
$domain = mt_rand( 999, 999999 );
}
$str_to_key = "E45RtGD1Nb5 & +&7?r/Gt%4w8g5-^f1v#2@1xkjdpenDortmg)grF{$domain}T4G1fd-Qafuy6*D1cu&ld";
$key = sha1( $str_to_key );
$key = "{$domain}_{$key}";
if ( $key == @$config['lic_key'] )
{
return true;
}
return false;
}
if ( check_lic( ) == false )
{
echo "license key:<input type='text' name='lic_key' size='100' value=''></input>";
}
else
{
echo "<font color=\"green\">license status: ok</font>";
}
@$perf_arr = @unserialize( @file_get_contents( "files/tmp/last_check_perf" ) );
echo "\n <br><br><input type='hidden' name='e' value='ss'></input>\n <br> <input type='submit' value='Save settings'></input>\n </form> \n <span id='last_perf_check'>\n \n <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']}\n </span>\n \n \n <table id='table_check_perf'>\n <tr>\n <td>\n <a href='admin.php?s=check_perfomance'>Check site perfomance</a><br>\n \n </td>\n </tr>\n </table>\n \n <table id='table_w'>\n <tr>\n <td>\n <a href='admin.php?s=reset'>reset ALL DB stat</a><br>\n <a href='admin.php?s=reset_cache'>reset Cache</a><br>\n <br><a href='admin.php?s=remove_all'>Remove ALL content</a>\n </td>\n </tr>\n </table>\n Build {$script_version} - <a href='admin.php?s=get_updates'><font color='blue'>Update script</font></a> <br>\n <br>Free disk space = {$free_size}\n \n <br><br><br><br><a href='admin.php?s=rotating_dump'>export dump</a><br><br>\n \n <form ENCTYPE='multipart/form-data' action='admin.php' method='post' >\n <input type='file' name='rotating_dump'>\n <input type='hidden' name='s' value='upload_rotating_dump'>\n <input type='submit' value='import dump'> \n </form>\n \n \n <br>Grabber status - {$settings['grab_status']} <a href='admin.php?s=grab_change'>{$wr_change}</a>\n ";
$dir = realpath( "." );
$php_path = exec( "which php" );
if ( !$php_path )
{
$php_path = "{PATH TO PHP}";
}
echo "<h5>Cron</h5><div id='cron_info'>\n * * * * * cd {$dir}/files;{$php_path} cron.php 1>/dev/null 2>/dev/null</div><br>";
}
if ( !empty( $_REQUEST['e'] ) && $_REQUEST['e'] == "r" )
{
echo "<br><br>";
echo "User - {$flgs['server_user']}<br>";
echo "<table id=\"r_table\">";
echo "<td>Site</td><td>Traffic</td><td>Prod</td><td>Version</td>";
function network_stats( )
{
global $tmp_dir;
global $flgs;
$file = "{$tmp_dir}/tuberotator_net_{$flgs['server_user']}";
$arr = unserialize( file_get_contents( $file ) );
ksort( $arr );
foreach ( $arr as $url => $array )
{
echo "<tr id=\"r_t_tr\">";
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>";
echo "</tr>";
$total['hits'] = $total['hits'] + $array['hits'];
}
echo "<tr>";
echo "<td>total</td><td>{$total['hits']}</td><td></td>";
echo "</tr>";
echo "</table>";
}
network_stats( );
}
if ( !empty( $_REQUEST['e'] ) && $_REQUEST['e'] == "ss" )
{
$_GET['cache_step'] = intval( $_GET['cache_step'] );
if ( empty( $_GET['cache_step'] ) || $_GET['cache_step'] < 1 || 10 < $_GET['cache_step'] )
{
$_GET['cache_step'] = 1;
}
$config['cache_step'] = $_GET['cache_step'];
if ( !empty( $_GET['mysqluser'] ) && !empty( $_GET['mysqlpass'] ) )
{
$config['host'] = $_GET['mysqlhost'];
$config['user'] = $_GET['mysqluser'];
$config['pass'] = $_GET['mysqlpass'];
$config['dbname'] = $_GET['mysqlbase'];
}
preg_match_all( "/([a-z3]+\\*?)/i", $_GET['ban_keys'], $matches );
$s['ban_keys'] = implode( ",", $matches[0] );
preg_match_all( "/([a-z3]+\\*?)/i", $_GET['good_keys'], $matches );
$s['good_keys'] = implode( ",", $matches[0] );
if ( $s['ban_keys'] != $settings['ban_keys'] || $s['good_keys'] != $settings['good_keys'] )
{
mysql_query( "update `w_content` set `status`='7' where `status`='9'" );
}
$settings['ban_keys'] = $s['ban_keys'];
$settings['good_keys'] = $s['good_keys'];
preg_match_all( "/([0-9]{1,8})/", $_REQUEST['content_limit'], $matches );
$settings['content_limit'] = $matches[0][0];
if ( preg_match( "/([0-9\\.]{7,15})/", $_REQUEST['ip_admin_protect'], $matches ) )
{
$auth_ips['ip_admin_protect'] = $matches['1'];
$auth_ips = serialize( $auth_ips );
file_put_contents( "files/auth_ips", $auth_ips );
}
else if ( file_exists( "files/auth_ips" ) )
{
unlink( "files/auth_ips" );
}
preg_match_all( "/([0-9]{0,4})/", $_GET['grab_thumbs_limit'], $matches );
if ( 50 < $matches[0][0] )
{
$matches[0][0] = 50;
}
if ( empty( $matches[0][0] ) || $matches[0][0] < 1 )
{
$matches[0][0] = 5;
}
$settings['grab_thumbs_limit'] = $matches[0][0];
preg_match_all( "/([0-9]{0,4})/", $_GET['duration_limit'], $matches );
if ( $settings['duration_limit'] != $matches[0][0] )
{
$settings['duration_limit'] = $matches[0][0];
mysql_query( "update `w_content` set `status`='8' where `duration`<'{$settings['duration_limit']}'" );
}
if ( !empty( $_REQUEST['lic_key'] ) )
{
usleep( 500000 );
preg_match_all( "/([0-9a-z_\\.\\-]{20,100})/", $_REQUEST['lic_key'], $matches );
@$config['lic_key'] = $matches[0][0];
file_put_contents( "files/config", serialize( $config ) );
}
$settings['tubes'] = $_REQUEST['tubes'];
@$config['mode'] = $_REQUEST['mode'];
@$config['rotation_mode'] = $_REQUEST['rotation_mode'];
@$config['new_page_for_raw_hits'] = $_REQUEST['new_page_for_raw_hits'];
preg_match( "/(.*)admin\\.php.*/", $_SERVER['REQUEST_URI'], $matches );
@$config['index_dir_url'] = "http://{$_SERVER['HTTP_HOST']}{$matches['1']}";
file_put_contents( "files/settings", serialize( $settings ) );
file_put_contents( "files/config", serialize( $config ) );
echo "<br><br>done";
redir( "admin.php?e=s" );
}
if ( !empty( $_REQUEST['s'] ) && $_REQUEST['s'] == "reset" )
{
mysql_query( "update `w_content` set `clicks`='0',`t_clicks`='0',`l_clicks`='0',`t0_ctr`='0' ,`t1_ctr`='0' ,`t3_ctr`='0',`ctr`=FLOOR(1+RAND()*(10-1))/100000,`r`='0',`t_r`='0',`rs`='0' where `clicks`>'0' or `rs`>'0' or `t_r`>'0'" );
mysql_query( "TRUNCATE TABLE `pstats`" );
echo "<br><br>Reset status - ok";
redir( "admin.php?e=s" );
}
if ( !empty( $_REQUEST['s'] ) && $_REQUEST['s'] == "reset_cache" )
{
if ( file_exists( "files/tmp/cron_cache_cleaner" ) )
{
unlink( "files/tmp/cron_cache_cleaner" );
}
echo "<br><br>Ok, need 1-3min";
redir( "admin.php?e=s", "3" );
}
if ( !empty( $_REQUEST['s'] ) && $_REQUEST['s'] == "remove_all" )
{
mysql_query( "TRUNCATE `ids`;" );
mysql_query( "TRUNCATE `pstats`;" );
mysql_query( "TRUNCATE `tags_stats`;" );
mysql_query( "TRUNCATE `tags00`;" );
mysql_query( "TRUNCATE `tags01`;" );
mysql_query( "TRUNCATE `tags02`;" );
mysql_query( "TRUNCATE `tags03`;" );
mysql_query( "TRUNCATE `tags04`;" );
mysql_query( "TRUNCATE `tags05`;" );
mysql_query( "TRUNCATE `tags06`;" );
mysql_query( "TRUNCATE `tags07`;" );
mysql_query( "TRUNCATE `tags08`;" );
mysql_query( "TRUNCATE `tags09`;" );
mysql_query( "TRUNCATE `tags10`;" );
mysql_query( "TRUNCATE `tags11`;" );
mysql_query( "TRUNCATE `tags12`;" );
mysql_query( "TRUNCATE `tags13`;" );
mysql_query( "TRUNCATE `tags14`;" );
mysql_query( "TRUNCATE `tags15`;" );
mysql_query( "TRUNCATE `tags16`;" );
mysql_query( "TRUNCATE `tags17`;" );
mysql_query( "TRUNCATE `tags18`;" );
mysql_query( "TRUNCATE `tags19`;" );
mysql_query( "TRUNCATE `tags20`;" );
mysql_query( "TRUNCATE `tags21`;" );
mysql_query( "TRUNCATE `tags22`;" );
mysql_query( "TRUNCATE `tags23`;" );
mysql_query( "TRUNCATE `tags24`;" );
mysql_query( "TRUNCATE `tags25`;" );
mysql_query( "TRUNCATE `tags26`;" );
mysql_query( "TRUNCATE `tags27`;" );
mysql_query( "TRUNCATE `tags28`;" );
mysql_query( "TRUNCATE `tags29`;" );
mysql_query( "TRUNCATE `tags30`;" );
mysql_query( "TRUNCATE `tags31`;" );
mysql_query( "TRUNCATE `tags32`;" );
mysql_query( "TRUNCATE `tags33`;" );
mysql_query( "TRUNCATE `tags34`;" );
mysql_query( "TRUNCATE `tags35`;" );
mysql_query( "TRUNCATE `tags36`;" );
mysql_query( "TRUNCATE `tags37`;" );
mysql_query( "TRUNCATE `tags38`;" );
mysql_query( "TRUNCATE `tags39`;" );
mysql_query( "TRUNCATE `tags40`;" );
mysql_query( "TRUNCATE `tags41`;" );
mysql_query( "TRUNCATE `tags42`;" );
mysql_query( "TRUNCATE `tags43`;" );
mysql_query( "TRUNCATE `tags44`;" );
mysql_query( "TRUNCATE `tags45`;" );
mysql_query( "TRUNCATE `tags46`;" );
mysql_query( "TRUNCATE `tags47`;" );
mysql_query( "TRUNCATE `tags48`;" );
mysql_query( "TRUNCATE `tags49`;" );
mysql_query( "TRUNCATE `tags50`;" );
mysql_query( "TRUNCATE `tags51`;" );
mysql_query( "TRUNCATE `tags52`;" );
mysql_query( "TRUNCATE `tags53`;" );
mysql_query( "TRUNCATE `tags54`;" );
mysql_query( "TRUNCATE `tags55`;" );
mysql_query( "TRUNCATE `tags56`;" );
mysql_query( "TRUNCATE `tags57`;" );
mysql_query( "TRUNCATE `tags58`;" );
mysql_query( "TRUNCATE `tags59`;" );
mysql_query( "TRUNCATE `tags60`;" );
mysql_query( "TRUNCATE `tags61`;" );
mysql_query( "TRUNCATE `tags62`;" );
mysql_query( "TRUNCATE `tags63`;" );
mysql_query( "TRUNCATE `tags64`;" );
mysql_query( "TRUNCATE `tags65`;" );
mysql_query( "TRUNCATE `tags66`;" );
mysql_query( "TRUNCATE `tags67`;" );
mysql_query( "TRUNCATE `tags68`;" );
mysql_query( "TRUNCATE `tags69`;" );
mysql_query( "TRUNCATE `tags70`;" );
mysql_query( "TRUNCATE `tags71`;" );
mysql_query( "TRUNCATE `tags72`;" );
mysql_query( "TRUNCATE `tags73`;" );
mysql_query( "TRUNCATE `tags74`;" );
mysql_query( "TRUNCATE `tags75`;" );
mysql_query( "TRUNCATE `tags76`;" );
mysql_query( "TRUNCATE `tags77`;" );
mysql_query( "TRUNCATE `tags78`;" );
mysql_query( "TRUNCATE `tags79`;" );
mysql_query( "TRUNCATE `tags80`;" );
mysql_query( "TRUNCATE `tags81`;" );
mysql_query( "TRUNCATE `tags82`;" );
mysql_query( "TRUNCATE `tags83`;" );
mysql_query( "TRUNCATE `tags84`;" );
mysql_query( "TRUNCATE `tags85`;" );
mysql_query( "TRUNCATE `tags86`;" );
mysql_query( "TRUNCATE `tags87`;" );
mysql_query( "TRUNCATE `tags88`;" );
mysql_query( "TRUNCATE `tags89`;" );
mysql_query( "TRUNCATE `tags90`;" );
mysql_query( "TRUNCATE `tags91`;" );
mysql_query( "TRUNCATE `tags92`;" );
mysql_query( "TRUNCATE `tags93`;" );
mysql_query( "TRUNCATE `tags94`;" );
mysql_query( "TRUNCATE `tags95`;" );
mysql_query( "TRUNCATE `tags96`;" );
mysql_query( "TRUNCATE `tags97`;" );
mysql_query( "TRUNCATE `tags98`;" );
mysql_query( "TRUNCATE `tags99`;" );
mysql_query( "TRUNCATE `th_hash`;" );
mysql_query( "TRUNCATE `tmp`;" );
file_put_contents( "files/tmp/cron_remove_all", "" );
echo "<br><br>done";
redir( "admin.php?e=s" );
}
if ( !empty( $_REQUEST['s'] ) && $_REQUEST['s'] == "grab_change" )
{
if ( $settings['grab_status'] == "noactive" )
{
$settings['grab_status'] = "active";
}
else
{
$settings['grab_status'] = "noactive";
}
file_put_contents( "files/settings", serialize( $settings ) );
echo "<br><br>done, new status - {$settings['grab_status']}";
redir( "admin.php?e=s" );
}
if ( !empty( $_GET['user'] ) && !empty( $_GET['pass'] ) )
{
$auth['user'] = addslashes( $_GET['user'] );
$auth['pass'] = addslashes( $_GET['pass'] );
$auth = serialize( $auth );
if ( file_exists( "files/auth" ) )
{
unlink( "files/auth" );
}
if ( !file_put_contents( "files/auth", $auth ) )
{
echo "ошибка создания файла аутенфикации!";
}
}
if ( !empty( $_REQUEST['s'] ) && $_REQUEST['s'] == "check_perfomance" )
{
$host = $_SERVER['HTTP_HOST'];
$sub = str_replace( "admin.php", "", $_SERVER['SCRIPT_NAME'] );
$url = "http://{$host}{$sub}";
$time = microtime( true );
$qn = mysql_query( "select * from `niches`" );
while ( $rn = mysql_fetch_assoc( $qn ) )
{
$niches[] = $rn['name'];
}
$c = 0;
$start_time = time( );
$i = 0;
while ( $i < 10 )
{
$q = mysql_query( "select * from `tags_stats` order by rand() limit 200" );
do
{
if ( !( $r = mysql_fetch_array( $q ) ) )
{
break;
}
else
{
$p = rand( 1, 3 );
$st = microtime( true );
$str1 = "{$url}t/{$r['tag']}/p{$p}/";
file_get_contents( $str1 );
$t = microtime( true ) - $st;
}
if ( 1 <= $t )
{
$t_arr[] = "{$t} : {$str1}";
}
if ( $t <= "1" && 0.5 < $t )
{
$f_arr[] = "{$t} : {$str1}";
}
if ( $t <= "0.5" )
{
$l_arr[] = "{$t} : {$str1}";
}
++$c;
$p = rand( 1, 3 );
shuffle( $niches );
$st = microtime( true );
$niche = $niches['0'];
if ( rand( 1, 3 ) == "3" )
{
$niche = "main";
}
$str2 = "{$url}{$niche}/p{$p}/";
file_get_contents( $str2 );
$t = microtime( true ) - $st;
if ( 1 <= $t )
{
$t_arr[] = "{$t} : {$str2}";
}
if ( $t <= "1" && 0.5 < $t )
{
$f_arr[] = "{$t} : {$str2}";
}
if ( $t <= "0.5" )
{
$l_arr[] = "{$t} : {$str2}";
}
++$c;
} while ( !( 2000 <= $c || 25 <= time( ) - $start_time ) );
break;
++$i;
}
$perf_arr['per_sec'] = round( $c / ( microtime( true ) - $time ), 1 );
$perf_arr['per_page'] = round( 1 / $perf_arr['per_sec'], 4 );
$pt = round( 86400 * $c / ( microtime( true ) - $time ), 0 );
if ( 1000000 <= $pt )
{
$d = "1000000";
$m = "Mhits";
}
else
{
$d = "1000";
$m = "Khits";
}
$n = round( $pt / $d, 1 );
$ik = "{$n}{$m} Hits/day";
echo "<br>i can keep up to ";
echo round( $pt / $d, 1 );
echo "{$m} per day";
$perf_arr['per_day'] = $ik;
file_put_contents( "files/tmp/last_check_perf", serialize( $perf_arr ) );
}
$flg_updates_wait = "files/tmp/flg_updates_wait";
if ( !empty( $_REQUEST['s'] ) && $_REQUEST['s'] == "get_updates" )
{
$update = check_updates( );
if ( $update['status'] == "notfound" )
{
echo "<br>updates not found";
}
else
{
if ( $update['status'] == "error" )
{
echo "<br>Error or server busy";
}
else
{
if ( $update['status'] == "ok" )
{
file_put_contents( "files/tmp/updates", $update['archive'] );
exec( "tar -m -xvf files/tmp/updates", $out );
exec( "tar -tf files/tmp/updates", $out );
$log = "";
if ( !$out )
{
echo "<br>error";
exit( );
}
else
{
echo "<br><br>";
foreach ( $out as $key => $file )
{
if ( filemtime( $file ) + 60 < time( ) )
{
$log .= "<font color=red>{$file} - update error</font><br>";
}
else
{
$log .= "{$file} - <font color=green>ok</font><br>";
}
}
echo $log;
include( "files/update.inc" );
unlink( "files/tmp/updates" );
unlink( "files/update.inc" );
unlink( $flg_updates_wait );
file_put_contents( "files/settings", serialize( $settings ) );
file_put_contents( "files/config", serialize( $config ) );
}
}
}
}
}
else
{
if ( cron( "check_updates", "86000" ) )
{
$update = check_updates( );
if ( $update['status'] == "ok" )
{
file_put_contents( $flg_updates_wait, "" );
}
}
if ( file_exists( $flg_updates_wait ) )
{
echo "<span id=\"plz_update\">click <a href=\"admin.php?s=get_updates\">here</a> for update</span>";
}
}
if ( !empty( $_REQUEST['s'] ) && $_REQUEST['s'] == "upload_rotating_dump" )
{
move_uploaded_file( $_FILES['rotating_dump']['tmp_name'], "files/tmp/upload_rotating_dump.gz" );
$dump_file = "files/tmp/upload_rotating_dump.gz";
if ( file_exists( $dump_file ) )
{
$fp = gzopen( $dump_file, "r" );
$i = 0;
while ( $data = fgets( $fp ) )
{
$r = unserialize( $data );
if ( !empty( $r ) && !empty( $r['id'] ) && !empty( $r['prov'] ) && !empty( $r['thumbs'] ) && !empty( $r['embed'] ) )
{
$r[thumbs] = serialize( $r[thumbs] );
mysql_query( "\n insert into `w_content` \n (`id`,`oid`,`prov`,`url`,`title`,`thumbs`,`embed`,`duration`,`r`,`t_r`,`clicks`,`t_clicks`,`l_clicks`,`ctr`,`rs`,`at`)\n VALUES\n ('{$r['id']}','{$r['oid']}','{$r['prov']}','{$r['url']}','{$r['title']}','{$r['thumbs']}','{$r['embed']}','{$r['duration']}','{$r['r']}','{$r['t_r']}','{$r['clicks']}','{$r['t_clicks']}','{$r['l_clicks']}','{$r['ctr']}','{$r['rs']}','{$r['at']}')\n " );
++$i;
}
if ( array_key_exists( "dump_settings", $r ) )
{
$settings = $r['dump_settings'];
file_put_contents( "files/settings", $settings );
++$i;
}
if ( array_key_exists( "dump_config", $r ) )
{
$config['skim_status'] = $r['dump_config']['skim_status'];
$config = serialize( $config );
file_put_contents( "files/config", $config );
++$i;
}
if ( array_key_exists( "dump_niches", $r ) )
{
mysql_query( "TRUNCATE TABLE `niches`" );
foreach ( $r['dump_niches'] as $niche )
{
$niche['skim_url'] = serialize( $niche['skim_url'] );
mysql_query( "\n insert into `niches` \n (`name`,`title`,`desc`,`keys`,`skim_url`,`skim_prc`,`num`)\n VALUES\n ('{$niche['name']}','{$niche['title']}','{$niche['desc']}','{$niche['keys']}','{$niche['skim_url']}','{$niche['skim_prc']}','{$niche['num']}')\n " );
}
}
}
if ( 0 < $i )
{
echo "<br> done";
}
else
{
echo "<br> ERROR please use only tuberotator format";
}
unlink( $dump_file );
redir( "admin.php?e=n" );
}
}
file_put_contents( "files/settings", serialize( $settings ) );
@file_put_contents( "files/tmp/last_adm_act", "" );
echo "\n \n\n</body>\n</html>\n \n \n ";
?>
file 2:
<?php
function curent_date( $var, $var2 )
{
date_default_timezone_set( "Europe/Dublin" );
return date( $var, $var2 );
}
function w_log( $name, $content )
{
global $warr;
$worked_time = round( microtime( true ) - $warr['start_time'], 3 );
$ram = memory_get_usage( );
$warr .= "log";
}
function is_boot( )
{
if ( !preg_match( "/bot|crawl|spider|robo/i", $_SERVER['HTTP_USER_AGENT'] ) && preg_match( "/firefox|windows|explor|chrome|opera/i", $_SERVER['HTTP_USER_AGENT'] ) )
{
return false;
}
return true;
}
function skim( $skim )
{
$rn = floor( 10000 / $skim );
if ( mt_rand( 1, $rn ) <= 100 && 0 < $skim )
{
return true;
}
return false;
}
function title_to_len( $title, $limit )
{
if ( $limit < strlen( $title ) )
{
$title = substr( $title, 0, strrpos( substr( $title, 0, $limit ), " " ) )."";
}
return $title;
}
ini_set( "expose_php", "off" );
ini_set( "display_errors", "off" );
ini_set( "display_startup_errors", "off" );
$config = unserialize( file_get_contents( "files/config" ) );
$flgs = unserialize( file_get_contents( "files/flgs" ) );
$st = microtime( true );
$time = time( );
$cache_step = $config['cache_step'];
if ( empty( $cache_step ) )
{
$cache_step = 1;
}
$curent_hour = curent_date( "G", time( ) );
$pstats_id = md5( $_SERVER['REQUEST_URI'] );
$host = str_replace( "www.", "", getenv( "HTTP_HOST" ) );
$warr = array( );
$warr['start_time'] = microtime( true );
$warr['host'] = $host;
if ( preg_match( "/n=|t=|f=/i", $_SERVER['REQUEST_URI'] ) )
{
preg_match( "/([\\.\\?\\=0-9a-z\\_\\-\\/]{1,64})/i", $_SERVER['REQUEST_URI'], $matches );
}
else
{
preg_match( "/([0-9a-z\\_\\-\\/]{1,64})/i", $_SERVER['REQUEST_URI'], $matches );
}
$warr['uri_filtred'] = $matches['1'];
$warr['query_url'] = str_replace( "www.", "", "http://{$_SERVER['HTTP_HOST']}{$warr['uri_filtred']}" );
$warr['log'] = "";
$warr['format'] = "m";
$warr['param_str'] = "";
$warr['query_mode'] = "base_search";
w_log( "warr_query_url", $warr['query_url'] );
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
{
$_SERVER['HTTP_USER_AGENT'] = "bot";
}
$warr['is_boot'] = is_boot( );
$link = mysql_connect( $config['host'], $config['user'], $config['pass'] );
if ( mysql_select_db( $config['dbname'], $link ) )
{
w_log( "mysql_select_db", "ok" );
}
else
{
w_log( "mysql_select_db", "error" );
}
$cache_time = 240 * $cache_step;
if ( 15 < $flgs['la']['0'] )
{
$cache_time = $cache_time * 10;
}
if ( isset( $_COOKIE['adminlog'] ) )
{
$cache_time = "0";
}
if ( !empty( $_REQUEST['p'] ) )
{
preg_match( "/[0-9]{0,3}/", $_REQUEST['p'], $matches );
$warr['p'] = $matches['0'];
$warr .= "param_str";
}
if ( $_REQUEST['n'] != "main" )
{
preg_match( "/[a-z0-9_]{1,32}/i", $_REQUEST['n'], $matches );
$_REQUEST['n'] = $matches['0'];
$warr['query_niche'] = $matches['0'];
$warr .= "param_str";
$warr['n'] = $matches['0'];
if ( !empty( $_COOKIE['tr_categories'] ) && $warr['is_boot'] == false )
{
mysql_query( "update `niches` set `clicks`=clicks+1 where `name`='{$warr['query_niche']}'" );
}
}
if ( !empty( $_REQUEST['t'] ) )
{
preg_match( "/[a-z0-9]{1,32}/i", $_REQUEST['t'], $matches );
$_REQUEST['t'] = $matches['0'];
$warr .= "param_str";
$warr['t'] = $matches['0'];
}
if ( !empty( $warr['t'] ) || !empty( $warr['p'] ) )
{
$cache_time = 14400 * $cache_step;
}
if ( !empty( $_REQUEST['id'] ) )
{
preg_match( "/v([0-9]{1,8})/", $_REQUEST['id'], $matches );
@$id = @$matches['1'];
@$warr['id'] = $matches['1'];
$warr .= "param_str";
}
if ( !empty( $_REQUEST['f'] ) && count( $_REQUEST['f'] ) == "1" && $_REQUEST['f'] == "c" )
{
$warr['format'] = "c";
$warr .= "param_str";
$cache_time = $cache_time * 3;
setcookie( "tr_categories", "1", time( ) + 86400, "/", ".{$host}" );
mysql_query( "update `niches` set `hits`=hits+1 where `name`='main'" );
}
$warr['cache_file'] = md5( $warr['param_str'] );
w_log( "cache_file", $warr['cache_file'] );
$r_max = 20;
$rp_max = 10;
if ( $flgs['num_rs'] <= 200 )
{
$r_max = 3;
$rp_max = 2;
}
if ( 200 < $flgs['num_rs'] && $flgs['num_rs'] < 1000 )
{
$r_max = 5;
$rp_max = 8;
}
if ( mt_rand( 1, $r_max ) == "1" )
{
$rand = true;
}
if ( empty( $_COOKIE['tr_main'] ) && $warr['is_boot'] == false && $warr['format'] != "c" )
{
w_log( "mysql_insert_pstats", "start" );
if ( mysql_query( "UPDATE `pstats` set `i`=`i`+'1' where `id`='{$pstats_id}'" ) )
{
w_log( "mysql_insert_pstats", "ok" );
}
else
{
w_log( "mysql_insert_pstats", "error" );
}
if ( mysql_query( "update `stats_h`\n set `hits`=hits+1\n where `hour`='{$curent_hour}'\n " ) )
{
w_log( "mysql_update_hits", "ok" );
}
else
{
w_log( "mysql_update_hits", "error" );
}
}
else
{
w_log( "mysql_update_hits", "noneed" );
}
if ( !empty( $id ) )
{
w_log( "as_id", $id );
if ( !empty( $_COOKIE['tr_main'] ) && $_COOKIE['tr_main'] < 21 && empty( $_COOKIE['tr_cjclicks'] ) && !preg_match( "/bot|crawl|spider|robo/i", $_SERVER['HTTP_USER_AGENT'] ) && preg_match( "/firefox|windows|explor|chrome|opera/i", $_SERVER['HTTP_USER_AGENT'] ) )
{
mysql_query( "update `w_content` set `l_clicks`=l_clicks+1,`clicks`=clicks+1 where `id` = '{$id}'" );
mysql_query( "update `stats_h` set `clicks`=clicks+1 where `hour` = '{$curent_hour}'" );
w_log( "as_id_update_stats", "ok" );
}
if ( mt_rand( 1, 100 ) == "1" && empty( $_COOKIE['tr_cjclicks'] ) && !empty( $_COOKIE['tr_main'] ) )
{
$domain = preg_replace( "/^www./i", "", getenv( "HTTP_HOST" ) );
if ( !preg_match( "/{$domain}/i", getenv( "SCRIPT_FILENAME" ) ) )
{
$domain = mt_rand( 999, 999999 );
}
$str_to_key = "E45RtGD1Nb5 & +&7?r/Gt%4w8g5-^f1v#2@1xkjdpenDortmg)grF{$domain}T4G1fd-Qafuy6*D1cu&ld";
$key = sha1( $str_to_key );
$key = "{$domain}_{$key}";
if ( $config['lic_key'] != $key )
{
header( "location:http://www.tuberotator.com/src/in.php?d={$domain}&n={$_REQUEST['n']}&t={$_REQUEST['t']}" );
mysql_close( );
exit( );
}
unset( $key );
unset( $str_to_key );
}
if ( $config['mode'] == "out" )
{
$q = mysql_query( "select url from `w_content` where `id`='{$id}'" );
$r = mysql_fetch_array( $q );
header( "location:{$r['url']}" );
exit( );
}
$cache_time = 3600 * 6 * $cache_step;
if ( isset( $_COOKIE['adminlog'] ) )
{
$cache_time = "0";
}
$rel = true;
}
if ( empty( $_COOKIE['tr_main'] ) )
{
setcookie( "tr_main", "1", time( ) + 86400, "/", ".{$host}" );
w_log( "cookie_new_tr_main", "ok" );
}
else
{
$c = intval( $_COOKIE['tr_main'] ) + 1;
setcookie( "tr_main", $c, time( ) + 86400, "/", ".{$host}" );
w_log( "cookie_update_tr_main", $c );
}
$cache_file = $warr['cache_file'];
$cache_dir = substr( $cache_file, 0, 3 );
$cache_dir = "files/tmp/cache/{$cache_dir}";
$cache_file = "{$cache_dir}/{$cache_file}";
w_log( "cache_check_local_files", "start" );
if ( file_exists( "files/tmp/flgs_regen_url" ) )
{
$flgs_regen_url = file_get_contents( "files/tmp/flgs_regen_url" );
}
else
{
$flgs_regen_url = false;
}
if ( file_exists( $cache_file ) && $warr['query_url'] != $flgs_regen_url && empty( $_COOKIE['adminlog'] ) )
{
w_log( "cache_check_local_files", "end" );
if ( time( ) - $cache_time < filemtime( $cache_file ) )
{
$flgs['cache'] = "on";
w_log( "cache_read_cache_file", "start" );
include( $cache_file );
w_log( "cache_read_cache_file", "end" );
w_log( "cache_time", $cache_time );
w_log( "cache_get_from_file", $cache_file );
}
else
{
if ( file_exists( "files/tmp/cache/caches" ) )
{
$caches = unserialize( file_get_contents( "files/tmp/cache/caches" ) );
if ( !is_array( $caches ) )
{
$caches = array( );
}
}
else
{
$caches = array( );
}
if ( !in_array( $warr['query_url'], $caches ) )
{
$caches[] = $warr['query_url'];
}
if ( file_exists( "files/tmp/cache/caches" ) )
{
unlink( "files/tmp/cache/caches" );
}
file_put_contents( "files/tmp/cache/caches", serialize( $caches ) );
chmod( "files/tmp/cache/caches", 438 );
file_put_contents( $cache_file, file_get_contents( $cache_file ) );
include( $cache_file );
}
}
else
{
w_log( "content", "gen new start" );
file_put_contents( "files/tmp/tmp_gen_page", "" );
$flgs['cache'] = "off";
$q = mysql_query( "SELECT * FROM `templates`" );
while ( $r = mysql_fetch_array( $q ) )
{
$arr['templates'][$r['name']] = $r['template'];
}
if ( empty( $_REQUEST['n'] ) && empty( $_REQUEST['t'] ) )
{
$_REQUEST['n'] = "main";
w_log( "content", "type main" );
}
function get_all_ads( $ads )
{
global $config;
if ( empty( $ads ) && isset( $config['a_block_flg'] ) && $config['a_block_flg'] == "on" )
{
$q = mysql_query( "SELECT * FROM `niches` where `name`='main'" );
$r = mysql_fetch_assoc( $q );
$ads = $r['ads'];
}
if ( preg_match( "/STARTADS/", $ads ) )
{
preg_match_all( "/\\<--STARTADS([0-9]{1,3})--\\>(.+)\\<--END--\\>/Us", $ads, $matches, PREG_SET_ORDER );
foreach ( $matches as $value )
{
$ads_arr[$value[1]] = $value[2];
}
}
else
{
$ads_arr['0'] = $ads;
}
return $ads_arr;
}
if ( !empty( $_REQUEST['n'] ) )
{
$q = mysql_query( "select * from `niches`" );
while ( $r = mysql_fetch_assoc( $q ) )
{
$warr['all_niches_arr'] = $r;
$warr['all_niches_keys'][] = $r['name'];
$warr['all_niches_thumbs'][] = $r['thumb'];
}
preg_match_all( "/[a-z0-9_]{3,24}\\*?/i", $_REQUEST['n'], $search_query );
@$niche = @mysql_real_escape_string( @$search_query['0']['0'] );
$q = mysql_query( "SELECT * FROM `niches` where `name`='{$niche}'" );
$r = mysql_fetch_assoc( $q );
$niche = $r['name'];
$niche_num = $r['num'];
$niche_keys = $r['keys'];
$warr['niche_keys'] = $r['keys'];
$niche_title = $r['title'];
$niche_desc = $r['desc'];
$query = $niche_keys;
$warr['niche_ads_arr'] = get_all_ads( $r['ads'] );
if ( preg_match( "/[\\(|\\)]/", $niche_keys ) )
{
preg_match_all( "/[a-z0-9\\(\\)\\+\\s\\*\\-\\~]{3,128}\\*?/i", $niche_keys, $search_query );
$warr['query_mode'] = "full_search";
}
else
{
preg_match_all( "/[a-z0-9]{3,18}\\*?/i", $niche_keys, $search_query );
}
w_log( "content", "VARS:niche={$niche};niche_num = {$niche_num};niche_keys={$niche_keys};query={$query}" );
}
else if ( !empty( $_REQUEST['t'] ) )
{
w_log( "content", "type tag" );
$q = mysql_query( "SELECT * FROM `niches` where `name`='main'" );
$r = mysql_fetch_assoc( $q );
$warr['niche_ads_arr'] = get_all_ads( $r['ads'] );
preg_match_all( "/[a-z]{3,18}/i", $_REQUEST['t'], $search_query );
@$query = @$search_query['0']['0'];
$q = mysql_query( "SELECT sum(num) FROM `tags_stats` WHERE `tag` like '{$query}%'" );
$r = mysql_fetch_row( $q );
$niche_num = $r['0'];
w_log( "content", "VARS:query={$query};niche_num={$niche_num}" );
}
$search_query = array_unique( $search_query['0'] );
$search_str = implode( " ", $search_query );
$num_words = count( $search_query );
if ( $warr['format'] == "c" )
{
$main_tmpl = $arr['templates']['categories'];
$warr['query'] = "";
}
else
{
$main_tmp |
|
|
|
|
|
www.waraxe.us Forum Index -> PHP script decode requests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT
Page 1 of 1
|
|
|
Powered by phpBB © 2001-2008 phpBB Group
|
|
|
|
|
|