Witaj,
kiedyś takie cudo znalazłem:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
<meta name="Description" content=" [wstaw tu opis strony] ">
<meta name="Keywords" content=" [wstaw tu slowa kluczowe] ">
<meta name="Author" content=" [dane autora] ">
<meta name="Generator" content="kED2">
<title> [tytuł strony] </title>
<link rel="stylesheet" href=" [nazwa_arkusza_stylow.css] " type="text/css">
</head>
<body>
<?php
function dane($a) {
if(get_magic_quotes_gpc())
{
$tmp = stripslashes($a);
}
else
{
$tmp = $a;
}
return mysql_real_escape_string($tmp);
}
// polaczenie z baz± danych
$sql_open = mysql_connect ("localhost", "user", "pass") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("nazwa_bazy");
$sql_id = ''; // prefix tabel
//szukamy posty z krzakami:
$zap = mysql_query("SELECT postid, pagetext FROM ".$sql_id."post WHERE pagetext LIKE '%[center:%' LIMIT 0,50");
while ($tab = mysql_fetch_assoc($zap)) {
$str = $tab['pagetext'];
echo '<br>id: '.$tab['postid'].' stare: '.$str;
$str = preg_replace("/\[center:([a-z0-9]+)\](.*?)\[\/center:([a-z0-9]+)\]/si", "
[center]\\2[/center]
", $str);
echo '<br><br>nowe: '.$str;
$zap2 = "UPDATE ".$sql_id."post SET pagetext='".dane($str)."' WHERE postid='".$tab['postid']."'";
$x = mysql_query($zap2);
}
?>
</body>
</html>
UWAGA: zrób kopię bazy przez użyciem tego skryptu!
Pamiętaj też, by zmienić dane dostępowe do bazy danych.