2009-07-22, 12:29 AM
Ok I am sick to death of trying to get this find and replace working properly but for the life of me its giving me a headache.
I have tried this:
But with that I get this error:
I have also tried doing 2 fwrite's in one file search but that isn't even working. Having 2 different searches and replacements in one file causes it to only do the first search and replace.
So any help in this are would make my day so much better.
Thanks
I have tried this:
//Change something in a 777 chmoded file.
$fh = fopen('modules/forum/management.php', "r") or die("Could not open file!"); //OPEN FILE
$size = fread($fh, filesize('modules/forum/management.php')) or die("Could not read file!"); //MAKE TEMPORARY STRING
fclose($fh); //CLOSE FILE AGAIN
$fw = fopen('modules/forum/management.php', "r+") or die('Could not open file!'); //OPEN FILE AGAIN
$data = preg_replace('#'.preg_quote('"defaultsortorder" => $db->escape_string($mybb->input[\'defaultsortorder\']),').'#','"defaultsortorder" => $db->escape_string($mybb->input[\'defaultsortorder\']),
"forum_icon" => $db->escape_string($mybb->input[\'forum_icon\']),',$size); //REPLACE IN STRING
fwrite($fw, $data) or die('Could not write to file');
$data = preg_replace('#'.preg_quote('$form_container->output_row($lang->forum_link, $lang->forum_link_desc, $form->generate_text_box(\'linkto\', $forum_data[\'linkto\'], array(\'id\' => \'linkto\')), \'linkto\');').'#','$form_container->output_row($lang->forum_link, $lang->forum_link_desc, $form->generate_text_box(\'linkto\', $forum_data[\'linkto\'], array(\'id\' => \'linkto\')), \'linkto\');
$form_container->output_row("Forum Icon", "Add a custom forum icon to appear in place of the default forum icons.", $form->generate_text_box(\'forum_icon\', $forum_data[\'forum_icon\'], array(\'id\' => \'forum_icon\')), \'forum_icon\');',$size); //REPLACE IN STRING
fwrite($fw, $data) or die('Could not write to file');
fclose($fw); //CLOSE FILE AGAIN
But with that I get this error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /forums/inc/plugins/pl9forumicons.php on line 181
I have also tried doing 2 fwrite's in one file search but that isn't even working. Having 2 different searches and replacements in one file causes it to only do the first search and replace.
So any help in this are would make my day so much better.
Thanks