require __DIR__.'/panel/config.php';
if($_SERVER['REQUEST_METHOD']==='POST'){
$d=read_data(); $d['reviews']=$d['reviews']??[];
$name=trim($_POST['name']??''); $company=trim($_POST['company']??''); $comment=trim($_POST['comment']??''); $rating=max(1,min(5,(int)($_POST['rating']??5)));
if($name!=='' && $comment!==''){
$d['reviews'][]=['id'=>bin2hex(random_bytes(8)),'name'=>$name,'company'=>$company,'rating'=>$rating,'comment'=>$comment,'approved'=>false,'date'=>date('Y-m-d')];
write_data($d);
}
}
header('Location:/musteri-yorumlari?durum=alindi'); exit;
?>