| Server IP : 69.72.244.102 / Your IP : 216.73.216.164 Web Server : LiteSpeed System : Linux s3434.fra1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64 User : konzalta ( 1271) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/konzalta/soko.chat/admin/ |
Upload File : |
<?php
require_once __DIR__ . '/../app/auth.php'; require_once __DIR__ . '/../app/redactor.php'; require_admin();
if($_SERVER['REQUEST_METHOD']==='POST'){$id=(int)$_POST['inbox_id'];$action=$_POST['action'];$stmt=$pdo->prepare("SELECT * FROM whatsapp_inbox WHERE id=?");$stmt->execute([$id]);$item=$stmt->fetch();if($item&&$action==='ignore'){$pdo->prepare("UPDATE whatsapp_inbox SET processing_status='ignored',processed_at=NOW() WHERE id=?")->execute([$id]);redirect(ADMIN_URL.'/whatsapp-inbox.php');}if($item&&$action==='convert'){$title=trim($_POST['title']??'')?:substr($item['message_text'],0,80);$slug=unique_slug($pdo,$title);$red=redact_deal_text($item['message_text']);$contact=extract_first_phone($item['message_text']);$stmt=$pdo->prepare("INSERT INTO deals (title,slug,public_summary,redacted_summary,full_details,contact_phone,source_whatsapp_number,submitter_phone,status,unlock_fee) VALUES (?,?,?,?,?,?,?,?, 'pending', ?)");$stmt->execute([$title,$slug,$red,$red,$item['message_text'],$contact,$item['from_phone'],$item['from_phone'],DEFAULT_UNLOCK_FEE]);$dealId=$pdo->lastInsertId();$pdo->prepare("UPDATE whatsapp_inbox SET processing_status='converted_to_deal',deal_id=?,processed_at=NOW() WHERE id=?")->execute([$dealId,$id]);redirect(ADMIN_URL.'/deals.php');}}
$items=$pdo->query("SELECT * FROM whatsapp_inbox ORDER BY created_at DESC LIMIT 100")->fetchAll();
?>
<!doctype html><html><head><meta charset="utf-8"><title>WhatsApp Inbox</title><link rel="stylesheet" href="<?= e(APP_URL) ?>/assets/css/style.css"></head><body><?php include __DIR__.'/partials_header.php'; ?><div class="wrap"><h2>whatsapp inbox</h2><?php foreach($items as $i):?><div class="panel"><strong><?= e($i['from_phone']) ?></strong> <span class="badge"><?= e($i['processing_status']) ?></span><p><?= nl2br(e($i['message_text'])) ?></p><?php if($i['processing_status']==='new'):?><form method="post"><input type="hidden" name="inbox_id" value="<?= e($i['id']) ?>"><input name="title" placeholder="title optional"><button class="button green" name="action" value="convert">convert to deal</button><button class="button gray" name="action" value="ignore">ignore</button></form><?php endif;?></div><?php endforeach;?></div></body></html>