Example #1
0
 function processPage($text)
 {
     if ($this->getParam('img') == 1) {
         $text = preg_replace('#<img [^>]+>#is', '', $text);
     } elseif ($this->getParam('img') >= 2) {
         $scaletype = $this->getParam('img') - 2;
         $addstyles = (bool) $this->getParam('img_addstyles');
         $text = MobileJoomla::RescaleImages($text, $scaletype, $addstyles);
     }
     if ($this->getParam('removetags')) {
         $text = preg_replace('#<object\\s[^>]+?/>#is', '', $text);
         $text = preg_replace('#<object\\s.+?</object>#is', '', $text);
         $text = preg_replace('#<embed\\s[^>]+?/>#is', '', $text);
         $text = preg_replace('#<embed.+?</embed>#is', '', $text);
         $text = preg_replace('#<applet\\s[^>]+?/>#is', '', $text);
         $text = preg_replace('#<applet\\s.+?</applet>#is', '', $text);
     }
     //TODO: parse css-files
     return $text;
 }
Example #2
0
 function processPage($text)
 {
     if ($this->getParam('img') == 1) {
         $text = preg_replace('#<img [^>]+>#is', '', $text);
     } elseif ($this->getParam('img') >= 2) {
         $scaletype = $this->getParam('img') - 2;
         $addstyles = (bool) $this->getParam('img_addstyles');
         $text = MobileJoomla::RescaleImages($text, $scaletype, $addstyles);
     }
     if ($this->getParam('removetags')) {
         $text = preg_replace('#<iframe\\s[^>]+? />#is', '', $text);
         $text = preg_replace('#<iframe.+?</iframe>#is', '', $text);
         $text = preg_replace('#<object\\s[^>]+? />#is', '', $text);
         $text = preg_replace('#<object\\s.+?</object>#is', '', $text);
         $text = preg_replace('#<embed\\s[^>]+? />#is', '', $text);
         $text = preg_replace('#<embed.+</embed>#is', '', $text);
         $text = preg_replace('#<applet\\s[^>]+? />#is', '', $text);
         $text = preg_replace('#<applet\\s.+?</applet>#is', '', $text);
         /*			$text = preg_replace('#(<.+?)align="center"(.+?>)#is', '\1class="center"\2', $text); // mosimage fix */
         $text = str_replace('<br>', '<br />', $text);
         // xml-compatibility
     }
     if ($this->config['xhtml.removescripts']) {
         $text = preg_replace('#<script\\s[^>]+? />#is', '', $text);
         //$text = preg_replace('#<script\s.+?</script>#is', '', $text);
         $text = preg_replace('#<script([^\'"/>]|"[^"]*?"|\'[^\']*?\')*?>([^\'"/]|"([^"\\\\]|\\\\.)*?"|\'([^\'\\\\]|\\\\.)*?\'|/[^/*]|/\\*.*?\\*/|//.*?$)*?</script>#ism', '', $text);
     }
     if ($this->config['xhtml.entitydecode']) {
         $text = strtr($text, array('&lt;' => '&amp;lt;', '&gt;' => '&amp;gt;', '&amp;' => '&amp;amp;'));
         $text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8');
     }
     //remove target="_blank" from links
     $text = preg_replace('#(<a [^>]*?)target="_blank"([^>]*?>)#is', '\\1\\2', $text);
     return $text;
 }
Example #3
0
 function processPage($text)
 {
     $doctypes = array(1 => '<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">', '<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml_1.2.xml">');
     $pretext = '<?xml version="1.0" encoding="utf-8" ?>' . "\n" . $doctypes[$this->config['wml.doctype']] . "\n";
     $text = preg_replace('#<img src="[^"]*arrow(_rtl)?\\.png" alt=""\\s*/>#', '&gt;', $text);
     //pathway fix
     $text = preg_replace('#<iframe\\s[^>]+? />#is', '', $text);
     $text = preg_replace('#<iframe.+</iframe>#is', '', $text);
     $text = preg_replace('#<object\\s[^>]+? />#is', '', $text);
     $text = preg_replace('#<object\\s.+?</object>#is', '', $text);
     $text = preg_replace('#<embed\\s[^>]+? />#is', '', $text);
     $text = preg_replace('#<embed.+</embed>#is', '', $text);
     $text = preg_replace('#<applet\\s[^>]+? />#is', '', $text);
     $text = preg_replace('#<applet\\s.+?</applet>#is', '', $text);
     $text = preg_replace('#<script\\s[^>]+? />#is', '', $text);
     //$text = preg_replace('#<script\s.+?</script>#is', '', $text);
     $text = preg_replace('#<script([^\'"/>]|"[^"]*?"|\'[^\']*?\')*?>([^\'"/]|"([^"\\\\]|\\\\.)*?"|\'([^\'\\\\]|\\\\.)*?\'|/[^/*]|/\\*.*?\\*/|//.*?$)*?</script>#ism', '', $text);
     $text = preg_replace('#<h\\d.*?>#is', '<big>', $text);
     $text = preg_replace('#</h\\d.*?>#is', '</big><br/>', $text);
     $text = preg_replace('#<(ol|ul|dl|div|table).*?>#i', '', $text);
     $text = preg_replace('#</(ol|ul|dl|table)>#i', '', $text);
     $text = preg_replace('#</div>#i', '<br/>', $text);
     $text = preg_replace('#<(td|tr|dd|li|span).*?>#is', '', $text);
     $text = preg_replace('#</(tr|dd|li)>#i', '<br/>', $text);
     $text = str_ireplace('</td>', ' | ', $text);
     $text = str_ireplace('</span>', '', $text);
     $text = str_replace(' | <br/>', '<br/>', $text);
     $text = preg_replace('#<dt.*?>#is', '<strong>', $text);
     $text = str_ireplace('</dt>', '</strong><br/>', $text);
     $text = preg_replace('# class=".*?"#is', '', $text);
     $text = preg_replace('# rel=".*?"#is', '', $text);
     $text = preg_replace('# id=".*?"#is', '', $text);
     $text = preg_replace('# style=".*?"#is', '', $text);
     $text = preg_replace('# title=".*?"#is', '', $text);
     $text = preg_replace('# target="_blank"#is', '', $text);
     $text = trim($text);
     $title = $this->getPageTitle();
     $pos = strpos($text, '<card');
     if ($pos === false) {
         $text = '<card id="main" title="' . $title . '">' . "\n" . $text . "\n</card>\n";
     } else {
         $text = '<card id="main" title="' . $title . '">' . "\n" . substr($text, 0, $pos) . "\n</card>\n" . substr($text, $pos);
     }
     $text = "<wml>\n" . "<head>\n" . "<meta http-equiv=\"Cache-Control\" content=\"max-age=0\" forua=\"true\" />\n" . "</head>\n" . $text . "\n" . "</wml>";
     if ($this->getParam('img') == 1) {
         $text = preg_replace('#<img [^>]+>#is', '', $text);
     } elseif ($this->getParam('img') >= 2) {
         $scaletype = $this->getParam('img') - 2;
         $text = MobileJoomla::RescaleImages($text, $scaletype);
     }
     $text = str_replace('<br/>', '<br>', $text);
     $text = strip_tags($text, '<a><access><anchor><b><big><br><card><do><em><fieldset><go><head><i><img><input><meta><noop><onevent><optgroup><option><p><postfield><prev><refresh><select><setvar><small><strong><table><td><tr><template><timer><u><wml>');
     $text = str_replace('<br />', '<br/>', $text);
     $text = str_replace('<br>', '<br/>', $text);
     $text = preg_replace('#\\s\\s+#', ' ', $text);
     $text = preg_replace("#(\n|\r)+#", "\n", $text);
     if ($this->config['wml.entitydecode'] == 1) {
         $text = strtr($text, array('&lt;' => '&amp;lt;', '&gt;' => '&amp;gt;', '&amp;' => '&amp;amp;'));
         $text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8');
     }
     return $pretext . $text;
 }
Example #4
0
 function processPage($text)
 {
     //replace '<.../>' on '<...>'
     $text = preg_replace('#<([^>]) ?/>#s', '<\\1>', $text);
     // TODO: remove table
     // TODO: remove colors
     // TODO: remove stylesheet
     if ($this->getParam('img') == 1) {
         $text = preg_replace('#<img [^>]+>#is', '', $text);
     } elseif ($this->getParam('img') >= 2) {
         $scaletype = $this->getParam('img') - 2;
         $text = MobileJoomla::RescaleImages($text, $scaletype);
     }
     // allowable tags: a base blockquote body br center dd dir div dl dt form head h... hr html img input(exept type=image&file) li menu meta(refresh only) ol option(selected, but not value) p plaintext pre select textarea title ul
     if ($this->getParam('removetags')) {
         $text = preg_replace('#<iframe\\s[^>]+ ?/>#is', '', $text);
         $text = preg_replace('#<iframe.+</iframe>#is', '', $text);
         $text = preg_replace('#<object\\s[^>]+ ?/>#is', '', $text);
         $text = preg_replace('#<object\\s.+</object>#is', '', $text);
         $text = preg_replace('#<embed\\s[^>]+ ?/>#is', '', $text);
         $text = preg_replace('#<embed.+</embed>#is', '', $text);
         $text = preg_replace('#<applet\\s[^>]+ ?/>#is', '', $text);
         $text = preg_replace('#<applet\\s.+</applet>#is', '', $text);
         $text = preg_replace('#<script\\s[^>]+ ?/>#is', '', $text);
         //$text = preg_replace('#<script\s.+</script>#is', '', $text);
         $text = preg_replace('#<script([^\'"/>]|"[^"]*?"|\'[^\']*?\')*?>([^\'"/]|"([^"\\\\]|\\\\.)*?"|\'([^\'\\\\]|\\\\.)*?\'|/[^/*]|/\\*.*?\\*/|//.*?$)*?</script>#ism', '', $text);
     }
     if ($this->config['chtml.entitydecode']) {
         $text = strtr($text, array('&lt;' => '&amp;lt;', '&gt;' => '&amp;gt;', '&amp;' => '&amp;amp;'));
         $text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8');
     }
     return $text;
 }