updated references to h4c to n4c, user_ID to uid, proxy to localhost and database to members
authoralex.mcmahon@cs.tcd.ie
Tue, 19 May 2009 08:30:24 +0100
changeset 1 29ae580f12bd
parent 0 a4bc6ef5dbfe
child 2 e8c21d72976d
child 3 ad69d332e9dc
updated references to h4c to n4c, user_ID to uid, proxy to localhost and database to members
add_search.php
delete.php
details.php
index.php
--- a/add_search.php	Tue May 19 00:30:06 2009 +0100
+++ b/add_search.php	Tue May 19 08:30:24 2009 +0100
@@ -6,7 +6,7 @@
 	}
 	
 	// get user ID from cookie
-	$currID = $_COOKIE['h4c_ID'];
+	$currID = $_COOKIE['n4c_ID'];
 	
 	if ($currID == "") 
 	{
@@ -35,10 +35,10 @@
 	// retrieve cookie if it exists
 	if ($search_term != "") 
 	{	
-		$conn = mysql_connect('localhost','root','') or die(mysql_error());
-		mysql_select_db('h4c_db');
+		$conn = mysql_connect('localhost','www-data','www-data') or die(mysql_error());
+		mysql_select_db('members');
 
-		$query = mysql_query("INSERT INTO requests_tbl (req_ID, user_ID, req_val, req_response, req_created) VALUES ('', '$currID', '$search_term', 0, CURDATE())");
+		$query = mysql_query("INSERT INTO requests_tbl (req_ID, uid, req_val, req_response, req_created) VALUES ('', '$currID', '$search_term', 0, CURDATE())");
 		$query2 =  mysql_query("SELECT MAX(req_ID) as id FROM requests_tbl");
 		mysql_close();
 		
@@ -50,7 +50,7 @@
 		// construct message string
 		$message = "#" . $currID . "#" . $reqID . "#" . $search_term;
 		
-		$host="134.226.36.154";
+		$host="localhost";
 		$port = 8080;
 		$timeout = 30;
 	
@@ -80,8 +80,8 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>H4C - deleting request information...</title>
-<link href="files/h4c_main.css" rel="stylesheet" type="text/css" media="screen" />
+<title>N4C - deleting request information...</title>
+<link href="files/n4c_main.css" rel="stylesheet" type="text/css" media="screen" />
 </head>
 
 <body>
--- a/delete.php	Tue May 19 00:30:06 2009 +0100
+++ b/delete.php	Tue May 19 08:30:24 2009 +0100
@@ -2,8 +2,8 @@
 	// get request ID to delete
 	$req_ID = $_GET['req_id'];
 	
-	$conn = mysql_connect('localhost','root','') or die(mysql_error());
-	mysql_select_db('h4c_db');
+	$conn = mysql_connect('localhost','www-data','www-data') or die(mysql_error());
+	mysql_select_db('members');
 	
 	// retrieve cookie if it exists
 	if ($req_ID != "") 
@@ -18,8 +18,8 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>H4C - deleting request information...</title>
-<link href="files/h4c_main.css" rel="stylesheet" type="text/css" media="screen" />
+<title>N4C - deleting request information...</title>
+<link href="files/n4c_main.css" rel="stylesheet" type="text/css" media="screen" />
 </head>
 
 <body>
--- a/details.php	Tue May 19 00:30:06 2009 +0100
+++ b/details.php	Tue May 19 08:30:24 2009 +0100
@@ -1,6 +1,6 @@
 <?php 
 	// read user ID from cookie, if cookie doesn't exist, set to 1 (master)
-	$currID = $_COOKIE['h4c_ID'];
+	$currID = $_COOKIE['n4c_ID'];
 	
 	if ($currID == "") 
 	{
@@ -13,25 +13,25 @@
 	
 	
 	// connect to the database
-	$conn = mysql_connect('localhost','root','') or die(mysql_error());
-	mysql_select_db('h4c_db');
+	$conn = mysql_connect('localhost','www-data','www-data') or die(mysql_error());
+	mysql_select_db('members');
 	
 	// search server cache for received websites
 	if ($currID != 1)
 	{
-		$query_cache = mysql_query("SELECT * FROM requests_tbl WHERE (user_ID = '$currID' OR user_ID = 1)");
+		$query_cache = mysql_query("SELECT * FROM requests_tbl WHERE (uid = '$currID' OR uid = 1)");
 	} 
 	else 
 	{
-		$query_cache = mysql_query("SELECT * FROM requests_tbl WHERE (user_ID = 1)");
+		$query_cache = mysql_query("SELECT * FROM requests_tbl WHERE (uid = 1)");
 	}
 	
 	while ($db_fieldcache = mysql_fetch_assoc($query_cache)) 
 	{
 		// 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["user_ID"] . " " . $db_fieldcache["req_val"] . " |grep X-Cache: |grep MISS";
-		exec($commandline, $cache_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";
+#		exec($commandline, $cache_results);
 		
 		// find out if site is available and update the database
 		if (strpos($cache_results, "HIT") == true)
@@ -67,15 +67,15 @@
 	// pick relervant mySQl QUERY
 	if ($view_mode == "public")
 	{
-		$query = mysql_query("SELECT * FROM requests_tbl WHERE (user_ID = 1) ORDER BY " . $order_sql);
+		$query = mysql_query("SELECT * FROM requests_tbl WHERE (uid = 1) ORDER BY " . $order_sql);
 	}
 	else if ($view_mode == "all")
 	{
-		$query = mysql_query("SELECT * FROM requests_tbl WHERE (user_ID = '$currID' OR user_ID = 1) ORDER BY " . $order_sql);
+		$query = mysql_query("SELECT * FROM requests_tbl WHERE (uid = '$currID' OR uid = 1) ORDER BY " . $order_sql);
 	}
 	else 
 	{
-		$query = mysql_query("SELECT * FROM requests_tbl WHERE (user_ID = '$currID') ORDER BY " . $order_sql);
+		$query = mysql_query("SELECT * FROM requests_tbl WHERE (uid = '$currID') ORDER BY " . $order_sql);
 	}
 	
 	
@@ -94,14 +94,14 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>H4C - Welcome. <?php print $search_info; ?></title>
-<link href="files/h4c_main.css" rel="stylesheet" type="text/css" media="screen" />
+<title>N4C - Welcome. <?php print $search_info; ?></title>
+<link href="files/n4c_main.css" rel="stylesheet" type="text/css" media="screen" />
 </head>
 
 <body>
 <div id="container">
     <div id="header">
-        <h1><span>H4C</span></h1>
+        <h1><span>N4C</span></h1>
     	<p id="credits">HTML Requester v. 1.00</p>
     </div>
     <?php 
@@ -161,7 +161,7 @@
 			
 			while ($db_field = mysql_fetch_assoc($query)) 
 			{		 
-				if ($db_field['user_ID'] != 1 and $view_mode == "all")
+				if ($db_field['uid'] != 1 and $view_mode == "all")
 				{
 					print "<div class='search_result_private'><span class='result_no'>" . $search_count . "</span> ";
 					print "<span class='search_txt'>Search:</span><span class='search_input'><em>" . $db_field['req_val'] . "</em></span> ";
--- a/index.php	Tue May 19 00:30:06 2009 +0100
+++ b/index.php	Tue May 19 08:30:24 2009 +0100
@@ -1,26 +1,26 @@
 <?php
-	$conn = mysql_connect('localhost','root','') or die(mysql_error());
-	mysql_select_db('h4c_db');
+	$conn = mysql_connect('localhost','www-data','www-data') or die(mysql_error());
+	mysql_select_db('members');
 	
 	// retrieve cookie if it exists
-	if (isset($_COOKIE['h4c_ID'])) 
+	if (isset($_COOKIE['n4c_ID'])) 
 	{	
-		$currID = $_COOKIE['h4c_ID'];
+		$currID = $_COOKIE['n4c_ID'];
 	} 
 	else 
 	{
 		// SQL queries
-		$result = mysql_query("INSERT INTO users_tbl (user_ID) VALUES ('')");
-		$user_id =  mysql_query("SELECT MAX(user_ID) as id FROM users_tbl");
+		$result = mysql_query("INSERT INTO creds (uid) VALUES ('')");
+		$user_id =  mysql_query("SELECT MAX(uid) as id FROM creds");
 		
 		$expiry = time() + (3600 * 24 * 30 * 12); 
 		
 		//create cookies
 		while ($db_field2 = mysql_fetch_assoc($user_id)) {		 
-		 	setcookie('h4c_ID', $db_field2['id'] , $expiry, '/', '', 0);
+		 	setcookie('n4c_ID', $db_field2['id'] , $expiry, '/', '', 0);
 		}
 		
-		if (!isset($_COOKIE['h4c_ID'])) 
+		if (!isset($_COOKIE['n4c_ID'])) 
 		{
 			$currID = 1;
 		}
@@ -34,7 +34,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>H4C - checking your user status...</title>
+<title>N4C - checking your user status...</title>
 </head>
 
 <body>
@@ -46,12 +46,12 @@
 	print 'COOKIE Status = ' . $currStatus . '</p>';
 	
 	// FOR TEST PURPOSES - READ USERS
-	$result2 = mysql_query('SELECT * FROM users_tbl');
+	$result2 = mysql_query('SELECT * FROM creds');
 	
 	print '<p><strong>LIST OF USERS -----------------------------------------------------------------</strong></p><p>';
 	
 	while ($db_field = mysql_fetch_assoc($result2)) {
-		print 'USERID: ' . $db_field['user_ID'] . ' | EMAIL: ' . $db_field['user_email'] . ' | USERSTATUS: ' . $db_field['user_status'] . '<br />';
+		print 'USERID: ' . $db_field['uid'] . ' | EMAIL: ' . $db_field['user_email'] . ' | USERSTATUS: ' . $db_field['user_status'] . '<br />';
 	}
 	
 	print '</p>';