smacpettit Posted July 23, 2009 Share Posted July 23, 2009 Morning everyone, I friend of mine has given me this script to have a look at but I cant seem to get any heads or tails of it, its a web site site search ive only ever done MYSQL searches before so any help would be greatly appreciated. index.php <?php define ("AUTHOR", "Simon"); require_once("SiteSearch.php"); $search = new SiteSearch (); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <HTML> <HEAD> <title><?=AUTHOR?></title> <link rel="stylesheet" type="text/css" href="style.css" /> </HEAD> <BODY> <div id="container"> <h2><span id="author"><?=AUTHOR?></span></h2> <form method="GET" action="<?=$_SERVER['PHP_SELF']?>"> <div id="searchBox"> <table id="searchDetails"> <tr><td>Search Term</td><td><input class="text" name="term" type="text" value="contribute" /></td></tr> <tr><td>Website</td><td><input class="text" name="url" type="text" value="http://ubuntu.com/" /></td></tr> <tr><td>Search Depth</td><td><select name="depth"> <option value="1">1</option> <option value="2" selected>2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select></td></tr> </table> <input type="submit" value="start search" /> </div> </form> <?php $results = $search->returnResults(); ?> <h2>Showing <?=count($results)?> results</h2> <div id="resultsBox"> <?php foreach ($results as $result) { ?> <div id="result"> <h3 class="title"><?=$result['title']?></h3> <em class="date"><?=$result['date']?></em> <p class="desc"><?=$result['content']?></p> <span class="url"><?=$result['url']?></span> </div> <?php } ?> </div> </div> </BODY> </HTML> SiteSearch.php class SiteSearch { public function setUrl ($url) { } public function setTerm ($search) { } public function returnResults () { $result = array(); /* Fake Results */ for ($i=0; $i<10; $i++) $result[$i] = array ( "title" => ($i+1).": Example Page Title", "date" => "Date Found: 15.08.06 17:17:23", "content" => "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed turpis. In mattis aliquet felis. Nunc sagittis urna ac felis. Phasellus sed <span class=\"exactMatch\">contribute</span> velit. Donec orci sem, tempus pharetra, fermentum nec, pellentesque vitae, massa.", "url" => "http://example.domain.com/url" ); return $result; } } ?> Link to comment https://forums.phpfreaks.com/topic/167106-php-site-search-class-help-please/ Share on other sites More sharing options...
gevans Posted July 23, 2009 Share Posted July 23, 2009 but I cant seem to get any heads or tails of it What is the problem? It looks like the code in place will work, is the problem you don't udnerstand it, or it's not doing what you expect it to? Link to comment https://forums.phpfreaks.com/topic/167106-php-site-search-class-help-please/#findComment-881081 Share on other sites More sharing options...
smacpettit Posted July 23, 2009 Author Share Posted July 23, 2009 Well I just dont understand it, it needs to be edited so instead of returning the fake results it actually return results from a webpage Link to comment https://forums.phpfreaks.com/topic/167106-php-site-search-class-help-please/#findComment-881083 Share on other sites More sharing options...
gevans Posted July 23, 2009 Share Posted July 23, 2009 That is a huge amount of work you're hoping to undertake, and if you want to search the actually pages (which may be dynamic) you're going to need to use a spider and search script. Have a look at http://www.sphider.eu/ as an example. Link to comment https://forums.phpfreaks.com/topic/167106-php-site-search-class-help-please/#findComment-881086 Share on other sites More sharing options...
smacpettit Posted July 23, 2009 Author Share Posted July 23, 2009 Right what if I only wanted to search the http://ubuntu.com/ that is in the example? Would that make it easier? Link to comment https://forums.phpfreaks.com/topic/167106-php-site-search-class-help-please/#findComment-881088 Share on other sites More sharing options...
gevans Posted July 23, 2009 Share Posted July 23, 2009 Do you want to search the website content, or the url? Link to comment https://forums.phpfreaks.com/topic/167106-php-site-search-class-help-please/#findComment-881090 Share on other sites More sharing options...
smacpettit Posted July 23, 2009 Author Share Posted July 23, 2009 I want to search the website content of http://ubuntu.com/ with what ever is typed in the Search Term Link to comment https://forums.phpfreaks.com/topic/167106-php-site-search-class-help-please/#findComment-881091 Share on other sites More sharing options...
gevans Posted July 23, 2009 Share Posted July 23, 2009 Have a look at http://www.sphider.eu/ as an example. You need to crawl the site with a spider if you want to search the content. But you will only be able to do this on your own domain, unless you start looking into curl() to gather content from other sites Link to comment https://forums.phpfreaks.com/topic/167106-php-site-search-class-help-please/#findComment-881125 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.