function afficheencheres () { //Fonction affichage des enchères. global $userrow, $numqueries; $encheresquery = doquery("SELECT * FROM {{table}} ORDER by id DESC LIMIT 20", "encheres"); $page = "

Voici la liste des objets à vendre.

La liste des objets à vendre:

"; $count = 1; if ( @mysql_num_rows($encheresquery) == 0 ) { $title = "Les enchères"; $page .= "
Aucunes enchères


"; } else { while($row = mysql_fetch_array($encheresquery)) { $timeactuel = date("d-m-Y", $row["posttime"]); $timefin = date("d-m-Y", $row["datefin"] ); $title = "Les enchères"; //debut if ($row["posttime"] >= $row["datefin"] ) { $acheteurquery = doquery("SELECT * FROM {{table}} WHERE posttime>='".$row["datefin"]."'", "encheres"); $acheteurrow = mysql_fetch_array($acheteurquery); $acheteurquery2 = doquery("SELECT * FROM {{table}} WHERE charname='".$acheteurrow["acheteur"]."'", "users"); $acheteurrow2 = mysql_fetch_array($acheteurquery2); $acheteurquery3 = doquery("SELECT * FROM {{table}} WHERE charname='".$acheteurrow["proprietaire"]."'", "users"); $acheteurrow3 = mysql_fetch_array($acheteurquery3); $itemsquery = doquery("SELECT * FROM {{table}} WHERE id='".$acheteurrow["idobjet"]."' LIMIT 1", "items"); $itemsrow = mysql_fetch_array($itemsquery); if ($row["type"] == 1 and $row["acheteur"] != "Aucun" ) { // weapon if ($acheteurrow2["weaponid"] != 0) { $itemsquery2 = doquery("SELECT * FROM {{table}} WHERE id='".$acheteurrow["idobjet"]."' LIMIT 1", "items"); $itemsrow2 = mysql_fetch_array($items2query); } else { $itemsrow2 = array("attribute"=>0,"buycost"=>0,"special"=>"Aucun"); } // Special item fields. $specialchange1 = ""; $specialchange2 = ""; if ($itemsrow["special"] != "Aucun") { $special = explode(",",$itemsrow["special"]); $tochange = $special[0]; $acheteurrow2[$tochange] = $acheteurrow2[$tochange] + $special[1]; $specialchange1 = "$tochange='".$acheteurrow2[$tochange]."',"; if ($tochange == "strength") { $acheteurrow2["attackpower"] += $special[1]; } if ($tochange == "dexterity") { $acheteurrow2["defensepower"] += $special[1]; } } if ($itemsrow2["special"] != "Aucun") { $special2 = explode(",",$itemsrow2["special"]); $tochange2 = $special2[0]; $acheteurrow2[$tochange2] = $acheteurrow2[$tochange2] - $special2[1]; $specialchange2 = "$tochange2='".$acheteurrow2[$tochange2]."',"; if ($tochange2 == "strength") { $acheteurrow2["attackpower"] -= $special2[1]; } if ($tochange2 == "dexterity") { $acheteurrow2["defensepower"] -= $special2[1]; } } // New stats. $newattack2 = $acheteurrow3["attackpower"] - $itemsrow["attribute"] ; $newgold2 = $acheteurrow3["gold"] + $acheteurrow["buycost"]; $newname2 = "Aucun"; $newid2 = 0; $newgold = $acheteurrow2["gold"] - $acheteurrow["buycost"]; $newattack = $acheteurrow2["attackpower"] + $itemsrow["attribute"] - $itemsrow2["attribute"]; $newid = $itemsrow["id"]; $newname = $itemsrow["name"]; $userid = $acheteurrow2["id"]; if ($acheteurrow2["currenthp"] > $acheteurrow2["maxhp"]) { $newhp = $acheteurrow2["maxhp"]; } else { $newhp = $acheteurrow2["currenthp"]; } if ($acheteurrow2["currentmp"] > $acheteurrow2["maxmp"]) { $newmp = $acheteurrow2["maxmp"]; } else { $newmp = $acheteurrow2["currentmp"]; } if ($acheteurrow2["currenttp"] > $acheteurrow2["maxtp"]) { $newtp = $acheteurrow2["maxtp"]; } else { $newtp = $acheteurrow2["currenttp"]; } // Final update. $updatequery = doquery("UPDATE {{table}} SET $specialchange1 $specialchange2 gold='$newgold', attackpower='$newattack', weaponid='$newid', weaponname='$newname', currenthp='$newhp', currentmp='$newmp', currenttp='$newtp' WHERE id='$userid' LIMIT 1", "users"); $updatequery2 = doquery("UPDATE {{table}} SET gold='$newgold2', attackpower='$newattack2', weaponid='$newid2', weaponname='$newname2' WHERE charname='".$acheteurrow["proprietaire"]."'", "users"); } elseif ($itemsrow["type"] == 2 and $row["acheteur"] != "Aucun" ) { // Armor // Check if they already have an item in the slot. if ($acheteurrow2["armorid"] != 0) { $itemsquery2 = doquery("SELECT * FROM {{table}} WHERE id='".$acheteurrow["idobjet"]."' LIMIT 1", "items"); $itemsrow2 = mysql_fetch_array($items2query); } else { $itemsrow2 = array("attribute"=>0,"buycost"=>0,"special"=>"Aucun"); } // Special item fields. $specialchange1 = ""; $specialchange2 = ""; if ($itemsrow["special"] != "Aucun") { $special = explode(",",$itemsrow["special"]); $tochange = $special[0]; $acheteurrow2[$tochange] = $acheteurrow2[$tochange] + $special[1]; $specialchange1 = "$tochange='".$acheteurrow2[$tochange]."',"; if ($tochange == "strength") { $acheteurrow2["attackpower"] += $special[1]; } if ($tochange == "dexterity") { $acheteurrow2["defensepower"] += $special[1]; } } if ($itemsrow2["special"] != "Aucun") { $special2 = explode(",",$itemsrow2["special"]); $tochange2 = $special2[0]; $acheteurrow2[$tochange2] = $acheteurrow2[$tochange2] - $special2[1]; $specialchange2 = "$tochange2='".$acheteurrow2[$tochange2]."',"; if ($tochange2 == "strength") { $acheteurrow2["attackpower"] -= $special2[1]; } if ($tochange2 == "dexterity") { $acheteurrow2["defensepower"] -= $special2[1]; } } // New stats. $newdefense2 = $acheteurrow3["attackpower"] - $itemsrow["attribute"] ; $newgold2 = $acheteurrow3["gold"] + $acheteurrow["buycost"]; $newname2 = "Aucun"; $newid2 = 0; $newgold = $acheteurrow2["gold"] - $acheteurrow["buycost"]; $newdefense = $acheteurrow2["defensepower"] + $itemsrow["attribute"] - $itemsrow2["attribute"]; $newid = $itemsrow["id"]; $newname = $itemsrow["name"]; $userid = $acheteurrow2["id"]; if ($acheteurrow2["currenthp"] > $acheteurrow2["maxhp"]) { $newhp = $acheteurrow2["maxhp"]; } else { $newhp = $acheteurrow2["currenthp"]; } if ($acheteurrow2["currentmp"] > $acheteurrow2["maxmp"]) { $newmp = $acheteurrow2["maxmp"]; } else { $newmp = $acheteurrow2["currentmp"]; } if ($acheteurrow2["currenttp"] > $acheteurrow2["maxtp"]) { $newtp = $acheteurrow2["maxtp"]; } else { $newtp = $acheteurrow2["currenttp"]; } // Final update. $updatequery = doquery("UPDATE {{table}} SET $specialchange1 $specialchange2 gold='$newgold', defensepower='$newdefense', armorid='$newid', armorname='$newname', currenthp='$newhp', currentmp='$newmp', currenttp='$newtp' WHERE id='$userid' LIMIT 1", "users"); $updatequery2 = doquery("UPDATE {{table}} SET gold='$newgold2', defensepower='$newdefense2', armorid='$newid2', armorname='$newname2' WHERE charname='".$acheteurrow["proprietaire"]."'", "users"); } elseif ($itemsrow["type"] == 3 and $row["acheteur"] != "Aucun") { // Shield // Check if they already have an item in the slot. if ($acheteurrow2["shieldid"] != 0) { $itemsquery2 = doquery("SELECT * FROM {{table}} WHERE id='".$acheteurrow["idobjet"]."' LIMIT 1", "items"); $itemsrow2 = mysql_fetch_array($items2query); } else { $itemsrow2 = array("attribute"=>0,"buycost"=>0,"special"=>"Aucun"); } // Special item fields. $specialchange1 = ""; $specialchange2 = ""; if ($itemsrow["special"] != "Aucun") { $special = explode(",",$itemsrow["special"]); $tochange = $special[0]; $acheteurrow2[$tochange] = $acheteurrow2[$tochange] + $special[1]; $specialchange1 = "$tochange='".$acheteurrow2[$tochange]."',"; if ($tochange == "strength") { $acheteurrow2["attackpower"] += $special[1]; } if ($tochange == "dexterity") { $acheteurrow2["defensepower"] += $special[1]; } } if ($itemsrow2["special"] != "Aucun") { $special2 = explode(",",$itemsrow2["special"]); $tochange2 = $special2[0]; $acheteurrow2[$tochange2] = $acheteurrow2[$tochange2] - $special2[1]; $specialchange2 = "$tochange2='".$acheteurrow2[$tochange2]."',"; if ($tochange2 == "strength") { $acheteurrow2["attackpower"] -= $special2[1]; } if ($tochange2 == "dexterity") { $acheteurrow2["defensepower"] -= $special2[1]; } } // New stats. $newdefense2 = $acheteurrow3["attackpower"] - $itemsrow["attribute"] ; $newgold2 = $acheteurrow3["gold"] + $acheteurrow["buycost"]; $newname2 = "Aucun"; $newid2 = 0; $newgold = $acheteurrow2["gold"] - $acheteurrow["buycost"]; $newdefense = $acheteurrow2["defensepower"] + $itemsrow["attribute"] - $itemsrow2["attribute"]; $newid = $itemsrow["id"]; $newname = $itemsrow["name"]; $userid = $acheteurrow2["id"]; if ($acheteurrow2["currenthp"] > $acheteurrow2["maxhp"]) { $newhp = $acheteurrow2["maxhp"]; } else { $newhp = $acheteurrow2["currenthp"]; } if ($acheteurrow2["currentmp"] > $acheteurrow2["maxmp"]) { $newmp = $acheteurrow2["maxmp"]; } else { $newmp = $acheteurrow2["currentmp"]; } if ($acheteurrow2["currenttp"] > $acheteurrow2["maxtp"]) { $newtp = $acheteurrow2["maxtp"]; } else { $newtp = $acheteurrow2["currenttp"]; } // Final update. $updatequery = doquery("UPDATE {{table}} SET $specialchange1 $specialchange2 gold='$newgold', defensepower='$newdefense', shieldid='$newid', shieldname='$newname', currenthp='$newhp', currentmp='$newmp', currenttp='$newtp' WHERE id='$userid' LIMIT 1", "users"); $updatequery2 = doquery("UPDATE {{table}} SET gold='$newgold2', defensepower='$newdefense2', shieldid='$newid2', shieldname='$newname2' WHERE charname='".$acheteurrow["proprietaire"]."'", "users"); } } //FIN if ($count == 1) { $page .= ""; $page .= ""; $page .= ""; $page .= ""; $page .= "
".$row["name"]." - ".$row["buycost"]." rubis

Mise en vente le: ".$timeactuel." par ".$row["proprietaire"].". Fin le: ".$timefin.". Dernière enchère par: ".$row["acheteur"].".
Enchérir

"; $count = 2; } else { $page .= ""; $page .= ""; $page .= ""; $page .= ""; $page .= "
".$row["name"]." - ".$row["buycost"]." rubis

Mise en vente le: ".$timeactuel." par ".$row["proprietaire"].". Fin le: ".$timefin.". Dernière enchère par: ".$row["acheteur"].".
Enchérir

"; $count = 1; } } // efface toutes les lignes dans la table enchere avec une datefin plus grande que posttime $updatequery3 = doquery("DELETE FROM {{table}} WHERE posttime>datefin", "encheres"); } display($page, $title); }