Browse Source

New version of webpage

James Seward 15 năm trước cách đây
mục cha
commit
2dc552c404
4 tập tin đã thay đổi với 511 bổ sung0 xóa
  1. 337 0
      QuoteEngine/index.php
  2. 59 0
      QuoteEngine/ocean.css
  3. 28 0
      QuoteEngine/settings.example.inc
  4. 87 0
      QuoteEngine/styles.css

+ 337 - 0
QuoteEngine/index.php

@@ -0,0 +1,337 @@
+<?php
+	// This is the web page for the QuoteEngine
+	//
+	// It goes with the QuoteEngine script for eggdrop by JamesOff
+	// http://jamesoff.net
+	//
+	// There are a couple of things to change in the settings file
+	// before this script can be used
+
+	require("settings.inc");
+
+	if (SETTINGS_EDITED == false) {
+		die("Please edit the settings.inc file before using the script.");
+	}
+
+	if (!mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS)) {
+		die("Unable to connect to database.");
+	}
+
+	if (!mysql_select_db(MYSQL_DB)) {
+		die("Unable to select database.");
+	}
+
+  if (isset($_GET['channel'])) {
+		$channel = $_GET['channel'];
+	}
+	else {
+		$channel = DEFAULT_CHAN;
+	}
+
+	if (isset($_GET['remote'])) {
+		$remote = $_GET['remote'];
+	}
+
+	if (isset($_GET['filter'])) {
+	  $filter = $_GET['filter'];
+	}
+
+	if (isset($_GET['page'])) {
+		$page = $_GET['page'];
+	}
+
+	
+	if (empty($channel)) {
+	  $channel = DEFAULT_CHAN;
+  }
+
+  if (!isset($remote) || empty($remote)) {
+    $remote = 0;
+  }
+
+	function parse_quote($quote) {
+
+
+	}
+
+  if (!$remote) {
+?>
+<html>
+<head>
+	<title><?php
+	if ($channel == "__all") {
+		echo "Quotes from " . QUOTES_HOST;
+	}
+	else {
+		echo "#" . $channel . " quotes from " . QUOTES_HOST;
+	}
+?></title>
+		<link rel="stylesheet" type="text/css" href="<?php echo QUOTES_CSS; ?>">
+</head>
+
+<?php
+	}
+	//check if we should be displaying all quotes from a channel
+	$single_quote = "";
+	if (isset($_GET['q']) && !empty($_GET['q']) && is_numeric($_GET['q'])) {
+		$single_quote = mysql_real_escape_string($_GET['q']);
+	}
+
+	if ($single_quote == "") {
+		//display list
+		if (!$remote) {
+		?>
+
+<body>
+<h1><center><?php
+	if ($channel == "__all") {
+		echo "All";
+	}
+	else {
+		echo "#" . $channel;
+	}
+?> quotes</center></h1>
+<br>
+<center><form method="get" action="<?=$_SERVER['PHP_SELF'];?>">
+Filter for: <input type="text" name="filter" maxlength="32" size="32"> <input type="submit" value="go"><input type="hidden" name="channel" value="<?=$channel?>">
+</form>
+<?php
+	$result = mysql_query("SELECT DISTINCT channel FROM quotes ORDER BY channel");
+
+  echo "<small>Other channels<br> :: ";
+  while ($chan = mysql_fetch_object($result)) {
+          $chanlink = preg_replace("/#(.+)/", "\\1", $chan->channel);
+          echo "<a href=\"" . $_SERVER['PHP_SELF']. "?channel=$chanlink\">$chan->channel</a> :: ";
+  } 
+?>
+		<a href="<?php echo $SERVER['PHP_SELF']; ?>?channel=__all">(All channels)</a> ::
+</center>
+<br><br>
+
+Sorted with most recent first.
+<?php
+
+  }
+
+	$chan = mysql_real_escape_string($channel);
+	$filter = mysql_real_escape_string($filter);
+
+	$channel = "#" . $channel;
+
+	$sql = "SELECT * FROM quotes ";
+
+	$filters = array();
+
+	if (isset($filter) && !empty($filter)) {
+		$filters[] = "quote LIKE '%" . $filter . "%'";
+	}
+
+	if ($chan != "__all") {
+		$filters[] = "channel = '#" . $chan . "'";
+	}
+
+	if (sizeof($filters) > 0) {
+		$sql .= "WHERE " . implode(" AND ", $filters);
+	}
+
+	$sql .= " ORDER BY timestamp DESC";
+
+  if ($remote) {
+    $sql .= " LIMIT 20";
+  }
+
+  $results = mysql_query($sql);
+
+	if ($results && mysql_num_rows($results)) {
+		$count = mysql_num_rows($results);
+    if (!$remote) {
+		  $quoted = array();
+		  $quoter = array();
+      echo "<table>";
+      echo "<tr><th>#</th><th>Added by</th><th>When</th><th align=\"left\">Quote</th></tr>";
+      $class = 0;
+    }
+    if (!empty($page)) {
+      mysql_data_seek($results, $page * 100);
+    }
+    else {
+      $page = 0;
+    }
+    $counter = 0;
+    while (($quote = mysql_fetch_object($results)) && ($counter < 100)) {
+      if (!$remote) {
+        $counter++;
+        echo "<tr class=\"";
+        echo ($class == 0) ? "odd" : "even";
+        $class = !$class;
+        echo "\"><td valign=\"top\"><a name=\"$quote->id\"><a href=\"" . $PHP_SELF . "?q=$quote->id\"><small>" . $quote->id . "</small></a></td><td class=\"nick\" valign=\"top\" nowrap>";
+        echo "<span title=\"" . $quote->host . "\">";
+        echo $quote->nick;
+				echo "</span>";
+				if ($chan == "__all") {
+					echo "<br><small>in " . $quote->channel . "</small>";
+				}
+        echo "</td>";
+        echo "<td class=\"time\" valign=\"top\" nowrap><small>";
+        echo date("H:i j M y", $quote->timestamp);
+        echo "</small></td>";
+
+        if (empty($quoter[$quote->nick])) {
+          $quoter[$quote->nick] = 1;
+        }
+        else {
+          $quoter[$quote->nick]++;
+        }
+
+        $quote_text = htmlentities($quote->quote);
+        $quotes = @preg_split("/ \| /", $quote_text);
+        $newquote = "";
+        foreach ($quotes as $q) {
+          $q = trim($q);
+          //no timestamps
+          $q = preg_replace('/^\[?[0-9:.]+\]?/', '', $q);
+
+          //$q = preg_replace('/^((&lt;|\\[|\\()*.*?)( )(.*?(&gt;|\\]|\\))+:?)/', "\\1&nbsp;\\4", $q);
+          
+          //hilight nicks
+          if (!preg_match("/^\* /", $q)) {
+            if (preg_match('/^((&lt;|\\[|\\()*[@%+]?([^\]>\\\)]+?)[@%+]?(&gt;|\\]|\\))+:?)/', $q, $matches)) {
+              if (empty($quoted[$matches[3]])) {
+                $quoted[$matches[3]] = 1;
+              }
+              else {
+                $quoted[$matches[3]] = $quoted[$matches[3]] + 1;
+              }
+            }
+            $q = preg_replace('/^((&lt;|\\[|\\()*[^\]>\\\)]+?(&gt;|\\]|\\))+:?)/', "<b>\\1</b>", $q);
+          }
+          else {
+            if (preg_match('/^\* [@%+]?(\S+)[@%+]?/', $q, $matches)) {
+              if (empty($quoted[$matches[1]])) {
+                $quoted[$matches[1]] = 1;
+              }
+              else {
+                $quoted[$matches[1]] = $quoted[$matches[1]] + 1;
+              }
+            }
+            $q = preg_replace('/^\* (\S+)/', "* <b>\\1</b>", $q);
+          }
+          //$newquote .= preg_replace('/ /', "&nbsp;", $q);
+          $newquote .= $q;
+          $newquote .= "<br>";
+        }      
+        $quote_text = preg_replace('/ \| /', "<br>", $quote_text);
+        echo "<td class=\"quote\">" . $newquote . "</td>";
+        echo "</tr>";
+      }
+      else {
+        //remote
+        echo $quote->quote . "\n";
+      }
+    }
+		
+    if (!$remote) {
+      echo "</table>";
+      echo "$count results<br>";
+      if ($page > 0) {
+        echo "<a href=\"index.php?channel=$chan&filter=$filter&page=" . ($page - 1) . "\">&lt;&lt; Prev page</a>&nbsp;&nbsp";
+      }
+      if (($counter + ($page * 100)) < $count) {
+        echo "<a href=\"index.php";
+        echo "?channel=$chan";
+        echo "&page=";
+        echo ($page + 1);
+        echo "&filter=$filter";
+        echo "\">Next page &gt;&gt;</a>";
+      }
+
+      echo "<br><br>";
+      echo "<table width=\"70%\" cellpadding=\"5\" align=\"center\">";
+      echo "<tr><td valign=\"top\">";
+      arsort($quoted);
+      $i = 0;
+      echo "<h3>Top 5 Quoted</h3>";
+      echo "<small>on this page of results</small><br><br>";
+      foreach($quoted as $q => $count) {
+        echo "$q was quoted $count times<br>";
+        if (++$i > 5) {
+          break;
+        }
+      }
+      echo "</td><td valign=\"top\">";
+      echo "<h3>Top 5 Quoters</h3>";
+      echo "<small>on this page of results</small><br><br>";
+      arsort($quoter);
+      $i = 0;
+      foreach($quoter as $q => $count) {
+        echo "$q added $count quotes<br>";
+        if (++$i > 5) {
+          break;
+        }
+      }
+      echo "</td></tr></table>";
+    }
+	}
+	else echo "oops: no results<br>" . mysql_error();
+  
+  if ($remote) {
+    exit;
+  }
+
+	} //list (not quote)
+	else {
+		//display single quote
+		$sql = "SELECT * FROM quotes WHERE id='$single_quote'";
+		$result = mysql_query($sql);
+
+		if ($result && mysql_num_rows($result)) {
+			$quote = mysql_fetch_object($result);
+			?>
+			<div class="singlequote">
+				<h1>Quote #<?=$quote->id?></h1>
+				<div class="quote">
+<?php
+        $quote_text = htmlentities($quote->quote);
+        $quotes = @preg_split("/ \| /", $quote_text);
+        $newquote = "";
+        foreach ($quotes as $q) {
+          $q = trim($q);
+          //no timestamps
+          $q = preg_replace('/^\[?[0-9:.]+\]?/', '', $q);
+
+          //$q = preg_replace('/^((&lt;|\\[|\\()*.*?)( )(.*?(&gt;|\\]|\\))+:?)/', "\\1&nbsp;\\4", $q);
+          
+          //hilight nicks
+          if (!preg_match("/^\* /", $q)) {
+            $q = preg_replace('/^((&lt;|\\[|\\()*[^\]>\\\)]+?(&gt;|\\]|\\))+:?)/', "<b>\\1</b>", $q);
+          }
+          else {
+            $q = preg_replace('/^\* (\S+)/', "* <b>\\1</b>", $q);
+          }
+          $newquote .= $q;
+          $newquote .= "<br>";
+        }      
+				?>
+					<?=$newquote?><br><br>
+					<div class="meta">
+						Added <?=date("Y-m-d H:i:s", $quote->timestamp)?> by <?=$quote->nick?> on <?=$quote->channel?>
+					</div>
+				</div>
+			</div>
+
+			<?php
+
+		}
+		else {
+			echo "Sorry, can't find that quote.";
+		}
+	}
+?>
+<br><br><br><br><br><br>
+<center>
+<a href="http://jamesoff.net/site/code/eggdrop-scripts/quoteengine/">QuoteEngine</a> by <a href="//www.jamesoff.net/">JamesOff</a> <br>
+	Quotes gatered by <?php echo QUOTES_HOST; ?>
+</center>
+
+</body>
+</html>

+ 59 - 0
QuoteEngine/ocean.css

@@ -0,0 +1,59 @@
+/* style sheet created by dubkat@dubkat.org  */
+
+body {
+	font-family: Arial, Helvetica, sans-serif;
+	background-color: #D1CE92;
+}
+h1 {
+	font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+	font-size: 30pt;
+	font-weight: bolder;
+	font-style: italic;
+}
+
+tr.odd {
+	background-color: #7FABD1;
+}
+
+tr.even {
+	background-color: #92D1AF;
+}
+
+td.nick {
+	font-weight: bold;
+	font-size: 12pt;
+}
+
+td.nick small {
+	font-weight: normal;
+	font-size: 10pt;
+}`
+
+td.time {
+	font-size: 10pt;
+}
+
+td.quote {
+	vertical-align: top;
+	font-family: Arial, Helvetica, Courier New;
+	font-size: 12pt;
+}
+
+div.singlequote {
+	margin: auto;
+	width: 50%;
+}
+
+div.singlequote .quote {
+	font-family: monospace;
+	background-color: white;
+	color: black;
+	border: 1px dashed #bbb;
+	padding: 4px;
+}
+
+div.singlequote .quote .meta {
+	font-family: sans-serif;
+	color: #aaa;
+	font-size: small;
+}

+ 28 - 0
QuoteEngine/settings.example.inc

@@ -0,0 +1,28 @@
+<?php
+	// Settings file for QuoteEngine
+
+	// Copy this file to settings.inc and edit the below
+	// There's a setting at the end you MUST change before the script will run
+
+	define("MYSQL_HOST", "localhost");
+	define("MYSQL_USER", "username");
+	define("MYSQL_PASS", "password");
+	define("MYSQL_DB",   "quotes");
+
+	// The channel you want to show by default
+	// Use "__all" to not filter
+	// Omit the leading # for the channel name!
+	define("DEFAULT_CHAN", "__all");
+
+	// The person to say is hosting the page
+	// Your name or your bot's name probably
+	define("QUOTES_HOST", "YourName");
+
+	// The stylesheet to use
+	// styles.css or ocean.css
+	// Or your own, if you're super-clever
+	define("QUOTES_CSS", "styles.css"); 
+
+	// Change 'false' to 'true' below!
+	define("SETTINGS_EDITED", false);
+?>

+ 87 - 0
QuoteEngine/styles.css

@@ -0,0 +1,87 @@
+body {
+	font-family: Arial, Helvetica, sans-serif;
+}
+
+tr.odd {
+	background-color: #DFDFDF;
+}
+
+tr.even {
+	background-color: white;
+}
+
+td.nick {
+	font-size: 10pt;
+}
+
+td.nick small {
+	font-size: 8pt;
+}
+
+td.time {
+	font-size: 10pt;
+}
+
+td.quote {
+	font-family: "Courier New";
+	font-size: 10pt;
+}
+
+
+h1 {
+	text-align: center;
+}
+
+#filter_form {
+	text-align: center;
+}
+
+#otherchans {
+	text-align: center;
+}
+
+#otherchans a {
+	color: black;
+	padding: 2px;
+}
+
+#otherchans a.current {
+	background-color: red;
+	color: white;
+}
+
+#otherchans a:hover {
+	color: white;
+	background-color: black;
+}
+
+#sortinfo {
+	text-align: right;
+	color: gray;
+}
+
+.nopage {
+	color: gray;
+}
+
+#pages {
+	padding-top: 2px;
+	text-align: center;
+	font-size: 12pt;
+
+}
+
+#pages a {
+	padding: 2px;
+	color: black;
+}
+
+#pages a:hover {
+	color: white;
+	background-color: red;
+}
+
+#poweredby {
+	text-align: right;
+	color: gray;
+}