Exemple #1
0
 /**
  * The <div id="individu">
  * @return DOMNode
  */
 public function getWidget()
 {
     $doc = new DOMDocument();
     $doc->preserveWhiteSpace = true;
     $this->isConnected() ? $doc->loadHTMLFile('page/edit/individu.html') : $doc->loadHTMLFile('page/show/individu.html');
     return $doc->saveHTML();
 }
Exemple #2
0
 public function setUp()
 {
     $this->test_options = new DefaultOptions();
     $this->test_options->set(Opt::DIR_ROOT, __DIR__ . '/../Fixures/LinkerTest');
     $this->test_dom = new \DOMDocument('1.0', 'UTF-8');
     $this->test_dom->loadHTMLFile(__DIR__ . '/../Fixures/InternalLink_1.html');
 }
Exemple #3
0
 /**
  * The <div id="connexion">
  * @return DOMNode
  */
 public function getWidget()
 {
     $doc = new \DOMDocument();
     $doc->preserveWhiteSpace = true;
     $this->isConnected() ? $doc->loadHTMLFile('page/edit/connexion.html') : $doc->loadHTMLFile('page/show/connexion.html', LIBXML_HTML_NOIMPLIED);
     return $doc->saveHTML();
 }
 private function _crawl($url, $depth)
 {
     static $seen = array();
     if (empty($url)) {
         return;
     }
     if (!($url = $this->buildUrl($this->url, $url))) {
         return;
     }
     if ($depth === 0 || isset($seen[$url])) {
         return;
     }
     $seen[$url] = true;
     $dom = new DOMDocument('1.0');
     @$dom->loadHTMLFile($url);
     $this->results[] = array('url' => $url);
     $anchors = $dom->getElementsByTagName('a');
     foreach ($anchors as $element) {
         if (!($href = $this->buildUrl($url, $element->getAttribute('href')))) {
             continue;
         }
         $this->_crawl($href, $depth - 1);
     }
     return $url;
 }
function get()
{
    $name = $_GET["name"];
    $surname = $_GET["surname"];
    $address = $_GET["address"];
    $email = $_GET["email"];
    $password = $_GET["password1"];
    $bank = $_GET["bank"];
    $card_no = $_GET["cardNo"];
    $conn = new mysqli("localhost", "root", "fjab1991", "ip3_php_project_db");
    $query = "INSERT INTO customer(customer_name,customer_surname,customer_address,customer_email,customer_password,customer_bank,customer_card_no) VALUES('{$name}', '{$surname}', '{$address}', '{$email}', '{$password}', '{$bank}', '{$card_no}')";
    if ($name == "" || $name == null || $surname == "" || ($surname = null || $address == "" || $address == null || $email == "" || $email == null || $password == "" || $password == null || $bank == "" || $bank == null || $card_no == "" || $card_no == null)) {
        $doc = new DOMDocument();
        $doc->loadHTMLFile("NewCustomerPage.html");
        echo $doc->saveHTML();
        echo "<div align='center'>Please make sure you enter data in all fields.</div>";
    } else {
        if ($conn->connect_error) {
            die('Could not connect to database!');
        } else {
            if ($conn->query($query)) {
                echo 'Account created. You may login.';
                $doc = new DOMDocument();
                $doc->loadHTMLFile("LoginPage.html");
                echo $doc->saveHTML();
            } else {
                echo $conn->error;
            }
        }
    }
}
Exemple #6
0
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/11/23
 * Time: 14:49
 */
function get_heros()
{
    $urlTarget = 'http://www.dota2.com.cn/heroes/index.htm';
    //$urlTarget = 'E:/heros.html';
    //建立Dom对象,分析HTML文件;
    $htmDoc = new DOMDocument();
    $htmDoc->loadHTMLFile($urlTarget);
    //获取英雄列表
    $hero_uls = $htmDoc->getElementsByTagName("ul");
    //echo $ul_count=$hero_uls->length;
    //遍历各阵营
    $heros_url = array();
    foreach ($hero_uls as $hero_ul) {
        //先去除不是英雄列表的ul节点
        if ($hero_ul->getAttribute('class') == 'hero_list') {
            //获取单个英雄的li节点
            $hero_lis = $hero_ul->getElementsByTagName("li");
            //echo $hero_lis->length;
            //遍历各阵营下英雄,并去除阵营标识 力量-敏捷-智力
            foreach ($hero_lis as $hero_li) {
                //带class的为阵营标识
                if (!$hero_li->getAttribute('class')) {
                    //获取各个英雄资料的页面url
                    $heros_url[] = $hero_li->getElementsByTagName('a')->item(0)->getAttribute('href');
                }
            }
        }
    }
    return $heros_url;
}
Exemple #7
0
function load_simplexml_page($page, $type = 'url')
{
    ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
    $dom = new DOMDocument('1.0', 'UTF-8');
    $type === 'url' ? @$dom->loadHTMLFile(trim($page)) : @$dom->loadHTML($page);
    return simplexml_import_dom($dom);
}
function get_extension_name($file, $extensions)
{
    $doc_dir = dirname($file);
    $current_file = basename($file);
    $files_checked = array();
    do {
        if (isset($extensions[$current_file])) {
            return $extensions[$current_file];
        }
        $doc = new DOMDocument();
        $doc->loadHTMLFile($doc_dir . '/' . $current_file);
        $xpath = new DOMXPath($doc);
        $up_link = $xpath->query('//div[@class="up"]/a');
        if ($up_link->length == 0) {
            fwrite(STDERR, "\nCan't find up link in " . $current_file . ' started ascending from ' . $file);
            exit;
        }
        $up_href = $up_link->item(0)->getAttribute('href');
        if ($current_file == $up_href) {
            fwrite(STDERR, "\nup link traversal got stuck at " . $current_file . " started ascending from " . $file);
            exit;
        }
        $files_checked[] = $current_file;
        $current_file = $up_href;
    } while ($current_file != 'index.html');
    fwrite(STDERR, "\nNOTICE: Can't find extension name for " . $file . " files checked: " . join(", ", $files_checked));
    return '_unknow';
}
 function get_play_store()
 {
     $remote = array();
     $store_page = new DOMDocument();
     $internalErrors = libxml_use_internal_errors(true);
     $store_page->loadHTMLFile("https://play.google.com/store/search?q=awareframework%20plugin");
     $xpath = new DOMXpath($store_page);
     $packages_titles = $xpath->query('//a[@class="title"]/@href');
     foreach ($packages_titles as $pkgs) {
         $package_name = substr($pkgs->textContent, strrpos($pkgs->textContent, "=") + 1, strlen($pkgs->textContent));
         preg_match("/^com\\.aware\\.plugin\\..*/", $package_name, $matches, PREG_OFFSET_CAPTURE);
         if (count($matches) == 0) {
             continue;
         }
         $package_page = new DOMDocument();
         $package_page->loadHTMLFile("https://play.google.com/store/apps/details?id={$package_name}");
         $xpath = new DOMXpath($package_page);
         $icon = $xpath->query('//img[@class="cover-image"]/@src');
         $version = $xpath->query('//div[@itemprop="softwareVersion"]');
         $description = $xpath->query('//div[@itemprop="description"]');
         $pkg = array('title' => trim($pkgs->parentNode->textContent), 'package' => $package_name, 'version' => trim($version->item(0)->textContent), 'desc' => $description->item(0)->childNodes->item(1)->nodeValue, 'iconpath' => 'https:' . $icon->item(0)->value, 'first_name' => 'AWARE', 'last_name' => 'Framework', 'email' => '*****@*****.**');
         $remote[] = $pkg;
     }
     return $remote;
 }
Exemple #10
0
function cep($filtro)
{
    $file = "http://www.buscacep.correios.com.br/servicos/dnec/consultaEnderecoAction.do?relaxation=" . $filtro . "&Metodo=listaLogradouro&TipoConsulta=relaxation&StartRow=1&EndRow=10";
    $doc = new DOMDocument();
    @$doc->loadHTMLFile($file);
    $elements = $doc->getElementsByTagName('table');
    echo "<br>\n\t<h4>Resultado:</h4>\n\t<table class='uk-table uk-table-hover uk-table-condensed uk-table-striped uk-text-nowrap uk-panel-box' style='font-size: 10px;padding: 2px;'>";
    if (!is_null($elements)) {
        $n = 0;
        foreach ($elements as $element) {
            $nodes = $element->childNodes;
            foreach ($nodes as $node) {
                $colunas = $node->childNodes;
                $endereco = "";
                foreach ($colunas as $coluna) {
                    $endereco = $endereco . $coluna->nodeValue;
                }
                if ($n > 0) {
                    echo "<tr onclick='selecionarcep(" . $n . ")' id='" . $n . "' class='uk-modal-close'>";
                    foreach ($colunas as $coluna) {
                        echo "<td style='max-width: 100px !important;width:auto;' class='uk-text-truncate'>" . mb_convert_encoding($coluna->nodeValue, 'ISO-8859-1', 'UTF-8') . "</td>";
                    }
                    echo "</tr>";
                }
                $n = $n + 1;
            }
        }
    }
    echo "</table>";
}
 public function update()
 {
     // this code is from Search the WordPress function reference
     // http://www.alfredforum.com/topic/2153-search-the-wordpress-function-reference/?p=12072
     // by keesiemeijer: http://www.alfredforum.com/user/4274-keesiemeijer/
     $base_url = 'http://codex.wordpress.org';
     $url = $base_url . '/Function_Reference/';
     // Create a new DOM Document to hold our webpage structure
     $xml = new DOMDocument();
     // Load the url's contents into the DOM (the @ supresses any errors from invalid XML)
     @$xml->loadHTMLFile($url);
     $links = array();
     $string = '';
     $tables = $xml->getElementsByTagName('table');
     //Loop through each <a> and </a> tag in the dom and add it to the link array
     foreach ($tables as $table) {
         if ($table->getAttribute('class') == 'widefat') {
             foreach ($table->getElementsByTagName('a') as $link) {
                 if ($link->getAttribute('href')) {
                     $links[] = array('url' => $base_url . $link->getAttribute('href'), 'title' => $link->nodeValue, 'description' => null);
                 }
             }
         }
     }
     $this->addResults($links);
     $this->save();
 }
 function import_horaire($date, $lign_id, $arret_id, $sens)
 {
     $page = 'http://www.reseau-stan.com/horaires/arret/index.asp?rub_code=28&laDate=' . $date . '&lheure=&laminute=&pointDep=&lign_id=' . $lign_id . '&pa_id=' . $arret_id . '&sens=' . $sens;
     $doc = new DOMDocument();
     if (!@$doc->loadHTMLFile($page)) {
         return FALSE;
     }
     $tableau = $doc->getElementsByTagName('tbody')->item(0);
     if (is_null($tableau)) {
         return FALSE;
     }
     $colonne = $tableau->getElementsByTagName('tr')->item(0);
     if (is_null($colonne)) {
         return FALSE;
     }
     $heures = $colonne->getElementsByTagName('td');
     if (is_null($heures)) {
         return FALSE;
     }
     $i = 5;
     foreach ($heures as $heure) {
         $heure_matche = $doc->saveHTML($heure);
         preg_match_all('/<div style=\\"background-color: #;\\">([0-9]+)<span class=\\"hidden\\">/', $heure_matche, $matches);
         $horaire[$i] = $matches[1];
         //var_dump($horaire[$i]);
         $i++;
     }
     return $horaire;
 }
Exemple #13
0
 public function openGame($idx)
 {
     $file = $this->games[$idx]['name'];
     $doc = new DOMDocument();
     $doc->preserveWhiteSpace = true;
     $doc->formatOutput = true;
     // modify state
     $libxml_previous_state = libxml_use_internal_errors(true);
     // parse
     $doc->loadHTMLFile("Games/" . $file);
     // Usuwanie scriptow - bład z tagamiw scripcie
     $domNodeList = $doc->getElementsByTagname('script');
     $domElemsToRemove = array();
     foreach ($domNodeList as $domElement) {
         $domElemsToRemove[] = $domElement;
     }
     foreach ($domElemsToRemove as $domElement) {
         $domElement->parentNode->removeChild($domElement);
     }
     $xpath = new DomXpath($doc);
     // traverse all results
     foreach ($xpath->query('//div[@tiddler]') as $tid) {
         if ($tid->getAttribute('tiddler') != 'checkvars') {
             $this->tiddlers[$tid->getAttribute('tiddler')] = $tid->nodeValue;
         }
     }
     // handle errors
     libxml_clear_errors();
     // restore
     libxml_use_internal_errors($libxml_previous_state);
 }
function extract_class_signatures($files, $extensions)
{
    $class_signatures = array();
    $interface_signatures = array();
    foreach ($files as $file) {
        $doc = new DOMDocument();
        $doc->loadHTMLFile($file);
        $xpath = new DOMXpath($doc);
        list($classname, $is_interface) = extract_class_name($xpath, $file);
        if (empty($classname)) {
            // no usual class synopsis found inside the file, just skip this class
            continue;
        }
        $fields = extract_class_fields($xpath, $classname, $file);
        $methods = extract_class_methods($xpath, $classname, $file);
        $extension_name = get_extension_name($file, $extensions);
        if (!isset($class_signatures[$extension_name][$classname])) {
            if ($is_interface) {
                if (!isset($interface_signatures[$extension_name])) {
                    $interface_signatures[$extension_name] = array();
                }
                $interface_signatures[$extension_name][$classname] = array('constants' => $fields['constants'], 'properties' => $fields['properties'], 'static_properties' => $fields['static_properties'], 'methods' => $methods['methods'], 'static_methods' => $methods['static_methods']);
            } else {
                if (!isset($class_signatures[$extension_name])) {
                    $class_signatures[$extension_name] = array();
                }
                $class_signatures[$extension_name][$classname] = array('constants' => $fields['constants'], 'properties' => $fields['properties'], 'static_properties' => $fields['static_properties'], 'methods' => $methods['methods'], 'static_methods' => $methods['static_methods']);
            }
        } else {
            // there are some duplicate class names in extensions, use only the first one
        }
    }
    return array($class_signatures, $interface_signatures);
}
Exemple #15
0
 public function score_html($path)
 {
     /*
     REQUIREMENT #1: Accept HTML Content Input
     REQUIREMENT #2: Accept unique id for HTML Content to score (filename prefix) - THIS IS DONE IN THE DATABASE CLASS->insert_score METHOD
     REQUIREMENT #3: Score HTML content using the scoring guide
     REQUIREMENT #4: Save results to a MySQL database
     */
     $doc = new \DOMDocument();
     @$doc->loadHTMLFile($path);
     $rules = $this->DB->get_rules();
     $score = 0;
     foreach ($rules as $rule) {
         $result = $doc->getElementsByTagName($rule->tag_name);
         $instances = $result->length;
         for ($i = 0; $i < $instances; $i++) {
             $score += (int) $rule->points;
         }
     }
     $filename = basename($path);
     if (!empty($this->DB->get_scores_by_id($filename))) {
         $this->DB->update_score($filename, $score);
     } else {
         $this->DB->insert_score($score, $filename);
     }
 }
 public function html_to_html($html)
 {
     $dom = new DOMDocument();
     if (is_file($html)) {
         $dom->loadHTMLFile($html);
     } else {
         $dom->loadHTML($html);
     }
     $section_title = $dom->getElementsByTagName('html')->item(0)->getElementsByTagName('head')->item(0)->nodeValue;
     $section_li_a = $this->dom->createElement('a', $section_title);
     $section_li_a->setAttribute('href', '#' . str_replace(' ', null, $section_title));
     $section_li = $this->dom->createElement('li');
     $section_li->appendChild($section_li_a);
     $this->section_list->appendChild($section_li);
     $p = $this->dom->createElement('hr');
     $p->setAttribute('style', 'height: 50px; border: 0;');
     $this->dom_body->appendChild($p);
     $p = $this->dom->createElement('a');
     $p->setAttribute('name', str_replace(' ', null, $section_title));
     $this->dom_body->appendChild($p);
     $p = $this->dom->createElement('h1', $section_title);
     $this->dom_body->appendChild($p);
     // TODO: the below code is known to emit a fatal error right now since the nodes are different, need to copy/merge nodes between docs
     foreach ($dom->getElementsByTagName('html')->item(0)->getElementsByTagName('body')->item(0)->childNodes as $node) {
         $n = $this->dom->importNode($node, true);
         $this->dom_body->appendChild($n);
     }
 }
Exemple #17
0
 public static function loadHTMLFile($fileName)
 {
     $doc = new DOMDocument();
     libxml_use_internal_errors(true);
     $doc->loadHTMLFile($fileName);
     return $doc;
 }
Exemple #18
0
function adminAddBlog()
{
    ?>
      Country: <input type="text"></input>

      <div id='text-editor' style='width: 400px; height: 400px;'>

      <?php 
    $doc = new DOMDocument();
    $doc->loadHTMLFile('quill/examples/index.html');
    echo $doc->saveHTML();
    echo "</div>";
    ?>

      <button onclick='submit_blog()'>Submit KK left here</button> 

      <script>
         function submit_blog() {
            var to_submit = {
               'title' :      'Hello, World!',
               'countries' :  ['Us', 'Russia'],
               'data' :       editor.getHTML(),
               'super_secret_3va3' : 'gentoo-rms42stalmman69'
            }
            post('upload.php', to_submit);
         }
      </script>
   <?php 
}
Exemple #19
0
function SearchDir($path)
{
    if (!($dir = opendir($path))) {
        return;
    }
    $result = array();
    $search = strtolower($_GET['search']);
    while (false !== ($file = readdir($dir))) {
        if ($file != "." && $file != "..") {
            if (is_dir($path . $file)) {
                $result = array_merge($result, SearchDir($path . $file . '/'));
            } else {
                // HTML-Dokument auslesen
                $doc = new DOMDocument();
                @$doc->loadHTMLFile($path . $file);
                $divs = $doc->getElementsByTagName('div');
                foreach ($divs as $div) {
                    if (strpos($div->getAttribute('class'), 'text') !== false) {
                        if (strpos(strtolower(strip_tags($div->nodeValue)), htmlspecialchars($search)) !== false) {
                            $dirname = basename(rtrim($path, '/'));
                            if (!isset($result[$dirname])) {
                                $result[$dirname] = array();
                            }
                            $name = $doc->getElementsByTagName('h1')->item(0)->nodeValue;
                            array_push($result[$dirname], array($path . $file, $name));
                            break;
                        }
                    }
                }
            }
        }
    }
    closedir($dir);
    return $result;
}
Exemple #20
0
function getDirectoryListing($result, $path, $cat)
{
    $path .= " > " . $cat;
    $cat = str_replace(" ", "_", $cat);
    $ch = curl_init();
    $buffer = fopen("buffer.html", "w");
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2");
    curl_setopt($ch, CURLOPT_URL, "http://ru.wikipedia.org/wiki/Категория:" . $cat);
    curl_setopt($ch, CURLOPT_FILE, $buffer);
    curl_exec($ch);
    curl_close($ch);
    fclose($buffer);
    // working with the pre-fetched page using DOMDocument
    // due to a bug (?) w/ fetching Cyrillic URLs via DOMDocument->loadHTMLFile
    $html = new DOMDocument();
    $html->loadHTMLFile("buffer.html");
    $subCats = $html->getElementById("mw-subcategories");
    if ($subCats) {
        foreach ($subCats->getElementsByTagName("a") as $s) {
            getDirectoryListing($result, $path, $s->textContent);
        }
        unset($subCats);
    }
    $pages = $html->getElementById("mw-pages");
    if ($pages) {
        foreach ($pages->getElementsByTagName("a") as $a) {
            fwrite($result, "{$path} > {$a->textContent}" . PHP_EOL);
        }
        unset($pages);
    }
}
Exemple #21
0
 public function handleError(\Dwoo\Exception $e)
 {
     $html = new \DOMDocument();
     $html->loadHTMLFile('lib/resources/exception.html');
     $message = $html->getElementById('message');
     $template = $html->createDocumentFragment();
     $template->appendXML($e->getMessage());
     $message->appendChild($template);
     unset($template);
     $php_version = $html->getElementById('php-version');
     $template = $html->createDocumentFragment();
     $template->appendXML(phpversion());
     $php_version->appendChild($template);
     unset($template);
     $dwoo_version = $html->getElementById('dwoo-version');
     $template = $html->createDocumentFragment();
     $template->appendXML(Core::VERSION);
     $dwoo_version->appendChild($template);
     unset($template);
     $exectime = $html->getElementById('exectime');
     $template = $html->createDocumentFragment();
     $template->appendXML(round(microtime(true) - $_SERVER['REQUEST_TIME'], 3));
     $exectime->appendChild($template);
     unset($template);
     echo $html->saveHTML();
 }
Exemple #22
0
 public function run()
 {
     header('Content-Type: text/html; charset=UTF-8');
     $url = $this->getUrl();
     $kategoria = $this->getKategoria();
     $dir = opendir('uploads/');
     $doc = new \DOMDocument();
     @$doc->loadHTMLFile($url);
     $xpath = new \DOMXPath($doc);
     $titles = $xpath->query('//div[@class="rendslide-box"]//div[@class="product-box"]//td[@class="label"]//p[@class="font-fitter"]');
     $links = $xpath->query('//div[@class="rendslide-box"]//div[@class="slide page"]/@onclick');
     for ($i = 0; $i < $links->length; $i++) {
         $title = iconv('UTF8', 'LATIN1', $titles->item($i)->nodeValue);
         $link = str_replace("'", "", str_replace('window.location.href=', '', $links->item($i)->value));
         $subDoc = new \DOMDocument();
         @$subDoc->loadHTMLFile($link);
         $subXpath = new \DOMXPath($subDoc);
         $src = $subXpath->query('//div[@id="product"]//div[@class="left"]//a[@class="box"]/@href')->item(0)->value;
         $ext = pathinfo($src, PATHINFO_EXTENSION);
         $description = $subDoc->saveHTML($subXpath->query('//div[@id="product"]//div[@class="right"]//div[@class="left-margin"]')->item(0));
         $permalink = $this->createPermalink($title);
         $description = iconv('UTF8', 'LATIN1', $description);
         $description = preg_replace('/<p>.<\\/p>/', '', $description);
         \DB\base\Manager::connection()->exec("\n                INSERT INTO element \n                    (label, permalink, opis, extension, kategoria_id)\n                    VALUES\n                    ('" . $title . "','" . $permalink . "','" . $description . "', '" . $ext . "'," . $kategoria . ")\n            ");
         $lastId = \DB\base\Manager::connection()->query("\n                SELECT id FROM element ORDER BY id DESC LIMIT 1\n            ")->fetchColumn();
         $imgCt = file_get_contents($src);
         $folder = 'uploads/' . $lastId;
         mkdir($folder);
         $fp = fopen($folder . "/image." . $ext, "w");
         fwrite($fp, $imgCt);
         fclose($fp);
     }
 }
Exemple #23
0
function get_element_by_id($url, $id)
{
    $html = new DOMDocument();
    @$html->loadHTMLFile($url);
    $element = $html->getElementById($id);
    return $html->saveHTML($element);
}
function parseResinImprFile($file_path)
{
    global $hostDict;
    $doc = new DOMDocument();
    @$doc->loadHTMLFile($file_path);
    $query = "//table[1]/tr[@class != 'first']/td[position() < 3]";
    $xpath = new DOMXPath($doc);
    $entries = $xpath->query($query);
    $index = 0;
    $key = "";
    $value = "";
    foreach ($entries as $entry) {
        if ($index % 2 == 0) {
            $key = $entry->nodeValue;
        } else {
            $value = $entry->nodeValue;
        }
        if ($index != 0 and $index % 2 == 1) {
            if ($key == "AD_EXCHANGE.bidResult") {
                # 还不能区分bid 和 bidResult, 所以加到一起
                $key = "AD_EXCHANGE.bid";
            }
            if (array_key_exists($key, $hostDict) && !in_array($value, $hostDict[$key])) {
                array_push($hostDict[$key], $value);
            }
        }
        $index++;
    }
}
 private function getLicenses()
 {
     $licenses = array();
     $dom = new \DOMDocument();
     $dom->loadHTMLFile($this->licensesUrl);
     $xPath = new \DOMXPath($dom);
     $trs = $xPath->query('//table//tbody//tr');
     // iterate over each row in the table
     foreach ($trs as $tr) {
         $tds = $tr->getElementsByTagName('td');
         // get the columns in this row
         if ($tds->length < 4) {
             throw new \Exception('Obtaining the license table failed. Wrong table format. Found less than 4 cells in a row.');
         }
         if (trim($tds->item(3)->nodeValue) == 'License Text') {
             $fullname = trim($tds->item(0)->nodeValue);
             $identifier = trim($tds->item(1)->nodeValue);
             $osiApproved = isset($tds->item(2)->nodeValue) && $tds->item(2)->nodeValue === 'Y' ? true : false;
             // The license URL is not scraped intentionally to keep json file size low.
             // It's build when requested, see SpdxLicense->getLicenseByIdentifier().
             //$licenseURL = = $tds->item(3)->getAttribute('href');
             $licenses += array($identifier => array($fullname, $osiApproved));
         }
     }
     return $licenses;
 }
Exemple #26
0
 /**
  * 
  * @param int $stop
  * @param callable $function
  * @return array
  */
 protected function getItens($stop = 10, $function = null)
 {
     if ($this->lastTS && count($this->lastItens) > 0 && $this->lastTS + $this->reloadTime > time()) {
         return $this->lastItens;
     }
     $doc = new DOMDocument();
     if ($this->isHtml) {
         //ignorando warnings do parse
         @$doc->loadHTMLFile($this->src);
     } else {
         //ignorando warnings do parse
         @$doc->load($this->src);
     }
     $articles = $doc->getElementsByTagName($this->itemName['tagName']);
     $this->lastItens = array();
     foreach ($articles as $article) {
         if (array_key_exists('class', $this->itemName) && $article->getAttribute('class') != $this->itemName['class']) {
             continue;
         }
         /* @var $article DOMElement */
         $item = array('source' => $this->source, 'href' => $this->getValue($article, $this->href), 'img' => $this->getValue($article, $this->img), 'titulo' => $this->getValue($article, $this->titulo), 'subtitulo' => $this->getValue($article, $this->subtitulo), 'datetime' => $this->getValue($article, $this->datetime));
         if ($function) {
             $function($item);
         }
         $this->lastItens[] = $item;
     }
     $this->save();
     return array_splice($this->lastItens, 0, $stop);
 }
Exemple #27
0
 public function run()
 {
     header('Content-Type: text/html; charset=utf-8');
     $url = $this->getUrl();
     $kategoria = $this->getKategoria();
     $dir = opendir('uploads/');
     $doc = new \DOMDocument();
     @$doc->loadHTMLFile($url);
     $xpath = new \DOMXPath($doc);
     $links = $xpath->query('//td[@class="main_table"]//td[@class="right"]//table[@class="tekst"]//td[@class="product_list_foto"]//a/@href');
     $titles = $xpath->query('//td[@class="main_table"]//td[@class="right"]//table[@class="tekst"]//td[@class="product_list_data"]//span[@class="product_list_name"]');
     $desc = $xpath->query('//td[@class="main_table"]//td[@class="right"]//table[@class="tekst"]//td[@class="product_list_data"]//td[@class="product_list_desc"]');
     for ($i = 0, $j = 0; $i < $links->length; $i++, $j = $j + 2) {
         $description = $doc->saveHTML($desc->item($j));
         $description = strip_tags($description, '<p><div><br>');
         $title = $titles->item($i)->nodeValue;
         $src = self::PREFIX_TO_IMAGES . $links->item($i)->value;
         $ext = pathinfo($src, PATHINFO_EXTENSION);
         $permalink = $this->createPermalink($title);
         \DB\base\Manager::connection()->exec("\n                INSERT INTO element \n                    (label, permalink, opis, extension, kategoria_id)\n                    VALUES\n                    ('" . $title . "','" . $permalink . "','" . $description . "', '" . $ext . "'," . $kategoria . ")\n            ");
         $lastId = \DB\base\Manager::connection()->query("\n                SELECT id FROM element ORDER BY id DESC LIMIT 1\n            ")->fetchColumn();
         $imgCt = file_get_contents($src);
         $folder = 'uploads/' . $lastId;
         mkdir($folder);
         $fp = fopen($folder . "/image." . $ext, "w");
         fwrite($fp, $imgCt);
         fclose($fp);
     }
 }
Exemple #28
0
 /**
  * Object constructor
  *
  * @param string  $data
  * @param boolean $isFile
  * @param boolean $storeContent
  */
 private function __construct($data, $isFile, $storeContent)
 {
     $this->_doc = new DOMDocument();
     $this->_doc->substituteEntities = true;
     if ($isFile) {
         @$this->_doc->loadHTMLFile($data);
     } else {
         @$this->_doc->loadHTML($data);
     }
     $xpath = new DOMXPath($this->_doc);
     $docTitle = '';
     $titleNodes = $xpath->query('/html/head/title');
     foreach ($titleNodes as $titleNode) {
         // title should always have only one entry, but we process all nodeset entries
         $docTitle .= $titleNode->nodeValue . ' ';
     }
     $this->addField(Zend_Search_Lucene_Field::Text('title', $docTitle, $this->_doc->actualEncoding));
     $metaNodes = $xpath->query('/html/head/meta[@name]');
     foreach ($metaNodes as $metaNode) {
         $this->addField(Zend_Search_Lucene_Field::Text($metaNode->getAttribute('name'), $metaNode->getAttribute('content'), $this->_doc->actualEncoding));
     }
     $docBody = '';
     $bodyNodes = $xpath->query('/html/body');
     foreach ($bodyNodes as $bodyNode) {
         // body should always have only one entry, but we process all nodeset entries
         $this->_retrieveNodeText($bodyNode, $docBody);
     }
     if ($storeContent) {
         $this->addField(Zend_Search_Lucene_Field::Text('body', $docBody, $this->_doc->actualEncoding));
     } else {
         $this->addField(Zend_Search_Lucene_Field::UnStored('body', $docBody, $this->_doc->actualEncoding));
     }
     $linkNodes = $this->_doc->getElementsByTagName('a');
     foreach ($linkNodes as $linkNode) {
         if (($href = $linkNode->getAttribute('href')) != '') {
             $this->_links[] = $href;
         }
     }
     $this->_links = array_unique($this->_links);
     $linkNodes = $xpath->query('/html/head/link');
     foreach ($linkNodes as $linkNode) {
         if (($href = $linkNode->getAttribute('href')) != '') {
             $this->_headerLinks[] = $href;
         }
     }
     $this->_headerLinks = array_unique($this->_headerLinks);
 }
	function __construct($htmlFilePath)
	{
		$this->filePath = $htmlFilePath;
		$this->fileInfo = new \SplFileInfo($htmlFilePath);
		$domDoc = new \DOMDocument();
		$domDoc->loadHTMLFile($htmlFilePath);
		$this->initialize($domDoc);
	}
Exemple #30
0
 public function setDOMForLN($lnTitle)
 {
     $lnTitle = str_replace(" ", "_", $lnTitle);
     $link = $this->lnDBLink . $lnTitle;
     $dom = new DOMDocument();
     $dom->loadHTMLFile($link);
     $this->lnMainHTML = $dom->saveHTML();
 }