'First',2=>'Second',3=>'Third',4=>'Fourth',-1=>'Last',-2=>'2nd Last',-3=>'3rd Last']; $cat = ["unknown", "User Group Event", "Conference", "Training"]; $type = [1=>'single',2=>'multi',3=>'recur']; head("event administration"); db_connect(); $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : false; $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : false; $in = isset($_REQUEST['in']) ? $_REQUEST['in'] : false; $begin = isset($_REQUEST['begin']) ? $_REQUEST['begin'] : false; $max = isset($_REQUEST['max']) ? $_REQUEST['max'] : false; $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : false; $order = isset($_REQUEST['order']) ? $_REQUEST['order'] : false; $full = isset($_REQUEST['full']) ? $_REQUEST['full'] : false; $unapproved = isset($_REQUEST['unapproved']) ? $_REQUEST['unapproved'] : false; if($id) $id = (int)$id; if ($id && $action) { switch ($action) { case 'approve': if (db_query_safe("UPDATE phpcal SET approved=1,app_by=? WHERE id=?", [$cuser, $id]) && mysql_affected_rows()) { $event = fetch_event($id); $message = "This event has been approved. It will appear on the PHP website shortly."; if ($event['email']) mail($event['email'],"Event #$id Approved: $event[sdesc]",$message,"From: PHP Webmasters ", "-fnoreply@php.net -O DeliveryMode=b"); warn("record $id approved"); } else { warn("wasn't able to approve id $id."); } break; case 'reject': $event = fetch_event($id); if (db_query_safe("DELETE FROM phpcal WHERE id=?", [$id]) && mysql_affected_rows()) { $message = $event['approved'] ? "This event has been deleted." : "This event has been rejected."; $did = $event['approved'] ? 'Deleted' : 'Rejected'; if ($event['email']) mail($event['email'],"Event #$id $did: $event[sdesc]",$message,"From: PHP Webmasters ", "-fnoreply@php.net -O DeliveryMode=b"); warn("record $id ".strtolower($did)); unset($id); } else { warn("wasn't able to delete id $id."); } break; default: warn("that action ('".html_entity_decode($action,ENT_QUOTES)."') is not understood."); } } if ($id && $in) { $tipo = array_search($in['type'],$type); if ($in['sday'] && $in['smonth'] && $in['syear']) $sdato = "$in[syear]-$in[smonth]-$in[sday]"; if ($in['eday'] && $in['emonth'] && $in['eyear']) $edato = "$in[eyear]-$in[emonth]-$in[eday]"; if ($in['recur'] && $in['recur_day']) $recur = "$in[recur]:$in[recur_day]"; $query = new Query('UPDATE phpcal SET '); if ($sdato) { $query->add('sdato=?, ', [$sdato]); } if ($edato) { $query->add('edato=?, ', [$edato]); } if ($recur) { $query->add('recur=?, ', [$recur]); } $query->add( "tipo=?, ldesc=?, sdesc=?, email=?, url=?, country=?, category=? WHERE id=?", [$tipo, $in['ldesc'], $in['sdesc'], $in['email'], $in['url'], $in['country'], $in['category'], $id] ); db_query($query); warn("record $id updated"); unset($id); } if ($id && !$in) { $in = fetch_event($id); if (!$in) { unset($id); } else { @list($in['syear'],$in['smonth'],$in['sday']) = @explode("-",$in['sdato']); @list($in['eyear'],$in['emonth'],$in['eday']) = @explode("-",$in['edato']); @list($in['recur'],$in['recur_day']) = @explode(':',$in['recur']); $in['type'] = $type[$in['tipo']]; } } elseif ($in) { foreach ($in as $k => $v) { $in[$k] = $v; } } if ($id) { ?>
Start Date " /> />
End Date " /> />
OR
Recurring
/>
Short
Description
Country
Event Category
Email
URL
Long Description
see upcoming events | ">see unapproved events
add(' WHERE MATCH(sdesc,ldesc,email) AGAINST (?)', [$search]); } elseif ($unapproved) { $searchby->add(' WHERE NOT approved'); } else { $searchby->add(' WHERE NOT (tipo = 1 AND sdato < NOW()) AND NOT (tipo = 2 AND edato < NOW())'); } $query = new Query("SELECT COUNT(id) FROM phpcal"); $query->addQuery($searchby); $res = db_query($query); $total = (int)mysql_result($res,0); $query = new Query("SELECT phpcal.*,country.name AS cname FROM phpcal LEFT JOIN country ON phpcal.country = country.id"); $query->addQuery($searchby); if ($order) { if (!in_array($order, ['sdato', 'sdesc', 'email', 'country', 'category'], true)) { $order = 'sdato'; } if ($forward) { $ext = "ASC"; } else { $ext = "DESC"; } // Safe because we checked that $order is part of a fixed set. $query->add(" ORDER BY $order $ext"); } $query->add(' LIMIT ?int, ?int', [$begin, $max]); $res = db_query($query); $extra = [ "search" => $search, "order" => $order, "begin" => $begin, "max" => $max, "full" => $full, "unapproved" => $unapproved, "forward" => $forward, ]; show_prev_next($begin,mysql_num_rows($res),$max,$total,$extra); ?>
$full ? 0 : 1]);?>"> "sdato"]);?>">date "sdesc"]);?>">summary "email"]);?>">email "country"]);?>">country "category"]);?>">category
">edit