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)); } } }
function userCompanyToUserIndustry($user) { $companies = json_decode(getCompanies($user)); $companyIds = $companies->{'ids'}; }
<?php switch ($_POST['API']) { case 1: getCompanies(); break; case 2: getDepartments($_POST['company']); break; case 3: getCourses($_POST['company'], $_POST['department']); break; case 4: getXMLs($_POST['company'], $_POST['department'], $_POST['course']); break; case 5: downloadXML($_POST['company'], $_POST['department'], $_POST['course'], $_POST['xmlname']); break; default: break; } function getCompanies() { $dir = @opendir("CaptivateResults"); if ($dir != "") { while (($file = readdir($dir)) !== false) { if (!is_file($file)) { echo $file . ";"; } } closedir($dir);
function controller_free_companies_index() { $data = getCompanies(); //переписать! view_companies($data); }
$resp = curl_exec($curl); echo $resp . "<br>"; curl_close($curl); } ?> <form method="post" action="" name="helpDeskRecords"> <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ? $_REQUEST['page'] : 1; ?> " id="page"> <input type="hidden" name="print" value="0" id="print"> <div class='filters'> <label>Company: </label> <select name='item_company_id' onchange="showDepartments(this.value,'')"><option value="">-SELECT-</option> <?php $company_list = getCompanies(); foreach ($company_list as $comp) { $comp_sel = $comp['company_id'] == $_POST['item_company_id'] ? "selected='selected'" : ""; echo "<option value='{$comp['company_id']}' {$comp_sel}>{$comp['company_name']}</option>"; } ?> </select> <label>Create Date From: </label> <input name='date_from' type='text' value="<?php echo $_POST['date_from']; ?> " autocomplete='off'> <label>Create Date Till: </label> <input name='date_till' type='text' value="<?php echo $_POST['date_till']; ?>
{ global $companyList; $limit_start = $counter; $limit_stop = $counter + 20; $conn = db_connect(); $conn->set_charset("utf8"); // 指定数据库字符编码 $result = $conn->query("select id, name, logo, comments_number, score from decoration_company where 1=1 LIMIT {$limit_start}, {$limit_stop} "); if (!$result) { throw new Exception('Search user score failed.'); } $num_result = $result->num_rows; $companyList['total'] = $num_result; //数据库查询出来的字段全部是字符串,另外json定义跟数据库定义可能不一致,所以需要做相应地转换 for ($i = 0; $i < $num_result; $i++) { $row_db = $result->fetch_assoc(); $converted_row = array(); //保存转换后的单条记录 $converted_row['id'] = intval(stripslashes($row_db['id'])); $converted_row['name'] = stripslashes($row_db['name']); $converted_row['logo'] = stripslashes($row_db['logo']); $converted_row['comments'] = intval(stripslashes($row_db['comments_number'])); $converted_row['score'] = intval(stripslashes($row_db['score'])); $companyList["row"][$i] = $converted_row; } $result->free(); $conn->close(); return json_encode($companyList); } $jsonStr = getCompanies($param_counter); print "{$jsonStr}";