Linux ubuntu 6.8.0-90-generic #91-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 18 14:14:30 UTC 2025 x86_64
nginx/1.24.0
: 67.217.245.49 | : 216.73.216.153
Cant Read [ /etc/named.conf ]
8.3.6
www-data
Bypass.pw
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
Backdoor Scanner
Backdoor Create
Alfa Webshell
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
var /
www /
html /
mangapix /
public_html /
berribo /
[ HOME SHELL ]
Name
Size
Permission
Action
js
[ DIR ]
drwxrwxrwx
uploads
[ DIR ]
drwxrwxrwx
.htaccess
480
B
-rwxrwxrwx
00-01.jpg
562.85
KB
-rwxrwxrwx
02.jpg
35.82
KB
-rwxrwxrwx
03.jpg
378.77
KB
-rwxrwxrwx
04-05.jpg
696.59
KB
-rwxrwxrwx
06-07.jpg
685.45
KB
-rwxrwxrwx
08.jpg
421.87
KB
-rwxrwxrwx
09.jpg
410.44
KB
-rwxrwxrwx
10.jpg
330.76
KB
-rwxrwxrwx
AgentForm.html
11.52
KB
-rwxrwxrwx
AgentPanel.html
17.48
KB
-rwxrwxrwx
AgentReport.html
24.23
KB
-rwxrwxrwx
actions.php
8.39
KB
-rwxrwxrwx
add_article.php
18.23
KB
-rwxrwxrwx
add_chapter_section.php
11.79
KB
-rwxrwxrwx
add_new_manga.php
12.93
KB
-rwxrwxrwx
articles.php
18.06
KB
-rwxrwxrwx
bootstrap.min.css
141.49
KB
-rwxrwxrwx
bootstrap.min.js
47.8
KB
-rwxrwxrwx
change-password.php
8.51
KB
-rwxrwxrwx
comment.php
23.33
KB
-rwxrwxrwx
dashboard.php
16.33
KB
-rw-rw-r--
dashboard_ori.php
21.05
KB
-rwxrwxrwx
datasource.php
1.5
KB
-rwxrwxrwx
dbhelper.php
52.98
KB
-rwxrwxrwx
edit_article.php
19.52
KB
-rwxrwxrwx
edit_chapter_section.php
19.73
KB
-rw-rw-r--
edit_chapter_section_org.php
16.57
KB
-rwxrwxrwx
edit_chapter_section_org1.php
35.18
KB
-rwxrwxrwx
edit_chapter_section_ori.php
35.2
KB
-rwxrwxrwx
edit_manga.php
23.37
KB
-rwxrwxrwx
edit_manga2.php
27.92
KB
-rw-rw-r--
error.php
0
B
-rwxrwxrwx
favicon.ico
67.58
KB
-rwxrwxrwx
footer.php
1.21
KB
-rwxrwxrwx
generate_sitemap.php
14.74
KB
-rwxrwxrwx
genre.php
15.07
KB
-rwxrwxrwx
header.php
8.49
KB
-rwxrwxrwx
home.php
45.57
KB
-rwxrwxrwx
index.php
258
B
-rwxrwxrwx
insert-image.png
12.36
KB
-rwxrwxrwx
jquery-slim.min.js
67.97
KB
-rwxrwxrwx
loading-dark.gif
17.85
KB
-rwxrwxrwx
log.txt
208.9
KB
-rwxrwxrwx
login.php
0
B
-rwxrwxrwx
logo_dark.7c81824.png
70.25
KB
-rwxrwxrwx
logo_light.d9991b5.png
70.25
KB
-rwxrwxrwx
logo_white.f5e6e19.png
70.25
KB
-rwxrwxrwx
logout.php
185
B
-rwxrwxrwx
main.js
56
B
-rwxrwxrwx
manage_ads.php
33.09
KB
-rw-rw-r--
manga_requests.php
11.38
KB
-rwxrwxrwx
page_section.php
15.59
KB
-rwxrwxrwx
phpinfo.php
18
B
-rwxrwxrwx
popper.min.js
18.74
KB
-rwxrwxrwx
pwnkit
0
B
-rw-r--r--
rome.css
1.76
KB
-rwxrwxrwx
rome.js
433.52
KB
-rwxrwxrwx
script.php
1.41
KB
-rwxrwxrwx
search_keywords.php
11.28
KB
-rw-rw-r--
signin.php
6.97
KB
-rwxrwxrwx
signup.php
7.23
KB
-rwxrwxrwx
sitemap-chapters.xml
1.65
MB
-rw-r--r--
sitemap-genre.xml
5.15
KB
-rw-r--r--
sitemap-manga.xml
30.47
KB
-rw-r--r--
sitemap.xml
648
B
-rwxrwxrwx
sitemap1.xml
13.43
KB
-rwxrwxrwx
sitemap_index.xml
528
B
-rw-r--r--
starter-template.css
109
B
-rwxrwxrwx
statistics.php
24.64
KB
-rwxrwxrwx
stats_data.php
2.94
KB
-rw-rw-r--
style_css.php
97.59
KB
-rwxrwxrwx
styles.css
660.94
KB
-rwxrwxrwx
thumbnail(19).webp
40.43
KB
-rwxrwxrwx
transfer_image.php
1.91
KB
-rwxrwxrwx
upload.php
1.26
KB
-rwxrwxrwx
Delete
Unzip
Zip
${this.title}
Close
Code Editor : dbhelper.php
<?php date_default_timezone_set("Asia/Kuching"); class DBHelper { private $db; function __construct() { require_once(__DIR__ . "/datasource.php"); $this->db = new DataSource(); } public function log($message) { $myfile = fopen("./log.txt", "a") or die("Unable to open file!"); $txt = $message . "\n"; fwrite($myfile, $txt); fclose($myfile); } public function write_sitemap($url, $priority) { $myfile = fopen("./sitemap.xml", "a") or die("Unable to open file!"); $txt = "<url>" . "\n"; $txt .= "<loc>" . $url . "</loc>" . "\n"; $txt .= "<lastmod>" . date("Y-m-d\TH:i:sP", time()) . "</lastmod>" . "\n"; $txt .= "<priority>" . $priority . "</priority>" . "\n"; $txt .= "</url>" . "\n\n"; fwrite($myfile, $txt); fclose($myfile); } public function write_sitemap1($url, $priority) { $myfile = fopen("./sitemap1.xml", "a") or die("Unable to open file!"); $txt = "<url>" . "\n"; $txt .= "<loc>" . $url . "</loc>" . "\n"; $txt .= "<lastmod>" . date("Y-m-d\TH:i:sP", time()) . "</lastmod>" . "\n"; $txt .= "<priority>" . $priority . "</priority>" . "\n"; $txt .= "</url>" . "\n\n"; fwrite($myfile, $txt); fclose($myfile); } function getUserById($user_id) { $result = $this->db->select("SELECT * FROM users WHERE id=:id", ['id' => $user_id]); return $result; } function getUsersCount() { $result = $this->db->select("SELECT * FROM users"); return sizeof($result); } function getClientIP() { $clientIP = $_SERVER['HTTP_CLIENT_IP'] ?? $_SERVER["HTTP_CF_CONNECTING_IP"] # when behind cloudflare ?? $_SERVER['HTTP_X_FORWARDED'] ?? $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['HTTP_FORWARDED'] ?? $_SERVER['HTTP_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0'; return $clientIP; } public function processLogin($username, $password) { $query = "select * FROM users WHERE username = :username AND active=1"; $params = ['username' => $username]; $user = $this->db->select($query, $params); if (!empty($user)) { if (!isset($_SESSION)) { session_start(); } if ($user && password_verify($password, $user[0]['password'])) { $_SESSION["userId"] = $user[0]["id"]; $_SESSION["username"] = $user[0]["username"]; $_SESSION["role"] = $user[0]["role"]; return true; } else { $_SESSION["errorMessage"] = 'Invalid User'; return false; } } else { $_SESSION["errorMessage"] = 'Not Active User'; return false; } } public function addUserActionLog($user_id, $action, $ref_table, $ref_id) { $query = "INSERT INTO user_action_logs (user_id, action, ip, ref_table, ref_id, created) VALUE (:user_id, :action, :ip, :ref_table, :ref_id, :created)"; $params = [ 'user_id' => $user_id, 'action' => $action, 'ip' => $this->getClientIP(), 'ref_table' => $ref_table, 'ref_id' => $ref_id, 'created' => date("Y-m-d H:i:s") ]; $this->db->execute($query, $params); } public function signUp($username, $password) { $passwordHash = password_hash($password, PASSWORD_DEFAULT); $query = "INSERT INTO users (username, password, role, created, modified) VALUE (:username, :password, :role, :created, :modified)"; $params = ['username' => $username, 'password' => $passwordHash, 'role' => 'Super Admin', 'created' => date("Y-m-d H:i:s"), 'modified' => date("Y-m-d H:i:s")]; $user = $this->db->execute($query, $params); if (!empty($user)) { return true; } else { return false; } } public function createManga($title, $author, $description, $genres, $attachment) { $path = ''; $ext = ''; if (!empty($attachment)) { //$this->log('Have Attachment'); $path = ''; $ext = ''; $filename = $attachment["name"]; $ext = pathinfo($filename, PATHINFO_EXTENSION); $tempname = $attachment["tmp_name"]; $filename = 'main-' . uniqid() . uniqid() . '.' . $ext; // $image_root = '/home/u317079482/domains/mangaberri.com/public_html'; $image_root = '/var/www/html/mangaberri/public_html'; $folder_name = 'mangas'; $path = $image_root . '/' . $folder_name . '/' . $filename; $upload_dir = $image_root . '/' . $folder_name . '/'; if (file_exists($upload_dir) && is_writable($upload_dir)) { if (move_uploaded_file($tempname, $path)) { $msg = "Image uploaded successfully"; $query = "INSERT INTO mangas (title, author, description, display_image, genres, created, modified) VALUES (:title, :author, :description, :display_image, :genres, :created, :modified)"; $params = [ 'title' => $title, 'author' => $author, 'description' => $description, 'display_image' => 'https://mangaberri.com/' . $folder_name . '/' . $filename, 'genres' => $genres, 'created' => date("Y-m-d H:i:s"), 'modified' => date("Y-m-d H:i:s") ]; try { $result = $this->db->execute($query, $params); return $result; } catch (Exception $e) { $this->db->log($e); } } else { $msg = "Not uploaded because of error #" . $_FILES["file"]["error"]; $this->db->log($msg); return false; } } $msg = "Not writeable folder"; $this->db->log($msg); return false; } else { $this->log('No Attachement'); $query = "INSERT INTO mangas (title, author, description, display_image, genres, created, modified) VALUES (:title, :author, :description, :display_image, :genres, :created, :modified)"; $params = [ 'title' => $title, 'author' => $author, 'description' => $description, 'display_image' => null, 'genres' => $genres, 'created' => date("Y-m-d H:i:s"), 'modified' => date("Y-m-d H:i:s") ]; $this->log(json_encode($params)); try { $result = $this->db->execute($query, $params); return $result; } catch (Exception $e) { $this->db->log($e); } } } public function updateManga($manga_id, $title, $author, $description, $genres, $rating, $attachment, $status, $released_date) { $path = ''; $ext = ''; if (!empty($attachment['name'])) { //$this->log('Have Attachment'); $path = ''; $ext = ''; $filename = $attachment["name"]; $ext = pathinfo($filename, PATHINFO_EXTENSION); $tempname = $attachment["tmp_name"]; $filename = 'main-' . uniqid() . uniqid() . '.' . $ext; // $image_root = '/home/u317079482/domains/mangaberri.com/public_html'; $image_root = '/var/www/html/mangaberri/public_html'; $folder_name = 'mangas'; $path = $image_root . '/' . $folder_name . '/' . $filename; $upload_dir = $image_root . '/' . $folder_name . '/'; if (file_exists($upload_dir) && is_writable($upload_dir)) { if (move_uploaded_file($tempname, $path)) { $msg = "Image uploaded successfully"; $query = "UPDATE mangas SET title=:title, author=:author, description=:description, display_image=:display_image, genres=:genres, rating=:rating, status=:status, released_date=:released_date, modified=:modified where id = :id"; $params = [ 'title' => $title, 'author' => $author, 'description' => $description, 'display_image' => 'https://mangaberri.com/' . $folder_name . '/' . $filename, 'genres' => $genres, 'rating' => $rating, 'status' => $status, 'released_date' => $released_date, 'modified' => date("Y-m-d H:i:s"), 'id' => $manga_id ]; try { $result = $this->db->execute($query, $params); return $result; } catch (Exception $e) { $this->db->log($e); } } else { $msg = "Not uploaded because of error #" . $_FILES["file"]["error"]; $this->db->log($msg); return false; } } $msg = "Not writeable folder"; $this->db->log($msg); return false; } else { $query = "UPDATE mangas SET title=:title, author=:author, description=:description, genres=:genres, rating=:rating, status=:status, released_date=:released_date, modified=:modified where id = :id"; $params = [ 'title' => $title, 'author' => $author, 'description' => $description, 'genres' => $genres, 'rating' => $rating, 'status' => $status, 'released_date' => $released_date, 'modified' => date("Y-m-d H:i:s"), 'id' => $manga_id ]; try { $result = $this->db->execute($query, $params); return $result; } catch (Exception $e) { $this->db->log($e); } } } function uploadTomangaberri($transfer_type, $files) { $url = 'https://mangaberri.com/mangabo/transfer_image.php?rnd=' . time(); $curl = curl_init(); $params = (object)array(); $params->transfer_type = $transfer_type; $this->db->log('Attachment TMP : ' . $files['tmp_name']); if (function_exists('curl_file_create')) { $params->attachment = curl_file_create($files['tmp_name'], $files['type'], $files['name']); } else { $params->attachment = '@' . $files['tmp_name']; } curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $params )); $this->db->log('Params : ' . json_encode($params)); $response = curl_exec($curl); $this->db->log('Reponse : ' . json_encode($response)); curl_close($curl); return $response; } function getAllMangas() { $query = "SELECT m.*, (select name from chapters where manga_id = m.id order by id desc limit 1) as latest_chapter FROM `mangas` as m"; return $this->db->select($query); } function getManga($id) { $query = "select * FROM mangas where id = :id"; $params = ['id' => $id]; return $this->db->select($query, $params); } function getMangaChapters($id) { $query = "select * FROM chapters where manga_id = :id order by display_priority,id desc"; $params = ['id' => $id]; return $this->db->select($query, $params); } /* function addMangaChapter($manga_id, $chapter_name, $attachments) { $query = "INSERT INTO chapters (manga_id, name, created, modified) VALUES (:manga_id, :name, :created, :modified)"; $params = [ 'manga_id' => $manga_id, 'name' => $chapter_name, 'created' => date("Y-m-d H:i:s"), 'modified' => date("Y-m-d H:i:s") ]; try { $chapter_id = $this->db->executeReturnID($query, $params); $total = count($attachments['name']); for ($i = 0; $i < $total; $i++) { $tmpFilePath = $attachments['tmp_name'][$i]; $filename = $attachments['name'][$i]; $this->addMangaChapterImage($manga_id, $chapter_id, $filename, $tmpFilePath); } return true; } catch (Exception $e) { $this->db->log($e); } } */ function addMangaChapter($manga_id, $chapter_name, $attachments) { $manga_id = (int)$manga_id; $chapter_name = trim((string)$chapter_name); if ($manga_id <= 0 || $chapter_name === '') return false; $query = "INSERT INTO chapters (manga_id, name, created, modified) VALUES (:manga_id, :name, :created, :modified)"; $params = [ 'manga_id' => $manga_id, 'name' => $chapter_name, 'created' => date("Y-m-d H:i:s"), 'modified' => date("Y-m-d H:i:s") ]; try { $chapter_id = (int)$this->db->executeReturnID($query, $params); if ($chapter_id <= 0) return false; // Upload images with display_priority = 1..N $total = isset($attachments['name']) ? count($attachments['name']) : 0; $priority = 1; for ($i = 0; $i < $total; $i++) { $tmpFilePath = $attachments['tmp_name'][$i] ?? ''; $filename = $attachments['name'][$i] ?? ''; if (empty($tmpFilePath) || empty($filename)) continue; if (!is_uploaded_file($tmpFilePath)) continue; $ok = $this->addMangaChapterImage($manga_id, $chapter_id, $filename, $tmpFilePath, $priority); if ($ok !== false) $priority++; } return true; } catch (Exception $e) { $this->db->log($e); return false; } } function updateMangaImages($chapter_id, $chapter_name, $attachments, $sorted_image_ids = '') { try { $chapter_id = (int)$chapter_id; $chapter_name = trim((string)$chapter_name); $info = $this->getChapterInfo($chapter_id); $manga_id = (int)($info[0]['manga_id'] ?? 0); // 1) Update chapter title $query = "UPDATE chapters SET name=:name, modified=:modified WHERE id=:id"; $params = [ 'id' => $chapter_id, 'name' => $chapter_name, 'modified' => date("Y-m-d H:i:s") ]; $this->db->execute($query, $params); // 2) Apply sorting for existing images (if provided) $sortedIds = []; if (!empty($sorted_image_ids)) { $sortedIds = array_values(array_filter(array_map('intval', explode(',', $sorted_image_ids)))); } if (!empty($sortedIds)) { // Safety: ensure these image ids belong to this chapter $placeholders = implode(',', array_fill(0, count($sortedIds), '?')); $checkSql = "SELECT id FROM chapter_images WHERE chapter_id = ? AND id IN ($placeholders)"; $checkParams = array_merge([$chapter_id], $sortedIds); $rows = $this->db->select($checkSql, $checkParams); $valid = []; foreach ($rows as $r) $valid[] = (int)$r['id']; $rank = 1; foreach ($sortedIds as $imgId) { if (!in_array($imgId, $valid, true)) continue; $uSql = "UPDATE chapter_images SET display_priority = :p, modified = :m WHERE id = :id AND chapter_id = :cid"; $this->db->execute($uSql, [ 'p' => $rank, 'm' => date("Y-m-d H:i:s"), 'id' => $imgId, 'cid' => $chapter_id ]); $rank++; } } // 3) Add new uploads at the end $maxRow = $this->db->select( "SELECT COALESCE(MAX(display_priority), 0) AS mx FROM chapter_images WHERE chapter_id = ?", [$chapter_id] ); $nextPriority = ((int)($maxRow[0]['mx'] ?? 0)) + 1; $total = isset($attachments['name']) ? count($attachments['name']) : 0; for ($i = 0; $i < $total; $i++) { $tmpFilePath = $attachments['tmp_name'][$i] ?? ''; $filename = $attachments['name'][$i] ?? ''; if (empty($tmpFilePath) || empty($filename)) continue; if (!is_uploaded_file($tmpFilePath)) continue; $this->log('New Chapter : ' . $nextPriority); // CORRECT call order $this->addMangaChapterImage( $manga_id, $chapter_id, $filename, $tmpFilePath, $nextPriority ); $nextPriority++; } return true; } catch (Exception $e) { $this->db->log($e); return false; } } function addMangaChapterImage($manga_id, $chapter_id, $filename, $tempname, $display_priority = null) { // Basic validations $manga_id = (int)$manga_id; $chapter_id = (int)$chapter_id; if ($manga_id <= 0 || $chapter_id <= 0) return false; if (empty($filename) || empty($tempname)) return false; if (!is_uploaded_file($tempname)) return false; // Only allow common image extensions (you can add more if needed) $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); $allowed = ['jpg', 'jpeg', 'png', 'webp', 'gif']; if (!in_array($ext, $allowed, true)) return false; // Sanitize filename (prevent path traversal / special characters) $safeBase = pathinfo($filename, PATHINFO_FILENAME); $safeBase = preg_replace('/[^A-Za-z0-9_\-\.]+/', '_', $safeBase); $safeBase = trim($safeBase, '._-'); if ($safeBase === '') $safeBase = 'page_' . time(); $safeFilename = $safeBase . '.' . $ext; // Paths $image_root = '/var/www/html/mangaberri/public_html'; $folder_name = 'mangas/' . $manga_id . '/' . $chapter_id; $upload_dir = rtrim($image_root . '/' . $folder_name, '/') . '/'; if (!is_dir($upload_dir)) { if (!mkdir($upload_dir, 0755, true)) return false; } if (!is_writable($upload_dir)) return false; // Avoid overwrite: if file exists, add suffix $finalFilename = $safeFilename; $targetPath = $upload_dir . $finalFilename; if (file_exists($targetPath)) { $suffix = 1; do { $finalFilename = $safeBase . '_' . $suffix . '.' . $ext; $targetPath = $upload_dir . $finalFilename; $suffix++; } while (file_exists($targetPath)); } // Optional: quick image check (not perfect, but helps) // For webp/gif sometimes getimagesize works, sometimes not depending on server build. $imgInfo = @getimagesize($tempname); if ($imgInfo === false) { // If you want to allow webp even when getimagesize fails, comment this out. // return false; } // Move upload if (!move_uploaded_file($tempname, $targetPath)) return false; // Determine display_priority (if not passed) if ($display_priority === null) { $row = $this->db->query( "SELECT COALESCE(MAX(display_priority),0) AS mx FROM chapter_images WHERE chapter_id=?", [$chapter_id] ); $display_priority = ((int)($row[0]['mx'] ?? 0)) + 1; } else { $display_priority = (int)$display_priority; if ($display_priority <= 0) $display_priority = 1; } // Public URL $publicUrl = 'https://mangaberri.com/' . $folder_name . '/' . $finalFilename; // Insert DB row (now includes display_priority) $query = "INSERT INTO chapter_images (chapter_id, path, filename, display_priority, created, modified) VALUES (:chapter_id, :path, :filename, :display_priority, :created, :modified)"; $params = [ 'chapter_id' => $chapter_id, 'path' => $publicUrl, 'filename' => $finalFilename, 'display_priority' => $display_priority, 'created' => date("Y-m-d H:i:s"), 'modified' => date("Y-m-d H:i:s") ]; try { return $this->db->execute($query, $params); } catch (Exception $e) { // cleanup file if DB insert fails @unlink($targetPath); $this->db->log($e); return false; } } /* function updateMangaImages($chapter_id, $chapter_name, $attachments) { $query = "UPDATE chapters SET name=:name, modified=:modified where id=:id"; $params = [ 'id' => $chapter_id, 'name' => $chapter_name, 'modified' => date("Y-m-d H:i:s") ]; try { $result = $this->db->execute($query, $params); $total = count($attachments['name']); for ($i = 0; $i < $total; $i++) { $tmpFilePath = $attachments['tmp_name'][$i]; $filename = $attachments['name'][$i]; $this->addMangaChapterImage($result[0]['manga_id'], $chapter_id, $filename, $tmpFilePath); } return true; } catch (Exception $e) { $this->db->log($e); return false; } } function addMangaChapterImage($manga_id, $chapter_id, $filename, $tempname) { $ext = pathinfo($filename, PATHINFO_EXTENSION); //$filename = 'chap-' . uniqid() . uniqid() . '.' . $ext; //$image_root = '/home/u317079482/domains/mangaberri.com/public_html'; $image_root = '/var/www/html/mangaberri/public_html'; $folder_name = 'mangas/' . $manga_id . '/' . $chapter_id; $path = $image_root . '/' . $folder_name . '/' . $filename; $upload_dir = $image_root . '/' . $folder_name . '/'; if (!file_exists($upload_dir)) { mkdir($upload_dir, 0777, true); } if (file_exists($upload_dir) && is_writable($upload_dir)) { if (move_uploaded_file($tempname, $path)) { $query = "INSERT INTO chapter_images (chapter_id, path, filename, created, modified) VALUES (:chapter_id, :path, :filename, :created, :modified)"; $params = [ 'chapter_id' => $chapter_id, 'path' => 'https://mangaberri.com/' . $folder_name . '/' . $filename, 'filename' => $filename, 'created' => date("Y-m-d H:i:s"), 'modified' => date("Y-m-d H:i:s") ]; try { $result = $this->db->execute($query, $params); return $result; } catch (Exception $e) { $this->db->log($e); } } } } */ function getChapterInfo($id) { $query = "select * FROM chapters where id = :id"; $params = ['id' => $id]; return $this->db->select($query, $params); } function getMangaChapterImages($id) { $query = "select * FROM chapter_images where chapter_id = :id order by display_priority"; $params = ['id' => $id]; return $this->db->select($query, $params); } function deleteChapterImage($id) { $query = "DELETE FROM chapter_images where id = :id"; $params = ['id' => $id]; return $this->db->execute($query, $params); } function deleteChapter($id) { $query = "DELETE FROM chapters where id = :id"; $params = ['id' => $id]; return $this->db->execute($query, $params); } function deleteManga($id) { $query = "DELETE FROM mangas where id = :id"; $params = ['id' => $id]; return $this->db->execute($query, $params); } function getGenres() { $query = "select * FROM genres order by name"; return $this->db->select($query); } function addGenre($name) { $query = "INSERT INTO genres (name, created, modified) VALUES (:name, :created, :modified)"; $params = [ 'name' => $name, 'created' => date("Y-m-d H:i:s"), 'modified' => date("Y-m-d H:i:s") ]; try { $result = $this->db->execute($query, $params); return $result; } catch (Exception $e) { $this->db->log($e); } } function deleteGenre($id) { $query = "DELETE FROM genres where id = :id"; $params = ['id' => $id]; return $this->db->execute($query, $params); } function getMangaRequests() { $query = "select * FROM request_inboxs order by created desc"; return $this->db->select($query); } function getSearchKeywords() { $query = "select keyword, count(id) as counter FROM search_keywords group by keyword order by count(id) desc"; return $this->db->select($query); } /* function generateSiteMangaSiteMap() { $myfile = fopen("./sitemap.xml", "w") or die("Unable to open file!"); $txt = '<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> <url> <loc>https://www.mangaberri.com/</loc> <lastmod>'. date("Y-m-d\TH:i:sP", time()) .'</lastmod> <priority>1.00</priority> </url> <url> <loc>https://www.mangaberri.com/index</loc> <lastmod>'. date("Y-m-d\TH:i:sP", time()) .'</lastmod> <priority>0.80</priority> </url>'; fwrite($myfile, $txt); fclose($myfile); $mangas = $this->getAllMangas(); foreach($mangas as $m) { $this->write_sitemap('https://mangaberri.com/' . preg_replace('/[^a-z0-9-]/', '', str_replace(' ','-', strtolower($m['title']))), '0.80'); } $query = "SELECT c.id as chapter_id, m.title as manga_title FROM `chapters` as c join mangas as m on (m.id = c.manga_id)"; $chapters = $this->db->select($query); foreach($chapters as $c) { $this->write_sitemap('https://mangaberri.com/' . preg_replace('/[^a-z0-9-]/', '', str_replace(' ','-', strtolower($c['manga_title']))) . '/' . $c['chapter_id'], '0.64'); } $genres = $this->getGenres(); foreach($genres as $g) { $this->write_sitemap('https://mangaberri.com/genres.php?genre='. $g['name'], '0.51'); } $myfile = fopen("./sitemap.xml", "a") or die("Unable to open file!"); $txt = '</urlset>'; fwrite($myfile, $txt); fclose($myfile); return true; } */ function generateSiteMangaSiteMap() { $baseUrl = 'https://mangaberri.com'; $now = date("Y-m-d\TH:i:sP"); // ===== 1) MAIN SITEMAP (home, index, maybe static pages) ===== $mainFile = './sitemap_index.xml'; $fhMain = $this->openSitemap($mainFile); $this->writeSitemapUrl($fhMain, $baseUrl . '/', '1.00', $now); $this->writeSitemapUrl($fhMain, $baseUrl . '/index', '0.80', $now); $this->closeSitemap($fhMain); // ===== 2) MANGA SITEMAP ===== $mangaFile = './sitemap-manga.xml'; $fhManga = $this->openSitemap($mangaFile); $mangas = $this->getAllMangas(); foreach ($mangas as $m) { $slug = preg_replace('/[^a-z0-9-]/', '', str_replace(' ', '-', strtolower($m['title']))); $url = $baseUrl . '/' . $slug; $this->writeSitemapUrl($fhManga, $url, '0.80', $now); } $this->closeSitemap($fhManga); // ===== 3) CHAPTER SITEMAP ===== $chapterFile = './sitemap-chapters.xml'; $fhChapter = $this->openSitemap($chapterFile); $query = "SELECT c.id as chapter_id, m.title as manga_title FROM chapters AS c JOIN mangas AS m ON (m.id = c.manga_id)"; $chapters = $this->db->select($query); foreach ($chapters as $c) { $slug = preg_replace('/[^a-z0-9-]/', '', str_replace(' ', '-', strtolower($c['manga_title']))); $url = $baseUrl . '/' . $slug . '/' . $c['chapter_id']; $this->writeSitemapUrl($fhChapter, $url, '0.64', $now); } $this->closeSitemap($fhChapter); // ===== 4) GENRE SITEMAP ===== $genreFile = './sitemap-genre.xml'; $fhGenre = $this->openSitemap($genreFile); $genres = $this->getGenres(); foreach ($genres as $g) { // urlencode so spaces/special chars don't break URLs $genreName = urlencode($g['name']); $url = $baseUrl . '/genres.php?genre=' . $genreName; $this->writeSitemapUrl($fhGenre, $url, '0.51', $now); } $this->closeSitemap($fhGenre); // ===== 5) SITEMAP INDEX (sitemap.xml) ===== $indexFile = './sitemap.xml'; $fhIndex = fopen($indexFile, 'w'); if (!$fhIndex) { die("Unable to open file sitemap.xml"); } $indexXml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n\n"; $sitemaps = [ 'sitemap_main.xml', 'sitemap-manga.xml', 'sitemap-chapters.xml', 'sitemap-genre.xml', ]; foreach ($sitemaps as $file) { $indexXml .= " <sitemap>\n"; $indexXml .= " <loc>{$baseUrl}/{$file}</loc>\n"; $indexXml .= " <lastmod>{$now}</lastmod>\n"; $indexXml .= " </sitemap>\n\n"; } $indexXml .= "</sitemapindex>"; fwrite($fhIndex, $indexXml); fclose($fhIndex); return true; } private function openSitemap($filename) { $fh = fopen($filename, "w"); if (!$fh) { die("Unable to open file $filename"); } $header = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset' . "\n" . ' xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"' . "\n" . ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . "\n" . ' xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9' . "\n" . ' http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . "\n\n"; fwrite($fh, $header); return $fh; } private function writeSitemapUrl($fh, $loc, $priority = '0.80', $lastmod = null) { if ($lastmod === null) { $lastmod = date("Y-m-d\TH:i:sP"); } $xml = " <url>\n"; $xml .= " <loc>" . htmlspecialchars($loc, ENT_QUOTES, 'UTF-8') . "</loc>\n"; $xml .= " <lastmod>{$lastmod}</lastmod>\n"; //$xml .= " <priority>{$priority}</priority>\n"; $xml .= " </url>\n\n"; fwrite($fh, $xml); } private function closeSitemap($fh) { fwrite($fh, "</urlset>"); fclose($fh); } function generateSiteMangaSiteMap1() { $myfile = fopen("./sitemap1.xml", "w") or die("Unable to open file!"); $txt = '<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> <url> <loc>https://jujutsukaisen1.com/</loc> <lastmod>' . date("Y-m-d\TH:i:sP", time()) . '</lastmod> <priority>1.00</priority> </url> <url> <loc>https://jujutsukaisen1.com/index</loc> <lastmod>' . date("Y-m-d\TH:i:sP", time()) . '</lastmod> <priority>0.80</priority> </url>'; fwrite($myfile, $txt); fclose($myfile); $query = "SELECT c.id as chapter_id, m.title as manga_title FROM `chapters` as c join mangas as m on (m.id = c.manga_id) where m.id = 22"; $chapters = $this->db->select($query); foreach ($chapters as $c) { $this->write_sitemap1('https://jujutsukaisen1.com/' . preg_replace('/[^a-z0-9-]/', '', str_replace(' ', '-', strtolower($c['manga_title']))) . '/' . $c['chapter_id'], '0.64'); } $myfile = fopen("./sitemap1.xml", "a") or die("Unable to open file!"); $txt = '</urlset>'; fwrite($myfile, $txt); fclose($myfile); return true; } function getDailyStatistics() { //$query = "select count(id) as view, date(created) as date from chapter_views WHERE created >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY) group by date(created) order by date(created) desc"; $query = "SELECT COUNT(id) AS views, created_date AS date FROM chapter_views WHERE created_date >= CURDATE() - INTERVAL 7 DAY GROUP BY created_date ORDER BY created_date DESC;"; return $this->db->select($query); } function getTotalViews() { $query = "select count(id) as view from chapter_views"; return $this->db->select($query); } function getMangaViewStatistics() { //$query = "select k.* from (select count(cv.id) as views, m.title from chapter_views as cv join mangas as m on (m.id = cv.manga_id) group by m.id) as k order by k.views desc;"; $query = "SELECT COUNT(cv.id) AS views, m.title FROM chapter_views AS cv JOIN mangas AS m ON m.id = cv.manga_id GROUP BY m.id, m.title ORDER BY views DESC;"; return $this->db->select($query); } function getIpViewStatistics() { $query = "select count(cv.id) as views, cv.ip from chapter_views as cv group by cv.ip order by count(cv.id) desc"; return $this->db->select($query); } function getUniqueIpCount() { $query = "SELECT COUNT(DISTINCT ip) AS unique_visitors FROM chapter_views"; return $this->db->select($query); } function getSourceViewStatistics() { $query = "select * from (select source, count(id) as views from chapter_views group by source) as k order by k.views desc"; return $this->db->select($query); } function getLatestChapterViewStatistics() { $query = "select m.title, c.name, cv.ip, cv.created, cv.source from chapter_views as cv join mangas as m on (m.id = cv.manga_id) join chapters as c on (cv.chapter_id = c.id) order by cv.id desc limit 200"; return $this->db->select($query); } public function resetOwnPassword($id, $oldpassword, $newpassword) { $u = $this->db->select("SELECT * FROM users WHERE id=:id", ['id' => $id]); if ($u && password_verify($oldpassword, $u[0]['password'])) { $passwordHash = password_hash($newpassword, PASSWORD_DEFAULT); $query = "Update users set password = :password, modified=:modified where id =:id"; $params = ['password' => $passwordHash, 'id' => $id, 'modified' => date("Y-m-d H:i:s")]; $user = $this->db->execute($query, $params); if (!empty($user)) { return ['success' => true, 'message' => 'Password updated.']; } else { return ['success' => false, 'message' => 'Failed to update.']; } } else { return ['success' => false, 'message' => 'Invalid old password']; } } function getArticles($category) { if (empty($category)) { $query = "select * FROM articles order by created desc"; return $this->db->select($query); } else { $query = "select * FROM articles where category = '" . $category . "' order by created desc"; return $this->db->select($query); } } public function addArticle($page_h1_title, $title, $author, $description, $main_tag, $tag, $category, $article_content, $attachment) { $path = ''; $ext = ''; if (!empty($attachment)) { $path = ''; $ext = ''; $filename = $attachment["name"]; $ext = pathinfo($filename, PATHINFO_EXTENSION); $tempname = $attachment["tmp_name"]; $filename = 'article-' . uniqid() . uniqid() . '.' . $ext; //$image_root = '/home/u317079482/domains/mangaberri.com/public_html'; $image_root = '/var/www/html/mangaberri/public_html'; $folder_name = 'articles'; $path = $image_root . '/' . $folder_name . '/' . $filename; $upload_dir = $image_root . '/' . $folder_name . '/'; if (file_exists($upload_dir) && is_writable($upload_dir)) { if (move_uploaded_file($tempname, $path)) { $msg = "Image uploaded successfully"; $query = "INSERT INTO articles (page_h1_title, title, author, description, display_image, main_tag, tag, category, article_content, created, modified) VALUES (:page_h1_title, :title, :author, :description, :display_image, :main_tag, :tag, :category, :article_content, :created, :modified)"; $params = [ 'page_h1_title' => $page_h1_title, 'title' => $title, 'author' => $author, 'description' => $description, 'display_image' => 'https://mangaberri.com/' . $folder_name . '/' . $filename, 'main_tag' => $main_tag, 'tag' => $tag, 'category' => $category, 'article_content' => $article_content, 'created' => date("Y-m-d H:i:s"), 'modified' => date("Y-m-d H:i:s") ]; try { $result = $this->db->execute($query, $params); return $result; } catch (Exception $e) { $this->db->log($e); } } else { $msg = "Not uploaded because of error #" . $_FILES["file"]["error"]; $this->db->log($msg); return false; } } $msg = "Not writeable folder"; $this->db->log($msg); return false; } else { $query = "INSERT INTO mangas (page_h1_title, title, author, description, display_image, main_tag, tag, category, article_content, created, modified) VALUES (:page_h1_title, :title, :author, :description, :display_image,:main_tag, :tag, :category, :article_content, :created, :modified)"; $params = [ 'page_h1_title' => $page_h1_title, 'title' => $title, 'author' => $author, 'description' => $description, 'display_image' => null, 'main_tag' => $main_tag, 'tag' => $tag, 'category' => $category, 'article_content' => $article_content, 'created' => date("Y-m-d H:i:s"), 'modified' => date("Y-m-d H:i:s") ]; $this->log(json_encode($params)); try { $result = $this->db->execute($query, $params); return $result; } catch (Exception $e) { $this->db->log($e); } } } public function getArticle($article_id) { $query = "select * FROM articles where id = :id"; $params = ['id' => $article_id]; return $this->db->select($query, $params); } public function publishArticle($article_id) { $query = "UPDATE articles SET publish=!publish, modified=:modified where id = :id"; $params = [ 'id' => $article_id, 'modified' => date("Y-m-d H:i:s") ]; try { $result = $this->db->execute($query, $params); return $result; } catch (Exception $e) { $this->db->log($e); } } public function updateArticle($article_id, $page_h1_title, $title, $author, $description, $main_tag, $tag, $category, $article_content, $attachment) { $path = ''; $ext = ''; if (!empty($attachment['name'])) { $path = ''; $ext = ''; $filename = $attachment["name"]; $ext = pathinfo($filename, PATHINFO_EXTENSION); $tempname = $attachment["tmp_name"]; $filename = 'main-' . uniqid() . uniqid() . '.' . $ext; // $image_root = '/home/u317079482/domains/mangaberri.com/public_html'; $image_root = '/var/www/html/mangaberri/public_html'; $folder_name = 'articles'; $path = $image_root . '/' . $folder_name . '/' . $filename; $upload_dir = $image_root . '/' . $folder_name . '/'; if (file_exists($upload_dir) && is_writable($upload_dir)) { if (move_uploaded_file($tempname, $path)) { $msg = "Image uploaded successfully"; $query = "UPDATE articles SET page_h1_title=:page_h1_title, title=:title, author=:author, description=:description, display_image=:display_image, main_tag=:main_tag, tag=:tag, category=:category, article_content=:article_content, modified=:modified where id = :id"; $params = [ 'page_h1_title' => $page_h1_title, 'title' => $title, 'author' => $author, 'description' => $description, 'display_image' => 'https://mangaberri.com/' . $folder_name . '/' . $filename, 'main_tag' => $main_tag, 'tag' => $tag, 'category' => $category, 'article_content' => $article_content, 'modified' => date("Y-m-d H:i:s"), 'id' => $article_id ]; try { $result = $this->db->execute($query, $params); return $result; } catch (Exception $e) { $this->db->log($e); } } else { $msg = "Not uploaded because of error #" . $_FILES["file"]["error"]; $this->db->log($msg); return false; } } $msg = "Not writeable folder"; $this->db->log($msg); return false; } else { $query = "UPDATE articles SET page_h1_title=:page_h1_title, title=:title, author=:author, description=:description, main_tag=:main_tag, tag=:tag, category=:category, article_content=:article_content, modified=:modified where id = :id"; $params = [ 'page_h1_title' => $page_h1_title, 'title' => $title, 'author' => $author, 'description' => $description, 'main_tag' => $main_tag, 'tag' => $tag, 'category' => $category, 'article_content' => $article_content, 'modified' => date("Y-m-d H:i:s"), 'id' => $article_id ]; try { $result = $this->db->execute($query, $params); return $result; } catch (Exception $e) { $this->db->log($e); } } } public function setMangaActive($id) { $query = "Update mangas set active = !active, modified=:modified where id =:id"; $params = ['id' => $id, 'modified' => date("Y-m-d H:i:s")]; $apw = $this->db->execute($query, $params); if (!empty($apw)) { return true; } else { return false; } } public function setIsAdultContent($id) { $query = "Update mangas set is_adult = !is_adult, modified=:modified where id =:id"; $params = ['id' => $id, 'modified' => date("Y-m-d H:i:s")]; $apw = $this->db->execute($query, $params); if (!empty($apw)) { return true; } else { return false; } } function getAllMangasWithComments() { $query = 'SELECT m.id, m.title, COUNT(c.id) AS comment_count, MAX(c.created) AS latest_comment_time FROM comments AS c JOIN mangas AS m ON m.id = c.manga_id GROUP BY m.id, m.title ORDER BY latest_comment_time DESC;'; return $this->db->select($query); } public function getComments($manga_id) { $query = "select * FROM comments where manga_id = :manga_id and parent_id is null order by created desc"; $params = ['manga_id' => $manga_id]; return $this->db->select($query, $params); } public function getAdminComments($parent_id) { $query = "select * FROM comments where parent_id = :parent_id"; $params = ['parent_id' => $parent_id]; return $this->db->select($query, $params); } function addAdminComment($manga_id, $comment_id, $comment) { $query = "INSERT INTO comments (manga_id, parent_id, comment, name, ip, created, modified) VALUES (:manga_id, :parent_id, :comment, :name, :ip, :created, :modified)"; $params = [ 'manga_id' => $manga_id, 'parent_id' => $comment_id, 'comment' => $comment, 'ip' => $this->getClientIP(), 'name' => uniqid(), 'created' => date("Y-m-d H:i:s"), 'modified' => date("Y-m-d H:i:s") ]; try { return $this->db->select($query, $params); } catch (Exception $e) { $this->db->log($e); } } function deleteComment($id) { $query = "DELETE FROM comments where id = :id"; $params = ['id' => $id]; return $this->db->execute($query, $params); } public function updateChapterOrder($manga_id, $sorted_chapter_ids) { try { $manga_id = (int)$manga_id; $ids = array_values(array_filter(array_map('intval', explode(',', (string)$sorted_chapter_ids)))); if (!$manga_id || empty($ids)) return false; // safety: only chapters from this manga $placeholders = implode(',', array_fill(0, count($ids), '?')); $rows = $this->db->select( "SELECT id FROM chapters WHERE manga_id = ? AND id IN ($placeholders)", array_merge([$manga_id], $ids) ); $valid = array_map(fn($r) => (int)$r['id'], $rows); $rank = 1; foreach ($ids as $cid) { if (!in_array($cid, $valid, true)) continue; $this->db->execute( "UPDATE chapters SET display_priority = :p, modified = :m WHERE id = :id AND manga_id = :mid", [ 'p' => $rank, 'm' => date("Y-m-d H:i:s"), 'id' => $cid, 'mid' => $manga_id, ] ); $rank++; } return true; } catch (Exception $e) { $this->db->log($e); return false; } } public function getActiveAdsByPlacement(string $placement) { $query = " SELECT * FROM ads_scripts WHERE placement = :p AND is_active = 1 ORDER BY sort_order ASC, id DESC "; return $this->db->select($query, ['p' => $placement]); } public function getAllAdsScripts() { $query = " SELECT * FROM ads_scripts ORDER BY placement ASC, sort_order ASC, id DESC "; return $this->db->select($query, []); } public function saveAdsScript($id, $placement, $provider, $name, $ad_type, $script, $direct_url, $is_active, $sort_order) { $id = (int)$id; $placement = trim((string)$placement); $provider = trim((string)$provider); $name = trim((string)$name); $ad_type = trim((string)$ad_type); if ($ad_type !== 'direct') $ad_type = 'script'; $script = (string)$script; $direct_url = trim((string)$direct_url); // Validate based on type if ($placement === '') return false; if ($ad_type === 'direct') { if ($direct_url === '') return false; // normalize if (!preg_match('~^https?://~i', $direct_url)) { $direct_url = 'https://' . $direct_url; } // optionally basic url validation if (!filter_var($direct_url, FILTER_VALIDATE_URL)) return false; // for direct type, script can be empty $script = ''; } else { if (trim($script) === '') return false; // for script type, direct_url can be null $direct_url = ''; } $params = [ 'placement' => $placement, 'provider' => $provider, 'name' => $name, 'ad_type' => $ad_type, 'script' => $script, 'direct_url' => $direct_url, 'is_active' => (int)$is_active, 'sort_order' => (int)$sort_order, 'modified' => date("Y-m-d H:i:s"), ]; if ($id > 0) { $query = " UPDATE ads_scripts SET placement=:placement, provider=:provider, name=:name, ad_type=:ad_type, script=:script, direct_url=:direct_url, is_active=:is_active, sort_order=:sort_order, modified=:modified WHERE id=:id "; $params['id'] = $id; return $this->db->execute($query, $params); } else { $query = " INSERT INTO ads_scripts (placement, provider, name, ad_type, script, direct_url, is_active, sort_order, created, modified) VALUES (:placement, :provider, :name, :ad_type, :script, :direct_url, :is_active, :sort_order, :created, :modified) "; $params['created'] = date("Y-m-d H:i:s"); return $this->db->execute($query, $params); } } public function deleteAdsScript($id) { $query = "DELETE FROM ads_scripts WHERE id = :id"; return $this->db->execute($query, ['id' => (int)$id]); } }
Close