Esempio n. 1
0
function dispatch(...$args)
{
    $verb = strtoupper($_SERVER['REQUEST_METHOD']);
    $path = '/' . trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');
    # post method override
    if ($verb === 'POST') {
        if (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
            $verb = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
        } else {
            $verb = isset($_POST['_method']) ? strtoupper($_POST['_method']) : $verb;
        }
    }
    $responder = serve(context(), $verb, $path, ...$args);
    $responder();
}
Esempio n. 2
0
function run($urls)
{
    global $url, $_S;
    foreach ($urls as $r => $c) {
        // $r, $c, $m = route, controller, matches
        preg_match('/^' . str_replace('/', '\\/', $r) . '$/', $url, $m);
        if (count($m) > 0) {
            array_shift($m);
            // Rid $m[0] (the matching URL)
            foreach ($m as &$i) {
                $i = '"' . $i . '"';
            }
            serve($c, in_array($_S['REQUEST_METHOD'], array('POST', 'GET', 'DELETE', 'PUT')) ? $_S['REQUEST_METHOD'] : 'GET', $m);
            return;
        }
        // else it isn't a match so go to the next item in array
    }
    // If the code reaches this point, there was no match
    die('not found');
}
Esempio n. 3
0
{
	$paint = imagecreatefromfile($settings['upload']['folder'][$dir].'paintcan_paintcolor.png');
	$color = int2rgb($paintcolor);
	
	imagefilter($paint, IMG_FILTER_COLORIZE, $color[0], $color[1], $color[2]);
	imagecopyresampled($thumb, $paint, 0, 0, $x0, $y0, $x, $y, ($x * $s), ($y * $s));
	
	$target_file = str_replace('.p'.$paintcolor,'/'.$paintcolor.'p_',$target_file);
	die($target_file);
}



imagewritefile($thumb,$target_file);
*/
serve($target_file);
//redirect($ext_file);
function imagewritefile($i, $file)
{
    $ext = strtolower($file);
    $ext = explode('.', $ext);
    $ext = end($ext);
    $i->setImageFormat($ext);
    $i->setCompressionQuality(90);
    $i->writeImage($file);
    return;
    switch ($ext) {
        case 'jpg':
        case 'jpeg':
            imagejpeg($im, $file);
            break;
Esempio n. 4
0
$app->token_extractor_instance = new TokenExtractor($app->global['lms_id'],$app->global['lms_desc'],$app->global['lms_secret'],$app->global['lms_url']);



$app->get('/test',function () use ($app){
	echo json_encode(array('version'=>3));
	exit(0);
});

$app->post('/lmsg',function() use ($app){
            $token = $app->request->post('token');
            if (strlen($token)>0)
                serve($app,$token);
            else
                $app->notFound();
});

$app->group('/lms', function () use ($app) {
    $app->post('/gate', function () use ($app) {
            $token = $app->request->post('token');
            if (strlen($token)>0)
                serve($app,$token);
            else
                $app->notFound();
    });

});

$app->run();
?>
Esempio n. 5
0
// fragile is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
// A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
// details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
require_once __DIR__ . '/classes/Builds.php';
require_once __DIR__ . '/config.php';
// TODO: maybe mark all "running" builds as failed
// TODO: maybe extract Builders and Builder classes
if (!putenv('FRAGILE_REPO=' . REPO_PATH)) {
    die("Failed to set FRAGILE_REPO environment variable\n");
}
prepareRepository();
serve();
/**
 * @brief Clones repository if it doesn't exist yet.
 */
function prepareRepository()
{
    if (!createPath(REPO_PATH)) {
        return;
    }
    system(__DIR__ . "/vcs/clone '" . REPO_URL . "'", $retval);
    if ($retval != 0) {
        delTree(REPO_PATH);
        die("Failed to clone repository\n");
    }
}
/**
Esempio n. 6
0
        if ($fileinfo->isDir() && !$fileinfo->isDot()) {
            array_push($people, $fileinfo->getFilename());
        }
    }
    $currentURL = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
    $template = $twig->loadTemplate('views/home.html.twig');
    echo $template->render(array('currenturl' => $currentURL, 'people' => $people));
});
$app->get('/:width/:height', function ($width, $height) use($app) {
    if ($width > 3000 || $height > 3000) {
        echo "Sorry but this size is not available. Max is 3000 x 3000.";
        die;
    }
    serve($width, $height, '');
});
$app->get('/:width', function ($width) use($app) {
    $app->response()->redirect("/{$width}/{$width}", 303);
});
$app->get('/:width/:height/:person', function ($width, $height, $person) use($app) {
    if ($width > 3000 || $height > 3000) {
        echo "Sorry but this size is not available. Max is 3000 x 3000.";
        die;
    }
    serve($width, $height, $person);
});
// Attribution
$app->get('/attribution', function () use($app, $twig) {
    $template = $twig->loadTemplate('views/attribution.html.twig');
    echo $template->render(array());
});
$app->run();