", $text); $text = nl2br($text); $text = str_replace("\t", " ", $text); return $text; } function encodep($text = ""){ $text = htmlentities($text); $text = str_replace("%u201C", "\"", $text); $text = str_replace("%u201D", "\"", $text); $text = str_replace("%u2013", "-", $text); $text = str_replace("\n", "

  ", $text); //$text = nl2br($text); $text = "  " . str_replace("\t", " ", $text); return $text; } function cbDias($name = "dia", $selected = "", $add = ""){ $result = ""; return $result; } $MES = array(); $MES[1] = "Janeiro"; $MES[2] = "Fevereiro"; $MES[3] = "Marco"; $MES[4] = "Abril"; $MES[5] = "Maio"; $MES[6] = "Junho"; $MES[7] = "Julho"; $MES[8] = "Agosto"; $MES[9] = "Setembro"; $MES[10] = "Outubro"; $MES[11] = "Novembro"; $MES[12] = "Dezembro"; function cream_num($var){ if(is_numeric($var)){ $final = $var; }else{ $final = 0; } return $final; } function convert_xml2array(&$result, $root, $rootname='root'){ $n=count($root->children()); if ($n>0){ if (!isset($result[$rootname]['@attributes'])){ $result[$rootname]['@attributes']=array(); foreach ($root->attributes() as $atr=>$value){ $result[$rootname]['@attributes'][$atr]=(string)$value; } } foreach ($root->children() as $child){ $name=$child->getName(); convert_xml2array($result[$rootname][], $child, $name); } }else{ $result[$rootname]= (array) $root; if(!isset($result[$rootname]['@attributes'])){ $result[$rootname]['@attributes']=array(); } } } function cream_cracker($var){ $var = str_replace("'", "\"", $var); $var = str_replace("\\", "/", $var); $var = str_replace(")", "", $var); $var = str_replace("(", "", $var); $var = str_replace("&", "", $var); // $var = str_replace("-", "", $var); $final = $var; return $final; } function html_cream_cracker($var){ $var = str_replace("'", "\"", $var); $var = str_replace("\\", "/", $var); $var = str_replace(")", "", $var); $var = str_replace("(", "", $var); $var = str_replace("&", "", $var); $final = $var; return htmlentities($final); } function is_cracker($var){ $final = $var; $var = str_replace("'", "", $var); $var = str_replace("\\", "", $var); if($final == $var){ return 0; }else{ return 1; } } function is_email($var){ if($var == "[email protected]"){ return 0; } $final = $var; $var = str_replace(".", "", $var); if($final == $var){ return 0; }else{ $final = $var; $var = str_replace("@", "", $var); if($final == $var){ return 0; }else{ return 1; } } } function is_cpf($CampoNumero){ $RecebeCPF=$CampoNumero; $s=""; for ($x=1; $x<=strlen($RecebeCPF); $x=$x+1) { $ch=substr($RecebeCPF,$x-1,1); if (ord($ch)>=48 && ord($ch)<=57) { $s=$s.$ch; } } $RecebeCPF=$s; if (strlen($RecebeCPF)!=11) { return 0; } else if ($RecebeCPF=="00000000000") { $then; return 0; } else { $Numero[1]=intval(substr($RecebeCPF,1-1,1)); $Numero[2]=intval(substr($RecebeCPF,2-1,1)); $Numero[3]=intval(substr($RecebeCPF,3-1,1)); $Numero[4]=intval(substr($RecebeCPF,4-1,1)); $Numero[5]=intval(substr($RecebeCPF,5-1,1)); $Numero[6]=intval(substr($RecebeCPF,6-1,1)); $Numero[7]=intval(substr($RecebeCPF,7-1,1)); $Numero[8]=intval(substr($RecebeCPF,8-1,1)); $Numero[9]=intval(substr($RecebeCPF,9-1,1)); $Numero[10]=intval(substr($RecebeCPF,10-1,1)); $Numero[11]=intval(substr($RecebeCPF,11-1,1)); $soma=10*$Numero[1]+9*$Numero[2]+8*$Numero[3]+7*$Numero[4]+6*$Numero[5]+5* $Numero[6]+4*$Numero[7]+3*$Numero[8]+2*$Numero[9]; $soma=$soma-(11*(intval($soma/11))); if ($soma==0 || $soma==1) { $resultado1=0; } else { $resultado1=11-$soma; } if ($resultado1==$Numero[10]) { $soma=$Numero[1]*11+$Numero[2]*10+$Numero[3]*9+$Numero[4]*8+$Numero[5]*7+$Numero[6]*6+$Numero[7]*5+ $Numero[8]*4+$Numero[9]*3+$Numero[10]*2; $soma=$soma-(11*(intval($soma/11))); if ($soma==0 || $soma==1) { $resultado2=0; } else { $resultado2=11-$soma; } if ($resultado2==$Numero[11]) { return 1; } else { return 0; } } else { return 0; } } } function is_cnpj($CampoNumero){ $RecebeCNPJ=${"CampoNumero"}; $s=""; for ($x=1; $x<=strlen($RecebeCNPJ); $x=$x+1) { $ch=substr($RecebeCNPJ,$x-1,1); if (ord($ch)>=48 && ord($ch)<=57) { $s=$s.$ch; } } $RecebeCNPJ=$s; if (strlen($RecebeCNPJ)!=14) { return 0; } else if ($RecebeCNPJ=="00000000000000") { $then; return 0; } else { $Numero[1]=intval(substr($RecebeCNPJ,1-1,1)); $Numero[2]=intval(substr($RecebeCNPJ,2-1,1)); $Numero[3]=intval(substr($RecebeCNPJ,3-1,1)); $Numero[4]=intval(substr($RecebeCNPJ,4-1,1)); $Numero[5]=intval(substr($RecebeCNPJ,5-1,1)); $Numero[6]=intval(substr($RecebeCNPJ,6-1,1)); $Numero[7]=intval(substr($RecebeCNPJ,7-1,1)); $Numero[8]=intval(substr($RecebeCNPJ,8-1,1)); $Numero[9]=intval(substr($RecebeCNPJ,9-1,1)); $Numero[10]=intval(substr($RecebeCNPJ,10-1,1)); $Numero[11]=intval(substr($RecebeCNPJ,11-1,1)); $Numero[12]=intval(substr($RecebeCNPJ,12-1,1)); $Numero[13]=intval(substr($RecebeCNPJ,13-1,1)); $Numero[14]=intval(substr($RecebeCNPJ,14-1,1)); $soma=$Numero[1]*5+$Numero[2]*4+$Numero[3]*3+$Numero[4]*2+$Numero[5]*9+$Numero[6]*8+$Numero[7]*7+ $Numero[8]*6+$Numero[9]*5+$Numero[10]*4+$Numero[11]*3+$Numero[12]*2; $soma=$soma-(11*(intval($soma/11))); if ($soma==0 || $soma==1) { $resultado1=0; } else { $resultado1=11-$soma; } if ($resultado1==$Numero[13]) { $soma=$Numero[1]*6+$Numero[2]*5+$Numero[3]*4+$Numero[4]*3+$Numero[5]*2+$Numero[6]*9+ $Numero[7]*8+$Numero[8]*7+$Numero[9]*6+$Numero[10]*5+$Numero[11]*4+$Numero[12]*3+$Numero[13]*2; $soma=$soma-(11*(intval($soma/11))); if ($soma==0 || $soma==1) { $resultado2=0; } else { $resultado2=11-$soma; } if ($resultado2==$Numero[14]) { return 1; } else { return 0; } } else { return 0; } } } function quebra_nozes($text){ $final_text = str_replace(chr(13), "
", $text); return $final_text; } function quebra_mil($text){ $nloop = 0; for($loop = 0; $loop <= strlen($text); $loop++){ if($nloop == 4){ $final_text = "." . $final_text; $nloop = 1; } $nloop++; $nstr = substr($text, (strlen($text) - $loop), 1); $final_text = $nstr . $final_text; } if($final_text == ""){ $final_text = "0"; } return $final_text; } function add_nozes($var, $nozes){ while($nozes > strlen($var)){ $var = "0" . $var; } return $var; } function idade($mes, $dia, $ano){ $ano_atual = date("Y"); $mes_atual = date("m"); $dia_atual = date("d"); if(($mes < $mes_autal)||($dia <= $dia_atual && $mes == $mes_autal)){ $idade = ($ano_atual - $ano); }else{ $idade = ($ano_atual - $ano) - 1; } return $idade; } function draw_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){ $first_of_month = gmmktime(0,0,0,$month,1,$year); $day_names = array(); #generate all the day names according to the current locale for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400){ #January 4, 1970 was a Sunday $day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name } list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month)); $weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day $title = htmlentities(ucfirst($month_name)).' '.$year; #note that some locales don't capitalize month and day names #Begin calendar. Uses a real . See http://diveintomark.org/archives/2002/07/03 @list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable if($p){ $p = ''.($pl ? ''.$p.'' : $p).' '; } if($n){ $n = ' '.($nl ? ''.$n.'' : $n).''; } $calendar = ''."\n". '\n"; if($day_name_length){ #if the day names should be shown ($day_name_length > 0) #if day_name_length is >3, the full name of the day will be printed foreach($day_names as $d){ $calendar .= ''; } $calendar .= "\n"; } if($weekday > 0){ $calendar .= ''; } #initial 'empty' days for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){ if($weekday == 7){ $weekday = 0; #start a new week $calendar .= "\n"; } if(isset($days[$day]) and is_array($days[$day])){ @list($link, $classes, $content) = $days[$day]; if(is_null($content)){ $content = $day; } $calendar .= '' : '>'). ($link ? ''.$content.'' : $content).''; } else $calendar .= ""; } if($weekday != 7){ $calendar .= ''; #remaining "empty" days } return $calendar."\n
'.$p.($month_href ? ''.$title.'' : $title).$n."
'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'
 
$day 
\n"; } ?>