OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
eSamudaay
/
inc
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
10/10/2024 10:20:39 AM
rwxr-xr-x
📁
PHPMailer
-
08/29/2024 12:14:12 PM
rwxr-xr-x
📄
bcommon.js
40.38 KB
08/29/2024 12:14:11 PM
rw-r--r--
📄
bconfig.php
10.12 KB
08/29/2024 12:14:11 PM
rw-r--r--
📄
common.js
41.63 KB
08/29/2024 12:14:11 PM
rw-r--r--
📄
config.php
18.75 KB
08/29/2024 12:14:11 PM
rw-r--r--
📁
fontawesome
-
08/29/2024 12:14:24 PM
rwxr-xr-x
📄
function.php
2.8 KB
08/29/2024 12:14:11 PM
rw-r--r--
📄
genai_func.js
13.09 KB
08/29/2024 12:14:11 PM
rw-r--r--
📄
genai_style.css
3.13 KB
08/29/2024 12:14:11 PM
rw-r--r--
📄
grayscale.min.css
4.55 KB
08/29/2024 12:14:11 PM
rw-r--r--
📄
handler.php
5.02 KB
08/29/2024 12:14:11 PM
rw-r--r--
📄
hhandler.php
4.51 KB
08/29/2024 12:14:11 PM
rw-r--r--
📄
jquery.magnific-popup.min.js
19.74 KB
08/29/2024 12:14:11 PM
rw-r--r--
📄
magnific-popup.css
6.79 KB
08/29/2024 12:14:11 PM
rw-r--r--
📄
old_genai_func.js
10.34 KB
08/29/2024 12:14:11 PM
rw-r--r--
📄
old_genai_style.css
2.21 KB
08/29/2024 12:14:12 PM
rw-r--r--
📄
oldcommon.js
45.07 KB
08/29/2024 12:14:11 PM
rw-r--r--
📄
repconfig.php
16.79 KB
08/29/2024 12:14:12 PM
rw-r--r--
📁
simplepie
-
08/29/2024 12:14:24 PM
rwxr-xr-x
📄
style.css
7.75 KB
08/29/2024 12:14:12 PM
rw-r--r--
📄
validate.logged.php
433 bytes
08/29/2024 12:14:12 PM
rw-r--r--
📄
zconfig.php
9.7 KB
08/29/2024 12:14:12 PM
rw-r--r--
📄
zzconfig.php
10.02 KB
08/29/2024 12:14:12 PM
rw-r--r--
Editing: handler.php
Close
<?php $servername = "139.59.38.164"; $dbname = "reader"; $username = "root"; $password = "newstart"; $db = new mysqli($servername, $username, $password, $dbname); if ($db->connect_error) { http_response_code(500); echo json_encode(['status' => 'error', 'message' => 'Database connection failed']); exit(); } // Get the JSON data from the AJAX request $data = json_decode(file_get_contents('php://input'), true); // Check if action and itemId are provided if (isset($data['action'])) { $action = $data['action']; if ($action === 'checkColl') { $url = isset($data['url']) ? $data['url'] : null; checkCollection($db, $url); } else { $title = isset($data['title']) ? $data['title'] : null; $url = isset($data['url']) ? $data['url'] : null; $description = isset($data['description']) ? $data['description'] : null; $image = isset($data['image']) ? $data['image'] : null; $publisher = isset($data['publisher']) ? $data['publisher'] : null; $date = isset($data['date']) ? $data['date'] : null; if ($action === 'add') { addCollection($db, $title, $url, $description, $image, $publisher, $date); } elseif ($action === 'remove') { removeCollection($db, $url); } else { http_response_code(400); echo json_encode(['status' => 'error', 'message' => 'Invalid action']); } } } else { http_response_code(400); echo json_encode(['status' => 'error', 'message' => 'Missing action or itemId']); } function checkCollection($db, $url) { try { $url = $db->real_escape_string($url); $result = $db->query("SELECT COUNT(*) AS count FROM reader_save where url=\"$url\""); // Check for query errors if (!$result) { throw new Exception("Database query failed: " . $db->error); } // Fetch the result $row = $result->fetch_assoc(); $count = isset($row['count']) ? (int)$row['count'] : 0; // Output the result in JSON format echo json_encode(['status' => 'success', 'count' => $count]); } catch (Exception $e) { // Handle other exceptions http_response_code(500); echo json_encode(['status' => 'error', 'message' => 'An unexpected error occurred: ' . $e->getMessage()]); } finally { $db->close(); } } function addCollection($db, $title, $url, $description, $image, $publisher, $date) { // Enable exception handling for mysqli mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); try { // Escape inputs to avoid SQL injection $title = $db->real_escape_string($title); $url = $db->real_escape_string($url); $description = $db->real_escape_string($description); $image = $db->real_escape_string($image); $publisher = $db->real_escape_string($publisher); $date = $db->real_escape_string($date); // Execute the query $db->query("INSERT INTO reader_save (title, url, description, image, publisher, date) VALUES ('$title', '$url', '$description', '$image', '$publisher', '$date')"); // Check if an error occurred if ($db->errno === 1062) { // 1062 is the error code for duplicate entry http_response_code(409); // HTTP status code for conflict echo json_encode(['status' => 'error', 'message' => 'Duplicate entry detected']); } else { // Successful insertion echo json_encode(['status' => 'success', 'message' => 'Added to collection']); } } catch (mysqli_sql_exception $e) { // Handle MySQL-related exceptions if ($e->getCode() == 1062) { // 1062 is the error code for duplicate entry http_response_code(409); // HTTP status code for conflict echo json_encode(['status' => 'error', 'message' => 'Duplicate entry detected']); } else { // Other MySQL errors http_response_code(500); echo json_encode(['status' => 'error', 'message' => 'Failed to add to collection: ' . $e->getMessage()]); } } catch (Exception $e) { // Handle other exceptions http_response_code(500); echo json_encode(['status' => 'error', 'message' => 'An unexpected error occurred: ' . $e->getMessage()]); } finally { // Close the connection $db->close(); } } function removeCollection($db, $url) { // Remove from collection $stmt = $db->prepare("DELETE FROM reader_save WHERE url = ?"); $stmt->bind_param('s', $url); if ($stmt->execute()) { $stmt->close(); $db->close(); echo json_encode(['status' => 'success', 'message' => 'Removed from collection']); } else { $stmt->close(); $db->close(); http_response_code(500); echo json_encode(['status' => 'error', 'message' => 'Failed to remove from collection']); } }