Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RavenNuke / Raven CMS CMS Wiki
Author Message
rogue3
Regular
Regular


Joined: Jul 02, 2009
Posts: 71

PostPosted: Sat Mar 31, 2018 8:49 pm Reply with quote

I have a review module that has a built in search function. This all worked fine in PHP5.3, but in PHP5.6 the output no longer works. I've narrowed the problem down to the string that is produced in the address bar. It seems it no longer recognizes the variable $query. Here is the code:

php Code:
        echo '<div class="SWRDRIndexSearchBox" align="center"><form name="search" method="post" form action="modules.php?name='.$module_name.'&amp;swop=search&amp;query='.$query.'">Search  RDRs:&nbsp;

<input type="text" class="SWRDRIndexSearchField" size="25" name="query"> <input type="submit" name="search" value="" />
</form></div>';


I know the search functionality works, because after I make a search I can go to the address bar and add a search criteria manually and I will get results.

So, when I run a search from the search field this is what shows up in the address bar: modules.php?name=Star-Wars-Reviews&swop=search&query=

As you can see, the $query is dropped. If I manually add something like this: modules.php?name=Star-Wars-Reviews&swop=search&query=rebels

Then I get results for 'rebels'.

Any insight as to why the $query string is being dropped? Is there some small thing I need to change because of PHP 5.6? Thanks for any help!

_________________
PHP Nuke Version: 7.5, patched
PHP Version: 4.3.11

Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message
neralex
Site Admin


Joined: Aug 22, 2007
Posts: 1442

PostPosted: Sun Apr 01, 2018 6:55 am Reply with quote

rogue3, form all what I know about your site, you are mixing an old patched phpnuke 7.5 with another nuke fork - I'm right?

php5.6 is an old stable, that means it gets only security updates until php7 is rolled out on all hosting packages. At the moment it should be the version of your choice. php5.3 has a lot of issues - not recommended. This is reason why you get will more issues like that in the future with this old patched phpnuke. I would suggest you install your website on a local test server and try an update to RavenNuke.

Without to see the code of the used module, there is no way to help you. You should also activate your error-reporting and check your error-messages and the log-file. Without to know, which error you are getting, how should we know it?

In the adress-bar you will see only the result. Its an dymically generated link and the variable $query is empty. That means in the module-file is an issue, where this variable is used and filled with data. And this will return an php error.
 
View user's profile Send private message
rogue3
PostPosted: Mon Apr 02, 2018 7:56 am Reply with quote

Thanks for the reply. The first thing I did when researching this is check the error log and it is not dropping any errors. I believe the search function itself is working correctly, it's just not finding any results (unless you manually input them in the address bar yourself). So, no errors are being generated.

This review module is one of the only things I actually run from PHP Nuke anymore. It's a custom module that I found online a while back. I just had to much content in it to make it work in anything else. The search function did work just fine prior to the PHP 5.6 upgrade. So, I'm not sure why the $query variable stopped working. The search is made up of two functions:

The menu section that houses the search box:

php Code:
function menu() {

global $module_name, $admin, $swop;
$ThFemeSel = get_theme();
if (file_exists("themes/$ThemeSel/images/banner-RDR.jpg")) {
echo '<p><img src="/images/spacer.gif" alt="" width="2" height="3" /><a href="modules.php?name='.$module_name.'"><img src="themes/'.$ThemeSel.'/images/banner-RDRSW.png" border="0" alt=""></a></p>';
} else {
echo '<p><img src="/images/spacer.gif" alt="" width="2" height="3" /><a href="modules.php?name='.$module_name.'"><img src="modules/'.$module_name.'/images/banner-RDRSW.png" border="0" alt=""></a></p>';
}


/* search section */

echo '<div class="SWRDR-Links-Box"> ';

echo '<div class="SWRDRIndexSearchBox" align="center"><form name="search" method="post" form action="modules.php?name='.$module_name.'&amp;swop=search&amp;query='.$query.'">Search RDRs:&nbsp;
<input type="text" class="SWRDRIndexSearchField" size="25" name="query"> <input type="submit" name="search" value="" />
</form></div>';


echo '<p align="center"><strong><a href="modules.php?name='.$module_name.'">'._REVIEWINDEX.'</a>';
}
echo ' | <a href="modules.php?name='.$module_name.'&amp;swop=MostPopular">'._POPULAR.'</a>';
echo ' | <a href="modules.php?name='.$module_name.'&amp;swop=TopRated">'._TOPRATED.'</a>';
echo ' | <a href="modules.php?name='.$module_name.'&amp;swop=RandomReview">'._RANDOM.'</a>';
echo '</strong></p>';
if (is_admin($admin))
echo '<p align="center"> admin: <a href="modules.php?name='.$module_name.'&amp;swop=WriteReview">'._WRITEREVIEW.'</a> | <a href="/content/modules.php?name=Star-Wars-Reviews&swop=masterlist&field=id&order=ASC">Master List</a>';
echo '</div>';

function convertorderbyin($orderby) {
if ($orderby == "titleA") $orderby = "TRIM(LEADING 'a ' FROM TRIM(LEADING 'an ' FROM TRIM(LEADING 'the ' FROM LOWER(`title`)))) ASC";
if ($orderby == "dateA") $orderby = "date ASC";
if ($orderby == "hitsA") $orderby = "hits ASC";
if ($orderby == "ratingA") $orderby = "rating ASC";
if ($orderby == "titleD") $orderby = "TRIM(LEADING 'a ' FROM TRIM(LEADING 'an ' FROM TRIM(LEADING 'the ' FROM LOWER(`title`)))) DESC";
if ($orderby == "dateD") $orderby = "date DESC";
if ($orderby == "hitsD") $orderby = "hits DESC";
if ($orderby == "ratingD") $orderby = "rating DESC";
return $orderby;
}

function convertorderbytrans($orderby) {
if ($orderby == "hits ASC") $orderbyTrans = ""._POPULARITY1."";
if ($orderby == "hits DESC") $orderbyTrans = ""._POPULARITY2."";
if ($orderby == "TRIM(LEADING 'a ' FROM TRIM(LEADING 'an ' FROM TRIM(LEADING 'the ' FROM LOWER(`title`)))) ASC") $orderbyTrans = ""._TITLEAZ."";
if ($orderby == "TRIM(LEADING 'a ' FROM TRIM(LEADING 'an ' FROM TRIM(LEADING 'the ' FROM LOWER(`title`)))) DESC") $orderbyTrans = ""._TITLEZA."";
if ($orderby == "date ASC") $orderbyTrans = ""._DATE1."";
if ($orderby == "date DESC") $orderbyTrans = ""._DATE2."";
if ($orderby == "rating ASC") $orderbyTrans = ""._RATING1."";
if ($orderby == "rating DESC") $orderbyTrans = ""._RATING2."";
return $orderbyTrans;
}

function convertorderbyout($orderby) {
if ($orderby == "TRIM(LEADING 'a ' FROM TRIM(LEADING 'an ' FROM TRIM(LEADING 'the ' FROM LOWER(`title`)))) ASC") $orderby = "titleA";
if ($orderby == "date ASC") $orderby = "dateA";
if ($orderby == "hits ASC") $orderby = "hitsA";
if ($orderby == "rating ASC") $orderby = "ratingA";
if ($orderby == "TRIM(LEADING 'a ' FROM TRIM(LEADING 'an ' FROM TRIM(LEADING 'the ' FROM LOWER(`title`)))) DESC") $orderby = "titleD";
if ($orderby == "date DESC") $orderby = "dateD";
if ($orderby == "hits DESC") $orderby = "hitsD";
if ($orderby == "rating DESC") $orderby = "ratingD";
return $orderby;
}



And the search function itself:

php Code:
function search($query, $min, $orderby, $show) {

global $prefix, $db, $admin, $bgcolor2, $module_name;
$row = $db->sql_fetchrow($db->sql_query("SELECT radminsuper FROM ".$prefix."_authors WHERE aid='$aid'"));
$aid = stripslashes(FixQuotes(check_html($admin[0], nohtml)));
$cid = intval($row['category']);
$radminsuper = intval($row['radminsuper']);
$reviewsresults = 1000;
$perpage=1000;
if (!isset($min)) $min=0;
if (!isset($max)) $max=$min+$reviewsresults;
if(isset($orderby)) {
$orderby = convertorderbyin($orderby);
} else {
$orderby = "TRIM(LEADING 'a ' FROM TRIM(LEADING 'an ' FROM TRIM(LEADING 'the ' FROM LOWER(`title`)))) ASC";
}
if ($show!="") {
$reviewsresults = $show;
} else {
$show=$reviewsresults;
}
$query = check_html($query, "nohtml");
// $query = mysqli_real_escape_string($query);
$query = addslashes($query);
$result = $db->sql_query("SELECT * FROM ".$prefix."_star_wars_reviews WHERE title LIKE '%$query%' OR keywords LIKE '%$query%' ORDER BY $orderby LIMIT $min, $reviewsresults");
$fullcountresult = $db->sql_query("SELECT * FROM ".$prefix."_star_wars_reviews WHERE title LIKE '%$query%' OR keywords LIKE '%$query%'");
$totalselectedlinks = $db->sql_numrows($fullcountresult);
$nrows = $db->sql_numrows($result);
$x=0;
$the_query = stripslashes($query);
$the_query = str_replace("\'", "'", $the_query);
if ($query <> '') {
if ($nrows>0) {
echo '<div class="SWRDR-QuickSearch-Results">';
echo "<h3>"._SEARCHRESULTS4.": <em>$the_query</em></h3>";

$result2 = $db->sql_query("SELECT * FROM ".$prefix."_star_wars_reviews_categories where title LIKE '%$query%' ORDER BY name DESC");
while ($row2 = $db->sql_fetchrow($result2)) {
$rid = intval($row2['id']);
$stitle = stripslashes(check_html($row2['title'], "nohtml"));
$res = $db->sql_query("SELECT * from ".$prefix."_star_wars_reviews where cid='$cid'");
$numrows = $db->sql_numrows($res);
$row3 = $db->sql_fetchrow($db->sql_query("SELECT * FROM ".$prefix."_star_wars_reviews_categories where id='$rid'"));
$rid3 = intval($row3['id']);
$title3 = stripslashes(check_html($row3['title'], "nohtml"));
$parentid3 = intval($row3['parentid']);
if ($parentid3>0) $title3 = getparent($parentid3,$title3);
$title3 = preg_match($query, "/<b>$query</b>/", $title3);
}
$orderbyTrans = convertorderbytrans($orderby);


echo "<p>"._SORTREVIEWSBY.": "
.""._TITLE." (<a href=\"modules.php?name=$module_name&amp;swop=search&amp;query=$the_query&amp;orderby=titleA\">A</a>\<a href=\"modules.php?name=$module_name&amp;swop=search&amp;query=$the_query&amp;orderby=titleD\">D</a>)"
." "._DATE." (<a href=\"modules.php?name=$module_name&amp;swop=search&amp;query=$the_query&amp;orderby=dateA\">A</a>\<a href=\"modules.php?name=$module_name&amp;swop=search&amp;query=$the_query&amp;orderby=dateD\">D</a>)"
." "._RATING." (<a href=\"modules.php?name=$module_name&amp;swop=search&amp;query=$the_query&amp;orderby=ratingA\">A</a>\<a href=\"modules.php?name=$module_name&amp;swop=search&amp;query=$the_query&amp;orderby=ratingD\">D</a>)"
." "._POPULARITY." (<a href=\"modules.php?name=$module_name&amp;swop=search&amp;query=$the_query&amp;orderby=hitsA\">A</a>\<a href=\"modules.php?name=$module_name&amp;swop=search&amp;query=$the_query&amp;orderby=hitsD\">D</a>)"
."<br>"._REVIEWSSORTED.": $orderbyTrans</p>";
echo '</div>';

echo '<table class="swrdr-index" border="0" cellspacing="0" cellpadding="0"><tr><td class="SWRDR-populartop">&nbsp;</td></tr>';
echo '<tr><td class="SWRDR-popularmid">';

while($row = $db->sql_fetchrow($result)) {
$rid = intval($row['id']);
$cid = intval($row['category']);
$sid = intval($row['sid']);
$parent = intval($row['parent']);
$title = stripslashes(check_html($row['title'], "nohtml"));
$url = stripslashes($row['url']);
$description = stripslashes($row['text']);
$score = intval($row['score']);
$time = $row['date'];
$hits = intval($row['hits']);
$rating = $row["rating"];
$totalvotes = intval($row["totalvotes"]);
$imagethumb = $row['imagethumb'];
$transfertitle = str_replace (" ", "_", $title);
$title = preg_replace("/".$query."/", "<b>$query</b>", $title);
echo "<a href=\"modules.php?name=$module_name&amp;swop=showcontent&amp;id=$rid\"><img src=\"$imagethumb\" width=\"100\" height=\"100\" class=\"RDRthumbImageFtLeft\"/ title=\"$title\"></a>";
echo '<font size="2" face="Arial, Helvetica" color="daab7c"><strong><a href="modules.php?name='.$module_name.'&amp;swop=showcontent&id='.$rid.'" target="_self">'.$title.'</a></strong>';
newreviewgraphic($time);
popgraphic($hits);
echo "<br>";
$description = preg_replace("/".$query."/", "<b>$query</b>", $description);
if (is_admin($admin))
echo ""._HITS.": $hits<br>";
setlocale (LC_TIME, $locale);
$datetime=explode('-', $time);
$datetime = strftime(_REVIEWSDATESTRING, mktime(0, 0, 0,$datetime[1],$datetime[2],$datetime[0]));
$datetime = ucfirst($datetime);
if ($radminsuper == 1) {
echo '<a href="modules.php?name='.$module_name.'&amp;swop=mod_review&amp;id='.$rid.'">'._EDIT.'</a> | ';
}
$title = stripslashes(FixQuotes(check_html($title, nohtml)));
$title = htmlspecialchars(urldecode($title));
$row4 = $db->sql_fetchrow($db->sql_query("SELECT * FROM ".$prefix."_star_wars_reviews_categories where id='".$cid."'"));
$cattitle = stripslashes(check_html($row4['name'], "nohtml"));
$row5 = $db->sql_fetchrow($db->sql_query("SELECT * FROM ".$prefix."_star_wars_reviews_categories WHERE parent='".$parent."'"));
$cat = $row5['name'];

/* Category breadcrumb */

echo _CATEGORY.': <a href="modules.php?name='.$module_name.'&amp;swop=categ&amp;id='.intval($row5["id"]).'">'.$cat.'</a>&nbsp;&raquo;&nbsp;<a href="modules.php?name='.$module_name.'&amp;swop=categ&amp;id='.intval($row4["id"]).'">'.$cattitle.'</a><br>';
echo ""._SCORE." ";
display_score3($score);
echo '<br>';
echo _ADDEDON.': '.$datetime.'';
echo "<div class=\"RDRpopularLineSeparator\"></div>";
$x++;
}
echo "</font>";
echo '</td></tr><tr><td class="SWRDR-popularbot">&nbsp;</td></tr></table>';
$orderby = convertorderbyout($orderby);
} else {
echo "<br><br><center><font size=\"2\" face=\"Arial, Helvetica\"><b>"._NOMATCHES."</b><br><br>"._GOBACK."<br></font></center>";
echo "<br><br><table width=\"75%\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><font size=\"2\" face=\"Arial, Helvetica\"><img src=\"/images/spacer.gif\" width=\"15\" height=\"3\" /></font></td></tr><tr><td bgcolor=\"#dddddd\"/images/spacer.gif\" width=\"15\" height=\"1\"></td></tr><tr><td><font size=\"2\" face=\"Arial, Helvetica\"><img src=\"/images/spacer.gif\" width=\"15\" height=\"2\" /></font></td></tr></table>";

}
/* Calculates how many pages exist. Which page one should be on, etc... */
$linkpagesint = ($totalselectedlinks / $reviewsresults);
$linkpageremainder = ($totalselectedlinks % $reviewsresults);
if ($linkpageremainder != 0) {
$linkpages = ceil($linkpagesint);
if ($totalselectedlinks < $reviewsresults) {
$linkpageremainder = 0;
}
} else {
$linkpages = $linkpagesint;
}
/* Page Numbering */
if ($linkpages!=1 && $linkpages!=0) {
echo "<br><br>"
.""._SELECTPAGE.": ";
$prev=$min-$reviewsresults;
if ($prev>=0) {
echo "&nbsp;&nbsp;<b>[ <a href=\"modules.php?name=$module_name&amp;swop=search&amp;query=$the_query&amp;min=$prev&amp;orderby=$orderby&amp;show=$show\">"
." &lt;&lt; "._PREVIOUS."</a> ]</b> ";
}
$counter = 1;
$currentpage = ($max / $reviewsresults);
while ($counter<=$linkpages ) {
$cpage = $counter;
$mintemp = ($perpage * $counter) - $reviewsresults;
if ($counter == $currentpage) {
echo "<b>$counter</b>&nbsp;";
} else {
echo "<a href=\"modules.php?name=$module_name&amp;swop=search&amp;query=$the_query&amp;min=$mintemp&amp;orderby=$orderby&amp;show=$show\">$counter</a> ";
}
$counter++;
}
$next=$min+$reviewsresults;
if ($x>=$perpage) {
echo "&nbsp;&nbsp;<b>[ <a href=\"modules.php?name=$module_name&amp;swop=search&amp;query=$the_query&amp;min=$max&amp;orderby=$orderby&amp;show=$show\">"
." "._NEXT." &gt;&gt;</a> ]</b>";
}
}
echo "<br><br><center><font size=\"2\" face=\"Arial, Helvetica\">"
."Search for \"<b><i>$the_query</i></b>\" "._ENTIRESITE.""
."<form action=\"http://www.jeditemplearchives.com/sitesearch.html\" id=\"cse-search-box\">"
."<input type=\"hidden\" name=\"cx\" value=\"" />"
."<input type=\"hidden\" name=\"cof\" value=\"" />"
."<input type=\"hidden\" name=\"ie\" value=\"ISO-8859-1\" />"
."<input type=\"text\" name=\"q\" size=\"25\" value=\"$the_query\"/>"
."&nbsp;<input type=\"submit\" name=\"sa\" value=\"Site Search\" />"
."</form>"
."</font><br><br>";
} else {
echo "<center><font size=\"2\" face=\"Arial, Helvetica\"><b>"._NOMATCHES."</b></font></center><br><br>";
}
}
 
neralex
PostPosted: Mon Apr 02, 2018 8:17 am Reply with quote

Ok I will check it in the next days.
 
neralex
PostPosted: Thu Apr 05, 2018 11:16 am Reply with quote

There some functions, which are not in your posted code. So I can't test it. Please upload the install-package of this module, all files and and an sql-file with the database-stucture without data and send it as compressed ZIP or RAR archive via PM.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RavenNuke / Raven CMS CMS Wiki

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©