Jump to content
MakeWebGames

Gang Banners


JamesRage
 Share

Recommended Posts

Hey guys, I really getting frustrated with a mod I'm trying to create, I'm trying to re-arrange V2 gang files for a friend of mine, the mod is Gang Banners. I added the SQL:

ALTER TABLE `gangs` ADD `gangsig` text NOT NULL ;

Now, before adding the editing your gang banner code in "yourgang.php" I wanted to test it, so I changed the gangsig details through PHPMyAdmin, with a image link.

And heres my code for the gang banner in gangs.php:

 

<?php
/**
* MCCodes Version 2.0.5b
* Copyright (C) 2005-2012 Dabomstew
* All rights reserved.
*
* Redistribution of this code in any form is prohibited, except in
* the specific cases set out in the MCCodes Customer License.
*
* This code license may be used to run one (1) game.
* A game is defined as the set of users and other game database data,
* so you are permitted to create alternative clients for your game.
*
* If you did not obtain this code from MCCodes.com, you are in all likelihood
* using it illegally. Please contact MCCodes to discuss licensing options
* in this case.
*
* File: gangs.php
* Signature: 92dce273deb1646013f261098b78903c
* Date: Fri, 20 Apr 12 08:50:30 +0000
*/

require_once('globals.php');
if (!isset($_GET['ID']))
{
   $_GET['ID'] = 0;
}
$_GET['ID'] = abs((int) $_GET['ID']);
if (!$_GET['ID'])
{
   echo "Invalid use of file";
}
else
{
   $gq =
           $db->query(
                   "SELECT `gangPRESIDENT`, `gangVICEPRES`, `gangNAME`,
                    `gangID`, `gangRESPECT`, `gangsig`, `gangDESC`
   				 FROM `gangs`
   				 WHERE `gangID` = {$_GET['ID']}");
   $gangdata = $db->fetch_row($gq);
   if (!isset($_GET['action']))
   {
       $_GET['action'] = '';
   }
   switch ($_GET['action'])
   {
   case 'view':
       gang_view();
       break;

   case 'userlist':
       gang_userlist();
       break;

   case 'apply':
       gang_applyform();
       break;

   case 'applys':
       gang_applysubmit();
       break;

   default:
       gang_view();
       break;
   }
}

function gang_view()
{
   global $db, $ir, $c, $h, $gangdata;
   $pq =
           $db->query(
                   "SELECT `userid`, `username`
   				 FROM `users`
   				 WHERE `userid` = {$gangdata['gangPRESIDENT']}
   				 LIMIT 1");
   if ($db->num_rows($pq) == 0)
   {
       $ldr = array('userid' => 0);
   }
   else
   {
       $ldr = $db->fetch_row($pq);
   }
   $db->free_result($pq);
   $vpq =
           $db->query(
                   "SELECT `userid`, `username`
                    FROM `users`
                    WHERE `userid` = {$gangdata['gangVICEPRES']}");
   if ($db->num_rows($vpq) == 0)
   {
       $coldr = array('userid' => 0);
   }
   else
   {
       $coldr = $db->fetch_row($vpq);
   }
   $db->free_result($vpq);
   echo "<h3><u>{$gangdata['gangNAME']}</u></h3>
   <hr width=60%/><img src='{$gangdata['gangsig']}' />
   <hr width=60%/>";
   if ($ldr['userid'] > 0)
   {
       print
               "President: <a href='viewuser.php?u={$ldr['userid']}'>{$ldr['username']}</a><br />";
   }
   else
   {
       print "President: N/A<br />";
   }
   if ($coldr['userid'] > 0)
   {
       print
               "Vice-President: <a href='viewuser.php?u={$coldr['userid']}'>{$coldr['username']}</a><hr />";
   }
   else
   {
       print "Vice-President: N/A<hr />";
   }
   $cnt =
           $db->query(
                   "SELECT COUNT(`userid`)
                    FROM `users`
                    WHERE `gang` = {$gangdata['gangID']}");
   echo "<b>Members:</b> " . $db->fetch_single($cnt)
           . "<br />
	  <b>Description: </b> {$gangdata['gangDESC']}<br />
	  <b>Respect Level: </b> {$gangdata['gangRESPECT']}<br />
	 > <a href='gangs.php?action=userlist&ID={$gangdata['gangID']}'>
	  User List
	 </a><br />
	 > <a href='gangs.php?action=apply&ID={$gangdata['gangID']}'>
	  Apply
	 </a>";
   $db->free_result($cnt);
}

function gang_userlist()
{
   global $db, $ir, $c, $h, $gangdata;
   echo "<h3>Userlist for {$gangdata['gangNAME']}</h3>
	  <table>
	  	<tr style='background: gray;'>
	  		<th>User</th>
	  		<th>Level</th>
	  		<th>Days In Gang</th>
	  	</tr>";
   $q =
           $db->query(
                   "SELECT `userid`, `username`, `level`, `daysingang`
                    FROM `users`
                    WHERE `gang` = {$gangdata['gangID']}
                    ORDER BY `daysingang` DESC, `level` DESC");
   while ($r = $db->fetch_row($q))
   {
       echo "<tr>
       		<td><a href='viewuser.php?u={$r['userid']}'>
                {$r['username']}
       		</a></td>
       		<td>{$r['level']}</td>
       		<td>{$r['daysingang']}</td>
       	  </tr>";
   }
   $db->free_result($q);
   echo "</table><br />
> <a href='gangs.php?action=view&ID={$gangdata['gangID']}'>
Back
</a>";
}

function gang_applyform()
{
   global $ir, $c, $h, $gangdata;
   if ($ir['gang'] == 0)
   {
       $apply_csrf = request_csrf_code('gang_apply');
       echo "<form action='gangs.php?action=applys&ID={$_GET['ID']}' method='post'>
Type the reason you should be in this faction.<br />
<textarea name='application' rows='7' cols='40'></textarea><br />
<input type='hidden' name='verf' value='{$apply_csrf}' />
<input type='submit' value='Apply' /></form>";
   }
   else
   {
       echo "You cannot apply for a gang when you are already in one.";
   }
}

function gang_applysubmit()
{
   global $db, $ir, $c, $h, $gangdata, $userid;
   $application =
           (isset($_POST['application']) && is_string($_POST['application']))
                   ? $db->escape(
                           htmlentities(
                                   stripslashes($_POST['application']),
                                   ENT_QUOTES, 'ISO-8859-1')) : '';
   if (!isset($_POST['verf'])
           || !verify_csrf_code('gang_apply', stripslashes($_POST['verf'])))
   {
       echo "
       Your request to apply to this gang has expired. Please try again.<br />
       > <a href='gangs.php?action=apply&ID={$_GET['ID']}'>Back</a>
          ";
       die($h->endpage());
   }
   if (!$ir['gang'])
   {
       $db->query(
               "INSERT INTO `applications`
                VALUES(NULL, $userid, {$_GET['ID']}, '{$application}')");
       $gev =
               $db->escape(
                       "<a href='viewuser.php?u={$userid}'>{$ir['username']}</a>"
                               . " sent an application to join this gang.");
       $db->query(
               "INSERT INTO `gangevents`
                VALUES(NULL, {$_GET['ID']}, " . time() . ", '{$gev}')");
       echo "You sent your application to the {$gangdata['gangNAME']} gang.";
   }
   else
   {
       echo "You cannot apply for a gang when you are already in one.";
   }
}
$h->endpage();

 

Lines 103 is the main focus, thanks guys, really need this for a friend! :')

Link to comment
Share on other sites

I hope this isnt for criminal wars but ill give it a shot. Try replacing 103 with this
<hr width=60%/><img src="{$gangdata['gangsig']}" />

I like to use the syntax highlighting as a reference and see it already looks a bit better

Nope nothing buddy ):

Parse error: syntax error, unexpected '{', expecting ',' or ';' in /home/cvjcp26/public_html/gangs.php on line 103

And can someone please tell whats wrong "yourgang.php?action=warview" I get a query error? ):

Link to comment
Share on other sites

Pretty much you have a { also a , or ; in the wrong place with the error it gave....

About the gang banner, you would copy exactly the default user pic function but you would put $gangdata instead of $ir/$r ....

Note: Everything you are trying to do is already in the scripts, and sometimes people think too hard, then afterwards realize what they were wanting was in the mccodes scripts, just have too look harder... as for any pic, you would use the same method as the default pic method is on the viewuser page, however you are adding the field to the gang table, which you would use the $gangdata var then the field you added.

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.

 Share

×
×
  • Create New...