コード例 #1
0
 public function ajax_players($id = null)
 {
     if (!$this->xhr) {
         Error403();
     }
     $server = self::load_gameserver($id);
     $this->assign("server", $server);
     $this->render("gameserver/_players.tpl", true);
 }
コード例 #2
0
 public function process($id = null)
 {
     if ($_GET['key'] == md5("winbarmint")) {
         if (!$id) {
             $id = mysql_real_escape_string($_GET['id']);
         }
         $topup = Topup::find_by_id($id);
         if ($topup) {
             $topup->processed = true;
             if ($topup->save()) {
                 echo "OK";
             } else {
                 echo "Fail";
             }
             die;
         } else {
             Error404();
         }
     } else {
         Error403();
     }
 }
コード例 #3
0
 public function intranet_index($permalink = null)
 {
     global $config;
     if (!in_array(Site::RemoteIP(), $config['intranet']['ips'])) {
         //throw new Error403();
     }
     $event = self::load_event($permalink, true);
     if ($_GET['key'] == md5("winbarmint")) {
         $event_id = mysql_real_escape_string($event->id);
         $signups = EventSignup::find_all("event_signups.event_id = '{$event_id}' AND event_signups.paid = true AND event_signups.voucher = false", "users.id ASC");
         $this->assign("signups", $signups);
         $this->assign("event", $event);
         header('Content-Type: text/xml');
         $this->render("event_signup/intranet_index.tpl", true);
     } else {
         Error403();
     }
 }
コード例 #4
0
ファイル: index.php プロジェクト: iantidy/rest-api
/**
 * Function to Process GET Requests
 * @global string $resRoot
 * @global string $resServer
 * @global string $resType
 * @global class array $db_tables
 * @global class array $db_conn
 * @global class $api
 * @param string $input_data
 */
function processGET($input_data)
{
    global $resRoot, $resServer, $resType, $db_tables, $db_conn, $api, $req_url;
    // Get Directory - Includes Token as first parameter
    $dir = explode("/", $input_data);
    // Clean up array
    $tmp = array();
    foreach ($dir as $item) {
        if (strlen($item) > 0) {
            $tmp[] = $item;
        }
    }
    $dir = $tmp;
    $tmp = NULL;
    // If API Key is true then the first element must be the API Key
    $api_key = 'public';
    $item_key = 0;
    // Used to keep track of the array items
    if ($api->getUseAPIKey()) {
        $api_key = $dir[$item_key];
        $valid = testAPIKey($api_key);
        if (!$valid) {
            exit(Error403($input_data));
        }
        $item_key++;
    }
    //  If only API Key then show list of Connections
    $conID = -9999;
    $resConn = new DB_Connection();
    if ($item_key + 1 > count($dir)) {
        // Return a List of Connections
        $resData = array();
        $resCount = 0;
        foreach ($db_conn as $conn) {
            $resData[] = array("type" => "resource", "value" => $conn->getName(), "description" => $conn->getDesc(), "link" => $resServer . "/" . $conn->getName(), "id" => $conn->getID());
            $resCount++;
        }
        showResults($resServer, $req_url, $resCount, $resData, $resType);
        exit;
    } else {
        // Check that the Connection is Valid
        $resData = array();
        $resCount = 0;
        foreach ($db_conn as $conn) {
            if (strtolower($dir[$item_key]) == strtolower($conn->getName())) {
                $conID = $conn->getID();
                $resConn = $conn;
                break;
            }
            // Get List just in-case needed
            $resData[] = array("type" => "resource", "value" => $conn->getName(), "description" => $conn->getDesc(), "link" => $resServer . "/" . $conn->getName(), "id" => $conn->getID());
            $resCount++;
        }
        // If Connection isn't found
        if ($conID === -9999) {
            showResults($resServer, $req_url, $resCount, $resData, $resType);
            exit;
        }
        // Increment Item Key
        $item_key++;
    }
    // Check if table is listed and valid
    $tblID = -9999;
    $resTable = new PublishTable();
    if ($item_key + 1 > count($dir)) {
        // Return a List of Tables
        $resData = array();
        $resCount = 0;
        foreach ($db_tables as $tbl) {
            if (strtolower($api_key) == 'public') {
                if ($tbl->getPublicAccess() > 0) {
                    if ($tbl->getConnID() == $conID) {
                        $resData[] = array("type" => "resource", "value" => $tbl->getName(), "description" => $tbl->getDesc(), "link" => $resServer . "/" . $tbl->getName(), "id" => $tbl->getTableID());
                        $resCount++;
                    }
                }
            } else {
                if ($tbl->getConnID() == $conID) {
                    $resData[] = array("type" => "resource", "value" => $tbl->getName(), "description" => $tbl->getDesc(), "link" => $resServer . "/" . $tbl->getName(), "id" => $tbl->getTableID());
                    $resCount++;
                }
            }
        }
        showResults($resServer, $req_url, $resCount, $resData, $resType);
        exit;
    } else {
        // Check Table Name is Valid for this Connection
        $resData = array();
        $resCount = 0;
        foreach ($db_tables as $tbl) {
            if (strtolower($api_key) == 'public') {
                if ($tbl->getPublicAccess() > 0) {
                    if ($tbl->getConnID() == $conID) {
                        // Test Table Name
                        if (strtolower($dir[$item_key]) == strtolower($tbl->getName())) {
                            $tblID = $tbl->getTableID();
                            $resTable = $tbl;
                            break;
                        }
                        $resData[] = array("type" => "resource", "value" => $tbl->getName(), "description" => $tbl->getDesc(), "link" => $resServer . "/" . $tbl->getName(), "id" => $tbl->getTableID());
                        $resCount++;
                    }
                }
            } else {
                if ($tbl->getConnID() == $conID) {
                    // Test Table Name
                    if (strtolower($dir[$item_key]) == strtolower($tbl->getName())) {
                        $tblID = $tbl->getTableID();
                        $resTable = $tbl;
                        break;
                    }
                    $resData[] = array("type" => "resource", "value" => $tbl->getName(), "description" => $tbl->getDesc(), "link" => $resServer . "/" . $tbl->getName(), "id" => $tbl->getTableID());
                    $resCount++;
                }
            }
        }
        // Exit if table not found
        if (strtolower($api_key) == 'public') {
            if ($tblID == -9999) {
                exit(Error404($req_url));
            }
        } else {
            if ($tblID == -9999) {
                showResults($resServer, $req_url, $resCount, $resData, $resType);
                exit;
            }
        }
        $item_key++;
    }
    // Check for Record Key
    $recID = -9999;
    if ($item_key + 1 > count($dir)) {
        // Return a List of Records
        $resData = array();
        $resCount = 0;
        // Query Table
        $resData = getRecord($resConn, $resTable, '', $resServer, $api_key);
        showResults($resServer, $req_url, count($resData), $resData, $resType);
        exit;
    } else {
        // Return a Single of Record
        $resData = array();
        $resCount = 0;
        // Query Table
        $resData = getRecord($resConn, $resTable, $dir[$item_key], $resServer, $api_key);
        showResults($resServer, $req_url, count($resData), $resData, $resType);
        exit;
        $item_key++;
    }
    return;
}