<?php
 if(!function_exists('print_rf')) { function print_rf($array,$n="",$title_only=0) { Helper::print_rf($array,$n,$title_only); } } class HelperBase { function getTestHtml() { return '
            <a href="http://dev/00015_ok/0020_sanvit/current/de/bike-3/bike/p/cube-access-wls-26-2015_2206">Produkt Test</a>

            <a href="http://dev/00015_ok/0020_sanvit/current/de/bike-3">Seite Test</a>
        '; return '
<h1>Anker Test</h1>
<p><a href="#test">Test</a></p>
<p>anker test <a id="test" name="test"></a></p>

<h1>Link Test</h1>
<ul>
	<li><a href="//google.com">link - // extern</a></li>
	
	<li><a href="mailto:puergstaller@gmail.com">email link</a></li>
	<li><a href="#testanker">zum anker link</a></li>
	<li><a href="http://dev/00014_asisto/mizu/demo/it/itatest">link auf andere sprache</a></li>
	<li><a href="http://dev/00014_asisto/mizu/demo/hallo">link - 404 error</a></li>
	
	<li><a href="http://dev/00014_asisto/mizu/demo/de">intern home url</a></li>
	<li><a href="http://dev/00014_asisto/mizu/demo/de/ueber-uns">interner</a></li>
	<li><a href="http://dev/00014_asisto/mizu/demo/de/ueber-uns?testparam=1">interner mit param</a></li>
	<li><a href="http://dev/00014_asisto/mizu/demo/de/ueber-uns#test">interner mit anker</a></li>
	<li><a href="http://dev/00014_asisto/mizu/demo/de/ueber-uns?testparam=1#test">interner mit param und anker</a></li>
	<li><a href="http://dev/00014_asisto/mizu/demo/img/suedtirol-online-kleinanzeiger-.png">BILD</a></li>
	<li><a href="http://dev/00014_asisto/mizu/demo/img/catalog.pdf">Sonstige Datei</a></li>
	<li><a href="http://www.youtube.com/upload">externer link</a></li>
	<li><a href="#" name="testanker">anker</a></li>
</ul>
<h1>Bilder Test</h1>
<ul>
	<li>normales bild<br />
	<img alt="" src="http://dev/00014_asisto/mizu/demo/img/suedtirol-online-kleinanzeiger-.png" style="width: 300px; height: 174px;" /></li>
	<li>externes bild<br />
	<img alt="" src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/187614_1501921218_124323831_q.jpg" style="width: 30px; height: 30px;" /></li>
	<li>test bild mit link<br />
	<a href="http://dev/00014_asisto/mizu/demo/img/struct/pic1.jpg" target="_fancybox"><img alt="" src="http://dev/00014_asisto/mizu/demo/img/struct/pic1.jpg" style="width: 200px; height: 83px;" /></a></li>
</ul>'; } function hasToCodeHtml($v) { if(is_array($v)) { return false; } if(strpos($v,'<a')===false AND strpos($v,'<img')===false AND strpos($v,'{')===false AND strpos($v,'#')===false) { return false; } return true; } function encodeHtml($v,$conf=array()) { if(!$this->hasToCodeHtml($v)) { return $v; } $v = stripslashes($v); if(!$conf['tags']) { $conf['tags'] = 'img|a'; } preg_match_all('!<('.$conf['tags'].')(.*)>!imsU',$v,$M); $denyProto = array(); $denyProto['mailto'] = true; $denyProto['tel'] = true; $denyProto['skype'] = true; $baseH = $this->Mizu->_Url->BaseHref; $toChange = array(); if($M[2]) { foreach($M[2] as $i => $Value) { preg_match_all('!(href|src)="(.*)"!imsU',$Value,$Attr); $url = $Attr[2][0]; $proto = substr($url,0,strpos($url,':')); if($denyProto[$proto]) { continue; } $opt = array(); $opt['type'] = $M[1][$i]; $opt['attrTag'] = $Attr[1][0]; $opt['url'] = $url; if(substr($opt['url'],0,strlen($baseH))==$baseH) { $opt['url'] = substr($opt['url'],strlen($baseH)); } else if($proto=='http' OR $proto=='https') { $opt['ext'] = true; } if(substr($url,0,2)=='//') { $opt['ext'] = true; } if($opt['ext']) { continue; } if(strpos($opt['url'],'{')!==false) { continue; } if(strpos($opt['url'],'?')!==false) { $opt['urlEndPos'] = strpos($opt['url'],'?'); } else if(strpos($opt['url'],'#')!==false) { $opt['urlEndPos'] = strpos($opt['url'],'#'); } if(isset($opt['urlEndPos'])) { $opt['addExt'] = substr($opt['url'],$opt['urlEndPos']); $opt['baseUrl'] = substr($opt['url'],0,$opt['urlEndPos']); } else { $opt['addExt'] = ''; $opt['baseUrl'] = $opt['url']; } switch($opt['type']) { case 'a' : if(!$opt['url']) { continue; } if($opt['baseUrl']) { $R = $this->Mizu->_Url->decodeUrl(false,$opt['baseUrl']); if(is_numeric($R['id']) AND $R['id']) { $opt['change'] = '{getUrl:'.$R['id'].':'.$R['L'].'}'; $opt['newUrl'] = $this->Mizu->getUrl($R['id']); if(substr($opt['newUrl'],0,strlen($baseH))==$baseH) { $opt['newUrl'] = substr($opt['newUrl'],strlen($baseH)); } if(strlen($opt['newUrl'])<strlen($opt['url'])) { $opt['addExt'].=substr($opt['url'],strlen($opt['newUrl'])); } } } if(!$opt['change'] AND $opt['baseUrl'] AND !$opt['addExt']) { $opt['change']='{getUrl:base}'.$opt['baseUrl']; } if(!$opt['change'] AND !$opt['ext']) { $opt['change']='{getUrl:}'; } if($opt['change'] AND $opt['addExt']) { $opt['change'].=$opt['addExt']; } break; case 'img' : $str = $M[2][$i]; $Get = array('height','width','style','class'); $myAttr = array(); $myAttr['src'] = $opt['url']; foreach($Get as $f) { preg_match('!'.$f.'="(.*)"!imsU',$str,$R); $myAttr[$f] = $R[1]; $myAttr[$f.'-full'] = $R[0]; } $myAttr['size'] = @getimagesize($myAttr['src']); if($myAttr['style']) { foreach($Get as $f) { preg_match('!'.$f.':(.*)px;!imsU',$myAttr['style'],$R2); if($R2[1]) { $myAttr[$f] = trim($R2[1]); } } } $opt['change']='{getImgUrl:'.$opt['url']; if($myAttr['width'] OR $myAttr['height']) { $opt['change'].= ':'.$myAttr['width'].'!'; $opt['change'].= ':'.$myAttr['height'].'!'; } $opt['change'].='}'; break; } if($opt['change']) { $opt['toC'][$Attr[0][0]] = $opt['attrTag'].'="'.$opt['change'].'"'; $opt['change'] = strtr($M[0][$i],$opt['toC']); $toChange[$M[0][$i]] = $opt['change']; } } } $toChange[''] = ''; if($toChange) { $v = strtr($v,$toChange); } return $v; } function decodeHtml($v,$conf=array()) { if(!$this->hasToCodeHtml($v)) { return $v; } $v = stripslashes($v); $vH = $this->Mizu->_Conf->execHook('Helper.decodeHtml.init',array('v'=>$v)); if($vH[0]) $v = $vH[0]; if(!$conf['forMizuClose']) { $v = $this->encodeHtml($v,array('tags'=>'img')); } $baseH = $this->Mizu->_Url->BaseHref; $toChange = array(); if($conf['forMizuClose']) { $conf['search'] = 'get'; } else { $conf['search'] = 'getUrl|getImgUrl|get|getTpl'; } preg_match_all('!{('.$conf['search'].'):(.*)}!imsU',stripslashes($v),$M); if($M[1]) { foreach($M[2] as $i => $Value) { $opt = array(); $opt['type'] = $M[1][$i]; $opt['attr'] = explode(':',$Value); switch($opt['type']) { case 'get' : if(!$conf['forAdmin']) { $opt['change'] = ''; if($opt['attr'][0] AND strpos($opt['attr'][0],'/')!==false) { $opt['change'] = $this->Mizu->get($opt['attr'][0],$opt['attr'][1]); } else { $opt['P'] = $this->Mizu->Conf['get'][$opt['attr'][0]]; if($conf['widgets']) { $opt['P']['attr'] = $conf['widgets']['get'][$opt['attr'][0]]; } if($opt['attr'][0]=='_') { $opt['change'] = $this->Mizu->_($opt['attr'][1]); } else if($opt['P']) { if($opt['P']['attr']['value']) { $opt['change'] = $opt['P']['attr']['value']; } else if($opt['P']['attr']['loadTpl']) { $opt['tC'] = array(); foreach($opt['attr'] as $y => $z) { $opt['tC']['v'.$y] = $z; if($opt['P']['attr']['v'.$y]) { $opt['tC'][$opt['P']['attr']['v'.$y]] = $z; } } $opt['change'] = $this->Mizu->getTpl($opt['P']['attr']['loadTpl'],$opt['tC'],true); } } } } break; case 'getTpl' : if($conf['forAdmin']) { } else { $opt['change'] = $this->Mizu->getTpl($opt['attr'][0],array(),true); } break; case 'getUrl' : if($opt['attr'][0]=='base') { $opt['change'] = $baseH; } else { if(!$opt['attr'][0]) { $opt['attr'][0] = $this->Mizu->GP['id']; } $opt['change'] = $this->Mizu->getUrl($opt['attr'][0],$opt['attr'][1]); } break; case 'getImg' : case 'getImgUrl' : if(strpos($v,'no-resize')!==false) { preg_match('|<img(.*)' . $M[0][$i] . '(.*)>|imsU', $v, $m); if (strpos($m[0], 'no-resize')!==false) { $opt['no-resize'] = true; } } if($conf['forAdmin'] OR $opt['no-resize']) { $opt['change'] = $opt['attr'][0]; } else { $opt['change'] = $baseH.$this->Mizu->getImgUrl($opt['attr'][0],$opt['attr'][1],$opt['attr'][2]); } break; } if(isset($opt['change'])) { $toChange[$M[0][$i]]= $opt['change']; } } } if($toChange) { $v = strtr($v,$toChange); } return $v; } function sort($a,$b) { $al = $a['conf']['sort']; $bl = $b['conf']['sort']; if ($al == $bl) { return 0; } return ($al < $bl) ? -1 : +1; } function utf8EncodeArray($A) { if(is_array($A)) { foreach($A as $k => $v) { $A[$k] = $this->utf8EncodeArray($v); } } else if(is_string($A)) { return utf8_encode($A); } else { return $A; } return $A; } function isMobile() { $toCheck = array('iPhone','iPad','Android','webOS','BlackBerry','iPod'); foreach($toCheck as $v) { if(strpos($_SERVER['HTTP_USER_AGENT'],$v)!==false) { return $v; } } if($_GET['isMobile']) { return true; } } function print_rf($array,$n="",$title_only=0) { $a = debug_backtrace(); echo "<div style='text-align:left;font-family:Verdana;font-size:12px;background-color:white;border:1px solid #ccc;padding:10px;margin:3px;color:black'>"; if($n) echo "<b>$n</b>"; if($n AND !$title_only) echo " | "; $i =1; if(!$title_only) echo "print_rf in ".basename($a[$i]["file"]).":".$a[$i]["line"]; echo "<pre style='font-family:Verdana'>"; print_r($array); echo "</pre>"; echo "</div>"; } function serialize($v) { $v = $this->rmSpcChars($v); return serialize($v); } function rmSpcChars($v) { if(is_array($v)) { foreach($v as $y => $z) { $v[$y] = $this->rmSpcChars($z); } } else { $v = stripslashes($v); $v = strtr($v,array('"'=>'&quot;',"'"=>'&#039;')); } return $v; } function getAfX($xml) { $x = 0; if($xml) { $attr = $xml->attributes(); } if(count($attr)) { foreach($attr as $y => $z) { $R['attr'][$y] = (string)$z; } } if($xml) { foreach ($xml->children() as $k => $v) { if(count($v->children()) OR count($v->attributes())) { if($R[$k]) { if(!$R[$k][0]) { $tmp = $R[$k]; $R[$k] = array(); $R[$k][] = $tmp; } $R[$k][] = $this->getAfX($v); } else { $R[$k] = $this->getAfX($v); } } else { $R[$k] = (string)$v; } $x++; } } if (PHP_VERSION == '5.0.3-0.4' AND trim((string)($xml))) { $R = $xml; } elseif(trim((string)($xml))) { $R['sdata'] = (string)($xml); } if($R['cdata'] AND count($R)==1) { $R = $R['cdata']; } return $R; } function getJsSelect($name,$A=array(),$default,$opt=array()) { foreach($A as $k => $v) { if(is_numeric($k)) { $k = (string)$k; } $V[] = array('value' => $k,'name' => $v); } $Store = array( 'xtype' => 'store', 'fields' => array('value','name'), 'data' => $V, ); $R = array( 'xtype' => 'myselect', 'displayField' => 'name', 'valueField' => 'value', 'name' => $name, 'forceSelection'=> true, 'queryMode' => 'local', 'editable' => false, 'triggerAction' => 'all', 'value' => $default, 'store' => $Store, ); $R['sortable'] = true; if($opt['multiselect']) { $R['xtype'] = 'myselectmulti'; } return $R; } function getAbyPath($A,$path=false,$sep='/') { $P = explode($sep,$path); $R = $A; foreach($P as $k) { if(!$k) continue; if(!is_array($R)) { return array(); } $R = $R[$k]; } return $R; } function writeXmlStringAsPhpArray($Xml) { if(is_string($Xml)) { $Xml = $this->getAfX(simplexml_load_string($Xml)); return var_export($Xml,true); } elseif(is_array($Xml)){ return var_export($Xml,true); } } function isValidEmail($v) { if(preg_match('#^[^\\x00-\\x1f@]+@[^\\x00-\\x1f@]{2,}\.[a-z]{2,}$#i',$v)) { return true; } else { return false; } } function explode($v,$sep=array()) { if(!$sep) { $sep = array(';',','); } $R = array(); foreach($sep as $s) { if(strpos($v,$s)!==false) { foreach(explode($s,$v) as $y => $z) { if($z) { $R[] = $z; } } break; } } if(!$R) { $R[] = $v; } return $R; } function removeWhiteSpaces($buffer) { $search = array( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s' ); $replace = array( '>', '<', '\\1' ); $buffer = preg_replace($search, $replace, $buffer); return $buffer; } function array_merge($tpl1,$tpl2) { if(is_array($tpl1) AND is_array($tpl2)) { $tpl = array_merge($tpl1,$tpl2); } else if(!is_array($tpl1)) { $tpl = $tpl2; } else if(!is_array($tpl2)) { $tpl = $tpl1; } return $tpl; } function mergeArray($tpl1,$tpl2,$forceTpl=array()) { $tpl = array(); if(is_array($tpl1) AND is_array($tpl2)) { $tpl = array_merge_recursive($tpl1,$tpl2); } else if(!is_array($tpl1)) { $tpl = $tpl2; } else if(!is_array($tpl2)) { $tpl = $tpl1; } if($forceTpl) { foreach($forceTpl as $k => $v) { $tpl[$k] = $v; } } return $tpl; } function remote_file_get_contents($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $A = curl_exec ($ch); curl_close ($ch); return $A; } function getArrayAsRows($A) { if(!is_array($A)) return array($A); if(!$A[0]) { $R[0] = $A; } else { $R = $A; } return $R; } var $cryptKey = 'trrIxGtNvPb3E6Hl6zBn
Wlk410k3S5HusLZEZ1wh
6QezmAZX4pwdfZt2R8PN
BfZBip2KkCR3hWdogshv
MMDT7XRlV3uShZ9t1wJz
0wT2LvWFFqB1rapNOUTD
JWVBaPgKbq2y3JnskNmd
Do1h7FR4cU4D2PuMx8sG
vpxzAxtllnIfowXSo6mT
tdrzJCMNmdYGjKu48tjt'; function encrypt($v,$key=false) { if(!$key) $key = $this->cryptKey; return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $v, MCRYPT_MODE_CBC, md5(md5($key)))); } function decrypt($v,$key=false) { if(!$key) $key = $this->cryptKey; return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($v), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); } } if(floatval(phpversion())>=5) { class Helper extends HelperBase {} } 