<?php function coin() { $heads = 0; $tails = 0; echo '<h1>Starting the program</h1>'; for ($i = 1; $i <= 5000; $i++) { $flip = rand(1, 2); switch ($flip) { case $flip == 1: $heads++; break; case $flip == 2: $tails++; break; } echo 'Attempt #' . $i . ': Throwing the coin... It\'s a head!... Got ' . $heads . " head(s) so far and " . $tails . ' tail(s) so far<br>'; } echo '<h1>Ending the program</h1>'; } coin();
// or die(mysql_error()); $row = mysql_fetch_assoc($res); if (!$row) { bark("invalid user"); } $CURUSER = $row; $id = isset($_GET['torrent']) ? intval($_GET['torrent']) : 0; if (!is_valid_id($id)) { stderr("{$lang['download_user_error']}", "{$lang['download_no_id']}"); } if ($TBDEV['coins']) { if ($CURUSER['coins'] < 200) { stderr("Error!", "You do not have enough coins to download this torrent"); } } coin(200, false); $res = @sql_query("SELECT name, owner, category, filename FROM torrents WHERE id = {$id}") or sqlerr(__FILE__, __LINE__); $row = mysql_fetch_assoc($res); $fn = "{$TBDEV['torrent_dir']}/{$id}.torrent"; if (!$row || !is_file($fn) || !is_readable($fn)) { httperr(); } if (happyHour("check") && happyCheck("checkid", $row["category"])) { $multiplier = happyHour("multiplier"); $time = time(); happyLog($CURUSER["id"], $id, $multiplier); @sql_query("INSERT INTO happyhour (userid, torrentid, multiplier ) VALUES (" . sqlesc($CURUSER["id"]) . " , " . sqlesc($id) . ", " . sqlesc($multiplier) . ")"); } @sql_query("UPDATE torrents SET hits = hits + 1 WHERE id = {$id}"); /** free mod for TBDev 09 by pdq **/ require_once MODS_DIR . 'freeslots_inc.php';
$id = mysql_insert_id(); if ($CURUSER["anonymous"] == 'yes') { $message = "New Torrent : [url={$TBDEV['baseurl']}/details.php?id={$id}] " . htmlspecialchars($torrent) . "[/url] Uploaded - Anonymous User"; } else { $message = "New Torrent : [url={$TBDEV['baseurl']}/details.php?id={$id}] " . htmlspecialchars($torrent) . "[/url] Uploaded by " . htmlspecialchars($CURUSER["username"]) . ""; } @sql_query("DELETE FROM files WHERE torrent = {$id}"); function file_list($arr, $id) { foreach ($arr as $v) { $new[] = "({$id}," . sqlesc($v[0]) . "," . $v[1] . ")"; } return join(",", $new); } sql_query("INSERT INTO files (torrent, filename, size) VALUES " . file_list($filelist, $id)); coin(100, true); $fp = fopen("{$TBDEV['torrent_dir']}/{$id}.torrent", "w"); if ($fp) { @fwrite($fp, benc($dict), strlen(benc($dict))); fclose($fp); } //===add karma @sql_query("UPDATE users SET seedbonus = seedbonus+15.0 WHERE id = " . sqlesc($CURUSER["id"]) . "") or sqlerr(__FILE__, __LINE__); //===end write_log(sprintf($lang['takeupload_log'], $id, $torrent, $CURUSER['username'])); autoshout($message); /* RSS feeds */ if (($fd1 = @fopen("rss.xml", "w")) && ($fd2 = fopen("rssdd.xml", "w"))) { $cats = ""; $res = sql_query("SELECT id, name FROM categories"); while ($arr = mysql_fetch_assoc($res)) {