1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
| <?php require_once('../Connections/infortech.php'); ?>
<?php require_once('../Connections/infortech.php'); ?>
<?php
session_start();
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "../login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "quantite")) {
$updateSQL = sprintf("UPDATE shop_panier SET client=%s, article=%s, quantite=%s WHERE id=%s",
GetSQLValueString($_POST['client'], "text"),
GetSQLValueString($_POST['article'], "int"),
GetSQLValueString($_POST['quantite'], "int"),
GetSQLValueString($_POST['article'], "int"));
mysql_select_db($database_infortech, $infortech);
$Result1 = mysql_query($updateSQL, $infortech) or die(mysql_error());
$updateGoTo = "panier.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "validation")) {
$insertSQL = sprintf("INSERT INTO shop_commande (`date`, total_ht, total_ttc) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['date'], "date"),
GetSQLValueString($_POST['total_ht'], "double"),
GetSQLValueString($_POST['total_ttc'], "double"));
mysql_select_db($database_infortech, $infortech);
$Result1 = mysql_query($insertSQL, $infortech) or die(mysql_error());
$insertGoTo = "traitement_commande.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$paramclient_panier = "1";
if (isset($_SESSION['MM_Username'])) {
$paramclient_panier = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_infortech, $infortech);
$query_panier = sprintf("SELECT shop_panier.*, shop_produits.titre, shop_produits.prix_ttc, (shop_produits.prix_ttc*shop_panier.quantite) AS total_ttc, (shop_produits.prix_ht*shop_panier.quantite) AS total_ht FROM shop_panier INNER JOIN shop_produits ON shop_panier.article=shop_produits.id WHERE shop_panier.client = '%s'", $paramclient_panier);
$panier = mysql_query($query_panier, $infortech) or die(mysql_error());
$row_panier = mysql_fetch_assoc($panier);
$totalRows_panier = mysql_num_rows($panier);
$paramclient_total = "0";
if (isset($_SESSION['MM_Username'])) {
$paramclient_total = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_infortech, $infortech);
$query_total = sprintf("SELECT now() AS date, SUM(shop_panier.quantite*shop_produits.prix_ttc) AS total_ttc, SUM(shop_panier.quantite*shop_produits.prix_ht) AS total_ht FROM shop_panier INNER JOIN shop_produits ON shop_produits.id=shop_panier.article WHERE shop_panier.client = '%s' GROUP BY shop_panier.client", $paramclient_total);
$total = mysql_query($query_total, $infortech) or die(mysql_error());
$row_total = mysql_fetch_assoc($total);
$totalRows_total = mysql_num_rows($total);
session_start();?> |
Partager