Bonjour,
J'ai un problème pour maintenir register_globals sur off et afficher les données de mon caddie, pouvez-vous me dire comment rectifier les fonctions suivantes?
Merci d'avance,
Cordialement,
Gilues
Modifié par Gilues (20 Dec 2008 - 13:24)
J'ai un problème pour maintenir register_globals sur off et afficher les données de mon caddie, pouvez-vous me dire comment rectifier les fonctions suivantes?
<?
require_once("start.php");
$qset = "select * from settings";
$rset = mysql_query($qset) or die(mysql_error());
$aset = mysql_fetch_array($rset);
function GetCartId(){
$cartId = session_id();
$_SESSION["cartId"] = $cartId;
return session_id();
}
function AddItem($item,$qty=1){
//get the product info
$q1 = "select * from items where ItemID = '$item' ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
//add to cart
$chk = mysql_query("SELECT * FROM cart WHERE OrderID='".GetCartId()."' AND ItemID='$a1[ItemID]'");
if( mysql_num_rows($chk) > 0 ){
UpdateItem($item,2);
}else{
$q2 = "insert into cart set
OrderID = '".GetCartId()."',
ItemID = '$a1[ItemID]',
ItemPrice = '$a1[ItemPrice]',
ItemQty = '$qty',
ItemTotal = '$a1[ItemPrice]' ";
mysql_query($q2) or die(mysql_error());
}
}
function UpdateItem($item,$qty){
//get the product info
$q1 = "select * from items where ItemID = '$item' ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
//add to cart
$q2 = "UPDATE cart SET ItemQty = '$qty' WHERE OrderID = '".GetCartId()."' AND ItemID = '$a1[ItemID]'";
mysql_query($q2) or die(mysql_error());
}
function RemoveItem($item){
mysql_query("DELETE FROM cart WHERE OrderID= '" . GetCartId() . "' and ItemID = '$item'");
}
function ShowCart(){
//get the cart content
$q1 = "select * from cart, items where cart.OrderID = '".GetCartId()."' and cart.ItemID = items.ItemID order by items.ItemName";
$r1 = mysql_query($q1) or die(mysql_error());
if(mysql_num_rows($r1) == '0'){
include_once("templates/viderboutique.inc.php");
}else{
$col = "white";
while($a1 = mysql_fetch_array($r1)){
if($col == "white"){
$col = "dddddd";
}else{
$col = "white";
}
$a1[ItemTotal] = ( $a1[ItemPrice] * $a1[ItemQty] );
$rows .= "<tr bgcolor=\"$col\">\n\t<td class=BlackLink>$a1[ItemName]</td>\n<td align=right>$aset[currency_sign] $a1[ItemPrice]</td>\t\n\t<td align=center>\n\t\t<input type=text size=3 name=\"qty[]\" value=\"$a1[ItemQty]\">\n\t\t<input type=hidden name=\"ids[]\" value=\"$a1[ItemID]\">\n\t</td>\n\t<td align=right>$aset[currency_sign] $a1[ItemTotal]</td>\n</tr>\n\n";
$order_total = $order_total + ( $a1[ItemPrice] * $a1[ItemQty] );
}
$order_total = number_format($order_total, 2, ".", ",");
include_once("templates/afficherboutique.inc.php");
}
}
function CategorySelect($c) {
$q1 = "select * from categories order by CategoryName";
$r1 = mysql_query($q1) or die(mysql_error());
if(mysql_num_rows($r1) > '0'){
$SelectCategory = "\n\n<select name=SelectCategory>\n\t<option value=\"\"></option>\n\t";
while($a1 = mysql_fetch_array($r1)){
if($a1[CategoryID] == $c){
$SelectCategory .= "<option value=\"$a1[CategoryID]|$a2[SubcategoryID]\" selected>$a1[CategoryName], $a2[SubcategoryName]</option>\n\t";
}else{
$SelectCategory .= "<option value=\"$a1[CategoryID]\">$a1[CategoryName]</option>\n\t";
}
}
}
$SelectCategory .= "</select>\n";
return $SelectCategory;
}
function CategoryTree($c) {
$tree = "<table align=center width=\"98%\">\n";
//get the categories
$q1 = "select * from categories order by CategoryName ";
$r1 = mysql_query($q1) or die(mysql_error());
while($a1 = mysql_fetch_array($r1)){
$tree .= "<tr>\n\t<td><a class=CategoryName href=\"categorie.php?cat=$a1[CategoryID]\"><B>$a1[CategoryName] </B></a></td>\n</tr>\n";
if($c == $a1[CategoryID]){
//get the products
$q2 = "select * from items where ItemCategory = '$a1[CategoryID]'";
$r2 = mysql_query($q2) or die(mysql_error());
while($a2 = mysql_fetch_array($r2)){
//$tree .= "<tr>\n\t<td><a href=\"view_item.php?ItemID=$a2[ItemID]\"> $a2[ItemName]</a></td>\n</tr>\n";
}
}
}
$tree .= "</table>\n";
return $tree;
}
function select_currency($c) {
$currency_array = array("EUR|€","CAD|&$dollar canadien;");
$select = "<select name=\"currency\">\n\t";
while(list($k,$v) = each($currency_array)){
$info = explode("|", $v);
if($c == $info[0]){
$select .= "<option value=\"$v\" selected>$info[0]</option>\n\t";
}else{
$select .= "<option value=\"$v\">$info[0]</option>\n\t";
}
}
$select .= "</select>";
return $select;
}
function strip_trim($str) {
$n = strip_tags($str);
$n = trim($n);
return $n;
}
function select_days($d) {
$select = "<select name=\"download_days\">";
for($i = '1'; $i <= '30'; $i++){
if($i == $d){
$select .= "<option value=\"$i\" selected>$i</option>\n\t";
}else{
$select .= "<option value=\"$i\">$i</option>\n\t";
}
}
$select .= "</select>";
return $select;
}
function show_banners(){
global $dir;
$q1 = "select * from banners order by rand() limit 0,1";
$r1 = mysql_query($q1) or die(mysql_error());
if(mysql_num_rows($r1) == '1'){
$a1 = mysql_fetch_array($r1);
$banners = "<BR><a href=\"$a1[BannerURL]\" target=\"_top\"><img src=\"banners/$a1[BannerFile]\" alt=\"$a1[BannerAlt]\" border=0></a>";
}
return $banners;
}
function show_links(){
//get the link
$q1 = "select * from links";
$r1 = mysql_query($q1) or die(mysql_error());
if(mysql_num_rows($r1) == '0'){
echo ("");
}
while($a1 = mysql_fetch_array($r1)){
?>
<a class=BlackLink href="<?=$a1[LinkURL]?>"><?=$a1[LinkName]?></a><br><BR>
<?
}
}
?>
Merci d'avance,
Cordialement,
Gilues
Modifié par Gilues (20 Dec 2008 - 13:24)