<?php include "../config.php"; include "../include/common.php"; include "../include/db_connect.php"; include "../include/session.php"; include "../include/chk.php"; if (isset($_SESSION['root'])) { $pdfArray = false; if (isset($_REQUEST['delete'])) { checkExtraPDFs(true); } else { $pdfArray = checkExtraPDFs(); } get_page_advanced("check_pdf", "root", array('pdfArray' => $pdfArray)); } else { header('Location: index.php'); }
function submitApplication($user_id, $application_id, $do_submit = true) { $user_id = escape($user_id); $application_id = escape($application_id); //verify application belongs to user and hasn't been submitted $checkResult = checkApplication($user_id, $application_id, true); if ($checkResult[0] !== 0) { return "check failed"; } //verify that the user is not trying to submit the general application if ($checkResult[1] == 0) { return ""; } //verify that the application can be submitted at this time // (checkResult checks view_time, not open_time) if (!isAvailableWindow($checkResult[1], true)) { return "application cannot be submitted at this time"; } //verify that enough peer recommendations have been inputted; grab the filenames while we're at it $result = mysql_query("SELECT num_recommend FROM clubs WHERE id = '" . $checkResult[1] . "'"); $recommendResult = mysql_query("SELECT filename FROM recommendations WHERE user_id = '{$user_id}' AND status = '1'"); if ($row = mysql_fetch_array($result)) { if ($row[0] > mysql_num_rows($recommendResult)) { return "not enough peer recommendations"; } } else { return "internal error, club not found"; } $peerString = ""; while ($row = mysql_fetch_array($recommendResult)) { $peerString .= ":" . $row[0]; } //create supplement PDF $createSupplementResult = createApplicationPDF($user_id, $application_id, "../submit/"); if ($createSupplementResult[0] === FALSE) { //true is success, string is error message return $createSupplementResult[1]; } //create general application PDF $gen_app_id = getApplicationByUserClub($user_id, 0); $createGeneralResult = createApplicationPDF($user_id, $gen_app_id, "../submit/"); if ($createGeneralResult[0] === FALSE) { //true is success, string is error message return $createGeneralResult[1]; } //update database if ($do_submit) { $submitName = escape($createGeneralResult[1] . ":" . $createSupplementResult[1] . $peerString); //handle files $result = mysql_query("SELECT val FROM answers WHERE application_id = '{$application_id}' AND val LIKE 'file:%'"); while ($row = mysql_fetch_array($result)) { $fileParts = explode(":", $row[0], 3); $submitName .= escape(":*" . $fileParts[1] . "," . $fileParts[2]); //:*file_id,filename } $result = mysql_query("SELECT val FROM answers WHERE application_id = '{$gen_app_id}' AND val LIKE 'file:%'"); while ($row = mysql_fetch_array($result)) { $fileParts = explode(":", $row[0], 3); $submitName .= escape(":*" . $fileParts[1] . "," . $fileParts[2]); //:*file_id,filename } mysql_query("UPDATE applications SET submitted='{$submitName}' WHERE id='{$application_id}' AND user_id='{$user_id}'"); } //some maintenance include includePath() . "/chk.php"; checkExtraPDFs(true, true); //delete old, extra PDFs return array($createGeneralResult[1], $createSupplementResult[1]); }