Example #1
0
            $parse = true;
        }
    } else {
        // cache is disabled
        $parse = true;
    }
}
/* parse webpage ---------------------------------------------------------- */
if ($parse) {
    // use the DOM to parse webpage contents
    $dom = new DOMDocument();
    $dom->formatOutput = true;
    $dom->preserveWhiteSpace = false;
    // hide warnings when parsing non valid (X)HTML pages
    @$dom->loadHTML($webpage);
    remove_smt_scripts($dom);
    // set HTML log name
    $date = date("Ymd-His");
    $ext = ".html";
    // "March 10th 2006 @ 15h 16m 08s" should create the log file "20060310-151608.html"
    $htmlfile = !is_file(CACHE_DIR . $date . $ext) ? $date . $ext : $date . '-' . mt_rand() . $ext;
    // store (UTF-8 encoded) log
    $dom->saveHTMLFile(CACHE_DIR . $htmlfile);
    // insert new row on TBL_CACHE and look for inserted id
    $cache_id = db_insert(TBL_PREFIX . TBL_CACHE, "file, url, layout, title, saved", "'" . $htmlfile . "', '" . $URL . "', '" . $_POST['layout'] . "','" . $_POST['urltitle'] . "', NOW()");
}
// verify
if (!isset($cache_id)) {
    exit;
}
/* client browser stats ----------------------------------------------------- */
Example #2
0
$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'];
$apiFile = './includes/api-' . $api . '.php';