| 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/ |
Upload File : |
<?php
require_once __DIR__ . '/app/db.php';
require_once __DIR__ . '/app/helpers.php';
require_once __DIR__ . '/app/redactor.php';
require_once __DIR__ . '/app/pricing.php';
$counties = $pdo->query("SELECT * FROM counties WHERE status='active' ORDER BY name ASC")->fetchAll();
$categories = $pdo->query("SELECT * FROM categories WHERE status='active' ORDER BY sort_order ASC")->fetchAll();
$prefCounty = $_GET['county'] ?? '';
$prefCategory = $_GET['category'] ?? '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title=trim($_POST['title']??''); $countyId=(int)($_POST['county_id']??0); $categoryId=(int)($_POST['category_id']??0);
$location=trim($_POST['location']??''); $price=trim($_POST['price']??''); $full=trim($_POST['full_details']??'');
$submitterName=trim($_POST['submitter_name']??''); $submitterPhone=trim($_POST['submitter_phone']??''); $submitterEmail=trim($_POST['submitter_email']??'');
if ($title==='' || $full==='') { flash('error','Please provide a title and deal details.'); redirect(APP_URL.'/submit.php'); }
$redacted=redact_deal_text($full); $contact=extract_first_phone($full); $slug=unique_slug($pdo,$title);
$countyName=''; $catName='';
foreach($counties as $c) if ((int)$c['id']===$countyId) $countyName=$c['name'];
foreach($categories as $c) if ((int)$c['id']===$categoryId) $catName=$c['name'];
$pricing = recommend_unlock_price(['category_name'=>$catName,'county_name'=>$countyName,'verification_status'=>'unverified','price'=>$price]);
$stmt=$pdo->prepare("INSERT INTO deals (title,slug,county_id,category_id,location,price,public_summary,redacted_summary,full_details,contact_phone,submitter_name,submitter_phone,submitter_email,verification_status,status,unlock_fee,recommended_unlock_fee,pricing_reason) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,'unverified','pending',?,?,?)");
$stmt->execute([$title,$slug,$countyId ?: null,$categoryId ?: null,$location,$price,$redacted,$redacted,$full,$contact,$submitterName,$submitterPhone,$submitterEmail,$pricing['amount'],$pricing['amount'],$pricing['reason']]);
flash('success','Deal submitted free. It will appear after review.');
redirect(APP_URL.'/submit.php');
}
?>
<!doctype html><html><head><meta charset="utf-8"><title>Post a Deal Free - <?= e(APP_NAME) ?></title><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="<?= e(APP_URL) ?>/assets/css/style.css"></head>
<body><div class="top"><div class="wrap"><a class="brand logo-brand" href="<?= e(APP_URL) ?>/"><img class="logo-img" src="<?= e(APP_URL) ?>/assets/img/soko-logo.png" alt="Soko.chat"></a><span class="tag"> post a deal free</span></div></div>
<div class="wrap"><div class="formbox"><h2>post a deal free</h2><p class="muted">Like Craigslist: simple listing, county-first. Sensitive contacts are redacted until unlock.</p>
<?php if($m=flash('success')):?><div class="alert"><?= e($m) ?></div><?php endif; ?><?php if($m=flash('error')):?><div class="alert error"><?= e($m) ?></div><?php endif; ?>
<form method="post">
<label>title</label><input name="title" required placeholder="Bedsitter in Bamburi - Ksh 7,500">
<label>county</label><select name="county_id"><option value="">choose county</option><?php foreach($counties as $c): ?><option value="<?= e($c['id']) ?>" <?= $prefCounty===$c['slug']?'selected':'' ?>><?= e($c['name']) ?></option><?php endforeach; ?></select>
<label>category</label><select name="category_id"><option value="">choose category</option><?php foreach($categories as $cat): ?><option value="<?= e($cat['id']) ?>" <?= $prefCategory===$cat['slug']?'selected':'' ?>><?= e($cat['name']) ?></option><?php endforeach; ?></select>
<label>location / estate / town</label><input name="location" placeholder="Bamburi, Kitengela, Eldoret CBD">
<label>price</label><input name="price" placeholder="Ksh 7,500">
<label>full deal details</label><textarea name="full_details" required placeholder="Paste the WhatsApp deal here, including contact details if available."></textarea>
<label>your name optional</label><input name="submitter_name"><label>your phone optional</label><input name="submitter_phone"><label>your email optional</label><input name="submitter_email">
<button class="button green">submit free</button></form></div></div></body></html>