function formatta_numero ($cifra) { return number_format($cifra,2,',','.'); } function generatePassword($length=9, $strength=0) { $vowels = 'aeuy'; $consonants = 'bdghjmnpqrstvz'; if ($strength & 1) { $consonants .= 'BDGHJLMNPQRSTVWXZ'; } if ($strength & 2) { $vowels .= "AEUY"; } if ($strength & 4) { $consonants .= '23456789'; } if ($strength & 8) { $consonants .= '@#$%'; } $password = ''; $alt = time() % 2; for ($i = 0; $i < $length; $i++) { if ($alt == 1) { $password .= $consonants[(rand() % strlen($consonants))]; $alt = 0; } else { $password .= $vowels[(rand() % strlen($vowels))]; $alt = 1; } } return $password; } /** *format_ts :: Questa funzione ha il compito di formattare il timestamp dal formato aaaa-mm-gg HH:MM:SS nel formato gg-mm-aaaa HH:MM:SS *@param string $data data nel formato aaaa-mm-gg HH:MM:SS da convertire *@return string la stessa data nel formato gg-mm-aaaa HH:MM:SS */ function format_ts ($data) { if ($data != ""){ $giorno = substr($data,0,10); $tmp = explode("-",$giorno); $newgiorno = $tmp[2]."-".$tmp[1]."-".$tmp[0]; $orario = substr($data,11,8); $newdata = $newgiorno." ".$orario; return $newdata; } else { return $data; } } /** *formatdata_it2en :: Questa funzione ha il compito di convertire una data dal formato gg-mm-aaaa nel formato aaaa-mm-gg *@param string $data data nel formato gg-mm-aaaa da convertire *@return string la stessa data nel formato aaaa-mm-gg */ function formatdata_it2en ($data) { if ($data != ""){ $tmp = explode("-",$data); $newdata = $tmp[2]."-".$tmp[1]."-".$tmp[0]; return $newdata; } else { return $data; } } /** *formatdata_en2it :: Questa funzione ha il compito di convertire una data dal formato aaaa-mm-gg nel formato gg-mm-aaaa *@param string $data data nel formato aaaa-mm-gg da convertire *@return string la stessa data nel formato gg-mm-aaaa */ function formatdata_en2it ($data) { if ($data != ""){ $tmp = explode("-",$data); $newdata = $tmp[2]."-".$tmp[1]."-".$tmp[0]; return $newdata; } else { return $data; } } function Find ($array, $element) { while (list ($key, $val) = each ($array)) if ( intval($val) == intval($element)) return 1; return 0; } ?>