News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Fatal Error in News.php

Started by snadge, January 23, 2014, 06:55:10 AM

Previous topic - Next topic

snadge

Its been brought too my attention that PHP is reporting a Fatal Error (PHP Fatal error:  Call to undefined function cdata_parse()) in news.php on line 789 - the code in question is:

            'description' => cdata_parse($row['body']),

now I had to manually edit this file yesterday to get the 2.0.7 update to install but this was not the code/line I edited, can anyone see any fault with the code above?

here is full block:

// Doesn't work as well as news, but it kinda does..
if ($xml_format == 'rss' || $xml_format == 'rss2')
$data[] = array(
'title' => $row['subject'],
'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
'description' => cdata_parse($row['body']),
'author' => in_array(showEmailAddress(!empty($row['hide_email']), $row['id_member']), array('yes', 'yes_permission_override')) ? $row['poster_email'] : null,
'category' => cdata_parse($row['bname']),
'comments' => $scripturl . '?action=post;topic=' . $row['id_topic'] . '.0',
'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']),
'guid' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg']
);


the code I changed was on line 385-386 and this was the code to replace the code there:

$val = preg_replace('/^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$/e', '\'\' . $scripturl . \'/\' . strtr(\'$1\', \'&;=\', \'//,\') . \'.html$2\'', $val); ***/
return $val;


if anyone could help with this I would appreciate it.

thanks

margarett

Please note that function cdata_parse is defined immediately below the changes you made, so please make sure you didn't mess with the coding of the file.

Can you attach your News.php?
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

snadge

yeah sure :)

no I defo didnt screw with coding, heres how I did it - initiate install, it says it will fail on news.php, I then make a backup (adding OLD to the file name) of said file, download the original, load up in dreamweaver, find the line of code it wants to replace (which is obviously now slightly different as the installer can not locate it), found it, highlighted the code then paste in the replacement...nothing else edited...I then commit the install through so it edits all but the failed news.php, then I quickly upload the new modified version of news.php in filezilla, literally seconds between the install making changes and me uploading the new copy.

I have attached the news.php - this was after i amended it.

margarett

Actually you did :P

Look at the attached picture, look at the amont of commented out code, including the whole function that is now stated as missing ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

margarett

You need to edit it to be like attached. It is required to close the comment block...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

snadge

I didnt - if its missing code then it was already like that before (probs from package) - I know for a fact I didnt remove or overwrite more than I needed to.

Im not quite sure what Im supposed to be changing as your images dont show everything....sorry im not PHP educated lol

margarett

You need to edit News.php and change

/*** if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && @ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd']))
return $val;

$val = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', create_function('$m', 'global $scripturl; return $scripturl . \'/\' . strtr("$m[1]", \'&;=\', \'//,\') . \'.html\' . (isset($m[2]) ? $m[2] : "");'), $val);
return $val;

to

/*** if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && @ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd']))
return $val;

$val = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', create_function('$m', 'global $scripturl; return $scripturl . \'/\' . strtr("$m[1]", \'&;=\', \'//,\') . \'.html\' . (isset($m[2]) ? $m[2] : "");'), $val);
return $val;
*/

(add a block comment close *)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Antes

This is happening because of PrettyURLs modification.

snadge

@ Margarret - many thanks for that

@ Antes - is it? I have another thread running (no replies)....but we are having issues with our host who say we are using more than 500Mb per-process on PHP and because of that were getting occasional (not very often) 500 Internal Server Errors occurring as we are 'limited' by the host - thing is when it happens it just does it once, refresh the page and it reloads? I would have thought if the hosting was applying limits it would automatically stay blocked until it came under?? - we never had this issue until we moved hosting from EZPZ to TSO, but they are adamant its the forum?  we have 0-4 regular users...  if anyone can help with that it would be ace

thanks

margarett

It is. Antes is right. That piece of code you modified isn't originally like that (the comment isn't there without that MOD)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

snadge

thanks very much for your help sorting it out...really appreciate it

margarett

Good you have it fixed ;) Marked as solved for you
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Advertisement: