Revize 171
Přidáno uživatelem Tomáš Dulík před více než 15 roky(ů)
freenetis/trunk/kohana/application/libraries/Parser_Html_Table.php | ||
---|---|---|
protected $buffer;
|
||
protected $eoln_pos; // the position of the last End Of Line in the buffer
|
||
protected $matches;
|
||
|
||
protected $table_end=false;
|
||
|
||
public function open($url) {
|
||
if ($url!="") {
|
||
$old = ini_set('default_socket_timeout', self::TIMEOUT);
|
||
... | ... | |
* PHP5 version: in PHP5, strripos can search whole string,
|
||
* not only 1 char as in PHP4
|
||
*/
|
||
if ( ($res=stripos($this->buffer, "<table")) !== false ||
|
||
($res=stripos($this->buffer, "</table")) !== false) {
|
||
$this->table_end=true;
|
||
return $res;
|
||
}
|
||
if ( ($res=strripos($this->buffer, "</tr")) !== false)
|
||
return $res;
|
||
else if ( ($res=strripos($this->buffer, "<tr")))
|
||
return $res;
|
||
else return strripos($this->buffer, "</table");
|
||
return strripos($this->buffer, "<tr");
|
||
/**
|
||
* PHP4 version: we have to use perl regular expressions...
|
||
* This is only 0.03sec/100kB slower than PHP5 strripos version
|
||
... | ... | |
|
||
|
||
/** now try to find the last <[/]tr> or <[/]table> tag by searching these tags not followed by the same tags,
|
||
if not successfull, read the next line of the file */
|
||
while ( ($lastTagPos=$this->find_row_end()) === false
|
||
if not successfull, read the next line of the file. Do it until EOF or table end */
|
||
while ( ($lastTagPos=$this->find_row_end()) === false && $this->table_end==false
|
||
&& $this->get_line());
|
||
|
||
if ($lastTagPos===false) return false; // if <tr> not found untill EOF, return EOF
|
||
... | ... | |
/**
|
||
* Now: get the contents of all the table cells (the texts between
|
||
* <td > and <td > or </td> or <tr> or </tr> tags
|
||
*/
|
||
preg_match_all("/<td[^>]*>(?:<[^>]*>)?(.*?)<(?:(?:\/)?td|tr)/si", $rows, $this->matches);
|
||
*/
|
||
preg_match_all("/<td[^>]*>(?:<[^>]*>)?(.*?)<(?:(?:\/)?td|tr|table)/si", $rows, $this->matches);
|
||
$this->buffer=substr($this->buffer,$lastTagPos);
|
||
return true;
|
||
}
|
Také k dispozici: Unified diff
Oprava parsování výpisů, které obsahují po hlavní tabulce s výpisem ještě další tabulku s výpisem spořícího účtu. Nyní parser parsuje jen jednu HTML tabulku, pokud ho nadřízený kód nepožádá o další.