<?php

/* Part of the codes are modified from https://github.com/jonsuh/jQuery-Ajax-Call-to-PHP-Script-with-JSON-Return */
/* 安全性,檢查是否為 AJAX、是否為 POST 方法,並檢查 $action 是否正確*/
if (is_ajax()) {
    if (isset($_POST["action"]) && !empty($_POST["action"])) {
        //Checks if action value exists
        $action = $_POST["action"];
        switch ($action) {
            //Switch case for value of action
            case "action_add":
                add_job();
                break;
            case "action_delete":
                delete_job();
                break;
        }
    }
}
//Function to check if the request is an AJAX request
function is_ajax()
{
    return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
/*
  Return the HTML content of the URL, return false if 404.
  e.g. https://www.ptt.cc/bbs/not_exist_board/not_exist_page.html is not valid
*/
function get_url_content($url)
{
    $handle = curl_init($url);
Exemple #2
0
    } else {
        $action = 'list_jobs';
    }
}
$categories = get_categories();
$message = "";
// LIST JOBS
if ($action == 'list_jobs') {
    // TO DO
    $jobs = get_jobs();
    include 'list_jobs.php';
} else {
    if ($action == 'delete_job') {
        // TO DO
        $job_id = $_POST['job_id'];
        delete_job($job_id);
        $jobs = get_jobs();
        include 'list_jobs.php';
    } else {
        if ($action == 'add_job') {
            include 'edit_job.php';
        } else {
            if ($action == 'edit_job') {
                // TO DO
                // GET ALL FIELD VALUES FOR JOB BASED ON JOB ID
                $job_id = $_POST['jobID'];
                $job_title = $_POST['jobTitle'];
                $job_category = $_POST['catID'];
                $job_type = $_POST['jobType'];
                $job_city = $_POST['city'];
                $job_state = $_POST['state'];
Exemple #3
0
function delete_job_action($session_uid, $id)
{
    //check if the user is admin
    if (user_is_admin($session_uid)) {
        delete_job($id);
        // Redirect browser
        header("Location: http://" . $_SERVER['SERVER_NAME'] . "/jobs");
        // Make sure that code below does not get executed when we redirect
        exit;
    } else {
        require 'templates/login.php';
    }
}