function parseInputs($user) { if (isset($_POST['func'])) { $func = $_POST['func']; // getters =============================== if ($func === "getGoals") { echo json_encode(getGoals($user)); } if ($func === "getIndustries") { echo json_encode(getIndustries($user)); } if ($func === "getLocations") { echo json_encode(getLocations($user)); } if ($func === "getPostings") { getPostings($user); } if ($func === "getContacts") { echo json_encode(getContacts($user)); } if ($func === "getSchedules") { echo json_encode(getSchedules($user)); } if ($func === "getCompanies") { echo getCompanies($user); } if ($func === "getBlogId") { echo json_encode(getBlogId($user, $_POST['title'], $_POST['text'])); } if ($func === "getBlog") { echo json_encode(getBlog($user)); } if ($func === "getNotesOnPosting") { $postingId = $_POST['postingId']; echo json_encode(getNotesOnPosting($user, $postingId)); } // inserters =============================== if ($func === "insertGoal") { if (isset($_POST["goal"]) && $_POST["goal"] !== '') { echo json_encode(insertGoal($user, $_POST["goal"])); } } if ($func === "insertIndustry") { if (isset($_POST["industry"]) && $_POST["industry"] !== '') { echo json_encode(insertIndustry($user, $_POST["industry"])); } } if ($func === "insertCompany") { $url = urldecode($_POST["url"]); $companyName = $_POST["company"]; insertCompany($user, $companyName); } if ($func === "insertLocation") { if (isset($_POST["location"]) && $_POST["location"] !== '') { echo json_encode(insertLocation($user, $_POST["location"])); } } if ($func === "insertPosting") { echo json_encode(insertPosting($user)); } if ($func === "insertContact") { // more complex. will be responsible for getting $_POST echo json_encode(insertContact($user)); } if ($func === "insertSchedule") { // more complex. will be responsible for getting $_POST // echo json_encode(insertSchedule($user)); echo insertSchedule($user); } if ($func === "addSchedule") { // more complex. will be responsible for getting $_POST // echo json_encode(insertSchedule($user)); // echo "adding ZSchecdule"; $name = $_POST["name"]; $description = $_POST["description"]; $contact = $_POST["contact"]; $start = $_POST["start"]; $end = $_POST["end"]; // addSchedule($name,$description,$contact,$start,$end) if (addSchedule($name, $description, $contact, $start, $end)) { $scheduleId = getScheduleId($name, $description, $contact, $start, $end); if ($scheduleId > 0) { // echo $scheduleId; // insert schedule id and user id to user_schedule $query = "insert into user_schedule "; $query .= "(user,schedule) "; $query .= "values ( {$user}, "; $query .= "{$scheduleId} ) "; //return $query; echo booleanEcho($query); } else { echo "error getting schedule id."; } } else { echo "error inserting schedule."; } } if ($func === "insertBlog") { echo json_encode(insertBlog($user)); } if ($func === "insertNotesPostingUser") { // insertBlog, then insertNotesPostingUser $noteId = insertBlog($user); // $noteId = $_POST["noteId"]; $postingId = $_POST["postingId"]; echo json_encode(insertNotesPostingUser($noteId, $postingId, $user)); } // removers =============================== if ($func === "removeGoal") { // url is the id for user_goals if (isset($_POST["url"]) && $_POST["url"] !== '') { echo json_encode(removeGoal($user, $_POST["url"])); } } if ($func === "removeIndustry") { // url is the id for user_industries if (isset($_POST["url"]) && $_POST["url"] !== '') { echo json_encode(removeIndustry($user, $_POST["url"])); } } if ($func === "removeLocation") { // url is the id for locations if (isset($_POST["url"]) && $_POST["url"] !== '') { echo json_encode(removeLocation($user, $_POST["url"])); } } if ($func === "removeContact") { // url is the id for user_contacts if (isset($_POST["url"]) && $_POST["url"] !== '') { echo json_encode(removeUserContact($user, $_POST["url"])); } } if ($func === "removePosting") { if (isset($_POST["url"]) && $_POST["url"] !== '') { removePosting($user, $_POST["url"]); } } if ($func === "removeCompany") { $companyId = $_POST["url"]; // companyID is stored here removeCompany($user, $companyId); } if ($func === "removeSchedule") { $scheduleId = $_POST["url"]; // scheduleID is stored here echo json_encode(removeSchedule($user, $scheduleId)); } if ($func === "removeBlog") { $userNoteId = $_POST["url"]; // need to get noteId from userNoteId $noteId = getNoteIdFromUserNoteId($userNoteId); if (removeNoteUser($user, $userNoteId) === true) { if (removeNote($noteId) === true) { echo json_encode(true); } else { echo json_encode("Error removing from notes."); } } else { echo json_encode("Error removing from NoteUser."); } } // updaters =============================== if ($func === "updateGoal") { echo json_encode(updateGoal($user)); } if ($func === "updateIndustry") { echo json_encode(updateIndustry($user)); } if ($func === "updatePosting") { updatePosting($user); // returns on its own } if ($func === "updateContact") { echo json_encode(updateContact($user)); } } }
$tpl->SetVar('groups', $groupList); $tpl->SetVar('paging', count($groupList) / 20); $tpl->SetVar('matchId', $matchId); echo '<h2>' . '对阵图设置' . '</h2>'; echo $tpl->GetTemplate('matchschedule.php'); break; case 'addschedule': $ngid = intval($_REQUEST['ngid']); $sgid = intval($_REQUEST['sgid']); $round = trim($_REQUEST['round']); $begin = trim($_REQUEST['begin']); $end = trim($_REQUEST['end']); $result = trim($_REQUEST['result']); $rid = intval($_REQUEST['rid']); $matchId = intval($_REQUEST['matchid']); $succe = addSchedule($ngid, $sgid, $matchId, $rid, $round, $begin, $end, $result); if ($succe != 1) { echo "添加队伍对阵图失败"; return; } echo "添加队伍对阵图成功"; break; // Del Schedule // Del Schedule case 'delschedule': $id = intval($_REQUEST['id']); $succe = delSchedule($id); if ($succe != 1) { echo "删除队伍对阵图:" . ngid . "失败"; return; }
$shift = $_POST['updShift']; $time = $_POST['updTime']; $id = $_POST['ID']; updateSchedule($shift, $time, $id); } elseif (isset($_POST['updFeature'])) { $feature = $_POST['updFeature']; $id = $_POST['featureID']; updateFeature($feature, $id); } elseif (isset($_POST['advantageID'])) { $id = $_POST['advantageID']; $adv = $_POST['updAdvantage']; updateAdvantage($adv, $id); } elseif (isset($_POST['addNewShift'])) { $shift = $_POST['addNewShift']; $time = $_POST['addNewTime']; addSchedule($shift, $time); $id = getScheduleID($shift, $time); echo $id; } elseif (isset($_POST['scheduleID'])) { $id = $_POST['scheduleID']; deleteSchedule($id); } elseif (isset($_POST['addNewFeature'])) { $desc = $_POST['addNewFeature']; addFeature($desc); $id = getFeatureID($desc); echo $id; } elseif (isset($_POST['featureID'])) { $id = $_POST['featureID']; deleteFeature($id); } elseif (isset($_POST['addNewAdvantage'])) { $advantage = $_POST['addNewAdvantage'];
<?php $input = "CarleenLewis,,,6106,3117,6106,6106\nJaredHuisingh,,,6111,6104,6104,6111\nBethLove,,,4104,4104,4104,4104\nValarieMills,,,6103,6103,6103,6103\nJenniferPace,,,4116,4116,4116,4116\nPaigeWalker,,4115,,4115,4106,4115\nJohnSides,,,4206,4206,4204,\nAllisonWalker,,6111,,6112,6111,6104\nAmandaWash,,,6113,6113,6113,\nMichelleWeller,6115,6115,,6115,,6115\nTerryDisney,,6106,4202,,4202,4202\nJenniferGalloway,,4112,4108,4112,,4108\nKeithGalloway,,4104,4103,5105,,4103\nJakeGulledge,,4205,4205,4205,,4205\nLoriHarder,,6110,6110,,6110,6110\nEmilyHarmon,,4203,4203,,4203,4203\nDorothyLee,,4202,4208,4202,,4208\nTealMcInturff,,4110,4114,,4114,4114\nJoeMichalski,,6103,4214,4214,,\nRachelO'Connor,,5102,5102,,5102,\nGerriParker,,4212,,4212,4212,4212\nShellyPatton,4214,4214,,4203,,4216\nKateRussell,,,4112,4114,4112,4112\nTeresaSon,4114,4114,4216,,,\nRobertWright,6112,6112,6112,,,6112\nNancyBusch,,5105,6211,,6211,6211\nRudyFurman,,4112,5205,,,\nAslynnHalverson,,6207,6212,,6207,6214\nMichaelHartman,,,6207,6208,6208,\nLisaJacobs,6214,6214,,6214,,6212\nArbyDickert,,6211,6214,6211,,6214\nMichaelKnapp,6213,6213,,6213,,5102\nKerriMiralles,,,6205,6209,6209,6209\nCalebPaquette,,6212,6210,6212,,6210\nSarahPrice,,6210,6209,,,\nTravisQuick,,6203,6203,,6203,6203\nYoungShim,,6205,,6205,6205,6205\nJamesSternberg,,6209,6202,,,6202\nVeronicaSussmane,,,6213,,6213,6213\nJohnTilson,,6208,6208,6203,,6208\nBryanBrown,4110,,4110,4110,,4110\nShaneChambers,,4116,4107,4116,,4106\nRebeccaFurman,,6108,,6108,6108,\nAndreaGuy,,6102,6101,,6101,6101\nMikeHicks,,,6108,6103,6103,6108\nSierraHuff,,6113,6113,6110,,6113\nDLKing,,,2112,2101,4104,2112\nCeliaMoorman,6114,6114,6114,,,6114\nLisaMyers,,,6115,6114,6114,6116\nMattPatillo,,4106,,4201,4106,4214\nSethRayman,,4108,4116,4108,,4206\nMikeRosenke,,4210,,1103,4210,4207\nHollyWilgus,,,4106,6106,6106,4115\nTreyWilliams,,,4210,4210,4214,4210\nMikeWise,,,4212,4115,,\nSandraAchenbach,,4105,4105,4105,,4105\nVeronicaCalderon-Speed,,,6109,6116,6116,6109\nCarlosLopez,,6116,6116,,6115,6116\nFrankChen,,4208,,4208,4208,4211\nEmilyFulgham,,,6102,6102,6102,6102\nAmandaDascomb,,,,6107,6107,\nBethHowe,,6107,6107,,6112,\nPeggyMelgaard,,6109,,6109,6109,6107\nSabineNebenfuehr,,,,,4105,\nAmandaBrown,,4209,4209,,4209,4209\nTammyDavis,,4215,,4215,5105,6116\nJimFriedrich,,,4215,5102,4215,4215\nGloriaPrice,,5106,5106,5106,5106,5106\nVivianWest,,4207,,4207,4207,\nJeffWilson,,,4211,4211,4211,4110\nChuckBrock,,2102,,2102,2102,2103\nAngelaDick,,5104,5104,,5104,5104\nBenEng,,,5103,5103,5103,5103\nPeggyJones,,2103,,2103,2103,2102\nAlexRector,,1106,2102,,2102,2102\nTeresaScoggins,,2112,,2112,2112,\nRobertWarren,2100,2101,2101,,,2101\nAndreCaballero,,,1100,1100,1103,1100\nRickCollett,,1100,,1102,1102,1106\nJeffHash,,1102,1102,,1100,1102\nWesJones,,2100,2100,,,2100\nPaulMaynard,,,2100,2100,2100,\nBrianneMcCroskey,,1100,1101,1101,,1101\nMitziMcCurry,,1103,1103,,1100,1103\nMarkPatterson,,1101,1100,1100,,1100\nMikePotter,,2100,,2100,2100,2100\nJeffBlack,,4107,,4107,4107,4107\nAmberHartman,,,5208,5208,5208,5208\nAmyMurrell,5205,5205,,5205,,4201\nDanaSherrell,,4201,4201,,5205,4201\nBeckySwann,,5208,,5206,5206,5206\nJoyBegnaud,,5206,5206,,4201,6207\nVanceBretz,,6212,4101,,6207,4101\nBethBuehler,,4101,4204,,6103,\nCoryMinzyk,,4216,4214,4216,,\nAnthonyDelisse,,6104,,4204,6114,\nKristeeGuy,,4106,,4101,4102,\nDonnaHenkel,,,4102,4102,4102,4102\nTerriHicks,,4103,4103,4103,,4102\nTimLee,,4109,4109,4109,4109,\nMalloryWoods,,4111,4111,4111,4111,4109\n"; require 'common.php'; $lines = explode("\r\n", $input); foreach ($lines as $key => $line) { $values = explode(",", $line); //create user echo $values[0]; $id = createUser($values[0]); echo "Created User: {$id}"; //add to schedule $nVals = count($values); for ($i = 1; $i < $nVals; $i++) { if ($values[$i]) { addSchedule($i - 1, $id, $values[$i]); } } } function createUser($TeacherName) { $dusername = "******"; $dpassword = "******"; $dbname = "hvcodecademy"; $school = "dbschool"; //TODO: what are we going to do with the school field? $host = "localhost"; //TODO: is this the correct host? //comunicates that we are using UTF-8 //stores wide varienty of special characters $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
function insertSchedule($user) { // should error check that all post fields are set $name = $_POST["name"]; $description = $_POST["description"]; $contact = $_POST["contact"]; $start = $_POST["start"]; $end = $_POST["end"]; // $name,$description,$contact,$start,$end // add to schedules if it doesnt' exist already /* if ( scheduleExists($name,$description,$contact,$start,$end) !== true) if ( addSchedule($name,$description,$contact,$start,$end) !== true ) return "error adding to schedules"; */ // return addSchedule($name,$description,$contact,$start,$end); if (addSchedule($name, $description, $contact, $start, $end)) { $scheduleId = getScheduleId($name, $description, $contact, $start, $end); return $scheduleId; $query = "insert into user_schedule "; $query .= "(user,schedule) "; $query .= "values ( {$user}, {$scheduleId}) "; booleanReturn($query); } else { return "error inserting schedule"; } // return "schedule id = " . $scheduleId; // add to user_schedules if it doesn't already exist /* if ( userScheduleExists($user,$scheduleId) !== true) { // return "schedule $scheduleId exists"; if ( addUserSchedule($user,$scheduleId) !== true ) return "error adding to user_schedules"; else return true; } else { return "existential problem. for $scheduleId"; } */ }
<?php include 'db_helper.php'; if ($_GET['f'] == 'add' && $_GET['p1'] && $_GET['p2'] && $_GET['p3'] && $_GET['p4']) { addSchedule($_GET['p1'], $_GET['p2'], $_GET['p3'], $_GET['p4']); } elseif ($_GET['f'] == 'get' && $_GET['p1']) { getSchedule($_GET['p1']); } elseif ($_GET['f'] == 'del' && $_GET['p1'] && $_GET['p2'] && $_GET['p3'] && $_GET['p4']) { deleteSchedule($_GET['p1'], $_GET['p2'], $_GET['p3'], $_GET['p4']); } function addSchedule($TID, $Day, $Start, $End) { $dbQuery = sprintf("INSERT INTO Schedule (TID,Day,Start,End) VALUES ('%d','%s','%d','%d')", $TID, mysql_real_escape_string($Day), $Start, $End); $result = getDBResultInserted($dbQuery, 'TID'); //header("Content-type: application/json"); echo json_encode($result); } function deleteSchedule($TID, $Day, $Start, $End) { $dbQuery = sprintf("DELETE from Schedule WHERE TID ='%d', Day='s%', Start='%d', End='%d'", $TID, mysql_real_escape_string($Day), $Start, $End); $result = getDBResultInserted($dbQuery, 'TID'); //header("Content-type: application/json"); echo json_encode($result); } function getSchedule($TID, $Day, $Start, $End) { $dbQuery = sprintf("SELECT * from Schedule WHERE TID ='%d'", $TID, mysql_real_escape_string($Day), $Start, $End); $result = getDBResultInserted($dbQuery, 'TID'); //header("Content-type: application/json"); echo json_encode($result); }
function submitAddSchedule() { $data = processScheduleInput(0); if ($id = addSchedule($data)) { $_POST["scheduleid"] = $id; $_SESSION['userresources'] = array(); editOrAddSchedule(0); } else { abort(10); } }