details.php
changeset 21 0bd6e7537154
parent 19 a1ed9d6856d6
child 22 52aaf1a838bd
equal deleted inserted replaced
20:b7f8324faded 21:0bd6e7537154
    42 			$enum = $row["enum"];
    42 			$enum = $row["enum"];
    43                 	$result->close();
    43                 	$result->close();
    44 
    44 
    45                         }
    45                         }
    46 
    46 
    47 /*        if ($currID == "")
       
    48         {
       
    49                 $currID = "1";
       
    50 echo $currID;
       
    51 	}	
       
    52 */
       
    53 /*	if ($currID == "") 
       
    54 	{
       
    55 		$currID = 1;
       
    56 		$mysql = new mysqli("localhost", "www-data", "www-data", "members");
       
    57  #       	$result = $mysql->query("SELECT sid, sid_dir FROM sessions WHERE ((uid = '$currID' or uid = 1) AND (expiration_date = DATE_ADD(NOW(), INTERVAL 24 HOUR)))");
       
    58 $result = $mysql->query("SELECT sid, sid_dir FROM sessions WHERE ((uid = '$currID' or uid = 1) AND (expiration_date = DATE_ADD(NOW(), INTERVAL 24 HOUR)))");
       
    59         	$row = $result->fetch_assoc();
       
    60         	$tsid1 = $row["sid"];
       
    61 		$tsid2 = $row["sid_dir"];
       
    62         	$result->close();
       
    63 
       
    64 
       
    65 	}
       
    66 */
       
    67  	// read session IDs from cookie, if cookie doesn't exist, set to 06D5VlLQTbM57LL7IBMW38yHkFpb1XVa (master)
       
    68 
       
    69 
       
    70 
       
    71 //echo $_COOKIE["sid1"];
       
    72         $currSID2 = $_COOKIE['sid2'];
    47         $currSID2 = $_COOKIE['sid2'];
    73 	$sid2 = $currSID2;
    48 	$sid2 = $currSID2;
    74                 if (!isset($_COOKIE['sid2']))
    49                 if (!isset($_COOKIE['sid2']))
    75                         {
    50                         {
    76 			$sid2 = $tsid2;
    51 			$sid2 = $tsid2;
    77 //                        $sid2 = '06D5VlLQTbM57LL7IBMW38yHkFpb1XVa';
    52 //                        $sid2 = '06D5VlLQTbM57LL7IBMW38yHkFpb1XVa';
    78 			$currSID2 = $sid2;
    53 			$currSID2 = $sid2;
    79                         }
    54                         }
    80 /*echo $uid;
       
    81 echo $sid1;
       
    82 echo $sid2;
       
    83 echo $enum;
       
    84 */
       
    85 /*
       
    86 	if ($currSID1 == "")
       
    87         {
       
    88                 $currSID1 = "06D5VlLQTbM57LL7IBMW38yHkFpb1XVa";
       
    89 //		$currSID1 = $tsid1;
       
    90 
       
    91 echo $currSID1;
       
    92 
       
    93         }
       
    94 
       
    95         $currSID2 = $_COOKIE['sid2'];
       
    96 	if ($currSID2 == "")
       
    97         {
       
    98                 $currSID2 = "06D5VlLQTbM57LL7IBMW38yHkFpb1XVa";
       
    99 //		$currSID2 = $tsid2;
       
   100 echo $currSID2;
       
   101         }
       
   102 */
       
   103 #print_r($_COOKIE);
       
   104 	
    55 	
   105 	$status = $_GET['alert'];
    56 	$status = $_GET['alert'];
   106 	$view_mode = $_GET['view_mode'];
    57 	$view_mode = $_GET['view_mode'];
   107 	$view_order = $_GET['view_order'];
    58 	$view_order = $_GET['view_order'];
   108 	
    59 	
   120 		$query_cache = mysql_query("SELECT * FROM requests_tbl WHERE (uid = '$currID' OR uid = 1)");
    71 		$query_cache = mysql_query("SELECT * FROM requests_tbl WHERE (uid = '$currID' OR uid = 1)");
   121 	} 
    72 	} 
   122 	else 
    73 	else 
   123 	{
    74 	{
   124 		$query_cache = mysql_query("SELECT * FROM requests_tbl WHERE (uid = 1)");
    75 		$query_cache = mysql_query("SELECT * FROM requests_tbl WHERE (uid = 1)");
   125                         while ($db_fieldcache = mysql_fetch_assoc($query_cache))
    76 	}
       
    77  /*                       while ($db_fieldcache = mysql_fetch_assoc($query_cache))
   126                         {
    78                         {
   127                         // send command to squid and return value
    79 			$curr_reqID = $db_fieldcache["req_ID"];
   128     #                    $command2 = "squidclient -m HEAD -p 8080 -H \"Cache-Control: only-if-cached\n\" -u " . $db_fieldcache["req_ID"] . " -w " . $db_fieldcache["uid"] . " " . $db_fieldcache["req_val"] . " |grep X-Cache: |grep MISS";
    80 			$strip_url_val = remove_http($db_fieldcache['req_val']);
   129 #                    $command2 = "squidclient -m HEAD -p 8080" . $db_fieldcache["req_val"] . " |grep X-Cache: |grep MISS";
    81 			$http_proxy = "http://localhost:8080";
   130 //                    $command2 = "squidclient -m HEAD -p 8080 -u {$db_fieldcache["req_ID"]} -w $currSID1 http://localhost/router_stage/{$db_fieldcache["req_ID"]}/$strip_url_val/ |grep X-Cache: |grep MISS";
    82 			$command2 = "squidclient -m HEAD -p 8080 -u www-data -w www-data http://localhost/router_stage/{$db_fieldcache["req_ID"]}/$strip_url_val/?uid=$uid'&'sid1=$sid1'&'sid2=$sid2 |grep MISS |awk -F \" \" '{print $2}'";
   131 		    $curr_reqID = $db_fieldcache["req_ID"];
    83 			exec($command2, $cache_results);
   132 #                    $http_proxy = "http://localhost:8080";
    84 			echo $cache_results;
   133 #                    $staging = "/var/www/private/HTMLrequester/staging/";
       
   134 #                    $wget_options = " --delete-after -N -r -l 3 --no-remove-listing -p --max-redirect 10 -t 1 -d";
       
   135 #                    $strip_url_val = remove_http($db_fieldcache['req_val']);
       
   136 #                                        $command1 = "wget -P $staging $wget_options http://localhost/router_stage/{$db_fieldcache["req_ID"]}/$strip_url_val/ . '?' . 'uid=' . $uid . '&'  . 'sid1=' . $sid1 . '&' . 'sid2=' . $sid2";
       
   137 #                    exec($command1, $wget_results);
       
   138 
       
   139 $http_proxy = "http://localhost:8080";
       
   140                     $command2 = "squidclient -m HEAD -p 8080 -u www-data -w www-data http://localhost/router_stage/{$db_fieldcache["req_ID"]}/$strip_url_val/?uid=$uid'&'sid1=$sid1'&'sid2=$sid2 |grep X-Cache: |grep MISS";
       
   141                         exec($command2, $cache_results);
       
   142                         // find out if site is available and update the database
    85                         // find out if site is available and update the database
   143                                 if (strpos($cache_results, "HIT") == true)
    86                                 if (strpos($cache_results, "HIT") == true)
   144                                         {
    87                                         {
   145                                         $query_update = mysql_query("UPDATE responses_tbl SET req_response = '1' WHERE req_ID = '$curr_reqID'");
    88                                         $query_update = mysql_query("UPDATE responses_tbl SET req_response = '1' WHERE req_ID = '$curr_reqID'");
   146                                         }
    89                                         }
   148                                         {
    91                                         {
   149                 			$filename = "/var/www/private/HTMLrequester/router_stage/{$db_fieldcache["req_ID"]}/";
    92                 			$filename = "/var/www/private/HTMLrequester/router_stage/{$db_fieldcache["req_ID"]}/";
   150               				if (file_exists($filename))
    93               				if (file_exists($filename))
   151                         		{
    94                         		{
   152                                         $query_update = mysql_query("UPDATE responses_tbl SET req_response = '0' WHERE req_ID = '$curr_reqID'");
    95                                         $query_update = mysql_query("UPDATE responses_tbl SET req_response = '0' WHERE req_ID = '$curr_reqID'");
   153                                        # $http_proxy = "http://localhost:8080";
    96                                         $staging = "/data/www/private/HTMLrequester/staging/";
   154 				#	$http_proxy = "http://localhost:8080";
       
   155                                         $staging = "/var/www/private/HTMLrequester/staging/";
       
   156                                        # $wget_options = "--dns-timeout=1 --proxy-user=www-data --proxy-password=www-data --cache=off -N -r -l 3 --no-remove-listing -p --max-redirect 10 -t 1 -d -I  http://localhost/router_stage/{$db_fieldcache["req_ID"]}/$strip_url_val/ -X   http://localhost/router_stage/{$db_fieldcache["req_ID"]}/";
       
   157                                         #$wget_options = "--dns-timeout=1 --proxy-user=www-data --proxy-password=www-data -N -r -l 3 --no-remove-listing -p --max-redirect 10 -t 1 -d -I  http://localhost/router_stage/{$db_fieldcache["req_ID"]}/$strip_url_val/ -X   http://localhost/router_stage/{$db_fieldcache["req_ID"]}/";
       
   158 					#$wget_options = "--no-cache --dns-timeout=1 --proxy-user=www-data --proxy-password=www-data -N -r -l 3 --no-remove-listing -p --max-redirect 10 -t 1 -d -I  http://localhost/router_stage/{$db_fieldcache["req_ID"]}/$strip_url_val/ -X   http://localhost/router_stage/{$db_fieldcache["req_ID"]}/ http://localhost/router_stage/{$db_fieldcache["req_ID"]}/$strip_url_val/";
       
   159                                         $wget_options = "--dns-timeout=1 --proxy-user=www-data --proxy-password=www-data -N -r -l 3 --no-remove-listing -p --max-redirect 10 -t 1 -d";
    97                                         $wget_options = "--dns-timeout=1 --proxy-user=www-data --proxy-password=www-data -N -r -l 3 --no-remove-listing -p --max-redirect 10 -t 1 -d";
   160 
       
   161 
       
   162 
       
   163                                         $strip_url_val = remove_http($db_fieldcache['req_val']);
       
   164                                        # $command1 = "wget -P $staging $wget_options http://localhost/router_stage/{$db_fieldcache["req_ID"]}/$strip_url_val/?uid=$uid'&'sid1=$sid1'&'sid2=$sid2";
       
   165                                        # exec($command1, $wget_results);
       
   166 					
       
   167                                         $command1 = "wget -P $staging $wget_options http://localhost/router_stage/{$db_fieldcache["req_ID"]}/$strip_url_val/?uid=$uid'&'sid1=$sid1'&'sid2=$sid2";
    98                                         $command1 = "wget -P $staging $wget_options http://localhost/router_stage/{$db_fieldcache["req_ID"]}/$strip_url_val/?uid=$uid'&'sid1=$sid1'&'sid2=$sid2";
   168                                        exec($command1, $wget_results);
    99                                        exec($command1, $wget_results);
   169 					}
   100 					}
   170 					else
   101 					else
   171 					{		
   102 					{		
   173 					}
   104 					}
   174                                         }
   105                                         }
   175 
   106 
   176 			}
   107 			}
   177 	}
   108 	}
   178 	
   109 */	
   179 	while ($db_fieldcache = mysql_fetch_assoc($query_cache)) 
   110 	while ($db_fieldcache = mysql_fetch_assoc($query_cache)) 
   180 	{
   111 	{
   181 		$curr_reqID = $db_fieldcache["req_ID"];
   112 		$curr_reqID = $db_fieldcache["req_ID"];
   182 		$filename = "/var/www/private/HTMLrequester/router_stage/{$db_fieldcache["req_ID"]}/";
   113 		$filename = "/data/www/private/HTMLrequester/router_stage/{$db_fieldcache["req_ID"]}/";
   183 		if (file_exists($filename)) 
   114 		if (file_exists($filename)) 
   184     			{
   115     			{
   185     			$query_update = mysql_query("UPDATE requests_tbl SET req_response = '1' WHERE req_ID = '$curr_reqID'");
   116     			$query_update = mysql_query("UPDATE requests_tbl SET req_response = '1' WHERE req_ID = '$curr_reqID'");
   186     			} 
   117     			} 
   187 		else 
   118 		else