Jump to content
MakeWebGames

Supporter Days{v1}


3XTR3M3

Recommended Posts

  • 3 weeks later...

Re: Supporter Days{v1}

i just converted it v2

 

smarket.php

 

 

<?php

// Supporter Days Market

// Originally DDay Market

// Editted and released by Liam

include "globals.php";

switch($_GET['action'])

{

case "buy":

sdays_buy();

break;

case "remove":

sdays_remove();

break;

case "add":

sdays_add();

break;

default:

sdays_index();

break;

}

function sdays_index() {

global $ir,$c,$userid,$h;

print "[Add A Listing]

 

<table width=100%>

<tr>

<th>Adder</th>

<th>Qty</th>

<th>Price each</th>

<th>Price total</th>

<th>Links</th>

</tr>";

$q=mysql_query("SELECT sd.*, u.* FROM sdaysmarket sd LEFT JOIN users u ON u.userid=sd.sdADDER ORDER BY sdPRICE/sdQTY ASC",$c);

while($r=mysql_fetch_array($q)) {

if($r['sdADDER'] == $userid) {

$link = "Remove";

} else {

$link = "Buy";

}

$each= (int) $r['sdPRICE'] / $r['sdQTY'];

echo "<tr>

<td>{$r['username']} [{$r['userid']}]</td>

<td>{$r['sdQTY']}</td>

<td> \$" . number_format($each)."</td>

<td>\$".number_format($r['sdPRICE'])."</td>

<td>[$link]</td>

</tr>";

}

echo "</table>";

}

function sdays_remove() {

global $ir,$c,$userid,$h;

$q=mysql_query("SELECT * FROM sdaysmarket WHERE sdID={$_GET['ID']} AND sdADDER=$userid",$c);

if(!mysql_num_rows($q)) {

echo "Error, either these Supporter Market Days do not exist, or you are not the owner.

> Back";

$h->endpage();

exit;

}

$r=mysql_fetch_array($q);

mysql_query("UPDATE users SET supporterdays=supporterdays+{$r['ddQTY']} where userid=$userid",$c) or die(mysql_error());

_query("DELETE FROM sdaysmarket WHERE sdID={$_GET['ID']}",$c);

echo "Supporter Days removed from market!

mysql

> Back";

}

function sdays_buy() {

global $ir,$c,$userid,$h;

$q=mysql_query("SELECT * FROM sdaysmarket sd WHERE sdID={$_GET['ID']}",$c);

if(!mysql_num_rows($q)) {

echo "Error, either these Supporter Days do not exist, or they have already been bought.

> Back";

$h->endpage();

exit;

}

$r=mysql_fetch_array($q);

if($r['sdPRICE'] > $ir['money']) {

echo "Error, you do not have the funds to buy these Supporter Days.

> Back";

$h->endpage();

exit;

}

mysql_query("UPDATE users SET supporterdays=supporterdays+{$r['sdQTY']} where userid=$userid",$c) or die(mysql_error());

mysql_query("DELETE FROM sdaysmarket WHERE sdID={$_GET['ID']}",$c);

mysql_query("UPDATE users SET money=money-{$r['sdPRICE']} where userid=$userid",$c);

mysql_query("UPDATE users SET money=money+{$r['sdPRICE']} where userid={$r['sdADDER']}",$c);

event_add($r['sdADDER'],"{$ir['username']} bought your {$r['sdQTY']} Supporter Days from the market for \$".number_format($r['sdPRICE']).".",$c);

print "You bought the {$r['sdQTY']} Supporter Days from the market for \$".number_format($r['sdPRICE']).".

 

Back";

}

function sdays_add() {

global $ir,$c,$userid,$h;

$_POST['amnt'] = abs((int) $_POST['amnt']);

$_POST['price'] = abs((int) $_POST['price']);

if($_POST['amnt']) {

if($_POST['amnt'] > $ir['supporterdays']) {

die ("You are trying to add more Supporter Days to the market than you have.");

}

$tp=$_POST['amnt']*$_POST['price'];

mysql_query("INSERT INTO sdaysmarket VALUES('',{$_POST['amnt']},$userid,$tp)", $c);

mysql_query("UPDATE users SET supporterdays=supporterdays-{$_POST['amnt']} WHERE userid=$userid", $c);

echo "supporter days added to market!

> Back";

} else {

echo "Adding a listing...

 

You have {$ir['supporterdays']} Suporter Days that you can add to the market.

<form action='smarket.php?action=add' method='post'>

<table width=50% border=2>

<tr>

<td>Supporter Days:</td>

<td><input type='text' name='amnt' value='{$ir['supporterdays']}' /></td>

</tr>

<tr>

<td>Price Each:</td>

<td><input type='text' name='price' value='2000' /></td>

</tr>

<tr>

<td colspan=2 align=center>

<input type='submit' value='Add To Market' />

</tr>

</table>

</form>";

}

}

$h->endpage();

?>

Link to comment
Share on other sites

  • 7 months later...

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

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

×   Your previous content has been restored.   Clear editor

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

×
×
  • Create New...