コード例 #1
0
ファイル: oauth.php プロジェクト: alvinchenghuiwu/twip
 function oob($oauth_key, $oauth_secret, $suff = '')
 {
     $connection = new TwitterOAuth($oauth_key, $oauth_secret);
     $request_token = $connection->getRequestToken('oob');
     /* Save request token to session */
     $_SESSION['oauth_token' . $suff] = $request_token['oauth_token'];
     $_SESSION['oauth_token_secret' . $suff] = $request_token['oauth_token_secret'];
     if ($connection->http_code != 200) {
         http_error($connection->http_code);
     }
     $url = $connection->getAuthorizeURL($request_token['oauth_token'], FALSE);
     $oauth_verifier = oauth_proxy($url, $_POST['username'], $_POST['password']);
     return "&oauth_token{$suff}=" . $request_token['oauth_token'] . "&oauth_verifier{$suff}=" . $oauth_verifier;
 }
コード例 #2
0
ファイル: server.php プロジェクト: voitto/rsscloud_dns_server
function acct_domain($accounts)
{
    foreach ($accounts as $arr) {
        if (md5($_POST['name'] . $_POST['record'] . $_POST['feedname'] . $arr[0]) == $_POST['key']) {
            return $arr[1];
        }
    }
    http_error('not authorized');
}
コード例 #3
0
ファイル: singlejs.php プロジェクト: mogiken/spring-scala
function error_handler($errno, $errstr, $errfile, $errline)
{
    http_error(500, "Internal Server Error", $errstr);
}
コード例 #4
0
ファイル: mvc_exception.php プロジェクト: rsms/phpab
<?php

/*
Copyright (c) 2005-2007, Rasmus Andersson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/**
 * @version    $Id$
 * @package    ab
 * @subpackage mvc
 */
http_error('500 Internal Error', 0, ABException::format($e));
コード例 #5
0
ファイル: api-v1.php プロジェクト: rfinnie/m29
            header("Content-Type: application/json; charset=UTF-8");
            print json_encode($out) . "\n";
        } else {
            $out = array('kind' => 'urlshortener#url', 'id' => $ret['short_url'], 'idIncomplete' => True);
            header("Content-Type: application/json; charset=UTF-8");
            print json_encode($out) . "\n";
        }
    } else {
        http_error(array('reason' => 'required', 'message' => 'Required parameter: longUrl', 'locationType' => 'parameter', 'location' => 'longUrl'), 'json');
    }
} else {
    if (isset($_GET['shortUrl'])) {
        try {
            $ret = $m29->process_short_url($_GET['shortUrl'], false);
        } catch (M29Exception $e) {
            http_error($e->error, 'json');
        }
        $out = array('kind' => 'urlshortener#url', 'id' => $_GET['shortUrl'], 'longUrl' => $ret['long_url'], 'status' => 'OK');
        if (isset($_GET['projection']) && ($_GET['projection'] == 'FULL' || $_GET['projection'] == 'ANALYTICS_CLICKS')) {
            $out['created'] = gmdate('c', $ret['created_at']);
            if ($ret['accessed_at']) {
                $out['lastClick'] = gmdate('c', $ret['accessed_at']);
            }
            $out['analytics'] = array('allTime' => array('shortUrlClicks' => $ret['hits'], 'longUrlClicks' => $ret['hits']));
        }
        header("Content-Type: application/json; charset=UTF-8");
        print json_encode($out) . "\n";
    } else {
        http_error(array('reason' => 'required', 'message' => 'Required parameter: shortUrl', 'locationType' => 'parameter', 'location' => 'shortUrl'), 'json');
    }
}
コード例 #6
0
ファイル: router_exception.php プロジェクト: rsms/phpab
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/**
 * @version    $Id$
 * @package    ab
 * @subpackage mvc
 */
$path = $_SERVER['REQUEST_URI'];
if (($p = strpos($path, '?')) !== false) {
    $path = substr($path, 0, $p);
}
$html = '<p>Recognition failed for ' . htmlentities($path) . '</p>';
if (MVC_DEV_MODE) {
    $html .= '<p><small>' . ABException::format($e) . '</small></p>';
}
http_error('404 Not Found', 'Routing Error', $html);
コード例 #7
0
Copyright (c) 2005-2007, Rasmus Andersson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/**
 * @version    $Id$
 * @package    ab
 * @subpackage mvc
 */
$html = '<p>No action responded to ' . (MVCRouter::$controller ? MVCRouter::$controller->action_name : 'index') . '</p>';
if (MVC_DEV_MODE) {
    $html .= '<p><small>' . ABException::format($e) . '</small></p>';
}
http_error('404 Not Found', 'Unknown action', $html);
コード例 #8
0
ファイル: redirect.php プロジェクト: rfinnie/m29
 * @copyright 2012 Ryan Finnie
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL version 2
 */
require_once 'config.php';
require_once 'functions.php';
require_once 'M29.php';
$m29 = new M29($config);
if (isset($_SERVER['PATH_INFO'])) {
    $url = $m29->base_url . $_SERVER['PATH_INFO'];
} else {
    http_error(array('reason' => 'serviceError', 'message' => 'Cannot determine the short URL'));
}
try {
    $ret = $m29->process_short_url($url, true);
} catch (M29Exception $e) {
    http_error($e->error);
}
header($_SERVER['SERVER_PROTOCOL'] . ' 301 Moved Permanently');
header("Location: " . $ret['long_url']);
?>
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
  <title>301 Moved Permanently</title>
</head>

<body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="<?php 
echo htmlentities($ret['long_url']);
コード例 #9
0
ファイル: get.php プロジェクト: fredrikekelund/svtget
}
function get_swfUrl($html)
{
    if (!preg_match('/data="([^"]+.swf)"/', $html, $swf)) {
        throw new Exception('Unable to find player swf, is URL working?');
    }
    return 'http://svtplay.se' . $swf[1];
}
function get_rtmp_streams($html)
{
    if (!preg_match_all('/rtmp[e]?:[^|&]+,bitrate:[0-9]+/', $html, $choices)) {
        throw new Exception('No rtmp streams found, does URL contain clips?');
    }
    $streams = array();
    foreach (array_unique($choices[0]) as $stream) {
        $streams[] = explode(',bitrate:', $stream);
    }
    return $streams;
}
try {
    $pageUrl = svtget_parse_url($_GET['url']);
    $html = get_url_contents($pageUrl);
    $swfUrl = get_swfUrl($html);
    $streams = get_rtmp_streams($html);
} catch (Exception $e) {
    http_error(400, $e->getmessage());
}
$program_name = basename($url);
/* pageUrl, swfUrl, tcUrl are names from Adobe RTMP specification */
$svtget_result = array('app' => 'SVT Play', 'program_name' => $program_name, 'pageUrl' => $pageUrl, 'swfUrl' => $swfUrl, 'tcUrls' => $streams);
echo json_encode($svtget_result);
コード例 #10
0
ファイル: exception.php プロジェクト: rsms/phpab
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/**
 * @version    $Id$
 * @package    ab
 * @subpackage mvc
 */
$html = '<pre>' . strip_tags(get_class($e) . " from " . $e->getFile() . ':' . $e->getLine() . ': ' . $e->getMessage());
$errmsg = "Killed by " . strip_tags(get_class($e) . " from " . $e->getFile() . ':' . $e->getLine() . ': ' . $e->getMessage());
if (MVC_DEV_MODE) {
    if ($e instanceof ABException) {
        $ts = ABException::formatTrace($e, false);
    } else {
        $ts = $e->getTraceAsString();
    }
    $errmsg .= "\n   " . strip_tags(str_replace("\n", "\n   ", $ts));
    $html .= "\n<small>\n   " . strip_tags(str_replace("\n", "\n   ", $ts)) . '</small>';
}
http_error('500 Internal Error', 0, $html . '</pre>');
コード例 #11
0
/**
 *	return a hotglue-themed error message to the client
 *
 *	the function does not return if successful.
 *	@param int $code error code
 *	@param bool $no_header don't output any header
 *	@return false if the error code is not supported yet
 */
function hotglue_error($code, $no_header = false)
{
    if (!$no_header) {
        // output header
        if (USE_HOTGLUE_ERRORS) {
            $header_only = true;
        } else {
            $header_only = false;
        }
        if (!http_error($code, $header_only)) {
            return false;
        }
    }
    // output informative message
    html_flush();
    default_html(false);
    html_add_css(base_url() . 'css/hotglue_error.css');
    $bdy =& body();
    elem_attr($bdy, 'id', 'hotglue_error');
    body_append(tab(1) . '<div id="paper">' . nl());
    body_append(tab(2) . '<div id="wrapper">' . nl());
    body_append(tab(3) . '<div id="content">' . nl());
    body_append(tab(4) . '<div id="left-nav">' . nl());
    body_append(tab(5) . '<img src="' . htmlspecialchars(base_url(), ENT_COMPAT, 'UTF-8') . 'img/hotglue-logo.png" alt="logo">' . nl());
    body_append(tab(4) . '</div>' . nl());
    body_append(tab(4) . '<div id="main">' . nl());
    if ($code == 400) {
        body_append(tab(5) . '<h1 id="error-title">ERROR 400, bad request!</h1>' . nl());
    } elseif ($code == 401) {
        body_append(tab(5) . '<h1 id="error-title">Authorization required!</h1>' . nl());
    } elseif ($code == 404) {
        body_append(tab(5) . '<h1 id="error-title">ERROR 404, not found!</h1>' . nl());
    } elseif ($code == 500) {
        body_append(tab(5) . '<h1 id="error-title">ERROR 500, server fault!</h1>' . nl());
    }
    body_append(tab(5) . '<p>' . nl());
    if ($code == 400) {
        body_append(tab(6) . 'Something got screwed up...<br>' . nl());
        body_append(tab(6) . 'The page is sending a bad request to the server!' . nl());
    } elseif ($code == 401) {
        body_append(tab(6) . 'You need to be logged in in order to do this.<br>' . nl());
    } elseif ($code == 404) {
        body_append(tab(6) . 'It looks like you got lost in cyber-space...<br>' . nl());
        body_append(tab(6) . 'The page you are trying to reach does not exist!' . nl());
    } elseif ($code == 500) {
        body_append(tab(6) . 'Are we runnining out of fuel?!<br>' . nl());
        body_append(tab(6) . 'Something is causing serious server errors!' . nl());
    }
    body_append(tab(5) . '</p>' . nl());
    body_append(tab(6) . '<a href="' . htmlspecialchars(base_url(), ENT_COMPAT, 'UTF-8') . '" id="home">take me home!</a>' . nl());
    body_append(tab(4) . '</div>' . nl());
    body_append(tab(3) . '</div>' . nl());
    body_append(tab(2) . '</div>' . nl());
    body_append(tab(2) . '<div style="position: absolute; left: 200px; top: -10px; z-index: 2;">' . nl());
    body_append(tab(3) . '<img src="' . htmlspecialchars(base_url(), ENT_COMPAT, 'UTF-8') . 'img/hotglue-404.png" alt="404">' . nl());
    body_append(tab(2) . '</div>' . nl());
    body_append(tab(1) . '</div>' . nl());
    echo html_finalize();
    die;
}
コード例 #12
0
if (!isset($_SERVER['PATH_INFO'])) {
    die(':)');
}
$components = array('.' => 'dump', 'token_key' => '', 'controller' => '', 'action' => '');
$component_names = array_keys($components);
foreach (explode('/', $_SERVER['PATH_INFO']) as $c) {
    if (strlen($c = trim($c))) {
        $components[next($component_names)] = $c;
    }
}
if (strpos($components['action'], '.') !== FALSE) {
    list($components['action'], $components['.']) = explode('.', $components['action'], 2);
}
/* Security */
if (!isset($API_TOKEN_KEYS[$components['controller']]) || $API_TOKEN_KEYS[$components['controller']] != $components['token_key']) {
    return http_error(403, 'Unauthorized', 'Invalid security token');
}
/* PHP errors */
if ($components['.'] == 'dump') {
    // Only allowed in .dump
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
} else {
    error_reporting(0);
    ini_set('display_errors', 0);
}
/* Controllers */
require_once "system/api.php";
/* Routing */
try {
    $router = Router::forClass($components['controller']);
コード例 #13
0
Copyright (c) 2005-2007, Rasmus Andersson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/**
 * @version    $Id$
 * @package    ab
 * @subpackage mvc
 */
$html = '<p>' . $e->getMessage() . '</p>';
if (MVC_DEV_MODE) {
    $html .= '<p><small>' . ABException::format($e) . '</small></p>';
}
http_error('404 Not Found', 'Template is missing', $html);
コード例 #14
0
ファイル: index.php プロジェクト: JJjie/RuCTF-2015
<?php

require_once 'inc/routing.php';
require_once 'inc/shortcuts.php';
ini_set('display_errors', 0);
$url = $_SERVER['REQUEST_URI'];
$controllers = ['/' => 'index', '/users' => 'users', '/users/:id' => 'users', '/report' => 'report', '/signin' => 'signin', '/signup' => 'signup', '/logout' => 'logout'];
$routing = new Routing($controllers);
$controller = $routing->find($url);
if (!$controller) {
    http_error(404);
}
$controller->run();