Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/monara/public_html/test.athavaneng.com/themes.php on line 99
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 226
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 227
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 228
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 229
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 230
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 231
\$conn is not defined in db_connect.php");
}
// 3. Define the slug function
function create_slug($string) {
$slug = strtolower($string);
$slug = str_replace(' ', '-', $slug);
$slug = preg_replace('/[^a-z0-9-]/', '', $slug);
$slug = preg_replace('/-+/', '-', $slug);
return trim($slug, '-');
}
echo "Starting Slug Update...
";
// 4. Handle based on connection type (PDO vs MySQLi)
if ($conn instanceof PDO) {
echo "Connection Type: PDO detected.
";
// Fetch all items
try {
// Try selecting from lowercase table first
$stmt = $conn->query("SELECT id, title, slug FROM teledramas");
} catch (PDOException $e) {
// If failed, try Capitalized table name (Linux is case sensitive)
try {
$stmt = $conn->query("SELECT id, title, slug FROM Teledramas");
} catch (PDOException $e2) {
die("Error: Could not find table 'teledramas' or 'Teledramas'.
DB Error: " . $e->getMessage());
}
}
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (count($rows) > 0) {
// Prepare the update statement once for efficiency
$updateStmt = $conn->prepare("UPDATE teledramas SET slug = :slug WHERE id = :id");
foreach ($rows as $row) {
$id = $row['id'];
$title = $row['title'];
$currentSlug = $row['slug'];
// Only update if slug is empty
if (empty($currentSlug)) {
$newSlug = create_slug($title);
$updateStmt->execute([':slug' => $newSlug, ':id' => $id]);
echo "Updated ID $id: $title -> $newSlug
";
} else {
echo "Skipped ID $id: Already has slug ($currentSlug)
";
}
}
} else {
echo "Table found, but it has 0 rows of data. Did you import your data?";
}
} elseif ($conn instanceof mysqli) {
echo "Connection Type: MySQLi detected.
";
$result = mysqli_query($conn, "SELECT id, title, slug FROM teledramas");
// Check if table exists/query worked
if (!$result) {
die("Query failed: " . mysqli_error($conn) . "
Check if table name is 'Teledramas' (Capitalized).");
}
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$id = $row['id'];
$title = $row['title'];
if (empty($row['slug'])) {
$slug = create_slug($title);
$updateSql = "UPDATE teledramas SET slug = '$slug' WHERE id = '$id'";
mysqli_query($conn, $updateSql);
echo "Updated ID $id: $title -> $slug
";
} else {
echo "Skipped ID $id: Already has slug.
";
}
}
} else {
echo "Table is empty.";
}
} else {
die("Error: \$conn is not a valid PDO or MySQLi object.");
}
?>