[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r14991: (ticket:99) Allowing the user to search easier with fingerpr (in torstatus/trunk/web: . css)



Author: kasimir
Date: 2008-06-06 11:30:56 -0400 (Fri, 06 Jun 2008)
New Revision: 14991

Modified:
   torstatus/trunk/web/css/style.css
   torstatus/trunk/web/index.php
   torstatus/trunk/web/router_detail.php
Log:
(ticket:99) Allowing the user to search easier with fingerprints

Modified: torstatus/trunk/web/css/style.css
===================================================================
--- torstatus/trunk/web/css/style.css	2008-06-06 06:33:57 UTC (rev 14990)
+++ torstatus/trunk/web/css/style.css	2008-06-06 15:30:56 UTC (rev 14991)
@@ -149,7 +149,7 @@
 /* Search box */
 input.searchbox
 {
-	width: 13em;
+	width: 15em;
 	height: 1.5em;
 	border: 2px #59990e solid;
 	margin: 0;

Modified: torstatus/trunk/web/index.php
===================================================================
--- torstatus/trunk/web/index.php	2008-06-06 06:33:57 UTC (rev 14990)
+++ torstatus/trunk/web/index.php	2008-06-06 15:30:56 UTC (rev 14991)
@@ -1816,23 +1816,25 @@
 
 	$CSInput_SAFE = mysql_real_escape_string($CSInput);
 
+	// Strip all whitespace and capitalize all for fingerprint matching
+	$CSInputFingerprint = preg_replace('/\s+/', '', strtoupper($CSInput_SAFE));
 	if ($CSField == 'Fingerprint')
 	{
 		if($CSMod == 'Equals')
 		{
-			$query .= "$ActiveNetworkStatusTable.Fingerprint = '$CSInput_SAFE'";
+			$query .= "$ActiveNetworkStatusTable.Fingerprint = '$CSInputFingerprint'";
 		}
 		else if($CSMod == 'Contains')
 		{
-			$query .= "$ActiveNetworkStatusTable.Fingerprint like '%$CSInput_SAFE%'";
+			$query .= "$ActiveNetworkStatusTable.Fingerprint like '%$CSInputFingerprint%'";
 		}
 		else if($CSMod == 'LessThan')
 		{
-			$query .= "$ActiveNetworkStatusTable.Fingerprint < '$CSInput_SAFE'";
+			$query .= "$ActiveNetworkStatusTable.Fingerprint < '$CSInputFingerprint'";
 		}
 		else if($CSMod == 'GreaterThan')
 		{
-			$query .= "$ActiveNetworkStatusTable.Fingerprint > '$CSInput_SAFE'";
+			$query .= "$ActiveNetworkStatusTable.Fingerprint > '$CSInputFingerprint'";
 		}
 	}
 	else if ($CSField == 'Name')
@@ -1844,6 +1846,9 @@
 		else if($CSMod == 'Contains')
 		{
 			$query .= "$ActiveNetworkStatusTable.Name like '%$CSInput_SAFE%'";
+			// Determine whether the string (w/o whitespace) is 40
+			// characters, to test for the fingerprint
+			$query .= " OR $ActiveNetworkStatusTable.Fingerprint LIKE '$CSInputFingerprint'";
 		}
 		else if($CSMod == 'LessThan')
 		{
@@ -2114,13 +2119,13 @@
 <form action="<?php echo $Self; ?>" method="post" name="search">
 <input type="hidden" name="CSMod" value="Contains" />
 <input type="hidden" name="CSField" value="Name" />
-<input type="text" class="searchbox" value="<?php echo ($CSInput)?htmlspecialchars($CSInput, ENT_QUOTES):"";?>" onfocus="javascript:if(this.value=='search for a router') { this.style.color = 'black';this.value=''; }" id="searchbox" name="CSInput"/><a href="javascript:document.search.submit();" class="searchbox" id="searchbutton"></a><noscript><input type="submit" value="Router Search"/></noscript>
+<input type="text" class="searchbox" value="<?php echo ($CSInput)?htmlspecialchars($CSInput, ENT_QUOTES):"";?>" onfocus="javascript:if(this.value=='search by name or fingerprint') { this.style.color = 'black';this.value=''; }" id="searchbox" name="CSInput"/><a href="javascript:document.search.submit();" class="searchbox" id="searchbutton"></a><noscript><input type="submit" value="Name/Fingerprint Search"/></noscript>
 </form>
 </td></tr></table>
 <?php if (!$CSInput) { ?>
 <script type="text/javascript">
 	document.getElementById('searchbox').style.color = 'gray';
-	document.getElementById('searchbox').value = 'search for a router';
+	document.getElementById('searchbox').value = 'search by name or fingerprint';
 </script>
 <?php } ?>
 <script type="text/javascript">

Modified: torstatus/trunk/web/router_detail.php
===================================================================
--- torstatus/trunk/web/router_detail.php	2008-06-06 06:33:57 UTC (rev 14990)
+++ torstatus/trunk/web/router_detail.php	2008-06-06 15:30:56 UTC (rev 14991)
@@ -81,6 +81,12 @@
 $ORPort = $record['ORPort'];
 $DirPort = $record['DirPort'];
 $Platform = $record['Platform'];
+// Break the platform after 55 characters
+if (strlen($Platform) > 55)
+{
+	$Platform = substr($Platform,0,55) . "<br/>" . substr($Platform,-(strlen($Platform)-55));
+}
+
 $Contact = $record['Contact'];
 $Uptime = $record['Uptime'];
 $Bandwidth_MAX = $record['BandwidthMAX'];