/** * print an error and die if the user is not logged in or is not an admin * @param string $errortext error text to be printed */ function MustBeAdmin() { MustLogIn(); if (!IsAdmin()) { bw_error("Only for admins!"); } }
/** * starts a bittorrent-client * @param $torrent name of the torrent * @param $interactive (1|0) : is this a interactive startup with dialog ? */ function startTorrentClient($torrent, $interactive) { // do tornado special-pre-start-checks // check to see if the path to the python script is valid if (!is_file($this->cfg["btclient_tornado_bin"])) { AuditAction($this->cfg["constants"]["error"], "Error Path for " . $this->cfg["btclient_tornado_bin"] . " is not valid"); if (IsAdmin()) { $this->status = -1; header("location: admin.php?op=configSettings"); return; } else { $this->status = -1; $this->messages .= "<b>Error</b> TorrentFlux settings are not correct (path to python script is not valid) -- please contact an admin.<br>"; return; } } // prepare starting of client parent::prepareStartTorrentClient($torrent, $interactive); // prepare succeeded ? if ($this->status != 2) { $this->status = -1; $this->messages .= "<b>Error</b> parent::prepareStartTorrentClient(" . $torrent . "," . $interactive . ") failed<br>"; return; } // build the command-string $skipHashCheck = ""; if (!empty($this->skip_hash_check) && getTorrentDataSize($torrent) > 0) { $skipHashCheck = " --check_hashes 0"; } $this->command = $this->runtime . " " . $this->sharekill_param . " " . $this->cfg["torrent_file_path"] . $this->alias . ".stat " . $this->owner . " --responsefile '" . $this->cfg["torrent_file_path"] . $this->torrent . "' --display_interval 5 --max_download_rate " . $this->drate . " --max_upload_rate " . $this->rate . " --max_uploads " . $this->maxuploads . " --minport " . $this->port . " --maxport " . $this->maxport . " --rerequest_interval " . $this->rerequest . " --super_seeder " . $this->superseeder . " --max_initiate " . $this->maxcons . $skipHashCheck; if (file_exists($this->cfg["torrent_file_path"] . $this->alias . ".prio")) { $priolist = explode(',', file_get_contents($this->cfg["torrent_file_path"] . $this->alias . ".prio")); $priolist = implode(',', array_slice($priolist, 1, $priolist[0])); $this->command .= " --priority " . $priolist; } $this->command .= " " . $this->cfg["btclient_tornado_options"] . " > /dev/null &"; if ($this->cfg["AllowQueing"] && $this->queue == "1") { // This file is queued. } else { // This file is started manually. if (!array_key_exists("pythonCmd", $this->cfg)) { insertSetting("pythonCmd", "/usr/bin/python"); } if (!array_key_exists("debugTorrents", $this->cfg)) { insertSetting("debugTorrents", "0"); } $pyCmd = ""; if (!$this->cfg["debugTorrents"]) { $pyCmd = $this->cfg["pythonCmd"] . " -OO"; } else { $pyCmd = $this->cfg["pythonCmd"]; } $this->command = "cd " . $this->savepath . "; HOME=" . $this->cfg["path"] . "; export HOME;" . $this->umask . " nohup " . $this->nice . $pyCmd . " " . $this->cfg["btclient_tornado_bin"] . " " . $this->command; } // start the client parent::doStartTorrentClient(); }
/** * starts a bittorrent-client * @param $torrent name of the torrent * @param $interactive (1|0) : is this a interactive startup with dialog ? */ function startTorrentClient($torrent, $interactive) { // do transmission special-pre-start-checks // check to see if the path to the transmission-bin is valid if (!is_file($this->cfg["btclient_transmission_bin"])) { AuditAction($this->cfg["constants"]["error"], "Error Path for " . $this->cfg["btclient_transmission_bin"] . " is not valid"); $this->status = -1; if (IsAdmin()) { header("location: admin.php?op=configSettings"); return; } else { $this->messages .= "<b>Error</b> TorrentFlux settings are not correct (path to transmission-bin is not valid) -- please contact an admin.<br>"; return; } } // prepare starting of client parent::prepareStartTorrentClient($torrent, $interactive); // prepare succeeded ? if ($this->status != 2) { $this->status = -1; $this->messages .= "<b>Error</b> parent::prepareStartTorrentClient(" . $torrent . "," . $interactive . ") failed<br>"; return; } // included in transmissioncli // quick-hack for transmission--1 //if ($this->rate == 0) // $this->rate = -1; //if ($this->drate == 0) // $this->drate = -1; // included in transmissioncli // pid-file $this->pidFile = "\"" . $this->cfg["torrent_file_path"] . $this->alias . ".stat.pid\""; // build the command-string $this->command = "-t \"" . $this->cfg["torrent_file_path"] . $this->alias . ".stat\" -w " . $this->owner; // "new" transmission-patch has pid-file included $this->command .= " -z " . $this->pidFile; /* - bsd-workaround */ $this->command .= " -e 5 -p " . $this->port . " -u " . $this->rate . " -c " . $this->sharekill_param . " -d " . $this->drate; $this->command .= " " . $this->cfg["btclient_transmission_options"] . "\"" . $this->cfg["torrent_file_path"] . $this->torrent; // standard, no shell trickery ("new" transmission-patch has pid-file included) : $this->command .= '" &> /dev/null &'; /* - bsd-workaround */ // <begin shell-trickery> to write the pid of the client into the pid-file // * b4rt : //$this->command .= '" &> /dev/null & echo $! > "'. $this->pidFile .'"'; // * lord_nor : //$this->command .= '" > /dev/null & echo $! & > "'. $this->pidFile .'"'; /* + bsd-workaround */ // <end shell-trickery> if ($this->cfg["AllowQueing"] && $this->queue == "1") { // This file is queued. } else { // This file is started manually. $this->command = "cd " . $this->savepath . "; HOME=" . $this->cfg["path"] . "; export HOME;" . $this->umask . " nohup " . $this->nice . $this->cfg["btclient_transmission_bin"] . " " . $this->command; } // start the client parent::doStartTorrentClient(); }
public function SetProjectAllow($id, $allow) { $resultArr = array('status' => false, 'info' => null); if (IsAdmin()) { if (M('Project')->where('id=%d', $id)->setField('allow', $allow)) { $resultArr['status'] = true; $resultArr['info'] = "操作成功"; } else { $resultArr['info'] = '系统异常,操作失败'; } } else { $resultArr['info'] = '不具有管理员权限'; } echo json_encode($resultArr); }
public function detail($id) { $acDetail = M('Activity')->where('id=%d', $id)->find(); // 比对活动是否结束 $now = time(); $over = strtotime($acDetail['over_time']); if ($now > $over) { $acDetail['isOver'] = true; } else { $acDetail['isOver'] = false; } $this->assign('detail', $acDetail); if (IsAdmin()) { $formList = M('ActivityFormSign')->where('activity_id=%d', $id)->select(); $this->assign('formList', $formList); } $this->display(); }
function CreateJam($theme, $date, $time) { $jamNumber = intval(GetNextJamNumber()); $theme = trim($theme); $date = trim($date); $time = trim($time); //Authorize user (logged in) if (IsLoggedIn() === false) { die("Not logged in."); } //Authorize user (is admin) if (IsAdmin() === false) { die("Only admins can create jams."); } //Validate jam number if ($jamNumber <= 0) { die("Invalid jam number"); } //Validate theme if (strlen($theme) <= 0) { die("Invalid theme"); } //Validate date and time and create datetime object if (strlen($date) <= 0) { die("Invalid date"); } else { if (strlen($time) <= 0) { die("Invalid time"); } else { $datetime = strtotime($date . " " . $time); } } $newJam = array(); $newJam["jam_number"] = $jamNumber; $newJam["theme"] = $theme; $newJam["date"] = date("d M Y", $datetime); $newJam["time"] = date("H:i", $datetime); $newJam["start_time"] = date("c", $datetime); $newJam["entries"] = array(); file_put_contents("data/jams/jam_{$jamNumber}.json", json_encode($newJam)); }
if ($inlineedit == EDIT_INLINE) { if (IsAdmin() || $_SESSION["AccessLevel"] == ACCESS_LEVEL_ADMINGROUP) { $lockmessage = $pageObject->lockingObj->GetLockInfo($strTableName, $keys, false, $id); } else { $lockmessage = $pageObject->lockingObj->LockUser; } $returnJSON['success'] = false; $returnJSON['message'] = $lockmessage; $returnJSON['enableCtrls'] = $enableCtrlsForEditing; $returnJSON['confirmTime'] = $pageObject->lockingObj->ConfirmTime; echo my_json_encode($returnJSON); exit; } $system_attrs = "style='display:block;'"; $system_message = $pageObject->lockingObj->LockUser; if (IsAdmin() || $_SESSION["AccessLevel"] == ACCESS_LEVEL_ADMINGROUP) { $rb = $pageObject->lockingObj->GetLockInfo($strTableName, $keys, true, $id); if ($rb != "") { $system_message = $rb; } } } } if ($pageObject->lockingObj && $inlineedit != EDIT_INLINE) { $pageObject->body["begin"] .= '<div class="runner-locking" ' . $system_attrs . '>' . $system_message . '</div>'; } if ($message) { $message = "<div class='message " . $mesClass . "'>" . $message . "</div>"; } // PRG rule, to avoid POSTDATA resend if ($IsSaved && no_output_done() && $inlineedit == EDIT_SIMPLE) {
static function checkUserPermissions($table, $permission) { // user is logged in if (!isLogged() || isLoggedAsGuest()) { Security::tryRelogin(); } // admin area security if ($table == ADMIN_USERS) { return IsAdmin(); } return CheckTablePermissions($table, $permission); }
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ include_once 'config.php'; include_once 'functions.php'; DisplayHead(_XFER); if ($cfg['enable_xfer'] == 1) { $cfg['xfer_realtime'] = 1; getDirList($cfg['torrent_file_path']); echo '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>'; if ($cfg['xfer_day']) { echo displayXferBar($cfg['xfer_day'], $xfer_total['day']['total'], _XFERTHRU . ' Today:'); } if ($cfg['xfer_week']) { echo displayXferBar($cfg['xfer_week'], $xfer_total['week']['total'], _XFERTHRU . ' ' . $cfg['week_start'] . ':'); } $monthStart = strtotime(date('Y-m-') . $cfg['month_start']); $monthText = date('j') < $cfg['month_start'] ? date('M�j', strtotime('-1 Day', $monthStart)) : date('M�j', strtotime('+1 Month -1 Day', $monthStart)); if ($cfg['xfer_month']) { echo displayXferBar($cfg['xfer_month'], $xfer_total['month']['total'], _XFERTHRU . ' ' . $monthText . ':'); } if ($cfg['xfer_total']) { echo displayXferBar($cfg['xfer_total'], $xfer_total['total']['total'], _TOTALXFER . ':'); } echo '</tr></table>'; echo '<br>'; if ($cfg['enable_public_xfer'] == 1 || IsAdmin()) { displayXfer(); } } DisplayFoot();
function ew_Info() { global $Security; ew_WritePaths(); echo "CurrentUserName() = " . CurrentUserName() . "<br>"; echo "CurrentUserID() = " . CurrentUserID() . "<br>"; echo "CurrentParentUserID() = " . CurrentParentUserID() . "<br>"; echo "IsLoggedIn() = " . (IsLoggedIn() ? "TRUE" : "FALSE") . "<br>"; echo "IsAdmin() = " . (IsAdmin() ? "TRUE" : "FALSE") . "<br>"; echo "IsSysAdmin() = " . (IsSysAdmin() ? "TRUE" : "FALSE") . "<br>"; if (isset($Security)) { $Security->ShowUserLevelInfo(); } }
/** * Makes assigns for admin * */ function assignAdmin() { if ($this->isAdminTable()) { $this->xt->assign("exitadminarea_link", true); $this->xt->assign("exitaalink_attrs", "id=\"exitAdminArea" . $this->id . "\""); } if ($this->isDynamicPerm && IsAdmin()) { $this->xt->assign("adminarea_link", true); $this->xt->assign("adminarealink_attrs", "id=\"adminArea" . $this->id . "\""); } }
function EditUserPassword($username, $newPassword1, $newPassword2) { global $users, $dbConn; //Authorize user (is admin) if (IsAdmin() === false) { die("Only admins can edit entries."); } $newPassword1 = trim($newPassword1); $newPassword2 = trim($newPassword2); if ($newPassword1 != $newPassword2) { die("passwords don't match"); } $password = $newPassword1; //Check password length if (strlen($password) < 8) { die("password must be longer than 8 characters"); } //Check that the user exists if (!isset($users[$username])) { die("User does not exist"); return; } //Generate new salt, number of iterations and hashed password. $newUserSalt = GenerateSalt(); $newUserPasswordIterations = intval(rand(10000, 20000)); $newPasswordHash = HashPassword($password, $newUserSalt, $newUserPasswordIterations); $users[$loggedInUser["username"]]["salt"] = $newUserSalt; $users[$loggedInUser["username"]]["password_hash"] = $newPasswordHash; $users[$loggedInUser["username"]]["password_iterations"] = $newUserPasswordIterations; $newUserSaltClean = mysqli_real_escape_string($dbConn, $newUserSalt); $newPasswordHashClean = mysqli_real_escape_string($dbConn, $newPasswordHash); $newUserPasswordIterationsClean = mysqli_real_escape_string($dbConn, $newUserPasswordIterations); $usernameClean = mysqli_real_escape_string($dbConn, $username); $sql = "\t\n\t\tUPDATE user\n\t\tSET\n\t\tuser_password_salt = '{$newUserSaltClean}',\n\t\tuser_password_iterations = '{$newUserPasswordIterationsClean}',\n\t\tuser_password_hash = '{$newPasswordHashClean}'\n\t\tWHERE user_username = '******';\n\t"; $data = mysqli_query($dbConn, $sql); $sql = ""; LoadUsers(); $loggedInUser = IsLoggedIn(TRUE); }
if (!isset($_SESSION['check']['allow_url_fopen'])) { $_SESSION['check']['allow_url_fopen'] = 1; if (@ini_get('allow_url_fopen') == '0' || strtolower(@ini_get('allow_url_fopen')) == 'off') { @error("allow_url_fopen disabled", "index.php?iid=index", "", array("tf-b4rt will not run flawless with this setting", "PHP-setting : allow_url_fopen")); } } // register_globals if (!isset($_SESSION['check']['register_globals'])) { $_SESSION['check']['register_globals'] = 1; if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on') { @error("register_globals enabled", "index.php?iid=index", "", array("tf-b4rt may not run flawless with this setting", "PHP-setting : register_globals")); } } } // set admin-var $cfg['isAdmin'] = IsAdmin(); // load some settings from users-table $sql = "SELECT hide_offline, theme, language_file FROM tf_users WHERE user_id=" . $db->qstr($cfg["user"]); $recordset = $db->Execute($sql); if ($db->ErrorNo() != 0) { dbError($sql); } list($cfg["hide_offline"], $cfg["theme"], $cfg["language_file"]) = $recordset->FetchRow(); // 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_file("inc/language/" . $cfg["language_file"])) { $cfg["language_file"] = $cfg["default_language"]; }
function xt_displaymenu($params) { global $strTableName, $pageName; $menuparams = array(); foreach ($params as $p) { $menuparams[] = $p; } $menuId = $menuparams[0]; $ProjectSettings = new ProjectSettings(); $menuName = $ProjectSettings->getMenuName($this->template_file, $menuId, $menuparams[1]); $menuStyle = $ProjectSettings->getMenuStyle($this->template_file, $menuId, $menuparams[1]); $isMobyleLayout = isMobile(); array_shift($menuparams); global $pageObject; $pageType = ""; $pageMode = 0; $menuNodes = array(); $isAdminTable = false; if (isset($pageObject)) { $pageObject->getMenuNodes(); $pageType = $pageObject->pageType; $pageMode = $pageObject->mode; $isAdminTable = $pageObject->isAdminTable(); if ($isAdminTable) { $menuName = "adminarea"; } $menuNodes = $pageObject->getMenuNodes($menuName); } $xt = new Xtempl(); $xt->assign("menuName", $menuName); $xt->assign("menustyle", $menuStyle ? "second" : "main"); $quickjump = false; $horizontal = false; if (count($menuparams)) { if ($menuparams[0] == "horizontal") { $horizontal = true; } elseif ($menuparams[0] == "quickjump") { $quickjump = true; } } if (!$isAdminTable) { if (!$quickjump) { if (!$isMobyleLayout) { $xt->assign("simpleTypeMenu", true); } else { $xt->assign("treeLikeTypeMenu", true); } } if ($pageType == PAGE_MENU && IsAdmin() && !$isMobyleLayout) { $xt->assign("adminarea_link", true); } } else { //Admin Area menu items $xt->assign("adminAreaTypeMenu", true); } // need to predefine vars $nullParent = NULL; $rootInfoArr = array("id" => 0, "href" => ""); // create treeMenu instance $menuNodesIndex = 0; $menuMap = array(); $menuRoot = new MenuItem($rootInfoArr, $menuNodes, $nullParent, $menuMap); // call xtempl assign, set session params $menuRoot->setMenuSession(); $menuRoot->assignMenuAttrsToTempl($xt); $menuRoot->setCurrMenuElem($xt); $xt->assign("mainmenu_block", true); $mainmenu = array(); if (isEnableSection508()) { $mainmenu["begin"] = "<a name=\"skipmenu\"></a>"; } $mainmenu["end"] = ''; $countLinks = 0; $countGroups = 0; $showMenuCollapseExpandAll = false; foreach ($menuRoot->children as $ind => $val) { if ($val->showAsLink) { $countLinks++; } if ($val->showAsGroup) { if (count($val->children)) { $showMenuCollapseExpandAll = true; } $countGroups++; } } $xt->assign("menu_collapse_expand_all", $showMenuCollapseExpandAll); if ($pageType == PAGE_MENU || $countLinks > 1 || $countGroups > 0) { $xt->assignbyref("mainmenu_block", $mainmenu); if ($this->layout->version == 1) { $menuName = "old" . $menuName; } if ($quickjump) { $xt->display($menuName . "_" . "mainmenu_quickjump.htm"); } else { if ($horizontal) { $xt->display($menuName . "_" . "mainmenu_horiz.htm"); } else { if ($isMobyleLayout && $this->layout->version != 1) { $xt->display($menuName . "_" . "mainmenu_m.htm"); } else { $xt->display($menuName . "_" . "mainmenu.htm"); } } } } }
function CheckAdmin() { if (IsAdmin()) { return true; } log_msg("userlib.php->CheckAdmin", "User is not Admin! Privilege violation!"); include "forms/header.php"; echo '<p class="ErrorMsg"> You do not have privilege to access this page.<p>'; echo '<br>'; echo '<a href="welcome.php">Back to Start</a>'; include "forms/footer.php"; exit; }
function ListDirectory($dirName) { global $dirModified, $dir, $cfg; $bgLight = $cfg["bgLight"]; $bgDark = $cfg["bgDark"]; $entrys = array(); $bg = $bgLight; $dirName = stripslashes($dirName); if (isset($dir)) { //setup default parent directory URL $parentURL = "dir.php"; //get the real parentURL if (preg_match("/^(.+)\\/.+\$/", $dir, $matches) == 1) { $parentURL = "dir.php?dir=" . urlencode($matches[1]); } echo "<a href=\"" . $parentURL . "\"><img src=\"images/up_dir.gif\" width=16 height=16 title=\"" . _BACKTOPARRENT . "\" border=0>[" . _BACKTOPARRENT . "]</a>"; } //echo "<table cellpadding=2 width=740>"; /* --- Multi Delete Hack --- */ echo '<table cellpadding="2"" width="740">'; echo '<form action="multi.php" method="post" name="multidir">'; $handle = opendir($dirName); while ($entry = readdir($handle)) { $entrys[] = $entry; } natsort($entrys); foreach ($entrys as $entry) { //if ($entry != "." && $entry != ".." && substr($entry, 0, 1) != ".") { if ($entry != "." && $entry != ".." && substr($entry, 0, 1) != "." && $entry != "lost+found") { if (@is_dir($dirName . $entry)) { echo "<tr bgcolor=\"" . $bg . "\"><td><a href=\"dir.php?dir=" . urlencode($dir . $entry) . "\"><img src=\"images/folder2.gif\" width=\"16\" height=\"16\" title=\"" . $entry . "\" border=\"0\" align=\"absmiddle\">" . $entry . "</a></td>"; // Some Stats dir hack // b4rt-5 if ($cfg['enable_dirstats'] == 1) { $dudir = shell_exec($cfg['bin_du'] . " -sk -h " . correctFileName($dirName . $entry)); $dusize = explode("\t", $dudir); $arStat = @lstat($dirName . $entry); $timeStamp = @filemtime($dirName . $entry); //$timeStamp = $arStat[10]; echo "<td align=\"right\">" . $dusize[0] . "B</td>"; echo "<td width=140>" . @date("m-d-Y h:i a", $timeStamp) . "</td>"; } else { echo "<td> </td>"; echo "<td> </td>"; } echo "<td align=\"right\" nowrap>"; // rename hack include 'rename_dir_extension.php'; // move hack include 'move_dir_extension.php'; // b4rt-5 : SFV Check if ($cfg['enable_sfvcheck'] == 1) { if (false !== ($sfv = findSFV($dirName . $entry))) { echo '<a href="javascript:CheckSFV(\'' . $sfv[dir] . '\',\'' . $sfv[sfv] . '\')"><img ' . 'src="images/sfv_enabled.gif" border="0" ' . 'width="16" height="16" alt="sfv check torrent"></a>'; } else { echo '<img src="images/sfv_disabled.gif" border="0" width="16" height="16" alt="sfv check torrent (no sfv found)">'; } } // b4rt-5 : SFV Check // maketorrentt if ($cfg["enable_maketorrent"]) { echo "<a href=\"JavaScript:MakeTorrent('maketorrent.php?path=" . urlencode($dir . $entry) . "')\"><img src=\"images/make.gif\" width=16 height=16 title=\"Make Torrent\" border=0></a>"; } // download if ($cfg["enable_file_download"]) { echo "<a href=\"dir.php?tar=" . urlencode($dir . $entry) . "\"><img src=\"images/tar_down.gif\" width=16 height=16 title=\"Download as " . $cfg["package_type"] . "\" border=0></a>"; } // The following lines of code were suggested by Jody Steele jmlsteele@stfu.ca // this is so only the owner of the file(s) or admin can delete // only give admins and users who "own" this directory // the ability to delete sub directories if (IsAdmin($cfg["user"]) || preg_match("/^" . $cfg["user"] . "/", $dir)) { //echo "<a href=\"dir.php?del=".urlencode($dir.$entry)."\" onclick=\"return ConfirmDelete('".addslashes($entry)."')\"><img src=\"images/delete_on.gif\" width=16 height=16 title=\""._DELETE."\" border=0></a>"; /* --- Multi Delete Hack --- */ /* checkbox appended to line */ echo "<a href=\"dir.php?del=" . urlencode($dir . $entry) . "\" onclick=\"return ConfirmDelete('" . addslashes($entry) . "')\"><img src=\"images/delete_on.gif\" width=16 height=16 title=\"" . _DELETE . "\" border=0></a><input type=\"checkbox\" name=\"file[]\" value=\"" . urlencode($dir . $entry) . "\">"; /* --- Multi Delete Hack --- */ } else { echo " "; } echo "</td></tr>\n"; if ($bg == $bgLight) { $bg = $bgDark; } else { $bg = $bgLight; } } } } closedir($handle); $entrys = array(); $handle = opendir($dirName); while ($entry = readdir($handle)) { $entrys[] = $entry; } natsort($entrys); foreach ($entrys as $entry) { if ($entry != "." && $entry != "..") { if (@is_dir($dirName . $entry)) { // Do nothing } else { $arStat = @lstat($dirName . $entry); $arStat[7] = $arStat[7] == 0 ? @file_size($dirName . $entry) : $arStat[7]; if (array_key_exists(10, $arStat)) { $timeStamp = @filemtime($dirName . $entry); } else { $timeStamp = ""; } $fileSize = number_format($arStat[7] / 1024); // Code added by Remko Jantzen to assign an icon per file-type. But when not // available all stays the same. $image = "images/time.gif"; $imageOption = "images/files/" . getExtension($entry) . ".png"; if (file_exists("./" . $imageOption)) { $image = $imageOption; } echo "<tr bgcolor=\"" . $bg . "\">"; echo "<td>"; // Can users download files? if ($cfg["enable_file_download"]) { // Yes, let them download echo "<a href=\"dir.php?down=" . urlencode($dir . $entry) . "\" >"; echo "<img src=\"" . $image . "\" width=\"16\" height=\"16\" alt=\"" . $entry . "\" border=\"0\"></a>"; echo "<a href=\"dir.php?down=" . urlencode($dir . $entry) . "\" >" . $entry . "</a>"; } else { // No, just show the name echo "<img src=\"" . $image . "\" width=\"16\" height=\"16\" alt=\"" . $entry . "\" border=\"0\">"; echo $entry; } echo "</td>"; echo "<td align=\"right\">" . $fileSize . " KB</td>"; // b4rt-5 // Some Stats dir hack if ($cfg['enable_dirstats'] == 1) { echo "<td width=140>" . @date("m-d-Y h:i a", $timeStamp) . "</td>"; } else { echo "<td>" . @date("m-d-Y g:i a", $timeStamp) . "</td>"; } // b4rt-5 echo "<td align=\"right\" nowrap>"; // rename hack include 'rename_dir_extension.php'; // move hack include 'move_dir_extension.php'; // b4rt if ($cfg['enable_rar'] == 1) { // R.D. - Display links for unzip/unrar //************************************************************************************************************** if (IsAdmin($cfg["user"]) || preg_match("/^" . $cfg["user"] . "/", $dir)) { if (strpos($entry, '.rar') !== FALSE and strpos($entry, '.Part') === FALSE or strpos($entry, '.part01.rar') !== FALSE or strpos($entry, '.part1.rar') !== FALSE) { echo "<a href=\"javascript:UncompDetails('uncomp.php?file=" . urlencode($dir . $entry) . "&dir=" . urlencode($dir) . "&type=rar')\"><img src=\"images/rar_enabled.gif\" width=16 height=16 title=\"Unrar\" border=0></a>"; } if (strpos($dir . $entry, '.zip') !== FALSE) { echo "<a href=\"javascript:UncompDetails('uncomp.php?file=" . urlencode($dir . $entry) . "&dir=" . urlencode($dir) . "&type=zip')\"><img src=\"images/zip.png\" width=16 height=16 title=\"Unzip\" border=0></a>"; } } //************************************************************************************************************** } // b4rt // nfo if ($cfg["enable_view_nfo"] && (substr(strtolower($entry), -4) == ".nfo" || substr(strtolower($entry), -4) == ".txt" || substr(strtolower($entry), -4) == ".log")) { echo "<a href=\"viewnfo.php?path=" . urlencode(addslashes($dir . $entry)) . "\"><img src=\"images/view_nfo.gif\" width=16 height=16 title=\"View '{$entry}'\" border=0></a>"; } // maketorrent if ($cfg["enable_maketorrent"]) { echo "<a href=\"JavaScript:MakeTorrent('maketorrent.php?path=" . urlencode($dir . $entry) . "')\"><img src=\"images/make.gif\" width=16 height=16 title=\"Make Torrent\" border=0></a>"; } // download if ($cfg["enable_file_download"]) { // Show the download button echo "<a href=\"dir.php?down=" . urlencode($dir . $entry) . "\" >"; echo "<img src=\"images/download_owner.gif\" width=16 height=16 title=\"Download\" border=0>"; echo "</a>"; } // The following lines of code were suggested by Jody Steele jmlsteele@stfu.ca // this is so only the owner of the file(s) or admin can delete // only give admins and users who "own" this directory // the ability to delete files if (IsAdmin($cfg["user"]) || preg_match("/^" . $cfg["user"] . "/", $dir)) { //echo "<a href=\"dir.php?del=".urlencode($dir.$entry)."\" onclick=\"return ConfirmDelete('".addslashes($entry)."')\"><img src=\"images/delete_on.gif\" width=16 height=16 title=\""._DELETE."\" border=0></a>"; /* --- Multi Delete Hack --- */ /* checkbox appended to line */ echo "<a href=\"dir.php?del=" . urlencode($dir . $entry) . "\" onclick=\"return ConfirmDelete('" . addslashes($entry) . "')\"><img src=\"images/delete_on.gif\" width=16 height=16 title=\"" . _DELETE . "\" border=0></a><input type=\"checkbox\" name=\"file[]\" value=\"" . urlencode($dir . $entry) . "\">"; /* --- Multi Delete Hack --- */ } else { echo " "; } echo "</td></tr>\n"; if ($bg == $bgLight) { $bg = $bgDark; } else { $bg = $bgLight; } } } } // b4rt-5 # Some Stats dir hack closedir($handle); /* --- Multi Delete Hack --- */ echo '<input type="hidden" name="action" value="fileDelete" />'; echo '<tr><td align="right" colspan="4"><a href="javascript:document.multidir.submit()" onclick="return ConfirmDelete(\'Multiple Files\')"><img src="images/delete_on.gif" title="Delete" border="0" height="16" width="16"></a><input type="checkbox" onclick="checkCheck(this);" /></td></tr>'; echo "</form>"; /* --- Multi Delete Hack --- */ echo "</table>"; if ($cfg['enable_dirstats'] == 1) { $cmd = $cfg['bin_du'] . " -ch \"" . $dirName . "\" | " . $cfg['bin_grep'] . " \"total\""; $du = shell_exec($cmd); echo '<table cellpadding="0" width="740">'; $du2 = substr($du, 0, -7); echo "<tr bgcolor=#ececec>"; echo "<td align=\"center\">" . _TDDU . " " . $du2 . "B</td></tr>"; echo "</table>"; } // b4rt-5 }
/** * */ public function doCommonAssignments() { $this->xt->assign("id", $this->id); $this->xt->assign("left_block", true); if ($this->crossTable) { $this->xt->assign("cross_controls", true); $this->body["begin"] .= '<script type="text/javascript" src="' . GetRootPathForResources("include/crosstable.js") . '"></script>'; } $this->body["begin"] .= GetBaseScriptsForPage($this->isDisplayLoading); if (!isMobile()) { $this->body["begin"] .= "<div id=\"search_suggest\" class=\"search_suggest\"></div>"; } // assign body end in such way, to prevent collisions with flyId increment $this->body['end'] = array(); AssignMethod($this->body['end'], "assignBodyEnd", $this); $this->xt->assignbyref('body', $this->body); if ($this->isDynamicPerm && IsAdmin()) { $this->xt->assign("adminarea_link", true); $this->xt->assign("adminarealink_attrs", "id=\"adminArea" . $this->id . "\""); } $this->xt->assign("changepwd_link", $_SESSION["AccessLevel"] != ACCESS_LEVEL_GUEST && $_SESSION["fromFacebook"] == false); $this->xt->assign("changepwdlink_attrs", "onclick=\"window.location.href='" . GetTableLink("changepwd") . "';return false;\""); //set the Search panel $this->xt->assign("searchPanel", true); if ($this->isShowMenu()) { $this->xt->assign("menu_block", true); } if (isMobile()) { $this->xt->assign('tableinfomobile_block', true); } $allow_search = true; $allow_export = true; $this->xt->assign("toplinks_block", $allow_search); $this->xt->assign("asearch_link", $allow_search); $this->xt->assign("print_link", $allow_export); if (!$this->crossTable) { $this->xt->assign("printall_link", $allow_export && $this->arrReport['countRows'] > $this->pageSize && $this->pageSize > 0); } $this->xt->assign("export_link", $allow_export); $this->xt->assign("printlink_attrs", "id=print_" . $this->id . " href='#'"); $this->xt->assign("printalllink_attrs", "id=printAll_" . $this->id . " href='#'"); $this->xt->assign("excellink_attrs", "id=export_to_excel" . $this->id . " href='#'"); $this->xt->assign("wordlink_attrs", "id=export_to_word" . $this->id . " href='#'"); $this->xt->assign("pdflink_attrs", "id=export_to_pdf" . $this->id . " href='#'"); $this->xt->assign("prints_block", $allow_export && ($this->crossTable || $this->arrReport['countRows'] > 0)); $this->xt->assign("advsearchlink_attrs", "id=\"advButton" . $this->id . "\""); if (!$this->crossTable && $allow_search && count($this->arrGroupsPerPage)) { $this->xt->assign("recordspp_block", true); $this->createPerPage(); } $this->xt->assign("grid_block", $allow_search); }
if (array_key_exists("custom1", $menuparams)) { if ($menuparams["custom1"] == "horizontal") { $horizontal = true; } elseif ($menuparams["custom1"] == "quickjump") { $quickjump = true; } } if (!$isAdminTable) { if (!$quickjump) { if (!isMobile()) { $xt->assign("simpleTypeMenu", true); } else { $xt->assign("treeLikeTypeMenu", true); } } if ($pageType == PAGE_MENU && IsAdmin() && !isMobile()) { $xt->assign("adminarea_link", true); } } else { //Admin Area menu items $xt->assign("adminAreaTypeMenu", true); } // need to predefine vars $nullParent = NULL; $rootInfoArr = array("id" => 0, "href" => ""); // create treeMenu instance $menuRoot = new MenuItem($rootInfoArr, $pageObject->menuNodes, $nullParent); // call xtempl assign, set session params $menuRoot->setMenuSession(); $menuRoot->assignMenuAttrsToTempl($xt); $menuRoot->setCurrMenuElem($xt);
$menuNode["type"] = "Leaf"; $menuNode["table"] = "public.tmp_bank2"; $menuNode["style"] = ""; $menuNode["params"] = ""; $menuNode["parent"] = "0"; $menuNode["nameType"] = "Text"; $menuNode["linkType"] = "Internal"; $menuNode["pageType"] = "List"; $menuNode["openType"] = "None"; $menuNode["title"] = "Tmp Bank2"; $menuNodesObject->menuNodes[] = $menuNode; $menuNode = array(); $menuNode["id"] = "66"; $menuNode["name"] = ""; $menuNode["href"] = "mypage.htm"; $menuNode["type"] = "Leaf"; $menuNode["table"] = "public.tmp_bank2_null_sspd"; $menuNode["style"] = ""; $menuNode["params"] = ""; $menuNode["parent"] = "0"; $menuNode["nameType"] = "Text"; $menuNode["linkType"] = "Internal"; $menuNode["pageType"] = "List"; $menuNode["openType"] = "None"; $menuNode["title"] = "Tmp Bank2 Null Sspd"; $menuNodesObject->menuNodes[] = $menuNode; if ($menuNodesObject->pageType == PAGE_MENU && IsAdmin()) { } } else { //Admin Area menu items }
function SaveConfig($key, $newValue) { global $config, $configSettings; if (!IsAdmin()) { return; //Lacks permissions to make edits } if ($configSettings[$key]["EDITABLE"] == FALSE) { //Some configuration settings cannot be set via this interface for security reasons. return; } $newValue = str_replace("\n", "", $newValue); $newValue = str_replace("\r", "", $newValue); $newValue = trim($newValue); $configTxt = file_get_contents("config/config.txt"); $lines = explode("\n", $configTxt); $linesUpdated = array(); foreach ($lines as $i => $line) { $line = trim($line); if (StartsWith($line, "#")) { //Comment continue; } $linePair = explode("|", $line); if (count($linePair) >= 2) { //key-value pair $currentKey = trim($linePair[0]); $value = trim($linePair[1]); if ($key == $currentKey) { if ($value != $newValue) { $lines[$i] = $key . " | " . $newValue; file_put_contents("config/config.txt", implode("\n", $lines)); } return; } } } }
function getDirList($dirName) { global $cfg, $db; include_once "AliasFile.php"; $lastUser = ""; $arUserTorrent = array(); $arListTorrent = array(); // sortOrder $sortOrder = getRequestVar("so"); if ($sortOrder == "") { $sortOrder = $cfg["index_page_sortorder"]; } // t-list $arList = getTransferArray($sortOrder); foreach ($arList as $entry) { $output = ""; $displayname = $entry; $show_run = true; $torrentowner = getOwner($entry); $owner = IsOwner($cfg["user"], $torrentowner); $kill_id = ""; $estTime = " "; // alias / stat $alias = getAliasName($entry) . ".stat"; if (substr(strtolower($entry), -8) == ".torrent") { // this is a torrent-client $btclient = getTorrentClient($entry); $af = AliasFile::getAliasFileInstance($dirName . $alias, $torrentowner, $cfg, $btclient); } else { if (substr(strtolower($entry), -4) == ".url") { // this is wget. use tornado statfile $alias = str_replace(".url", "", $alias); $af = AliasFile::getAliasFileInstance($dirName . $alias, $cfg['user'], $cfg, 'tornado'); } else { // this is "something else". use tornado statfile as default $af = AliasFile::getAliasFileInstance($dirName . $alias, $cfg['user'], $cfg, 'tornado'); } } //XFER: add upload/download stats to the xfer array if ($cfg['enable_xfer'] == 1 && $cfg['xfer_realtime'] == 1) { $torrentTotalsCurrent = getTorrentTotalsCurrentOP($entry, $btclient, $af->uptotal, $af->downtotal); $sql = 'SELECT 1 FROM tf_xfer WHERE date = ' . $db->DBDate(time()); $newday = !$db->GetOne($sql); showError($db, $sql); sumUsage($torrentowner, $torrentTotalsCurrent["downtotal"] + 0, $torrentTotalsCurrent["uptotal"] + 0, 'total'); sumUsage($torrentowner, $torrentTotalsCurrent["downtotal"] + 0, $torrentTotalsCurrent["uptotal"] + 0, 'month'); sumUsage($torrentowner, $torrentTotalsCurrent["downtotal"] + 0, $torrentTotalsCurrent["uptotal"] + 0, 'week'); sumUsage($torrentowner, $torrentTotalsCurrent["downtotal"] + 0, $torrentTotalsCurrent["uptotal"] + 0, 'day'); //XFER: if new day add upload/download totals to last date on record and subtract from today in SQL if ($newday) { $newday = 2; $sql = 'SELECT date FROM tf_xfer ORDER BY date DESC'; $lastDate = $db->GetOne($sql); showError($db, $sql); // MySQL 4.1.0 introduced 'ON DUPLICATE KEY UPDATE' to make this easier $sql = 'SELECT 1 FROM tf_xfer WHERE user_id = "' . $torrentowner . '" AND date = "' . $lastDate . '"'; if ($db->GetOne($sql)) { $sql = 'UPDATE tf_xfer SET download = download+' . ($torrentTotalsCurrent["downtotal"] + 0) . ', upload = upload+' . ($torrentTotalsCurrent["uptotal"] + 0) . ' WHERE user_id = "' . $torrentowner . '" AND date = "' . $lastDate . '"'; $db->Execute($sql); showError($db, $sql); } else { showError($db, $sql); $sql = 'INSERT INTO tf_xfer (user_id,date,download,upload) values ("' . $torrentowner . '","' . $lastDate . '",' . ($torrentTotalsCurrent["downtotal"] + 0) . ',' . ($torrentTotalsCurrent["uptotal"] + 0) . ')'; $db->Execute($sql); showError($db, $sql); } $sql = 'SELECT 1 FROM tf_xfer WHERE user_id = "' . $torrentowner . '" AND date = ' . $db->DBDate(time()); if ($db->GetOne($sql)) { $sql = 'UPDATE tf_xfer SET download = download-' . ($torrentTotalsCurrent["downtotal"] + 0) . ', upload = upload-' . ($torrentTotalsCurrent["uptotal"] + 0) . ' WHERE user_id = "' . $torrentowner . '" AND date = ' . $db->DBDate(time()); $db->Execute($sql); showError($db, $sql); } else { showError($db, $sql); $sql = 'INSERT INTO tf_xfer (user_id,date,download,upload) values ("' . $torrentowner . '",' . $db->DBDate(time()) . ',-' . ($torrentTotalsCurrent["downtotal"] + 0) . ',-' . ($torrentTotalsCurrent["uptotal"] + 0) . ')'; $db->Execute($sql); showError($db, $sql); } } } $timeStarted = ""; $torrentfilelink = ""; if (!file_exists($dirName . $alias)) { $af->running = "2"; // file is new $af->size = getDownloadSize($dirName . $entry); $af->WriteFile(); } if (strlen($entry) >= 47) { // needs to be trimmed $displayname = substr($entry, 0, 44); $displayname .= "..."; } if ($cfg["enable_torrent_download"]) { $torrentfilelink = "<a href=\"maketorrent.php?download=" . urlencode($entry) . "\"><img src=\"images/down.gif\" width=9 height=9 title=\"Download Torrent File\" border=0 align=\"absmiddle\"></a>"; } // $hd = getStatusImage($af); $output .= "<tr>"; $detailsLinkString = "<a style=\"font-size:9px; text-decoration:none;\" href=\"JavaScript:ShowDetails('downloaddetails.php?alias=" . $alias . "&torrent=" . urlencode($entry) . "')\">"; // ========================================================== led + meta $output .= '<td valign="bottom" align="center">'; // led $hd = getStatusImage($af); if ($af->running == 1) { $output .= "<a href=\"JavaScript:ShowDetails('downloadhosts.php?alias=" . $alias . "&torrent=" . urlencode($entry) . "')\">"; } $output .= "<img src=\"images/" . $hd->image . "\" width=\"16\" height=\"16\" title=\"" . $hd->title . $entry . "\" border=\"0\" align=\"absmiddle\">"; if ($af->running == 1) { $output .= "</a>"; } // meta $output .= $torrentfilelink; $output .= "</td>"; // ================================================================ name $output .= "<td valign=\"bottom\">"; $output .= $detailsLinkString; $output .= $displayname; $output .= "</a>"; $output .= "</td>"; $output .= "<td align=\"right\"><font class=\"tiny\">" . formatBytesToKBMGGB($af->size) . "</font></td>"; $output .= "<td align=\"center\"><a href=\"message.php?to_user="******"\"><font class=\"tiny\">" . $torrentowner . "</font></a></td>"; $output .= "<td valign=\"bottom\"><div align=\"center\">"; if ($af->running == "2") { $output .= "<i><font color=\"#32cd32\">" . _NEW . "</font></i>"; } elseif ($af->running == "3") { $estTime = "Waiting..."; $qDateTime = ''; if (is_file($dirName . "queue/" . $alias . ".Qinfo")) { $qDateTime = date("m/d/Y H:i:s", strval(filectime($dirName . "queue/" . $alias . ".Qinfo"))); } $output .= "<i><font color=\"#000000\" onmouseover=\"return overlib('" . _QUEUED . ": " . $qDateTime . "<br>', CSSCLASS);\" onmouseout=\"return nd();\">" . _QUEUED . "</font></i>"; } else { if ($af->time_left != "" && $af->time_left != "0") { $estTime = $af->time_left; } $sql_search_time = "Select time from tf_log where action like '%Upload' and file like '" . $entry . "%'"; $result_search_time = $db->Execute($sql_search_time); list($uploaddate) = $result_search_time->FetchRow(); $lastUser = $torrentowner; $sharing = $af->sharing . "%"; $graph_width = 1; $progress_color = "#00ff00"; $background = "#000000"; $bar_width = "4"; $popup_msg = _ESTIMATEDTIME . ": " . $af->time_left; $popup_msg .= "<br>" . _DOWNLOADSPEED . ": " . $af->down_speed; $popup_msg .= "<br>" . _UPLOADSPEED . ": " . $af->up_speed; $popup_msg .= "<br>" . _SHARING . ": " . $sharing; $popup_msg .= "<br>Seeds: " . $af->seeds; $popup_msg .= "<br>Peers: " . $af->peers; $popup_msg .= "<br>" . _USER . ": " . $torrentowner; $eCount = 0; foreach ($af->errors as $key => $value) { if (strpos($value, " (x")) { $curEMsg = substr($value, strpos($value, " (x") + 3); $eCount += substr($curEMsg, 0, strpos($curEMsg, ")")); } else { $eCount += 1; } } $popup_msg .= "<br>" . _ERRORSREPORTED . ": " . strval($eCount); $popup_msg .= "<br>" . _UPLOADED . ": " . date("m/d/Y H:i:s", $uploaddate); if (is_file($dirName . $alias . ".pid")) { $timeStarted = "<br>" . _STARTED . ": " . date("m/d/Y H:i:s", strval(filectime($dirName . $alias . ".pid"))); } // incriment the totals if (!isset($cfg["total_upload"])) { $cfg["total_upload"] = 0; } if (!isset($cfg["total_download"])) { $cfg["total_download"] = 0; } $cfg["total_upload"] = $cfg["total_upload"] + GetSpeedValue($af->up_speed); $cfg["total_download"] = $cfg["total_download"] + GetSpeedValue($af->down_speed); if ($af->percent_done >= 100) { if (trim($af->up_speed) != "" && $af->running == "1") { $popup_msg .= $timeStarted; $output .= "<a href=\"JavaScript:ShowDetails('downloaddetails.php?alias=" . $alias . "&torrent=" . urlencode($entry) . "')\" style=\"font-size:7pt;\" onmouseover=\"return overlib('" . $popup_msg . "<br>', CSSCLASS);\" onmouseout=\"return nd();\">seeding (" . $af->up_speed . ") " . $sharing . "</a>"; } else { $popup_msg .= "<br>" . _ENDED . ": " . date("m/d/Y H:i:s", strval(filemtime($dirName . $alias))); $output .= "<a href=\"JavaScript:ShowDetails('downloaddetails.php?alias=" . $alias . "&torrent=" . urlencode($entry) . "')\" onmouseover=\"return overlib('" . $popup_msg . "<br>', CSSCLASS);\" onmouseout=\"return nd();\"><i><font color=red>" . _DONE . "</font></i></a>"; } $show_run = false; } else { if ($af->percent_done < 0) { $popup_msg .= $timeStarted; $output .= "<a href=\"JavaScript:ShowDetails('downloaddetails.php?alias=" . $alias . "&torrent=" . urlencode($entry) . "')\" onmouseover=\"return overlib('" . $popup_msg . "<br>', CSSCLASS);\" onmouseout=\"return nd();\"><i><font color=\"#989898\">" . _INCOMPLETE . "</font></i></a>"; $show_run = true; } else { $popup_msg .= $timeStarted; if ($af->percent_done > 1) { $graph_width = $af->percent_done; } if ($graph_width == 100) { $background = $progress_color; } $output .= "<a href=\"JavaScript:ShowDetails('downloaddetails.php?alias=" . $alias . "&torrent=" . urlencode($entry) . "')\" onmouseover=\"return overlib('" . $popup_msg . "<br>', CSSCLASS);\" onmouseout=\"return nd();\">"; $output .= "<font class=\"tiny\"><strong>" . $af->percent_done . "%</strong> @ " . $af->down_speed . "</font></a><br>"; $output .= "<table width=\"100\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"; $output .= "<tr><td background=\"themes/" . $cfg["theme"] . "/images/progressbar.gif\" bgcolor=\"" . $progress_color . "\"><img src=\"images/blank.gif\" width=\"" . $graph_width . "\" height=\"" . $bar_width . "\" border=\"0\"></td>"; $output .= "<td bgcolor=\"" . $background . "\"><img src=\"images/blank.gif\" width=\"" . (100 - $graph_width) . "\" height=\"" . $bar_width . "\" border=\"0\"></td>"; $output .= "</tr></table>"; } } } $output .= "</div></td>"; $output .= "<td><div class=\"tiny\" align=\"center\">" . $estTime . "</div></td>"; $output .= "<td><div align=center>"; $torrentDetails = _TORRENTDETAILS; if ($lastUser != "") { $torrentDetails .= "\n" . _USER . ": " . $lastUser; } $output .= "<a href=\"details.php?torrent=" . urlencode($entry); if ($af->running == 1) { $output .= "&als=false"; } $output .= "\"><img src=\"images/properties.png\" width=18 height=13 title=\"" . $torrentDetails . "\" border=0></a>"; if ($owner || IsAdmin($cfg["user"])) { if ($af->percent_done >= 0 && $af->running == 1) { $output .= "<a href=\"index.php?alias_file=" . $alias . "&kill=" . $kill_id . "&kill_torrent=" . urlencode($entry) . "\"><img src=\"images/kill.gif\" width=16 height=16 title=\"" . _STOPDOWNLOAD . "\" border=0></a>"; $output .= "<img src=\"images/delete_off.gif\" width=16 height=16 border=0>"; if ($cfg['enable_multiops'] == 1) { $output .= "<input type=\"checkbox\" name=\"torrent[]\" value=\"" . urlencode($entry) . "\">"; } } else { if ($torrentowner == "n/a") { $output .= "<img src=\"images/run_off.gif\" width=16 height=16 border=0 title=\"" . _NOTOWNER . "\">"; } else { if ($af->running == "3") { $output .= "<a href=\"index.php?alias_file=" . $alias . "&dQueue=" . $kill_id . "&QEntry=" . urlencode($entry) . "\"><img src=\"images/queued.gif\" width=16 height=16 title=\"" . _DELQUEUE . "\" border=0></a>"; } else { if (!is_file($cfg["torrent_file_path"] . $alias . ".pid")) { // Allow Avanced start popup? if ($cfg["advanced_start"] != 0) { if ($show_run) { $output .= "<a href=\"#\" onclick=\"StartTorrent('startpop.php?torrent=" . urlencode($entry) . "')\"><img src=\"images/run_on.gif\" width=16 height=16 title=\"" . _RUNTORRENT . "\" border=0></a>"; } else { $output .= "<a href=\"#\" onclick=\"StartTorrent('startpop.php?torrent=" . urlencode($entry) . "')\"><img src=\"images/seed_on.gif\" width=16 height=16 title=\"" . _SEEDTORRENT . "\" border=0></a>"; } } else { // Quick Start if ($show_run) { $output .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?torrent=" . urlencode($entry) . "\"><img src=\"images/run_on.gif\" width=16 height=16 title=\"" . _RUNTORRENT . "\" border=0></a>"; } else { $output .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?torrent=" . urlencode($entry) . "\"><img src=\"images/seed_on.gif\" width=16 height=16 title=\"" . _SEEDTORRENT . "\" border=0></a>"; } } } else { // pid file exists so this may still be running or dieing. $output .= "<img src=\"images/run_off.gif\" width=16 height=16 border=0 title=\"" . _STOPPING . "\">"; } } } if (!is_file($cfg["torrent_file_path"] . $alias . ".pid")) { $deletelink = $_SERVER['PHP_SELF'] . "?alias_file=" . $alias . "&delfile=" . urlencode($entry); $output .= "<a href=\"" . $deletelink . "\" onclick=\"return ConfirmDelete('" . $entry . "')\"><img src=\"images/delete_on.gif\" width=16 height=16 title=\"" . _DELETE . "\" border=0></a>"; if ($cfg['enable_multiops'] == 1) { $output .= "<input type=\"checkbox\" name=\"torrent[]\" value=\"" . urlencode($entry) . "\">"; } } else { // pid file present so process may be still running. don't allow deletion. $output .= "<img src=\"images/delete_off.gif\" width=16 height=16 title=\"" . _STOPPING . "\" border=0>"; if ($cfg['enable_multiops'] == 1) { $output .= "<input type=\"checkbox\" name=\"torrent[]\" value=\"" . urlencode($entry) . "\">"; } } } } else { $output .= "<img src=\"images/locked.gif\" width=16 height=16 border=0 title=\"" . _NOTOWNER . "\">"; $output .= "<img src=\"images/locked.gif\" width=16 height=16 border=0 title=\"" . _NOTOWNER . "\">"; $output .= "<input type=\"checkbox\" disabled=\"disabled\">"; } $output .= "</div>"; $output .= "</td>"; $output .= "</tr>\n"; // Is this torrent for the user list or the general list? if ($cfg["user"] == getOwner($entry)) { array_push($arUserTorrent, $output); } else { array_push($arListTorrent, $output); } } //XFER: if a new day but no .stat files where found put blank entry into the DB for today to indicate accounting has been done for the new day if ($cfg['enable_xfer'] == 1 && $cfg['xfer_realtime'] == 1) { if (isset($newday) && $newday == 1) { $sql = 'INSERT INTO tf_xfer (user_id,date) values ( "",' . $db->DBDate(time()) . ')'; $db->Execute($sql); showError($db, $sql); } getUsage(0, 'total'); $month_start = date('j') >= $cfg['month_start'] ? date('Y-m-') . $cfg['month_start'] : date('Y-m-', strtotime('-1 Month')) . $cfg['month_start']; getUsage($month_start, 'month'); $week_start = date('Y-m-d', strtotime('last ' . $cfg['week_start'])); getUsage($week_start, 'week'); $day_start = date('Y-m-d'); getUsage($day_start, 'day'); } // Now spit out the junk //XFER: return the junk as a string instead $output = '<table bgcolor="' . $cfg["table_data_bg"] . '" width="100%" bordercolor="' . $cfg["table_border_dk"] . '" border="1" cellpadding="3" cellspacing="0" class="sortable" id="transfer_table">'; if (sizeof($arUserTorrent) > 0) { $output .= "<tr>"; // first $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/bar.gif\" bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">"; switch ($sortOrder) { case 'da': // sort by date ascending $output .= '<a href="?so=dd"><font class="adminlink">#</font></a>'; $output .= ' '; $output .= '<a href="?so=dd"><img src="images/s_down.gif" width="9" height="9" border="0"></a>'; break; case 'dd': // sort by date descending $output .= '<a href="?so=da"><font class="adminlink">#</font></a>'; $output .= ' '; $output .= '<a href="?so=da"><img src="images/s_up.gif" width="9" height="9" border="0"></a>'; break; default: $output .= '<a href="?so=dd"><font class="adminlink">#</font></a>'; break; } $output .= "</div></td>"; // name $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/bar.gif\" bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">"; switch ($sortOrder) { case 'na': // sort alphabetically by name ascending $output .= '<a href="?so=nd"><font class="adminlink">' . $cfg["user"] . ": " . _TORRENTFILE . '</font></a>'; $output .= ' '; $output .= '<a href="?so=nd"><img src="images/s_down.gif" width="9" height="9" border="0"></a>'; break; case 'nd': // sort alphabetically by name descending $output .= '<a href="?so=na"><font class="adminlink">' . $cfg["user"] . ": " . _TORRENTFILE . '</font></a>'; $output .= ' '; $output .= '<a href="?so=na"><img src="images/s_up.gif" width="9" height="9" border="0"></a>'; break; default: $output .= '<a href="?so=na"><font class="adminlink">' . $cfg["user"] . ": " . _TORRENTFILE . '</font></a>'; break; } $output .= "</div></td>"; $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/bar.gif\" bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">Size</div></td>"; $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/bar.gif\" bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _USER . "</div></td>"; $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/bar.gif\" bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _STATUS . "</div></td>"; $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/bar.gif\" bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _ESTIMATEDTIME . "</div></td>"; $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/bar.gif\" bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _ADMIN . "</div></td>"; $output .= "</tr>\n"; foreach ($arUserTorrent as $torrentrow) { $output .= $torrentrow; } } // "Only Admin can see other user torrents" $boolCond = true; if ($cfg['enable_restrictivetview'] == 1) { $boolCond = IsAdmin(); } if ($boolCond && sizeof($arListTorrent) > 0) { // "Only Admin can see other user torrents" $output .= "<tr>"; // first $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/bar.gif\" bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">"; switch ($sortOrder) { case 'da': // sort by date ascending $output .= '<a href="?so=dd"><font class="adminlink">#</font></a>'; $output .= ' '; $output .= '<a href="?so=dd"><img src="images/s_down.gif" width="9" height="9" border="0"></a>'; break; case 'dd': // sort by date descending $output .= '<a href="?so=da"><font class="adminlink">#</font></a>'; $output .= ' '; $output .= '<a href="?so=da"><img src="images/s_up.gif" width="9" height="9" border="0"></a>'; break; default: $output .= '<a href="?so=dd"><font class="adminlink">#</font></a>'; break; } $output .= "</div></td>"; // name $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/bar.gif\" bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">"; switch ($sortOrder) { case 'na': // sort alphabetically by name ascending $output .= '<a href="?so=nd"><font class="adminlink">' . _TORRENTFILE . '</font></a>'; $output .= ' '; $output .= '<a href="?so=nd"><img src="images/s_down.gif" width="9" height="9" border="0"></a>'; break; case 'nd': // sort alphabetically by name descending $output .= '<a href="?so=na"><font class="adminlink">' . _TORRENTFILE . '</font></a>'; $output .= ' '; $output .= '<a href="?so=na"><img src="images/s_up.gif" width="9" height="9" border="0"></a>'; break; default: $output .= '<a href="?so=na"><font class="adminlink">' . _TORRENTFILE . '</font></a>'; break; } $output .= "</div></td>"; $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/bar.gif\" bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">Size</div></td>"; $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/bar.gif\" bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _USER . "</div></td>"; $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/bar.gif\" bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _STATUS . "</div></td>"; $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/bar.gif\" bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _ESTIMATEDTIME . "</div></td>"; $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/bar.gif\" bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _ADMIN . "</div></td>"; $output .= "</tr>\n"; foreach ($arListTorrent as $torrentrow) { $output .= $torrentrow; } } return $output; }
/** * ctor * * @param $file * @param $owner * @param $path * @param $drate * @param $retries * @param $pasv * @return WrapperWget */ function WrapperWget($file, $owner, $path, $drate, $retries, $pasv) { global $cfg; // set fields from params $this->_transfer = str_replace($cfg['transfer_file_path'], '', $file); $this->_owner = $owner; $this->_path = $path; $this->_drate = $drate; $this->_retries = $retries; $this->_pasv = $pasv; $this->_commandFile = $file . ".cmd"; // set user-var $cfg["user"] = $this->_owner; // set admin-var $cfg['isAdmin'] = IsAdmin($this->_owner); // init sf-instance $this->_sf = new StatFile($this->_transfer, $this->_owner); }
<span> Valley Christian High School, Cerritos CA</span> <span style="margin-left: 20px">2015/2016 Season</span> </div> <?php if (IsMasquerading()) { echo '<div id="footer_masquerader">['; echo GetMasquerader(); echo ']</div>'; } if (isset($timer)) { echo '<div id="footer_timer">'; echo $timer->Str(); echo '</div>'; } if (IsAdmin() && isset($config['DevBypass'])) { echo '<div id="footer_test_link"><a href="test.php">Test</a></div>' . "\n"; echo '<div style="clear: both"></div>'; } ?> <div id="footer_home_link"> <?php // <a href="pages/welcome.php">Home</a> ?> </div> </div> </div> <?php // End of screen div
$messages .= "<font color=\"#ff0000\" size=3>ERROR: The type of file you are uploading is not allowed.</font><br>"; } } else { $messages .= "<font color=\"#ff0000\" size=3>ERROR: File not uploaded, check file size limit.</font><br>"; } if ($messages != "") { // there was an error AuditAction($cfg["constants"]["error"], $cfg["constants"]["file_upload"] . " :: " . $ext_msg . $file_name); } } // End File Upload // if a file was set to be deleted then delete it $delfile = SecurityClean(getRequestVar('delfile')); if (!$delfile == '') { $alias_file = SecurityClean(getRequestVar('alias_file')); if ($cfg["user"] == getOwner($delfile) || IsAdmin()) { @unlink($cfg["torrent_file_path"] . $delfile); @unlink($cfg["torrent_file_path"] . $alias_file); // try to remove the QInfo if in case it was queued. @unlink($cfg["torrent_file_path"] . "queue/" . $alias_file . ".Qinfo"); // try to remove the pid file @unlink($cfg["torrent_file_path"] . $alias_file . ".pid"); @unlink($cfg["torrent_file_path"] . getAliasName($delfile) . ".prio"); AuditAction($cfg["constants"]["delete_torrent"], $delfile); header("location: index.php"); exit; } else { AuditAction($cfg["constants"]["error"], $cfg["user"] . " attempted to delete " . $delfile); } } // Did the user select the option to kill a running torrent?
function IsManager() { return IsStaff() || IsAdmin(); }
public function detail($id) { $projectInfo = M('Project')->where('id=%d', $id)->find(); if ($projectInfo['allow'] != 1) { if ($projectInfo['username'] == cookie('username') or IsAdmin()) { } else { $this->error('您没有访问的权限'); return; } } D('ProjectClass')->ClassFactory($projectInfo); $this->assign('proinfo', $projectInfo); $this->display(); }
<?php // -------------------------------------------------------------------- // nav_form.php -- Form for nav area that fits to left of most pages. // Include after header.php if used on a given page. // // Created: 12/29/14 DLB // -------------------------------------------------------------------- require_once "maindef.php"; $bu = $config["BaseUrl"]; echo '<div id="nav_area">'; echo '<div class="btn_nav_div"><a class="btn_nav" href="yourwork.php?Assignments=yes" > Your Work </a></div>' . "\n"; echo '<div class="btn_nav_div"><a class="btn_nav" href="wo_new.php" > New Order </a></div>' . "\n"; echo '<div class="btn_nav_div"><a class="btn_nav" href="wo_lookup.php"> Lookup </a></div>' . "\n"; if (IsAdmin() || IsEditor() || IsCaptain() || IsIPTLead()) { echo '<div class="btn_nav_div"><a class="btn_nav" href="inbox.php?Opened=Yes&UseSelfTeam=Yes" > In Box </a></div>' . "\n"; } echo '<div class="btn_nav_div"><a class="btn_nav" href="findlist_simple.php" > Find / List</a></div>' . "\n"; echo '<div class="btn_nav_div"><a class="btn_nav" href="team.php" > Team View </a></div>' . "\n"; if (IsAdmin() || IsEditor() || IsCaptain()) { echo '<div class="btn_nav_div"><a class="btn_nav" href="utils.php" > Utilities </a></div>' . "\n"; } if (IsAdmin()) { echo '<div class="btn_nav_div"><a class="btn_nav" href="admin.php" > Admin </a></div>' . "\n"; } echo '<div class="btn_nav_div"><a class="btn_nav" href="help.php" > Help </a></div>' . "\n"; echo '</div>' . "\n";
<?php if (!defined('THINK_PATH')) { exit; } ?> <!DOCTYPE HTML> <?php $auto_login = new \User\Api\UserApi(); $auto_login->autologin(); if (!IsAdmin()) { exit('Permission error'); } ?> <html class="no-js"> <head> <!doctype html> <html class="no-js"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title><?php echo C('SITE_TITLE'); ?> Admin Center</title> <meta name="description" content="这是一个 index 页面"> <meta name="keywords" content="index"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <meta name="renderer" content="webkit"> <meta http-equiv="Cache-Control" content="no-siteapp" /> <link rel="icon" type="image/png" href="assets/i/favicon.png">
function getTransferList() { global $cfg, $db; include_once "AliasFile.php"; $kill_id = ""; $lastUser = ""; $arUserTorrent = array(); $arListTorrent = array(); // settings $settings = convertIntegerToArray($cfg["index_page_settings"]); // sortOrder $sortOrder = getRequestVar("so"); if ($sortOrder == "") { $sortOrder = $cfg["index_page_sortorder"]; } // t-list $arList = getTransferArray($sortOrder); foreach ($arList as $entry) { // --------------------------------------------------------------------- // init some vars $displayname = $entry; $show_run = true; $torrentowner = getOwner($entry); $owner = IsOwner($cfg["user"], $torrentowner); if (strlen($entry) >= 47) { // needs to be trimmed $displayname = substr($entry, 0, 44); $displayname .= "..."; } if ($cfg["enable_torrent_download"]) { $torrentfilelink = "<a href=\"maketorrent.php?download=" . urlencode($entry) . "\"><img src=\"images/down.gif\" width=9 height=9 title=\"Download Torrent File\" border=0 align=\"absmiddle\"></a>"; } else { $torrentfilelink = ""; } // --------------------------------------------------------------------- // alias / stat $alias = getAliasName($entry) . ".stat"; if (substr(strtolower($entry), -8) == ".torrent") { // this is a torrent-client $btclient = getTorrentClient($entry); $af = AliasFile::getAliasFileInstance($cfg["torrent_file_path"] . $alias, $torrentowner, $cfg, $btclient); } else { if (substr(strtolower($entry), -4) == ".url") { // this is wget. use tornado statfile $btclient = "wget"; $alias = str_replace(".url", "", $alias); $af = AliasFile::getAliasFileInstance($cfg["torrent_file_path"] . $alias, $cfg['user'], $cfg, 'tornado'); } else { $btclient = "tornado"; // this is "something else". use tornado statfile as default $af = AliasFile::getAliasFileInstance($cfg["torrent_file_path"] . $alias, $cfg['user'], $cfg, 'tornado'); } } // cache running-flag in local var. we will access that often $transferRunning = (int) $af->running; // cache percent-done in local var. ... $percentDone = $af->percent_done; // more vars $detailsLinkString = "<a style=\"font-size:9px; text-decoration:none;\" href=\"JavaScript:ShowDetails('downloaddetails.php?alias=" . $alias . "&torrent=" . urlencode($entry) . "')\">"; // --------------------------------------------------------------------- //XFER: add upload/download stats to the xfer array if ($cfg['enable_xfer'] == 1 && $cfg['xfer_realtime'] == 1) { if ($btclient != "wget") { $torrentTotalsCurrent = getTorrentTotalsCurrentOP($entry, $btclient, $af->uptotal, $af->downtotal); } else { $torrentTotalsCurrent["uptotal"] = $af->uptotal; $torrentTotalsCurrent["downtotal"] = $af->downtotal; } $sql = 'SELECT 1 FROM tf_xfer WHERE date = ' . $db->DBDate(time()); $newday = !$db->GetOne($sql); showError($db, $sql); sumUsage($torrentowner, $torrentTotalsCurrent["downtotal"] + 0, $torrentTotalsCurrent["uptotal"] + 0, 'total'); sumUsage($torrentowner, $torrentTotalsCurrent["downtotal"] + 0, $torrentTotalsCurrent["uptotal"] + 0, 'month'); sumUsage($torrentowner, $torrentTotalsCurrent["downtotal"] + 0, $torrentTotalsCurrent["uptotal"] + 0, 'week'); sumUsage($torrentowner, $torrentTotalsCurrent["downtotal"] + 0, $torrentTotalsCurrent["uptotal"] + 0, 'day'); //XFER: if new day add upload/download totals to last date on record and subtract from today in SQL if ($newday) { $newday = 2; $sql = 'SELECT date FROM tf_xfer ORDER BY date DESC'; $lastDate = $db->GetOne($sql); showError($db, $sql); // MySQL 4.1.0 introduced 'ON DUPLICATE KEY UPDATE' to make this easier $sql = 'SELECT 1 FROM tf_xfer WHERE user_id = "' . $torrentowner . '" AND date = "' . $lastDate . '"'; if ($db->GetOne($sql)) { $sql = 'UPDATE tf_xfer SET download = download+' . ($torrentTotalsCurrent["downtotal"] + 0) . ', upload = upload+' . ($torrentTotalsCurrent["uptotal"] + 0) . ' WHERE user_id = "' . $torrentowner . '" AND date = "' . $lastDate . '"'; $db->Execute($sql); showError($db, $sql); } else { showError($db, $sql); $sql = 'INSERT INTO tf_xfer (user_id,date,download,upload) values ("' . $torrentowner . '","' . $lastDate . '",' . ($torrentTotalsCurrent["downtotal"] + 0) . ',' . ($torrentTotalsCurrent["uptotal"] + 0) . ')'; $db->Execute($sql); showError($db, $sql); } $sql = 'SELECT 1 FROM tf_xfer WHERE user_id = "' . $torrentowner . '" AND date = ' . $db->DBDate(time()); if ($db->GetOne($sql)) { $sql = 'UPDATE tf_xfer SET download = download-' . ($torrentTotalsCurrent["downtotal"] + 0) . ', upload = upload-' . ($torrentTotalsCurrent["uptotal"] + 0) . ' WHERE user_id = "' . $torrentowner . '" AND date = ' . $db->DBDate(time()); $db->Execute($sql); showError($db, $sql); } else { showError($db, $sql); $sql = 'INSERT INTO tf_xfer (user_id,date,download,upload) values ("' . $torrentowner . '",' . $db->DBDate(time()) . ',-' . ($torrentTotalsCurrent["downtotal"] + 0) . ',-' . ($torrentTotalsCurrent["uptotal"] + 0) . ')'; $db->Execute($sql); showError($db, $sql); } } } // --------------------------------------------------------------------- // injects if (!file_exists($cfg["torrent_file_path"] . $alias)) { $transferRunning = 2; $af->running = "2"; $af->size = getDownloadSize($cfg["torrent_file_path"] . $entry); $af->WriteFile(); } // --------------------------------------------------------------------- // preprocess alias-file and get some vars $estTime = " "; $statusStr = " "; switch ($transferRunning) { case 2: // new // $statusStr $statusStr = $detailsLinkString . "<font color=\"#32cd32\">New</font></a>"; break; case 3: // queued // $statusStr $statusStr = $detailsLinkString . "Queued</a>"; // $estTime $estTime = "Waiting..."; break; default: // running // increment the totals if (!isset($cfg["total_upload"])) { $cfg["total_upload"] = 0; } if (!isset($cfg["total_download"])) { $cfg["total_download"] = 0; } $cfg["total_upload"] = $cfg["total_upload"] + GetSpeedValue($af->up_speed); $cfg["total_download"] = $cfg["total_download"] + GetSpeedValue($af->down_speed); // $estTime if ($af->time_left != "" && $af->time_left != "0") { $estTime = $af->time_left; } // $lastUser $lastUser = $torrentowner; // $show_run + $statusStr if ($percentDone >= 100) { if (trim($af->up_speed) != "" && $transferRunning == 1) { $statusStr = $detailsLinkString . 'Seeding</a>'; } else { $statusStr = $detailsLinkString . 'Done</a>'; } $show_run = false; } else { if ($percentDone < 0) { $statusStr = $detailsLinkString . "Stopped</a>"; $show_run = true; } else { $statusStr = $detailsLinkString . "Leeching</a>"; } } break; } // totals-preparation // if downtotal + uptotal + progress > 0 if ($settings[2] + $settings[3] + $settings[5] > 0) { if ($btclient != "wget") { $torrentTotals = getTorrentTotalsOP($entry, $btclient, $af->uptotal, $af->downtotal); } else { $torrentTotals["uptotal"] = $af->uptotal; $torrentTotals["downtotal"] = $af->downtotal; } } // --------------------------------------------------------------------- // output-string $output = "<tr>"; // ========================================================== led + meta $output .= '<td valign="bottom" align="center">'; // led $hd = getStatusImage($af); if ($transferRunning == 1) { $output .= "<a href=\"JavaScript:ShowDetails('downloadhosts.php?alias=" . $alias . "&torrent=" . urlencode($entry) . "')\">"; } $output .= "<img src=\"images/" . $hd->image . "\" width=\"16\" height=\"16\" title=\"" . $hd->title . $entry . "\" border=\"0\" align=\"absmiddle\">"; if ($transferRunning == 1) { $output .= "</a>"; } // meta $output .= $torrentfilelink; $output .= "</td>"; // ================================================================ name $output .= "<td valign=\"bottom\">" . $detailsLinkString . $displayname . "</a></td>"; // =============================================================== owner if ($settings[0] != 0) { $output .= "<td valign=\"bottom\" align=\"center\"><a href=\"message.php?to_user="******"\"><font class=\"tiny\">" . $torrentowner . "</font></a></td>"; } // ================================================================ size if ($settings[1] != 0) { $output .= "<td valign=\"bottom\" align=\"right\" nowrap>" . $detailsLinkString . formatBytesToKBMGGB($af->size) . "</a></td>"; } // =========================================================== downtotal if ($settings[2] != 0) { $output .= "<td valign=\"bottom\" align=\"right\" nowrap>" . $detailsLinkString . formatBytesToKBMGGB($torrentTotals["downtotal"] + 0) . "</a></td>"; } // ============================================================= uptotal if ($settings[3] != 0) { $output .= "<td valign=\"bottom\" align=\"right\" nowrap>" . $detailsLinkString . formatBytesToKBMGGB($torrentTotals["uptotal"] + 0) . "</a></td>"; } // ============================================================== status if ($settings[4] != 0) { $output .= "<td valign=\"bottom\" align=\"center\">" . $detailsLinkString . $statusStr . "</a></td>"; } // ============================================================ progress if ($settings[5] != 0) { $graph_width = 1; $progress_color = "#00ff00"; $background = "#000000"; $bar_width = "4"; $percentage = ""; if ($percentDone >= 100 && trim($af->up_speed) != "") { $graph_width = -1; $percentage = @number_format($torrentTotals["uptotal"] / $af->size * 100, 2) . '%'; } else { if ($percentDone >= 1) { $graph_width = $percentDone; $percentage = $graph_width . '%'; } else { if ($percentDone < 0) { $graph_width = round($percentDone * -1 - 100, 1); $percentage = $graph_width . '%'; } else { $graph_width = 0; $percentage = '0%'; } } } if ($graph_width == 100) { $background = $progress_color; } $output .= "<td valign=\"bottom\" align=\"center\" nowrap>"; if ($graph_width == -1) { $output .= $detailsLinkString . '<strong>' . $percentage . '</strong></a>'; } else { if ($graph_width > 0) { $output .= $detailsLinkString . '<strong>' . $percentage . '</strong></a>'; $output .= "<br>"; $output .= "<table width=\"100\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr>"; $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/progressbar.gif\" bgcolor=\"" . $progress_color . "\">" . $detailsLinkString . "<img src=\"images/blank.gif\" width=\"" . $graph_width . "\" height=\"" . $bar_width . "\" border=\"0\"></a></td>"; $output .= "<td bgcolor=\"" . $background . "\">" . $detailsLinkString . "<img src=\"images/blank.gif\" width=\"" . (100 - $graph_width) . "\" height=\"" . $bar_width . "\" border=\"0\"></a></td>"; $output .= "</tr></table>"; } else { if ($transferRunning == 2) { $output .= ' '; } else { $output .= $detailsLinkString . '<strong>' . $percentage . '</strong></a>'; $output .= "<br>"; $output .= "<table width=\"100\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr>"; $output .= "<td background=\"themes/" . $cfg["theme"] . "/images/progressbar.gif\" bgcolor=\"" . $progress_color . "\">" . $detailsLinkString . "<img src=\"images/blank.gif\" width=\"" . $graph_width . "\" height=\"" . $bar_width . "\" border=\"0\"></a></td>"; $output .= "<td bgcolor=\"" . $background . "\">" . $detailsLinkString . "<img src=\"images/blank.gif\" width=\"" . (100 - $graph_width) . "\" height=\"" . $bar_width . "\" border=\"0\"></a></td>"; $output .= "</tr></table>"; } } } $output .= "</td>"; } // ================================================================ down if ($settings[6] != 0) { $output .= '<td valign="bottom" align="right" class="tiny" nowrap>'; if ($transferRunning == 1) { $output .= $detailsLinkString; if (trim($af->down_speed) != "") { $output .= $af->down_speed; } else { $output .= '0.0 kB/s'; } $output .= '</a>'; } else { $output .= ' '; } $output .= '</td>'; } // ================================================================== up if ($settings[7] != 0) { $output .= '<td valign="bottom" align="right" class="tiny" nowrap>'; if ($transferRunning == 1) { $output .= $detailsLinkString; if (trim($af->up_speed) != "") { $output .= $af->up_speed; } else { $output .= '0.0 kB/s'; } $output .= '</a>'; } else { $output .= ' '; } $output .= '</td>'; } // =============================================================== seeds if ($settings[8] != 0) { $output .= '<td valign="bottom" align="right" class="tiny" nowrap>'; if ($transferRunning == 1) { $output .= $detailsLinkString; $output .= $af->seeds; $output .= '</a>'; } else { $output .= ' '; } $output .= '</td>'; } // =============================================================== peers if ($settings[9] != 0) { $output .= '<td valign="bottom" align="right" class="tiny" nowrap>'; if ($transferRunning == 1) { $output .= $detailsLinkString; $output .= $af->peers; $output .= '</a>'; } else { $output .= ' '; } $output .= '</td>'; } // ================================================================= ETA if ($settings[10] != 0) { $output .= "<td valign=\"bottom\" align=\"center\">" . $detailsLinkString . $estTime . "</a></td>"; } // ============================================================== client if ($settings[11] != 0) { switch ($btclient) { case "tornado": $output .= "<td valign=\"bottom\" align=\"center\">B</a></td>"; break; case "transmission": $output .= "<td valign=\"bottom\" align=\"center\">T</a></td>"; break; case "wget": $output .= "<td valign=\"bottom\" align=\"center\">W</a></td>"; break; default: $output .= "<td valign=\"bottom\" align=\"center\">U</a></td>"; } } // =============================================================== admin $output .= "<td><div align=center>"; $torrentDetails = _TORRENTDETAILS; if ($lastUser != "") { $torrentDetails .= "\n" . _USER . ": " . $lastUser; } $output .= "<a href=\"details.php?torrent=" . urlencode($entry); if ($transferRunning == 1) { $output .= "&als=false"; } $output .= "\"><img src=\"images/properties.png\" width=18 height=13 title=\"" . $torrentDetails . "\" border=0></a>"; if ($owner || IsAdmin($cfg["user"])) { if ($percentDone >= 0 && $transferRunning == 1) { $output .= "<a href=\"index.php?alias_file=" . $alias . "&kill=" . $kill_id . "&kill_torrent=" . urlencode($entry) . "\"><img src=\"images/kill.gif\" width=16 height=16 title=\"" . _STOPDOWNLOAD . "\" border=0></a>"; $output .= "<img src=\"images/delete_off.gif\" width=16 height=16 border=0>"; if ($cfg['enable_multiops'] != 0) { $output .= "<input type=\"checkbox\" name=\"torrent[]\" value=\"" . urlencode($entry) . "\">"; } } else { if ($torrentowner == "n/a") { $output .= "<img src=\"images/run_off.gif\" width=16 height=16 border=0 title=\"" . _NOTOWNER . "\">"; } else { if ($transferRunning == 3) { $output .= "<a href=\"index.php?alias_file=" . $alias . "&dQueue=" . $kill_id . "&QEntry=" . urlencode($entry) . "\"><img src=\"images/queued.gif\" width=16 height=16 title=\"" . _DELQUEUE . "\" border=0></a>"; } else { if (!is_file($cfg["torrent_file_path"] . $alias . ".pid")) { // Allow Avanced start popup? if ($cfg["advanced_start"] != 0) { if ($show_run) { $output .= "<a href=\"#\" onclick=\"StartTorrent('startpop.php?torrent=" . urlencode($entry) . "')\"><img src=\"images/run_on.gif\" width=16 height=16 title=\"" . _RUNTORRENT . "\" border=0></a>"; } else { $output .= "<a href=\"#\" onclick=\"StartTorrent('startpop.php?torrent=" . urlencode($entry) . "')\"><img src=\"images/seed_on.gif\" width=16 height=16 title=\"" . _SEEDTORRENT . "\" border=0></a>"; } } else { // Quick Start if ($show_run) { $output .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?torrent=" . urlencode($entry) . "\"><img src=\"images/run_on.gif\" width=16 height=16 title=\"" . _RUNTORRENT . "\" border=0></a>"; } else { $output .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?torrent=" . urlencode($entry) . "\"><img src=\"images/seed_on.gif\" width=16 height=16 title=\"" . _SEEDTORRENT . "\" border=0></a>"; } } } else { // pid file exists so this may still be running or dieing. $output .= "<img src=\"images/run_off.gif\" width=16 height=16 border=0 title=\"" . _STOPPING . "\">"; } } } if (!is_file($cfg["torrent_file_path"] . $alias . ".pid")) { $deletelink = $_SERVER['PHP_SELF'] . "?alias_file=" . $alias . "&delfile=" . urlencode($entry); $output .= "<a href=\"" . $deletelink . "\" onclick=\"return ConfirmDelete('" . $entry . "')\"><img src=\"images/delete_on.gif\" width=16 height=16 title=\"" . _DELETE . "\" border=0></a>"; if ($cfg['enable_multiops'] != 0) { $output .= "<input type=\"checkbox\" name=\"torrent[]\" value=\"" . urlencode($entry) . "\">"; } } else { // pid file present so process may be still running. don't allow deletion. $output .= "<img src=\"images/delete_off.gif\" width=16 height=16 title=\"" . _STOPPING . "\" border=0>"; if ($cfg['enable_multiops'] != 0) { $output .= "<input type=\"checkbox\" name=\"torrent[]\" value=\"" . urlencode($entry) . "\">"; } } } } else { $output .= "<img src=\"images/locked.gif\" width=16 height=16 border=0 title=\"" . _NOTOWNER . "\">"; $output .= "<img src=\"images/locked.gif\" width=16 height=16 border=0 title=\"" . _NOTOWNER . "\">"; $output .= "<input type=\"checkbox\" disabled=\"disabled\">"; } $output .= "</div>"; $output .= "</td>"; $output .= "</tr>\n"; // --------------------------------------------------------------------- // Is this torrent for the user list or the general list? if ($cfg["user"] == getOwner($entry)) { array_push($arUserTorrent, $output); } else { array_push($arListTorrent, $output); } } //XFER: if a new day but no .stat files where found put blank entry into the DB for today to indicate accounting has been done for the new day if ($cfg['enable_xfer'] == 1 && $cfg['xfer_realtime'] == 1) { if (isset($newday) && $newday == 1) { $sql = 'INSERT INTO tf_xfer (user_id,date) values ( "",' . $db->DBDate(time()) . ')'; $db->Execute($sql); showError($db, $sql); } getUsage(0, 'total'); $month_start = date('j') >= $cfg['month_start'] ? date('Y-m-') . $cfg['month_start'] : date('Y-m-', strtotime('-1 Month')) . $cfg['month_start']; getUsage($month_start, 'month'); $week_start = date('Y-m-d', strtotime('last ' . $cfg['week_start'])); getUsage($week_start, 'week'); $day_start = date('Y-m-d'); getUsage($day_start, 'day'); } // ------------------------------------------------------------------------- // build output-string $output = '<table bgcolor="' . $cfg["table_data_bg"] . '" width="100%" bordercolor="' . $cfg["table_border_dk"] . '" border="1" cellpadding="3" cellspacing="0" class="sortable" id="transfer_table">'; if (sizeof($arUserTorrent) > 0) { $output .= getTransferTableHead($settings, $sortOrder, $cfg["user"] . " : "); foreach ($arUserTorrent as $torrentrow) { $output .= $torrentrow; } } $boolCond = true; if ($cfg['enable_restrictivetview'] == 1) { $boolCond = IsAdmin(); } if ($boolCond && sizeof($arListTorrent) > 0) { $output .= getTransferTableHead($settings, $sortOrder); foreach ($arListTorrent as $torrentrow) { $output .= $torrentrow; } } $output .= "</tr></table>\n"; return $output; }
/** * prepares start of a bittorrent-client. * prepares vars and other generic stuff * @param $torrent name of the torrent * @param $interactive (1|0) : is this a interactive startup with dialog ? */ function prepareStartTorrentClient($torrent, $interactive) { if ($this->status < 1) { $this->status = -1; $this->messages .= "Error. ClientHandler in wrong state on prepare-request."; return; } $this->skip_hash_check = ""; if ($interactive == 1) { // interactive, get vars from request vars $this->rate = getRequestVar('rate'); if (empty($this->rate)) { if ($this->rate != "0") { $this->rate = $this->cfg["max_upload_rate"]; } } $this->drate = getRequestVar('drate'); if (empty($this->drate)) { if ($this->drate != "0") { $this->drate = $this->cfg["max_download_rate"]; } } $this->superseeder = getRequestVar('superseeder'); if (empty($this->superseeder)) { $this->superseeder = "0"; } // should be 0 in most cases $this->runtime = getRequestVar('runtime'); if (empty($this->runtime)) { $this->runtime = $this->cfg["torrent_dies_when_done"]; } $this->maxuploads = getRequestVar('maxuploads'); if (empty($this->maxuploads)) { if ($this->maxuploads != "0") { $this->maxuploads = $this->cfg["max_uploads"]; } } $this->minport = getRequestVar('minport'); if (empty($this->minport)) { $this->minport = $this->cfg["minport"]; } $this->maxport = getRequestVar('maxport'); if (empty($this->maxport)) { $this->maxport = $this->cfg["maxport"]; } $this->maxcons = getRequestVar('maxcons'); if (empty($this->maxcons)) { $this->maxcons = $this->cfg["maxcons"]; } $this->rerequest = getRequestVar("rerequest"); if (empty($this->rerequest)) { $this->rerequest = $this->cfg["rerequest_interval"]; } $this->sharekill = getRequestVar('sharekill'); if ($this->runtime == "True") { $this->sharekill = "-1"; } if (empty($this->sharekill)) { if ($this->sharekill != "0") { $this->sharekill = $this->cfg["sharekill"]; } } $this->savepath = getRequestVar('savepath'); $this->skip_hash_check = getRequestVar('skiphashcheck'); } else { // non-interactive, load settings from db and set vars $this->rerequest = $this->cfg["rerequest_interval"]; $this->skip_hash_check = $this->cfg["skiphashcheck"]; $this->superseeder = 0; // load settings $settingsAry = loadTorrentSettings(urldecode($torrent)); $this->rate = $settingsAry["max_upload_rate"]; $this->drate = $settingsAry["max_download_rate"]; $this->runtime = $settingsAry["torrent_dies_when_done"]; $this->maxuploads = $settingsAry["max_uploads"]; $this->minport = $settingsAry["minport"]; $this->maxport = $settingsAry["maxport"]; $this->maxcons = $settingsAry["maxcons"]; $this->sharekill = $settingsAry["sharekill"]; $this->savepath = $settingsAry["savepath"]; // fallback-values if fresh-torrent is started non-interactive or // something else strange happened if ($this->rate == '') { $this->rate = $this->cfg["max_upload_rate"]; } if ($this->drate == '') { $this->drate = $this->cfg["max_download_rate"]; } if ($this->runtime == '') { $this->runtime = $this->cfg["torrent_dies_when_done"]; } if ($this->maxuploads == '') { $this->maxuploads = $this->cfg["max_uploads"]; } if ($this->minport == '') { $this->minport = $this->cfg["minport"]; } if ($this->maxport == '') { $this->maxport = $this->cfg["maxport"]; } if ($this->maxcons == '') { $this->maxcons = $this->cfg["maxcons"]; } if ($this->sharekill == '') { $this->sharekill = $this->cfg["sharekill"]; } } // queue if ($this->cfg["AllowQueing"]) { if (IsAdmin()) { $this->queue = getRequestVar('queue'); if ($this->queue == 'on') { $this->queue = "1"; } else { $this->queue = "0"; } } else { $this->queue = "1"; } } else { $this->queue = "0"; } // $this->torrent = urldecode($torrent); $this->alias = getAliasName($this->torrent); $this->owner = getOwner($this->torrent); if (empty($this->savepath)) { $this->savepath = $this->cfg['path'] . $this->owner . "/"; } // ensure path has trailing slash $this->savepath = checkDirPathString($this->savepath); // The following lines of code were suggested by Jody Steele jmlsteele@stfu.ca // This is to help manage user downloads by their user names // if the user's path doesnt exist, create it if (!is_dir($this->cfg["path"] . "/" . $this->owner)) { if (is_writable($this->cfg["path"])) { mkdir($this->cfg["path"] . "/" . $this->owner, 0777); } else { AuditAction($this->cfg["constants"]["error"], "Error -- " . $this->cfg["path"] . " is not writable."); if (IsAdmin()) { $this->status = -1; header("location: admin.php?op=configSettings"); return; } else { $this->status = -1; $this->messages .= "Error. TorrentFlux settings are not correct (path is not writable) -- please contact an admin."; } } } // create AliasFile object and write out the stat file include_once "AliasFile.php"; $this->af = AliasFile::getAliasFileInstance($this->cfg["torrent_file_path"] . $this->alias . ".stat", $this->owner, $this->cfg, $this->handlerName); //XFER: before a torrent start/restart save upload/download xfer to SQL $torrentTotals = getTorrentTotalsCurrent($this->torrent); saveXfer($this->owner, $torrentTotals["downtotal"] + 0, $torrentTotals["uptotal"] + 0); // update totals for this torrent updateTorrentTotals($this->torrent); // set param for sharekill if ($this->sharekill <= 0) { // nice, we seed forever $this->sharekill_param = 0; } else { // recalc sharekill $totalAry = getTorrentTotals(urldecode($torrent)); $upTotal = $totalAry["uptotal"] + 0; $torrentSize = $this->af->size + 0; $upWanted = $this->sharekill / 100 * $torrentSize; if ($upTotal >= $upWanted) { // we already have seeded at least // wanted percentage. continue to seed // forever is suitable in this case ~~ $this->sharekill_param = 0; } else { // not done seeding wanted percentage $this->sharekill_param = (int) ($this->sharekill - $upTotal / $torrentSize * 100); // the type-cast may have floored the value. (tornado lacks // precision because only (really?) accepting percentage-values) // better to seed more than less so we add a percent in case ;) if ($upWanted % $upTotal != 0) { $this->sharekill_param += 1; } // sanity-check. if ($this->sharekill_param <= -1) { $this->sharekill_param = 0; } } } if ($this->cfg["AllowQueing"]) { if ($this->queue == "1") { $this->af->QueueTorrentFile(); // this only writes out the stat file (does not start torrent) } else { if ($this->setClientPort() === false) { return; } $this->af->StartTorrentFile(); // this only writes out the stat file (does not start torrent) } } else { if ($this->setClientPort() === false) { return; } $this->af->StartTorrentFile(); // this only writes out the stat file (does not start torrent) } $this->status = 2; }