示例#1
0
$roles = array('offices' => array('athteam' => array('athteam'), 'damage' => array('damagecontrol'), 'historians' => array('historian'), 'imss' => array('headimssrep', 'imssrep'), 'librarians' => array('librarian'), 'socteam' => array('socteam')), 'people' => array('arc' => array('arcrep'), 'boc' => array('bocrep'), 'bookie' => array('bookie'), 'crc' => array('crcrep'), 'pope' => array('pope'), 'president' => array('president'), 'secretary' => array('secretary'), 'treasurer' => array('treasurer'), 'vp' => array('vicepresident')), 'support' => array('healthad' => array('healthad'), 'ra-prime' => array('ra'), 'ucc-prime' => array('coheaducc', 'ucc')));
$order = 'ORDER BY `class`, `name`';
$president = 'President <*****@*****.**>';
$secretary = 'Secretary <*****@*****.**>';
$pdo = new PDO('sqlite:../hovselist.db');
$year = date('Y') + (date('n') >= 7);
if (array_key_exists('action', $_POST)) {
    header('HTTP/1.1 400 Bad Request');
    header('Status: 400 Bad Request');
    $content = '';
    $format = "`name` || ' ''' || SUBSTR(`class`, 3) || ' <' || `email` || '>'";
    $lists = array();
    try {
        switch ($_POST['action']) {
            case 'delete':
                $content = Mole::killMoleByUid($pdo, (int) $_POST['uid']);
                break;
            case 'gen_class':
                $result = $pdo->prepare(<<<EOF
SELECT `class`,
\t{$format}
FROM `moles`
WHERE `alley` <> 'Social'
\tAND `class` <> ''
\tAND `class` >= {$year}
\tAND `position` <> 'RA'
{$order}
EOF
);
                $result->execute();
                $rows = $result->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_GROUP);