"; var $lng; function ErrorReports(){ require(EREPORTS_LANG_DIR.'er.'.strtolower(EREPORTS_LANG).'.php'); } //Mostra erros function display($errors='ND'){ if($errors=='ND'){ $errors=$this->errors; } if($errors!=''){ global ${$this->tpl_object}; ${$this->tpl_object}->assign($this->tpl_var,$errors); $error_page=${$this->tpl_object}->fetch($this->template); ${$this->tpl_object}->clear_assign('ERRORS'); return $error_page; } } function add($error,$title=''){ if($title!=''){ $this->errors.="- ".$title.": ".$error.$this->linebreak; } else{ $this->errors.="- ".$error.$this->linebreak; } } //Verifica tamanho de uma string function check_length($value,$field,$min_chars,$max_chars){ $error=""; if(strlen($value)>0){ if(strlen($value)<$min_chars){ $error="- ".$field.": ".str_replace('%n%',$min_chars,$this->lng['minChars']).$this->linebreak; } if(strlen($value)>$max_chars){ $error="- ".$field.": ".str_replace('%n%',$max_chars,$this->lng['maxChars']).$this->linebreak; } if(strlen($value)>0 && strlen($value)<$max_chars && $max_chars==$min_chars){ $error="- ".$field.": ".str_replace('%n%',$min_chars,$this->lng['fixedChars']).$this->linebreak; } } $this->errors.=$error; return $error; } //Verifica se uma string est� em conformidade com a express�o regular fornecida function is_other($reg_exp,$value,$field,$custom_error,$check_empty=true){ $error=""; if(strlen($value)>0){ if(eregi($reg_exp,$value)){ $error="- ".$field.": ".$custom_error.$this->linebreak; } } else{ if($check_empty){ $error="- ".$field.": ".$this->lng['emptyString'].$this->linebreak; } } $this->errors.=$error; return $error; } //Verifica se uma string � composta por algarismos function is_mail($value,$field,$check_empty=true){ $error=""; if(strlen($value)>0){ if(!eregi("^([a-z0-9]{1,}((\.|_|\-)[a-z0-9]+)*)+@(([a-z0-9]+\.)|([a-z0-9]+\-[a-z0-9]))+[a-z]{2,4}$",$value)){ $error="- ".$field.": ".$this->lng['wrongMailFormat'].$this->linebreak; } } else{ if($check_empty){ $error="- ".$field.": ".$this->lng['emptyString'].$this->linebreak; } } $this->errors.=$error; return $error; } //Verifica se uma string � composta por algarismos function is_cstring($value,$field,$check_empty=true){ $error=""; if(strlen($value)>0){ if(eregi("[\"';<>]",$value)){ $error="- ".$field.": ".str_replace('%chars%',"';>\"<",$this->lng['wrongFormat']).$this->linebreak; } } else{ if($check_empty){ $error="- ".$field.": ".$this->lng['emptyString'].$this->linebreak; } } $this->errors.=$error; return $error; } //Verifica se uma string � composta por algarismos function is_num($value,$field,$check_empty=true){ $error=""; if(strlen($value)>0){ if(!eregi('^[0-9]+$',$value)){ $error="- ".$field.": ".$this->lng['onlyNumbers'].$this->linebreak; } } else{ if($check_empty){ $error="- ".$field.": ".$this->lng['emptyString'].$this->linebreak; } } $this->errors.=$error; return $error; } function is_fnum($value,$field,$check_empty=true){ $error=""; if(strlen($value)>0){ if(!eregi('^[0-9]+((\.){1}[0-9]+)?$',$value)){ $error="- ".$field.": ".$this->lng['onlyDecimalNumbers'].$this->linebreak; } } else{ if($check_empty){ $error="- ".$field.": ".$this->lng['emptyString'].$this->linebreak; } } $this->errors.=$error; return $error; } //Verifica se uma string � composta por letras de 'a' a 'Z' function is_text($value,$field,$check_empty=true){ $error=""; if(strlen($value)>0){ if(!eregi('^[a-z'.$this->special_chars.']+([[:space:]]*[a-z'.$this->special_chars.']*)*$',$value)){ $error="- ".$field.": ".$this->lng['onlyLetters'].$this->linebreak; } } else{ if($check_empty){ $error="- ".$field.": ".$this->lng['emptyString'].$this->linebreak; } } $this->errors.=$error; return $error; } //Verifica se uma string � composta por algarismos e/ou letras function is_mixed($value,$field,$check_empty=true){ $error=""; if(strlen($value)>0){ if(!eregi('^[a-z0-9'.$this->special_chars.']+([[:space:]]+[a-z0-9'.$this->special_chars.']*)*$',$value)){ $error="- ".$field.": ".$this->lng['lettersAndNumbers'].$this->linebreak; } } else{ if($check_empty){ $error="- ".$field.": ".$this->lng['emptyString'].$this->linebreak; } } $this->errors.=$error; return $error; } function is_safe($value,$field,$check_empty=true){ $error=""; if(strlen($value)>0){ if(eregi("^(;|,|\'|\")",$value)){ $error="- ".$field.": ".$this->lng['safeString'].$this->linebreak; } } else{ if($check_empty){ $error="- ".$field.": ".$this->lng['emptyString'].$this->linebreak; } } $this->errors.=$error; return $error; } function is_domain($value,$field,$check_empty=true){ $error=""; $regex="^(www\.)?".//www "([0-9A-Z]{2,}((\-[0-9A-Z]{2,}))*\.)+".//subdominios/dominios "([a-z]{2,6}){1}$";//tld if(strlen($value)>0){ if(!eregi($regex,$value)){ $error="- ".$field.": ".$this->lng['wrongDomainFormat'].".

"; } } else{ if($check_empty){ $error="- ".$field.": ".$this->lng['emptyString'].$this->linebreak; } } $this->errors.=$error; return $error; } function is_url($value,$field,$check_empty=true){ $error=""; $regex="^(http|https|ftp|sftp){1}://(www\.)?".//www "([0-9A-Z]{2,}((\-[0-9A-Z]{2,}))*\.)+".//subdominios/dominios "([0-9a-z]{2,6}/*){1}".//tld "((\/[a-z0-9]+)*".//pastas "(\.[a-z0-9_-]+)*)*".//extensoes ".*$";//parametros if(strlen($value)>0){ if(!eregi($regex,$value)){ $error="- ".$field.": ".$this->lng['wrongURLFormat'].$this->linebreak; } } else{ if($check_empty){ $error="- ".$field.": ".$this->lng['emptyString'].$this->linebreak; } } $this->errors.=$error; return $error; } function in_between($value,$field,$min,$max,$check_empty=true){ $error=""; if(!($value>$min and $value<$max)){ $error="- ".$field.": ".str_replace(array('%min%','%max%'),array($min,$max),$this->lng['inBetween']).$this->linebreak; } else{ if($check_empty){ $error="- ".$field.": ".$this->lng['emptyString'].$this->linebreak; } } $this->errors.=$error; return $error; } } ?>