Пример #1
0
function output($result_array)
{
    //输出函数
    if ($_GET['playerid'] && $result_array['status'] == 'success') {
        $playerid = htmlspecialchars($_GET['playerid']);
    }
    echo ($_GET['callback'] ? htmlspecialchars($_GET['callback']) . '(' : '') . urldecode(json_encode(url_encode_array($result_array))) . ($_GET['callback'] ? ($playerid ? ',\'' . (get_magic_quotes_gpc() ? $playerid : addslashes($playerid)) . '\'' : '') . ');' : '');
    exit;
}
Пример #2
0
 public function count($params = array())
 {
     $params = url_encode_array($params);
     return sendToAPI($this->prefix . "webhooks/count?" . $params);
 }
 function testURLEncodeArray()
 {
     $array = array('one' => 1, 'two' => 'to o', 'three' => array('blah'));
     $this->assertEqual("one=1&two=to%20o", url_encode_array($array));
 }
Пример #4
0
function url_encode_array($arr, $parent = '')
{
    $string = "";
    foreach ($arr as $key => $value) {
        if (is_array($value)) {
            if (strlen($parent)) {
                $string .= url_encode_array($value, $parent . '[' . $key . ']');
            } else {
                $string .= url_encode_array($value, $key);
            }
        } else {
            if (strlen($parent)) {
                $string .= urlencode($parent . '[' . $key . ']') . "=" . urlencode($value) . "&";
            } else {
                $string .= $key . "=" . urlencode($value) . "&";
            }
        }
    }
    trim($string, "&");
    return $string;
}