Viewing file: c1.php (1.33 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
require_once("encodingroutines.php");
$conn = pg_connect("dbname=ax_andras_tinkers");
pg_query("ALTER TABLE msgboard_messages ADD COLUMN text_in_utf8 bool NOT NULL DEFAULT false;"); pg_query("ALTER TABLE msgboard_messages ADD COLUMN text_original_in_utf8 bool NOT NULL DEFAULT false;"); pg_query("ALTER TABLE msgboard_messages ADD COLUMN text_marked_for_checkup bool NOT NULL DEFAULT false;"); pg_query("ALTER TABLE msgboard_messages ADD COLUMN text_original text;"); pg_query("ALTER TABLE msgboard_messages ADD COLUMN text_conversion_date timestamp;");
pg_query("select set_curcfg('default');");
$result=pg_query("SELECT id,text from msgboard_messages where not text_in_utf8 and not text_original_in_utf8;"); $itemcounter=0; while($row=pg_fetch_array($result)) { $itemcounter++; echo $itemcounter."\r"; if(is_ascii($row['text'])) { pg_query('UPDATE msgboard_messages SET text_in_utf8=true WHERE id='.$row['id'].';'); continue; } $mytext=str_replace(chr(160),chr(32),$row['text']); if(is_ascii($mytext)) { pg_query("UPDATE msgboard_messages SET text_in_utf8=true, text_original=text, text='".pg_escape_string($mytext)."' WHERE id=".$row['id'].";"); continue; } else if(is_utf8($row['text'])) { pg_query("UPDATE msgboard_messages SET text_original_in_utf8=true WHERE id=".pg_escape_string($row['id']).";"); continue; } } echo "\n";
?>
|