/** * Adds mouse tracking script. */ function includeTracking($html) { $dom = new DOMUtil(); $dom->formatOutput = true; $dom->preserveWhiteSpace = false; // hide warnings when parsing non valid (X)HTML pages @$dom->loadHTML($html); // create (smt) record script $aux = $dom->createExternalScript(VA_AUX); $rec = $dom->createExternalScript(VA_RECORD); require_once BASE_PATH . '/proxy/conf/trackingcode.php'; $va = $dom->createInlineScript($vacode); // parse $head = $dom->getElementsByTagName('head'); foreach ($head as $h) { $h->appendChild($aux); $h->appendChild($rec); $h->appendChild($va); } /* // custom warn DIV $div = createDiv($dom, "test", "[SMT] on!"); foreach ($dom->getElementsByTagName('body') as $b) { $b->insertBefore($div, $b->firstChild); } */ // render parsed page $page = $dom->saveHTML(); return $page; }
public function SingleTitle() { return $this->singleTitle ? $this->singleTitle : DOMUtil::readable_class($this->AddTitle()); }
<?php Moriarti::register(3, '/view/adminlte/private/*', function ($code, $data) { $doc = Moriarti::get('view'); DOMUtil::findElementsByClassName('messages-text')->item(0)->nodeValue = 'Tienes 100 mensajes'; DOMUtil::findElementsByClassName('messages-count')->item(0)->nodeValue = 100; });
// custom tracking analysis options include './includes/sql.php'; // load tracking data from database // A fallback error page: $errpage = '<h1>Page not found on cache!</h1>'; $errpage .= '<p>Error loading file <code>' . $htmlFile . '</code>, which is a snapshot of <code>' . $url . '</code></p>'; $errpage .= '<p>Some reasons for this issue include the following:</p>'; $errpage .= '<ol>'; $errpage .= '<li>Cache request could not be processed at the time.</li>'; $errpage .= '<li>The cache log was deleted.</li>'; $errpage .= '<li>The cache dir has been moved/renamed.</li>'; $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));
<?php Moriarti::register(2, '/view/adminlte/*/*', function ($code, $data) { $viewName = explode('/', $code)[4]; $filename = dirname(__FILE__) . "/view/{$viewName}.html"; if (file_exists($filename)) { $doc = Moriarti::get('view'); $content = file_get_contents($filename); DOMUtil::importDOM($doc->getElementById('contentFragment'), DOMUtil::parseHTML($content)); } });
<?php Moriarti::register(9, '/view/adminlte/private/*', function ($code, $data) { $view = explode('/', $code)[4]; $doc = Moriarti::get('view'); $list = DOMUtil::findElementsByClassName('sidebar-menu')->item(0); $item = $list->firstChild; foreach (Moriarti::get('userMenu') as $menu) { $menuref = str_replace(' ', '', strtolower($menu)); $newItem = $item->cloneNode(true); $list->appendChild($newItem); DOMUtil::xpathQuery('.//span', $newItem)->item(0)->nodeValue = $menu; DOMUtil::xpathQuery('.//a/@href', $newItem)->item(0)->nodeValue = $menuref; if ($view === $menuref) { $newItem->setAttribute('class', 'active'); } } $item->parentNode->removeChild($item); });
<?php Moriarti::register(9, '/view/adminlte/*', function ($code, $data) { // show warnings $doc = Moriarti::get('view'); $notifications = $doc->getElementByID('notifications'); if ($notifications != null) { $content = file_get_contents(__DIR__ . '/view/notifications/warning.html'); $warningDoc = DOMUtil::parseHTML($content); foreach (Moriarti::getArr('warning') as $warningTxt) { DOMUtil::findElementsByClassName('warning-message', $warningDoc)->item(0)->nodeValue = $warningTxt; DOMUtil::importDOM($notifications, $warningDoc); } $content = file_get_contents(__DIR__ . '/view/notifications/error.html'); $errorDoc = DOMUtil::parseHTML($content); foreach (Moriarti::getArr('error') as $errorTxt) { DOMUtil::findElementsByClassName('error-message', $errorDoc)->item(0)->nodeValue = $errorTxt; DOMUtil::importDOM($notifications, $errorDoc); } $content = file_get_contents(__DIR__ . '/view/notifications/info.html'); $infoDoc = DOMUtil::parseHTML($content); foreach (Moriarti::getArr('info') as $infoTxt) { DOMUtil::findElementsByClassName('info-message', $infoDoc)->item(0)->nodeValue = $infoTxt; DOMUtil::importDOM($notifications, $infoDoc); } } });
<?php Moriarti::register(3, '/view/adminlte/private/*', function ($code, $data) { foreach (DOMUtil::xpathQuery("//text()[. = 'USER_NAME']") as $userName) { $userName->nodeValue = $_SESSION['USER']['NAME']; } });