0) { --$i; $c =ord($s[$i]); if (($c & 0xC0) == 0xC0) { // two most significante bits on if (($c != 215) and ($c != 223)){ // two chars OK as is // to get lowercase set 3. most significante bit if needed: $s[$i] = chr($c | 0x20); } } } return strtolower($s); } function ucfirst_sentence($str,$a_char = array("-"," ")){ //$str contains the complete raw name string //$a_char is an array containing the characters we use as separators for capitalization. If you don't pass anything, there are three in there as default. $string = strtolower_iso8859_1($str); foreach ($a_char as $temp){ $pos = strpos($string,$temp); if ($pos){ //we are in the loop because we found one of the special characters in the array, so lets split it up into chunks and capitalize each one. $mend = ''; $a_split = explode($temp,$string); foreach ($a_split as $temp2){ //capitalize each portion of the string which was separated at a special character $mend .= ucfirst($temp2).$temp; } $string = substr($mend,0,-1); } } return ucfirst($string); } // Fjerner man denne går alt til helvette, ikke forstår jeg hvorfor... echo " "; // Lager en funksjon for å gjøre om nl2br funksjonen function br2nl($text) { $text = str_replace("
","",$text); $text = str_replace("
","",$text); return $text; } // Fikser datohelvette! function makedate($inputdato) { //2005-04-03 20:36:35 $dato=substr($inputdato, 8, 2); if (substr($dato, 0, 1) == "0") { $dato=substr($dato, 1, 1); }; $month=substr($inputdato, 5, 2); if ($month == "01") { $month="Januar"; } if ($month == "02") { $month="Februar"; } if ($month == "03") { $month="Mars"; } if ($month == "04") { $month="April"; } if ($month == "05") { $month="Mai"; } if ($month == "06") { $month="Juni"; } if ($month == "07") { $month="Juli"; } if ($month == "08") { $month="August"; } if ($month == "09") { $month="September"; } if ($month == "10") { $month="Oktober"; } if ($month == "11") { $month="November"; } if ($month == "12") { $month="Desember"; } $year=substr($inputdato, 0, 4); $hour=substr($inputdato, 11, 2); $min=substr($inputdato, 14, 2); print "$dato. $month $year - $hour:$min"; } // Beregner alder, basert på input i format: YYYY-MM-DD function getage($dob) { list($year,$month,$day) = explode("-",$dob); $year_diff = date("Y") - $year; $month_diff = date("m") - $month; $day_diff = date("d") - $day; if ($month_diff < 0) $year_diff--; elseif (($month_diff==0) && ($day_diff < 0)) $year_diff--; return $year_diff; } // Sjekker om en string er alfanumerisk function eralphanum($str) { $str=ereg_replace("[^A-Za-z0-9]", "", $str); print "$str"; } function makefodt($fodt) { $y=substr($fodt, 0, 4); $m=substr($fodt, 5, 2); $d=substr($fodt, 8, 2); if (substr($d, 0, 1) == "0") { $d=substr($d, 1, 1); }; if ($m == "01") { $m="Januar"; } if ($m == "02") { $m="Februar"; } if ($m == "03") { $m="Mars"; } if ($m == "04") { $m="April"; } if ($m == "05") { $m="Mai"; } if ($m == "06") { $m="Juni"; } if ($m == "07") { $m="Juli"; } if ($m == "08") { $m="August"; } if ($m == "09") { $m="September"; } if ($m == "10") { $m="Oktober"; } if ($m == "11") { $m="November"; } if ($m == "12") { $m="Desember"; } print "$d. $m $y"; } // // getCount() // // Oppdaterer sidetreff, unike treff og sist innlogget tid for brukere. // function getCount($setting='') { $login = $_SESSION['login']; $db=mysql_connect(localhost, lanv6, lan5GFH3) or die ("Could not connect"); mysql_select_db(lanv6); if (isset($login)) { // Her er det en bruker som er logget inn! La oss oppdatere reg-infoen hans! $ip = getenv("REMOTE_ADDR"); $sql="SELECT * FROM lanv155_deltakere WHERE nick LIKE '$login'"; $result=mysql_query($sql,$db); $num=mysql_num_rows($result); $row=mysql_fetch_array($result); $id=$row['ID']; $dato = date("ymdHis"); mysql_query("INSERT INTO lanv155_bruker_logs VALUES('','$id','$ip',NULL)"); mysql_query("UPDATE lanv6.lanv155_deltakere SET `sist_innlogget` = '$dato' WHERE lanv155_deltakere.ID = '$id' LIMIT 1 ;"); } else { // Her er det en bruker som ikke er logget inn, bare hiv en til på sidetreffbasen. $ip = getenv("REMOTE_ADDR"); mysql_query("INSERT INTO lanv155_bruker_logs VALUES('','0','$ip',NULL)"); } } // // Lager ett tilfeldig passord som ineholder A-Za-z0-9 og som har lengden $length. // function genPass($length="8") { return(substr(ereg_replace("[^a-z0-9]", "", crypt(time())) . ereg_replace("[^a-z0-9]", "", crypt(time())) . ereg_replace("[^a-z0-9]", "", crypt(time())), 0, $length)); } // // brukerIdle - viser om en bruker er aktiv,idle, more idle eller offline... // function brukerIdle($brukerID='') { $q = mysql_query("SELECT UNIX_TIMESTAMP(sist_innlogging) as mydate FROM tlan6_bruker WHERE id='$brukerID'") or die(sql_error()); $idle = mysql_fetch_row($q); if(time() - 30 < $idle[0]) { $idle = "Aktiv"; } elseif(time()- 120 < $idle[0]) { $idle = "Idle"; } elseif(time() - 180 < $idle[0]) { $idle = "More Idle"; } else { $idle = "Offline"; } return $idle; } // function idle() // // DEFINISJONER FOR HEADERE, FOOTERE OG MELLOMSTYKKER - GRAFIKK! // $header1 = "
"; if ($_SESSION[kat] == "seatreg") { $divmargin = "
"; } else { $divmargin = "
"; } $header2 = "
$divmargin "; $footer = "
 
"; $divider = "
"; // IMAGE RESIZER class ImgResizer { private $originalFile = ''; public function __construct($originalFile = '') { $this -> originalFile = $originalFile; } public function resize($newWidth, $targetFile) { if (empty($newWidth) || empty($targetFile)) { return false; } $info = exif_imagetype($targetFile); if ($info == "1") { $src = imagecreatefromgif($this -> originalFile); } if ($info == "2") { $src = imagecreatefromjpeg($this -> originalFile); } if ($info == "3") { $src = imagecreatefrompng($this -> originalFile); } list($width, $height) = getimagesize($this -> originalFile); $newHeight = ($height / $width) * $newWidth; $tmp = imagecreatetruecolor($newWidth, $newHeight); imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); if (file_exists($targetFile)) { unlink($targetFile); } imagejpeg($tmp, $targetFile, 85); // 85 is my choice, make it between 0 – 100 for output image quality with 100 being the most luxurious } }