Jump to content

r.v

Members
  • Posts

    4
  • Joined

  • Last visited

r.v's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Not to mention it's not good for your server.. Every time a user visits the homepage it does at least 12 queries to your character database just to get info on the amount of race-specific characters.. The error is because of the usage of constants in an array. This script is also viable to sql-injection, so i wouldn't use it..
  2. Something like this? ps, this is not secure, and hasn't got everything. It runs on a webserver with php.. <?php // Database info $db_host = "127.0.0.1"; $db_user = "user"; $db_pass = "password"; $db_database = "auth"; // Conf info $world = 'worldserver.conf'; $filesize = filesize($world); if($_SERVER['REQUEST_METHOD'] === 'POST'): // Save to file // Read current data $fh = fopen($world,"r"); $old_worldconfig = fread($fh, $filesize); fclose($fh); // Update database servername $link = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db($db_database,$link); $sql = mysql_query("UPDATE `realmlist` SET `name` = '".$_POST['servername']."' WHERE `id` = '".$_POST['realmid']."'"); mysql_close($link); // Update config $new_worldconfig = preg_replace('/MaxPlayerLevel = ([0-9]{1,3})/','MaxPlayerLevel = '.$_POST['maxplayerlevel'],$old_worldconfig); $new_worldconfig = preg_replace('/GameType = ([0-9]{1,2})/','GameType = '.$_POST['gametype'],$new_worldconfig); $new_worldconfig = preg_replace('/Motd = "([.|\s|\S]*?)"/','Motd = "'.$_POST['motd'].'"',$new_worldconfig); $new_worldconfig = preg_replace('/Rate.XP.Kill = ([0-9]{1,4})/','Rate.XP.Kill = '.$_POST['rate_xp_kill'],$new_worldconfig); $new_worldconfig = preg_replace('/Rate.XP.Quest = ([0-9]{1,4})/','Rate.XP.Quest = '.$_POST['rate_xp_quest'],$new_worldconfig); $new_worldconfig = preg_replace('/Rate.XP.Explore = ([0-9]{1,4})/','Rate.XP.Explore = '.$_POST['rate_xp_explore'],$new_worldconfig); $fh = fopen($world,"w+"); fwrite($fh,$new_worldconfig); fclose($fh); die("Config updated!"); else : // Read current data $fh = fopen($world,"r"); $old_worldconfig = fread($fh, $filesize); preg_match('/RealmID = ([0-9]{1,3})/',$old_worldconfig, $realmid); preg_match('/MaxPlayerLevel = ([0-9]{1,3})/',$old_worldconfig, $cur_maxlevel); preg_match('/GameType = ([0-9]{1,2})/',$old_worldconfig, $gametype); preg_match('/Motd = "([.|\s|\S]*?)"/',$old_worldconfig, $motd); preg_match('/Rate.XP.Kill = ([0-9]{1,4})/',$old_worldconfig, $rate_xp_kill); preg_match('/Rate.XP.Quest = ([0-9]{1,4})/',$old_worldconfig, $rate_xp_quest); preg_match('/Rate.XP.Explore = ([0-9]{1,4})/',$old_worldconfig, $rate_xp_explore); // Get realm info from database $link = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db($db_database,$link); $sql = mysql_query("SELECT * FROM `realmlist` WHERE `id` = '".$realmid[1]."'"); if($sql){ $row = mysql_fetch_assoc($sql); $servername = $row['name']; } else { $servername = ''; } mysql_close($link); fclose($fh); // Build form ?> <form method="POST"> <input type="hidden" name="realmid" value="<?php echo (isset($realmid[1])?$realmid[1]:'1');?>" /> <label for="servername">Servername</label> <input type="text" name="servername" value="<?php echo $servername;?>" /><br /><br /> <label for="motd">MOTD</label> <textarea name="motd"><?php echo (isset($motd[1])?$motd[1]:'');?></textarea><br /><br /> <label for="gametype">Gametype</label> <select name="gametype"> <option value="0"<?php echo(isset($gametype[1]) && $gametype[1]==0?' selected="selected"':'');?>>NORMAL (0)</option> <option value="1"<?php echo(isset($gametype[1]) && $gametype[1]==1?' selected="selected"':'');?>>PVP (1)</option> <option value="4"<?php echo(isset($gametype[1]) && $gametype[1]==4?' selected="selected"':'');?>>NORMAL (4)</option> <option value="6"<?php echo(isset($gametype[1]) && $gametype[1]==6?' selected="selected"':'');?>>RP (6)</option> <option value="8"<?php echo(isset($gametype[1]) && $gametype[1]==8?' selected="selected"':'');?>>RPPVP (8)</option> <option value="16"<?php echo(isset($gametype[1]) && $gametype[1]==16?' selected="selected"':'');?>>FFA_PVP (16)</option> </select><br /><br /> <label for="maxplayerlevel">Max playerlevel</label> <input type="text" name="maxplayerlevel" value="<?php echo (isset($cur_maxlevel[1])?$cur_maxlevel[1]:''); ?>" /><br /><br /> <label for="rate_xp_kill">rate_xp_kill</label> <input type="text" name="rate_xp_kill" value="<?php echo (isset($rate_xp_kill[1])?$rate_xp_kill[1]:''); ?>" /><br /><br /> <label for="rate_xp_quest">rate_xp_quest</label> <input type="text" name="rate_xp_quest" value="<?php echo (isset($rate_xp_quest[1])?$rate_xp_quest[1]:''); ?>" /><br /><br /> <label for="rate_xp_explore">rate_xp_explore</label> <input type="text" name="rate_xp_explore" value="<?php echo (isset($rate_xp_explore[1])?$rate_xp_explore[1]:''); ?>" /><br /><br /> <input type="submit" name="submit" value="Save" /> </form> <?php endif;?>
  3. How about this one:

    skyfire.png

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.