Example #1
0
require_once __DIR__ . '/libs/bourbon.php';
$b = new Bourbon();
function cidr_match($ip, $range)
{
    list($subnet, $bits) = explode('/', $range);
    $ip = ip2long($ip);
    $subnet = ip2long($subnet);
    $mask = -1 << 32 - $bits;
    $subnet &= $mask;
    # nb: in case the supplied subnet wasn't correctly aligned
    return ($ip & $mask) == $subnet;
}
// Make sure either an authenticated user or GitHub is running this script
if (!WEB::_req('POST')) {
    $b->auth(null);
} else {
    if (!cidr_match($_SERVER['REMOTE_ADDR'], '192.30.252.0/22')) {
        header('Location: ' . realpath() . '/index.php');
    }
}
/**
 * GIT DEPLOYMENT SCRIPT
 *
 * Used for automatically deploying websites via github or bitbucket, more deets here:
 *
 *		https://gist.github.com/1809044
 */
// The commands
$commands = array('echo $PWD', 'whoami', 'git pull', 'git status', 'git submodule sync', 'git submodule update', 'git submodule status', 'mysqladmin -uroot -proot -f drop bourbon', 'mysqladmin -uroot -proot -f create bourbon', 'mysql -uroot -proot bourbon < /srv/cpsc471-bourbon/sql/latest.sql');
// Run the commands for output
Example #2
0
<?php

require_once __DIR__ . "/../bourbon/libs/bourbon.php";
API::_json();
// Auth and Grab Data
$index = new Bourbon();
if (!$index->auth(API::_get('api_key'))) {
    exit;
}
// Here is the API Interface
// Here is the API Interface
// GET
if (API::_req('GET')) {
    printNotSupportedClass();
}
// POST
if (API::_req('POST')) {
    printNotSupportedClass();
}
// PUT - Since PHP Does not support PUT, we look for &update action
if (API::_req('PUT')) {
    printNotSupportedClass();
}
// DELETE
if (API::_req('DELETE')) {
    printNotSupportedClass();
}
// Simple Helper Function to print user data
function printNotSupportedClass()
{
    echo json_encode(array("status" => "error", "name" => "Invalid_Request", "message" => "Request Not Supported."));