/** * Return data about the uploaded roster file. */ public static function get_roster_file() { $dh = opendir($GLOBALS['UPLOAD_DIR']); $roster_file_path = null; while (($name = readdir($dh)) !== false) { $path = $GLOBALS['UPLOAD_DIR'] . '/' . $name; if (is_file($path)) { $roster_file_path = $path; break; } } if (!$roster_file_path) { return false; } $info = array('name' => $name, 'size' => filesize($roster_file_path)); $info['uploader'] = new PSUPerson(PSUMeta::get($GLOBALS['META_WEBAPP'], 'roster_uploader')->value); $info['uploaded'] = PSUMeta::get($GLOBALS['META_WEBAPP'], 'roster_uploaded')->value; return $info; }
<?php /// /// Accept a file upload, deleting the old file. /// if (!is_uploaded_file($_FILES['roster']['tmp_name'])) { $_SESSION['errors'][] = 'That didn\'t look like an uploaded file.'; PSU::redirect($GLOBALS['BASE_URL']); } $dh = opendir($GLOBALS['UPLOAD_DIR']); // delete old file while (($file = readdir($dh)) !== false) { $path = $GLOBALS['UPLOAD_DIR'] . '/' . $file; if (is_file($path)) { unlink($path); break; } } PSUMeta::set('webapp_els', 'roster_uploader', $_SESSION['pidm']); PSUMeta::set('webapp_els', 'roster_filename', $_FILES['roster']['name']); PSUMeta::set('webapp_els', 'roster_uploaded', time()); $roster_path = $GLOBALS['UPLOAD_DIR'] . '/' . $_FILES['roster']['name']; move_uploaded_file($_FILES['roster']['tmp_name'], $roster_path); PSU::redirect($GLOBALS['BASE_URL']);
$app->populate('gatesystems', new TeacherCert\GateSystems()); // setup search default pref $wpid = $_SESSION['wp_id']; $meta = PSUMeta::get('teacher-cert', "search:{$wpid}:gs"); if ($meta) { $app->populate('search_default_gs', $meta->value); } }); // // Nothing specific requested; show list of gatesystems // respond('GET', '/', function ($request, $response, $app) { $app->tpl->display('index.tpl'); }); respond('POST', '/search', function ($request, $response, $app) { $gs_id = $request->param('gatesystem_id'); $q = $request->param('q'); $gate_system = new TeacherCert\GateSystem($gs_id); $wpid = $_SESSION['wp_id']; PSUMeta::set('teacher-cert', "search:{$wpid}:gs", $gate_system->id); $url = sprintf("%s/gate-system/%s/search?q=%s", $GLOBALS['BASE_URL'], $gate_system->slug, urlencode($q)); $response->redirect($url); }); with("/admin", __DIR__ . "/teacher-cert/admin.php"); with("/api", __DIR__ . "/teacher-cert/api.php"); with("/student-gate", __DIR__ . "/teacher-cert/student-gate.php"); with("/student-clinical-faculty", __DIR__ . "/teacher-cert/student-clinical-faculty.php"); with("/student-school", __DIR__ . "/teacher-cert/student-school.php"); with("/gate-system", __DIR__ . "/teacher-cert/gate-system.php"); with("/gate-systems", __DIR__ . "/teacher-cert/gate-systems.php"); with("/student", __DIR__ . "/teacher-cert/student.php");