| Server IP : 119.195.102.159 / Your IP : 216.73.217.134 Web Server : nginx/1.18.0 System : Linux picell 5.15.0-181-generic #191-Ubuntu SMP Fri May 22 19:09:02 UTC 2026 x86_64 User : altablue ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /tmp/ |
Upload File : |
<?php
require_once '/home2/haeyulhome/blog-haeyul-co-kr/db/db.php';
$conn = new mysqli($host, $user, $passwd, $dataname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$conn->set_charset("utf8");
echo "Connected to DB: {$dataname}\n";
$res = $conn->query("SHOW TABLES");
$total_updated = 0;
while ($row = $res->fetch_array()) {
$table = $row[0];
$cols_res = $conn->query("SHOW COLUMNS FROM `{$table}`");
while ($col = $cols_res->fetch_assoc()) {
$field = $col['Field'];
$type = strtolower($col['Type']);
if (strpos($type, 'char') !== false || strpos($type, 'text') !== false) {
$check_sql = "SELECT COUNT(*) as cnt FROM `{$table}` WHERE `{$field}` LIKE '%http://haeyul.co.kr/ko_finder/%'";
$cnt_res = $conn->query($check_sql);
if ($cnt_res) {
$c = $cnt_res->fetch_assoc()['cnt'];
if ($c > 0) {
echo "Found {$c} rows in {$table}.{$field}\n";
$update_sql = "UPDATE `{$table}` SET `{$field}` = REPLACE(`{$field}`, 'http://haeyul.co.kr/ko_finder/', '/ko_finder/') WHERE `{$field}` LIKE '%http://haeyul.co.kr/ko_finder/%'";
$conn->query($update_sql);
$affected = $conn->affected_rows;
echo "Updated {$affected} rows in {$table}.{$field}\n";
$total_updated += $affected;
}
}
}
}
}
echo "TOTAL UPDATED ROWS: {$total_updated}\n";