function createApplicationPDF($user_id, $application_id, $targetDirectory) { $user_id = escape($user_id); $application_id = escape($application_id); //first verify that application belongs to user and has not been submitted yet $checkArray = checkApplication($user_id, $application_id, true); if ($checkArray[0] == -2 || $checkArray[0] == -1) { return array(FALSE, "verification failure"); } $club_id = $checkArray[1]; //get application fields if ($club_id == 0) { $result = mysql_query("SELECT baseapp.varname, baseapp.vardesc, baseapp.vartype, profiles.val, 0 AS sort_col, baseapp.orderId AS sort2_col FROM profiles, baseapp WHERE profiles.user_id = '{$user_id}' AND profiles.var_id = baseapp.id UNION ALL SELECT baseapp.varname, baseapp.vardesc, baseapp.vartype, answers.val, basecat.orderId AS sort_col, baseapp.orderId AS sort2_col FROM answers, baseapp, basecat WHERE answers.application_id = '{$application_id}' AND baseapp.id = answers.var_id AND basecat.id = baseapp.category ORDER BY sort_col, sort2_col"); $sectionheader = "General Application"; } else { $result = mysql_query("SELECT supplements.varname, supplements.vardesc, supplements.vartype, answers.val FROM answers, supplements WHERE answers.application_id = '{$application_id}' AND supplements.id = answers.var_id ORDER BY supplements.orderId"); $clubInfo = clubInfo($club_id); //array (club name, club description, open_time, close_time, num_recommendations) $sectionheader = "Supplement: " . $clubInfo[0]; } $userInfo = getUserInformation($user_id); //array(username, email, name) return generatePDFByResult($result, $targetDirectory, latexSpecialChars($sectionheader), "User ID: " . latexSpecialChars($user_id) . "\\\\" . latexSpecialChars($userInfo[2])); }
<?php include "../include/common.php"; include "../config.php"; include "../include/db_connect.php"; include "../include/session.php"; include "../include/apply_gen.php"; if (isset($_SESSION['user_id'])) { if (isset($_REQUEST['app_id']) && isset($_REQUEST['club_id'])) { $club_id = $_REQUEST['club_id']; $app_id = $_REQUEST['app_id']; $clubInfo = clubInfo($club_id); //passed to page, and also used to validate ownership of application $checkStatus = checkApplication($_SESSION['user_id'], $app_id); if ($checkStatus != -2) { get_page_advanced("club_detail", "apply", array("club_id" => $club_id, "app_id" => $app_id, "clubInfo" => $clubInfo, 'checkStatus' => $checkStatus)); } else { get_page_advanced("message", "apply", array("title" => "Internal error", "message" => "Internal error: application does not appear to belong to the requesting user.")); } } else { get_page_advanced("message", "apply", array("title" => "Internal error", "message" => "Internal error: app_id or club_id unspecified.")); } } else { get_page_advanced("message", "apply", array("title" => "Not Logged In", "message" => "You cannot access the application because you are not logged in. Please <a href=\"../login.php\">login first</a>.")); }
$inform["error"] = "{$club_name} is not open yet! Try again after the open date!"; } } } } } } } } } $clubsSubscribed = listSubscriptions($_SESSION['user_id']); $clubsApplied = getUserClubsApplied($_SESSION['user_id']); //matrix maps from club id to array(subscribed?, applystate, applyinfo, clubinfo) $clubsArray = array(); foreach ($clubsSubscribed as $club_id) { $clubsArray[$club_id] = array(true, false, false, false); } foreach ($clubsApplied as $club) { if (!isset($clubsArray[$club[0]])) { $clubsArray[$club[0]] = array(false, false, false, false); } $clubsArray[$club[0]][1] = checkApplication($_SESSION['user_id'], $club[3]); $clubsArray[$club[0]][2] = $club; } foreach (array_keys($clubsArray) as $club_id) { $clubsArray[$club_id][3] = clubInfo($club_id); } get_page_advanced("clubs", "apply", array("clubs" => $clubsArray, "inform" => $inform)); } else { get_page_advanced("message", "apply", array("title" => "Not Logged In", "message" => "You cannot access the application because you are not logged in. Please <a href=\"../login.php\">login first</a>.", "redirect" => "../login.php")); }
$inform["detail"] = $result; } } else { echo $_REQUEST['action'] . "<br />"; } } if ($applicationId !== FALSE) { $inform["info"] = "Be sure to save often!"; if ($_REQUEST['club_id'] == 0) { if (isset($_REQUEST['cat_id'])) { $cat_name = getCategory($_REQUEST['cat_id']); $title = "General Application > {$cat_name}"; get_page_advanced("app", "apply", array("user_id" => $_SESSION['user_id'], "app_id" => $applicationId, "club_id" => $_REQUEST['club_id'], "cat_id" => $_REQUEST['cat_id'], "action" => "view", "title" => $title, "inform" => $inform)); } else { get_page_advanced("message", "apply", array("title" => "Internal error", "message" => "Internal error: application not found.")); } } else { $club_data = clubInfo($_REQUEST['club_id']); $club_name = $club_data[0]; $title = "Supplement > {$club_name}"; get_page_advanced("app", "apply", array("user_id" => $_SESSION['user_id'], "app_id" => $applicationId, "club_id" => $_REQUEST['club_id'], "title" => $title, "inform" => $inform)); } } else { get_page_advanced("message", "apply", array("title" => "Internal error", "message" => "Internal error: application not found.")); } } else { get_page_advanced("message", "apply", array("title" => "Internal error", "message" => "Internal error: club ID or action not specified.")); } } else { get_page_advanced("message", "apply", array("title" => "Not Logged In", "message" => "You cannot access the application because you are not logged in. Please <a href=\"../login.php\">login first</a>.")); }
</table> </form> <h3>Completed</h3> <table> <tr> <th>Club Name</th> <th>Submit Time</th> <th>Finalized Time</th> <th>Status</th> <th>Amount</th> </tr> <? while($row = mysql_fetch_array($completed)) { ?> <tr> <td><? $club_detail = clubInfo($row['club_id']); echo $club_detail[0]; ?></td> <td><?php echo date('m/d/y H:i', $row['submit_time']); ?> </td> <td><? if($row['status'] <= -1) echo date('m/d/y H:i:s', $row['status_time']); ?></td> <td><?php echo getPurchaseStatusString($row['status']); ?> </td> <td><?php echo $row['amount']; ?> </td> </tr> <? } ?>
<?php include "include/common.php"; include "config.php"; include "include/db_connect.php"; include "include/session.php"; include "include/apply_submit.php"; if (isset($_REQUEST['id'])) { $clubInfo = clubInfo($_REQUEST['id']); get_page('affclubs_info', array('clubInfo' => $clubInfo)); } else { $clubList = listClubs(true); get_page('affclubs', array('clubList' => $clubList)); }