function fetch_data_from_html($remote_page)
{
    // Returns an array of products and ratings
    $product_rating_arr = array();
    $html = get_html($remote_page);
    $dom = new domDocument();
    $dom->loadHTML($html);
    $dom->preserveWhiteSpace = false;
    $tables = $dom->getElementsByTagName('table');
    $table = $tables->item(0);
    $rows = $table->getElementsByTagName('tr');
    $i = 0;
    foreach ($rows as $row) {
        if ($i != 0) {
            $columns = $row->getElementsByTagName('td');
            $product = $columns->item(0)->textContent;
            $rating = $columns->item(1)->textContent;
            $image = $columns->item(2)->textContent;
            $var = $product . "__" . $image;
            $product_rating_arr[$var] = $rating;
        }
        $i += 1;
    }
    return $product_rating_arr;
}
 public static function read_manifest()
 {
     global $base_path;
     $informations = array();
     @ini_set("zend.ze1_compatibility_mode", "0");
     $manifest = new domDocument();
     $module_path = realpath(dirname($base_path . "/cms/modules/" . str_replace("cms_module_", "", get_called_class()) . "/" . get_called_class() . ".class.php"));
     $manifest->load($module_path . "/manifest.xml");
     //on récupère le nom
     $name = $manifest->getElementsByTagName("name")->item(0);
     $informations['informations']['name'] = cms_module_root::charset_normalize($name->nodeValue, "utf-8");
     //on récupère le(les) auteur(s)
     $informations['informations']['author'] = array();
     $authors = $manifest->getElementsByTagName("author");
     for ($i = 0; $i < $authors->length; $i++) {
         $author = array();
         //on récupère son nom
         $author['name'] = cms_module_root::charset_normalize($authors->item($i)->getElementsByTagName('name')->item(0)->nodeValue, "utf-8");
         //on récupère son organisation
         $organisation = $authors->item($i)->getElementsByTagName("organisation");
         if ($organisation->length > 0) {
             $author['organisation'] = cms_module_root::charset_normalize($organisation->item(0)->nodeValue, "utf-8");
         }
         $informations['informations']['author'][] = $author;
     }
     //on récupère les dates
     $created_date = $manifest->getElementsByTagName("created_date")->item(0);
     $informations['informations']['created_date'] = cms_module_root::charset_normalize($created_date->nodeValue, "utf-8");
     $updated_date = $manifest->getElementsByTagName("updated_date");
     if ($updated_date->length > 0) {
         $informations['informations']['updated_date'] = cms_module_root::charset_normalize($updated_date->item(0)->nodeValue, "utf-8");
     }
     //on récupère la version
     $version = $manifest->getElementsByTagName("version")->item(0);
     $informations['informations']['version'] = cms_module_root::charset_normalize($version->nodeValue, "utf-8");
     // on récupère la langue par défaut du module...
     $informations['informations']['default_language'] = self::get_module_default_language($manifest);
     // administrable?
     $informations['informations']['managed'] = $manifest->getElementsByTagName("managed") && $manifest->getElementsByTagName("managed")->item(0)->nodeValue == "true" ? true : false;
     //fournisseur de liens?
     $informations['informations']['extension_form'] = $manifest->getElementsByTagName("extension_form") && $manifest->getElementsByTagName("extension_form")->item(0)->nodeValue == "true" ? true : false;
     @ini_set("zend.ze1_compatibility_mode", "0");
     //on récupère la listes des éléments utilisés par le module...
     $use = $manifest->getElementsbyTagName("use")->item(0);
     $informations['elements_used'] = self::read_elements_used($use);
     @ini_set("zend.ze1_compatibility_mode", "1");
     return $informations;
 }
 public function findWspolrzedne($adres, $miasto)
 {
     $adresTrim = trim($adres);
     $adresReplaceSpace = str_replace(' ', '+', $adresTrim);
     $LettersToChange = array('ó', 'ż', 'ź', 'ś', 'ę', 'ą', 'ł', 'ń', 'ć');
     $LettersChanged = array('o', 'z', 'z', 's', 'e', 'a', 'l', 'n', 'c');
     $adresWithoutPolishLetters = str_replace($LettersToChange, $LettersChanged, $adresReplaceSpace);
     $curl1 = curl_init();
     curl_setopt($curl1, CURLOPT_URL, "http://www.zumi.pl/namapie.html?qt=&loc={$miasto}%2C+{$adresWithoutPolishLetters}&Submit=Szukaj&cId=&sId=");
     curl_setopt($curl1, CURLOPT_RETURNTRANSFER, 1);
     $stronaZumi = curl_exec($curl1);
     curl_close($curl1);
     $dom = new domDocument();
     @$dom->loadHTML($stronaZumi);
     $dom->preserveWhiteSpace = false;
     $szukana = array();
     $divs = $dom->getElementsByTagName('div');
     foreach ($divs as $div) {
         $script = $div->getElementsByTagName('script');
         $szukana[] = $script->item(0)->nodeValue;
     }
     foreach ($szukana as $text) {
         if (strpos($text, 'objDefLoc')) {
             $a = substr($text, -29);
             $letterToRemove = array(':', '"', 'y', 'x', '}');
             $wspolrzedne1 = str_replace($letterToRemove, '', $a);
             $poz = strpos($wspolrzedne1, ',');
             $dlugosc = substr($wspolrzedne1, $poz);
             $dlugosc = str_replace(',', '', $dlugosc);
             $szerokosc = substr($wspolrzedne1, 0, $poz);
             $wspolrzedne[] = "{$dlugosc},{$szerokosc}";
         }
     }
     return $wspolrzedne[0];
 }
示例#4
0
文件: dz.php 项目: echmaster/data
function viewInfo($node)
{
    if ($_POST["model1"] == "telefon") {
        $nameEl = "телефона";
    }
    if ($_POST["model2"] == "noutbuk") {
        $nameEl = "ноутбука";
    }
    if ($_POST["model3"] == "printer") {
        $nameEl = "принтера";
    }
    echo "<tr>\n\t\t<td><b>Марка " . $nameEl . "</b>\n\t\t</td><td><b>Год выпуска</b>\n\t</td></tr>";
    $document = new domDocument("1.0", "utf-8");
    $document->load("test3.xml");
    $nodelist = $document->getElementsByTagName("model");
    $model = $nodelist->item($i);
    for ($i = 0; $i < $nodelist->length; $i++) {
        $model = $nodelist->item($i);
        if ($model->parentNode->nodeName == $node || $model->parentNode->nodeName == "asort:" . $node) {
            $name = $model->childNodes->item(0);
            $year = $model->childNodes->item(1);
            echo "<tr>\n\t\t\t\t<td>" . $name->nodeValue . "</td>\n\t\t\t\t<td align='center'>" . $year->nodeValue . "</td>\n\t\t\t</tr>";
        }
    }
}
示例#5
0
文件: rss.php 项目: vcgato29/poff
 function readContent()
 {
     $data = read_xml_file($this->server, $this->port, $this->url);
     if (strlen($data) > 0) {
         $dom = new domDocument();
         $dom->loadXML(substr($data, 0, strrpos($data, '>') + 1));
         $arrFeeds = array();
         $count = 0;
         foreach ($dom->getElementsByTagName('item') as $node) {
             if (function_exists('date_parse')) {
                 $date_raw = date_parse($node->getElementsByTagName('pubDate')->item(0)->nodeValue);
                 //$date = date('H:i j.m.Y', mktime($date_raw['hour'], $date_raw['minute'], $date_raw['second'], $date_raw['month'], $date_raw['day'], $date_raw['year']));
                 $date = date('j.m', mktime($date_raw['hour'], $date_raw['minute'], $date_raw['second'], $date_raw['month'], $date_raw['day'], $date_raw['year']));
             } else {
                 $date1 = explode(' ', $node->getElementsByTagName('pubDate')->item(0)->nodeValue);
                 $months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
                 $months_n = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
                 $time = explode(':', $date1[4]);
                 //$date = $time[0] . ':' . $time[1] . ' ' . intval($date1[1]) . '.' . str_replace($months, $months_n, $date1[2]) . '.' . $date1[3];
                 $date = intval($date1[1]) . '.' . str_replace($months, $months_n, $date1[2]);
             }
             $itemRSS = array('title' => mb_convert_case(!$this->decodeUTF ? utf8_decode($node->getElementsByTagName('title')->item(0)->nodeValue) : $node->getElementsByTagName('title')->item(0)->nodeValue, MB_CASE_UPPER, "UTF-8"), 'description' => substr(!$this->decodeUTF ? utf8_decode($node->getElementsByTagName('description')->item(0)->nodeValue) : $node->getElementsByTagName('description')->item(0)->nodeValue, 0, 60), 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue);
             $itemRSS['date'] = $date;
             array_push($arrFeeds, $itemRSS);
             $count++;
             if ($count == $this->nr_of_posts) {
                 break;
             }
         }
         return $arrFeeds;
     }
     return null;
 }
示例#6
0
文件: User.php 项目: echmaster/data
		public function addUser(){
			$document = new domDocument();
			$document->load("users/users.xml");
			$root = $document->getElementsByTagName("users")->item(0);
			$user = $root->appendChild(new domElement("user"));
			$user->appendChild($document->createElement("login", "$this->login"));
			$user->appendChild($document->createElement("password","$this->pass"));
			$document->save("users/users.xml");
		}
示例#7
0
 public function findMonitor($szukana)
 {
     $curl1 = curl_init();
     curl_setopt($curl1, CURLOPT_URL, "http://www.samsung.com/pl/function/espsearch/searchResult.do?keywords={$szukana}&amp;input_keyword={$szukana}");
     curl_setopt($curl1, CURLOPT_RETURNTRANSFER, 1);
     $strona1 = curl_exec($curl1);
     curl_close($curl1);
     $dom1 = new domDocument();
     @$dom1->loadHTML($strona1);
     $dom1->preserveWhiteSpace = false;
     $nazwa = array();
     $a = $dom1->getElementsByTagName('a');
     foreach ($a as $a) {
         $class = $a->getAttribute('class');
         $href = $a->getAttribute('href');
         $nazwa[$class] = $href;
     }
     $nazwa2 = $nazwa['arrow_blue'];
     $url = "{$nazwa2}&tab=specification";
     $curl2 = curl_init();
     curl_setopt($curl2, CURLOPT_URL, "{$url}");
     curl_setopt($curl2, CURLOPT_RETURNTRANSFER, 1);
     $strona2 = curl_exec($curl2);
     curl_close($curl2);
     $tabela = array();
     $dom2 = new domDocument();
     @$dom2->loadHTML($strona2);
     $dom2->preserveWhiteSpace = false;
     $nazwa = $dom2->getElementsByTagName('h1');
     $tabela['nazwa'] = $nazwa->item(0)->nodeValue;
     $rows = $dom2->getElementsByTagName('tr');
     foreach ($rows as $row) {
         $th = $row->getElementsByTagName('th');
         $nazwa = $th->item(0)->nodeValue;
         $nazwa2 = $th->item(1)->nodeValue;
         $td = $row->getElementsByTagName('td');
         $wartosc = $td->item(0)->nodeValue;
         $tabela[trim($nazwa)] = trim($wartosc);
         $tabela[trim($nazwa2)] = trim($wartosc);
     }
     $correctTable = $this->removeAllWrongValueFromTable($tabela);
     return $correctTable;
 }
示例#8
0
function bench2()
{
    global $XML;
    $dom = new domDocument();
    $dom->loadxml($XML);
    $children = $dom->getElementsByTagName('title');
    foreach ($children as $v) {
        $arr[] = $v->nodeValue;
    }
    return $arr;
}
 public function __construct($html, $baseurl)
 {
     $doc = new domDocument();
     $doc->loadHTML($html);
     $this->body = $doc->getElementsByTagName('html')->item(0)->getElementsByTagName('body')->item(0);
     $this->lines = array();
     $this->line = (object) array('text' => '', 'wrap' => true, 'prefix' => "\n");
     $this->pre = 0;
     $this->indent = array();
     $this->baseurl = $baseurl;
     $this->links = array();
     $this->linkcount = 0;
 }
示例#10
0
function get_pre($url)
{
    $html = file_get_contents($url);
    // a new dom object
    $dom = new domDocument('1.0', 'utf-8');
    // load the html into the object ***/
    @$dom->loadHTML($html);
    //discard white space
    $dom->preserveWhiteSpace = false;
    $pre = $dom->getElementsByTagName('pre');
    //Get elements by desired tag.
    return htmlspecialchars($pre->item(0)->nodeValue);
}
 function prepareContent($content)
 {
     if (!$content) {
         return '';
     }
     $dom = new domDocument();
     $dom->loadHTML('<?xml encoding="UTF-8">' . $content);
     $images = $dom->getElementsByTagName('img');
     foreach ($images as $image) {
         $src = $image->getAttribute('src');
         $image->setAttribute('src', site_url($src));
     }
     return $dom->saveHTML();
 }
示例#12
0
 function get_instituicao_cursos($cod_endereco, $cod_instituicao)
 {
     $html = file_get_contents('http://emec.mec.gov.br/emec/consulta-ies/listar-curso-endereco/d96957f455f6405d14c6542552b0f6eb/' . base64_encode($cod_instituicao) . '/aa547dc9e0377b562e2354d29f06085f/' . base64_encode($cod_endereco) . '/list/1000');
     include_once './src/simple_html_dom.php';
     $dom = new domDocument();
     @$dom->loadHTML($html);
     $dom->preserveWhiteSpace = false;
     $tables = $dom->getElementsByTagName('tbody');
     foreach ($tables as $row) {
         $cols = $row->getElementsByTagName('td');
         $array[] = preg_replace("/[^A-Za-z]/", "", $cols->item(0)->nodeValue);
     }
     return $array;
 }
示例#13
0
 private function parseTags($tag = '', $source = "")
 {
     if (!$tag) {
         throw new Exception\CrawlException('Tag has type of null');
     }
     /*** a new dom object ***/
     $dom = new \domDocument();
     @$dom->loadHTML($source);
     /*** remove silly white space ***/
     $dom->preserveWhiteSpace = false;
     /*** get the links from the HTML ***/
     //  $tag->setTag('a');
     $tags = $dom->getElementsByTagName($tag);
     return $tags;
 }
示例#14
0
 function readhtml()
 {
     $dom = new domDocument();
     $dom->loadHTMLFile("docs/KUNNAMKUL.html");
     $dom->preserveWhiteSpace = false;
     $tables = $dom->getElementsByTagName('table');
     /*** get all rows from the table ***/
     $rows = $tables->item(0)->getElementsByTagName('tr');
     /*** loop over the table rows ***/
     $dataArray = array();
     foreach ($rows as $row) {
         /*** get each column by tag name ***/
         $cols = $row->getElementsByTagName('td');
         /*** echo the values ***/
         if ($cols->item(0)->nodeValue) {
             $tmpArray = array();
             $tmpArray[] = $cols->item(0)->nodeValue;
             $name = $cols->item(1)->getElementsByTagName('p');
             $tmpArray[] = $name->item(0)->nodeValue;
             $tmpstring = isset($name->item(1)->nodeValue) ? $name->item(1)->nodeValue : '';
             $tmpstring .= isset($name->item(2)->nodeValue) ? $name->item(2)->nodeValue : '';
             $tmpstring .= isset($name->item(3)->nodeValue) ? $name->item(3)->nodeValue : '';
             $tmpArray[] .= $tmpstring;
             //$tmpArray[]=$cols->item(1)->nodeValue;
             $bsdob = $cols->item(2)->getElementsByTagName('p');
             $tmpArray[] = $bsdob->item(0)->nodeValue;
             $tmpArray[] = isset($bsdob->item(1)->nodeValue) ? $bsdob->item(1)->nodeValue : '';
             $tmpArray[] = isset($bsdob->item(2)->nodeValue) ? $bsdob->item(2)->nodeValue : '';
             //$tmpArray[]=$bsdob->item(2)->nodeValue;
             $factorinfo = $cols->item(3)->getElementsByTagName('p');
             $tmpArray[] = isset($factorinfo->item(0)->nodeValue) ? $factorinfo->item(0)->nodeValue : '';
             $tmpArray[] = isset($factorinfo->item(1)->nodeValue) ? $factorinfo->item(1)->nodeValue : '';
             $dpan = $cols->item(4)->getElementsByTagName('p');
             $tmpArray[] = $dpan->item(0)->nodeValue;
             $tmpArray[] = isset($dpan->item(1)->nodeValue) ? $dpan->item(1)->nodeValue : '';
             $tmpArray[] = isset($dpan->item(2)->nodeValue) ? $dpan->item(2)->nodeValue : '';
             $dataArray[] = $tmpArray;
         }
     }
     $this->load->library('table');
     $tmpl = array('table_open' => '<table border="1" cellpadding="2" cellspacing="1" class="mytable">');
     $this->table->set_template($tmpl);
     echo $this->table->generate($dataArray);
 }
 private function _grab($date)
 {
     $content = new domDocument();
     // кривая разметка камы
     @$content->loadHTML(file_get_contents($this->_url . '?date=' . date('Y-m-d', $date)));
     $rows = $content->getElementsByTagName('tr');
     $result = array();
     for ($i = 2; $i < $rows->length; $i++) {
         $cols = $rows->item($i)->getElementsByTagName('td');
         $item = array('title' => $cols->item(1)->nodeValue, 'description' => 'Зал: ' . $cols->item(4)->nodeValue, 'fire_at' => date('Y-m-d ', $date) . trim(substr($cols->item(0)->nodeValue, 2)));
         if ($cols->item(4)->nodeValue == 1) {
             $item['description'] .= sprintf("\n\nЭконом: %s р.\nVIP: %s р.", $cols->item(2)->nodeValue, $cols->item(3)->nodeValue);
         } else {
             $item['description'] .= sprintf("\n\nЦена: %s р.", $cols->item(3)->nodeValue);
         }
         $result[] = $item;
     }
     return $result;
 }
示例#16
0
 public function getPrice($marka, $nazwa)
 {
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, "http://www.ceneo.pl/Monitory;004+s{$marka}~~M{$nazwa}");
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     $strona = curl_exec($curl);
     curl_close($curl);
     $dom = new domDocument();
     @$dom->loadHTML($strona);
     $dom->preserveWhiteSpace = false;
     $table = array();
     $bigs = $dom->getElementsByTagName('big');
     foreach ($bigs as $big) {
         $strong = $big->getElementsByTagName('strong');
         $cena = $strong->item(0)->nodeValue;
         $table[] = $cena;
     }
     return $table[0];
 }
示例#17
0
 function parse_content()
 {
     $this->im = "";
     if ($this->content == "") {
         return;
     }
     $dom = new domDocument();
     @$dom->loadHTML($this->content);
     $dom->preserveWhiteSpace = false;
     @($images = $dom->getElementsByTagName('img'));
     if ($images->length > 0) {
         if ($images->length > $this->imagenum) {
             $this->im = $images->item($this->imagenum)->getAttribute('src');
         } else {
             $this->imagenum = 0;
             $this->im = $images->item(0)->getAttribute('src');
         }
     }
 }
示例#18
0
function getUnfilteredWebData($place_origin, $name_origin, $place_destination, $type_destination)
{
    global $config_url_efa;
    $curl_conenction = prepare_curl_connection($config_url_efa);
    $post_data = build_post_array($place_origin, $name_origin, $place_destination, $type_destination);
    $result = execute_curl_connection($curl_conenction, $post_data);
    /*** a new dom object ***/
    $dom = new domDocument();
    @$dom->loadHTML($result);
    $dom->preserveWhiteSpace = false;
    $table_list = $dom->getElementsByTagName('table');
    foreach ($table_list as $table) {
        if ($table->hasAttributes()) {
            foreach ($table->attributes as $attribute) {
                if ($attribute->value == "100%") {
                    $dom_ele_timetable = $table;
                    break;
                }
            }
        }
    }
    $xml_string = str_replace("&#13;", "", $dom->saveXML($dom_ele_timetable));
    return $xml_string;
}
示例#19
0
 public function mapPost($blog, $strip_tags = '', $text_length = 0, $skip = array())
 {
     $creator = JFactory::getUser($blog->created_by);
     $item = new PostSimpleSchema();
     $item->textplain = $blog->fulltext;
     $item->postid = $blog->id;
     $item->title = $blog->title;
     $item->introtext = $this->sanitize($blog->introtext);
     $item->text = $this->sanitize($blog->fulltext);
     if (empty($item->text)) {
         $item->text = $blog->introtext . " " . $blog->fulltext;
         $item->textplain = $blog->introtext . " " . $blog->fulltext;
     }
     $item->textplain = $item->textplain;
     $item->image = new stdClass();
     $img_obj = json_decode($blog->images);
     if (isset($img_obj->image_intro)) {
         $item->image->intro_url = (string) JURI::root() . $img_obj->image_intro;
         $item->image->full_image_url = JURI::root() . $img_obj->image_fulltext;
     } else {
         $item->image->intro_url = null;
         $item->image->full_image_url = null;
     }
     $item->created_date = JHTML::_('date', $blog->created, JText::_('DATE_FORMAT_LC2'));
     $item->author->name = $creator->username;
     $item->author->photo = null;
     $item->category->categoryid = $blog->catid;
     $item->category->title = $blog->category_title;
     $item->url = JURI::root() . trim('index.php?option=com_content&view=article&id=' . $item->postid . ':' . $blog->alias);
     //load content module and position
     $c_obj = new BlogappContentHelper();
     $c_obj->loadContent($item);
     if (strpos($item->text, 'src="data:image') == false) {
         if (strpos($item->text, 'href="images')) {
             $item->introtext = str_replace('href="images', 'href="' . JURI::root() . 'images', $item->introtext);
             $item->text = str_replace('href="images', 'href="' . JURI::root() . 'images', $item->text);
             //$item->text = str_replace('src="','src="'.JURI::root(),$item->text);
         }
         if (strpos($item->text, 'src="images')) {
             $item->introtext = str_replace('src="', 'src="' . JURI::root(), $item->introtext);
             $item->text = str_replace('src="', 'src="' . JURI::root(), $item->text);
         }
         if (strpos($item->text, 'src="/')) {
             $item->introtext = str_replace('src="/', 'src="' . 'http://', $item->introtext);
             $item->text = str_replace('src="/', 'src="' . 'http://', $item->text);
         }
         if (strpos($item->text, 'href="/')) {
             $item->introtext = str_replace('href="/', 'href="' . 'http://', $item->introtext);
             $item->text = str_replace('href="/', 'href="' . 'http://', $item->text);
         }
     }
     if (empty($item->image->url)) {
         $dom = new domDocument();
         $dom->loadHTML($item->text);
         $dom->preserveWhiteSpace = false;
         $images = $dom->getElementsByTagName('img');
         foreach ($images as $img) {
             $item->image->url = $img->getAttribute('src');
             if (!empty($item->image->url)) {
                 break;
             }
         }
     }
     return $item;
 }
示例#20
0
function getImage($html)
{
    if ($html != "") {
        $dom = new domDocument();
        $dom->loadHTML($html);
        $dom->preserveWhiteSpace = false;
        $images = $dom->getElementsByTagName('img');
        foreach ($images as $image) {
            return $image->getAttribute('src');
        }
    }
}
 /**
  * Gets images from post body
  *
  * @param string $postContent body of WordPress post
  *
  * @return array/bool Array of urls to remote assets
  */
 private function _getImageUrlsFromPost($postContent)
 {
     if (empty($postContent)) {
         return false;
     }
     $images = array();
     $dom = new \domDocument();
     // load the html into the object
     $dom->loadHTML($postContent);
     // discard white space
     $dom->preserveWhiteSpace = false;
     $imgEls = $dom->getElementsByTagName('img');
     foreach ($imgEls as $img) {
         $images[$img->getAttribute('src')] = array('alt' => $img->getAttribute('alt'), 'src' => $img->getAttribute('src'), 'height' => $img->getAttribute('height'), 'width' => $img->getAttribute('width'));
     }
     return $images;
 }
示例#22
0
 function generate($tbl)
 {
     session_start();
     $_SESSION['zprofile'] = 'yes';
     $_SESSION['zprofile']['username'] = '******';
     $_SESSION['zprofile']['useremail'] = '*****@*****.**';
     $_SESSION['zprofile']['usercompany'] = 'hehehahhaha';
     $_GET['var'] = 'tbl_tes';
     $_SESSION['tbl_tes'] = $tbl;
     /* $_SESSION['tbl_tes'] = '
     <table border="1">
     	<thead>
     		<tr bgcolor="yellow">
     			<th>no</th>
     			<th>col1</th>
     			<th>col2</th>
     			<th>col3</th>
     			<th>col4</th>
     		</tr>
     	</thead>
     	<tbody>
     		<tr>
     			<td>1</td>
     			<td>B2</td>
     			<td>C2</td>
     			<td rowspan="2">D2</td>
                 <td>E3</td>
     		</tr>
     		<tr>
     			<td>2</td>
     			<td colspan="2">B3</td>
     			<td>C3</td>
     		</tr>
     		<tr>
     			<td>3</td>
     			<td>B4</td>
     			<td colspan="2" rowspan="2">C4</td>
     			<td>D4</td>
     		</tr>
     		<tr>
     			<td>4</td>
     			<td>
                     B5<img src="././assets/img/ecsi.png" name="gambar tes" title="hehehe coba titlenya" width="100" height="100">
     			<td><b>C5</b></td>
     		</tr>
     	</tbody>
     </table>
     '; */
     //echo $_SESSION['tbl_tes'];exit();
     ini_set("memory_limit", "-1");
     ini_set("set_time_limit", "0");
     set_time_limit(0);
     if (isset($_SESSION['zprofile'])) {
         $username = $_SESSION['zprofile']['username'];
         // user's name
         $usermail = $_SESSION['zprofile']['useremail'];
         // user's emailid
         $usercompany = $_SESSION['zprofile']['usercompany'];
         // user's company
     } else {
         header('Location: index.php?e=0');
     }
     if (!isset($_GET['var'])) {
         echo "<br />No Table Variable Present, nothing to Export.";
         exit;
     } else {
         $tablevar = $_GET['var'];
     }
     if (!isset($_GET['limit'])) {
         $limit = 12;
     } else {
         $limit = $_GET['limit'];
     }
     if (!isset($_GET['debug'])) {
         $debug = false;
     } else {
         $debug = true;
         $handle = fopen("Auditlog/exportlog.txt", "w");
         fwrite($handle, "\nDebugging On...");
     }
     if (!isset($_SESSION[$tablevar]) or $_SESSION[$tablevar] == '') {
         echo "<br />Empty HTML Table, nothing to Export.";
         exit;
     } else {
         $htmltable = $_SESSION[$tablevar];
     }
     if (strlen($htmltable) == strlen(strip_tags($htmltable))) {
         echo "<br />Invalid HTML Table after Stripping Tags, nothing to Export.";
         exit;
     }
     $htmltable = strip_tags($htmltable, "<table><tr><th><thead><tbody><tfoot><td><br><br /><b><span><img><img />");
     $htmltable = str_replace("<br />", "\n", $htmltable);
     $htmltable = str_replace("<br/>", "\n", $htmltable);
     $htmltable = str_replace("<br>", "\n", $htmltable);
     $htmltable = str_replace("&nbsp;", " ", $htmltable);
     $htmltable = str_replace("\n\n", "\n", $htmltable);
     //
     //  Extract HTML table contents to array
     //
     $dom = new domDocument();
     $dom->loadHTML($htmltable);
     if (!$dom) {
         echo "<br />Invalid HTML DOM, nothing to Export.";
         exit;
     }
     $dom->preserveWhiteSpace = false;
     // remove redundant whitespace
     $tables = $dom->getElementsByTagName('table');
     if (!is_object($tables)) {
         echo "<br />Invalid HTML Table DOM, nothing to Export.";
         exit;
     }
     if ($debug) {
         fwrite($handle, "\nTable Count: " . $tables->length);
     }
     $tbcnt = $tables->length - 1;
     // count minus 1 for 0 indexed loop over tables
     if ($tbcnt > $limit) {
         $tbcnt = $limit;
     }
     //
     //
     // Create new PHPExcel object with default attributes
     //
     require_once 'PHPExcel/PHPExcel.php';
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
     $objPHPExcel->getDefaultStyle()->getFont()->setSize(9);
     $tm = date(YmdHis);
     $pos = strpos($usermail, "@");
     $user = substr($usermail, 0, $pos);
     $user = str_replace(".", "", $user);
     $tfn = $user . "_" . $tm . "_" . $tablevar . ".xlsx";
     //$fname = "AuditLog/".$tfn;
     $fname = $tfn;
     $objPHPExcel->getProperties()->setCreator($username)->setLastModifiedBy($username)->setTitle("Automated Export")->setSubject("Automated Report Generation")->setDescription("Automated report generation.")->setKeywords("Exported File")->setCompany($usercompany)->setCategory("Export");
     //
     // Loop over tables in DOM to create an array, each table becomes a worksheet
     //
     for ($z = 0; $z <= $tbcnt; $z++) {
         $maxcols = 0;
         $totrows = 0;
         $headrows = array();
         $bodyrows = array();
         $r = 0;
         $h = 0;
         $rows = $tables->item($z)->getElementsByTagName('tr');
         $totrows = $rows->length;
         if ($debug) {
             fwrite($handle, "\nTotal Rows: " . $totrows);
         }
         foreach ($rows as $row) {
             $ths = $row->getElementsByTagName('th');
             if (is_object($ths)) {
                 if ($ths->length > 0) {
                     $headrows[$h]['colcnt'] = $ths->length;
                     if ($ths->length > $maxcols) {
                         $maxcols = $ths->length;
                     }
                     $nodes = $ths->length - 1;
                     for ($x = 0; $x <= $nodes; $x++) {
                         $thishdg = $ths->item($x)->nodeValue;
                         $headrows[$h]['th'][] = $thishdg;
                         $headrows[$h]['bold'][] = $this->findWrapText('b', $this->innerHTML($ths->item($x)));
                         $headrows[$h]['italic'][] = $this->findWrapText('i', $this->innerHTML($ths->item($x)));
                         $headrows[$h]['underline'][] = $this->findWrapText('u', $this->innerHTML($ths->item($x)));
                         if ($ths->item($x)->hasAttribute('style')) {
                             $style = $ths->item($x)->getAttribute('style');
                             $stylecolor = $this->findStyleCSS('color', $style);
                             if ($stylecolor == '') {
                                 $headrows[$h]['color'][] = $this->findSpanColor($this->innerHTML($ths->item($x)));
                             } else {
                                 $headrows[$h]['color'][] = $stylecolor;
                             }
                             $headrows[$h]['font_name'][] = $this->findStyleCSS('font-family', $style);
                             $headrows[$h]['font_size'][] = $this->findStyleCSS('font-size', $style);
                             $headrows[$h]['border_top'][] = $this->findStyleCSS('border-top', $style);
                             $headrows[$h]['border_bottom'][] = $this->findStyleCSS('border-bottom', $style);
                             $headrows[$h]['border_left'][] = $this->findStyleCSS('border-left', $style);
                             $headrows[$h]['border_right'][] = $this->findStyleCSS('border-right', $style);
                         } else {
                             $headrows[$h]['color'][] = $this->findSpanColor($this->innerHTML($ths->item($x)));
                         }
                         if ($ths->item($x)->hasAttribute('colspan')) {
                             $headrows[$h]['colspan'][] = $ths->item($x)->getAttribute('colspan');
                         } else {
                             $headrows[$h]['colspan'][] = 1;
                         }
                         if ($ths->item($x)->hasAttribute('rowspan')) {
                             $headrows[$h]['rowspan'][] = $ths->item($x)->getAttribute('rowspan');
                         } else {
                             $headrows[$h]['rowspan'][] = 1;
                         }
                         if ($ths->item($x)->hasAttribute('align')) {
                             $headrows[$h]['align'][] = $ths->item($x)->getAttribute('align');
                         } else {
                             $headrows[$h]['align'][] = 'left';
                         }
                         if ($ths->item($x)->hasAttribute('valign')) {
                             $headrows[$h]['valign'][] = $ths->item($x)->getAttribute('valign');
                         } else {
                             $headrows[$h]['valign'][] = 'top';
                         }
                         if ($ths->item($x)->hasAttribute('bgcolor')) {
                             $headrows[$h]['bgcolor'][] = str_replace("#", "", $ths->item($x)->getAttribute('bgcolor'));
                         } else {
                             $headrows[$h]['bgcolor'][] = 'FFFFFF';
                         }
                     }
                     $h++;
                 }
             }
         }
         $iRow = 0;
         $fillCell = array();
         foreach ($rows as $row) {
             $iRow++;
             $tds = $row->getElementsByTagName('td');
             if (is_object($tds)) {
                 if ($tds->length > 0) {
                     $bodyrows[$r]['colcnt'] = $tds->length;
                     if ($tds->length > $maxcols) {
                         $maxcols = $tds->length;
                     }
                     $nodes = $tds->length - 1;
                     $iCol = 'A';
                     for ($x = 0; $x <= $nodes; $x++) {
                         $thistxt = $tds->item($x)->nodeValue;
                         $bodyrows[$r]['td'][] = $thistxt;
                         $bodyrows[$r]['img'][] = $this->collecImg($tds->item($x)->getElementsByTagName('img'));
                         $bodyrows[$r]['bold'][] = $this->findWrapText('b', $this->innerHTML($tds->item($x)));
                         $bodyrows[$r]['italic'][] = $this->findWrapText('i', $this->innerHTML($tds->item($x)));
                         $bodyrows[$r]['underline'][] = $this->findWrapText('u', $this->innerHTML($tds->item($x)));
                         if ($tds->item($x)->hasAttribute('style')) {
                             $style = $tds->item($x)->getAttribute('style');
                             $stylecolor = $this->findStyleCSS('color', $style);
                             if ($stylecolor == '') {
                                 $bodyrows[$r]['color'][] = $this->findSpanColor($this->innerHTML($tds->item($x)));
                             } else {
                                 $bodyrows[$r]['color'][] = $stylecolor;
                             }
                             $bodyrows[$h]['font_name'][] = $this->findStyleCSS('font-family', $style);
                             $bodyrows[$h]['font_size'][] = $this->findStyleCSS('font-size', $style);
                             $bodyrows[$h]['border_top'][] = $this->findStyleCSS('border-top', $style);
                             $bodyrows[$h]['border_bottom'][] = $this->findStyleCSS('border-bottom', $style);
                             $bodyrows[$h]['border_left'][] = $this->findStyleCSS('border-left', $style);
                             $bodyrows[$h]['border_right'][] = $this->findStyleCSS('border-right', $style);
                         } else {
                             $bodyrows[$r]['color'][] = $this->findSpanColor($this->innerHTML($tds->item($x)));
                         }
                         if ($tds->item($x)->hasAttribute('colspan')) {
                             $icolspan = $tds->item($x)->getAttribute('colspan');
                             $bodyrows[$r]['colspan'][] = $tds->item($x)->getAttribute('colspan');
                         } else {
                             $icolspan = 1;
                             $bodyrows[$r]['colspan'][] = 1;
                         }
                         if ($tds->item($x)->hasAttribute('rowspan')) {
                             $irowspan = $tds->item($x)->getAttribute('rowspan');
                             $bodyrows[$r]['rowspan'][] = $irowspan;
                         } else {
                             $irowspan = 1;
                             $bodyrows[$r]['rowspan'][] = 1;
                         }
                         if ($tds->item($x)->hasAttribute('align')) {
                             $bodyrows[$r]['align'][] = $tds->item($x)->getAttribute('align');
                         } else {
                             $bodyrows[$r]['align'][] = 'left';
                         }
                         if ($tds->item($x)->hasAttribute('valign')) {
                             $bodyrows[$r]['valign'][] = $tds->item($x)->getAttribute('valign');
                         } else {
                             $bodyrows[$r]['valign'][] = 'top';
                         }
                         if ($tds->item($x)->hasAttribute('bgcolor')) {
                             $bodyrows[$r]['bgcolor'][] = str_replace("#", "", $tds->item($x)->getAttribute('bgcolor'));
                         } else {
                             $bodyrows[$r]['bgcolor'][] = 'FFFFFF';
                         }
                         $lastIcol = $iCol;
                         $lastIrow = $iRow;
                         for ($ic = 1; $ic < $icolspan; $ic++) {
                             $lastIcol++;
                             $fillCell[$lastIcol . ':' . $lastIrow] = true;
                         }
                         $lastIcol = $iCol;
                         $lastIrow = $iRow;
                         for ($ir = 1; $ir < $irowspan; $ir++) {
                             $lastIrow++;
                             $fillCell[$lastIcol . ':' . $lastIrow] = true;
                         }
                         $lastIcol = $iCol;
                         $lastIrow = $iRow;
                         for ($ic = 1; $ic < $icolspan; $ic++) {
                             for ($ir = 1; $ir < $irowspan; $ir++) {
                                 $lastIrow++;
                                 $fillCell[$lastIcol . ':' . $lastIrow] = true;
                             }
                             $lastIcol++;
                             $fillCell[$lastIcol . ':' . $lastIrow] = true;
                         }
                         $iCol++;
                     }
                     $r++;
                 }
             }
         }
         //echo '<pre>';print_r($fillCell);
         //exit();
         if ($z > 0) {
             $objPHPExcel->createSheet($z);
         }
         $suf = $z + 1;
         $tableid = $tablevar . $suf;
         $wksheetname = ucfirst($tableid);
         $objPHPExcel->setActiveSheetIndex($z);
         // each sheet corresponds to a table in html
         $objPHPExcel->getActiveSheet()->setTitle($wksheetname);
         // tab name
         $worksheet = $objPHPExcel->getActiveSheet();
         // set worksheet we're working on
         $style_overlay = array('font' => array('color' => array('rgb' => '000000'), 'bold' => false), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'CCCCFF')), 'alignment' => array('wrap' => true, 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_TOP), 'borders' => array('top' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'left' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
         $xcol = '';
         $xrow = 1;
         $usedhdrows = 0;
         $heightvars = array(1 => '42', 2 => '42', 3 => '48', 4 => '52', 5 => '58', 6 => '64', 7 => '68', 8 => '76', 9 => '82');
         for ($h = 0; $h < count($headrows); $h++) {
             $th = $headrows[$h]['th'];
             $colspans = $headrows[$h]['colspan'];
             $rowspans = $headrows[$h]['rowspan'];
             $aligns = $headrows[$h]['align'];
             $valigns = $headrows[$h]['valign'];
             $bgcolors = $headrows[$h]['bgcolor'];
             $colcnt = $headrows[$h]['colcnt'];
             $colors = $headrows[$h]['color'];
             $bolds = $headrows[$h]['bold'];
             $italics = $headrows[$h]['italic'];
             $underlines = $headrows[$h]['underline'];
             $font_sizes = $headrows[$h]['font_size'];
             $font_names = $headrows[$h]['font_name'];
             $border_tops = $headrows[$h]['border_top'];
             $border_bottoms = $headrows[$h]['border_bottom'];
             $border_lefts = $headrows[$h]['border_left'];
             $border_rights = $headrows[$h]['border_right'];
             $usedhdrows++;
             $mergedcells = false;
             for ($t = 0; $t < count($th); $t++) {
                 if ($xcol == '') {
                     $xcol = 'A';
                 } else {
                     $xcol++;
                 }
                 $thishdg = $th[$t];
                 $thisalign = $aligns[$t];
                 $thisvalign = $valigns[$t];
                 $thiscolspan = (int) $colspans[$t];
                 $thisrowspan = (int) $rowspans[$t];
                 $thiscolor = $colors[$t];
                 $thisbg = $bgcolors[$t];
                 $thisbold = $bolds[$t];
                 $thisitalic = $italics[$t];
                 $thisunderline = $underlines[$t];
                 $thissize = (double) str_replace(array('pt', 'PT', 'px', 'PX'), '', $font_sizes[$t]);
                 $thissize = $thissize > 0 ? $thissize : 9;
                 $thisname = $font_names[$t];
                 $thisname = $thisname ? $thisname : 'Arial';
                 $thisbordertop = str_replace(array('px', 'PX'), '', $border_tops) > 0 && !empty($border_tops) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE;
                 $thisborderbottom = str_replace(array('px', 'PX'), '', $border_bottoms) > 0 && !empty($border_bottoms) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE;
                 $thisborderleft = str_replace(array('px', 'PX'), '', $border_lefts) > 0 && !empty($border_lefts) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE;
                 $thisborderright = str_replace(array('px', 'PX'), '', $border_rights) > 0 && !empty($border_rights) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE;
                 $strbordertop = str_replace(array('px', 'PX'), '', $border_tops) > 0 ? 'true' : 'false';
                 $strborderbottom = str_replace(array('px', 'PX'), '', $border_bottoms) > 0 ? 'true' : 'false';
                 $strborderleft = str_replace(array('px', 'PX'), '', $border_lefts) > 0 ? 'true' : 'false';
                 $strborderright = str_replace(array('px', 'PX'), '', $border_rights) > 0 ? 'true' : 'false';
                 $strbold = $thisbold == true ? 'true' : 'false';
                 $stritalic = $thisitalic == true ? 'true' : 'false';
                 $strunderline = $thisunderline == true ? 'true' : 'false';
                 if ($thisbg == 'FFFFFF') {
                     $style_overlay['fill']['type'] = PHPExcel_Style_Fill::FILL_NONE;
                 } else {
                     $style_overlay['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID;
                 }
                 $style_overlay['alignment']['vertical'] = $thisvalign;
                 // set styles for cell
                 $style_overlay['alignment']['horizontal'] = $thisalign;
                 $style_overlay['font']['color']['rgb'] = $thiscolor;
                 $style_overlay['font']['bold'] = $thisbold;
                 $style_overlay['font']['italic'] = $thisitalic;
                 $style_overlay['font']['underline'] = $thisunderline == true ? PHPExcel_Style_Font::UNDERLINE_SINGLE : PHPExcel_Style_Font::UNDERLINE_NONE;
                 $style_overlay['font']['size'] = $thissize;
                 $style_overlay['font']['name'] = $thisname;
                 $style_overlay['borders']['top']['style'] = $thisbordertop;
                 $style_overlay['borders']['bottom']['style'] = $thisborderbottom;
                 $style_overlay['borders']['left']['style'] = $thisborderleft;
                 $style_overlay['borders']['right']['style'] = $thisborderright;
                 $style_overlay['fill']['color']['rgb'] = $thisbg;
                 $worksheet->setCellValue($xcol . $xrow, $thishdg);
                 $worksheet->getStyle($xcol . $xrow)->applyFromArray($style_overlay);
                 if ($debug) {
                     fwrite($handle, "\n" . $xcol . ":" . $xrow . " Rowspan:" . $thisrowspan . " ColSpan:" . $thiscolspan . " Color:" . $thiscolor . " Align:" . $thisalign . " VAlign:" . $thisvalign . " BGColor:" . $thisbg . " Bold:" . $strbold . " Italic:" . $stritalic . " Underline:" . $strunderline . " Font-name:" . $thisname . " Font-size:" . $thissize . " Border-top: " . $strbordertop . " Border-bottom" . $strborderbottom . " Border-left:" . $strborderleft . " Border-right:" . $strborderright . " cellValue: " . $thishdg);
                 }
                 if ($thiscolspan > 1 && $thisrowspan < 1) {
                     // spans more than 1 column
                     $mergedcells = true;
                     $lastxcol = $xcol;
                     for ($j = 1; $j < $thiscolspan; $j++) {
                         $lastxcol++;
                         $worksheet->setCellValue($lastxcol . $xrow, '');
                         $worksheet->getStyle($lastxcol . $xrow)->applyFromArray($style_overlay);
                     }
                     $cellRange = $xcol . $xrow . ':' . $lastxcol . $xrow;
                     if ($debug) {
                         fwrite($handle, "\nmergeCells: " . $xcol . ":" . $xrow . " " . $lastxcol . ":" . $xrow);
                     }
                     $worksheet->mergeCells($cellRange);
                     $worksheet->getStyle($cellRange)->applyFromArray($style_overlay);
                     $num_newlines = substr_count($thishdg, "\n");
                     // count number of newline chars
                     if ($num_newlines > 1) {
                         $rowheight = $heightvars[1];
                         // default to 35
                         if (array_key_exists($num_newlines, $heightvars)) {
                             $rowheight = $heightvars[$num_newlines];
                         } else {
                             $rowheight = 75;
                         }
                         $worksheet->getRowDimension($xrow)->setRowHeight($rowheight);
                         // adjust heading row height
                     }
                     $xcol = $lastxcol;
                 }
             }
             $xrow++;
             $xcol = '';
         }
         //Put an auto filter on last row of heading only if last row was not merged
         if (!$mergedcells) {
             $worksheet->setAutoFilter("A{$usedhdrows}:" . $worksheet->getHighestColumn() . $worksheet->getHighestRow());
         }
         if ($debug) {
             fwrite($handle, "\nautoFilter: A" . $usedhdrows . ":" . $worksheet->getHighestColumn() . $worksheet->getHighestRow());
         }
         // Freeze heading lines starting after heading lines
         $usedhdrows++;
         $worksheet->freezePane("A{$usedhdrows}");
         if ($debug) {
             fwrite($handle, "\nfreezePane: A" . $usedhdrows);
         }
         //
         // Loop thru data rows and write them out
         //
         $xcol = '';
         $xrow = $usedhdrows;
         for ($b = 0; $b < count($bodyrows); $b++) {
             $td = $bodyrows[$b]['td'];
             $img = $bodyrows[$b]['img'];
             $colcnt = $bodyrows[$b]['colcnt'];
             $colspans = $bodyrows[$b]['colspan'];
             $rowspans = $bodyrows[$b]['rowspan'];
             $aligns = $bodyrows[$b]['align'];
             $valigns = $bodyrows[$b]['valign'];
             $bgcolors = $bodyrows[$b]['bgcolor'];
             $colors = $bodyrows[$b]['color'];
             $bolds = $bodyrows[$b]['bold'];
             $italics = $bodyrows[$h]['italic'];
             $underlines = $bodyrows[$h]['underline'];
             $font_sizes = $bodyrows[$h]['font_size'];
             $font_names = $bodyrows[$h]['font_name'];
             $border_tops = $bodyrows[$h]['border_top'];
             $border_bottoms = $bodyrows[$h]['border_bottom'];
             $border_lefts = $bodyrows[$h]['border_left'];
             $border_rights = $bodyrows[$h]['border_right'];
             for ($t = 0; $t < count($td); $t++) {
                 if ($xcol == '') {
                     $xcol = 'A';
                 } else {
                     $xcol++;
                 }
                 if (isset($fillCell[$xcol . ':' . $xrow])) {
                     $xcol = $this->nextCol($xcol, $xrow);
                 }
                 $thistext = $td[$t];
                 $thisimg = $img[$t];
                 $thisalign = $aligns[$t];
                 $thisvalign = $valigns[$t];
                 $thiscolspan = (int) $colspans[$t];
                 $thisrowspan = (int) $rowspans[$t];
                 $thiscolor = $colors[$t];
                 $thisbg = $bgcolors[$t];
                 $thisbold = $bolds[$t];
                 $strbold = $thisbold == true ? 'true' : 'false';
                 $thisbold = $bolds[$t];
                 $thisitalic = $italics[$t];
                 $thisunderline = $underlines[$t];
                 $thissize = (double) str_replace(array('pt', 'PT', 'px', 'PX'), '', $font_sizes[$t]);
                 $thissize = $thissize > 0 ? $thissize : 9;
                 $thisname = $font_names[$t];
                 $thisname = $thisname ? $thisname : 'Arial';
                 $thisbordertop = str_replace(array('px', 'PX'), '', $border_tops) > 0 && !empty($border_tops) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE;
                 $thisborderbottom = str_replace(array('px', 'PX'), '', $border_bottoms) > 0 && !empty($border_bottoms) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE;
                 $thisborderleft = str_replace(array('px', 'PX'), '', $border_lefts) > 0 && !empty($border_lefts) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE;
                 $thisborderright = str_replace(array('px', 'PX'), '', $border_rights) > 0 && !empty($border_rights) ? PHPExcel_Style_Border::BORDER_THIN : PHPExcel_Style_Border::BORDER_NONE;
                 $strbold = $thisbold == true ? 'true' : 'false';
                 $stritalic = $thisitalic == true ? 'true' : 'false';
                 $strunderline = $thisunderline == true ? 'true' : 'false';
                 $strbordertop = str_replace(array('px', 'PX'), '', $border_tops) > 0 ? 'true' : 'false';
                 $strborderbottom = str_replace(array('px', 'PX'), '', $border_bottoms) > 0 ? 'true' : 'false';
                 $strborderleft = str_replace(array('px', 'PX'), '', $border_lefts) > 0 ? 'true' : 'false';
                 $strborderright = str_replace(array('px', 'PX'), '', $border_rights) > 0 ? 'true' : 'false';
                 if ($thisbg == 'FFFFFF') {
                     $style_overlay['fill']['type'] = PHPExcel_Style_Fill::FILL_NONE;
                 } else {
                     $style_overlay['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID;
                 }
                 $style_overlay['alignment']['vertical'] = $thisvalign;
                 // set styles for cell
                 $style_overlay['alignment']['horizontal'] = $thisalign;
                 $style_overlay['font']['color']['rgb'] = $thiscolor;
                 $style_overlay['font']['bold'] = $thisbold;
                 $style_overlay['font']['italic'] = $thisitalic;
                 $style_overlay['font']['underline'] = $thisunderline == true ? PHPExcel_Style_Font::UNDERLINE_SINGLE : PHPExcel_Style_Font::UNDERLINE_NONE;
                 $style_overlay['font']['size'] = $thissize;
                 $style_overlay['font']['name'] = $thisname;
                 $style_overlay['borders']['top']['style'] = $thisbordertop;
                 $style_overlay['borders']['bottom']['style'] = $thisborderbottom;
                 $style_overlay['borders']['left']['style'] = $thisborderleft;
                 $style_overlay['borders']['right']['style'] = $thisborderright;
                 $style_overlay['fill']['color']['rgb'] = $thisbg;
                 if ($thiscolspan == 1) {
                     $worksheet->getColumnDimension($xcol)->setWidth(25);
                 }
                 $worksheet->setCellValue($xcol . $xrow, $thistext);
                 if (is_array($thisimg) && count($thisimg) > 0) {
                     $thisCellWidth = $worksheet->getColumnDimension($xcol)->getWidth();
                     $thisCellHeight = 0;
                     $offsetY = 5;
                     foreach ($thisimg as $Vimg) {
                         $objDrawing = new PHPExcel_Worksheet_Drawing();
                         $objDrawing->setWorksheet($worksheet);
                         $objDrawing->setName($Vimg['name']);
                         $objDrawing->setDescription($Vimg['title']);
                         $objDrawing->setPath($Vimg['src']);
                         $objDrawing->setCoordinates($xcol . $xrow);
                         $objDrawing->setOffsetX(1);
                         $objDrawing->setOffsetY($offsetY);
                         $objDrawing->setWidth($Vimg['width']);
                         $objDrawing->setHeight($Vimg['height']);
                         $thisCellHeight += $Vimg['height'];
                         if ($Vimg['width'] > $thisCellWidth) {
                             $worksheet->getColumnDimension($xcol)->setWidth($Vimg['width'] / 5);
                         }
                         if ($Vimg['height'] > 0) {
                             $worksheet->getRowDimension($xrow)->setRowHeight($thisCellHeight);
                         }
                         if ($debug) {
                             fwrite($handle, "\n Insert Image on " . $xcol . ":" . $xrow . ' src:' . $Vimg['src'] . ' Width:' . $Vimg['width'] . ' Height:' . $Vimg['height'] . ' Offset:' . $offsetY);
                         }
                         $offsetY += $Vimg['height'] + 10;
                     }
                 }
                 if ($debug) {
                     fwrite($handle, "\n" . $xcol . ":" . $xrow . " Rowspan:" . $thisrowspan . " ColSpan:" . $thiscolspan . " Color:" . $thiscolor . " Align:" . $thisalign . " VAlign:" . $thisvalign . " BGColor:" . $thisbg . " Bold:" . $strbold . " Italic:" . $stritalic . " Underline:" . $strunderline . " Font-name:" . $thisname . " Font-size:" . $thissize . " Border-top: " . $strbordertop . " Border-bottom" . $strborderbottom . " Border-left:" . $strborderleft . " Border-right:" . $strborderright . " cellValue: " . $thistext);
                 }
                 $worksheet->getStyle($xcol . $xrow)->applyFromArray($style_overlay);
                 if ($thiscolspan > 1 && $thisrowspan == 1) {
                     // spans more than 1 column
                     $lastxcol = $xcol;
                     for ($j = 1; $j < $thiscolspan; $j++) {
                         $lastxcol++;
                     }
                     $cellRange = $xcol . $xrow . ':' . $lastxcol . $xrow;
                     if ($debug) {
                         fwrite($handle, "\nmergeCells: " . $xcol . ":" . $xrow . " " . $lastxcol . ":" . $xrow);
                     }
                     $worksheet->mergeCells($cellRange);
                     $worksheet->getStyle($cellRange)->applyFromArray($style_overlay);
                     $xcol = $lastxcol;
                 } elseif ($thiscolspan == 1 && $thisrowspan > 1) {
                     // spans more than 1 column
                     $lastxrow = $xrow;
                     for ($j = 1; $j < $thisrowspan; $j++) {
                         $lastxrow++;
                         //$fillCell[$xcol.':'.$lastxrow] = true;
                     }
                     $cellRange = $xcol . $xrow . ':' . $xcol . $lastxrow;
                     if ($debug) {
                         fwrite($handle, "\nmergeCells: " . $xcol . ":" . $xrow . " " . $xcol . ":" . $lastxrow);
                     }
                     $worksheet->mergeCells($cellRange);
                     $worksheet->getStyle($cellRange)->applyFromArray($style_overlay);
                     //$xrow = $lastxrow;
                 } elseif ($thiscolspan > 1 && $thisrowspan > 1) {
                     // spans more than 1 column
                     $lastxcol = $xcol;
                     $lastxrow = $xrow;
                     for ($j = 1; $j < $thiscolspan; $j++) {
                         $lastxcol++;
                         for ($k = 1; $k < $thisrowspan; $k++) {
                             $lastxrow++;
                             //$fillCell[$lastxcol.':'.$lastxrow] = true;
                         }
                     }
                     $cellRange = $xcol . $xrow . ':' . $lastxcol . $lastxrow;
                     if ($debug) {
                         fwrite($handle, "\nmergeCells: " . $xcol . ":" . $xrow . " " . $lastxcol . ":" . $lastxrow);
                     }
                     $worksheet->mergeCells($cellRange);
                     $worksheet->getStyle($cellRange)->applyFromArray($style_overlay);
                     $xcol = $lastxcol;
                     //$xrow = $lastxrow;
                 }
             }
             $xrow++;
             $xcol = '';
         }
         // autosize columns to fit data
         $azcol = 'A';
         for ($x = 1; $x == $maxcols; $x++) {
             $worksheet->getColumnDimension($azcol)->setAutoSize(true);
             $azcol++;
         }
         if ($debug) {
             fwrite($handle, "\nHEADROWS: " . print_r($headrows, true));
             fwrite($handle, "\nBODYROWS: " . print_r($bodyrows, true));
             fwrite($handle, "\nFILLCELL: " . print_r($fillCell, true));
         }
     }
     // end for over tables
     $objPHPExcel->setActiveSheetIndex(0);
     // set to first worksheet before close
     //
     // Write to Browser
     //
     if ($debug) {
         fclose($handle);
     }
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header("Content-Disposition: attachment;filename={$fname}");
     header('Cache-Control: max-age=0');
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     //$objWriter->save($fname);
     $objWriter->save('php://output');
     exit;
 }
示例#23
0
 function noticeInfos($notice_id, $enrich_params)
 {
     global $lang;
     if ($enrich_params['label'] != "") {
         $titre = $enrich_params['label'];
     } else {
         $rqt = "select tit1 from notices where notice_id='{$notice_id}'";
         $res = pmb_mysql_query($rqt);
         if (pmb_mysql_num_rows($res)) {
             $titre = pmb_mysql_result($res, 0, 0);
         }
     }
     $curl = new Curl();
     //on fait un premier appel pour regarder si on a quelque chose chez Wikipédia...
     $url = "http://" . substr($lang, 0, 2) . ".wikipedia.org/w/api.php?format=json&action=opensearch&search=" . rawurlencode($titre) . "&limit=20";
     $json = $curl->get($url);
     $search = json_decode($json);
     if (count($search[1]) == 1 || $enrich_params['label'] != "") {
         if ($enrich_params['label']) {
             $title = $enrich_params['label'];
         } else {
             $title = $search[1][0];
         }
         $url = "http://" . substr($lang, 0, 2) . ".wikipedia.org/w/api.php?format=json&action=query&titles=" . rawurlencode($title) . "&prop=revisions&rvprop=content&rvparse=1";
         $json = $curl->get($url);
         $response = json_decode($json);
         $html_to_return = "";
         foreach ($response->query->pages as $page) {
             foreach ($page->revisions[0] as $rev) {
                 $html_to_return .= utf8_decode($rev);
             }
         }
         $html_to_return = str_replace("href=\"/", "target='_blank' href=\"http://" . substr($lang, 0, 2) . ".wikipedia.org/", $html_to_return);
         @ini_set("zend.ze1_compatibility_mode", "0");
         $dom = new domDocument();
         $dom->loadHTML($html_to_return);
         $spans = $dom->getElementsByTagName("span");
         for ($i = 0; $i < $spans->length; $i++) {
             for ($j = 0; $j < $spans->item($i)->attributes->length; $j++) {
                 if ($spans->item($i)->attributes->item($j)->name == "class" && $spans->item($i)->attributes->item($j)->nodeValue == "editsection") {
                     $spans->item($i)->parentNode->removeChild($spans->item($i));
                 }
             }
         }
         $html_to_return = $dom->saveHTML();
         @ini_set("zend.ze1_compatibility_mode", "1");
     } else {
         if (count($search[1]) > 1) {
             //si plus d'un résultat on propose le choix...
             $html_to_return = "\n\t\t\t<div id='wiki_bio_" . $notice_id . "'>\n\t\t\t\t<table>";
             for ($i = 0; $i < count($search[1]); $i++) {
                 if ($i % 4 == 0) {
                     $html_to_return .= "\n\t\t\t\t\t<tr>";
                 }
                 $html_to_return .= "\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<a href='#' onclick='load_wiki(\"" . $notice_id . "\",\"wiki\",\"" . htmlentities(utf8_decode($search[1][$i]), ENT_QUOTES, $charset) . "\");return false;' >" . utf8_decode($search[1][$i]) . "</a>\n\t\t\t\t\t\t</td>";
                 if ($i % 4 == 3) {
                     $html_to_return .= "\n\t\t\t\t\t</tr>";
                 }
             }
             $html_to_return .= "\n\t\t\t\t</table>\n\t\t\t</div>";
         } else {
             $html_to_return = $this->msg['wikipedia_no_informations'];
         }
     }
     return $html_to_return;
 }
function retorna_links_endereco_url($codigo_html_site, $endereco_url_site)
{
    // globals ----------------------------------------------------------------
    global $numero_maximo_links_pagina;
    // numero maximo de links por pagina
    // --------------------------------------------------------------------------
    // host principal ------------------------------------------------------
    $host_site = retorna_host_url($endereco_url_site);
    // host do site
    // --------------------------------------------------------------------------
    // array com dados de retorno ----------------------------------
    $array_dados_retorno = array();
    // array com dados de retorno
    $array_dados_buffer = array();
    // dados de array de buffer temporario
    // --------------------------------------------------------------------------
    // dom com objetos do codigo html ----------------------------
    $dom = new domDocument();
    // dom com objetos do codigo html
    // --------------------------------------------------------------------------
    // obtendo codigo html de site ------------------------------------
    @$dom->loadHTML($codigo_html_site);
    // obtendo codigo html de site
    // --------------------------------------------------------------------------
    // representa documento html por completo ----------------
    $dom->preserveWhiteSpace = false;
    // representa documento html por completo
    // --------------------------------------------------------------------------
    // obtendo dom por tag --------------------------------------------
    $endereco_sites = $dom->getElementsByTagName('a');
    // obtendo dom por tag
    // --------------------------------------------------------------------------
    // obtendo links da pagina ----------------------------------------
    foreach ($endereco_sites as $url_link_principal) {
        // endereco url --------------------------------------------------------
        $endereco_url = $url_link_principal->getAttribute('href');
        // endereco url
        // --------------------------------------------------------------------------
        // endereco url normal, sera usado para verificar se a url nao e null
        // ---- usado apenas para comparacao de valor nulo!
        $endereco_url_normal = $url_link_principal->getAttribute('href');
        // endereco url normal
        // --------------------------------------------------------------------------
        // verifica se o link esta completo --------------------------------
        if (retorna_host_url($endereco_url) == null) {
            // adiciona protocolo e host de link ------------------------------
            $endereco_url = "http://{$host_site}" . $endereco_url;
            // completa link
            // ----------------------------------------------------------------------------
        }
        // --------------------------------------------------------------------------
        // titulo do link ----------------------------------------------------------
        $titulo_link = $url_link_principal->childNodes->item(0)->nodeValue;
        // titulo do link
        // --------------------------------------------------------------------------
        // endereco host de url de link --------------------------------------
        $host_url_link = retorna_host_url($endereco_url);
        // endereco host de url de link
        // --------------------------------------------------------------------------
        // puxa links de host diferentes ----------------------------------
        puxa_links_host_diferente($endereco_url_site, $endereco_url, $titulo_link);
        // puxa links de host diferentes
        // ------------------------------------------------------------------------
        // atualiza array de retorno ----------------------------------------
        if (retorne_elemento_array_existe($array_dados_retorno, $endereco_url) == false and $endereco_url_normal != null and $titulo_link != null and $host_site == $host_url_link) {
            // atualizando array com links de pagina ----------------------
            $array_dados_retorno[$endereco_url] = $titulo_link;
            // atualizando array com links de pagina
            // ------------------------------------------------------------------------
        }
        // --------------------------------------------------------------------------
        // tamanho do array --------------------------------------------------
        $tamanho_array = count($array_dados_retorno);
        // tamanho do array
        // --------------------------------------------------------------------------
        // verifica se atingiu o tamanho de alocacao maximo ------
        if ($tamanho_array > $numero_maximo_links_pagina) {
            break;
            // saindo de foreach
        }
        // --------------------------------------------------------------------------
    }
    // --------------------------------------------------------------------------
    // aloca resultados no buffer --------------------------------------
    $array_dados_buffer = $array_dados_retorno;
    // aloca resultados no buffer
    // --------------------------------------------------------------------------
    // varrendo array de buffer ------------------------------------------
    foreach ($array_dados_buffer as $endereco_url_buffer => $titulo_buffer) {
        // urls de url principal ------------------------------------------------
        $sublinks_array = puxar_sublinks($endereco_url_buffer);
        // urls de url principal
        // --------------------------------------------------------------------------
        // obtendo sublinks e atualizando array de retorno --------
        foreach ($sublinks_array as $url_sublink) {
            // titulo de sublink ----------------------------------------------------
            $titulo_sublink = basename($url_sublink);
            // titulo de sublink
            // ------------------------------------------------------------------------
            // endereco host de url de link --------------------------------------
            $host_url_link = retorna_host_url($url_sublink);
            // endereco host de url de link
            // --------------------------------------------------------------------------
            // puxa links de host diferentes ----------------------------------
            puxa_links_host_diferente($endereco_url_site, $url_sublink, $titulo_sublink);
            // puxa links de host diferentes
            // ------------------------------------------------------------------------
            // atualiza array de retorno ----------------------------------------
            if (retorne_elemento_array_existe($array_dados_retorno, $url_sublink) == false and $url_sublink != null and $host_site == $host_url_link) {
                // atualizando array com links de pagina ------------------------
                $array_dados_retorno[$url_sublink] = $titulo_sublink;
                // atualizando array com links de pagina
                // ------------------------------------------------------------------------
            }
            // --------------------------------------------------------------------------
        }
        // --------------------------------------------------------------------------
        // tamanho do array --------------------------------------------------
        $tamanho_array = count($array_dados_retorno);
        // tamanho do array
        // --------------------------------------------------------------------------
        // verifica se atingiu o tamanho de alocacao maximo ------
        if ($tamanho_array > retorne_tamanho_pode_indexar_site()) {
            break;
            // saindo de foreach
        }
        // --------------------------------------------------------------------------
    }
    // --------------------------------------------------------------------------
    // retorno ----------------------------------------------------------------
    return $array_dados_retorno;
    // retorno
    // --------------------------------------------------------------------------
}
示例#25
0
</SET_OF_RELATED_PATTERNS>
<PATTERN_IDENTIFICATION>
</PATTERN_IDENTIFICATION>
</Patern>';
$doc = new domDocument();
$doc->loadXML($anXMLString);
$key = key($resultQuery);
$val = current($resultQuery);
$nbrValues = count($resultQuery);
while (list($key, $val) = each($resultQuery)) {
    if (!is_array($val)) {
        switch ($key) {
            case $key == 'pattern_name':
                $newnode = $doc->createElement($key, $val);
                $doc->appendChild($newnode);
                $add = $doc->getElementsByTagName('GENERAL')->item(0);
                $add->appendChild($newnode);
                break;
            case $key == 'pattern_abstract':
                $newnode = $doc->createElement($key, $val);
                $doc->appendChild($newnode);
                $add = $doc->getElementsByTagName('GENERAL')->item(0);
                $add->appendChild($newnode);
                break;
            case $key == 'pattern_desc':
                $newnode = $doc->createElement($key, $val);
                $doc->appendChild($newnode);
                $add = $doc->getElementsByTagName('GENERAL')->item(0);
                $add->appendChild($newnode);
                break;
            case $key == 'pattern_desc':
示例#26
0
 /**
  * Finds all <link>-Tags in the passed HTML content, strips them out
  * and puts them in the internal CSS placeholder store.
  * You can then retreive them all-in-one with JS::getCode().
  * @param string $content - Reference to the HTML content. Note that it
  *                          WILL be modified in-place.
  */
 public static function findCSS(&$content)
 {
     JS::grabComments($content);
     //deactivate error handling for not well formed html
     libxml_use_internal_errors(true);
     $css = array();
     $dom = new domDocument();
     $dom->loadHTML($content);
     libxml_clear_errors();
     foreach ($dom->getElementsByTagName('link') as $element) {
         if (preg_match('/\\.css(\\?.*)?$/', $element->getAttribute('href'))) {
             $css[] = $element->getAttribute('href');
             JS::registerCSS($element->getAttribute('href'));
         }
     }
     JS::restoreComments($content);
     return $css;
 }
示例#27
0
文件: dz.php 项目: echmaster/data
<?php

$document = new domDocument("1.0", "utf-8");
$document->load("test2.xml");
$nodelist = $document->getElementsByTagName("model");
echo "Количество моделей: <b>" . $nodelist->length . "<b><br/>";
示例#28
0
         } else {
             $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
             $xmlWriter->save("temporal.{$extension}");
             rename("{$id_curso}.{$extension}", "{$carpeta}/{$id_curso}.{$extension}");
         }
     }
 }
 echo date('H:i:s'), " Leyendo archivo html <br><br>";
 //Agregar codigo de captura de datos
 $url = $carpeta . "/" . $_REQUEST['idcurso'] . ".html";
 $html = file_get_contents($url);
 $dom = new domDocument();
 $dom->loadHTML($html);
 /*** eliminar espacios en blanco ***/
 $dom->preserveWhiteSpace = false;
 $ps = $dom->getElementsByTagName('p');
 /*** obteniendo todas las tablas ***/
 $tables = $dom->getElementsByTagName('table');
 /*** obteniendo filas de la tabla 1 ***/
 $rows = $tables->item(0)->getElementsByTagName('tr');
 //$titles = $tables->item(1)->getAttribute('title');
 /*******Variables a reemplazar con POO*********************************/
 $codigo = "";
 $docente = "";
 $horario = array();
 $num_horas = array();
 $contenidos = array();
 $fechas = array();
 $dias = array("lunes", "martes", "miercoles", "jueves", "viernes", "sabado", "domingo");
 /*******Variables a reemplazar con POO**********************************/
 $i = 0;
 }
 $skip = 0;
 // now we test if (more) results are available
 if (strstr($htmdata, "/images/yellow_warning.gif")) {
     echo "No (more) results left{$NL}";
     $skip = 1;
 }
 if (!$skip) {
     $len = strlen($htmdata);
     echo "\t Received {$len} bytes{$NL}";
     // Now we parse the html content, putting it into a DOM tree
     $dom = new domDocument();
     $dom->strictErrorChecking = false;
     $dom->preserveWhiteSpace = true;
     @$dom->loadHTML($htmdata);
     $lists = $dom->getElementsByTagName('li');
     $num = 0;
     foreach ($lists as $list) {
         unset($ar);
         unset($divs);
         unset($div);
         unset($cont);
         unset($result);
         unset($tmp);
         $result['main_keyword'] = $main_keyword;
         $result['sub_keyword'] = $keyword;
         $ar = dom2array_full($list);
         if (count($ar) < 2) {
             echo "S";
             continue;
             // skipping advertisement and similar spam
示例#30
0
<?php

/*КЛАСС DOMAttr урок 11
		/Этот класс отвечает за атрибуты элемента
		***Метод getAttributeNodeNs("http://mysite.ru","number") - возвращает объект класса DOMAttr
		/Свойство name объекта класса DOMAttr - возвращает имя атрибута
		/Свойство value объекта класса DOMAttr - возвращает значение атрибута
		/Свойство ownerElement объекта класса DOMAttr - возвращает объект DomElement в котором содержится указанный атрибут и чтобы вывести имя элемента в котором содержится тег указываем свойство nodeName 
	*/
$document = new domDocument("1.0", "utf-8");
$document->load("test.xml");
$nodelist = $document->getElementsByTagName("garage");
$element = $nodelist->item(0);
echo $element->nodeName . "<br/>";
$attr = $element->getAttributeNodeNS("http://mysite.ru", "number");
echo $attr->name . "<br/>";
echo $attr->value . "<br/>";
echo $attr->ownerElement->nodeName . "<br/>";