Jump to content

Boojum

Members
  • Posts

    549
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.moralintelligence.net

Profile Information

  • Gender
    Male
  • Location
    San Francisco, California
  • Interests
    Writing, editing, graphic art, chess, politics, dismantling pathocracy.

Boojum's Achievements

Proficient

Proficient (10/14)

  • First Post
  • Collaborator
  • Posting Machine Rare
  • Conversation Starter
  • Week One Done

Recent Badges

1

Reputation

  1. One other question: Have you managed to isolate which site(s) are the targets of the DDOS attacks?
  2. Are we having another outage? My site once again won't load.
  3. Ah. *That's* why I can't open any pages on my site or check my email.
  4. Okay, figured it out. An absolute path was needed. Say, Bruce. It's been a while since I've been on the forums, but they seem ... quieter than I remember them. How are things around here?
  5. Thank you, Bruce. But before I open a ticket, could I resolve this problem simply by adding the error-document line to the subdomains' .htaccess files? At first blush, that looks like what's missing.
  6. I have recently deleted a number of pages from my site, and I noticed something interesting. When I click on such a page in my main (www) domain, my custom 404 page appears. When I click on one from another subdomain, I get a 404 *and* a 404 for the 404 error page itself! Is this caused by something missing from the .htaccess files for the subdomains? I thought I should ask here first before changing the .htaccess files because I don't like to mess with them any more than necessary.
  7. I've downloaded and installed a full-text site search engine which, despite some limitations, seems to serve my needs. However, I'd like to modify it to paginate the results. Here's the existing code: <?php /* Easy Real Time Full Text Search © 2012 Christer Svensson ---------------------------------------------- Instructions ------------------------------------------------------------------------------------------- If the name of this file not is easy.php then rename it to easy.php Upload it to the directory (folder) on your homepage server that you want to search through. The PHP-script in this file performs a real time full text search of every htm, html, asp, and php file in the directory (folder) and all subdirectories (subfolders). The search is not case sensitive. The text displayed in the browser window is searched. For that reason, in the html code, all text in tags are omitted and also text between the tag and the end tag for head, script, noscript and iframe. You may translate the text (string values) in this file to your native language without the author's permission. If you do so, please send a copy to postbox@christersvensson.com and it will be published on the homepage of this script. You may also use another CSS style and you may include the script as a natural part at pages at your site. */ // You may translate the string values here under to your native languages. $buttonvalue = "Search"; $search_at = "A search for"; $search_result = "returned these results"; $pages = "Number of pages with hits"; $to_small = "At least two characters are required"; $recursive = true; // Change to false if no searching should be done in subdirectories. //---------------------------- Do not change anything below this line ------------------------------------------------------------------------------- $html = <<<HTML <form name="form" action=""> <fieldset> <legend>Search Moralintelligence.net</legend> <input type="text" name="search" size="50"> <input type="button" value="$buttonvalue" onclick='window.location.assign(document.URL.substring(0,document.URL.indexOf("?")) + "?search=" + document.form.search.value.replace(/ /g,"%20"))'><br> <!-- Please do not remove or change this link to the application's site. Others might like it too. --> <small>Powered by <a href="http://www.christersvensson.com/easy/">Easy Real Time Full Text Search</a></small><br> </fieldset> </form> HTML; echo $html; function textpart($body, $search) { // Displays the text after the title $length = 100; $text = substr($body, max(stripos($body,$search) - $length, 0), strripos($body,$search) - stripos($body,$search) + strlen($search) + 2 * $length); if (strripos($text, " ") < strripos($text,$search)) { $text = $text . " "; } if (stripos($text, " ") != strripos($text, " ")) { $text = substr($text, stripos($text, " "), strripos($text, " ") - stripos($text, " ")); } $temp = $text; $stop = substr($text, strripos($text, $search) + strlen($search)); if (strlen($stop) > $length) { $stop = substr($text, strripos($text, $search) + strlen($search), $length); $stop = substr($stop, 0, strripos($stop, " ")); } $text = "... "; while (stripos($temp,$search)) { $temp = substr_replace($temp, "<b>", stripos($temp, $search), 0); $temp = substr_replace($temp, "</b>", stripos($temp, $search) + strlen($search), 0); $text = $text . substr($temp, 0, stripos($temp, "</b>") + 4); $temp = substr($temp, stripos($temp, "</b>") + 4); if(stripos($temp, $search) > (2 * $length)) { $text = $text . substr($temp, 0, $length); $text = substr($text, 0, strripos($text, " ")) . " ... "; $temp = substr($temp, stripos($temp, $search) - $length); $temp = substr($temp, stripos($temp, " ")); } } $text = $text . $stop . " ... "; echo $text; return; } function compress($string, $first, $last) { // Removes everything in $string from $first to $last including $first and $last while(stripos($string,$first) && stripos($string,$last)) { $string = substr_replace($string, "", stripos($string,$first), stripos($string,$last) - stripos($string,$first) + strlen($last)); } return $string; } function directoryToArray($directory, $recursive) { // This function by XoloX was downloaded from http://snippets.dzone.com/user/XoloX $array_items = array(); if ($handle = opendir($directory)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if (is_dir($directory. "/" . $file)) { if($recursive) { $array_items = array_merge($array_items, directoryToArray($directory. "/" . $file, $recursive)); } } else { $file = $directory . "/" . $file; $array_items[] = preg_replace("/\/\//si", "/", $file); } } } closedir($handle); } return $array_items; } function filewalk($file, $search, $counter, $webpath) { // Selects and treats files with the extension .htm and .html and .asp and .php if (strtolower(substr($file, stripos($file, ".htm"))) == ".htm" || strtolower(substr($file, stripos($file, ".html"))) == ".html" || strtolower(substr($file, stripos($file, ".asp"))) == ".asp" || strtolower(substr($file, stripos($file, ".php"))) == ".php") { $all = file_get_contents($file); $body = substr($all, stripos($all,"<body"),stripos($all,"</body>") - stripos($all,"<body")); $body = preg_replace('/<br \/>/i', ' ', $body); $body = preg_replace('/<br>/i', ' ', $body); $body = compress($body,"<noscript","</noscript>"); $body = compress($body,"<script","</script>"); $body = compress($body,"<iframe","</iframe>"); $body = compress($body,"<noframe","</noframe>"); $body = strip_tags($body); $body = html_entity_decode($body, ENT_QUOTES); $body = preg_replace('/\s+/', ' ', $body); // Scans and displays the results if (stripos($body, $search)) { $title = substr($all, stripos($all,"<title>") + 7,stripos($all,"</title>") - stripos($all,"<title>") - 7); $title = html_entity_decode($title, ENT_QUOTES); $title = preg_replace('/\s+/', ' ', $title); echo '<p><a href="' . $file . '">' . $title . '</a></br>'; echo '<span id="webpath">' . $webpath . substr($file, stripos($file, "/")) . '</span><br />'; echo textpart($body, $search) . '</p>'; $counter = $counter + 1; } } return $counter; } // Reads the search text from the page's URL $url = $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://'; $url .= $_SERVER['SERVER_PORT'] != '80' ? $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"] : $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if (stripos($url,"?search=")) $search = $_GET['search']; $webpath = dirname($url); // Starts searching if (strlen($search) < 2 && trim($search) <> "") { echo '<p>' . $to_small . '!</p>'; $search = ""; } if (trim($search) <> "") { echo "<h3>" . $search_at . " “<b>" . $search . "</b>” " . $search_result . ":</h3>"; $counter = 0; // Path to the folder containing this file $curdir = getcwd(); // Opens the folder and read its contents if ($dir = opendir($curdir)) { $files = directoryToArray("./", $recursive); foreach ($files as $file) { $counter = filewalk($file, $search, $counter, $webpath); } closedir($dir); } echo "<p>" . $pages . ": " . $counter . "</p>"; } ?> As you can see here (http://www.moralintelligence.net/easy.php?search=future), by default, this displays all the results on one page, which in some cases can be rather long. 1) I'd like to have the results divided into pages, with up to 25 results per page. Ideally, at the bottom of each page should be links to the previous and next pages (if applicable). 2) I'd also like to have the total number of pages incorporated into the <h3> appearing over the results. This would be taken from "$counter" in the script, but so far I haven't been able to plug in that variable. Can anyone suggest appropriate PHP to add to this script in order to implement these enhancements?
  8. If possible, I'd like to have my last reply deleted. I know, of course, that the fault is entirely mine, for posting a vague question that no one could answer. I will try to make future questions clearer.
  9. I want to thank you for providing me with a venue to come in and talk to myself in front of a number of indifferent strangers. Lord knows there's nowhere else I could go to do that.
  10. Hmm. Three out of four. The search bar now works correctly in Firefox, Chrome and IE -- but not in Safari.
  11. Question withdrawn. I finally figured out what was wrong: My input type for the "Search" button was "button" and needed to be "submit." But ... if you want to help me improve my search pages, I would also like to ask any if two refinements can be added: 1) Pagination of results pages where there are many results. By default, the script renders one long, continuous page, and I'd rather split it into pages containing, say, 50 results each. 2) At the bottom of each search page, the script displays the number of pages with results. I'd like to echo this at the top of the page: "A search for <search query> returned <n> results:" where <n> equals the number of pages with results on them. But since <n> is defined by the script as "$counter", and its value is determined by counting the result pages as the script finds and displays them, how would I modify the script to insert the value from "$counter" above the results? As before, this seems as though it should be so simple....
  12. I downloaded a nifty little search script (you can see it at http://www.christersvensson.com/easy/) for my site and installed it as directed. The search pages themselves work fine, but I also wanted to add a search box to each page so visitors can search directly from the pages. To set this up, I added the following code: <!-- Search area --> <div id="search_area"> <?php /* Easy Real Time Full Text Search © 2012 Christer Svensson ---------------------------------------------- Instructions ------------------------------------------------------------------------------------------- If the name of this file not is easy.php then rename it to easy.php Upload it to the directory (folder) on your homepage server that you want to search through. The PHP-script in this file performs a real time full text search of every htm, html, asp, and php file in the directory (folder) and all subdirectories (subfolders). The search is not case sensitive. The text displayed in the browser window is searched. For that reason, in the html code, all text in tags are omitted and also text between the tag and the end tag for head, script, noscript and iframe. You may translate the text (string values) in this file to your native language without the author's permission. If you do so, please send a copy to postbox@christersvensson.com and it will be published on the homepage of this script. You may also use another CSS style and you may include the script as a natural part at pages at your site. */ // You may translate the string values here under to your native languages. $buttonvalue = "Search"; $search_at = "A search for"; $search_result = "returned these results"; $pages = "Number of pages with hits"; $to_small = "At least two characters are required"; $recursive = true; // Change to false if no searching should be done in subdirectories. //---------------------------- Do not change anything below this line ------------------------------------------------------------------------------- $html = <<<HTML <form name="form" method="get" action="http://www.moralintelligence.net/easy.php"> <fieldset> <legend>Search Moralintelligence.net</legend> <input type="text" value="Out of order. Click button. -->" name="search" size="30"> <a href="http://www.moralintelligence.net/easy.php"><input type="button" value="$buttonvalue" onclick='window.location.assign(document.URL.substring(0,document.URL.indexOf("?")) + "?search=" + document.form.search.value.replace(/ /g,"%20"))'></a><br> <!-- Please do not remove or change this link to the application's site. Others might like it too. --> <small>Powered by <a href="http://www.christersvensson.com/easy/">Easy Real Time Full Text Search</a></small><br> </fieldset> </form> HTML; echo $html; ?> </div> <!-- End search area --> What I *want* this box to do is get the search query from the text entered by the user and then open a search page with the results (ideally in a different tab). Here's what it *does* do, as tested in four modern browsers, using Windows 7: 1) Internet Explorer 11: No matter what text user enters, clicking "Search" causes the browser to reload the page with the search term added to the URL in the address bar. Nothing else happens. 2) Firefox 38: On first click, does as IE does. On second click, opens search page, but text area is blank, so user must re-enter search query. 3) Safari 5.1.7: Opens search page on first click, but user must re-enter search query. 4) Chrome 43: Does exactly as Safari does. --- I *think* I'm not very far away from my intended result, but something seems to be missing or improperly configured, and I don't know enough about PHP to see what it is. Please point me in the right direction.
  13. Well, I'll look on the bright side: If I can't use Entropy Search, I can stop worrying about how to get it to validate.
  14. In this case, my .php pages use that extension only because they contain includes. There is no sensitive information in them, and apart from the includes they are static pages indistinguishable from the ordinary .html variety. On principle, I am averse to using major search engines to search my site. I suppose I can look up the necessary instructions and build my own search engine if necessary, but I'd certainly *prefer* to get Entropy Search to index my (static and non-sensitive) pages.
  15. After all my concerns about Entropy Search breaking W3C validation, now I find that it won't index any of my pages anyway because they're served as .php. Apparently ES indexes only .html, .htm and a few other extensions, *not* including .php. Is there a way to change the parameters so it will do so?
×
×
  • Create New...