| 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_once __DIR__ . '/../app/pricing.php'; require_admin();
$counties=$pdo->query("SELECT * FROM counties ORDER BY name")->fetchAll();$categories=$pdo->query("SELECT * FROM categories ORDER BY sort_order")->fetchAll();
if($_SERVER['REQUEST_METHOD']==='POST'){
$title=trim($_POST['title']??'');$full=trim($_POST['full_details']??'');if($title===''||$full===''){flash('error','Title and details required.');redirect(ADMIN_URL.'/deal-create.php');}
$countyId=(int)($_POST['county_id']??0);$categoryId=(int)($_POST['category_id']??0);$location=trim($_POST['location']??'');$price=trim($_POST['price']??'');$status=$_POST['status']??'pending';$ver=$_POST['verification_status']??'unverified';
$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'=>$ver,'price'=>$price]);$fee=(float)($_POST['unlock_fee']?:$pricing['amount']);
$red=redact_deal_text($_POST['public_summary']?:$full);$slug=unique_slug($pdo,$title);$contact=extract_first_phone($full);
$stmt=$pdo->prepare("INSERT INTO deals (title,slug,county_id,category_id,location,price,public_summary,redacted_summary,full_details,contact_phone,verification_status,status,unlock_fee,recommended_unlock_fee,pricing_reason,created_by) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$stmt->execute([$title,$slug,$countyId?:null,$categoryId?:null,$location,$price,$_POST['public_summary']??'',$red,$full,$contact,$ver,$status,$fee,$pricing['amount'],$pricing['reason'],current_user()['id']]);
flash('success','Deal created.');redirect(ADMIN_URL.'/deals.php');
}
?>
<!doctype html><html><head><meta charset="utf-8"><title>Add Deal</title><link rel="stylesheet" href="<?= e(APP_URL) ?>/assets/css/style.css"></head><body><?php include __DIR__.'/partials_header.php'; ?><div class="wrap"><div class="formbox"><h2>add deal</h2><?php if($m=flash('error')):?><div class="alert error"><?= e($m) ?></div><?php endif; ?><form method="post"><label>title</label><input name="title" required><label>county</label><select name="county_id"><option value="">county</option><?php foreach($counties as $c):?><option value="<?= e($c['id']) ?>"><?= e($c['name']) ?></option><?php endforeach;?></select><label>category</label><select name="category_id"><option value="">category</option><?php foreach($categories as $c):?><option value="<?= e($c['id']) ?>"><?= e($c['name']) ?></option><?php endforeach;?></select><label>location</label><input name="location"><label>price</label><input name="price"><label>public summary optional</label><textarea name="public_summary"></textarea><label>full details</label><textarea name="full_details" required></textarea><label>unlock fee blank = recommended</label><input name="unlock_fee" placeholder="Leave blank"><label>status</label><select name="status"><option>pending</option><option>published</option><option>rejected</option><option>expired</option><option>flagged</option></select><label>verification</label><select name="verification_status"><option value="unverified">unverified</option><option value="basic_checked">basic_checked</option><option value="verified">verified</option><option value="suspicious">suspicious</option></select><button class="button green">save</button></form></div></div></body></html>