MyBB Community Forums

Full Version: [solved]PluginLibrary editcore[/solved]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

Last night, I wrote a function that edits global.php in the mybb root. This was successful, but now today I noticed that I need to add some lines to inc/functions.php. So I wrote up the code to do so,
$result2 = $PL->edit_core("steam_mod", "inc/functions.php", array("search" => "?>", "before" => array("function url_get_contents($url) {","$ch = curl_init();","curl_setopt($ch, CURLOPT_URL, $url);","curl_setopt($ch, CURLOPT_RETURNTRANSFER, $url);","$out = curl_exec($ch);",	"curl_close($ch);","return $out;","}")), true, $debugr2);

This should represent:

function url_get_contents($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, $url);
$out = curl_exec($ch);
curl_close($ch);
return $out;
}

Though when run I run my core edit apply link I am getting an error, so I added the $debugr2 variable and added it to the error flash message I created. All I see in that variable with print_r($debugr2) is "1".

Here is the full edit function code:
http://pastie.org/private/6v7hr3jsdoaogfclhakq

I'm really not sure what's going on. Anyone have any clue? Thanks in advance.

Solved

I didn't realize there were multiple "?>"'s in the file.
(2013-07-08, 12:59 AM)JakeA Wrote: [ -> ]All I see in that variable with print_r($debugr2) is "1".

1 is the return value of print_r() itself.

use '<pre style="text-align: left">'.htmlspecialchars(print_r($yourstuff, true)).'</pre>'

or just print_r($yourstuff); exit; so it won't vanish in a redirect