Ejemplo n.º 1
0
function qwp_create_json_response($result, $msg, $msg_type = 'error', $additional_fields = null)
{
    $json = array('ret' => $result, 'msg' => $msg);
    if ($additional_fields) {
        copy_from($json, $additional_fields);
    }
    if ($msg_type) {
        $json['msg_type'] = $msg_type;
    }
    return $json;
}
Ejemplo n.º 2
0
Archivo: db.php Proyecto: steem/qwp
function qwp_db_get_data($table_name, &$data, $fields, &$options = null)
{
    if (!$options) {
        $options = array();
    }
    if (is_string($options)) {
        $options = array('where' => $options);
    }
    if (!$fields) {
        qwp_db_get_fields_from_modal($options['data modal'], $fields);
    }
    if (isset($options['data modal'])) {
        if (isset($options['data modal']['alias'])) {
            if (isset($options['alias'])) {
                copy_from($options['alias'], $options['data modal']['alias']);
            } else {
                $options['alias'] = $options['data modal']['alias'];
            }
        }
    }
    $data = array();
    qwp_db_init_order_by($options);
    qwp_db_init_search_params($options);
    qwp_create_query($query, $table_name, $fields, $options);
    $result = $query->execute();
    $data = array();
    if ($result->rowCount() > 0) {
        $is_flat = isset($options['flat']);
        if (isset($options['data converter'])) {
            $data_converter = $options['data converter'];
            while ($r = $result->fetchAssoc()) {
                $data_converter($r);
                if ($is_flat) {
                    $data[] = $r[$fields];
                } else {
                    $data[] = $r;
                }
            }
        } else {
            while ($r = $result->fetchAssoc()) {
                if ($is_flat) {
                    $data[] = $r[$fields];
                } else {
                    $data[] = $r;
                }
            }
        }
    }
}
Ejemplo n.º 3
0
Archivo: common.php Proyecto: steem/qwp
function http_post_file($url, $file_path, $name, $file_name, $content_type, $headers, $boundary)
{
    copy_from($headers, array("Expect" => "100-continue", 'Accept-Language' => 'zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4'));
    $body = implode("\r\n", array("", $boundary, "Content-Disposition: form-data; name=\"{$name}\"; filename=\"{$file_name}\"", "Content-Type: {$content_type}", "", file_get_contents($file_path), $boundary));
    $header_string = array();
    $header_string[] = 'Content-Length: ' . strlen($body);
    $user_agent = '';
    $cookies = '';
    foreach ($headers as $k => $v) {
        if ($k == 'User-Agent') {
            $user_agent = $v;
        } else {
            if ($k == 'Cookie') {
                $cookies = $v;
            } else {
                $header_string[] = $k . ': ' . $v;
            }
        }
    }
    $process = curl_init();
    curl_setopt($process, CURLOPT_URL, $url);
    curl_setopt($process, CURLOPT_HTTPHEADER, $header_string);
    curl_setopt($process, CURLOPT_HEADER, 0);
    if ($user_agent) {
        curl_setopt($process, CURLOPT_USERAGENT, $user_agent);
    }
    if ($cookies) {
        curl_setopt($process, CURLOPT_COOKIE, $cookies);
    }
    curl_setopt($process, CURLOPT_TIMEOUT, 50);
    curl_setopt($process, CURLOPT_POSTFIELDS, array("tmp" => "@{$file_path}"));
    $return = curl_exec($process);
    curl_close($process);
    return $return;
}