index.php (8140B)
1 <?php // index.php :: Index principal du jeu. 2 if (file_exists('install.php')) { die('Effacez le fichier <b>install.php</b>, si vous avez éffecué l\'installation'); } 3 4 error_reporting(E_ALL); 5 session_start(); 6 7 include('kernel/functions.php'); 8 include('kernel/display.php'); 9 $link = opendb(); 10 11 $controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control"); 12 $controlrow = mysql_fetch_array($controlquery); 13 14 if ($_SESSION == true) { 15 $userquery = doquery("SELECT * FROM {{table}} WHERE id='".addslashes($_SESSION['id'])."' LIMIT 1", "users"); 16 $userrow = mysql_fetch_array($userquery); 17 }else{ 18 $userrow = null; 19 } 20 21 if ($userrow == null) { 22 if (isset($_GET["do"])) { 23 if ($_GET["do"] == "verify") { header("Location: users.php?do=verify"); die(); } 24 if ($_GET["do"] == "flash") { flash(); die(); } 25 } 26 header("Location: login.php?do=login"); die(); 27 } 28 29 // Jeu fermé 30 if ($controlrow["gameopen"] == 0) { display("Le jeu est actuellement fermé pour cause de maintenance"); die(); } 31 // Forcé la vérification de l'utilisateur. 32 if ($controlrow["verifyemail"] == 1 && $userrow["verify"] != 1) { header("Location: users.php?do=verify"); die(); } 33 // Compte bloqué. 34 if ($userrow["authlevel"] == 2) { die("Votre compte est bloqué!"); } 35 36 if(isset($_GET["do"])) { 37 $do = explode(":",$_GET["do"]); 38 switch ($do[0]) { 39 case 'babblebox': babblebox(); break; 40 case 'flash': flash(); break; 41 case 'inn': include('towns.php'); inn(); break; 42 case 'buy': include('towns.php'); buy(); break; 43 case 'buy2': include('towns.php'); buy2($do[1]); break; 44 case 'buy3': include('towns.php'); buy3($do[1]); break; 45 case 'maps': include('towns.php'); maps(); break; 46 case 'maps2': include('towns.php'); maps2($do[1]); break; 47 case 'maps3': include('towns.php'); maps3($do[1]); break; 48 case 'gotown': include('towns.php'); travelto($do[1]); break; 49 case 'move': include('explore.php'); move(); break; 50 case 'fight': include('fight.php'); fight(); break; 51 case 'victory': include('fight.php'); victory(); break; 52 case 'drop': include('fight.php'); drop(); break; 53 54 } 55 } else { donothing(); } 56 57 function donothing() { 58 59 global $userrow; 60 61 if ($userrow["currentaction"] == "En ville") { 62 $page = dotown(); 63 $title = "En ville"; 64 } elseif ($userrow["currentaction"] == "En exploration") { 65 $page = doexplore(); 66 $title = "En exploration"; 67 } elseif ($userrow["currentaction"] == "En combat") { 68 $page = dofight(); 69 $title = "En combat"; 70 } 71 72 display($page, $title); 73 74 } 75 76 function dotown() { // En ville. 77 78 global $userrow, $controlrow; 79 80 $townquery = doquery("SELECT id, name FROM {{table}} WHERE latitude='".$userrow["latitude"]."' AND longitude='".$userrow["longitude"]."' LIMIT 1", "towns"); 81 $townrow = mysql_fetch_array($townquery); 82 $townrow["currenttownid"] = $townrow["id"]; 83 $townrow["currenttown"] = $townrow["name"]; 84 85 if ($controlrow["showbabble"] == 1) {// T'chat. 86 $townrow["babble_warning"]= null; 87 88 if (isset($_POST['chat'])) { 89 extract($_POST); 90 91 if (trim($chat) == "") {$townrow["babble_warning"] = '<div class="alerte_session">Votre texte est vide!</div><br >'; } 92 elseif (preg_match("/^[#$%&*<|>^_`{|}~]/", $chat)) {$townrow["babble_warning"] = '<div class="alerte_session">Caractères non autorisés!</div><br >'; } 93 94 else{ 95 $insert = doquery("INSERT INTO {{table}} SET id='',postdate=NOW(),author='".$userrow['charname']."',babble='".addslashes($chat)."'","babble"); } } 96 97 $townrow["babblebox"] = "<script type='text/javascript'> 98 function rafraichir() { 99 var xmlhttp = getHTTPObject(); 100 xmlhttp.open('POST','?do=babblebox',true); 101 xmlhttp.send(null); 102 setTimeout('rafraichir()', 1000); 103 } 104 rafraichir(); 105 </script><div id='page2' class='rose2'></div>"; 106 $townrow["babble_bottom"] ='<form action="" method="post" onSubmit="submit.disabled=true"> 107 <div style="text-align:center;"><input type="text" name="chat" size="26" maxlength="95" ><br ><input type="submit" name="submit" value="Envoyer" > <input type="reset" name="reset" value="Effacer" ></div></form>'; 108 109 } else {$townrow["babble_warning"] = 'Babble blox désactivé'; $townrow["babblebox"] = $townrow["babble_bottom"] = null; } 110 111 if ($controlrow["showonline"] == 1) { 112 $onlinequery = doquery("SELECT charname FROM {{table}} WHERE UNIX_TIMESTAMP(onlinetime) >= '".(time()-600)."' ORDER BY charname", "users"); 113 114 if ( mysql_num_rows($onlinequery) >= 2){// Membres en ligne. 115 $townrow["whosonline"] = '<b>'.mysql_num_rows($onlinequery).'</b> joueurs en ligne: '; 116 }else{ 117 $townrow["whosonline"] = '<b>'.mysql_num_rows($onlinequery).'</b> joueur en ligne: ';} 118 119 while ($onlinerow = mysql_fetch_array($onlinequery)) { $townrow["whosonline"] .='<span class="rose5">'.$onlinerow["charname"].'</span>, '; } 120 $townrow["whosonline"] = rtrim($townrow["whosonline"], ', '); 121 } else { $townrow["whosonline"] = 'Modules des joueurs en ligne désactivé'; } 122 123 $page = gettemplate("towns"); 124 $page = parsetemplate($page, $townrow); 125 126 return $page; 127 128 } 129 130 131 function doexplore() { // Page d'exploration.. 132 133 global $userrow; 134 135 $page = '<img src="images/jeu/actions/exploration.jpg" width="580" height="82" alt="En exploration"><br><br> 136 Vous êtes actuellement en exploration mais rien ne s\'est produit, continuez à vous déplacer avec les boutons de navigation.<br><br>Votre position est: <b>Latitude '.$userrow['latitude'].', Longitude '.$userrow['longitude'].'</b>.<br><br>Maintenant vous pouvez:<br><br> 137 <form action="?do=move" method="post"><div> 138 <input name="east_x" type="submit" class="no_bordure" value="» aller à l\'est"><br><br> 139 <input name="west_x" type="submit" class="no_bordure" value="» aller à l\'ouest"><br><br> 140 <input name="south_x" type="submit" class="no_bordure" value="» aller au sud"><br><br> 141 <input name="north_x" type="submit" class="no_bordure" value="» aller au nord"> 142 </div> 143 </form>'; 144 145 return $page; 146 147 } 148 149 150 function dofight() { // Redirection combat. 151 152 header("Location: ?do=fight"); 153 154 } 155 156 157 function babblebox() { // T'chat. 158 159 global $userrow; 160 include('class/bbcode.php'); 161 $text = new texte(); 162 163 $bg = 1; 164 $babblequery = doquery("SELECT * FROM {{table}} ORDER BY id DESC LIMIT 8", "babble"); 165 $babblebox["content"] =''; 166 while ($babblerow = mysql_fetch_array($babblequery)) { 167 $message = strip_tags($babblerow['babble']); 168 169 if ($bg == 1) { $content = '<div class="rose1" style="margin-left:2px; margin-top:4px; margin-bottom:4px"><span class="taille1"><span class="rose5"><b>'.$babblerow['author'].':</b></span> '.utf8_encode($text->ms_format($message)).'</span></div>'; $bg = 2; } 170 else { $content = '<div name="texte" class="rose2" style="margin-left:2px; margin-top:4px; margin-bottom:4px"><span class="taille1" ><span class="rose5"><b>'.$babblerow['author'].':</b></span> '.utf8_encode($text->ms_format($message)).'</div>'; $bg = 1; } 171 $babblebox["content"] .= $content; 172 } 173 174 $page = gettemplate("babblebox"); 175 echo parsetemplate($page, $babblebox); 176 die(); 177 178 } 179 180 181 function flash() { 182 183 global $userrow; 184 185 $historyquery = doquery("SELECT content, time FROM {{table}} ORDER BY id DESC", "history"); 186 $historyrow = mysql_fetch_array($historyquery); 187 188 if (($userrow) == null) { 189 190 $history = '&infoMAJ= '.$historyrow['content'].' - '.date('(H:i)', $historyrow['time']); 191 $misc = '&messagerie=<img src="images/login/horloge.gif" hspace="0" vspace="-16"> <p><span class="mauve2"><b>'.datefrance(date('Y-m-d')).'</b></span></p>'; 192 }else{ 193 $history = '&infoMAJ='.$historyrow['content'].' - '.date("(H:i)", $historyrow['time']); 194 $misc = '&messagerie=<img src="images/jeu/messagerie.gif" hspace="0" vspace="-14"> <p><span class="mauve2"><b>Bientot votre messagerie!</b></span></p>'; 195 } 196 197 echo utf8_encode($history); 198 echo utf8_encode($misc); 199 200 } 201 ?>