Jump to content
MakeWebGames

Looking for someone to clean up framework of page for money


VegasKiller

Recommended Posts

Whoever posts back the best rewrite of this script I will send $15 CAD to your bank/paypal. I need the framework fixed so it will work on diff devices and I need the layout cleaned up so its all nice. The sidebars content are stretching too far and ned to be thinned so they dont stretch the background. I have attached a screen shot to show the current look and errors, as you can see the images are not touching and the sidebars content are too wide stretching the sidebars.

Edited by VegasKiller
Link to comment
Share on other sites

I can't see the screenshot, so I have stopped on the html part, but all the PHP is good:

 

<?php
session_start();

extract($_SESSION);

$ip_banlist = array(
'86.131.94.68',
'66.232.196.20',
'71.254.108.205',
'80.47.176.187',

//add new rows to ban users
);

/* Check if user is banned */
if(in_array($_SERVER['REMOTE_ADDR'], $ip_banlist))	{
die('<center>
	<table width="96%">
		<tr>
			<td>
				<span style="color: red;font-weight: bold;">Error | Crime-Nations.com data failed to load due to your IP being on our global ip ban list. If this is a mistake, contact a staff member through <a href="mailto:[email protected]">[email protected]</a>.</span>
				<img src="../beta/layout_images/topnav.gif" width="100%" height="4" />
			</td>
		</tr>
	</table>
</center>');
}

/* Include our config & functions file */
include_once('includes/config.php');
include_once('includes/functions.php');

/* Connect to our database server, if connection failed throw an error */
$server = mysql_connect($gamedbhost, $gamedbuser, $gamedbpassword);
if(!$server)	{
die('<center>
	<table width="96%">
		<tr>
			<td>
				<span style="color: red;font-weight: bold;">Error | Could not connect to database. If this problem persists contact a staff member through <a href="mailto:[email protected]">[email protected]</a>.</span>
				<img src="../beta/layout_images/topnav.gif" width="100%" height="4" />
			</td>
		</tr>
	</table>
</center>');
}

/* Connect to our game database. */
$game_db = mysql_select_db($prefix, $server) or die(mysql_error());

/* Connect to our core database. */
$core_db = mysql_select_db($prefix, $server) or die(mysql_error());

/* Instantiate our counters. */
$counters = array();

/* insert into counters how many users */
$query_users = mysql_query('SELECT COUNT(`email`) as `total` FROM `login_info`');
$query_users = mysql_fetch_assoc($query_users);
$counters['users'] = $query_users['total'];

/* Users counters */

/* last active */
$query_last_active = mysql_query('SELECT COUNT(`lastactive`) as `total` FROM `user_profiles` WHERE `lastactive` > '.(time() - 121));
$query_last_active = mysql_fetch_assoc($query_last_active);
$counters['last_active'] = $query_last_active['total'];

/* families */
$query_families = mysql_query('SELECT COUNT(*) as `total` FROM `families`');
$query_families = mysql_fetch_assoc($query_families);
$counters['families'] = $query_families['total'];

/* funeral home */
$query_funeral_home = mysql_query('SELECT COUNT(*) as `total` FROM `funeral_home`');
$query_funeral_home = mysql_fetch_assoc($query_funeral_home);
$counters['funeral_home'] = $query_funeral_home['total'];

/* users characters */
$query_user_characters = mysql_query('SELECT COUNT(*) as `total` FROM `user_characters`');
$query_user_characters = mysql_fetch_assoc($query_user_characters);
$counters['user_characters'] = $query_user_characters['total'];

/* Instantiate our game settings */
$query_settings = mysql_query('SELECT * FROM `game_settings` WHERE `id` = 1');
$settings = mysql_fetch_assoc($query_settings);


/* Combine post and request variables (Unsure why this is needed?) */ 
$_GVARS = array_merge($_POST, $_REQUEST);
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Crime Nations | Free Mafia MMORPG Browser Game | Cash Prizes | Round <?php echo $game_settings['round']; ?></title>

	<meta name="keywords" content="mafia,game,free,rpg,kingpin,economy,organization,colpitts,text based,crime,networking,rackets,gambling,corporation,drugs,empire,vegaskiller" />
	<meta name="description" content="Crime Nations Com. It is an amazing free mass online game where you can mug/beat/hack/spy/stab/shoot/bomb/extort, and pretty much do what ever you want to the opposition, including killing them. You can choose from over 12 classes, and  25 cities to explore. You can pimp and/or own properties, Setting up a Roulette/ Slots/ Fence/ Chop shop/ launderer and many other back room features including Firebombing. Work for the corporation working your way out of the mail room into that ever so cozy CEO office. Send or receive your stolen goods from bank heists and transport truck robberies. Drug or Black market run across cities, making loads of money while eluding the FBI. And even kidnap that ****ing rat who sold you out. Co-Op with other players to succeed in organized crimes and bank robberies, creating new friendships and connections. Work for a organization, Doing hits for the boss or bringing in mass profits for the vault, or Start your own organization, leading hundreds of loyal members and take it to the top, Or start an airport riot causing mass chaos in the community. its all here at Crime Nations Com. Win prizes every week. www.crime-nations.com" />
	<meta name="robots" content="ALL,INDEX,FOLLOW">
	<meta name="revisit" content="3 days">

	<style>
		A:link, A:visited, A:active {
			COLOR: #FFFFFF;
			TEXT-DECORATION: none;
		}
		A:hover {
			COLOR: #660000;
			TEXT-DECORATION: none;
		}
		.imgfloat{
			position:absolute;
		}
		.login {
			border:1px solid black;
			text-color: #FFFFFF;
			border-color: solid black;
			background-color: #000000
		}
		td.on {
			background: #111111;
			font-family: Verdana, Arial, Helvetica, sans-serif;
			font-size: 10px;
			color: #999999;
			align: center;
		}
		textarea, input, select {
			font-size : 11px;
			font-family : Tahoma;
			color : #FFFFFF;
			background-color : #333333;
		}
		.submit {
			font-size : 11px;
			font-family : Tahoma;
			font-weight: bold;
			color : #FFFFFF;
			background-color : #333333;
		}
		.font1 {
			font-size : 11px;
			font-family : Tahoma;
			color : #FFFFFF;
			font-weight: bold;
		}
		.text_head {
			font-size : 12px;
			font-family : Tahoma;
			color : #FFFFFF;
			font-weight: bold;
		}
		.text_menu {
			font-size : 11px;
			font-family : Tahoma;
			color : #FFFFFF;
			font-weight: bold;
		}
		.text_small {
			font-size : 11px;
			font-family : Tahoma;
			color : #FFFFFF;
		}
		.text_normal {
			font-size : 12px;
			font-family : Arial;
			color : silver;
		}
		.sidemenu2 {
			background-color: #222222;
			font-size : 10px;
			font-family : Tahoma;
			color : #FFFFFF;
		}
		.sidemenu {
			font-size : 10px;
			font-family : Tahoma;
			color : #FFFFFF;
		}
		td,body {
			font-size : 10px;
			font-family : Tahoma;
			color : #FFFFFF;
		}
	</style>
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" background="/beta/layout_images/bg_6.gif">
	<center>
		<img src="/beta/layout_images/headertop.gif" width="100%" height="4" />
		<img src="/beta/layout_images/header.png" repeat="true" width="100%" />

		<?php
		if($user_email == '')	{
			/* User is not logged in */

echo "<body background='/beta/layout_images/bg_6.gif' topmargin=0 leftmargin=0 rightmargin=0><center><img src='/beta/layout_images/headertop.gif' width='100%' height='4'></center>
<center><table width='100%' background='beta/layout_images/fbg.gif' cellspacing=0 width='100%'><tr><td width=15% valign='top'><b><center><font color=black><b><a href='?x=info' alt='Home' title='Home'><font color=tan>Home</font></a> | <a href='?x=scrnshots' alt='Screen Shots' title='Screen Shots'><font color=tan>Screen Shots</font></a> | <a target=_href href=http://www.youtube.com/watch?v=YsrQkWsvJUI><font color=tan>Teh Sins Video Tutorial</font></a> | <a href='?x=contact' alt='Contact Us' title='Contact Us'><font color=tan>Contact Us</font></a> | <a href='?x=updates' alt='Updates' title='Updates'><font color=tan>Updates</font></a> | <a href='?x=referral_program' alt='Refer Us' title='Refer Us'><font color=tan>Refer Us</font></a> | <a href='?x=signup' alt='Register Account' title='Register Account'><font color=tan>Register Account</font></a> | <a href='?x=account&action=forgotpass' alt='Forgot Password' title='Forgot Password'><font color=tan>Forgot Password</font></a></b></font></center>
</td></tr></table><img src='/beta/layout_images/headertop.gif' width='100%' height=4></center></td></tr></table></center><center><table width=100% bgcolor='black'><tr><td>";
}
else
{

echo "<body background='/beta/layout_images/bg_2.gif' topmargin=0 leftmargin=0 rightmargin=0><center><img src='/beta/layout_images/headertop.gif' width='100%' height='4'></center>
<center><table width='100%' background='beta/layout_images/fbg.gif' cellspacing=0 width='100%'><tr><td width=15% valign='top'><b><center><font color=black><b><a href='index.php' alt='Game List' title='Game List'><font color=tan>Game List</font></a> | <a target=_href href=http://www.youtube.com/watch?v=YsrQkWsvJUI><font color=tan>Teh Sins Video Tutorial</font></a> |<a href='?x=account&action=logout' alt='Log Out' title='Log Out'><font color=tan>Log Out Account</font></a></b></font></center>
</td></tr></table><img src='/beta/layout_images/headertop.gif' width='100%' height=4></center></td></tr></table></center><center><table width=100% bgcolor='black'><tr><td>";
           }
if ($user_email == "") {
echo"<table width=100% align=center bgcolor=black><tr><td align=center class=sidemenu2 width=250 valign=top background='beta
/layout_images/menubgg.png'>
<table><td class=on align=center width=240><b><font color=#FFFFFF>Richest Gangsters</font></b></td><tr><td>
   <center><table width=100%><tr>";


$sql="SELECT nickname, nrank, rank, SUM(bank+cash) AS nw FROM $prefix.user_characters where rank!='Admin' and staff_rank!='Mod' and staff_rank!='Public_Relations' GROUP BY nickname ORDER BY nrank ASC LIMIT 0,5;";
$sql=mysql_query($sql);
if(@mysql_num_rows($sql)==0) {
           echo "<td><font face=arial size=2 color=#FFFFFF>
       <font color=silver><b>None...</b></font></td>";
       }
       else
       {
           $ranknum=1;
           while($temp=mysql_fetch_array($sql)) {
       echo "<td>$ranknum.</td><td><font face=arial size=2 color=#FFFFFF>
       <font color=silver><b>".$temp[nickname]."</b></font></td><td><font face=arial size=2 color=#FFFFFF>
       <font color=silver><b>$".number_format($temp[nw])."</b></font></td><tr>";
       $ranknum++;
}
}


   echo"</tr></table></td><tr><td class=on align=center><b><font color=#FFFFFF>Top Hitmen</font></b></td></tr><tr><td>  <table align=left border=0 width=240><tr>";

                   $sql="SELECT kills, nickname, view FROM $prefix.adv_stats WHERE view >= '10000' and nickname!='Teh_Sin' and nickname!='Teh_Boss' ORDER BY kills DESC LIMIT 0,5";
                   $sql=mysql_query($sql);
if(@mysql_num_rows($sql)==0) {
           echo "<td><font face=arial size=2 color=#FFFFFF>
       <font color=silver><b>None...</b></font></td>";
       }
       else
       {
           $ranknum=1;
           while($temp=mysql_fetch_array($sql)) {
       echo "<td>$ranknum.</td><td><font face=arial size=2 color=#FFFFFF>
       <font color=silver><b>".$temp[nickname]."</b></font></td><td><font face=arial size=2 color=#FFFFFF>
       <font color=silver><b>".number_format($temp[kills])."</b></font></td><tr>";
       $ranknum++;
}
}


   echo"</tr></table></td></tr></table>";
} ?>

</td>
<td align=left width=100% bgcolor=black valign=top>
<?php
   $x=$_GET['x'];
   if($x=='') {
       $x="home";
   }
   $z=$x.".php";
   if(is_file($z)) {
       include($z);
   } else {
       include('error.php');
   }
   ?>
</td>
<?php

if($user_email=="")
{
echo "<td align=center class=sidemenu2 width=250 valign=top background='beta
/layout_images/menubg2.png'>
<table><tr><td><table align=center width=240><tr><td colspan=2 align=center class=on><b><font color=#FFFFFF>Members Login</font></b></td><tr><form method=post action=index.php?x=account&action=login><td>Email:  </td><td><input type=text name=email></td><tr>
<td>Password</td><td><input type=password name=passwd></td><tr>
<td colspan=2 align=center><input type=submit name=submit value=Login></form></td></tr></table></tr><tr><table align=center width=240 height><tr><td colspan=2 align=center class=on><b><font color=#FFFFFF>Game Stats & Info</font></b></td><tr><td>Users Online: </td><td><b>".number_format($onlinegangsters) . "</b></td><tr><td>Alive Gangsters: </td><td><b>".number_format($alive_members) . "</b></td><tr><td>Dead Gangsters: </td><td><b>".number_format($dead_members) . "</b></td><tr><td>Organizations: </td><td><b>".number_format($total_families) . "</b></td><tr><td>Registered Gangsters: </td><td><b>" . number_format($totalgangsters) . "</b></td></font></td></tr></table></td></table></td>";
}
else
{
   echo"<td align=center class=sidemenu2 width=250 valign=top><table class=sidemenu2 width=190 align=center background=layout_images/gray-greident.gif cellpadding=4 cellspacing=0>
            <tr valign=top>
           <td class=on align=center><font color=#FFFFFF><b>Account News</b></font></td><tr><td>";
               $time=time();
               $query= "SELECT * FROM news WHERE `to`='$user_email' ORDER BY timestamp DESC LIMIT 5;";   
               $result=mysql_query($query);
               if (mysql_num_rows($result) == 0) {

                   echo "<font size=1 color=#FFFFFF>No News.";

               } else {


                   while($row=mysql_fetch_row($result))
                   {
                       $timegap=$time - $row[2];
                       if ($timegap < 86400) {
                       $fontcolor="#FFCC00";
                       }
                       else
                       {
                       $fontcolor="silver";
                       }
                       echo "<font size=1 color=$fontcolor face=tahoma><b>" . date('m/d/Y  H:i:s', $row[2]) . "</b><font color=#FFFFFF> $row[3]";
                   }
                       }
       echo "</td></tr></table></center></td></table>";
       }
?>
</td></tr></table></center><center><img src='/beta/layout_images/headertop.gif' width='100%' height='4'></center>
<center><table width='100%' background='beta
/layout_images/topnav.gif' cellspacing=0 width='100%'><tr><td width=15% valign='top'><b><center><font color=black size=1><b>Crime-Nations.com™ Trademarked by Red-Circus Creative. Copyright © 2008-2012 Crime-Nations.Com™. WorldWideOCR SEAL™ Files © Last Modified: Nov, 2012.</b></center>
<center><font color=black><b><a href='?x=frontvotepage' alt='Vote For Us' title='Vote For Us'><font color=tan>Vote For Us</font></a> | <a href='?x=about' alt='About Us' title='About Us'><font color=tan>About Us</font></a> | <a href='?x=customerservice' alt='Customer Service' title='Customer Service'><font color=tan>Customer Service</font></a> |<a href='?x=contact' alt='Contact Us' title='Contact Us'><font color=tan>Contact Us</font></a> | <a href='?x=updates' alt='Updates' title='Updates'><font color=tan>Updates</font></a> | <a href='?x=tos' alt='Terms Of Service' title='Terms Of Service'><font color=tan>T.O.S</font></a> | <a href='?x=scrnshots' alt='Screen Shots' title='Screen Shots'><font color=tan>Screen Shots</font></a> | <a href='?x=referral_program' alt='Refer Us' title='Refer Us'><font color=tan>Refer Us</font></a> | <a href='?x=signup' alt='Register Account' title='Register Account'><font color=tan>Register Account</font></a> | <a href='?x=account&action=forgotpass' alt='Forgot Password' title='Forgot Password'><font color=tan>Forgot Password</font></a> | <a href='?x=stats' alt='Game Stats' title='Game Stats'><font color=tan>Game Stats</font></a></b></font></center></td></tr></table><center><img src='/beta/layout_images/headertop.gif' width='100%' height=4></center>
</body>
</html><script type="text/javascript">

 var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-5704392-1']);
 _gaq.push(['_trackPageview']);

 (function() {
   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 })();

</script>

 

provide me with the screenshot and I might finish it.

Link to comment
Share on other sites

I'm not going to rewrite your file because I don't have the time, and HauntedDawg have put some quite nice effort on doing it already, but I thought I'd give you some advice instead, I hope you don't mind:

- You should drop the mysql_ extension, because as of version 5.5 mysql_ will be deprecated.

- You should keep the logic (php code) separated from the view (html).

- Supressing errors are generally bad practise.

- Why do you use include_once? Keep your code structured and make sure you wouldn't include it twice, or even better, have your code as structured as that you don't need to bother include_once, it sucks. http://robert.accettura.com/blog/2011/06/11/phps-include_once-is-insanely-expensive/

Link to comment
Share on other sites

I'm not going to rewrite your file because I don't have the time, and HauntedDawg have put some quite nice effort on doing it already, but I thought I'd give you some advice instead, I hope you don't mind:

- You should drop the mysql_ extension, because as of version 5.5 mysql_ will be deprecated.

- You should keep the logic (php code) separated from the view (html).

- Supressing errors are generally bad practise.

- Why do you use include_once? Keep your code structured and make sure you wouldn't include it twice, or even better, have your code as structured as that you don't need to bother include_once, it sucks. http://robert.accettura.com/blog/2011/06/11/phps-include_once-is-insanely-expensive/

Before jumping the gun and asking why am I using include_once, and then you point me to a thread that literally, is storming with comment's on how wrong his code is? Lets go quote...

Dilly Smith:

This article is inaccurate and dangerous for developers to stumble upon. Please update it. As Terrasque pointed out, include_once is actually MUCH faster than include. For another reference, see http://blog.seeit.org/2010/06/php-the-include-include_once-performance-debate/. Unless you specifically want to include a file multiple times, you should never use include.

Terrasque:

Correction… PHP include is insanely expensive :D

I tried taking your original include_once and just replace include_once with include and then test speed difference.

$ time php incNormal.php

real 0m29.794s

user 0m13.477s

sys 0m15.541s

$ time php incOnce.php

real 0m2.569s

user 0m1.216s

sys 0m1.336s

Also, as others have pointed out, your code is not functionally the same as include_once.

Now for the rest of the points:

- You should keep the logic (php code) separated from the view (html). - This is not an MVC ready framework, where one can simply just do that. Yes, one can have 2 different pages, but why for a login page? KISS

- Supressing errors are generally bad practise. - Bad practice on a live environment? I won't even go further into this one.

- You should drop the mysql_ extension, because as of version 5.5 mysql_ will be deprecated. - Some servers require mysqli extension to be enabled. While, I wanted to use MySQLi, I did not know if his server has it enabled or not.

Link to comment
Share on other sites

Before jumping the gun and asking why am I using include_once, and then you point me to a thread that literally, is storming with comment's on how wrong his code is? Lets go quote...

Dilly Smith:

 

Terrasque:

 

Now for the rest of the points:

- You should keep the logic (php code) separated from the view (html). - This is not an MVC ready framework, where one can simply just do that. Yes, one can have 2 different pages, but why for a login page? KISS

- Supressing errors are generally bad practise. - Bad practice on a live environment? I won't even go further into this one.

- You should drop the mysql_ extension, because as of version 5.5 mysql_ will be deprecated. - Some servers require mysqli extension to be enabled. While, I wanted to use MySQLi, I did not know if his server has it enabled or not.

Storming? 2 comments? I suppose. But no, the dude is referring to a link that is even older than mine, makes sense much.

Because structuring code like OP has sucks, and it is inefficent, hard to read, and undoubtley hard to change. You don't need files, a lot improvement would to put all LOGIC on the top, and then render/echo out the data on certain places needed. Not perfect, but seriosuly, a huge improvement.

Yes using @ to supress errors are bad advice, you shouldn't simply take away the errors, but learn to handle them.

The last tip wasn't pointed to you, but the OP himself.

Link to comment
Share on other sites

I don't usually place myself between other having an argument, but here's my advise.

The whole paradigm surrounding HTML is quite "sketchy". Using a markup language to define the logic behind an application is just bad.

Programming languages(i.e. PHP) and markup languages(i.e. HTML) are incompatible, and thus the reason why application logic should be separated from it's presentation.

I'm with Aventoro here: K.I.S.S. applies to many things, but not this - there's a proper way of doing something, and then there's hacking code together and hoping it works.

The template view pattern is one of the easiest to implement, and can be created from scratch to finish within a minute or two.

class View extends View_Abstract {
   private $_collection = array();
   public $template = 'index.phtml';

   public function __get($name) {
       return $this->_collection[$name];
   }

   public function __set($name, $value) {
       $this->_collection[$name] = $value;
   }


   public function render() {
        extract($this->_collection);
        require($this->template);
   }
}

Time taken: 1m3s, having no tabs is hard!

Suppressing errors is a very bad idea. Suppressing exceptions could be a good idea, depending on the context.

PHP provides no way to "catch" errors(other than hacking), since usually, you shouldn't attempt to recover from a fatal error.

But I'm guessing both of your advise governs all errors in PHP? Warnings should be silenced in production and notices probably discarded of, but in development it's fair game for anything as each dev will have their own setup.

Link to comment
Share on other sites

Thank you guys for taking my thread off subject. SO again, I am willing to pay someone who will rewrite my script. Stop posting how I should do it cause I aint doing it myself. There is a ****ing reason I offered to pay, Geez.

No, but I suppose you want your really bad script, as Good as you can get it?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...