コード例 #1
0
ファイル: muachung.php プロジェクト: hbarrios/auto-stock-data
function loantin(&$ch, $url, &$startURLList, &$countSuccess, $MAX_COUNT_SUCCESS, $index, &$db)
{
    if ($countSuccess >= $MAX_COUNT_SUCCESS) {
        return true;
    }
    echo $url . "\n";
    $id = $url;
    if (!checkVisited($db, $index, $id)) {
        curl_setopt($ch, CURLOPT_URL, "http://muachung.vn/ajax.php?act=connect&mccode=check-loantin");
        initCommonCURL($ch);
        $params = array("item_id" => $id, "yahoo" => "1", "facebook" => "0", "content" => "", "rand" => randomFloat());
        curl_setopt($ch, CURLOPT_POST, count($params));
        $fields_string = "";
        foreach ($params as $key => $value) {
            $fields_string .= $key . '=' . urlencode($value) . '&';
        }
        rtrim($fields_string, '&');
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
        $output = curl_exec($ch);
        echo "id:" . $id . ", result:" . $output . "\n";
        if ('{"err":-1,"msg":"done"}' == trim($output)) {
            visited($db, $index, $id);
        }
        if (startsWith(trim($output), '{"err":0,"msg":"done"')) {
            visited($db, $index, $id);
            $countSuccess = $countSuccess + 1;
            if ($countSuccess >= $MAX_COUNT_SUCCESS) {
                return true;
            }
        }
        if ('{"err":-1,"msg":"not_login"}' == trim($output)) {
            return true;
        }
    }
    return false;
}
コード例 #2
0
<?php

$titleController = 'Details';
if (!empty($_GET['target'])) {
    if ($_GET['target'] == 'getDetails') {
        $col = array('id', 'title', 'category', 'desc', 'imgPath', 'area', 'duration', 'featured', 'offer');
        $table = 'trip';
        $id = 'id';
        $val = $_GET['id'];
        $res = $obj_query->select_single($col, $table, $id, $val);
        if (checkVisited($obj_query, $val)) {
            updateVisited($obj_query, $val);
        } else {
            insertVisited($obj_query, $val);
        }
    }
}
function checkVisited($obj_query, $tripId)
{
    $col = array('id', 'tripId', 'visited', 'session_id');
    $table = 'visited';
    $id = 'tripId';
    $val = $tripId;
    $res = $obj_query->select_one($col, $table, $id, $val);
    if (!empty($res)) {
        return true;
    } else {
        return FALSE;
    }
}
function updateVisited($obj_query, $val)