Example #1
0
    die(":(");
}
require_once '../config.php';
$URL = $_POST['url'];
// check proxy requests
$pattern = "proxy/index.php?url=";
if (strpos($URL, $pattern)) {
    list($remove, $URL) = explode($pattern, $URL);
    $URL = base64_decode($URL);
}
// get remote webpage
$request = get_remote_webpage($URL, array(CURLOPT_COOKIE => $_POST['cookies']));
$webpage = utf8_encode($request['content']);
// check request status
if ($request['errnum'] != CURLE_OK || $request['http_code'] != 200) {
    $webpage = error_webpage('<h1>Could not fetch page</h1><pre>' . print_r($request, true) . '</pre>');
    $parse = true;
} else {
    $cachedays = db_option(TBL_PREFIX . TBL_CMS, "cacheDays");
    // is cache enabled?
    if ($cachedays > 0) {
        // get the most recent version saved of this page
        $cachelog = db_select(TBL_PREFIX . TBL_CACHE, "id,UNIX_TIMESTAMP(saved) as savetime", "url='" . $URL . "' ORDER BY id DESC");
        // check if url exists on cache, and if it should be stored (again) on cache
        if ($cachelog && time() - $cachelog['savetime'] < $cachedays * 86400) {
            // get HTML log id
            $cache_id = $cachelog['id'];
            $parse = false;
        } else {
            // cache days expired
            $parse = true;
Example #2
0
$errpage .= '</ol>';
$errpage .= '<p>As a fallback solution, mark the option <code>fetchOldUrl</code> in the <em>Customize</em> section and reload this page.</p>';
// parse HTML log
$file = CACHE_DIR . $htmlFile;
$doc = new DOMUtil();
if (db_option(TBL_PREFIX . TBL_CMS, "fetchOldUrl")) {
    // try to re-fetch page, if available
    $request = get_remote_webpage($url);
    $page = $request ? $request['content'] : error_webpage();
    // hide warnings when parsing non valid (X)HTML pages
    @$doc->loadHTML($page);
    remove_smt_scripts($doc);
} else {
    if (!is_file($file)) {
        // page not in cache and not fetched
        @$doc->loadHTML(error_webpage($errpage));
        remove_smt_scripts($doc);
    } else {
        // page in cache (smt scripts were already removed)
        @$doc->loadHTMLFile(utf8_decode($file));
    }
}
// include user data
include './includes/user.php';
// hilite hovered/clicked elements
if (db_option(TBL_PREFIX . TBL_CMS, "displayWidgetInfo")) {
    include './includes/widget.php';
}
// include drawing API
$api = "swf";
//$_GET['api'];