Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > Free Torrent Source > Mods & Themes
Reply
  #1  
Old 18th January 2009, 20:08
Edgein's Avatar
Edgein Edgein is offline
Senior Member
 
Join Date: Sep 2008
Netherlands
Posts: 154
Default Bytes Calculator based on tbdev
Hello i'm playing with fts 1.2.3 Final

my first mod is a
a Bytes calculator
You can convert Bytes, KiloBytes, MegaBytes, GigaBytes, and TeraBytes

first the sql for the Moderator Control & Stats Panel

Code:
INSERT INTO `stafftools` (`name`, `file`, `desc`, `minclass`) VALUES
('Calculator', 'calc.php', 'You can here convert Bytes, KiloBytes, MegaBytes, GigaBytes, and TeraBytes', 4);
in functions.php

add above function ug

PHP Code:
function Convert_to_bytes($number$size$returnall=false)
{
if(
$returnall === false)
{
switch(
$size)
{
case 
"t":
return 
$number*1024*1024*1024*1024;
case 
"g":
return 
$number*1024*1024*1024;
case 
"m":
return 
$number*1024*1024;
case 
"k":
return 
$number*1024;
case 
"b":
return 
$number;
}
}
else
{
switch(
$size)
{
case 
"b":
return array(
$number$number/1024$number/1024/1024$number/1024/1024/1024$number/1024/1024/1024/1024);
break;
case 
"k":
return array(
$number*1024$number$number/1024$number/1024/1024$number/1024/1024/1024);
break;
case 
"m":
return array(
$number*1024*1024$number*1024$number$number/1024$number/1024/1024);
break;
case 
"g":
return array(
$number*1024*1024*1024$number*1024*1024$number*1024$number$number/1024);
break;
case 
"t":
return array(
$number*1024*1024*1024*1024$number*1024*1024*1024$number*1024*1024$number*1024$number);
break;
}
}

and create a new file named calc.php and put it into de admin folder

PHP Code:
<?
$rootpath 
'../';
require_once ( 
$rootpath."include/bittorrent.php" ) ;

ADMIN::check();


stdhead("Calculator");


if(
$CURUSER['class'] < UC_MODERATOR){
header("Location: 404.php");}
if(
$_SERVER['REQUEST_METHOD'] == 'POST')
{
if(isset(
$_POST['value']))
{
if(isset(
$_POST['size']))
{
$values Convert_to_bytes($_POST["value"], $_POST["size"], true);
?>


<table width="80%" border="3" cellpadding="0" cellspacing="0" cellpadding="0" align="center" >
<h2>Calculator</h2>
<tr>
<td colspan="3" align="center" nowrap ><b>Coversion Result</b></td>
</tr>
<tr>
<td align="right" nowrap ><b>Bytes</b></td>
<td align="center" nowrap width="1%">=</td>
<td align="left" nowrap ><? echo $values[0];?></td>
</tr>
<tr>
<td align="right" nowrap ><b>KiloBytes</b></td>
<td align="center" nowrap width="1%">=</td>
<td align="left" nowrap ><? echo $values[1];?></td>
</tr>

<tr>
<td align="right" nowrap ><b>MegaBytes</b></td>
<td align="center" nowrap width="1%">=</td>
<td align="left" nowrap ><? echo $values[2];?></td>
</tr>
<tr>
<td align="right" nowrap ><b>GigaBytes</b></td>

<td align="center" nowrap width="1%">=</td>
<td align="left" nowrap ><? echo $values[3];?></td>
</tr>
<tr>
<td align="right" nowrap ><b>TeraBytes</b></td>
<td align="center" nowrap width="1%">=</td>
<td align="left" nowrap ><? echo $values[4];?></td>

</tr>
</table>
<br>
<?
}
else{
stderr("Error""Missing post data");
}
}
else{
stderr("Error""Missing post data");
}

?>

<?
}
?>

<p align=center> Get the value of this in Bytes, KiloBytes, MegaBytes, GigaBytes, and TeraBytes </p>
<form method=post action=calc.php name=calc>
<input name=value type=text size=10 value="">&nbsp;<select name=size>
<option value="b">Bytes</option>
<option value="k">KiloBytes</option>
<option value="m">MegaBytes</option>
<option value="g">GigaBytes</option>
<option value="t">TeraBytes</option>
</select>
<br />
<input type=submit value='Do It' />
</form>

<?
stdfoot
();
?>

screen:
Click the image to open in full size.
Reply With Quote
The Following 2 Users Say Thank You to Edgein For This Useful Post:
Fynnon (19th January 2009), hellix (19th January 2009)
Reply

Tags
based , bytes , calculator , tbdev

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[TBDev] shoutcast radio for tbdev Slatkis TBDev 14 3rd June 2017 09:08
TorrentStrike theme engine to TBdev Kotafi Mods & Themes 6 13th May 2012 04:42
I need help with announce.php on TBDeV based tracker simalingur Community Cafe 9 2nd February 2010 12:05
Looking for designer for tbdev based tracker! Viperia Sell & Buy 1 26th July 2009 15:26
Based on TBDev...? icecore Torrent Strike 4 8th August 2008 04:35



All times are GMT +2. The time now is 14:31. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.