Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have you purchased a mod and lost your copy? Just file a support ticket through your "My Mods" page.


This forum is now closed and has moved to a new location! Click here to find out why.
Pages: [1] 2 3

AuthorTopic: The Ultimate Business Mod.  (Read 3900 times)

JoshuaDams

  • Active Member
  • **
  • Reputation Power: 129
  • JoshuaDams is working their way up.JoshuaDams is working their way up.JoshuaDams is working their way up.
  • Offline Offline
  • Posts: 240
    • MSN Messenger - immortalthug4ever@hotmail.com
    • View Profile
    • WWW
The Ultimate Business Mod.
« on: December 08, 2009, 07:17:29 PM »
I'm doing this One Time and One time only.  Minor bugs post here and I'll try and fix, but I'm not posting the entire new code as I do that on my own forums.

That being said, Enjoy, I spent A lot of time on this.

**Mod originally created by Richard off MWG forums, It had several bugs, several missing functions, security issues, and over all just wasnt up to snuff**

It is now, Tested, Works 100%.  BludClart added the comppoints bit so all credits for that go to him.

Now lets do the SQLS.  This will be more than one post as limits on forums restrict characther amounts.

SQLS
Code: [Select]
CREATE TABLE IF NOT EXISTS `businesses` (
  `busId` int(11) NOT NULL auto_increment,
  `busName` varchar(255) NOT NULL,
  `busClass` int(11) NOT NULL,
  `busDirector` int(11) NOT NULL,
  `busProfit` bigint(25) NOT NULL,
  `busYProfit` bigint(25) NOT NULL,
  `busCust` int(11) NOT NULL,
  `busYCust` int(11) NOT NULL,
  `busCash` int(11) NOT NULL,
  `busDebt` int(11) NOT NULL,
  `busImage` varchar(255) NOT NULL,
  `busDays` bigint(32) NOT NULL default '0',
  `busEmployees` int(11) NOT NULL default '0',
  `brank` int(11) NOT NULL default '0',
  `busDesc` varchar(50) NOT NULL,
  `bussecurity` int(11) NOT NULL default '0',
  PRIMARY KEY  (`busId`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
Code: [Select]
CREATE TABLE IF NOT EXISTS `businesses_alerts` (
  `alertId` int(11) NOT NULL auto_increment,
  `alertBusiness` int(11) NOT NULL default '0',
  `alertTime` int(11) NOT NULL default '0',
  `alertText` text NOT NULL,
  PRIMARY KEY  (`alertId`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=19 ;
Code: [Select]
CREATE TABLE IF NOT EXISTS `businesses_apps` (
  `appId` int(11) NOT NULL auto_increment,
  `appMember` int(11) NOT NULL,
  `appBusiness` int(11) NOT NULL,
  `appText` text NOT NULL,
  `appTime` int(11) NOT NULL,
  PRIMARY KEY  (`appId`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
Code: [Select]
CREATE TABLE IF NOT EXISTS `businesses_classes` (
  `classId` int(11) NOT NULL auto_increment,
  `className` varchar(255) NOT NULL,
  `classDesc` text NOT NULL,
  `classMembers` int(11) NOT NULL,
  `classCost` int(11) NOT NULL,
  PRIMARY KEY  (`classId`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Dumping data for table `businesses_classes`
--

INSERT INTO `businesses_classes` (`classId`, `className`, `classDesc`, `classMembers`, `classCost`) VALUES
(1, 'Fireworks stand', 'Our customers will explode in delight with our fireworks. Great for holidays or any special event.', 4, 500000),
(2, 'Hair salon', 'A hair salon is a place where one goes to get their hair cut, as well as styled, highlighted or coloured.', 4, 750000),
(3, 'Law firm', 'A law firm is a business entity formed by one or more lawyers to engage in the practice of law. The money made is determined by the work hours the company sells. The amount of employees will increase this, aswell as the hired lawyers stats.', 6, 4000000),
(4, 'Flower shop', 'A store where flowers are purchased.', 4, 100000),
(5, 'Car dealership', 'Our customers need transportation. Sell them our best and send them on their way.', 8, 6000000),
(6, 'Football Club', 'Lead the way with your team and become the champions.', 10, 12000000);
Code: [Select]
CREATE TABLE IF NOT EXISTS `businesses_members` (
  `bmembId` int(11) NOT NULL auto_increment,
  `bmembMember` int(11) NOT NULL,
  `bmembBusiness` int(11) NOT NULL default '0',
  `bmembCash` int(11) NOT NULL,
  `bmembRank` int(11) NOT NULL default '0',
  `bmembDays` bigint(32) NOT NULL default '0',
  PRIMARY KEY  (`bmembId`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
Code: [Select]
CREATE TABLE IF NOT EXISTS `businesses_ranks` (
  `rankId` int(11) NOT NULL auto_increment,
  `rankName` varchar(255) NOT NULL,
  `rankClass` int(11) NOT NULL,
  `rankCash` int(11) NOT NULL,
  `rankPrim` enum('labour','IQ','strength') NOT NULL,
  `rankSec` enum('labour','IQ','strength') NOT NULL,
  `rankPGain` decimal(11,2) NOT NULL,
  `rankSGain` decimal(11,2) NOT NULL,
  PRIMARY KEY  (`rankId`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;

--
-- Dumping data for table `businesses_ranks`
--

INSERT INTO `businesses_ranks` (`rankId`, `rankName`, `rankClass`, `rankCash`, `rankPrim`, `rankSec`, `rankPGain`, `rankSGain`) VALUES
(1, 'Sales person', 1, 1000, 'IQ', 'labour', '30.50', '15.25'),
(2, 'Product manager', 1, 2500, 'labour', 'strength', '20.00', '10.00'),
(3, 'Cashier', 1, 5000, 'IQ', 'strength', '25.00', '12.00'),
(4, 'Stylist', 2, 800, 'IQ', 'labour', '25.00', '12.50'),
(5, 'Cleaner', 2, 1400, 'labour', 'strength', '20.00', '10.00'),
(6, 'Shampooist', 2, 2100, 'strength', 'labour', '25.00', '12.50'),
(7, 'Lawyer', 3, 1200, 'IQ', 'labour', '40.00', '20.00'),
(8, 'Cleaner', 3, 800, 'labour', 'strength', '20.00', '10.00'),
(9, 'Receptionist', 3, 600, 'IQ', 'labour', '30.00', '15.00'),
(10, 'Florist', 4, 500, 'labour', 'strength', '25.00', '12.50'),
(11, 'Cleaner', 4, 750, 'labour', 'IQ', '20.00', '10.00'),
(12, 'Salesman', 5, 3400, 'labour', 'strength', '30.00', '15.00'),
(13, 'Cleaner', 5, 1400, 'labour', 'strength', '20.00', '10.00'),
(14, 'Receptionist', 5, 900, 'IQ', 'labour', '34.00', '17.00'),
(15, 'Referee', 6, 3150, 'labour', 'strength', '15.00', '10.00'),
(16, 'Player', 6, 3500, 'labour', 'IQ', '28.00', '7.00'),
(17, 'Goal Keeper', 6, 3100, 'labour', 'strength', '25.00', '7.00');
Code: [Select]
CREATE TABLE IF NOT EXISTS `compspecials` (
  `csID` int(11) NOT NULL auto_increment,
  `csNAME` varchar(255) NOT NULL default '',
  `csJOB` int(11) NOT NULL default '0',
  `csCOST` int(11) NOT NULL default '0',
  `csMONEY` int(11) NOT NULL default '0',
  `csCRYSTALS` int(11) NOT NULL default '0',
  `csITEM` int(11) NOT NULL default '0',
  `csENDU` int(11) NOT NULL default '0',
  `csIQ` int(11) NOT NULL default '0',
  `csLABOUR` int(11) NOT NULL default '0',
  `csSTR` int(11) NOT NULL default '0',
  PRIMARY KEY  (`csID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;

--
-- Dumping data for table `compspecials`
--

INSERT INTO `compspecials` (`csID`, `csNAME`, `csJOB`, `csCOST`, `csMONEY`, `csCRYSTALS`, `csITEM`, `csENDU`, `csIQ`, `csLABOUR`, `csSTR`) VALUES
(1, 'Steal A Ford Transit', 5, 3, 0, 0, 31, 0, 0, 0, 0),
(2, 'Working 24/7 + $1500', 1, 3, 1500, 0, 0, 0, 0, 0, 0),
(3, 'Steal a Diamond', 1, 5, 0, 1, 0, 0, 0, 0, 0),
(4, 'Steal an Energy Bar', 1, 20, 0, 0, 131, 0, 0, 0, 0),
(5, 'Gang Respect + 5', 2, 10, 0, 0, 0, 0, 0, 0, 0),
(6, 'Eat Out - Gain a Pizza', 2, 5, 0, 0, 117, 0, 0, 0, 0),
(7, '+ 50 Gang Respect ', 2, 30, 0, 0, 0, 0, 0, 0, 0),
(8, 'Steal a Jail Ticket ', 3, 10, 0, 0, 182, 0, 0, 0, 0),
(9, 'Steal Jail Keys', 3, 3, 0, 0, 76, 0, 0, 0, 0),
(10, 'Steal Super Jail Keys', 3, 5, 0, 0, 94, 0, 0, 0, 0),
(11, 'Working Overtime + $500', 4, 3, 500, 0, 0, 0, 0, 0, 0),
(12, 'Steal A Ford Focus', 5, 15, 0, 0, 75, 0, 0, 0, 0),
(13, 'Steal A Lamborgini Gallardo', 5, 45, 0, 0, 16, 0, 0, 0, 0),
(14, 'Combat Training + 50 Strength', 14, 2, 0, 0, 0, 0, 0, 0, 50);
Code: [Select]
ALTER TABLE `users` ADD `comppoints` INT(11) NOT NULL DEFAULT '0';
ALTER TABLE `users` ADD `business` INT(11) NOT NULL DEFAULT '0';
ALTER TABLE `users` ADD `active` INT(11) NOT NULL DEFAULT '0';
ALTER TABLE `users` ADD `activedays` INT(11) NOT NULL DEFAULT '0';

Next
Open up loggedin.php
Add this query, I'd suggest right under neath the include "globals.php" bit
Code: [Select]
$db->query("UPDATE users SET active=1 WHERE userid=$userid");
Next Open up Global_func.php and find ?>

Above that add
Code: [Select]
function business_alert($business, $text)
 {
    mysql_query(sprintf("INSERT INTO `businesses_alerts` (`alertId`, `alertBusiness`, `alertText`, `alertTime`) VALUES ('NULL', '%u', '%s', '%d')", $business, $text, time()));
 }

JoshuaDams

  • Active Member
  • **
  • Reputation Power: 129
  • JoshuaDams is working their way up.JoshuaDams is working their way up.JoshuaDams is working their way up.
  • Offline Offline
  • Posts: 240
    • MSN Messenger - immortalthug4ever@hotmail.com
    • View Profile
    • WWW
Re: The Ultimate Business Mod.
« Reply #1 on: December 08, 2009, 07:20:22 PM »
business_create.php
Code: [Select]
<?php
                                 
include_once (DIRNAME(__FILE__). '/globals.php');
   global 
$db,$ir;

          
$check $db->query(sprintf("SELECT * FROM `businesses` WHERE (`busDirector` = '%u')"$ir['userid']));
          
$check_member $db->query(sprintf("SELECT * FROM `businesses_members` WHERE (`bmembMember` = '%u')"$ir['userid']));
   
   if(
$ir['level'] < 5
                                                       {
          die (
'You must be at least Level 5 to begin a Company.'); 
                                                       }
   if(
$db->num_rows($check) || $db->num_rows($check_member)) 
                                                       {
          die (
'You are part of a job/company at this time, leave to start a new one.'); 
                                                       }
          echo 
'<p class="heading">Create Company</p>';
                               
$_POST['name'] = mysql_real_escape_string($_POST['name']);
                               
$_POST['class'] = abs(@intval($_POST['class']));   
   if(
$_POST['name'] AND $_POST['class'])
                                                       {
          
$fetch_class $db->query(sprintf("SELECT * FROM `businesses_classes` WHERE (`classId` = '%u')"$_POST['class']));
          
$check $db->query(sprintf("SELECT * FROM `businesses` WHERE (`busDirector` = '%u')"abs(@intval($ir['userid']))));
          
$check_member $db->query(sprintf("SELECT * FROM `businesses_members` WHERE (`bmembMember` = '%u')"abs(@intval($ir['userid']))));
   
   if(!
$db->num_rows($fetch_class))
                                                       {
          echo 
'You cannot start a business in a class that doesn\'t exist.';
                                                       }
   else
                                                       {
          
$r $db->fetch_row($fetch_class);
      
   if(
$ir['level'] < 5)
                                                       {
          echo 
'You must be at least Level 5 to begin a Company.';
                                                       }
   else if(
$ir['money'] < $r['classCost'])
                                                       {
          echo 
'You cannot afford to start a business of this class right now.';
                                                       }
   else if(
$db->num_rows($check) || $db->num_rows($check_member))
                                                       {
          echo 
'You are part of a business at this time, leave to start a new one.';
                                                       }
   else
                                                       {
          
$db->query(sprintf("INSERT INTO `businesses` (`busId`, `busName`, `busClass`, `busDirector`, `busEmployees`) VALUES ('NULL','%s', '%d', '%u', '%u')"stripslashes($_POST['name']), $_POST['class'], abs(@intval($ir['userid'])), $r['classMembers']));
          
$db->query(sprintf("UPDATE `users` SET `money` = `money` - '%d' WHERE `userid` = '%u'"$r['classCost'], abs(@intval($ir['userid']))));
          
$check $db->query(sprintf("SELECT * FROM `businesses` WHERE (`busDirector` = '%u')"abs(@intval($ir['userid']))));
          
$direct $db->fetch_row($check);
          
$db->query(sprintf("UPDATE `users` SET `business` = '%u' WHERE `userid` = '%u'"$direct['busId'], abs(@intval($ir['userid']))));
          echo 
'The '.$_POST['name'].' business was created.';
                                                        }
                                                        }
                                                        }
   else
                                                        {
          echo 
'<form action="business_create.php" method="post">
          <p align="center">
          <b>Create a new business:</b><br /><br />
          Please enter a name for the new business below, then select a class.<br /><br />
          Business name: <input type="text" name="name" /><br />
          Business class: <select name="class">
          <option value="0">None</option>'
;
          
$select_classes $db->query("SELECT * FROM `businesses_classes` ORDER BY `classCost` ASC");
          while(
$c $db->fetch_row($select_classes))
                                                         {
          echo 
'<option value="'.$c['classId'].'">'.stripslashes($c['className']).' (\$'.number_format($c['classCost']).')</option>';
                                                         }
          echo 
'</select><br /><br />
          <input type="submit" value="Create business" /></p>
          </form>'
;
                                                         }
   
$h->endpage();
?>



business_cron.php
Code: [Select]
<?php
include "config.php";
include 
"global_func.php";
global 
$_CONFIG;
if(
$_GET['code'] != $_CONFIG['code']) { die(""); }
define("MONO_ON"1);
require 
"class/class_db_{$_CONFIG['driver']}.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
 
$_CONFIG['username'],
 
$_CONFIG['password'],
 
$_CONFIG['database'],
 
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
$set=array();
$settq=$db->query("SELECT * FROM settings");
while(
$r=$db->fetch_row($settq))
{
$set[$r['conf_name']]=$r['conf_value'];
}

$db->query("UPDATE `businesses` SET `brank` = '100000' WHERE `brank` > '100000'");

$select_businesses $db->query("SELECT * FROM `businesses` LEFT JOIN `businesses_classes` ON (`classId` = `busClass`) ORDER BY `busId` ASC");

while(
$bs=$db->fetch_row($select_businesses))
 {
   
$amount $db->num_rows($db->query(sprintf("SELECT * FROM `businesses_members` WHERE `bmembBusiness` = '%u'"$bs['busId'])));
   
$active $db->num_rows($db->query(sprintf("SELECT * FROM `users` WHERE `business` = '%u' AND active='%d'"$bs['busId'], 1)));

$new_customers = ($bs['brank']*($active)+ rand(1020)*$bs['classCost'] / 200);
$new_profit = (($new_customers)+ rand(110990));
$new_rank = ($bs['classId']*($active)/2);
      
$db->query(sprintf("UPDATE `businesses` SET `busYCust` = `busCust`, `busYProfit` = `busProfit`, `busCust` = '%d', `busProfit` = '%d', `busCash` = '%d' WHERE `busId` = '%u'"$new_customers$new_profit, ($new_profit $bs['busCash']), $bs['busId']));
$db->query(sprintf("UPDATE `businesses` SET `busDays` = `busDays` + '1'"));
$db->query(sprintf("UPDATE `users` SET `activedays` = `activedays` + '1' WHERE `active` = '1'"));
$db->query(sprintf("UPDATE `users` SET `active` = '0' WHERE `active` = '1'"));
$db->query(sprintf("UPDATE `businesses` SET `brank` = `brank` + '%d' WHERE `busId` = '%u'",  $new_rank$bs['busId']));
 
$fetch_members $db->query(sprintf("SELECT * FROM `businesses_members` LEFT JOIN `users` ON (`userid` = `bmembMember`) LEFT JOIN `businesses_ranks` ON (`rankId` = `bmembRank`) WHERE `bmembBusiness` = '%u'"$bs['busId'])) OR die('Cron not run');
$db->query("UPDATE userstats SET labour = labour + 50, IQ = IQ + 50, strength = strength + 50 WHERE userid = {$bs['busDirector']}");
$db->query("UPDATE users SET comppoints = comppoints + 1 WHERE userid = {$bs['busDirector']}");

   while(
$fm=$db->fetch_row($fetch_members))
    {
    
 
$db->query(sprintf("UPDATE `userstats` SET `{$fm['rankPrim']}` = `{$fm['rankPrim']}` + '%.6f', `{$fm['rankSec']}` = `{$fm['rankSec']}` + '%.6f' WHERE (`userid` = '%u')"$fm['rankPGain'], $fm['rankSGain'], $fm['userid'])) OR die('Cron not run');
   
   
$db->query(sprintf("UPDATE `users` SET `money` = `money` + '%d' WHERE `userid` = '%u'"$fm['bmembCash'], $fm['userid'])) OR die('Cron not run');

 
$db->query(sprintf("UPDATE `users` SET `comppoints` = `comppoints` + '1' WHERE `userid` = '%u'"$fm['userid'])) OR die('Cron not run');

     

          
if(
$bs['busCash'] < $fm['bmembCash'])
       {
         
$text "Member ID {$fm['bmembMember']} was not paid their \$".number_format($fm['bmembCash'])." due to lack of funds." OR die('Cron not run');
         
$db->query(sprintf("INSERT INTO `businesses_alerts` (`alertId`, `alertBusiness`, `alertText`, `alertTime`) VALUES ('NULL', '%u', '%s', '%d')"$bs['busId'], $texttime())) OR die('Cron not run');
         
$db->query(sprintf("UPDATE `businesses` SET `busDebt` = `busDebt` + '%d' WHERE `busId` = '%u'"$fm['bmembCash'], $bs['busId'])) OR die('Cron not run');
       }
      else
       {
         
$db->query(sprintf("UPDATE `businesses` SET `busCash` = `busCash` - '%d' WHERE `busId` = '%u'"$fm['bmembCash'], $bs['busId'])) OR die('Cron not run');
       }
    }
   if(
$bs['busDebt'] > $bs['classCost'])
    {
      
$send_event $db->query(sprintf("SELECT `bmembMember` FROM WHERE `bmembBusiness` = '%u' ORDER BY `bmembId` DESC"$bs['busId'])) OR die('Cron not run') ;
      while(
$se=$db->fetch_row($send_event))
       {
         
$text "The {$bs['busName']} business went bankrupt\, all members have been made redundent." OR die('Cron not run');
         
insert_event($se['bmembMember'], $text);
       }
      
$db->query(sprintf("DELETE FROM `businesses_members` WHERE (`bmembBusiness` = '%u')"$bs['busId'])) OR die('Cron not run');
      
$db->query(sprintf("DELETE FROM `businesses` WHERE (`busId` = '%u')"$bs['busId'])) OR die('Cron not run');
    }
 }
?>

JoshuaDams

  • Active Member
  • **
  • Reputation Power: 129
  • JoshuaDams is working their way up.JoshuaDams is working their way up.JoshuaDams is working their way up.
  • Offline Offline
  • Posts: 240
    • MSN Messenger - immortalthug4ever@hotmail.com
    • View Profile
    • WWW
Re: The Ultimate Business Mod.
« Reply #2 on: December 08, 2009, 07:24:21 PM »
business_home.php
Code: [Select]
<?php
                                  
include_once (DIRNAME(__FILE__). '/globals.php');
                                include_once (
DIRNAME(__FILE__). '/bbcode_parser.php');
   global 
$ir,$db;

         echo 
'<p class="heading">Your Job<hr width="50%"></p>';
         
$check $db->query(sprintf("SELECT * FROM `businesses_members` WHERE (`bmembMember` = '%u')"$ir['userid']));
         
$check_two $db->query(sprintf("SELECT * FROM `businesses` WHERE (`busDirector` = '%u')"$ir['userid']));
   if(!
$db->num_rows($check_two) AND !$db->num_rows($check))
                                                          {
         echo 
'You are not a member of a Company right now, come back another time.';
         
$h->endpage();
         exit;
                                                          }
   else
                                                          {
        
$r $db->fetch_row($check);
        
$b $db->fetch_row($check_two);
        
$fetch_business $db->query(sprintf("SELECT * FROM `businesses` LEFT JOIN `businesses_classes` ON (`classId` = `busClass`) WHERE (`busId` = '%u') OR (`busId` = '%u')"$r['bmembBusiness'], $b['busId']));
        if(!
$db->num_rows($fetch_business))
                                                           {
        echo 
'This Company does not exist at this time, please come back later.';
        
$h->endpage();
        exit;
                                                           }
   else
                                                           {
       
$inf $db->fetch_row($fetch_business);
                                                           }
                                                           }
   switch (
$_GET['p'])
                                                           {
       case 
'leave_business'leave_business(); break;
       case 
'view_members'view_members(); break;
       case 
'donate_cash'donate_cash(); break;
       case 
'view_vault'view_vault(); break;
       default: 
business_index(); break;
                                                           }
   function 
business_index()
                                                           {
   global 
$ir$inf$db;
       echo 
'<b>'.stripslashes($inf['busName']).' options:</b><br /><br />';
    
   if(
$inf['busDirector'] == $ir['userid'])
                                                           {
       echo 
'<a href="business_manage.php">Manage Company</a><br />';
                                                           }
   else
                                                           {
       echo 
'<a href="business_home.php?p=view_vault">Donate to the Company</a><br />';
       echo 
'<a href="business_home.php?p=leave_business">Leave the Company</a><br />';
                                                           }
       echo 
'<a href="business_home.php?p=view_members">View members</a><br /><br>';
   
       
$fetch_business $db->query(sprintf("SELECT * FROM `businesses` LEFT JOIN `businesses_classes` ON (`classId` = `busClass`) LEFT JOIN `users` ON (`userid` = `busDirector`) WHERE (`busId` = '%u')"abs((int) $inf['busId'])));    
   
   if(!
$db->num_rows($fetch_business))
                                                           {
       echo 
'You cannot view a Company that doesn\'t exist .';
                                                           }
   else
                                                           {
      
$r $db->fetch_row($fetch_business);
      
$fetch_memberinfo $db->query(sprintf("SELECT * FROM `businesses_members` WHERE `bmembMember` = '%u'"$ir['userid']));
      
$mem $db->fetch_row($fetch_memberinfo);
      
$realrank $db->query(sprintf("SELECT * FROM `businesses_ranks` WHERE (`rankId` = '%u')"$mem['bmembRank']));
      
$rname $db->fetch_row($realrank);
      
   if(
$mem['bmembRank'] == 0
                                                           {
      
$rank='dont have an assigned rank'
                                                           }
   else  
                                                           {
      
$rank='work as a '.($rname['rankName']).'';  
                                                           }
   
   if(
$mem['bmembCash'] >= 0){ $mcash='£'.number_format($mem['bmembCash']).'';
                                                           }
   if(!
$rname['rankPGain'] AND !$rname['rankPrim'] AND !$rname['rankSGain'] AND !$rname['rankSec']) 
                                                           {
      
$gaininfo='You also receive 50 labour, 50 intelligence and 50 strength every day.'
                                                           }
   else                                                    {
      
$gaininfo='You also receive '.($rname['rankPGain']).' '.($rname['rankPrim']).' and '.($rname['rankSGain']).' '.($rname['rankSec']).' every day.'
                                                           }
   if(
$mem['bmembRank'] == 0)
                                                           {
      
$gaininfo='You also receive 0 labour, 0 intelligence and 0 strength every day.'
                                                           } 
   if(
$ir['userid'] == $r['busDirector']) 
                                                           {
      
$rank='are the owner'
                                                           }
   if(
$ir['userid'] == $r['busDirector']) 
                                                           {
      
$gaininfo='You also receive 50 labour, 50 intelligence and 50 strength every day.'
                                                           }
      echo 
'<hr width="50%">
      You currently '
.stripslashes($rank).' at '.stripslashes($r['busName']).' which is owned by <a href="viewuser.php?u='.$r['userid'].'">'.stripslashes($r['username']).'</a>.<br/>
      You are paid '
.($mcash).' at midnight TIL time every day!<br/>
      '
.($gaininfo).'
      <hr width="50%">
      <table width="50%" class="table">
      <tr>
      <th colspan="2">Details of '
.stripslashes($r['busName']).' - '.stripslashes($r['className']).'</th>
      </tr>
      <tr>
      <td colspan="2"><center>'
.($r['busDesc']).'</center></td>
      </tr>
      <tr height="100">
      <td colspan="2" valign="middle" align="center">'
;
      
   if(
$r['busImage'])
                                                            {
      echo 
'<img src="'.stripslashes($r['busImage']).'" alt="'.stripslashes($r['busName']).' banner" width="100%" height="100" />';
                                                            }
   else
                                                            {
        echo 
'<img src="dimg.jpg"/>';
                                                            }
   if(
$r['brank'] < 1000
                                                            {
        
$stars='<img src="job_star.gif" width=25 height=25/>'
                                                            }
   if(
$r['brank'] > 1000
                                                            {
        
$stars='<img src="job_star.gif" width=25 height=25/> <img src="job_star.gif" width=25 height=25/>'
                                                            }
   if(
$r['brank'] > 5000
                                                            {
        
$stars='<img src="job_star.gif" width=25 height=25/> <img src="job_star.gif" width=25 height=25/> <img src="job_star.gif" width=25 height=25/>'
                                                             }
   if(
$r['brank'] > 35000
                                                             {
        
$stars='<img src="job_star.gif" width=25 height=25/> <img src="job_star.gif" width=25 height=25/> <img src="job_star.gif" width=25 height=25/> <img src="job_star.gif" width=25 height=25/>'
                                                             }
   if(
$r['brank'] > 100000
                                                             {
        
$stars='<img src="job_star.gif" width=25 height=25/> <img src="job_star.gif" width=25 height=25/> <img src="job_star.gif" width=25 height=25/> <img src="job_star.gif" width=25 height=25/> <img src="job_star.gif" width=25 height=25/>'
                                                             }

        
$fetch_members $db->num_rows($db->query(sprintf("SELECT * FROM `businesses_members` WHERE `bmembBusiness` = '%u'"$r['busId'])));
        
$fetch_memberinfo $db->query(sprintf("SELECT * FROM `businesses_members` WHERE `bmembMember` = '%u'"$ir['userid']));
        
$mem $db->fetch_row($fetch_memberinfo);
        
$cd $db->query(sprintf("SELECT * FROM `userstats` WHERE `userid` = '%u'"$ir['userid']));
        
$fstats $db->fetch_row($cd);
        
$realrank $db->query(sprintf("SELECT * FROM `businesses_ranks` WHERE (`rankId` = '%u')"$mem['bmembRank']));
        
$rname $db->fetch_row($realrank);

   if(
$mem['bmembRank'] <= 0
                                                              {
        
$rank='None'
                                                              }
    else 
                                                              {
        
$rank=''.($rname['rankName']).''
                                                              }

   if(
$mem['bmembCash'] == 0
                                                              {
        
$mcash='$<font color=red>-'.number_format($mem['bmembCash']).'</font>'
                                                              }
   else if(
$mem['bmembCash'] > 0)
                                                              { 
        
$mcash='<font color=green>+'.number_format($mem['bmembCash']).'</font>'
                                                              }

        echo 
'</td></tr>
        <tr>
        <td colspan="2"><center><b><u>Company Rank</b></u><br/>'
.$stars.'</center></td>
        </tr>
        <tr>
        <th colspan="2">Further information</th>
        </tr>
        <tr height="150">
        <td colspan="2" valign="middle" align="center">
        <table width="100%">
        <tr>
        <td>
        <b>Type:</b> '
.stripslashes($r['className']).'<br />
        <b>Director:</b> <a href="viewuser.php?u='
.$r['userid'].'">'.stripslashes($r['username']).'</a><br />
        <b>Company bank:</b> $'
.number_format($r['busCash']).'<br />
        <b>Employees:</b> '
.number_format($fetch_members).'/'.($r['busEmployees']).'<br />
        <b>Days old:</b> '
.number_format($r['busDays']).'<br /><br/>
        </td>
        <td>
        <b>Your details</b><br/>
        <b>Rank: </b>'
.stripslashes($rank).'</b><br/>
        <b>Income: </b>'
.($mcash).'<br/>
        <b>labour: </b>'
.number_format($fstats['labour']).'<br/>
        <b>Intelligence: </b>'
.number_format($fstats['IQ']).'<br/>
        <b>Strength:</b> '
.number_format($fstats['strength']).'<br/>
        <b>Company points:</b> '
.number_format($ir['comppoints']).' [<a href="companyspecials.php"/>Use</a>]<br/>
        <br/>
        </td>
        </tr>
        <tr>
        <td>
        <b>Todays profit:</b> Â£'
.number_format($r['busProfit']).'<br />
        <b>Yesterdays profit:</b> Â£'
.number_format($r['busYProfit']).'<br />
        <b>Todays customers:</b> '
.number_format($r['busCust']).'<br />
        <b>Yesterdays customers:</b> '
.number_format($r['busYCust']).'<br />
        <center></td>
        </tr>
        </table>'
;
                                                                   }
   
        echo 
'
        <table width="100%" class="table">
        <tr>
        <th>Action</th>
        <th>Time</th>
        </tr>'
;
        
$business_alerts $db->query(sprintf("SELECT * FROM `businesses_alerts` WHERE `alertBusiness` = '%u' ORDER BY `alertTime` DESC LIMIT 25"$inf['busId']));
        while(
$ba $db->fetch_row($business_alerts))
                                                                   {
        echo 
'
        <tr>
        <td width="50%">'
.stripslashes($ba['alertText']).'</td>
        <td width="20%">'
.date('d-m-Y, g:i:s A'$ba['alertTime']).'</td>
        </tr>'
;
                                                                   }
        echo 
'</table></table>';
                                                                   }

   function 
view_vault()
                                                                   {
   global 
$ir$inf$db;
        echo 
'<form action="business_home.php?p=donate_cash" method="post">
        Your Company has '
.number_format($inf['busCash']).' secured in it\'s vault.<br /><br />
        <b>Donate cash:</b><br /><br />
        Cash amount: <input type="text" name="cash" /><br /><br />
        <input type="submit" value="Donate cash"></form>'
;
                                                                    }

   function 
donate_cash()
                                                                    {
   global 
$ir$inf$db;
                                           
$_POST['cash'] = abs(@intval($_POST['cash']));   
   if(
$_POST['cash'] > 0)
                                                                    {
   if(
$_POST['cash'] > $ir['money'])
                                                                    {
         echo 
'You do not have enough cash to donate this much to the Company.';
                                                                    }
   else
                                                                    {
         
$db->query(sprintf("UPDATE `users` SET `money` = `money` - '%d' WHERE `userid` = '%u'"$_POST['cash'], $ir['userid']));
         
$db->query(sprintf("UPDATE `businesses` SET `busCash` = `busCash` + '%d' WHERE `busId` = '%u'"$_POST['cash'], $inf['busId']));
         echo 
'You have donated \$'.number_format($_POST['cash']).' to the Company.';
         
business_alert($inf['busId'], "".$ir['username']." donated $".number_format($_POST['cash'])." to the Company.");
                                                                    }
                                                                    }
   else
                                                                    {
         echo 
'You missed one or more of the required fields.';
                                                                    }
                                                                    }

   function 
leave_business()
                                                                    {
   global 
$ir$inf$db;
   
   if(
$inf['busDirector'] != $ir['userid'])
                                                                    {
   if(!
$_GET['confirm'])
                                                                    {
         echo 
'You are about to leave the '.$inf['busName'].' Company. Please confirm this action.<br /><br />
         <a href="business_home.php?p=leave_business&confirm=1">Leave the Company</a>'
;
                                                                    }
   else
                                                                    {
         
$db->query(sprintf("DELETE FROM `businesses_members` WHERE (`bmembMember` = '%u')"$ir['userid']));
         
$db->query(sprintf("UPDATE `users` SET `business` = '0' WHERE (`userid` = '%u')"$ir['userid']));
         echo 
'You have decided to leave the Company.';
                                                                    }
                                                                    }
   else
                                                                    {
         echo 
'You cannot leave the Company while still the director.'
                                                                    }
                                                                    }

   function 
view_members()
                                                                    {
   global 
$ir$inf$db;
         echo 
'<table width="60%" class="table">
         <tr>
         <th width="50%">Member name</th>
         <th width="50%">Job rank</th>
         </tr>'
;
         
$fetch_members $db->query(sprintf("SELECT * FROM `businesses_members` LEFT JOIN `users` ON (`userid` = `bmembMember`) LEFT JOIN `businesses_ranks` ON (`rankId` = `bmembRank`) WHERE `bmembBusiness` = '%u'"$inf['busId']));
         while(
$fm $db->fetch_row($fetch_members))
                                                                     {
         echo 
'
         <tr>
         <td><a href="viewuser.php?u='
.$fm['userid'].'">'.stripslashes($fm['username']).'</a> ['.$fm['userid'].']</td>
         <td>'
.stripslashes($fm['rankName']).' (£'.number_format($fm['bmembCash']).')</td>
         </tr>'
;
                                                                      }
         echo 
'</table>';
                                                                      }
   
$h->endpage();
?>

JoshuaDams

  • Active Member
  • **
  • Reputation Power: 129
  • JoshuaDams is working their way up.JoshuaDams is working their way up.JoshuaDams is working their way up.
  • Offline Offline
  • Posts: 240
    • MSN Messenger - immortalthug4ever@hotmail.com
    • View Profile
    • WWW
Re: The Ultimate Business Mod.
« Reply #3 on: December 08, 2009, 07:25:18 PM »
business_view.php
Code: [Select]
<?php
                              
include_once (DIRNAME(__FILE__). '/globals.php');

          echo 
'<p class="heading">Companies<br/><br/><a href="business_create.php"><b>Create a Company Here</b></a></p>';
          switch (
$_GET['page'])
                                                   {
          case 
'class'view_class(); break;
          case 
'profile'view_profile(); break;
          case 
'sendapp'send_application(); break;
          case 
'rob'rob_business(); break;
          default: 
business_index(); break;
                                                   }
    function 
business_index()
                                                   {
    global 
$ir,$db;
          echo 
'<p align="center">
          <b>Company Classes:</b><br /><br />
          <table width="600">'
;
          
$fetch_classes $db->query("SELECT * FROM `businesses_classes` ORDER BY `classId` ASC");
          while(
$r $db->fetch_row($fetch_classes))
                                                   {
          echo 
'
          <tr>
          <td width="275" align="right">'
.stripslashes($r['className']).'ʉۢ</td>
          <td width="50"></td>
          <td width="275" align="left">> <a href="business_view.php?page=class&id='
.$r['classId'].'">View '.stripslashes($r['className']).' companies</a></td>
          </tr>'
;
                                                    }
          echo 
'</table>
          </p>'
;
                                                    }
   function 
view_class()
                                                    {
   global 
$ir,$db;
                                
$_GET ['id'] = abs(@intval($_GET['id']));

   if(
$_GET['id'])
                                                    {
          
$fetch_class $db->query(sprintf("SELECT * FROM `businesses_classes` WHERE (`classId` = '%u')"$_GET['id']));
   if(!
$db->num_rows($fetch_class))
                                                    {
          echo 
'You cannot view a company class that doesn\'t exist.';
                                                    }
   else
                                                    {
          
$r $db->fetch_row($fetch_class);
          echo 
'<hr width="600">
          <p align="center">
          <b>'
.stripslashes($r['className']).':</b><br />
          <i>'
.stripslashes($r['classDesc']).'</i>
          <hr width="600">
          <p align="center">
          <b>Companies:</b><br />
          The '
.stripslashes($r['className']).' company is small and starts with a maximum of <b>'.number_format($r['classMembers']).'</b> members until it has been upgraded.<br />
          The total start up cost of a '
.stripslashes($r['className']).' company is Â£'.number_format($r['classCost']).'.</p>
          <hr width="600">
          <table width="600" class="table">
          <tr>
          <th colspan="4">'
.stripslashes($r['className']).' ranks</th>
          </tr>'
;
          
$fetch_ranks $db->query(sprintf("SELECT * FROM `businesses_ranks` WHERE `rankClass` = '%u'"$_GET['id']));
          while(
$rn $db->fetch_row($fetch_ranks))
                                                      {
          echo 
'
          <tr>
          <td width="25%"><b>Rank:</b> '
.stripslashes($rn['rankName']).'</td>
          <td width="20%"><b>Primary stat:</b> '
.stripslashes($rn['rankPrim']).'</td>
          <td width="20%"><b>Secondary stat:</b> '
.stripslashes($rn['rankSec']).'</td>
          <td width="45%"><b>Stat gain:</b> '
.$rn['rankPGain'].' '.stripslashes($rn['rankPrim']).' and '.$rn['rankSGain'].' '.stripslashes($rn['rankSec']).'</td>
          </tr>'
;
                                                       }
          echo 
'</table>
          <hr width="600">
          <table width="600" class="table">
          <tr>
          <th colspan="3">'
.stripslashes($r['className']).' companies</th>
          </tr>'
;
          
$bus_rating $db->query("SELECT `busCash` FROM `businesses`");
          
$ttl_profit 0;
          while(
$fetch_cash $db->fetch_row($bus_rating))
                                                        {
          
$ttl_profit += ($fetch_cash['busCash'] + 1);
                                                        }
          
$fetch_businesses $db->query(sprintf("SELECT * FROM `businesses` LEFT JOIN `users` ON (`userid` = `busDirector`) WHERE `busClass` = '%u'"$_GET['id']));
          while(
$fb $db->fetch_row($fetch_businesses))
                                                        {
   if(
$fb['brank'] < 1000) { $stars='<img src="donator.gif" width=25 height=25/>';
                                                        }
   if(
$fb['brank'] > 1000) { $stars='<img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/>'
                                                        }
   if(
$fb['brank'] > 5000) { $stars='<img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/>'
                                                        }
   if(
$fb['brank'] >= 35000) { $stars='<img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/>'
                                                        }
   if(
$fb['brank'] >= 100000) { $stars='<img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/>';              
                                                        }
          
$rate = (int) ((($fb['busCash'] + 1) / $ttl_profit 100) / 20);
          echo 
'
          <tr>
          <td width="85%"><a href="business_view.php?page=profile&id='
.$fb['busId'].'"><b>'.stripslashes($fb['busName']).'</b></a> - <a href="viewuser.php?u='.$fb['userid'].'"><i>'.stripslashes($fb['username']).'</i></a> '.$stars.'</td>
          
          </tr>'
;
                                                        }
          echo 
'</table>
          <hr width="600">'
;
                                                        }
                                                        }
   else
                                                        {
          echo 
'You did not select a company class to view.';
                                                        }
                                                        }
   function 
view_profile()
                                                        {
   global 
$ir,$db;
                                   
$_GET['id'] = abs(@intval($_GET['id']));

   if(
$_GET['id'])
                                                        {
         
$fetch_business $db->query(sprintf("SELECT * FROM `businesses` LEFT JOIN `businesses_classes` ON (`classId` = `busClass`) LEFT JOIN `users` ON (`userid` = `busDirector`) WHERE (`busId` = '%u')"$_GET['id']));
   if(!
$db->num_rows($fetch_business))
                                                        {
         echo 
'You cannot view a company that doesn\'t exist.';
                                                        }
   else
                                                        {
         
$r $db->fetch_row($fetch_business);
         echo 
'<hr width="400">
         <table width="400" class="table">
         <tr>
         <th colspan="2">Details of '
.stripslashes($r['busName']).' - '.stripslashes($r['className']).'</th>
         </tr>
         <tr height="100">
         <td colspan="2" valign="middle" align="center">'
;
    
   if(
$r['busImage'])
                                                        {
         echo 
'<img src="'.stripslashes($r['busImage']).'" alt="'.stripslashes($r['busName']).' banner" width="400" height="100" />';
                                                         }
   else
                                                         {
         echo 
'<img src="dimg.jpg"/>';
                                                         }
   if(
$r['brank'] < 1000)
                                                         {
         
$stars='<img src="donator.gif" width=25 height=25/>'
                                                         }
   if(
$r['brank'] > 1000
                                                         {
         
$stars='<img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/>'
                                                         }
   if(
$r['brank'] >= 5000)
                                                         {
         
$stars='<img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/>'
                                                         }
   if(
$r['brank'] > 35000)
                                                         {
         
$stars='<img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/>'
                                                          }
   if(
$r['brank'] > 100000) { $stars='<img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/> <img src="donator.gif" width=25 height=25/>'
                                                          }
         echo 
'</td></tr>
         <tr>
         <td colspan="2"><center><b><u>Company Rank</b></u><br/>'
.$stars.'</center></td>
         </tr>
         <tr>
         <th colspan="2">Further information</th>
         </tr>
         <tr height="150">
         <td colspan="2" valign="middle" align="center">
         <table width="200">
         <tr>
         <td>
         <b>Class:</b> '
.stripslashes($r['className']).'<br />
         <b>Director:</b> <a href="viewuser.php?u='
.$r['userid'].'">'.stripslashes($r['username']).'</a><br /><br />
         <b>Todays profit:</b> Â£'
.number_format($r['busProfit']).'<br />
         <b>Yesterdays profit:</b> Â£'
.number_format($r['busYProfit']).'<br />
         <b>Todays customers:</b> '
.number_format($r['busCust']).'<br />
         <b>Yesterdays customers:</b> '
.number_format($r['busYCust']).'<br />
         </td>
         </tr>
         </table>
         </td>
         </tr>
         <tr>
         <th colspan="2">'
.stripslashes($r['busName']).' members</th>
         </tr>
         <tr>
         <td width="50%"><b>Name:</b> <a href="viewuser.php?u='
.$r['userid'].'">'.stripslashes($r['username']).'</a></td>
         <td width="50%"><b>Rank:</b> Director (None)</td>
         </tr>'
;
         
$fetch_members $db->query(sprintf("SELECT * FROM `businesses_members` LEFT JOIN `users` ON (`userid` = `bmembMember`) LEFT JOIN `businesses_ranks` ON (`rankId` = `bmembRank`) WHERE `bmembBusiness` = '%u'"$_GET['id']));
         while(
$fm $db->fetch_row($fetch_members))
                                                       {
         echo 
'
         <tr>
         <td width="50%"><b>Name:</b> <a href="viewuser.php?u='
.$fm['userid'].'">'.stripslashes($fm['username']).'</a></td>
         <td width="50%"><b>Rank:</b> '
.stripslashes($fm['rankName']).' (£'.number_format($fm['bmembCash']).')</td>
         </tr>'
;
                                                        }
         echo 
'</table>
         <hr width="400"><br/><a href="business_view.php?page=sendapp&id='
.$_GET['id'].'">Send application</a><br /><a href="business_view.php?page=rob&id='.$_GET['id'].'">Attempt Robbery</a><br />';
                                                        }
                                                        }
   else
                                                        {
         echo 
'You did not select a company to view.';
                                                        }
                                                        }
   function 
send_application()
                                                        {
   global 
$ir,$db;
                                 
$_GET['id'] = abs(@intval($_GET['id']));
   if(
$ir['job'])
                                                        {
        echo 
'You Have A Job';
        exit;
                                                        }

        
$check_bus $db->query(sprintf("SELECT * FROM `businesses` WHERE (`busId` = '%u')"$_GET['id']));
        
$check_app $db->query(sprintf("SELECT * FROM `businesses_apps` WHERE (`appMember` = '%u') AND (`appBusiness` = '%d')"$ir['userid'], $_GET['id']));
        
$check $db->query(sprintf("SELECT * FROM `businesses` WHERE (`busDirector` = '%u')"$ir['userid']));
        
$check_member $db->query(sprintf("SELECT * FROM `businesses_members` WHERE (`bmembMember` = '%u')"$ir['userid']));
        if(!
$db->num_rows($check_bus))
                                                         {
        echo 
'You cannot send an application to a non-existant company.';
                                                         }
   else if(
$db->num_rows($check) || $db->num_rows($check_member))
                                                         {
        echo 
'<font color=red><blink>You are part of a company right now, leave before sending an application to a new one.</blink></font>';
                                                         }
   else if(
$db->num_rows($check_app))
                                                         {
        echo 
'You have a sent application to this company right now, wait for a responce.';
                                                         }
   else if(!
$_GET['id'])
                                                         {
        echo 
'You did not choose a company to send an application to.';
                                                         }
   else if(
$_POST['application'])
                                                         {
        
$app str_replace(array("\n"), array("<br />"), strip_tags($_POST['application']));
        
$string_app mysql_real_escape_string($app);
        
$db->query(sprintf("INSERT INTO `businesses_apps` (`appId`, `appMember`, `appBusiness`, `appText`, `appTime`) VALUES ('NULL','%d', '%u', '%s', '%d')"$ir['userid'], $_GET['id'], $string_apptime()));
        echo 
'Your application was sent to the selected company, a responce will be given from the director soon.';
                                                         }
   else
                                                         {
        
$r $db->fetch_row($check_bus);
        echo 
'<form action="business_view.php?page=sendapp&id='.$_GET['id'].'" method="post">
        <p align="center">
        <b>Enter an application below to send a request to the director of '
.stripslashes($r['busName']).'.</b><br />
        You can send one application at a time, wait for the result of that application before sending another.
        If the company director is not active, it might take a while for the application to be managed,
        So it could be worth speaking with the director before submitting a new application to the company.
        Entering a detailed application will increase the chance of having it accepted, but this is no guarantee.
        Your working stats will also be sent to the director of the company with the application to help them decide.<br /><br />

        Your application:<br />
        <textarea type="text" name="application" s="40" rows="10" cols="70" maxlength="255"></textarea><br />
        <input type="submit" value="Submit application" /></p>
        </form>'
;
                                                          }
                                                          }

function 
rob_business()
{
global 
$ir,$db,$h,$userid;
                                   
$_GET['id'] = abs(@intval($_GET['id']));
 if(
$_GET['id'])
{
$fetch_business $db->query(sprintf("SELECT * FROM `businesses` LEFT JOIN `businesses_classes` ON (`classId` = `busClass`) LEFT JOIN `users` ON (`userid` = `busDirector`) WHERE (`busId` = '%u')"$_GET['id']));
if(!
$db->num_rows($fetch_business))
                                                        {
         echo 
'You cannot rob a company that doesn\'t exist.';
                                                        }
   else
                                                        {
$r $db->fetch_row($fetch_business);


if(
$ir['rob'] < 1)
{
echo 
'You cannot attempt to rob a company more than once a day!';
$h->endpage();
exit;
}

if(
$ir['userid'] == $r['busDirector'])
{
echo 
'Why would you attempt to rob your own company?';
$h->endpage();
exit;
}

else
{

if(
$ir['robskill'] <= $r['busCash'])
{
print 
"While attempting to break into the business, greedy with plans of large bucks.  You fail to notice the police car driving by.  Just as you crack the lock and begin to head inside you are knocked over the head.  You wake up in jail with a raging headache and the discovery YOU WERE CAUGHT";
event_add($_GET['id'],"<a href='viewuser.php?u=$userid'>{$ir['username']}</a> Attempted to Rob your Business but was caught.");
$jailtime=mt_rand(10,40);
$query sprintf('UPDATE users SET jail = jail +%u, jail_reason = "Failed to Rob %s.", rob = 0 WHERE userid = %u'$jailtime$r['busName'], $userid);
$db->query($query);
$db->query("UPDATE businesses SET bussecurity = bussecurity + 1 WHERE busId = {$_GET['id']}");
$db->query("UPDATE userstats SET robskill = robskill - 1 WHERE userid = $userid");
}

else if(
$ir['robskill'] > $r['busCash'])
{
$rando mt_rand(10,25);
$cash round($r['busCash']/$rando);

print 
"After scoping out the latest company for a few days, you decide now is your chance to do some damage.  You sneak up to the backdoor after dark and jiggle the lock.  With a bit of luck on your side, the door is unlocked.  You sneak in flashlight in hand and head for the vault.  Noticing the lack of security in this place you are hopeful someone hasn't beat you to the punch.  As you enter the dark office where the stash of cash is located it would appear luck is on your side twice!  The owner left the key to the safe on his desk!  You quickly grab the cash and bolt.  You earned yourself a nice smooth $cash cash.";
$db->query("UPDATE users SET meony = money + $cash, rob = 0 WHERE userid = $userid");
$db->query("UPDATE userstats SET robskill = robskill + 1 WHERE userid = $userid");
$db->query("UPDATE businesses SET busCash = busCash - $cash, bussecurity = bussecurity - 1 WHERE busId = {$_GET['id']}");

}
}
}
}

}
$h->endpage();
?>

JoshuaDams

  • Active Member
  • **
  • Reputation Power: 129
  • JoshuaDams is working their way up.JoshuaDams is working their way up.JoshuaDams is working their way up.
  • Offline Offline
  • Posts: 240
    • MSN Messenger - immortalthug4ever@hotmail.com
    • View Profile
    • WWW
Re: The Ultimate Business Mod.
« Reply #4 on: December 08, 2009, 07:26:57 PM »
business_manage.php
Code: [Select]
<?php
                               
include_once (DIRNAME(__FILE__). '/globals.php');
    global 
$db,$ir;
          echo 
'<p class="heading">Manage Company</p>';
          
$fetch_business $db->query(sprintf("SELECT * FROM `businesses` LEFT JOIN `businesses_classes` ON (`classId` = `busClass`) WHERE (`busDirector` = '%u')"$ir['userid']));
    if(!
$db->num_rows($fetch_business))
                                                     {
          echo 
'You do not own a Company right now!';
          
$h->endpage();
          exit;
                                                     }
    else
                                                     {
          
$inf $db->fetch_row($fetch_business);
                                                     }
    switch (
$_GET['p'])
                                                     {
          case 
'new_name'new_business_name(); break;
          case 
'new_banner'new_business_banner(); break;
          case 
'new_rank'edit_member_rank(); break;
          case 
'new_salary'edit_member_salary(); break;
          case 
'view_vault'view_vault(); break;
          case 
'donate_cash'donate_cash(); break;
          case 
'withdraw_mula'withdraw_mula(); break;
          case 
'debt'sort_debt(); break;
          case 
'bankrupt'bankrupt_business(); break;
          case 
'credit_member'credit_member(); break;
          case 
'view_apps'manage_applications(); break;
          case 
'kick_out'kick_member(); break;
          case 
'upgrade'upgrade_business(); break;
          case 
'change_desc'change_description(); break;
          case 
'secupgrade'secure_business(); break;
          default: 
business_index(); break;
                                                      }
    function 
business_index()
                                                      {
    global 
$ir$inf$db;
  
    if(
$inf['busDebt'])
                                                      {
          echo 
'This Company is in debt of \$'.number_format($inf['busDebt']).' right now. Click <a href="business_manage.php?p=debt">here</a> to sort it out.<br />
          To bankrupt and close down the Company, click <a href="business_manage.php?p=bankrupt">here</a> to complete proceedings.'
;
                                                      }
    else
                                                      {

          echo 
'
          <table width="300" bgcolor="black" border="2">
        <tr>
          <td colspan="100%"><center>
          <b>Manage Your Company:</b></center></td></tr>
          <tr><td><a href="business_manage.php?p=new_name">Edit Company name</a></td>
          <td><a href="business_manage.php?p=change_desc">Edit description</a></td></tr>
          <tr><td><a href="business_manage.php?p=new_banner">Change company banner</a></td>
         <td><a href="business_manage.php?p=credit_member">Credit cash to employee</a></td></tr>
       <td><a href="business_manage.php?p=view_apps">Manage applications</a></td>
       <td><a href="business_manage.php?p=new_rank">Edit employees rank</a></td></tr>
        <td><a href="business_manage.php?p=upgrade">Upgrade The Company size</a></td>
       <td><a href="business_manage.php?p=new_salary">Change employee salary</a></td></tr>
        <td><a href="business_manage.php?p=kick_out">Kick employee out</a><br /></td>
        <td><a href="business_manage.php?p=view_vault">View company vault</a></td></tr>
        <td><a href="business_manage.php?p=bankrupt">Bankrupt the Company</a></td>
        <td><a href="business_manage.php?p=secupgrade">Hire Security</a>
                 </td>
          </tr>
          </table>'
;
                                                       }
                                                       }
    function 
new_business_name()
                                                       {
    global 
$ir$inf$db;
                               
$_POST['name'] = $db->escape(stripslashes($_POST['name']));
    if(!
$_POST['name'])
                                                       {
          echo 
'<form action="business_manage.php?p=new_name" method="post">
          <p align="center">
          <b>You are changing the Company name of the '
.stripslashes($inf['busName']).' Company.</b><br />
          Please enter a new name in the input box below and click \'Change name\' to submit the new name.<br /><br />
          <input type="text" name="name" /><br /><br />
          <input type="submit" value="Change name" />
          </p>
          </form>'
;
                                                        }
    else
                                                        {
          
$check $db->query(sprintf("SELECT * FROM `businesses` WHERE (`busName` = '%s')"$_POST['name']));
          if(!
$db->num_rows($check))
                                                        {
          
$db->query(sprintf("UPDATE `businesses` SET `busName` = '%s' WHERE `busId` = '%u'"$_POST['name'], $inf['busId']));
          echo 
'The Company name was changed to '.$_POST['name'].'!';
          
business_alert($inf['busId'], "The Company name was changed to ".$_POST['name'].".");
                                                         }
    else
                                                         {
          echo 
'Sorry this Company name is in use at this time.';
                                                         }
                                                         }
                                                         }
    function 
new_business_banner()
                                                         {
    global 
$ir$inf$db;
    
    if(!
$_POST['banner'])
                                                         {
          echo 
'<form action="business_manage.php?p=new_banner" method="post">
          <p align="center">
          <b>You are changing the banner of the '
.stripslashes($inf['busName']).' Company.</b><br />
          Please enter a new banner image location in the input box below and click \'Change banner\' to submit the new image.<br /><br />
          <b>Current image:</b><br />'
;
        
   if(
$inf['busImage'])
                                                         {
          echo 
'<img src="'.stripslashes($inf['busImage']).'" alt="'.stripslashes($inf['busName']).' banner" width="400" height="100" />';
                                                         }
   else
                                                         {
          echo 
'<img src="dimg.jpg"/>';
                                                         }
          echo 
'<br /><br />
          New image: <input type="text" name="banner" size="50" /><br /><br />
          <input type="submit" value="Change banner" />
          </p>
          </form>'
;
                                                         }
   else
                                                         {
          
$db->query(sprintf("UPDATE `businesses` SET `busImage` = '%s' WHERE `busId` = '%u'"stripslashes($_POST['banner']), $inf['busId']));
          echo 
'The Company banner was updated.';
          
business_alert($inf['busId'], "The Company banner has been updated.");
                                                         }
                                                         }
   function 
edit_member_rank()
                                                         {
   global 
$ir$inf$db;

                              
$_POST['member'] = abs(@intval($_POST['member']));   
                                
$_POST['rank'] = abs(@intval($_POST['rank']));
   if(!
$_POST['member'] || !$_POST['rank'])
                                                         {
          echo 
'<form action="business_manage.php?p=new_rank" method="post">
          <p align="center">
          <b>Set the Company rank:</b><br /><br />
          Company employee: <select name="member">
          <option value="0">None</option>'
;
          
$select_members $db->query(sprintf("SELECT * FROM `businesses_members` LEFT JOIN `users` ON (`userid` = `bmembMember`) WHERE (`bmembBusiness` = '%u') ORDER BY `bmembId` ASC"$inf['busId']));
          while(
$sm $db->fetch_row($select_members))
                                                         {
          echo 
'<option value="'.$sm['userid'].'">'.stripslashes($sm['username']).'</option>';
                                                         }
          echo 
'</select><br />
          Company rank: <select name="rank">
          <option value="0">None</option>'
;
          
$select_ranks $db->query(sprintf("SELECT * FROM `businesses_ranks` WHERE (`rankClass` = '%u') ORDER BY `rankId` ASC"$inf['classId']));
          while(
$sr $db->fetch_row($select_ranks))
                                                         {
          echo 
'<option value="'.$sr['rankId'].'">'.stripslashes($sr['rankName']).'</option>';
                                                         }
          echo 
'</select><br /><br />
          <input type="submit" value="Change rank" /></p>
          </form>'
;
                                                         }
   else
                                                         {
          
$select_member $db->query(sprintf("SELECT * FROM `businesses_members` WHERE (`bmembMember` = '%u') AND (`bmembBusiness` = '%u')"$_POST['member'], $inf['busId']));
          
   if(!
$db->num_rows($select_member))
                                                         {
           echo 
'You cannot edit the rank of this employee.';
                                                         }
   else
                                                         {
           
$select_cash $db->query(sprintf("SELECT * FROM `businesses_ranks` WHERE (`rankId` = '%u')"$_POST['rank']));
           
$realname $db->query(sprintf("SELECT * FROM `users` WHERE (`userid` = '%u')"$_POST['member']));
           
$sc $db->fetch_row($select_cash);
           
$thename $db->fetch_row($realname);
           
$realrank $db->query(sprintf("SELECT * FROM `businesses_ranks` WHERE (`rankId` = '%u')"$_POST['rank']));
           
$rname $db->fetch_row($realrank);
           echo 
'This member\'s rank was updated.';
           
$db->query(sprintf("UPDATE `businesses_members` SET `bmembRank` = '%d', `bmembCash` = '%d' WHERE (`bmembMember` = '%u')"$_POST['rank'], $sc['rankCash'], $_POST['member']));
           
business_alert($inf['busId'], " ".$thename['username']."\'s rank was changed to ".$rname['rankName'].".");
                                                          }
                                                          }
                                                          }
   function 
edit_member_salary()
                                                          {
   global 
$ir$inf$db;
                               
$_POST['member'] = abs(@intval($_POST['member']));
                               
$_POST['salary'] = abs(@intval($_POST['salary']));

   if(!
$_POST['member'] || !$_POST['salary'])
                                                          {
           echo 
'<form action="business_manage.php?p=new_salary" method="post">
           <p align="center">
           <b>Set the new Company salary:</b><br /><br />
           Company employee: <select name="member">
           <option value="0">None</option>'
;
           
$select_members $db->query(sprintf("SELECT * FROM `businesses_members` LEFT JOIN `users` ON (`userid` = `bmembMember`) WHERE (`bmembBusiness` = '%u') ORDER BY `bmembId` ASC"$inf['busId']));
           while(
$sm $db->fetch_row($select_members))
                                                           {
           echo 
'<option value="'.$sm['userid'].'">'.stripslashes($sm['username']).'</option>';
                                                           }
           echo 
'</select><br />
           Salary amount: <input type="text" name="salary" size="8" maxlength="6" /><br /><br />
           <input type="submit" value="Change salary" /></p>
           </form>'
;
                                                            }
   else
                                                            {
           
$select_member $db->query(sprintf("SELECT * FROM `businesses_members` WHERE (`bmembMember` = %u) AND (`bmembBusiness` = %u)"$_POST['member'], $inf['busId']));
      
   if(!
$db->num_rows($select_member))
                                                            {
            echo 
'You cannot edit the salary of this employee.';
                                                            }
   else
                                                            { 
            echo 
'This employee\'s salary was updated to Â£'.number_format($_POST['salary']).'.';
            
$realname $db->query(sprintf("SELECT * FROM `users` WHERE (`userid` = '%u')"$_POST['member']));
            
$thename $db->fetch_row($realname);
            
$db->query(sprintf("UPDATE `businesses_members` SET `bmembCash` = '%d' WHERE (`bmembMember` = '%u')"$_POST['salary'], $_POST['member']));
            
business_alert($inf['busId'], "".$thename['username']."\'s salary was changed to ".number_format($_POST['salary']).".");
                                                             }
                                                             }
                                                             }
   function 
view_vault()
                                                             {
   global 
$ir$inf$db;
            echo 
'<form action="business_manage.php?p=donate_cash" method="post">
            Your Company has '
.number_format($inf['busCash']).' secured in it\'s vault.<br /><br />
            <b>Donate cash:</b><br /><br />
            Cash amount: <input type="text" name="cash" /><br /><br />
            <input type="submit" value="Donate cash"></form>
            <form action="business_manage.php?p=withdraw_mula" method="post">
            <br/><b>Withdraw cash:</b><br /><br />
            Cash amount: <input type="text" name="mula" /><br /><br />
            <input type="submit" value="Withdraw cash">'
;
                                                              }
   function 
sort_debt()
                                                              {
   global 
$ir$inf$db;
                                       
$_POST['cash'] = abs(@intval($_POST['cash']));
   if(
$_POST['cash'] > 0)
                                                              {
   if(
$_POST['cash'] > $ir['money'])
                                                              {
            echo 
'You do not have enough cash to sort out that amount of debt.';
                                                              }
   else if(
$_POST['cash'] > $inf['busDebt'])
                                                              {
            echo 
'The Company does not owe that much cash in debt.';
                                                              }
   else
                                                              {
            
$db->query(sprintf("UPDATE `users` SET `money` = `money` - '%d' WHERE `userid` = '%u'"$_POST['cash'], $ir['userid']));
            
$db->query(sprintf("UPDATE `businesses` SET `busDebt` = `busDebt` - '%d' WHERE `busId` = '%u'"$_POST['cash'], $inf['busId']));
            echo 
'You have cleared up '.number_format($_POST['cash']).' of the Company debt.';
            
business_alert($inf['busId'], "".$ir['username']." paid ".number_format($_POST['cash'])." of the Company debt.");
                                                               }
                                                               }
   else
                                                               {
            echo 
'<form action="business_manage.php?p=debt" method="post">
            Your Company has Â£'
.number_format($inf['busDebt']).' of debt.<br /><br />
            <b>Enter amount:</b><br /><br />
            Cash: <input type="text" name="cash" /><br /><br />
            <input type="submit" value="Submit" />
            </form>'
;
                                                               }
                                                               }
   function 
donate_cash()
                                                               {
   global 
$ir$inf$db;
                                        
$_POST['cash'] = abs(@intval($_POST['cash']));

   if(
$_POST['cash'] > 0)
                                                               {
   if(@
intval($_POST['cash'] > $ir['money']))
                                                               {
            echo 
'You do not have enough cash to donate this much to the Company.';
                                                               }
   else
                                                               {
            
$db->query(sprintf("UPDATE `users` SET `money` = `money` - '%d' WHERE `userid` = '%u'"$_POST['cash'], $ir['userid']));
            
$db->query(sprintf("UPDATE `businesses` SET `busCash` = `busCash` + '%d' WHERE `busId` = '%u'"$_POST['cash'], $inf['busId']));
            echo 
'You have donated '.number_format($_POST['cash']).' to the Company.';
            
business_alert($inf['busId'], "".$ir['username']." donated ".number_format($_POST['cash'])." to the Company.");
                                                                }
                                                                }
   else
                                                                {
            echo 
'You missed one or more of the required fields.';
                                                                }
                                                                }
   function 
withdraw_mula()
                                                                {
   global 
$ir$inf$userid$db;

                                            
$_POST['mula']=abs(@intval($_POST['mula']));
   if(
$_POST['mula'] > 0)
                                                                {
   if(
$_POST['mula'] > $inf['busCash'])
                                                                {
            echo 
'You do not have enough cash to withdraw this much from the Company.';
                                                                }
else
                                                                {
            
$db->query(sprintf("UPDATE `users` SET `money` = `money` + '%d' WHERE `userid` = '%u'"$_POST['mula'], $ir['userid']));
            
$db->query(sprintf("UPDATE `businesses` SET `busCash` = `busCash` - '%d' WHERE `busId` = '%u'"$_POST['mula'], $inf['busId']));
            echo 
'You have withdrawn '.number_format($_POST['mula']).' from the Company.';
            
business_alert($inf['busId'], "".$ir['username']." withdrawn ".number_format($_POST['mula'])." from the Company.");
                                                                 }
                                                                 }
   else
                                                                 {
            echo 
'You missed one or more of the required fields.';
                                                                 }
                                                                 }

   function 
kick_member()
                                                                 {
   global 
$ir$inf$db;
             
   if(!isset(
$_POST['member']))
                                                                 {
            echo 
'Please select a member to kick out of the Company:<br />
            <form action="business_manage.php?p=kick_out" method="post">
            Company employee: <select name="member">
            <option value="0">None</option>'
;
            
$select_members $db->query(sprintf("SELECT * FROM `businesses_members` LEFT JOIN `users` ON (`userid` = `bmembMember`) WHERE (`bmembBusiness` = '%u') ORDER BY `bmembId` ASC"$inf['busId']));
            while(
$sm $db->fetch_row($select_members))
                                                                 {
            echo 
'<option value="'.$sm['userid'].'">'.stripslashes($sm['username']).'</option>';
                                                                 }
            echo 
'</select><br /><br />
            <input type="submit" value="Kick from company" />
            </form>'
;
                                                                 }
   else
                          
$_POST['member'] = abs(@intval($_POST['member']));
                                       {
            
$db->query(sprintf("DELETE FROM `businesses_members` WHERE `bmembMember` = '%u'"$_POST['member']));
            
$realname $db->query(sprintf("SELECT * FROM `users` WHERE (`userid` = '%u')"$_POST['member']));
            
$thename $db->fetch_row($realname);
            
$db->query(sprintf("UPDATE `users` SET `business` = '0' WHERE `userid` = '%u'"$_POST['member']));
            echo 
'This member has been kicked out of the Company.';
            
business_alert($inf['busId'], " ".$thename['username']." was kicked out of the Company.");
                                                                  }
                                                                  }
   function 
bankrupt_business()
                                                                  {
   global 
$ir$inf$db;
   
   if(!
$_GET['confirm'])
                                                                  {
            echo 
'You are about to bankrupt the '.stripslashes($inf['busName']).' Company. Please confirm this action.<br />
            Once this has been confirmed there is no chance to go back.<br /><br />
            <a href="business_manage.php?p=bankrupt&confirm=1">Bankrupt the Company</a>'
;
                                                                  }
   else
                                                                  {
            
$send_event $db->query(sprintf("SELECT `bmembMember` FROM businesses_members WHERE `bmembBusiness` = '%u' ORDER BY `bmembId` DESC"$bs['busId']));
            while(
$se $db->fetch_row($send_event))
                                                                  {
            
$text "The director has chosen to bankrupt the {$inf['busName']} Company\, all members have been made redundent.";
            
insert_event($se['bmembMember'], $text);
                                                                  }
            
$db->query(sprintf("DELETE FROM `businesses_members` WHERE (`bmembBusiness` = '%u')"$inf['busId']));
            
$db->query(sprintf("DELETE FROM `businesses` WHERE (`busId` = '%u')"$inf['busId']));
            
$db->query(sprintf("UPDATE `users` SET `business` = '0' WHERE `business` = '%u'"$inf['busId']));
            echo 
'You have decided to bankrupt the Company, all members have been made redundent.';
                                                                  }
                                                                  }
   function 
credit_member()
                                                                  {
   global 
$ir$inf$db;
                                           
$_POST['cash'] = abs(@intval($_POST['cash']));
                                          
$_POST['member'] = abs(@intval($_POST['cash']));
   if(
$_POST['cash'] AND $_POST['member'])
                                                                  {
   if(
$_POST['cash'] > $inf['busCash'])
                                                                  {
            echo 
'You cannot credit more than the Company has in it\'s vault.';
                                                                  }
   else
                                                                  {
            
$db->query(sprintf("UPDATE `users` SET `money` = `money` + '%d' WHERE `userid` = '%u'"$_POST['cash'], $_POST['member']));
            
$db->query(sprintf("UPDATE `businesses` SET `busCash` = `busCash` - '%d' WHERE `busId` = '%u'"$_POST['cash'], $inf['busId']));
            
$realname $db->query(sprintf("SELECT * FROM `users` WHERE (`userid` = '%u')"$_POST['member']));
            
$thename $db->fetch_row($realname);
            echo 
'You gave '.number_format($_POST['cash']).' to this member from the vault.';
            
business_alert($inf['busId'], " ".$thename['username']." was credited ".number_format($_POST['cash'])." from the Company.");
                                                                   }
                                                                   }
   else
                                                                   {
            echo 
'<form action="business_manage.php?p=credit_member" method="post">
            <p align="center">
            Your Company vault contains '
.number_format($inf['busCash']).' at this time, which can be credited to a member.<br />
            Select a member from the box below and enter an amount of cash to give to them.<br /><br />
            Cash amount: <input type="text" name="cash" /><br />
            Company employee: <select name="member">
            <option value="0">None</option>
            <option value="'
.$ir['userid'].'">'.stripslashes($ir['username']).'</option>';
            
$select_members $db->query(sprintf("SELECT * FROM `businesses_members` LEFT JOIN `users` ON (`userid` = `bmembMember`) WHERE (`bmembBusiness` = '%u') ORDER BY `bmembId` ASC"$inf['busId']));
            while(
$sm $db->fetch_row($select_members))
                                                                    {
            echo 
'<option value="'.$sm['userid'].'">'.stripslashes($sm['username']).'</option>';
                                                                    }
            echo 
'</select><br /><br />
            <input type="submit" value="Credit cash" />
            </p>
            </form>'
;
                                                                    }
                                                                    }
   function 
manage_applications()
                                                                    {
   global 
$ir$inf$db;
                                              
$_GET['id'] = abs(@intval($_GET['id']));
                                          
$_POST['member'] = abs(@intval($_POST['member'])); 
   if(!isset(
$_GET['a']))
                                                                    {
           
$fetch_apps $db->query(sprintf("SELECT * FROM `businesses_apps` LEFT JOIN `users` ON `userid` = `appMember` WHERE `appBusiness` = '%u'"$inf['busId']));
           echo 
'<table width="600" class="table">
           <tr>
           <th width="15%">Member</th>
           <th width="50%">Application</th>
           <th width="15%">Time</th>
           <th width="20%">Manage</th>
           </tr>'
;
           while(
$r $db->fetch_row($fetch_apps))
                                                                    {
           echo 
'
           <tr>
           <td><a href="viewuser.php?u='
.$r['userid'].'">'.stripslashes($r['username']).'</a></td>
           <td>'
.stripslashes(htmlentities($r['appText'])).'</td>
           <td>'
.date('d-m-Y, g:i:s A'$r['appTime']).'</td>
           <td><a href="business_manage.php?p=view_apps&a=accept&id='
.$r['appId'].'"><small>Accept</small></a><small>-</small>  <a href="business_manage.php?p=view_apps&a=decline&id='.$r['appId'].'"><small>Decline</small></a></td>
           </tr>'
;
                                                                    }
           echo 
'</table>';
                                                                    }
           else if(
$_GET['a'] == 'accept' AND $_GET['id'])
                                                                    {
          
$fetch_app $db->query(sprintf("SELECT * FROM `businesses_apps` LEFT JOIN `users` ON `userid` = `appMember` WHERE `appId` = '%u'"$_GET['id']));
       
   if(
$db->num_rows($fetch_app))
                                                                    {
          
$it $db->fetch_row($fetch_app);
          
$check $db->query(sprintf("SELECT * FROM `businesses_members` WHERE (`bmembMember` = '%u')"$it['appMember']));
          
   if(!
$db->num_rows($check))
                                                                    {
          
$rows $db->query(sprintf("SELECT * FROM `businesses_members` WHERE (`bmembBusiness` = '%u')"$inf['busId']));
          
   if(
$db->num_rows($rows) < $inf['busEmployees'])
                                                                    {
          
$fetch_rank $db->query(sprintf("SELECT * FROM `businesses_ranks` WHERE (`rankClass` = '%u') ORDER BY `rankCash` ASC LIMIT 1"$inf['classId']));
          
$fr $db->fetch_row($fetch_rank);
          
$realname $db->query(sprintf("SELECT * FROM `users` WHERE (`userid` = '%u')"$_POST['member']));
          
$thename $db->fetch_row($realname);
          
business_alert($inf['busId'], " A new employee has been accepted into the Company.");
          
$db->query(sprintf("INSERT INTO `businesses_members` (`bmembId`, `bmembMember`, `bmembBusiness`, `bmembCash`, `bmembRank`) VALUES ('NULL', '%u', '%d', '%d', '%d')"$it['appMember'], $inf['busId'], $fr['rankCash'], $fr['rankId']));
          
$db->query(sprintf("UPDATE `users` SET business='{$inf['busId']}' WHERE `userid` = '%u'"$it['appMember']));
          
$db->query(sprintf("DELETE FROM `businesses_apps` WHERE `appId` = '%u'"$_GET['id']));
          echo 
'The selected application has been accepted.';
                                                                     }
   else
                                                                     {
          echo 
'Your Company cannot hold more members at this time.';
                                                                     }
                                                                     }
   else
                                                                     {
          echo 
'This member is part of a Company at this time, the application could not be accepted.';
          
$db->query(sprintf("DELETE FROM `businesses_apps` WHERE `appId` = '%u'"$_GET['id']));
                                                                     }
                                                                     }
   else
                                                                     {
          echo 
'The selected application no longer exists.';
                                                                     }
                                                                     }
   else if(
$_GET['a'] == 'decline' AND $_GET['id'])
                                                                     {
         
$fetch_app $db->query(sprintf("SELECT * FROM `businesses_apps` WHERE `appId` = '%u'"$_GET['id']));
       
   if(
$db->num_rows($fetch_app))
                                                                     {
          echo 
'The selected application was declined, It has been removed from the log.';
          
$db->query(sprintf("DELETE FROM `businesses_apps` WHERE `appId` = '%u'"$_GET['id']));
                                                                     }
   else
                                                                     {
          echo 
'The selected application no longer exists.';
                                                                     }
                                                                     }
   else
                                                                     {
          echo 
'You did not select an application to manage, go back and select one!';
                                                                     }
                                                                     }


  function 
upgrade_business()
                                                                     {
   global 
$ir$inf$db;

   if(
$inf['busEmployees'] >= 50
                                                                     {
          die(
'This company is already fully upgraded to 50 employees.');
                                                                     }
   if(!
$_GET['confirm'])
                                                                     {
          
$price_upgrade = (($inf['busEmployees'])*1500000);
          echo 
'You currently have '.$inf['busEmployees'].' employee spots.<br/><br/>You are about to upgrade the '.stripslashes($inf['busName']).' Company at a cost of '.number_format($price_upgrade).' for an additional 5 slots. Please confirm this action.<br />
          Once this has been confirmed there is no chance to go back.<br /><br />
          <a href="business_manage.php?p=upgrade&confirm=1">Upgrade the Company</a>'
;
                                                                      }
   else
                                                                      {
          
$price_upgrade = (($inf['busEmployees'])*1500000);
      
   if (
$inf['busCash'] < $price_upgrade
                                                                      {
          die(
'You do not have enough money in the vault.');
                                                                      }
   else if(
$inf['busEmployees'] >= 50)  
                                                                      {
          die(
'this company is already fully upgraded to 50 employees.');    
                                                                      }
   else
                                                                      {
          
$db->query(sprintf("UPDATE `businesses` SET `busEmployees` = busEmployees+5, `busCash` = busCash - ".$price_upgrade." WHERE `busDirector` = ".$ir['userid'].""));
          
business_alert($inf['busId'], "The Director has upgraded the Company for 5 extra members.");

          echo 
'You have decided to upgrade the Company, you can now employee an additional 5 members.';
                                                                      }
                                                                      } 
                                                                      }
   function 
change_description()
                                                                      {
   global 
$ir$inf$db;
   
   if(!
mysql_real_escape_string(htmlentities($_POST['desc'])))
                                                                      {
          echo 
'<form action="business_manage.php?p=change_desc" method="post">
          <p align="center">
          <b>You are changing the Company description of the '
.stripslashes($inf['busName']).' Company.</b><br />
          Please enter a description in the input box below and click \'Change description\' to submit the new description. <br/>Maximum characters is set at 50!!<br /><br />
          <textarea rows="10" cols="50" name="desc">'
.($inf['busDesc']).'</textarea><br/>
          <input type="submit" value="Change description" />
          </p>
          </form>'
;
                                                                       }
   else
                                                                       {
          
$db->query(sprintf("UPDATE `businesses` SET `busDesc` = '%s' WHERE `busId` = '%u'"stripslashes($_POST['desc']), $inf['busId']));
          echo 
'The Company description was changed to:<br/> '.stripslashes($_POST['desc']).'!';
                                                                        }
                                                                        }

 function 
secure_business()
                                                                     {
   global 
$ir$inf$db;

   
   if(!
$_GET['confirm'])
                                                                     {
          
$price_upgrade = (($inf['busEmployees'])*200000);
          echo 
'You currently have '.$inf['bussecurity'].' security guards.<br/><br/>You are about to upgrade the '.stripslashes($inf['busName']).' Company at a cost of '.number_format($price_upgrade).' for one additional guard. Please confirm this action.<br />
          Once this has been confirmed there is no chance to go back.<br /><br />
          <a href="business_manage.php?p=secupgrade&confirm=1">Purchase Guard</a>'
;
                                                                      }
   else
                                                                      {
          
$price_upgrade = (($inf['busEmployees'])*200000);
      
   if (
$inf['busCash'] < $price_upgrade
                                                                      {
          die(
'You do not have enough money in the vault.');
                                                                      }
   
   else
                                                                      {
          
$db->query(sprintf("UPDATE `businesses` SET `bussecurity` = bussecurity+1, `busCash` = busCash - ".$price_upgrade." WHERE `busDirector` = ".$ir['userid'].""));


    echo 
'You have decided to upgrade the Company, you now have one additional guard.';
          
business_alert($inf['busId'], "The Director has upgraded the Company and added an Extra security guard.");
                                                                      }
                                                                      } 
                                                                   }     
      
$h->endpage();
?>

« Last Edit: December 09, 2009, 07:25:27 PM by Immortalthug »
Logged

JoshuaDams

  • Active Member
  • **
  • Reputation Power: 129
  • JoshuaDams is working their way up.JoshuaDams is working their way up.JoshuaDams is working their way up.
  • Offline Offline
  • Posts: 240
    • MSN Messenger - immortalthug4ever@hotmail.com
    • View Profile
    • WWW
Re: The Ultimate Business Mod.
« Reply #5 on: December 08, 2009, 07:28:05 PM »
***Merged with the above****
« Last Edit: December 09, 2009, 12:26:46 PM by Immortalthug »
Logged

JoshuaDams

  • Active Member
  • **
  • Reputation Power: 129
  • JoshuaDams is working their way up.JoshuaDams is working their way up.JoshuaDams is working their way up.
  • Offline Offline
  • Posts: 240
    • MSN Messenger - immortalthug4ever@hotmail.com
    • View Profile
    • WWW
Re: The Ultimate Business Mod.
« Reply #6 on: December 08, 2009, 07:28:57 PM »
Merged with the above********
« Last Edit: December 09, 2009, 12:26:11 PM by Immortalthug »
Logged

JoshuaDams

  • Active Member
  • **
  • Reputation Power: 129
  • JoshuaDams is working their way up.JoshuaDams is working their way up.JoshuaDams is working their way up.
  • Offline Offline
  • Posts: 240
    • MSN Messenger - immortalthug4ever@hotmail.com
    • View Profile
    • WWW
Re: The Ultimate Business Mod.
« Reply #7 on: December 08, 2009, 07:30:39 PM »
companyspecials.php
Code: [Select]
<?php
             
include_once (DIRNAME(__FILE__) . '/globals.php');
                      

print 
"<br/><br/><b>Specials unlocked:</b><b/><br/>You have {$ir['comppoints']} company points, What would you like to spend them on?<br/><br/>
       <form action='compspecials.php' method='post'>
       <table width=75% cellspacing=1 class='table'><tr style='background:gray'><th>Reward</th><th>Cost</th><th>Take</th</tr>"
;
       global 
$ir,$db;
       
$com $db->query("SELECT bmembBusiness FROM businesses_members WHERE bmembMember='{$ir['userid']}'");
       
$cc=$db->fetch_row($com);
       
$clas $db->query("SELECT * FROM businesses WHERE busId='{$cc['bmembBusiness']}'");
       
$cs=$db->fetch_row($clas);
       
$clas $db->query("SELECT * FROM businesses WHERE busDirector='1'");
       
$cs=$db->fetch_row($clas);

       
$js=$db->query("SELECT * FROM compspecials WHERE csJOB='{$cs['busClass']}'");
if(
$db->num_rows($js) == 0)
                                           {
       print 
"<tr class='row$current_row'><td colspan=3>This Company has no Specials</td></tr>";
       
$current_row $current_row;
                                           }
       while(
$sp=$db->fetch_row($js))
                                           {
       print 
"<tr class='row$current_row'><td><font color=white>{$sp['csNAME']}</td><td><font color=#FF0000>-{$sp['csCOST']}Company Points</font></td><td><center><input type='radio' name='ID' value='{$sp['csID']}' /></td></tr>";
       
$current_row $current_row;
                                           }
       print 
"<tr>
       <td colspan=3><div align=center><input type='submit' value='Purchase'></div></td>
       </tr></table></form><br/>"
;
       
$h->endpage();
?>

compspecials.php

Code: [Select]
<?php
                  
include_once (DIRNAME(__FILE__) . '/globals.php');
                     
$_POST['ID'] = abs(@intval($_POST['ID']));


if(!
$_POST['ID'])
                               {
   echo 
"Invalid use of file";
   exit;
                               }

else
                               {
   
$com $db->query("SELECT bmembBusiness FROM businesses_members WHERE bmembMember='{$ir['userid']}'");
   
$cc=$db->fetch_row($com);
   
$clas $db->query("SELECT * FROM businesses WHERE busId='{$cc['bmembBusiness']}'");
   
$cs=$db->fetch_row($clas);
   
$clas $db->query("SELECT * FROM businesses WHERE busDirector='1'");
   
$cs=$db->fetch_row($clas);
   
$q<