2005-12-11, 08:55 PM
This small code change will allow you to search and replace in all of your templates, be careful! dont replace loads of things, only do this if you know what you are doing.
open admin/templates.php and find the follwoing code.
replace this with :
enjoy, and let me know if it works properly!
open admin/templates.php and find the follwoing code.
if($mybb->input['action'] == "do_replace") {
$noheader = 1;
if(!$mybb->input['find']) {
cpmessage($lang->search_noneset);
} else {
cpheader();
starttable();
tableheader($lang->search_results);
$lang->search_header = sprintf($lang->search_header, $mybb->input['find']);
tablesubheader($lang->search_header);
echo "<tr>\n";
echo "<td class=\"altbg1\">\n";
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."templates WHERE sid>='1'");
while($template = $db->fetch_array($query)) {
$newtemplate = str_replace($mybb->input['find'], $mybb->input['replace'], $template['template']);
if($newtemplate != $template['template']) {
if($mybb->input['replace'] != "") {
$updatedtemplate = array(
"template" => addslashes($newtemplate)
);
$db->update_array(TABLE_PREFIX."templates", $updatedtemplate, "tid='".$template['tid']."'");
echo "$lang->search_updated $template[title]".
makelinkcode($lang->search_edit, "templates.php?action=edit&tid=".$template[tid]).
"<br>";
} else {
echo "$lang->search_found $template[title]".
makelinkcode($lang->search_edit, "templates.php?action=edit&tid=".$template[tid]).
"<br>";
}
}
}
replace this with :
if($mybb->input['action'] == "do_replace") {
$noheader = 1;
if(!$mybb->input['find']) {
cpmessage($lang->search_noneset);
} else {
cpheader();
starttable();
tableheader($lang->search_results);
$lang->search_header = sprintf($lang->search_header, $mybb->input['find']);
tablesubheader($lang->search_header);
echo "<tr>\n";
echo "<td class=\"altbg1\">\n";
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."templates");
while($template = $db->fetch_array($query)) {
$newtemplate = str_replace($mybb->input['find'], $mybb->input['replace'], $template['template']);
if($newtemplate != $template['template']) {
if($mybb->input['replace'] != "") {
$updatedtemplate = array(
"template" => addslashes($newtemplate)
);
$db->update_query(TABLE_PREFIX."templates", $updatedtemplate, "tid='".$template['tid']."'");
echo "$lang->search_updated $template[title]".
makelinkcode($lang->search_edit, "templates.php?action=edit&tid=".$template[tid]).
"<br>";
} else {
echo "$lang->search_found $template[title]".
makelinkcode($lang->search_edit, "templates.php?action=edit&tid=".$template[tid]).
"<br>";
}
}
}
enjoy, and let me know if it works properly!