// Funktion för att kolla lägga produkt i varukorg function addCart($productid,$quantity,$price,$info,$fraktkoll){ if($productid<1 or $quantity<1 or $price<1) return; $pIDX=rand(); if(is_array($_SESSION['cart'])){ if(product_exists($productid,$quantity)) return; $max=count($_SESSION['cart']); $_SESSION['cart'][$max]['productid']=$productid; $_SESSION['cart'][$max]['quantity']=$quantity; $_SESSION['cart'][$max]['price']=$price; $_SESSION['cart'][$max]['info']=$info; $_SESSION['cart'][$max]['fraktkoll']=$fraktkoll; $_SESSION['cart'][$max]['pID']=$pIDX; } else{ $_SESSION['cart']=array(); $_SESSION['cart'][0]['productid']=$productid; $_SESSION['cart'][0]['quantity']=$quantity; $_SESSION['cart'][0]['price']=$price; $_SESSION['cart'][0]['info']=$info; $_SESSION['cart'][0]['fraktkoll']=$fraktkoll; $_SESSION['cart'][0]['pID']=$pIDX;; } } function addCartSpec($productid,$quantity,$price,$info,$koll,$fraktkoll){ if($productid<1 or $quantity<1 or $price<1) return; $pIDX=rand(); if(is_array($_SESSION['cart'])){ // if(product_exists($productid,$quantity)) return; $max=count($_SESSION['cart']); $_SESSION['cart'][$max]['productid']=$productid; $_SESSION['cart'][$max]['quantity']=$quantity; $_SESSION['cart'][$max]['price']=$price; $_SESSION['cart'][$max]['info']=$info; $_SESSION['cart'][$max]['koll']=$koll; $_SESSION['fraktkoll'] = $fraktkoll; $_SESSION['cart'][$max]['pID']=$pIDX; } else{ $_SESSION['cart']=array(); $_SESSION['cart'][0]['productid']=$productid; $_SESSION['cart'][0]['quantity']=$quantity; $_SESSION['cart'][0]['price']=$price; $_SESSION['cart'][0]['info']=$info; $_SESSION['cart'][0]['koll']=$koll; $_SESSION['fraktkoll'] = $fraktkoll; $_SESSION['cart'][0]['pID']=$pIDX;; } } function addCartTP($productid,$quantity,$price,$info,$koll,$koll2,$fraktkoll,$fraktkoll2){ if($productid<1 or $quantity<1 or $price<1) return; $pIDX=rand(); if(is_array($_SESSION['cart'])){ // if(product_exists($productid,$quantity)) return; $max=count($_SESSION['cart']); $_SESSION['cart'][$max]['productid']=$productid; $_SESSION['cart'][$max]['quantity']=$quantity; $_SESSION['cart'][$max]['price']=$price; $_SESSION['cart'][$max]['info']=$info; $_SESSION['cart'][$max]['koll']=$koll; $_SESSION['cart'][$max]['koll2']=$koll2; $_SESSION['fraktkoll'] = $fraktkoll; $_SESSION['fraktkoll2'] = $fraktkoll2; $_SESSION['cart'][$max]['pID']=$pIDX; } else{ $_SESSION['cart']=array(); $_SESSION['cart'][0]['productid']=$productid; $_SESSION['cart'][0]['quantity']=$quantity; $_SESSION['cart'][0]['price']=$price; $_SESSION['cart'][0]['info']=$info; $_SESSION['cart'][0]['koll']=$koll; $_SESSION['cart'][0]['koll2']=$koll2; $_SESSION['fraktkoll'] = $fraktkoll; $_SESSION['fraktkoll2'] = $fraktkoll2; $_SESSION['cart'][0]['pID']=$pIDX;; } } // Funktion för att kolla så varukorgen inte innehåller dubletter function product_exists($productid,$quantity){ $productid=intval($productid); $quantity=intval($quantity); $max=count($_SESSION['cart']); $flag=0; for($i=0;$i<$max;$i++){ if($productid==$_SESSION['cart'][$i]['productid']){ $flag=1; break; } } return $flag; } function addCart2($productid,$quantity,$price,$info){ if($productid<1 or $quantity<1 or $price<1) return; if(is_array($_SESSION['cart'])){ $varde=product_exists2($productid,$quantity); echo $varde; exit; if($varde!="") { $_SESSION['cart'][$varde]['quantity'] = $_SESSION['cart'][$varde]['quantity'] + 1; } else { $max=count($_SESSION['cart']); $_SESSION['cart'][$max]['productid']=$productid; $_SESSION['cart'][$max]['quantity']=$quantity; $_SESSION['cart'][$max]['price']=$price; $_SESSION['cart'][$max]['info']=$info; } } else { $_SESSION['cart']=array(); $_SESSION['cart'][0]['productid']=$productid; $_SESSION['cart'][0]['quantity']=$quantity; $_SESSION['cart'][0]['price']=$price; $_SESSION['cart'][0]['info']=$info; } } // Funktion för att kolla så varukorgen inte innehåller dubletter function product_exists2($productid,$quantity){ $productid=intval($productid); $quantity=intval($quantity); $max=count($_SESSION['cart']); $flag=0; for($i=0;$i<$max;$i++){ if($productid==$_SESSION['cart'][$i]['productid']){ $flag=$i; break; } } return $flag; } // Funktion för att radera produkt ur varukorgen function remove_product($productid,$pID){ $productid=intval($productid); $pID=intval($pID); $max=count($_SESSION['cart']); for($i=0;$i<$max;$i++){ if(($productid==$_SESSION['cart'][$i]['productid']) && ($pID==$_SESSION['cart'][$i]['pID']) && ($_SESSION['cart'][$i]['koll']!='0')) { $_SESSION['fraktkoll'] = ($_SESSION['fraktkoll']-$_SESSION['cart'][$i]['koll']); unset($_SESSION['cart'][$i]); break; } if(($productid==$_SESSION['cart'][$i]['productid']) && ($pID==$_SESSION['cart'][$i]['pID']) && ($_SESSION['cart'][$i]['koll2']!='0')) { $_SESSION['fraktkoll2'] = ($_SESSION['fraktkoll2']-$_SESSION['cart'][$i]['koll2']); unset($_SESSION['cart'][$i]); break; } if(($productid==$_SESSION['cart'][$i]['productid']) && ($pID==$_SESSION['cart'][$i]['pID']) && ($_SESSION['cart'][$i]['koll2']=='0') && ($_SESSION['cart'][$i]['koll']=='0')) { $_SESSION['fraktkoll'] = ($_SESSION['fraktkoll']-$_SESSION['cart'][$i]['koll']); unset($_SESSION['cart'][$i]); break; } } $_SESSION['cart']=array_values($_SESSION['cart']); } // Funktion för att hämta produktnamn function get_product_name($produktid){ global $koppling; $result=$koppling->query("SELECT namn FROM sortiment_produkt WHERE artikelnr='$produktid'") or die(mysqli_error());; $row = $result->fetch_assoc(); return $row['namn']; } // Funkrion för att hämta pris på produkt function get_price($produktid){ global $koppling; $result=$koppling->query("SELECT pris FROM sortiment_produkt WHERE artikelnr='$produktid'"); $row = $result->fetch_assoc(); return $row['pris']; } // Funktion för att hämta rabattkod function get_cupon($cupon){ global $koppling; $rabattkoll=$koppling->query("SELECT * FROM webshop_discount WHERE code='$cupon'") or (mysqli_error(die)); $rad = $rabattkoll->fetch_assoc(); // Om felaktikgt kod if (mysqli_num_rows($rabattkoll) == 0) { $mox=$cupon; header("Location: /varukorg/kodfel/"); } else { $_SESSION['rabatt']=(100-$rad['procent'])/100; $mox=$rad['procent']; header("Location: /varukorg/kodok/"); } return $mox; } // Funktion för att räkna ut totalpriset i varukorgen function get_order_total(){ $max=count($_SESSION['cart']); $sum=0; for($i=0;$i<$max;$i++){ $pid=$_SESSION['cart'][$i]['productid']; $q=$_SESSION['cart'][$i]['quantity']; //$price=get_price($pid); $price=$_SESSION['cart'][$i]['price']; $sum+=$price*$q; } return $sum; } // Funktion för att räkna ut totalt antal valda varor function get_total_choise(){ $max=count($_SESSION['cart']); $sum=0; for($i=0;$i<$max;$i++){ $pid=$_SESSION['cart'][$i]['productid']; $q=$_SESSION['cart'][$i]['quantity']; $totalX+=$q; } if(($totalX=="") OR ($totalX=="0")) { return " tom"; } else if($totalX=="1") { return $totalX." produkt"; } else { return $totalX." produkter"; } } //Funktion för att resna hela varukorgen function clear_cart() { unset($_SESSION['fraktkoll']); unset($_SESSION['fraktkoll2']); unset($_SESSION['cart']); $_SESSION['cart']=array_values($_SESSION['cart']); } function update_cart($productid,$quantity) { $max=count($_SESSION['cart']); for($i=0;$i<$max;$i++){ $pid=$_SESSION['cart'][$i]['productid']; $q=intval($_REQUEST['product'.$pid]); if($q>0 && $q<=999){ $_SESSION['cart'][$i]['quantity']=$q; } else { $msg='Some proudcts not updated!, quantity must be a number between 1 and 999'; } } } function krypt1($data = "", $width=192, $rounds = 3) { return substr( implode( array_map( function ($h) { return str_pad(bin2hex(strrev($h)), 16, "0"); }, str_split(hash("tiger192,$rounds", $data, true), 8) ) ), 0, 48-(192-$width)/4 ); } // Funktion för att kryptera lösenord. function krypt($string) { if ($string != "") { $retstring=""; for($i=0;$i < strlen($string); $i++) { $retstring[$i]=chr((ord($string[$i])+($i%60))); } return $retstring; } else { return false; } } // Funktion för att dekryptera lösenord. function dekryptOLD($string) { if ($string != "") { $retstring=""; for($i=0;$i < strlen($string); $i++) { $retstring[$i]=chr((ord($string[$i])-($i%60))); } return implode("",$retstring); } else { return false; } } // Funktion för att skapa SEO vänliga urler function urlname( $s, $charset='utf-8' ) { $pattern = '/&([a-z][ze]?)(uml|acute|circ|tilde|ring|lig|grave|slash|horn|cedil|th);/i'; $replace = "\\1"; $s = htmlentities($s, ENT_NOQUOTES, $charset); $s = preg_replace($pattern, $replace, $s); $s = html_entity_decode($s, ENT_NOQUOTES, $charset); return preg_replace('/[^a-z0-9._-]/', '-', strtolower( $s )); } // Funktion för att ladda upp bilder och beskära class thumbnail { var $img; function thumbnail($imgfile) { //detect image format $this->img["format"] = preg_replace("#.*\.(.*)$#", "\\1", $imgfile); $this->img["format"] = strtoupper($this->img["format"]); if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") { //JPEG $this->img["format"]="JPEG"; $this->img["src"] = ImageCreateFromJPEG ($imgfile); } else if ($this->img["format"]=="PNG") { //PNG $this->img["format"]="PNG"; $this->img["src"] = ImageCreateFromPNG ($imgfile); } else if ($this->img["format"]=="GIF") { //GIF $this->img["format"]="GIF"; $this->img["src"] = ImageCreateFromGIF ($imgfile); } else if ($this->img["format"]=="WBMP") { //WBMP $this->img["format"]="WBMP"; $this->img["src"] = ImageCreateFromWBMP ($imgfile); } else { //DEFAULT echo "Not Supported File"; exit(); } @$this->img["lebar"] = imagesx($this->img["src"]); @$this->img["tinggi"] = imagesy($this->img["src"]); //default quality jpeg $this->img["quality"]=75; } function size_height($size=100) { //height $this->img["tinggi_thumb"]=$size; //@$this->img["lebar_thumb"] = ($this->img["tinggi_thumb"]/$this->img["tinggi"])*$this->img["lebar"]; } function size_width($size=100) { //width $this->img["lebar_thumb"]=$size; //@$this->img["tinggi_thumb"] = ($this->img["lebar_thumb"]/$this->img["lebar"])*$this->img["tinggi"]; } function size_auto($size=500) { //size if ($this->img["lebar"]>=$this->img["tinggi"]) { $this->img["lebar_thumb"]=$size; @$this->img["tinggi_thumb"] = ($this->img["lebar_thumb"]/$this->img["lebar"])*$this->img["tinggi"]; } else { $this->img["tinggi_thumb"]=$size; @$this->img["lebar_thumb"] = ($this->img["tinggi_thumb"]/$this->img["tinggi"])*$this->img["lebar"]; } } function jpeg_quality($quality=75) { //jpeg quality $this->img["quality"]=$quality; } function show() { //show thumb @Header("Content-Type: image/".$this->img["format"]); /* change ImageCreateTrueColor to ImageCreate if your GD not supported ImageCreateTrueColor function*/ $this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]); @imagecopyresampled ($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]); if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") { //JPEG imageJPEG($this->img["des"],"",$this->img["quality"]); } elseif ($this->img["format"]=="PNG") { //PNG imagePNG($this->img["des"]); } elseif ($this->img["format"]=="GIF") { //GIF imageGIF($this->img["des"]); } elseif ($this->img["format"]=="WBMP") { //WBMP imageWBMP($this->img["des"]); } } function save($save="") { //save thumb if (empty($save)) $save=strtolower("./thumb.".$this->img["format"]); /* change ImageCreateTrueColor to ImageCreate if your GD not supported ImageCreateTrueColor function*/ $this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]); ImageCopyResampled($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]); if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") { //JPEG imageJPEG($this->img["des"],"$save",$this->img["quality"]); } elseif ($this->img["format"]=="PNG") { //PNG imagePNG($this->img["des"],"$save"); } elseif ($this->img["format"]=="GIF") { //GIF imageGIF($this->img["des"],"$save"); } elseif ($this->img["format"]=="WBMP") { //WBMP imageWBMP($this->img["des"],"$save"); } } } function stammerPersonnummer($personnummer, $kon){ for($i = 2; $i < 13; $i++) if($i != 8) @$kontroll += ($nummer = $personnummer[$i] * (2 - @$uddaEllerJamn++ % 2)) > 9 ? $nummer - 9 : $nummer; return $personnummer[11] % 2 == ($kon == "Man") && !($kontroll % 10); } ?> $actual_linkX = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $partsX = parse_url($actual_linkX); $path_partsX= explode('/', $partsX[path]); $active = $path_partsX[1]; $thispage = isset($_GET['id']) ? $_GET['id'] : ''; $kkl = isset( $_GET["visa"] ) ? $_GET["visa"] : null; $readmoreX=isset( $_GET["visa"] ) ? $_GET["visa"] : null; if(($thispage=="") OR ($thispage=="startsida")) { $desctitle="Välkommen till Nordsvenska Bangolfförbundet"; } else if($thispage=="nyhetsarkiv") { $desctitle="Nyhetsarkiv"; } else if($thispage=="nyheter") { if($kkl!="") { $infoX=$koppling->query("SELECT * FROM webshop_news WHERE url='$readmoreX'") or die(mysqli_error()); $raf = $infoX->fetch_assoc(); $desctitle=$raf['rubrik']; } else { $desctitle="Nyhetsarkiv"; } } else { $infoX=$koppling->query("SELECT * FROM webshop_pages WHERE url='$kkl'") or die(mysqli_error()); $raf = $infoX->fetch_assoc(); $desctitle=$raf['namn']; } ?>
Välkommen till Nordsvenska Bangolfförbundet