Pergunta

Here is the script:

<?php 

$line0PHP = '<?php';
$line1PHP = 'defined( '_JEXEC' ) or die( 'Restricted access' );';
$line2PHP = 'jimport( 'joomla.plugin.plugin');';
$line3PHP = 'jimport( 'joomla.html.parameter');';
$line4PHP = 'class&#32;plgSystem'.$titleString.'plugin&#32;extends&#32;JPlugin';
$line5PHP = '{';
$line6PHP = 'function plgSystem'.$titleString.'plugin()';
$line7PHP = '{';
$line8PHP = '}';      
$line9PHP = '}';
$line10PHP = '?>';

$phpFileOutput = $line0PHP.'&nbsp;'.$line1PHP.'&nbsp;'.$line2PHP.'&nbsp;'.$line3PHP.'&nbsp;'.$line4PHP.'&nbsp;'.$line5PHP.'&nbsp;'.$line6PHP.'&nbsp;'.$line7PHP.'&nbsp;'.$line8PHP.'&nbsp;'.$line9PHP.'&nbsp;'.$line10PHP;

$varOutputPhp = print_r($phpFileOutput, true);

file_put_contents($root,$varOutputPhp);

?>

$root and $titleString are defined earlier.

Foi útil?

Solução 2

You have quoting problems, because you have single quotes inside your single-quoted strings. You need to either escape them, or use double quotes. And you still have a number of HTML entities that need to be replaced with normal characters.

<?php 

$line0PHP = '<?php';
$line1PHP = "defined( '_JEXEC' ) or die( 'Restricted access' );";
$line2PHP = "jimport( 'joomla.plugin.plugin');";
$line3PHP = "jimport( 'joomla.html.parameter');";
$line4PHP = 'class plgSystem'.$titleString.'plugin extends JPlugin';
$line5PHP = '{';
$line6PHP = 'function plgSystem'.$titleString.'plugin()';
$line7PHP = '{';
$line8PHP = '}';      
$line9PHP = '}';
$line10PHP = '?>';
$phpFileOutput = $line0PHP.' '.$line1PHP.' '.$line2PHP.' '.$line3PHP.' '.$line4PHP.' '.$line5PHP.' '.$line6PHP.' '.$line7PHP.' '.$line8PHP.' '.$line9PHP.' '.$line10PHP;

Outras dicas

    $text = "<?php \n";
    $text .= "defined('_JEXEC') or die( 'Restricted access' );\n";
    $text .= "jimport( 'joomla.plugin.plugin');\n";
    $text .= "jimport( 'joomla.html.parameter');\n";
    $text .= "class plgSystem".$titleStringplugin." extends JPlugin\n";
    $text .= "{\n";
    $text .= "function plgSystem".$titleString."plugin()\n";
    $text .= "{\n";
    $text .= "}\n";
    $text .= "}\n";
    $text .= "?>\n";

Here's the correct way of writing the code : file_put_contents($filename, $newfilecode);

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top