--- a/details.php Fri May 22 15:42:33 2009 +0100
+++ b/details.php Fri Jun 19 16:55:15 2009 +0100
@@ -1,4 +1,24 @@
<?php
+ function remove_http($url = '')
+ {
+ if ($url == 'http://' OR $url == 'https://')
+ {
+ return $url;
+ }
+ $matches = substr($url, 0, 7);
+ if ($matches=='http://')
+ {
+ $url = substr($url, 7);
+ }
+ else
+ {
+ $matches = substr($url, 0, 8);
+ if ($matches=='https://')
+ $url = substr($url, 8);
+ }
+ return $url;
+ }
+
// read user ID from cookie, if cookie doesn't exist, set to 1 (master)
$currID = $_COOKIE['uid'];
@@ -7,24 +27,21 @@
$currID = 1;
}
// read session IDs from cookie, if cookie doesn't exist, set to 1 (master)
+
+echo $_COOKIE["sid1"];
$currSID1 = $_COOKIE['sid1'];
- $currSID2 = $_COOKIE['sid2'];
-
-
- if ($currID == "")
- {
- $currID = 1;
- }
if ($currSID1 == "")
{
- $currSID1 = 1;
+ $currSID1 = "06D5VlLQTbM57LL7IBMW38yHkFpb1XVa";
}
+
+ $currSID2 = $_COOKIE['sid2'];
if ($currSID2 == "")
{
- $currSID2 = 1;
+ $currSID2 = "06D5VlLQTbM57LL7IBMW38yHkFpb1XVa";
}
-
+print_r($_COOKIE);
$status = $_GET['alert'];
$view_mode = $_GET['view_mode'];
@@ -36,7 +53,8 @@
mysql_select_db('members');
// search server cache for received websites
- if (($currID != 1) && ($currSID1 != 1) && ($currSID2 != 1))
+ // anonymous uid=1, sid1=06D5VlLQTbM57LL7IBMW38yHkFpb1XVa & sid2 =06D5VlLQTbM57LL7IBMW38yHkFpb1XVa
+ if (($currID != 1) && ($currSID1 != "06D5VlLQTbM57LL7IBMW38yHkFpb1XVa") && ($currSID2 != "06D5VlLQTbM57LL7IBMW38yHkFpb1XVa"))
{
$query_cache = mysql_query("SELECT * FROM requests_tbl WHERE (uid = '$currID' OR uid = 1)");
}
@@ -49,18 +67,35 @@
{
// send command to squid and return value
$curr_reqID = $db_fieldcache["req_ID"];
-# $commandline = "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";
-# exec($commandline, $cache_results);
+//$commandline = "wget --delete-after -N -r -l 3 --no-remove-listing -p --max-redirect 10 -t 1 -d http://localhost/staging/" " . $db_fieldcache["req_ID"] . " " . $db_fieldcache["req_val"];
+//echo $commandline;
+
+// exec($commandline, $wget_results);
+//$commandline = "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";
+
+ $filename = "/var/www/private/HTMLrequester/staging/{$db_fieldcache["req_ID"]}/";
+
+//$commandline = "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";
+
+// exec($commandline, $cache_results);
// find out if site is available and update the database
- if (strpos($cache_results, "HIT") == true)
- {
- $query_update = mysql_query("UPDATE responses_tbl SET req_response = '1' WHERE req_ID = '$curr_reqID'");
- }
+// if (strpos($cache_results, "HIT") == true)
+// {
+// $query_update = mysql_query("UPDATE responses_tbl SET req_response = '1' WHERE req_ID = '$curr_reqID'");
+// }
+// else
+// {
+// $query_update = mysql_query("UPDATE responses_tbl SET req_response = '0' WHERE req_ID = '$curr_reqID'");
+// }
+ if (file_exists($filename))
+ {
+ $query_update = mysql_query("UPDATE requests_tbl SET req_response = '1' WHERE req_ID = '$curr_reqID'");
+ }
else
- {
- $query_update = mysql_query("UPDATE responses_tbl SET req_response = '0' WHERE req_ID = '$curr_reqID'");
- }
+ {
+ $query_update = mysql_query("UPDATE requests_tbl SET req_response = '0' WHERE req_ID = '$curr_reqID'");
+ }
}
@@ -196,7 +231,10 @@
print "<span class='result_output_none'>Result pending</span>";
print "<a href='delete.php?req_id=" . $db_field['req_ID'] . "'><img src='images/x.gif' width='14' height='20' /></a>";
} else {
- print "<span class='result_output'><a href='" . $db_field['req_val'] ."' target='_blank'>View website</a></span>";
+//header ('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . dirname($db_fieldcache["req_ID"]));
+//strip_tags($text, '<p><a>')
+ print "<span class='result_output'><a href='". 'staging/' . $db_field['req_ID'] . '/' . remove_http($db_field['req_val']) ."' target='_blank'>View website</a></span>";
+// print "<span class='result_output'><a href='" . $db_field['req_val'] ."' target='_blank'>View website</a></span>";
print "<a href='delete.php?req_id=" . $db_field['req_ID'] . "'><img src='images/x.gif' width='14' height='20' /></a>";
}
print "<div class='clear'></div></div>";
--- a/mysql_apache/apache-default-site Fri May 22 15:42:33 2009 +0100
+++ b/mysql_apache/apache-default-site Fri Jun 19 16:55:15 2009 +0100
@@ -1,6 +1,6 @@
<VirtualHost *:80>
- ServerAdmin webmaster@localhost
- ServerName sphere.dsg.cs.tcd.ie
+ ServerAdmin librarian@village.n4c.eu
+ ServerName dtnrouter.village.n4c.eu
DocumentRoot /var/www/private/HTMLrequester
@@ -50,6 +50,20 @@
#Require valid-user
Require group 0 1
</Directory>
+<Directory "/var/www/private/HTMLrequester/staging">
+ AuthType Basic
+ AuthName "Administration"
+ AuthUserFile /var/www/private/HTMLrequester/passwords
+
+ # Turn off 'mod_auth_form' in this directory,
+ # giving control to 'mod_auth'.
+ AuthFormAuthoritative Off
+
+ Allow from 127.0.0.1 # localhost
+ Deny from all
+ Order Deny,Allow
+ Require valid-user
+</Directory>
<Directory "/var/www/private/public">
AuthFormPageNotAllowed /paying_members_only.html
@@ -99,12 +113,4 @@
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
-# <Directory "/var/www/HTMLrequester/">
-# Options Indexes MultiViews FollowSymLinks
-# AllowOverride None
-# Order deny,allow
-# Deny from all
-# Allow from 127.0.0.0/255.0.0.0 ::1/128
-# </Directory>
-
</VirtualHost>