Example #1
0
if ($_REQUEST['method'] == "POST") {
    curl_setopt($ch, CURLOPT_POST, $_REQUEST['method'] == "POST");
}
curl_setopt($ch, CURLOPT_HTTPGET, $_REQUEST['method'] == "GET");
if (in_array("Content-Type: application/json", $headerKeyValue)) {
    $keyValue = json_encode($keyValue);
}
if ($_REQUEST['method'] == "POST") {
    curl_setopt($ch, CURLOPT_POSTFIELDS, $_REQUEST['method'] == "POST" ? $keyValue : null);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerKeyValue);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
$result = curl_exec($ch);
if ($result === false) {
    $result = "<div style='color:red;'>" . curl_error($ch) . "</div>";
}
$headerSent = curl_getinfo($ch, CURLINFO_HEADER_OUT);
$insertData = array('url' => $_REQUEST['url'], 'params' => serialize(json_decode($keyValue, true)), 'method' => $_REQUEST['method'], 'response' => $result, 'time' => time());
$history_id = has_in_history($insertData);
if (!$history_id) {
    $id = re_db_insert("history", $insertData);
} else {
    $id = $history_id;
    re_db_update("history", $insertData, "id=" . $history_id);
}
$history = re_db_select("history", array("*"), "id = {$id}");
$his = $history[0];
$return = array("id" => $id, "history" => getHistoryAcc($his));
echo json_encode($return);
exit;
Example #2
0
function addURL($domain)
{
    $urls = re_db_select("`urls`", array("`url`"), "`url` = '" . re_db_input($domain) . "'");
    if (!$urls) {
        re_db_insert("urls", array("url" => re_db_input($domain)));
    }
}