1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| ini_set('max_execution_time', 0);
$action = "";
$index = 0;
if(!empty($_GET['action'])) $action = $_GET['action'];
if(!empty($_GET['index'])) $index = $_GET['index'];
$tables = array("table1", "table2", "table3", "table4");
echo "<button OnClick=\"javascript:self.location.href ='admin_options.php?action=set_correct_money_caracter';\"> Set correct money caracter in the database </button>";
echo "<BR><BR>";
echo "<img src=images\warning.gif height=30>";
echo "<BR><BR>";
echo "<I>This action can take few minutes. Do not quit during the procedure.</I>";
echo "<BR><BR>";
echo "<hr style=\"width: 100%; height: 2px;\">";
echo "<BR><BR>";
if($action=="set_correct_money_caracter"){
if($index<count($tables)){
$index ++;
echo "<SCRIPT langage=javascript>
if (confirm(\"Do you want to update the table ".$tables[$index-1]."?\")) {
window.location=\"admin_options.php?action=update_table&index=$index\";
}else{
window.location=\"admin_options.php?action=set_correct_money_caracter&index=$index\";
}
</SCRIPT>";
}
}
if($action=="update_table"){
$qry = mssql_query("SELECT * FROM ".$tables[$index-1]);
$nb_columns = mssql_num_fields($qry);
$nb_lines = mssql_num_rows($qry);
for($line=0; $line<$nb_lines; $line++){
$table_array = mssql_fetch_array($qry);
for($column=0; $column<$nb_columns; $column++){
$id = $table_array['id'];
$field = mssql_field_name($qry, $column);
if($field!="id"){
$table_array[$column] = str_replace("Gé¼", "", "$table_array[$column]" );
mssql_query("UPDATE ".$tables[$index-1]." SET $field = '$table_array[$column]' WHERE id=\"$id\"");
$table_array[$column] = str_replace("Ç", "", "$table_array[$column]" );
mssql_query("UPDATE ".$tables[$index-1]." SET $field = '$table_array[$column]' WHERE id=\"$id\"");
$table_array[$column] = str_replace("ç", "", "$table_array[$column]" );
mssql_query("UPDATE ".$tables[$index-1]." SET $field = '$table_array[$column]' WHERE id=\"$id\"");
$table_array[$column] = str_replace("ú", "£", "$table_array[$column]" );
mssql_query("UPDATE ".$tables[$index-1]." SET $field = '$table_array[$column]' WHERE id=\"$id\"");
}
}
}
js_alert("Table updated!");
echo "<SCRIPT langage=javascript>
window.location=\"admin_options.php?action=set_correct_money_caracter&index=$index\";
</SCRIPT>";
} |
Partager