MyBB Community Forums

Full Version: Plugin Library not working?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I'm using PluginLibrary (12) and it seems that the function

$PL->edit_core();

is not working. It activates the plugin fine but it doesn't do any changes to the plugin file I've specified.

$PL->edit_core('sprited_awards', 'my_awards.php', array(
		'search' => '$awards .= "<img src="uploads/awards/".$cawards[$key][\'awimg\']."" alt="".$cawards[$key][\'awname\']."" title="".$cawards[$key][\'awname\']."" />";',
		'replace' => '$awards .= "<i class="awards-".$cawards[$key][\'id\'].""></i>";'), true);

Note: yes, i have tried debugging it. No errors... I'm using PHP 5.6.23 if that helps.
When you say you've tried to debug it, how?

Have you tried to parse another argument with a variable for debugging?
Is the file in question writeable by the user PHP is running under? Check the chmod permissions to be sure.
(2016-08-26, 05:05 PM)nth Wrote: [ -> ]When you say you've tried to debug it, how?

Have you tried to parse another argument with a variable for debugging?

https://github.com/frostschutz/MyBB-Plug...#debugging

(2016-08-26, 05:15 PM)Euan T Wrote: [ -> ]Is the file in question writeable by the user PHP is running under? Check the chmod permissions to be sure.

Using XAMPP (on Windows 10) so I'm not sure about chmoding files, but I chmoded the folder but still no change.
And what's the output after you've debugged? Is it giving you any matches?
(2016-08-26, 07:40 PM)nth Wrote: [ -> ]And what's the output after you've debugged? Is it giving you any matches?

Nothing happens when activating, it says it's been successfully activated.

Edit: tested it on my live board, still nothing.
The code you're trying to replace would be a syntax error in PHP so I'm 99% sure you got the quotes wrong and or the \ are missing.

$awards .= "<img src="uploads/awards/".$cawards[$key]['awimg']."" alt="".$cawards[$key]['awname']."" title="".$cawards[$key]['awname']."" />";

PHP Parse error:  syntax error, unexpected 'uploads' (T_STRING) in php shell code on line 1

Parse error: syntax error, unexpected 'uploads' (T_STRING) in php shell code on line 1

As for edit_core() please check the return value and pass the $debug variable and print it afterwards.
(2016-08-27, 02:45 PM)frostschutz Wrote: [ -> ]The code you're trying to replace would be a syntax error in PHP so I'm 99% sure you got the quotes wrong and or the \ are missing.

$awards .= "<img src="uploads/awards/".$cawards[$key]['awimg']."" alt="".$cawards[$key]['awname']."" title="".$cawards[$key]['awname']."" />";

PHP Parse error:  syntax error, unexpected 'uploads' (T_STRING) in php shell code on line 1

Parse error: syntax error, unexpected 'uploads' (T_STRING) in php shell code on line 1

As for edit_core() please check the return value and pass the $debug variable and print it afterwards.

Thanks, i've now fixed the problem.

	$PL->edit_core('sprited_awards', 'inc/plugins/my_awards.php', array(
		'search' => '$postawards .= "<img src=\"uploads/awards/".$cawards[$key][\'awimg\']."\" alt=\"".$cawards[$key][\'awname\']."\" title=\"".$cawards[$key][\'awname\']."\" />";',
		'replace' => '$postawards .= "<i class=\"award-".$cawards[$key][\'id\']."\"></i>";'), true);