Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Can't find exactly what you've been wanting? Try searching for what you are looking for in the search box to the right. ----------->


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: [v1] & [v2] Medical Insurance && Hospital Bill  (Read 1243 times)

Cyanide

  • Global Moderator
  • Basic Member
  • *****
  • Reputation Power: 38
  • Cyanide has no influence.
  • Offline Offline
  • Posts: 55
    • MSN Messenger - xcyanide187x@live.com
    • View Profile
[v1] & [v2] Medical Insurance && Hospital Bill
« on: April 01, 2009, 03:08:43 AM »
Another older mod of mine...I wrote and released this on CE...never tested it....but there was never a bug reported to me on it...so here it is...

(v1)insagent.php
Code: [Select]
<?php
/*-----------------------------------------------------
-- Medical Insurance v1
-- This is a free modification, please do not resell
-- If you use this mod, please give credit 
-- insagent.php
-----------------------------------------------------*/
session_start();
require 
"global_func.php";
if(
$_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require 
"header.php";
$h = new headers;
$h->startheaders();
include 
"mysql.php";
global 
$c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$cm=money_formatter($ir['crystals'],'');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();
if(
$ir['hospital']>0)
{
print 
"You cant buy insurance while youre already in the hospital.";
$h->endpage();
}
if(
$ir['jail']>0)
{
print 
"You cant buy insurance while youre in jail.";
$h->endpage();
}
if(!
$_GET['x'])
{
print 
"<center><table><table width=100% border=3 cellspacing=5 bordercolor=white>Welcome to the Insurance Agency!<br />
You have <b>{$ir['medins']}</b> days left before you can renew your policy.<br /><br />
How would you like to pay for your policy?
<br />
<center><a href='insagent.php?x=money'> Pay With Cash - \$2500</a><br />
<center><a href='insagent.php?x=crystals'> Pay With Crystals - 25</a><br />"
;
}
else
{
if(
$_GET['x'] == 'money')
{
if(
$ir['money'] <2500)
{
print 
"You don't have enough money, sorry.";
}
else if(
$ir['medins'] > 0)
{
print 
"You have {$ir['medins']} days left before you must renew your policy.";
}
else
{
$_POST['money']=strip_tags($_POST['money']);
$_POST['money']=mny_stripfmt($_POST['money'], ENT_QUOTES);
$_POST['money']=abs((int)($_POST['money']));
mysql_query("UPDATE users SET medins=medins+30,money=money-2500 WHERE userid=$userid",$c);
print 
"You have paid \$2,500 for a 30 day insurance policy.";
}
}
else if(
$_GET['x'] == 'crystals')
{
if(
$ir['crystals'] <25)
{
print 
"You don't have enough crystals, sorry.";
}
else if(
$ir['medins'] > 0)
{
print 
"You have {$ir['medins']} days left before you must renew your policy.";
}
else
{
$_POST['crystals']=strip_tags($_POST['crystals']);
$_POST['crystals']=mny_stripfmt($_POST['crystals'], ENT_QUOTES);
$_POST['crystals']=abs((int)($_POST['crystals']));
mysql_query("UPDATE users SET medins=medins+30,crystals=crystals-25 WHERE userid=$userid",$c);
print 
"You have paid 25 crystals for a 30 day insurance policy.";
}
}

$h->endpage();
?>

(v2) insagent.php
Code: [Select]
<?php
include "globals.php";
if(
$ir['hospital']>0)
{
print 
"You cant buy insurance while youre already in the hospital.";
$h->endpage();
}
if(
$ir['jail']>0)
{
print 
"You cant buy insurance while youre in jail.";
$h->endpage();
}
if(!
$_GET['x'])
{
print 
"<center><table><table width=100% border=3 cellspacing=5 bordercolor=white>Welcome to the Insurance Agency!<br />
You have <b>{$ir['medins']}</b> days left before you can renew your policy.<br /><br />
How would you like to pay for your policy?
<br />
<center><a href='insagent.php?x=money'> Pay With Cash - \$2500</a><br />
<center><a href='insagent.php?x=crystals'> Pay With Crystals - 25</a><br />"
;
}
else
{
if(
$_GET['x'] == 'money')
{
if(
$ir['money'] <2500)
{
print 
"You don't have enough money, sorry.";
}
else if(
$ir['medins'] > 0)
{
print 
"You have {$ir['medins']} days left before you must renew your policy.";
}
else
{
$_POST['money']=strip_tags($_POST['money']);
$_POST['money']=mny_stripfmt($_POST['money'], ENT_QUOTES);
$_POST['money']=abs((int)($_POST['money']));
mysql_query("UPDATE users SET medins=medins+30,money=money-2500 WHERE userid=$userid",$c);
print 
"You have paid \$2,500 for a 30 day insurance policy.";
}
}
else if(
$_GET['x'] == 'crystals')
{
if(
$ir['crystals'] <25)
{
print 
"You don't have enough crystals, sorry.";
}
else if(
$ir['medins'] > 0)
{
print 
"You have {$ir['medins']} days left before you must renew your policy.";
}
else
{
$_POST['crystals']=strip_tags($_POST['crystals']);
$_POST['crystals']=mny_stripfmt($_POST['crystals'], ENT_QUOTES);
$_POST['crystals']=abs((int)($_POST['crystals']));
mysql_query("UPDATE users SET medins=medins+30,crystals=crystals-25 WHERE userid=$userid",$c);
print 
"You have paid 25 crystals for a 30 day insurance policy.";
}
}

$h->endpage();
?>

Edits for attack.php

Find your query that sends a user to the hospital that looks something like this:
Code: [Select]
mysql_query("UPDATE users SET hp=1,hospital=$hosptime,hospreason='Mugged by <a href=\'viewuser.php?u={$userid}\'>{$ir['username']}</a>' WHERE userid={$r['userid']}");
Under it add this:
Code: [Select]
mysql_query("UPDATE users SET hospbill=hospbill+$hosptime*10 WHERE userid={$r['userid']}");
Open attacklost.php and find the line that sends you to the hospital, under it add this:
Code: [Select]
mysql_query("UPDATE users SET hospbill=hospbill+$hosptime*10 WHERE userid={$ir['userid']}");
Cron Edits:

Add this to your daily cron:
Code: [Select]
mysql_query("UPDATE users SET medins=medins-1 WHERE medins>0",$c);
mysql_query("UPDATE users SET money=money-hospbill WHERE medins>0",$c);
mysql_query("UPDATE users SET hospbill=0 WHERE hospbill>0",$c);

SQL:
Code: [Select]
ALTER TABLE `users` ADD `medins` BIGINT( 22 ) NOT NULL DEFAULT '0',
ADD `hospbill` BIGINT( 22 ) NOT NULL DEFAULT '0';

Enjoy.
Logged
 


This forum is now closed and has moved to a new location! Click here to find out why.