Esempio n. 1
0
 function run()
 {
     global $container;
     $uiConfResult = $container['uiconf_result'];
     $data = json_encode($uiConfResult->getPlayerConfig());
     if (array_key_exists('callback', $_REQUEST)) {
         //  JSONP request wrapped in callback
         function is_valid_callback($subject)
         {
             $identifier_syntax = '/^[$_\\p{L}\\.][$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}\\.]*+$/u';
             $reserved_words = array('break', 'do', 'instanceof', 'typeof', 'case', 'else', 'new', 'var', 'catch', 'finally', 'return', 'void', 'continue', 'for', 'switch', 'while', 'debugger', 'function', 'this', 'with', 'default', 'if', 'throw', 'delete', 'in', 'try', 'class', 'enum', 'extends', 'super', 'const', 'export', 'import', 'implements', 'let', 'private', 'public', 'yield', 'interface', 'package', 'protected', 'static', 'null', 'true', 'false');
             return preg_match($identifier_syntax, $subject) && !in_array(mb_strtolower($subject, 'UTF-8'), $reserved_words);
         }
         $callback = $_REQUEST['callback'];
         if (is_valid_callback($callback)) {
             header('Content-Type: text/javascript; charset=utf8');
             echo $callback . '(' . $data . ');';
         }
     } else {
         // normal JSON string
         header('Content-Type: application/json; charset=utf8');
         echo $data;
     }
 }
        $a = array();
        while ($ip = tep_db_fetch_array($ips_query)) {
            $squery = tep_db_query("SELECT country_code,country_name FROM aas_ip2c WHERE " . sprintf("%u", ip2long($ip['ip_address'])) . " BETWEEN begin_ip_num AND end_ip_num");
            while ($sq = tep_db_fetch_array($squery)) {
                $a[] = $sq['country_name'];
            }
        }
        $n = array_count_values($a);
        arsort($n);
        foreach ($n as $key => $nnn) {
            $ret[$key] = $nnn;
        }
    }
    $json = json_encode($ret);
}
# JSON if no callback
if (!isset($_GET['callback'])) {
    exit($json);
}
# JSONP if valid callback
if (is_valid_callback($_GET['callback'])) {
    exit("{$_GET['callback']}({$json})");
}
# Otherwise, bad request
header('status: 400 Bad Request', true, 400);
function is_valid_callback($subject)
{
    $identifier_syntax = '/^[$_\\p{L}][$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*+$/u';
    $reserved_words = array('break', 'do', 'instanceof', 'typeof', 'case', 'else', 'new', 'var', 'catch', 'finally', 'return', 'void', 'continue', 'for', 'switch', 'while', 'debugger', 'function', 'this', 'with', 'default', 'if', 'throw', 'delete', 'in', 'try', 'class', 'enum', 'extends', 'super', 'const', 'export', 'import', 'implements', 'let', 'private', 'public', 'yield', 'interface', 'package', 'protected', 'static', 'null', 'true', 'false');
    return preg_match($identifier_syntax, $subject) && !in_array(mb_strtolower($subject, 'UTF-8'), $reserved_words);
}
Esempio n. 3
0
    is_valid_callback function provided by:
        http://www.geekality.net/2010/06/27/php-how-to-easily-provide-json-and-jsonp/

    This validator does NOT conform to the ideal padding rules specified by http://www.json-p.org.
    It can not namespace (the regex does not allow period characters, quotes, or brakets. It only
    allows callback strings that are valid variable names in JavaScript (accounting for non-latin
    characters)
*/
function is_valid_callback($subject)
{
    $identifier_syntax = '/^[$_\\p{L}][$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*+$/u';
    $reserved_words = array('break', 'do', 'instanceof', 'typeof', 'case', 'else', 'new', 'var', 'catch', 'finally', 'return', 'void', 'continue', 'for', 'switch', 'while', 'debugger', 'function', 'this', 'with', 'default', 'if', 'throw', 'delete', 'in', 'try', 'class', 'enum', 'extends', 'super', 'const', 'export', 'import', 'implements', 'let', 'private', 'public', 'yield', 'interface', 'package', 'protected', 'static', 'null', 'true', 'false');
    return preg_match($identifier_syntax, $subject) && !in_array(mb_strtolower($subject, 'UTF-8'), $reserved_words);
}
$callback = null;
if (isset($_GET['callback']) && is_valid_callback($_GET['callback'])) {
    $callback = $_GET['callback'];
}
/* config options to send to the manager */
$config = array('feedUrl' => $url, 'format' => 'json');
/* get the feed */
$feedManager = new \Feed\Manager($config);
$output = $feedManager->process();
/* determine the expires time for this feed */
$ttl = $feedManager->getParser()->getProperty('ttl');
$expires = gmdate("r", strtotime('+' . $ttl . ' minutes'));
/* send 304 headers if the client cache is not stale */
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
    $modifiedSince = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
    if (time() - $ttl <= $modifiedSince) {
        header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified', true, 304);
Esempio n. 4
0
|| # This file may not be redistributed in whole or significant part. # ||
|| #   ---------------- Rhino IS NOT FREE SOFTWARE ----------------   # ||
|| #                  http://www.livesupportrhino.com                 # ||
|| #################################################################### ||
\*======================================================================*/
function is_valid_callback($input)
{
    $identifier_syntax = '/^[$_\\p{L}][$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*+$/u';
    $reserved_words = array('break', 'do', 'instanceof', 'typeof', 'case', 'else', 'new', 'var', 'catch', 'finally', 'return', 'void', 'continue', 'for', 'switch', 'while', 'debugger', 'function', 'this', 'with', 'default', 'if', 'throw', 'delete', 'in', 'try', 'class', 'enum', 'extends', 'super', 'const', 'export', 'import', 'implements', 'let', 'private', 'public', 'yield', 'interface', 'package', 'protected', 'static', 'null', 'true', 'false');
    return preg_match($identifier_syntax, $input) && !in_array(mb_strtolower($input, 'UTF-8'), $reserved_words);
}
function is_valid_callback2($input)
{
    return !preg_match('/[^0-9a-zA-Z\\$_]|^(abstract|boolean|break|byte|case|catch|char|class|const|continue|debugger|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|long|native|new|null|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|var|volatile|void|while|with|NaN|Infinity|undefined)$/', $input);
}
if (!is_valid_callback($_GET['callback']) || !is_valid_callback2($_GET['callback'])) {
    header('status: 400 Bad Request', true, 400);
} else {
    header('content-type: application/json; charset=utf-8');
}
if (!file_exists('../config.php')) {
    die('include/[slide_up.php] config.php not exist');
}
require_once '../config.php';
// Import the language file
if ($BT_LANGUAGE && file_exists(APP_PATH . 'lang/' . $BT_LANGUAGE . '.ini')) {
    $tl = parse_ini_file(APP_PATH . 'lang/' . $BT_LANGUAGE . '.ini', true);
    $lang = $BT_LANGUAGE;
} elseif (!$BT_LANGUAGE && file_exists(APP_PATH . 'lang/' . LS_LANG . '.ini')) {
    $tl = parse_ini_file(APP_PATH . 'lang/' . LS_LANG . '.ini', true);
    $lang = LS_LANG;
Esempio n. 5
0
$menu = (include 'featuresStructure.php');
foreach ($menu as $menuItem => &$menuContent) {
    foreach ($menuContent['children'] as $pluginName => &$pluginData) {
        if (isset($configRegister[$pluginName]) && isset($configRegister[$pluginName]['attributes'])) {
            $pluginData = $menuMaker->Menu($pluginName, $configRegister[$pluginName]);
        }
    }
}
header("Access-Control-Allow-Origin: *");
header('Access-Control-Max-Age: 3628800');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
if (array_key_exists('callback', $_REQUEST)) {
    //  JSONP request wrapped in callback
    function is_valid_callback($subject)
    {
        $identifier_syntax = '/^[$_\\p{L}\\.][$_\\p{L}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}\\.]*+$/u';
        $reserved_words = array('break', 'do', 'instanceof', 'typeof', 'case', 'else', 'new', 'var', 'catch', 'finally', 'return', 'void', 'continue', 'for', 'switch', 'while', 'debugger', 'function', 'this', 'with', 'default', 'if', 'throw', 'delete', 'in', 'try', 'class', 'enum', 'extends', 'super', 'const', 'export', 'import', 'implements', 'let', 'private', 'public', 'yield', 'interface', 'package', 'protected', 'static', 'null', 'true', 'false');
        return preg_match($identifier_syntax, $subject) && !in_array(mb_strtolower($subject, 'UTF-8'), $reserved_words);
    }
    $callback = $_REQUEST['callback'];
    if (is_valid_callback($callback)) {
        header('Content-Type: text/javascript; charset=utf8');
        $data = json_encode($menu);
        echo $callback . '(' . $data . ');';
    }
} else {
    // normal JSON string
    header('Content-Type: application/json; charset=utf8');
    echo json_encode($menu);
}
//echo json_encode($configRegister);