torrentflux_2.4/ 0000755 0000000 0000000 00000000000 11026130131 012517 5 ustar root root torrentflux_2.4/CHANGELOG 0000755 0000041 0000041 00000016441 11023133254 015302 0 ustar www-data www-data TorrentFlux: PHP Torrent Download Manager
=================================================================
by TorrentFlux.com
=================================================================
Change Log
TorrentFlux v2.4
------------------
* Removed TorrentSpy search plugin
* Cryptography functionality & enabled by default (by imrook)
* Added checks to prevent normal users from seeing sensitive information (by deadeyes)
* Updated MiniNova search plugin (by alx)
* Removed CVS files for BitTornado
* Converted \r\n to \n in all source files
* Bug fix for torrents dying after they're started (tornado shell args not escaped)
* Postgres 8 sql install scripts
* Updated MySQL install scripts (TYPE clause depreciated for storage engine declarations)
* Fixed bug preventing torrents from starting in simple mode
Bug fixes from Debian team
* Recursive call error in SearchEngineBase
* Python filename dependency
* Parameter check in directory browser to prevent traversal above download directory
* Update settings fails with blank search filter
TorrentFlux v2.3
------------------
* Fixed more Arbitrary File Creation/Overwrite/Deletion & Command
Execution Vulnerablity (by TF Users).
* Security fixes on htmlentities.
* Added security check for JPG support with GD libs to prevent
user lock out if JPG support is not included in GD libs.
(Note GD support is not required and is only for graphic
Security Code login).
* Upgraded to BitTornado 3.17 (BitTornado 3.15 source is still
included in tar.gz if you want to change back to 3.15).
TorrentFlux v2.2
------------------
* Added optional Security Code for login security.
* Fixed Arbitrary File Creation/Overwrite/Deletion & Command
Execution Vulnerablity (by TF Users).
* Fixed Qmanager looping issue.
* Added multi select delete to the directory listing.
* Updated RSSReader to not show error when no RSS feeds are used.
* Updated Search Engine Modules and bug fixes.
* Updated maketorrent to allow changing of chunk size.
* Added security fixes for htmlentities in User-Agents and
request variables.
* Fixed torrent start when advanced torrent start is turned off.
* Added page refresh countdown.
* Fixed jump links on RSS feed page.
* Updated Admin Links to allow editing and sorting.
* Added Turkish and Russian language files.
TorrentFlux v2.1
----------------
* Addes support for reading file size of files over 2.0 GB.
* Added Queue Manager functionality
this will allow an admin to specify the following.
maximum torrent threads per server
maximum torrent threads per user
polling interval
amount of time the q manager waits in (seconds)
between each sweep of the queue
enable / disable of queuing
admins will have the ability to override the queuing
when starting a torrent in the start dialog.
* Settings are now stored in a database table and can be
modified from the admin screens.
* Torrents will not be able to be deleted until they have
shutdown -- prevents hanging threads.
* Admin can specify what categories will be filtered out on
torrent searches.
* User may continue browsing when downloading via package
downloading.
* Using ADODB 4.80 for database connections.
* Using BitTornado 3.15 Linux Source.
* Support for Cookies for each user under profiles.
* Updated RSS feed and Fetching of Torrents over a URL.
* Added Rerequest Interval to the Startpop and Settings
* Added modular search engine. Support for several
popular torrent search engines -- you can build your
own.
* Search Engine settings and filtering.
* File Priority selection
* Added btmakemetafile.py for Making Torrents
* Users may download the torrent file from the list.
* NFO / Text viewer
* Download torrent meta file from main torrent list.
TorrentFlux v2.0
-----------------
* Added Size to the main page to view the download size of the
torrent.
* Added natural sort order for directory and file listings.
* Fixed deleting so that file names with .. in it will delete.
* Download files via the directory listing.
* Tar/Zip and download directories on with a single click.
* Added max download rate as an option.
* Added Super Seeder option for advanced start.
* Added mouse over torrent status.
* Added Database Abstraction layer (using ADODB)
* Updated to use BitTornado-0.3.10 source.
* Added new torrent search.
* Dynamic URLs now download and use proper torrent name.
* Added Chinese, Tiawanese, Finnish, Galacian, and Estonian
language files.
* Option to show server load on main page.
* Added torrent health icons for torrents that are running.
* Each user now sees his torrents grouped together in their own
list.
* Dropped BitTorrent client from install package. Includes
BitTornado only now.
TorrentFlux v1.5
-----------------
* Created login screen -- no longer uses Basic Authentication
through the headers. PHP no longer has to run as a module in
Apache.
* Added loggoff button.
* Storage bar to display free drive space.
* Download details now shows distributed seeds (BitTornado only).
* Download details now show download and upload amounts.
* Updated the torrent grabing via URL -- uses curl or fopen
depending on what is available to server. Much faster.
* Endless seeding (0% share kill) bug has been fixed.
* Minor bug fixes.
* Added Polish language file.
* Changed how torrents are stopped. No longer uses kill command
but now messages the torrent client to shutdown -- stats are
now reported to the tracker when torrent is stopped.
* Enhanced directory browsing with file type icons.
TorrentFlux v1.4
-----------------
* The RSS Feed page now has jump links to the different sections
of the page.
* Better directory browsing.
* More complete logging for Admins.
* Total Upload and Download rates displayed at bottom of page.
* Replaced time stamp column with Estimated Time.
* Users may specify Max Upload Rate when running torrent.
* Users may specify when the torrent stops seeding.
* Updated to use BitTornado or BitTorrent clients. More
statistics with the BitTornado client.
* Forced user names to lower case. When dealing with owner
directories this UserName is NOT the same as username.
* Fixed issue of starting a torrent when "n/a" is the owner.
* Fixed timeout issue with the RSS reader.
* Updated URL Torrent download to work with Suprnova.orgs
referer requirement -- can be changed in the config.php.
* Many small HTML and display updates.
TorrentFlux v1.3
-----------------
* Torrents will be marked incomplete if they are stopped outside
of TorrentFlux (system reboot or what ever).
* No longer uses Screen for managing the downloads. Should fix
torrents not starting on some Linux versions like Fedora.
* Users downloads now go to a directory with the users name.
Only the user that downloaded the file or an admin may delete.
* Torrent Files are now sorted by date. Newest at the top.
* Error(s) from the trackers are now displayed in the download
details dialog box.
* Admin section now has a place to add and remove RSS feeds.
* Torrent meta files download directly to TorrentFlux from the
RSS links.
* Updated btphpdownload.py so that it no longer uses curses for
display -- this was not needed and causes issues on servers
that don't allow the user running Apache to have a terminal.
* Added Suprnova.org search field the home page. This can be
turned on or off from the config.php file.
torrentflux_2.4/html/ 0000755 0000041 0000041 00000000000 11026130131 015015 5 ustar www-data www-data torrentflux_2.4/html/logout.php 0000755 0000041 0000041 00000003044 11017367654 017071 0 ustar www-data www-data qstr($cfg["user"])." and action=".$db->qstr($cfg["constants"]["hit"]);
// do the SQL
$result = $db->Execute($sql);
showError($db, $sql);
}
?> torrentflux_2.4/html/functions.php 0000755 0000041 0000041 00000244210 11024310576 017557 0 ustar www-data www-data GetOne($sql);
showError($db,$sql);
return $rtnValue;
}
//*********************************************************
// avddelete()
function avddelete($file)
{
$file = html_entity_decode($file, ENT_QUOTES);
chmod($file,0777);
if (@is_dir($file))
{
$handle = @opendir($file);
while($filename = readdir($handle))
{
if ($filename != "." && $filename != "..")
{
avddelete($file."/".$filename);
}
}
closedir($handle);
@rmdir($file);
}
else
{
@unlink($file);
}
}
//*********************************************************
// Authenticate()
function Authenticate()
{
global $cfg, $db;
$create_time = time();
if(!isset($_SESSION['user']))
{
header('location: login.php');
exit();
}
if ($_SESSION['user'] == md5($cfg["pagetitle"]))
{
// user changed password and needs to login again
header('location: logout.php');
exit();
}
$sql = "SELECT uid, hits, hide_offline, theme, language_file FROM tf_users WHERE user_id=".$db->qstr($cfg['user']);
$recordset = $db->Execute($sql);
showError($db, $sql);
if($recordset->RecordCount() != 1)
{
AuditAction($cfg["constants"]["error"], "FAILED AUTH: ".$cfg['user']);
session_destroy();
header('location: login.php');
exit();
}
list($uid, $hits, $cfg["hide_offline"], $cfg["theme"], $cfg["language_file"]) = $recordset->FetchRow();
// Check for valid theme
if (!ereg('^[^./][^/]*$', $cfg["theme"]))
{
AuditAction($cfg["constants"]["error"], "THEME VARIABLE CHANGE ATTEMPT: ".$cfg["theme"]." from ".$cfg['user']);
$cfg["theme"] = $cfg["default_theme"];
}
// Check for valid language file
if(!ereg('^[^./][^/]*$', $cfg["language_file"]))
{
AuditAction($cfg["constants"]["error"], "LANGUAGE VARIABLE CHANGE ATTEMPT: ".$cfg["language_file"]." from ".$cfg['user']);
$cfg["language_file"] = $cfg["default_language"];
}
if (!is_dir("themes/".$cfg["theme"]))
{
$cfg["theme"] = $cfg["default_theme"];
}
// Check for valid language file
if (!is_file("language/".$cfg["language_file"]))
{
$cfg["language_file"] = $cfg["default_language"];
}
$hits++;
$sql = 'select * from tf_users where uid = '.$uid;
$rs = $db->Execute($sql);
showError($db, $sql);
$rec = array(
'hits' => $hits,
'last_visit' => $create_time,
'theme' => $cfg['theme'],
'language_file' => $cfg['language_file']
);
$sql = $db->GetUpdateSQL($rs, $rec);
$result = $db->Execute($sql);
showError($db,$sql);
}
//*********************************************************
// SaveMessage
function SaveMessage($to_user, $from_user, $message, $to_all=0, $force_read=0)
{
global $_SERVER, $cfg, $db;
$message = str_replace(array("'"), "", $message);
$create_time = time();
$sTable = 'tf_messages';
if($to_all == 1)
{
$message .= "\n\n__________________________________\n*** "._MESSAGETOALL." ***";
$sql = 'select user_id from tf_users';
$result = $db->Execute($sql);
showError($db,$sql);
while($row = $result->FetchRow())
{
$rec = array(
'to_user' => $row['user_id'],
'from_user' => $from_user,
'message' => $message,
'IsNew' => 1,
'ip' => $cfg['ip'],
'time' => $create_time,
'force_read' => $force_read
);
$sql = $db->GetInsertSql($sTable, $rec);
$result2 = $db->Execute($sql);
showError($db,$sql);
}
}
else
{
// Only Send to one Person
$rec = array(
'to_user' => $to_user,
'from_user' => $from_user,
'message' => $message,
'IsNew' => 1,
'ip' => $cfg['ip'],
'time' => $create_time,
'force_read' => $force_read
);
$sql = $db->GetInsertSql($sTable, $rec);
$result = $db->Execute($sql);
showError($db,$sql);
}
}
//*********************************************************
function addNewUser($newUser, $pass1, $userType)
{
global $cfg, $db;
$create_time = time();
$record = array(
'user_id'=>strtolower($newUser),
'password'=>md5($pass1),
'hits'=>0,
'last_visit'=>$create_time,
'time_created'=>$create_time,
'user_level'=>$userType,
'hide_offline'=>"0",
'theme'=>$cfg["default_theme"],
'language_file'=>$cfg["default_language"]
);
$sTable = 'tf_users';
$sql = $db->GetInsertSql($sTable, $record);
$result = $db->Execute($sql);
showError($db,$sql);
}
//*********************************************************
function PruneDB()
{
global $cfg, $db;
// Prune LOG
$testTime = time()-($cfg['days_to_keep'] * 86400); // 86400 is one day in seconds
$sql = "delete from tf_log where time < " . $db->qstr($testTime);
$result = $db->Execute($sql);
showError($db,$sql);
unset($result);
$testTime = time()-($cfg['minutes_to_keep'] * 60);
$sql = "delete from tf_log where time < " . $db->qstr($testTime). " and action=".$db->qstr($cfg["constants"]["hit"]);
$result = $db->Execute($sql);
showError($db,$sql);
unset($result);
}
//*********************************************************
function IsOnline($user)
{
global $cfg, $db;
$online = false;
$sql = "SELECT count(*) FROM tf_log WHERE user_id=" . $db->qstr($user)." AND action=".$db->qstr($cfg["constants"]["hit"]);
$number_hits = $db->GetOne($sql);
showError($db,$sql);
if ($number_hits > 0)
{
$online = true;
}
return $online;
}
//*********************************************************
function IsUser($user)
{
global $cfg, $db;
$isUser = false;
$sql = "SELECT count(*) FROM tf_users WHERE user_id=".$db->qstr($user);
$number_users = $db->GetOne($sql);
if ($number_users > 0)
{
$isUser = true;
}
return $isUser;
}
//*********************************************************
function getOwner($file)
{
global $cfg, $db;
$rtnValue = "n/a";
// Check log to see what user has a history with this file
$sql = "SELECT user_id FROM tf_log WHERE file=".$db->qstr($file)." AND (action=".$db->qstr($cfg["constants"]["file_upload"])." OR action=".$db->qstr($cfg["constants"]["url_upload"])." OR action=".$db->qstr($cfg["constants"]["reset_owner"]).") ORDER BY time DESC";
$user_id = $db->GetOne($sql);
if($user_id != "")
{
$rtnValue = $user_id;
}
else
{
// try and get the owner from the stat file
$rtnValue = resetOwner($file);
}
return $rtnValue;
}
//*********************************************************
function resetOwner($file)
{
global $cfg, $db;
include_once("AliasFile.php");
// log entry has expired so we must renew it
$rtnValue = "";
$alias = getAliasName($file).".stat";
if(file_exists($cfg["torrent_file_path"].$alias))
{
$af = new AliasFile($cfg["torrent_file_path"].$alias);
if (IsUser($af->torrentowner))
{
// We have an owner!
$rtnValue = $af->torrentowner;
}
else
{
// no owner found, so the super admin will now own it
$rtnValue = GetSuperAdmin();
}
$host_resolved = $cfg['ip'];
$create_time = time();
$rec = array(
'user_id' => $rtnValue,
'file' => $file,
'action' => $cfg["constants"]["reset_owner"],
'ip' => $cfg['ip'],
'ip_resolved' => $host_resolved,
'user_agent' => $_SERVER['HTTP_USER_AGENT'],
'time' => $create_time
);
$sTable = 'tf_log';
$sql = $db->GetInsertSql($sTable, $rec);
// add record to the log
$result = $db->Execute($sql);
showError($db,$sql);
}
return $rtnValue;
}
//*********************************************************
function getCookie($cid)
{
global $cfg, $db;
$rtnValue = "";
$sql = "SELECT host, data FROM tf_cookies WHERE cid=".$cid;
$rtnValue = $db->GetAll($sql);
return $rtnValue[0];
}
//*********************************************************
function getAllCookies($uid)
{
global $cfg, $db;
$rtnValue = "";
$sql = "SELECT c.cid, c.host, c.data FROM tf_cookies AS c, tf_users AS u WHERE u.uid=c.uid AND u.user_id='" . $uid . "' order by host";
$rtnValue = $db->GetAll($sql);
return $rtnValue;
}
// ***************************************************************************
// Delete Cookie Host Information
function deleteCookieInfo($cid)
{
global $db;
$sql = "delete from tf_cookies where cid=".$cid;
$result = $db->Execute($sql);
showError($db,$sql);
}
// ***************************************************************************
// addCookieInfo - Add New Cookie Host Information
function addCookieInfo( $newCookie )
{
global $db, $cfg;
// Get uid of user
$sql = "SELECT uid FROM tf_users WHERE user_id = '" . $cfg["user"] . "'";
$uid = $db->GetOne( $sql );
$sql = "INSERT INTO tf_cookies ( uid, host, data ) VALUES ( " . $uid . ", " . $db->qstr($newCookie["host"]) . ", " . $db->qstr($newCookie["data"]) . " )";
$db->Execute( $sql );
showError( $db, $sql );
}
// ***************************************************************************
// modCookieInfo - Modify Cookie Host Information
function modCookieInfo($cid, $newCookie)
{
global $db;
$sql = "UPDATE tf_cookies SET host='" . $newCookie["host"] . "', data='" . $newCookie["data"] . "' WHERE cid=" . $cid;
$db->Execute($sql);
showError($db,$sql);
}
//*********************************************************
function getSite($lid)
{
global $cfg, $db;
$rtnValue = "";
$sql = "SELECT sitename FROM tf_links WHERE lid=".$lid;
$rtnValue = $db->GetOne($sql);
return $rtnValue;
}
//*********************************************************
function getLink($lid)
{
global $cfg, $db;
$rtnValue = "";
$sql = "SELECT url FROM tf_links WHERE lid=".$lid;
$rtnValue = $db->GetOne($sql);
return $rtnValue;
}
//*********************************************************
function getRSS($rid)
{
global $cfg, $db;
$rtnValue = "";
$sql = "SELECT url FROM tf_rss WHERE rid=".$rid;
$rtnValue = $db->GetOne($sql);
return $rtnValue;
}
//*********************************************************
function IsOwner($user, $owner)
{
$rtnValue = false;
if (strtolower($user) == strtolower($owner))
{
$rtnValue = true;
}
return $rtnValue;
}
//*********************************************************
function GetActivityCount($user="")
{
global $cfg, $db;
$count = 0;
$for_user = "";
if ($user != "")
{
$for_user = "user_id=".$db->qstr($user)." AND ";
}
$sql = "SELECT count(*) FROM tf_log WHERE ".$for_user."(action=".$db->qstr($cfg["constants"]["file_upload"])." OR action=".$db->qstr($cfg["constants"]["url_upload"]).")";
$count = $db->GetOne($sql);
return $count;
}
//*********************************************************
function GetSpeedValue($inValue)
{
$rtnValue = 0;
$arTemp = split(" ", trim($inValue));
if (is_numeric($arTemp[0]))
{
$rtnValue = $arTemp[0];
}
return $rtnValue;
}
// ***************************************************************************
// Is User Admin
// user is Admin if level is 1 or higher
function IsAdmin($user="")
{
global $cfg, $db;
$isAdmin = false;
if($user == "")
{
$user = $cfg["user"];
}
$sql = "SELECT user_level FROM tf_users WHERE user_id=".$db->qstr($user);
$user_level = $db->GetOne($sql);
if ($user_level >= 1)
{
$isAdmin = true;
}
return $isAdmin;
}
// ***************************************************************************
// Is User SUPER Admin
// user is Super Admin if level is higher than 1
function IsSuperAdmin($user="")
{
global $cfg, $db;
$isAdmin = false;
if($user == "")
{
$user = $cfg["user"];
}
$sql = "SELECT user_level FROM tf_users WHERE user_id=".$db->qstr($user);
$user_level = $db->GetOne($sql);
if ($user_level > 1)
{
$isAdmin = true;
}
return $isAdmin;
}
// ***************************************************************************
// Returns true if user has message from admin with force_read
function IsForceReadMsg()
{
global $cfg, $db;
$rtnValue = false;
$sql = "SELECT count(*) FROM tf_messages WHERE to_user=".$db->qstr($cfg["user"])." AND force_read=1";
$count = $db->GetOne($sql);
showError($db,$sql);
if ($count >= 1)
{
$rtnValue = true;
}
return $rtnValue;
}
// ***************************************************************************
// Get Message data in an array
function GetMessage($mid)
{
global $cfg, $db;
$rtnValue = array();
if (is_numeric($mid))
{
$sql = "select from_user, message, ip, time, isnew, force_read from tf_messages where mid=".$mid." and to_user=".$db->qstr($cfg['user']);
$rtnValue = $db->GetRow($sql);
showError($db,$sql);
}
return $rtnValue;
}
// ***************************************************************************
// Get Themes data in an array
function GetThemes()
{
$arThemes = array();
$dir = "themes/";
$handle = opendir($dir);
while($entry = readdir($handle))
{
if (is_dir($dir.$entry) && ($entry != "." && $entry != ".."))
{
array_push($arThemes, $entry);
}
}
closedir($handle);
sort($arThemes);
return $arThemes;
}
// ***************************************************************************
// Get Languages in an array
function GetLanguages()
{
$arLanguages = array();
$dir = "language/";
$handle = opendir($dir);
while($entry = readdir($handle))
{
if (is_file($dir.$entry) && (strcmp(strtolower(substr($entry, strlen($entry)-4, 4)), ".php") == 0))
{
array_push($arLanguages, $entry);
}
}
closedir($handle);
sort($arLanguages);
return $arLanguages;
}
// ***************************************************************************
// Get Language name from file name
function GetLanguageFromFile($inFile)
{
$rtnValue = "";
$rtnValue = str_replace("lang-", "", $inFile);
$rtnValue = str_replace(".php", "", $rtnValue);
return $rtnValue;
}
// ***************************************************************************
// Delete Message
function DeleteMessage($mid)
{
global $cfg, $db;
$sql = "delete from tf_messages where mid=".$mid." and to_user=".$db->qstr($cfg['user']);
$result = $db->Execute($sql);
showError($db,$sql);
}
// ***************************************************************************
// Delete Link
function deleteOldLink($lid)
{
global $db;
// Get Current sort order index of link with this link id:
$idx = getLinkSortOrder($lid);
// Fetch all link ids and their sort orders where the sort order is greater
// than the one we're removing - we need to shuffle each sort order down
// one:
$sql = "SELECT sort_order, lid FROM tf_links ";
$sql .= "WHERE sort_order > ".$idx." ORDER BY sort_order ASC";
$result = $db->Execute($sql);
showError($db,$sql);
$arLinks = $result->GetAssoc();
// Decrement the sort order of each link:
foreach($arLinks as $sid => $this_lid)
{
$sql="UPDATE tf_links SET sort_order=sort_order-1 WHERE lid=".$this_lid;
$db->Execute($sql);
showError($db,$sql);
}
// Finally delete the link:
$sql = "DELETE FROM tf_links WHERE lid=".$lid;
$result = $db->Execute($sql);
showError($db,$sql);
}
// ***************************************************************************
// Delete RSS
function deleteOldRSS($rid)
{
global $db;
$sql = "delete from tf_rss where rid=".$rid;
$result = $db->Execute($sql);
showError($db,$sql);
}
// ***************************************************************************
// Delete User
function DeleteThisUser($user_id)
{
global $db;
$sql = "SELECT uid FROM tf_users WHERE user_id = ".$db->qstr($user_id);
$uid = $db->GetOne( $sql );
showError($db,$sql);
// delete any cookies this user may have had
//$sql = "DELETE tf_cookies FROM tf_cookies, tf_users WHERE (tf_users.uid = tf_cookies.uid) AND tf_users.user_id=".$db->qstr($user_id);
$sql = "DELETE FROM tf_cookies WHERE uid=".$uid;
$result = $db->Execute($sql);
showError($db,$sql);
// Now cleanup any message this person may have had
$sql = "DELETE FROM tf_messages WHERE to_user=".$db->qstr($user_id);
$result = $db->Execute($sql);
showError($db,$sql);
// now delete the user from the table
$sql = "DELETE FROM tf_users WHERE user_id=".$db->qstr($user_id);
$result = $db->Execute($sql);
showError($db,$sql);
}
// ***************************************************************************
// Update User -- used by admin
function updateThisUser($user_id, $org_user_id, $pass1, $userType, $hideOffline)
{
global $db;
if ($hideOffline == "")
{
$hideOffline = 0;
}
$sql = 'select * from tf_users where user_id = '.$db->qstr($org_user_id);
$rs = $db->Execute($sql);
showError($db,$sql);
$rec = array();
$rec['user_id'] = $user_id;
$rec['user_level'] = $userType;
$rec['hide_offline'] = $hideOffline;
if ($pass1 != "")
{
$rec['password'] = md5($pass1);
}
$sql = $db->GetUpdateSQL($rs, $rec);
if ($sql != "")
{
$result = $db->Execute($sql);
showError($db,$sql);
}
// if the original user id and the new id do not match, we need to update messages and log
if ($user_id != $org_user_id)
{
$sql = "UPDATE tf_messages SET to_user=".$db->qstr($user_id)." WHERE to_user=".$db->qstr($org_user_id);
$result = $db->Execute($sql);
showError($db,$sql);
$sql = "UPDATE tf_messages SET from_user=".$db->qstr($user_id)." WHERE from_user=".$db->qstr($org_user_id);
$result = $db->Execute($sql);
showError($db,$sql);
$sql = "UPDATE tf_log SET user_id=".$db->qstr($user_id)." WHERE user_id=".$db->qstr($org_user_id);
$result = $db->Execute($sql);
showError($db,$sql);
}
}
// ***************************************************************************
// changeUserLevel Changes the Users Level
function changeUserLevel($user_id, $level)
{
global $db;
$sql='select * from tf_users where user_id = '.$db->qstr($user_id);
$rs = $db->Execute($sql);
showError($db,$sql);
$rec = array('user_level'=>$level);
$sql = $db->GetUpdateSQL($rs, $rec);
$result = $db->Execute($sql);
showError($db,$sql);
}
// ***************************************************************************
// Mark Message as Read
function MarkMessageRead($mid)
{
global $cfg, $db;
$sql = 'select * from tf_messages where mid = '.$mid;
$rs = $db->Execute($sql);
showError($db,$sql);
$rec = array('IsNew'=>0,
'force_read'=>0);
$sql = $db->GetUpdateSQL($rs, $rec);
$db->Execute($sql);
showError($db,$sql);
}
//**************************************************************************
// alterLink()
// This function updates the database and alters the selected links values
function alterLink($lid,$newLink,$newSite)
{
global $cfg, $db;
$sql = "UPDATE tf_links SET url='".$newLink."',`sitename`='".$newSite."' WHERE `lid`=".$lid;
$db->Execute($sql);
showError($db,$sql);
}
// ***************************************************************************
// addNewLink - Add New Link
function addNewLink($newLink,$newSite)
{
global $db;
// Link sort order index:
$idx = -1;
// Get current highest link index:
$sql = "SELECT sort_order FROM tf_links ORDER BY sort_order DESC";
$result = $db->SelectLimit($sql, 1);
showError($db, $sql);
if($result->fields === false)
{
// No links currently in db:
$idx = 0;
}
else
{
$idx = $result->fields["sort_order"]+1;
}
$rec = array
(
'url'=>$newLink,
'sitename'=>$newSite,
'sort_order'=>$idx
);
$sTable = 'tf_links';
$sql = $db->GetInsertSql($sTable, $rec);
$db->Execute($sql);
showError($db,$sql);
}
// ***************************************************************************
// addNewRSS - Add New RSS Link
function addNewRSS($newRSS)
{
global $db;
$rec = array('url'=>$newRSS);
$sTable = 'tf_rss';
$sql = $db->GetInsertSql($sTable, $rec);
$db->Execute($sql);
showError($db,$sql);
}
// ***************************************************************************
// UpdateUserProfile
function UpdateUserProfile($user_id, $pass1, $hideOffline, $theme, $language)
{
global $cfg, $db;
if (empty($hideOffline) || $hideOffline == "" || !isset($hideOffline))
{
$hideOffline = "0";
}
// update values
$rec = array();
if ($pass1 != "")
{
$rec['password'] = md5($pass1);
AuditAction($cfg["constants"]["update"], _PASSWORD);
}
$sql = 'select * from tf_users where user_id = '.$db->qstr($user_id);
$rs = $db->Execute($sql);
showError($db,$sql);
$rec['hide_offline'] = $hideOffline;
$rec['theme'] = $theme;
$rec['language_file'] = $language;
$sql = $db->GetUpdateSQL($rs, $rec);
$result = $db->Execute($sql);
showError($db,$sql);
}
// ***************************************************************************
// Get Users in an array
function GetUsers()
{
global $cfg, $db;
$user_array = array();
$sql = "select user_id from tf_users order by user_id";
$user_array = $db->GetCol($sql);
showError($db,$sql);
return $user_array;
}
// ***************************************************************************
// Get Super Admin User ID as a String
function GetSuperAdmin()
{
global $cfg, $db;
$rtnValue = "";
$sql = "select user_id from tf_users WHERE user_level=2";
$rtnValue = $db->GetOne($sql);
showError($db,$sql);
return $rtnValue;
}
// ***************************************************************************
// Get Links in an array
function GetLinks()
{
global $cfg, $db;
$link_array = array();
$link_array = $db->GetAssoc("SELECT lid, url, sitename, sort_order FROM tf_links ORDER BY sort_order");
return $link_array;
}
// ***************************************************************************
// Get RSS Links in an array
function GetRSSLinks()
{
global $cfg, $db;
$link_array = array();
$sql = "SELECT rid, url FROM tf_rss ORDER BY rid";
$link_array = $db->GetAssoc($sql);
showError($db,$sql);
return $link_array;
}
// ***************************************************************************
// Build Search Engine Drop Down List
function buildSearchEngineDDL($selectedEngine = 'PirateBay', $autoSubmit = false)
{
$output = "\n";
return $output;
}
// ***************************************************************************
// Build Search Engine Links
function buildSearchEngineLinks($selectedEngine = 'PirateBay')
{
global $cfg;
$settingsNeedsSaving = false;
$settings['searchEngineLinks'] = Array();
$output = '';
if( (!array_key_exists('searchEngineLinks', $cfg)) || (!is_array($cfg['searchEngineLinks'])))
{
saveSettings($settings);
}
$handle = opendir("./searchEngines");
while($entry = readdir($handle))
{
$entrys[] = $entry;
}
natcasesort($entrys);
foreach($entrys as $entry)
{
if ($entry != "." && $entry != ".." && substr($entry, 0, 1) != ".")
if(strpos($entry,"Engine.php"))
{
$tmpEngine = str_replace("Engine",'',substr($entry,0,strpos($entry,".")));
if(array_key_exists($tmpEngine,$cfg['searchEngineLinks']))
{
$hreflink = $cfg['searchEngineLinks'][$tmpEngine];
$settings['searchEngineLinks'][$tmpEngine] = $hreflink;
}
else
{
$hreflink = getEngineLink($tmpEngine);
$settings['searchEngineLinks'][$tmpEngine] = $hreflink;
$settingsNeedsSaving = true;
}
if (strlen($hreflink) > 0)
{
$output .= "";
if ($selectedEngine == $tmpEngine)
{
$output .= "".$hreflink."";
}
else
{
$output .= $hreflink;
}
$output .= "
\n";
}
}
}
if ( count($settings['searchEngineLinks'],COUNT_RECURSIVE) <> count($cfg['searchEngineLinks'],COUNT_RECURSIVE))
{
$settingsNeedsSaving = true;
}
if ($settingsNeedsSaving)
{
natcasesort($settings['searchEngineLinks']);
saveSettings($settings);
}
return $output;
}
function getEngineLink($searchEngine)
{
$tmpLink = '';
$engineFile = 'searchEngines/'.$searchEngine.'Engine.php';
if (is_file($engineFile))
{
$fp = @fopen($engineFile,'r');
if ($fp)
{
$tmp = fread($fp, filesize($engineFile));
@fclose( $fp );
$tmp = substr($tmp,strpos($tmp,'$this->mainURL'),100);
$tmp = substr($tmp,strpos($tmp,"=")+1);
$tmp = substr($tmp,0,strpos($tmp,";"));
$tmpLink = trim(str_replace(array("'","\""),"",$tmp));
}
}
return $tmpLink;
}
// ***************************************************************************
// ***************************************************************************
// Display Functions
// ***************************************************************************
// ***************************************************************************
// Display the header portion of admin views
function DisplayHead($subTopic, $showButtons=true, $refresh="", $percentdone="")
{
global $cfg;
?>
|
: |
|
![]() | ";
$output .= "![]() | ";
$output .= "
".$cfg["user"].": "._TORRENTFILE." | ";
echo "Size | ";
echo ""._USER." | ";
echo ""._STATUS." | ";
echo ""._ESTIMATEDTIME." | ";
echo ""._ADMIN." | ";
echo "
"._TORRENTFILE." | ";
echo "Size | ";
echo ""._USER." | ";
echo ""._STATUS." | ";
echo ""._ESTIMATEDTIME." | ";
echo ""._ADMIN." | ";
echo "