com web/news: We have VCS so it's not a place for such things: common.php search.php
| From: | Hannes Magnusson | Date: | Thu, 13 Mar 2014 05:59:31 +0000 |
| Subject: | com web/news: We have VCS so it's not a place for such things: common.php search.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-18470@lists.php.net to get a copy of this message | ||
Commit: 01316745ec086cc3f59573460a97455d487a36fb
Author: Sobak <msobaczewski@gmail.com> Thu, 13 Mar 2014 06:59:31 +0100
Parents: 80aff627ec41af469963848e0f30c2eef14cc2ac
Branches: master
Link: http://git.php.net/?p=web/news.git;a=commitdiff;h=01316745ec086cc3f59573460a97455d487a36fb
Log:
We have VCS so it's not a place for such things
Changed paths:
M common.php
D search.php
Diff:
diff --git a/common.php b/common.php
index 3dd96b8..88ff233 100644
--- a/common.php
+++ b/common.php
@@ -82,32 +82,6 @@ function to_utf8($str, $charset)
return $n;
}
-/*
-if (function_exists("mb_convert_encoding")) {
-function to_utf8($str, $charset)
-{
-return mb_convert_encoding($str, "utf-8", strlen($charset) ? $charset :
"iso-8859-1");
-}
-} else if (function_exists("recode_string")) {
-function to_utf8($str, $charset)
-{
-if (strlen($charset) == 0)
-$charset = "iso-8859-1";
-return recode_string("$charset..utf-8", $str);
-}
-} else if (function_exists("iconv")) {
-function to_utf8($str, $charset)
-{
-return iconv(strlen($charset) ? $charset : "iso-8859-1", "utf-8", $str);
-}
-} else {
-function to_utf8($str, $charset)
-{
-return $str;
-}
-}
-*/
-
function decode_header($charset,$encoding,$text) {
if (strtolower($encoding) == "b") {
$text = base64_decode($text);
diff --git a/search.php b/search.php
deleted file mode 100644
index 44cc39c..0000000
--- a/search.php
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-require 'common.php';
-
-$q = isset($_GET['q']) ? $_GET['q'] : false;
-
-if ($q && get_magic_quotes_gpc()) $q = stripslashes($q);
-
-head("news search");
-?>
-<blockquote>
-sorry, search is offline for now.
-</blockquote>
-<?php
-
-foot();
-exit;
-
-if ($q) {
- $udm = udm_alloc_agent("mysql://root@localhost/news_search/", "crc-multi");
- if ($p) udm_set_agent_param($udm, UDM_PARAM_PAGE_NUM, $p);
- if ($t) udm_add_search_limit($udm, UDM_LIMIT_TAG, substr($t,0,11));
- udm_set_agent_param($udm, UDM_PARAM_PAGE_SIZE, 20);
- udm_set_agent_param($udm, UDM_PARAM_TRACK_MODE, UDM_TRACK_DISABLED);
- $res = udm_find($udm,$q)
- or die("search failed"); ### XXX
- $found = udm_get_res_param($res, UDM_PARAM_FOUND);
- if ($found) {
- $first = udm_get_res_param($res, UDM_PARAM_FIRST_DOC);
- $last = udm_get_res_param($res, UDM_PARAM_LAST_DOC);
- $wordinfo = udm_get_res_param($res, UDM_PARAM_WORDINFO);
- $time = udm_get_res_param($res, UDM_PARAM_SEARCHTIME);
- navbar($q,$first,$last,$found,$wordinfo,$time);
- echo '<table class="alist" width="100%">';
- echo '<tr>'.
- '<td class="alisthead">#</td>'.
- '<td class="alisthead">subject</td>'.
- '<td class="alisthead">from</td>'.
- '<td class="alisthead">date</td>'.
- '</tr>';
- $c = udm_get_res_param($res, UDM_PARAM_NUM_ROWS);
- for ($i = 0; $i < $c; $i++) {
- $class = $i % 2 ? "odd" : "even";
- $u = udm_get_res_field($res,$i,UDM_FIELD_URL);
- $t = udm_get_res_field($res,$i,UDM_FIELD_TITLE);
- $b = udm_get_res_field($res,$i,UDM_FIELD_TEXT);
- $m = udm_get_res_field($res,$i,UDM_FIELD_MODIFIED);
- $f = udm_get_res_field($res,$i,UDM_FIELD_KEYWORDS);
- $u =
preg_replace("#^file:/home/news/articles/(.+?)/(\\d+)\$#e","gen_url('\\1','\\2')",
$u);
- echo "<tr class=\"$class\"><td>";
- echo "<a href=\"$u\">".($i+$first)."</a>";
- echo "</td><td>";
- echo format_subject($t);
- echo "</td><td>";
- echo format_author($f);
- echo "</td><td>";
- # yeah, this is a pretty dumb round-trip on formatting the time. whatever.
- echo $m > 0 ? format_date(strftime("%c", $m)) : " ";
- echo "</td></tr>\n";
- echo "<tr class=\"$class\"><td></td><td
colspan=\"3\">".nl2br(htmlspecialchars($b, ENT_QUOTES,
"UTF-8"))."</td></tr>\n";
- }
- echo "</table>";
- navbar($q,$first,$last,$found,$wordinfo,$time);
- echo '<a href="http://www.mnogosearch.ru/"><img
align="left" src="i/udm.gif" border="0" width="102"
height="25" alt="Powered by mnoGoSearch"></a>';
- foot();
- exit();
- }
-}
-
-function gen_url($group,$article) {
- return
"article.php?group=".ereg_replace("/",".",$group)."&article=$article";
-}
-
-# display search box, possibly with message about no results
-if ($q) {
- echo "<p><b>No results found!</b></p>";
-}
-
-echo "<p>Use the box up top for now. More features later.</p>";
-
-foot();
-
-function navbar($q,$first,$last,$found,$wordinfo,$time) {
- echo '<table border="0" cellpadding="2" cellspacing="2"
width="100%"><tr class="alisthead">';
- echo '<td width="20%">';
- $p = floor($first / 20);
- if ($p > 0) {
- echo "<a href=\"search.php?q=".htmlspecialchars(urlencode($q), ENT_QUOTES,
"UTF-8")."&p=".($p-1).($GLOBALS["t"]?"&t=".$GLOBALS["t"]:"")."\"><b>«
previous</b></a>";
- }
- else {
- echo " ";
- }
- echo '</td>';
- $j = min($i+20,$l);
- $c = $l - $f + 1;
- echo '<td align="center" class="alisthead"
width="60%">'.htmlspecialchars("found: $wordinfo in $time secs",
ENT_QUOTES, "UTF-8")." ($first-$last of $found)</td>";
- echo '<td align="right" width="20%">';
- $maxpages = floor($found / 20);
- if ($p < $maxpages) {
- echo "<a href=\"search.php?q=".htmlspecialchars(urlencode($q), ENT_QUOTES,
"UTF-8")."&p=".($p+1).($GLOBALS["t"]?"&t=".$GLOBALS["t"]:"")."\"><b>next
»</b></a>";
- }
- else {
- echo " ";
- }
- echo '</td>';
- echo '</tr></table>';
-}
-
-