$metodo($"."param1,$"."param2,$"."param3,$"."param4,$"."param5,$"."param6,$"."param7,$"."param8,$"."param9,$"."param10);"); else $a = $GLOBALS['api']->msg_erro("Erro no sistema","O m�todo ".$metodo." da classe ".$class." n�o existe"); }else{ $a = $GLOBALS['api']->msg_erro("Erro no sistema","Classe ".$class." n�o existe"); } return $a; } /* * Procura e executa os includes do template * exec[pasta.classe.metodo] */ function ExecIncludes($html) { //$return = ereg_replace("exec\[([^\[]{1,})\]", "\".ExecMethod('\\1').\"", ereg_replace("\"", "\\\"", $html)); preg_match_all("/(\include\[([^\[]{1,})\])/", $html, $matches, PREG_SET_ORDER); foreach ($matches as $val) { list($metodo,$parans) = explode('|',$val[2]); $exec = "ExecMethod('$metodo'"; $exec .= ($parans!="")? ",$parans)":");"; eval("$"."html = str_replace($"."val[0],".$exec.",$"."html);"); } return $html; } /** * * Fun��o utilizada para recuperar usuario * @param $id */ function recuperaUsuario ($id) { return $GLOBALS['api']->bd->select("SELECT * FROM associado WHERE email='".$id."'"); } /** * * Fun��o utilizada para autoload das classes na pasta Zend * @param $pClassName */ function my_autoload ($pClassName) { include(str_replace("_", DIRECTORY_SEPARATOR,$pClassName) . ".php"); } define('CLASSES_PATH', realpath(dirname(__FILE__))); set_include_path(implode(PATH_SEPARATOR, array( realpath(CLASSES_PATH), realpath(CLASSES_PATH."/"), get_include_path(), ))); spl_autoload_extensions('.php'); spl_autoload_register("my_autoload"); //trata os dados de um form /*function dados($form, $tipo) { foreach($form as $campo => $value) { if($campo == sem_acento($value)) $value = ''; if($campo == 'senha') $value = md5($value); if($campo == 'cpf') $value = str_replace(array('.','-'),"",$value); if($campo == 'cep') $value = str_replace('-',"",$value); if($campo == 'cnpj') $value = str_replace(array('.','-','/'),"",$value); if($campo == 'data_nascimento') { $value = explode("/",$value); $value = $value[2]."-".$value[1]."-".$value[0]; } if($campo || $value) { if($value=='Cidade'|| $value=='DDD' || $value='Telefone fixo' || $value='*Telefone Celular') $value=''; else $value = ($tipo=='utf8')?utf8_decode($value):$value; $colunas[] = "$campo = '".$value."'"; $dados[$campo] = $value; } } $dados[] = implode(',',$colunas); return $dados; }*/ function dados($form, $id) { foreach($form as $campo => $value) { if($campo == 'senha') $value = md5($value); if($campo == 'cpf') $value = str_replace(array('.','-'),"",$value); if($campo == 'cep') $value = str_replace('-',"",$value); if($campo == 'telefone') $value = str_replace('-',"",$value); if($campo == 'formacao' || $campo == 'lingua' || $campo == 'info' || $campo == 'exper' || $campo == 'area') { unset($campo); unset($value); } if($campo == 'cnpj') $value = str_replace(array('.','-','/'),"",$value); if($campo == 'data_nascimento') { $value = explode("/",$value); $value = $value[2]."-".$value[1]."-".$value[0]; } if($campo || $value) { if ($id == "associese") $colunas[] = "$campo = '".$value."'"; else $colunas[] = "$campo = '".utf8_decode($value)."'"; } } return $dados = implode(',',$colunas); } function mostraVideo($url,$w,$h) { if(strpos($url,'vimeo')==true): $link = str_replace('vimeo.com','player.vimeo.com/video',$url); $embed=""; endif; if(strpos($url,'youtube')==true): $url = explode('?',$url); $url = explode('&',$url[1]); foreach($url as $u): $u = explode('=',$u); foreach($u as $i) $url[] = $i; endforeach; $pos = array_search('v',$url); $link = $url[$pos+1]; $embed = ""; //$embed=""; endif; return $embed; } function thumbVideo($url,$thumb,$w) { if(strpos($url,'vimeo')==true): $imgid = str_replace("http://", "", $url); $imgid = str_replace("vimeo.com/", "", $imgid); $hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$imgid.php")); $img = $hash[0]['thumbnail_medium']; endif; if(strpos($url,'youtube')==true): $url = explode('?',$url); $url = explode('&',$url[1]); foreach($url as $u): $u = explode('=',$u); foreach($u as $i) $url[] = $i; endforeach; $pos = array_search('v',$url); $link = $url[$pos+1]; if($thumb!='g') $img="http://i2.ytimg.com/vi/".$link."/default.jpg"; else $img="http://i1.ytimg.com/vi/".$link."/hqdefault.jpg"; endif; return 'Thumb vdeo'; } //tira acentos de uma string e adiciona mais nos espa�os function sem_acento($frase) { $acentos = array( 'A' => '/À|Á|Â|Ã|Ä|Å/', 'a' => '/à|á|â|ã|ä|å/', 'C' => '/Ç/', 'c' => '/ç/', 'E' => '/È|É|Ê|Ë/', 'e' => '/è|é|ê|ë/', 'I' => '/Ì|Í|Î|Ï/', 'i' => '/ì|í|î|ï/', 'N' => '/Ñ/', 'n' => '/ñ/', 'O' => '/Ò|Ó|Ô|Õ|Ö/', 'o' => '/ò|ó|ô|õ|ö/', 'U' => '/Ù|Ú|Û|Ü/', 'u' => '/ù|ú|û|ü/', 'Y' => '/Ý/', 'y' => '/ý|ÿ/', 'a.' => '/ª/', 'o.' => '/º/', '' => '/%/' ); if(is_array($frase)): foreach($frase as $f): $word = preg_replace($acentos, array_keys($acentos), htmlentities($f,ENT_NOQUOTES, 'utf-8')); $palavra[] = strtolower(str_replace(" ","-",$word)); endforeach; else: $word = preg_replace($acentos, array_keys($acentos), htmlentities($frase,ENT_NOQUOTES, 'utf-8')); $palavra = strtolower(str_replace(" ","-",$word)); endif; return $palavra; } function trataTxt($var) { $var = strtolower($var); $var = ereg_replace("[]","a",$var); $var = ereg_replace("[ê]","A",$var); $var = ereg_replace("[]","e",$var); $var = ereg_replace("[]","e",$var); $var = ereg_replace("[]","i",$var); $var = ereg_replace("[]","i",$var); $var = ereg_replace("[]","o",$var); $var = ereg_replace("[պ]","O",$var); $var = ereg_replace("[]","u",$var); $var = ereg_replace("[]","U",$var); $var = str_replace("","c",$var); $var = str_replace(" ","-",$var); return $var; } function moeda($valor){ return 'R$ '.number_format($valor, 2, ',', '.'); } function upload_($arquivo, $caminho, $tipo) { $arq = explode(".", $arquivo['name']); $ext = strtolower($arq[count($arq)-1]); if (in_array($ext, $tipo)) { //renomeia o arquivo $arquivo_nome = $arquivo['name']; //Caminho $arquivo_dir = $caminho.$arquivo_nome; //upload if (move_uploaded_file($arquivo["tmp_name"], $arquivo_dir)) return $arquivo_nome; else return false; } else { return false; } } function gera_drop($tipo,$idioma) { $item = $GLOBALS['api']->bd->selectlista("select * from contato_".$tipo."_lang where lang='".$idioma."' order by ".$tipo); foreach($item as $it): echo ''; endforeach; } function meses() { return array ('', 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'); } function mes_extenso($data,$opt=false) { $mes = meses(); $data = explode('-',$data); if($opt==false) return $data[2]. ' de '.$mes[(int)$data[1]].' de '.$data[0]; else return $mes[(int)$data[1]].'/'.$data[0]; } function getPlayer($fsharedUrl) { $login = "admin@internit.com.br"; $senha = "INT@2010"; $options = array('trace' => true, 'exceptions' => true); //print_r($options); //$wsdl = "https://api.4shared.com/jax3/DesktopApp?wsdl"; $wsdl = "http://api2.4shared.com/jax2/DesktopApp?wsdl"; $client = new SoapClient($wsdl, $options); $url = $client->getDirectLink($login, $senha, $fsharedUrl); return $url; } function getUrlId($pg,$_url,$query='') { $pos = array_search($pg,$_url); if(is_numeric($_url[$pos+1])|| !$_url[$pos+1]): $_info['secao'] = $pg; $_info['id'] = $_url[$pos+1]; else: $_info['secao'] = $_url[$pos+1]; $_info['id'] = $_url[$pos+2]; endif; $_info['secao'] = ($query!='')?str_replace('-','_',$_info['secao']):$_info['secao']; return $_info; } function getExt($arq) { $ext = explode('.',$arq); $ult = count($ext); return $ext[$ult-1]; } function getBanner($arq,$pqn=false) { $tamanho = explode('x',$arq['tamanho']); $agente_usuario = $_SERVER['HTTP_USER_AGENT']; $isMobile = "Mobile"; //echo $arq['id_local']; if((getExt($arq['arquivo_lnk'])=='swf') || ($pqn==true)): if (ereg($isMobile, $agente_usuario)): //return ($pqn==true)?$arq['arquivo2_mobile_lnk']:$arq['arquivo_mobile_lnk']; return ''; else: return ' '; endif; else: return ''; endif; } function _thumbs($targetFile,$width,$heigth,$targetPath,$prop,$img) { $prop = explode("x",$prop); $imgsize = getimagesize($targetFile); //Verificando a extens�o do arquivo switch(strtolower(substr($targetFile, -3))){ case "jpg": $image = imagecreatefromjpeg($targetFile); break; case "png": $image = imagecreatefrompng($targetFile); break; case "gif": $image = imagecreatefromgif($targetFile); break; default: exit; break; } $novox = $prop[0]; //New width of image $novoy = $prop[1]; //This maintains proportions $suf = $prop[2]; $pImg = $width / $heigth; $pMini = $novox / $novoy; if($pImg > $pMini){ $novoy = (int)($novox * $heigth)/$width; } if($pImg < $pMini){ $novox = (int)($novoy * $width)/$heigth; } $src_w = $imgsize[0]; $src_h = $imgsize[1]; $picture = imagecreatetruecolor($novox, $novoy); imagealphablending($picture, false); imagesavealpha($picture, true); $bool = imagecopyresampled($picture, $image, 0, 0, 0, 0, $novox, $novoy, $src_w, $src_h); $ex = substr($img, -4); $im = explode(".", $img); $img = $im[0].$suf.$ex; if($suf == "_g" || $suf == "_p") $targetPath = str_replace("admIN/upload/", "media/upload/", $targetPath); if($bool){ switch(strtolower(substr($targetFile, -3))){ case "jpg": //header("Content-Type: image/jpeg"); $bool2 = imagejpeg($picture,$targetPath.$img,95); break; case "png": //header("Content-Type: image/png"); imagepng($picture,$targetPath.$img); break; case "gif": //header("Content-Type: image/gif"); imagegif($picture,$targetPath.$img); break; } } imagedestroy($picture); imagedestroy($image); } function get_qtd($array,$tipo,$tipoImovel=''){ $total = count($array); foreach($array as $a=>$i): if($a==0) $item .=$i; elseif($a==($total-1)) $item .=' e '.$i; else $item .=', '.$i; endforeach; $plural = (($array[0]>1) || $total>1)?'s':''; $tipo = ($tipoImovel!='')?'sala':$tipo; return $item.' '.$tipo.$plural; } ?>