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: Fri Mar 16, 2018 9:04 am Reply with quote

Part of my site still runs on an older CMS (PHP Nuke) so that our archived articles can still be accessed. To access them, we have an archive page that archives the articles by month. I recently upgraded our server to PHP 5.6 (from 5.3) and it broke some of the older Nuke code. Nothing major, just little things here and there. One of them was how the monthly archives are loading. When you click on a link to the month it will bring up the correct month but the year is completely random. It will pull up years before the internet even around! I suspect there is something in the result code causing this, but I'm not sure what to change or try to get it to properly identify the year.

Here is the select month function:
php Code:
function select_month() {

global $prefix, $user_prefix, $db, $module_name;
echo "<br><br><center><a href=\"/archives/\"><img src=\"/archives/banner-archives-square.jpg\" width=\"657\" height=\"71\" title=\"Return to the News Archives Index\" /></a><center><br><br>";
OpenTable();
echo "<center><font face=\"arial\" font size=\"2\">"._SELECTMONTH2VIEW."</center><br><br>";
$result = $db->sql_query("SELECT time from ".$prefix."_stories order by time DESC");
echo "<ul>";
while($row = $db->sql_fetchrow($result)) {
$time = $row['time'];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $getdate);
if ($getdate[2] == "01") { $month = _JANUARY; } elseif ($getdate[2] == "02") { $month = _FEBRUARY; } elseif ($getdate[2] == "03") { $month = _MARCH; } elseif ($getdate[2] == "04") { $month = _APRIL; } elseif ($getdate[2] == "05") { $month = _MAY; } elseif ($getdate[2] == "06") { $month = _JUNE; } elseif ($getdate[2] == "07") { $month = _JULY; } elseif ($getdate[2] == "08") { $month = _AUGUST; } elseif ($getdate[2] == "09") { $month = _SEPTEMBER; } elseif ($getdate[2] == "10") { $month = _OCTOBER; } elseif ($getdate[2] == "11") { $month = _NOVEMBER; } elseif ($getdate[2] == "12") { $month = _DECEMBER; }
if ($month != $thismonth) {
$year = $getdate[1];
echo "<li><a href=\"modules.php?name=$module_name&amp;sa=show_month&amp;year=$year&amp;month=$getdate[2]&amp;month_l=$month\">$month, $year</a>";
$thismonth = $month;
}
}
echo "</ul>"
."<br><center>"
."<form action=\"search.html\" method=\"post\">"
."<input type=\"text\" name=\"query\" size=\"30\">&nbsp;"
."<input type=\"submit\" value=\"News Search\">"
."</form><br>"
."<a href=\"modules.php?name=$module_name&amp;sa=show_all\">"._SHOWALLSTORIES."</a></center><br><br>";
CloseTable();
}





If anyone has any suggestions I'm all ears! I can provide more code if it looks like this isn't the culprit, or even the entire function.

The generated link looks like this: modules.php?name=Archives&sa=show_month&year=2013&month=01&month_l=January

The year in the generated link is always correct. It's the content on the page that is incorrect.

_________________
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: Fri Mar 16, 2018 10:39 am Reply with quote

try to replace ereg:

Code:
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $getdate);

with preg_match:

Code:
preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $time, $getdate);
 
View user's profile Send private message
rogue3
PostPosted: Fri Mar 16, 2018 10:54 am Reply with quote

Thanks for the fast reply!

I found 3 instances of that line in the full php file and replaced them all. It didn't see to help. Here is the page linking to the archived months if you want to see what the behaviour is doing:
Only registered users can see links on this board! Get registered or login!

Just click on anything pre-June 2017.
 
neralex
PostPosted: Fri Mar 16, 2018 11:14 am Reply with quote

Ok it seems there is an issue with the mysql-query. Can you please post an pastebin-link with code of your index.php?
Only registered users can see links on this board! Get registered or login!
 
rogue3
PostPosted: Fri Mar 16, 2018 12:03 pm Reply with quote

Here you go. Thanks for having a look....
Only registered users can see links on this board! Get registered or login!
 
neralex
PostPosted: Fri Mar 16, 2018 12:59 pm Reply with quote

Try to replace the index.php with this one:
Only registered users can see links on this board! Get registered or login!

Click on the "Download ZIP" button on the top-right to download/extract the modified file. Make a backup of the current file before replacing it.
 
rogue3
PostPosted: Fri Mar 16, 2018 1:18 pm Reply with quote

Hmmm, so far as I can tell, that didn't change anything. It still seems to be randomizing the year.

Update: actually, after further testing, that updated code broke the article links.
 
neralex
PostPosted: Fri Mar 16, 2018 1:30 pm Reply with quote

Which article-links - the readmore-buttons or what do you mean?

Edit: after re-checking your pastebin code, all article-links (title, readmore) are the same like: /content/modules.php?name=News&file=article&sid=

But I guess the issue is not the code of the index.php, I guess its based on your rewrite-rules. There is something strange and maybe this rewrites the links.
 
rogue3
PostPosted: Fri Mar 16, 2018 1:38 pm Reply with quote

If you click on either the article title or the read more link it takes you back to the index page instead of to the article page. I switched it back for now.
 
neralex
PostPosted: Fri Mar 16, 2018 1:48 pm Reply with quote

It works from my end, I can't notice an issue. I'm lost on this point because this was exactly the same as before. Maybe your mixed old code and an issue with your rewrite rules are causing this.
 
rogue3
PostPosted: Fri Mar 16, 2018 3:27 pm Reply with quote

I had to change it back, that is why it is currently working (the article links).
 
neralex
PostPosted: Fri Mar 16, 2018 4:37 pm Reply with quote

I guess you are able to compare your old code and my changes. So it should be easy for you to identify the difference between both. I tested it with a local installation of RavenNuke 252. The generated article-links are exactly the same. And I guess you are also able to copy the not working links into the clipboard, that would make it possible to compare between your working links. But without all these results, noone can help you.

In php5.6 was made many changes and many old functions like eregi etc are deprecated or were removed completely. So if you had only switched the php-version without own code changes on the php-files, you would run in more issues like that. So I guess an mix of some of your own made changes and some deprecated/removed php-functions after switching the php-version are causing your issues. With php7 you will get much more issues like that.

Create an backup of your running website, install the backup on a local server like wamp or xampp, use php7, activate the error-reporting and start a research through the massive count of error-messages.

Good luck!
 
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 ©