true, 'resize_over_bytes' => mbToBytes(setting('forum_image_resize_threshold_mb','1'), 1), 'image_max_width' => (int)setting('forum_image_max_width','1600'), 'image_quality' => (int)setting('forum_image_quality','82'), ] ); if (!$upload['ok']) { flash($upload['error'], 'error'); go('/admin/events.php'.($id ? '?edit='.$id : '')); } if (!empty($upload['path'])) $imagePath = (string)$upload['path']; $f=['title'=>ps('title'),'description'=>ps('description'),'venue'=>ps('venue'),'address'=>ps('address'), 'event_date'=>ps('event_date'),'event_time'=>ps('event_time'),'end_date'=>ps('end_date')?:null, 'end_time'=>ps('end_time'),'cost'=>ps('cost'),'website'=>ps('website'),'contact_name'=>ps('contact_name'), 'contact_email'=>ps('contact_email'),'contact_phone'=>ps('contact_phone'),'image_path'=>$imagePath, 'status'=>p('status','approved'),'is_featured'=>(int)p('is_featured',0)]; if (!$f['title'] || !$f['event_date']) { flash('Title and date required.','error'); go('/admin/events.php'); } if ($act === 'add') { qrun("INSERT INTO events(title,description,venue,address,event_date,event_time,end_date,end_time,cost,website,contact_name,contact_email,contact_phone,image_path,status,is_featured,submitted_by)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",array_merge(array_values($f),[uid()])); flash('Event added!','success'); } else { qrun("UPDATE events SET title=?,description=?,venue=?,address=?,event_date=?,event_time=?,end_date=?,end_time=?,cost=?,website=?,contact_name=?,contact_email=?,contact_phone=?,image_path=?,status=?,is_featured=? WHERE id=?",array_merge(array_values($f),[$id])); flash('Event updated!','success'); } go('/admin/events.php'); } } $filter = gs('filter') ?: 'all'; $editId = iget('edit'); $editing = $editId ? qone("SELECT * FROM events WHERE id=?",[$editId]) : null; $where = match($filter) { 'pending'=>"WHERE status='pending'",'approved'=>"WHERE status='approved'", default=>"" }; $events = qall("SELECT e.*,u.username FROM events e LEFT JOIN users u ON u.id=e.submitted_by $where ORDER BY CASE status WHEN 'pending' THEN 0 ELSE 1 END,event_date DESC"); include __DIR__.'/admin_header.php'; ?>
| TITLE | DATE | SUBMITTED BY | STATUS | FEATURED | ACTIONS |
|---|---|---|---|---|---|
| =fdate($ev['event_date'])?> | =e($ev['username']??'Admin')?> | 'badge-green','pending'=>'badge-gold','rejected'=>'badge-red']; ?>">=strtoupper($ev['status'])?> | =$ev['is_featured']?'★':'—'?> |