I'll be happy to provide support for it to a certain extent, but this is more so just a personal mod I'm letting anyone use.
- Code: Select all
<?php
//This is an advanced news searching program that helps me in generating related news. The script is VERY SQL involved, so you will need your Coranto news stored in an SQL database, either by the CorantoSQL or FakeSQL addons.
//Look towards the end of this scipt for formatting options.
/*Call this into your coranto-generated php page with the following parameters: It's bet to use this in Coranto styles.
Note that you don't want your searchfield to be too long, as it searches for each word invidually, at least in its original state. So, if you enter one or two keywords, it should work great.
<?php
$search = "<Field: SEARCHFIELD>";
$search = urlencode($search);
include ( 'http://' . $_SERVER['HTTP_HOST'] . '/related.php?s=' . $search);
<close php tag>
*/
//DB INFO
$dbuser = ''; //DB username
$dbpass = ''; //DB pass
$dbhost = 'localhost'; //DB Host
$newstable = ''; //Table where news is stored
//List the fields that you need searched, following the below format.
$searchfield[] = 'Text';
$searchfield[] = 'Subject';
function dbConnect(
$database="" //The database where you store Coranto news goes here.
) {
global $dbhost, $dbuser, $dbpass;
$db = mysql_connect($dbhost, $dbuser, $dbpass);
$selected = mysql_select_db($database);
if (!(isset($selected))) {
die ("Error!");
}
}
//Here's where all the fun starts.
dbConnect();
//Get the search string, we're going to search for all the words in the fields we've specified.
$search = urldecode($_REQUEST['s']);
$search = explode(" ", $search);
$SearchSQL = '';
foreach ($searchfield as $field) {
foreach ($search as $s) {
$SearchSQL[] = "SELECT * FROM `" . $newstable . "` WHERE `" . $field . "` LIKE '%" . $s . "%'";
}
}
$SQL = implode(" UNION ", $SearchSQL);
$SQL .= " ORDER BY `newstime` DESC";
$query = mysql_query($SQL) or die(mysql_error());
//Count the results with rcount
$rcount = 0;
//Formating section starts here!
//I've left the formatting I have in order to help you.
//Image this part as what goes about the <Field: Content> in a template
$relatedHTML = "<table cellpadding=\"0\" cellspacing=\"2\" border=\"0\" class=\"bodyline\" width=\"90%\">\n";
$relatedHTML .= "<tr><td><b>" . urldecode($_REQUEST['s']) . " News From OTC:</b></td></tr>\n";
$relatedHTML .= "<tr><td> </td></tr>";
//Now, this is where the style goes.
while($results=mysql_fetch_array($query)) {
if($results['xMultiSubmitSP'] == '69421072513396') { //If the XMS Profile is draft news.
if($results['CustomField_outside'] == "Yes") { //If it links to the outside, surl will be filled, so just send the user there
$relatedHTML .= "<tr><td><a href=\"" . $results['CustomField_surl'] . "\" target=\"new\">" . $results['Subject'] . "</a> <i>(from " . $results['CustomField_source'] . ")</i></td></tr>\n";
$rcount++;
} else { //If its not, its either a maginot page or its a link to a page.
if( $results['CustomField_surl'] != '' ) {
$relatedHTML .= "<tr><td><a href=\"" . $results['CustomField_surl'] . "\">" . $results['Subject'] . "</a></td></tr>\n";
$rcount++;
} else {
$relatedHTML .= "<tr><td><a href=\"/2005/content/article/" . $results['newsid'] . ".php\">" . $results['Subject'] . "</a></td></tr>\n";
$rcount++;
}
}
}
}
//And finally, this is below the <Field: Content> in a template
$relatedHTML .= "</table>\n";
//This will only dispaly your result box if at least one result is returned.
if($rcount > 0) {
print $relatedHTML;
}
?>