Пример #1
0
function getIpList($url)
{
    $list = '';
    $content = curl_string($url);
    $doc = phpQuery::newDocumentHTML($content);
    $artlist = pq('#ip_list tr');
    foreach ($artlist as $li) {
        if (pq($li)->find('td:eq(2)')->html()) {
            $list .= "'" . pq($li)->find('td:eq(2)')->html() . ':' . pq($li)->find('td:eq(3)')->html() . "', ";
        }
    }
    return $list;
}
Пример #2
0
function make_file_pickup($keyword, $suffix, $offset = 1, $index, $browseNode, $curlReq = 0)
{
    global $cg;
    global $lang;
    $yesterday = strtotime("yesterday") + 60 * 60 * $offset;
    // yesterday + offset hours
    $today = strtotime("today") + 60 * 60 * $offset;
    // today + offset hours
    $fileY = $yesterday . $suffix;
    $fileY = $cg['basedir'] . '/cache/' . $fileY . '.php';
    $fileT = $today . $suffix;
    $fileT = $cg['basedir'] . '/cache/' . $fileT . '.php';
    $lastWrite = $cg['basedir'] . '/cache/lastwrite.txt';
    $canWrite = _check_last_time(3);
    // interval of 3 mins
    if (!$canWrite) {
        // prevent amazon api call for less than 3 minutes
        // if last file write is less than 3 minutes, return and use current file to display.
        if (file_exists($fileT)) {
            return $fileT;
        } else {
            return $fileY;
        }
        exit;
    }
    // if no file exists, means 1 day has elapsed.
    // need to create a new file based on today.
    // will also make an API call to amazon to pull new content
    if (!file_exists($fileT)) {
        if ($curlReq) {
            $response = curl_string($curlReq);
            $res = simplexml_load_string($response);
            $data = arrify($res->Items);
        } else {
            $data = recommended_pickup($keyword, $index, 3, $browseNode);
            // 3 pages or loops
        }
        if (!$data) {
            return false;
        }
        $str = '<ol>';
        $i = 0;
        foreach ($data->Items->Item as $item) {
            if ($i == 15) {
                $str .= '</ol>';
                break;
            }
            if (isset($item->ItemAttributes->ListPrice)) {
                $price = trim($item->ItemAttributes->ListPrice->FormattedPrice);
            } else {
                $price = $lang[119];
            }
            if (isset($item->LargeImage)) {
                $image = $item->LargeImage->URL;
            } else {
                if (isset($item->MediumImage)) {
                    $image = $item->MediumImage->URL;
                } else {
                    if (isset($item->SmallImage)) {
                        $image = $item->SmallImage->URL;
                    } else {
                        $image = $cg['imageurl'] . '/no-image.png';
                    }
                }
            }
            if (isset($item->ItemAttributes->ProductGroup)) {
                $pg = (string) $item->ItemAttributes->ProductGroup[0];
                $categ[$pg] = $pg;
            }
            if ($i != 0 and $i % 5 == 0) {
                $str .= '</ol>';
                $str .= '<ol>';
            }
            $str .= <<<EOF
\t\t\t\t\t<li><a href="{$item->DetailPageURL}" target="_blank">
\t\t\t\t\t<div class="prbox"><span class="hovmask"></span>
\t\t\t\t\t\t<img src="{$image}" class="" alt="{$item->ItemAttributes->Title}" title="">
\t\t\t\t\t</div>
\t\t\t\t\t<div class="prbottom simptip" data-tooltip="{$item->ItemAttributes->Title}">
\t\t\t\t\t\t<h3 class="title">{$item->ItemAttributes->Title}</h3>
\t\t\t\t\t\t<span class="price">{$price}</span>
\t\t\t\t\t</div>
\t\t\t\t</a></li>
EOF;
            $i++;
            //<span class="price">{htmlspecialchars($price, ENT_HTML5,'UTF-8', true)}</span>
        }
        // foreach
        unlink($fileY);
        // delete yesterday's file
        unlink($lastWrite);
        file_put_contents($fileT, $str);
        file_put_contents($lastWrite, time());
        // write to file last time();
    }
    // !file_exists
    return $fileT;
}
Пример #3
0
    }
    $keyword = str_replace(" ", "+", $keyword);
    $keyword = urlencode($keyword);
    $operation = 'ItemSearch';
    //$searchIndex = 'All';
    $service = 'AWSECommerceService';
    $version = '2011-08-01';
    $responseGroup = 'ItemAttributes,Images';
    $browseNode = $nodeID;
    $string_to_sign = build_request($keyword, $searchIndex, $operation, $service, $version, $responseGroup, 0, $browseNode);
    $signature = get_signature($string_to_sign);
    $request = $cg['amazonUrl'] . '?' . $string_to_sign;
    $request .= "&Signature=" . $signature;
    $maxPage = $searchIndex == 'All' ? 5 : 10;
    //$response = file_get_contents($request);
    $response = curl_string($request);
} else {
    $response = false;
}
if ($response) {
    $xml = array();
    $res = simplexml_load_string($response);
    //echo '<meta charset="utf-8">';
    //echo $string_to_sign . '<br/>';
    //echo '<pre>';
    //print_r($res);
    //exit;
    if ($res->Items->Request->IsValid) {
        $xml['isValid'] = $res->Items->Request->IsValid;
        $xml['TotalResults'] = $res->Items->TotalResults;
        $xml['TotalPages'] = (string) $res->Items->TotalPages;
Пример #4
0
function transfer_file($pid, $is_gif = false)
{
    $img_server = "http://images2.minnano-camera.com";
    if ($is_gif) {
        $file = base64_encode('/camera/pdata/' . $pid . '.gif');
        $file1 = base64_encode('/camera/pdata/t/' . $pid . '.gif');
        $file2 = base64_encode('/camera/pdata/t/l-' . $pid . '.gif');
        $file3 = base64_encode('/camera/pdata/t/s-' . $pid . '.gif');
        $file4 = base64_encode('/camera/pdata/t/static-' . $pid . '.gif');
        $file5 = base64_encode('/camera/pdata/t/static-l-' . $pid . '.gif');
        $file6 = base64_encode('/camera/pdata/t/static-s-' . $pid . '.gif');
        $uri = '/get-image.php?file=' . $file;
        $out = curl_string($img_server . $uri);
        if (!$out) {
            return false;
        }
        $uri = '/get-image.php?file=' . $file1;
        $out = curl_string($img_server . $uri);
        if (!$out) {
            return false;
        }
        $uri = '/get-image.php?file=' . $file2;
        $out = curl_string($img_server . $uri);
        if (!$out) {
            return false;
        }
        $uri = '/get-image.php?file=' . $file3;
        $out = curl_string($img_server . $uri);
        if (!$out) {
            return false;
        }
        $uri = '/get-image.php?file=' . $file4;
        $out = curl_string($img_server . $uri);
        if (!$out) {
            return false;
        }
        $uri = '/get-image.php?file=' . $file5;
        $out = curl_string($img_server . $uri);
        if (!$out) {
            return false;
        }
        $uri = '/get-image.php?file=' . $file6;
        $out = curl_string($img_server . $uri);
        if (!$out) {
            return false;
        }
    } else {
        $file = base64_encode('/camera/pdata/' . $pid . '.jpg');
        $file1 = base64_encode('/camera/pdata/t/' . $pid . '.jpg');
        $file2 = base64_encode('/camera/pdata/t/l-' . $pid . '.jpg');
        $file3 = base64_encode('/camera/pdata/t/s-' . $pid . '.jpg');
        $uri = '/get-image.php?file=' . $file;
        $out = curl_string($img_server . $uri);
        if (!$out) {
            return false;
        }
        $uri = '/get-image.php?file=' . $file1;
        $out = curl_string($img_server . $uri);
        if (!$out) {
            return false;
        }
        $uri = '/get-image.php?file=' . $file2;
        $out = curl_string($img_server . $uri);
        if (!$out) {
            return false;
        }
        $uri = '/get-image.php?file=' . $file3;
        $out = curl_string($img_server . $uri);
        if (!$out) {
            return false;
        }
    }
    return true;
}