OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
cream
/
new_ui
/
assets
/
php
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
05/19/2025 10:07:13 AM
rwxr-xr-x
📁
PHPMailer
-
05/19/2025 10:07:13 AM
rwxr-xr-x
📄
blockAccount.php
2.23 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
bottom_navbar.php
5.67 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
ch_config.php
9.37 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
ch_db_config.php
3.44 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
common.js
46.89 KB
05/16/2025 04:32:09 AM
rw-r--r--
📄
config.php
9.37 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
db_config.php
3.43 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
db_connect.php
293 bytes
05/19/2025 10:07:13 AM
rw-r--r--
📄
db_gallery.php
294 bytes
05/19/2025 10:07:13 AM
rw-r--r--
📄
delete_account.php
3.5 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
edit_post.php
2.23 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
event_scrollbar.php
4.63 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
footer.php
1.12 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
function.php
23.34 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
getEditContent.php
860 bytes
05/19/2025 10:07:13 AM
rw-r--r--
📄
go_backbar.php
2.32 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
handler.php
3.51 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
indexFooter.php
1.05 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
mail.php
2.67 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
navbar.php
22.77 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
new_social_navbar.php
1.07 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
new_social_sidebar.php
5.59 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
original-function.php
30.55 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
process_data.php
3.87 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
readert_validate.logged.php
481 bytes
05/19/2025 10:07:13 AM
rw-r--r--
📄
report_account.php
1.42 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
report_stream.php
2.08 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
savePost.php
2.38 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
sidebar.php
19.68 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
siginupProcess.php
5.24 KB
05/19/2025 10:07:13 AM
rw-r--r--
📁
simplepie
-
05/19/2025 10:07:13 AM
rwxr-xr-x
📄
stream.php
62.49 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
stream_post_handler.php
3.68 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
validate.logged.php
1.31 KB
05/19/2025 10:07:13 AM
rw-r--r--
Editing: handler.php
Close
<?php // Function to check if the user has already liked the post function hasUserLiked($conn, $userId, $streamId) { $query = "SELECT 1 FROM reader_stream_like WHERE userId = ? AND streamId = ?"; $stmt = $conn->prepare($query); $stmt->bind_param("ii", $userId, $streamId); $stmt->execute(); $stmt->store_result(); return $stmt->num_rows > 0; // Return true if the user has already liked, else false } // Function to insert a like (like the post) function insertLike($conn, $userId, $streamId) { $query = "INSERT INTO reader_stream_like (userId, streamId) VALUES (?, ?)"; $stmt = $conn->prepare($query); $stmt->bind_param("ii", $userId, $streamId); return $stmt->execute(); } // Function to delete a like (unlike the post) function deleteLike($conn, $userId, $streamId) { $query = "DELETE FROM reader_stream_like WHERE userId = ? AND streamId = ?"; $stmt = $conn->prepare($query); $stmt->bind_param("ii", $userId, $streamId); return $stmt->execute(); } // Function to get the like count for a stream function getLikeCount($conn, $streamId) { $query = "SELECT COUNT(*) AS like_count FROM reader_stream_like WHERE streamId = ?"; $stmt = $conn->prepare($query); $stmt->bind_param("i", $streamId); $stmt->execute(); $result = $stmt->get_result(); $data = $result->fetch_assoc(); // return ($data['like_count']* 10)+ rand(0, 9); return $data['like_count']; } // Include your database connection (assumed to be set up in db.php) include('db_connect.php'); // Get the raw POST data $data = json_decode(file_get_contents('php://input'), true); // Check if data is valid if (isset($data['request'], $data['userId'], $data['feedId'])) { $request = $data['request']; $userId = $data['userId']; $streamId = $data['feedId']; // FeedId corresponds to streamId // Handle like or unlike action if ($request === 'like') { // Check if the user has already liked this post if (!hasUserLiked($conn, $userId, $streamId)) { // User has not liked yet, so insert a new like if (insertLike($conn, $userId, $streamId)) { // After inserting, get the new like count $likeCount = getLikeCount($conn, $streamId); $response = ['status' => 'success', 'likeCount' => $likeCount]; } else { $response = ['status' => 'error', 'message' => 'Unable to like post']; } } else { $response = ['status' => 'error', 'message' => 'You already liked this post']; } } elseif ($request === 'unlike') { // User has liked this post, so remove the like if (deleteLike($conn, $userId, $streamId)) { // After deleting, get the updated like count $likeCount = getLikeCount($conn, $streamId); // If there are no likes, return null (or 0 depending on your preference) $response = ['status' => 'success', 'likeCount' => $likeCount > 0 ? $likeCount : null]; } else { $response = ['status' => 'error', 'message' => 'Unable to unlike post']; } } else { // Invalid request type $response = ['status' => 'error', 'message' => 'Invalid request']; } } else { $response = ['status' => 'error', 'message' => 'Invalid data']; } // Set the response content type to JSON and return the response header('Content-Type: application/json'); echo json_encode($response); ?>