rendered paste body<?phpfunction TrimUserLine(){ $file = "./user"; $handle = fopen($file, 'r+'); $lastlinesz = strlen(FetchName()); $filesize = filesize($file); $trimto = ($filesize-$lastlinesz); $success = ftruncate($handle, $trimto); fclose($handle);}function CompleteSet($set){ global $globset; $the_complete = array(); $handle = file_get_contents('./cards'); $array = explode(chr(10), $handle); reset($array); $gotcards = array(); foreach ($array AS $value) { list($card_set, $card_number, $r) = explode(':', $value); if ($card_set == $set) { $gotcards[] = $card_number; } } $the_complete['gots'] = count($gotcards); $the_complete['tots'] = $globset[$set]; $the_complete['need'] = ($the_complete['tots'] - $the_complete['gots']); @$the_complete['percentage'] = round(($the_complete['gots'] / $the_complete['tots']) * 100, 1); return $the_complete;}function FetchMoney(){ $handle = file_get_contents('./user'); list($name, $money) = explode(chr(10), $handle); return $money;}function FetchName(){ $handle = file_get_contents('./user'); list($name, $money) = explode(chr(10), $handle); return $name;}function SellCard($value){ $money = FetchMoney(); $sum = ($money + $value); SetMoney($sum);}function SetMoney($newmoney){ TrimUserLine(); $file = "./user"; $handle = fopen($file, 'a'); fwrite($handle, $newmoney); fclose($handle);}function GetCards($set){ global $backlink, $globset; $iscomplete = CompleteSet($set); $variable = "<table class=\"tblbdr\" border=1 cellpadding=3 width=100%><tr><td class='newbg' colspan=4 align='center' valign='middle'>Printing Set # " . $set . " (owned cards) [" . $iscomplete['gots'] . " / " . $iscomplete['tots'] . "] " . $iscomplete['percentage'] . "%</td></tr><tr><td align='center' valign='middle' class='newbg'>Number</td><td align='center' valign='middle' class='newbg'>Name</td><td align='center' valign='middle' class='newbg'>Rarity</td><td align='center' valign='middle' class='newbg'>Number Owned</td></tr>"; $handle = file_get_contents('./cards'); $array = explode(chr(10), $handle); reset($array); $gotcards = array(); foreach ($array AS $value) { list($card_set, $card_number, $r) = explode(':', $value); if ($card_set == $set) { $gotcards[] = $card_number; } } //draw list $handle2 = file_get_contents('./sets'); $array2 = explode(chr(10), $handle2); reset($array2); foreach ($array2 AS $value) { list($card_set, $card_number, $card_name, $card_rarity, $card_value) = explode(':', $value); if ($card_set == $set) { $havegot = array_keys($gotcards, $card_number); $card_qty = count($havegot); $newbg = ""; if ($card_qty) { $newbg = "class='newbg'"; } $variable .= "<tr><td align='center' valign='middle' " . $newbg . ">" . $card_number . " / " . $globset[$set] . "</td><td align='center' valign='middle' " . $newbg . ">" . $card_name . "</td><td align='center' valign='middle' " . $newbg . ">" . $card_rarity . "</td><td align='center' valign='middle' " . $newbg . ">" . $card_qty . "</td></tr>"; } } $variable .= "</table>" . $backlink . ""; return $variable;}function AddCards($set, $card){ $var = $set . ":" . $card . ":" . chr(10); $handle = fopen('./cards', 'a'); fwrite($handle, $var); fclose($handle);}function DoHolo(){ $rand = rand(1,2); if ($rand == '1') //holo! { $holo = true; } if ($rand == '2') //rare.. { $holo = false; } return $holo;}function SpecialCard(){ $rand = rand(1,300); // 1 in 300 chance of getting a holo in pack, despite already having a holo or rare //should this event actually happen, //give the user some additional funds for this fortune, just in case they missed the event if ($rand == '1') { SellCard('30000'); //not selling anything, but its easier than making another dummy function to add funds $holo = true; } else { $holo = false; } return $holo;}function BuyBooster($set, $cost){ global $backlink; $funds = FetchMoney(); if ($funds >= $cost) //proceed { $new = ($funds - $cost); echo "-" . $cost . "$<br>(" . $new . "$)<br><br>"; SetMoney($new); } if ($funds < $cost) { die("You do not have enough money to purchase this. Please try selling some duplicate unwanted cards in order to make some return in order to buy more cards.<br><br>" . $backlink); } $cards = array(); $handle2 = file_get_contents('./cards'); $array2 = explode(chr(10), $handle2); reset($array2); $gotcards = array(); foreach ($array2 AS $value) { list($card_set, $card_number, $r) = explode(':', $value); if ($card_set == $set) { $gotcards[] = $card_number; } } $loosepacket = CallSetGatherer($set); $packet = explode('¬', $loosepacket); foreach ($packet AS $value) { $cards[] = $value; } $handle = file_get_contents('./sets'); $array = explode(chr(10), $handle); reset($array); $inset = array(); foreach ($array AS $value) { list($c_set, $c_num, $c_name, $c_rarity, $c_value) = explode(':', $value); if ($c_set == $set) { $inset[] = $c_num . "¬" . $c_name . "¬" . $c_rarity . "¬" . $c_value . "¬"; } } $tempgotarray = array(); //array to prevent multi adding duplicate cards for ($i=0; $i<(count($cards)-1); $i++) { $cnum = ($cards[$i]-1); list($c_num, $c_name, $c_rarity, $c_value) = explode("¬", $inset[$cnum]); $prevar = $c_num . "¬" . $c_name . "¬" . $c_rarity . "¬" . $c_value; $havegot = array_keys($gotcards, $c_num); $card_qty = count($havegot); if ($card_qty) { SellCard($c_value); $tag1 = ""; $tag2 = ""; } if (!$card_qty) { $hgot = array_keys($tempgotarray, $c_num); $cqty = count($hgot); if ($cqty) //found a duplicate card already in this packet; sell it { SellCard($c_value); $tag1 = ""; $tag2 = ""; } if (!$cqty) { AddCards($set, $cards[$i]); $tag1 = "<strong>"; $tag2 = "</strong>"; } } $tempgotarray[] = $c_num; echo "Obtained: " . $tag1 . $c_name . $tag2 . " [" . $tag1 . $c_rarity . $tag2 . "], " . $tag1 . "card #" . $c_num . $tag2 . "<br>"; } echo "<br>" . $backlink;}?>