Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2013
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.62 KB | None | 0 0
  1. <?php require_once("wp-load.php"); session_start();  
  2.  
  3.  
  4.     function add_cart($kas=0,$type,$type2,$plotis,$kiekis,$aukstis,$type3=0) {
  5.         $id=time();
  6.         $all=$kas."_".$type."_".$type2."_".$plotis."_".$kiekis."_".$aukstis."_".$type3;      
  7.         $_SESSION['skaiciuokle_'.$id] = $all;      
  8.     }  
  9.     function del_cart($id) {
  10.         foreach($_SESSION as $key=>$val) {
  11.             $mas = explode("_", $key);
  12.             if($mas[1] == $id) {
  13.                 unset($_SESSION[$key]);
  14.             }
  15.         }
  16.     }
  17.     function get_cart() {
  18.         $cart = array();
  19.         if($_SESSION){
  20.             foreach($_SESSION as $key=>$val) {
  21.                 $mas = explode("_", $key);
  22.                 if($mas[0] == "skaiciuokle" && $mas[1] > 0) {
  23.                     $cart[]=$mas[1]."_".$val;
  24.                 }                        
  25.             }
  26.         }
  27.         return $cart;
  28.     }
  29. if($_POST["job"]=="add"){
  30.     add_cart($_POST["kas"],$_POST["type"],$_POST["type2"],$_POST["plotis"],$_POST["kiekis"],$_POST["aukstis"],$_POST["type3"]);
  31. }
  32. if($_POST["job"]=="del"){
  33.      del_cart($_POST["id"]);  
  34. }  
  35.        
  36. if(($_POST["job"]=="add" or $_POST["job"]=="del" or $_POST["job"]=="view") and count(get_cart())>0){
  37.     foreach(get_cart() as $k=>$c){
  38.         $one=explode("_",$c);
  39.         $i=$k+1;
  40.         echo $i.". ";
  41.         if($one[1]==0){
  42.             echo "Dører: ";
  43.             if($one[2]==0){echo "Innerdører, ";}else{echo "Ytterdører, ";}
  44.         }else{
  45.             echo "Vinduer: ";
  46.             if($one[2]==0){echo "Nordline, ";}else{echo "Euroline, ";}
  47.         }  
  48.         if($one[3]==0){echo "PVC";}elseif($one[3]==1){echo "TRE";}elseif($one[3]==2){echo "TRE-ALUMINIUM";}else{echo "ALUMINIUM";}
  49.         if($one[1]==1){ echo ", ";
  50.           if($one[7]==0){echo "Sidehengte vindu";}elseif($one[7]==1){echo "Toppsving vindu";}elseif($one[7]==2){echo "Toppstyrte vindu";}
  51.           elseif($one[7]==3){echo "Sprosse vindu";}elseif($one[7]==4){echo "Side hung";}elseif($one[7]==5){echo "Side swing 180";}
  52.           elseif($one[7]==6){echo "Side swing 90";}elseif($one[7]==7){echo "Top hung";}elseif($one[7]==8){echo "Top sliding";}
  53.           else{echo "Top turn 180";}
  54.         }
  55.         echo "<br /><small>Bredde: ".$one[4]." mm,;";
  56.        
  57.         ?>
  58.         <?
  59.        
  60.         echo "Høyde: ".$one[5]." mm,
  61.        Stk. ".$one[6]."</small>
  62.        <a href='#' class='del' rel='".$one[0]."'><big><b>X</b></big></a>
  63.        <hr></hr>";
  64.        
  65.     }
  66.     echo "<br /><a href='#' class='go'>Gå videre</a>";
  67. }elseif($_POST["job"]=="mini" and count(get_cart())>0){
  68.     foreach(get_cart() as $c){
  69.         echo $c."|";
  70.     }
  71. }
  72.  
  73. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement