function FormSitePdfConfig(&$template, $siteAdmin, $pdfId = null) { parent::Form($template); $this->siteAdmin = $siteAdmin; $confpdf = new PdfConfigDb($siteAdmin); $this->tpl->assign('choix_pdf', $confpdf->getChoixPdf()); $this->tpl->assign('default_pdf', $confpdf->getDefaultPdf()); $this->tpl->assign('siteAdmin', $siteAdmin); $this->tpl->assign('pdfId', $pdfId); // case modify a pdf if (!is_null($pdfId)) { $o_pdf = $confpdf->getPdf($pdfId); $setDefault = getRequestVar("default", "false", "string"); if ($setDefault == "true") { $o_pdf->pdfParam = $confpdf->getDefaultPdf(); } $this->pdfId = $pdfId; $this->pdfName = $o_pdf->pdfName; $this->pdfParam = $o_pdf->pdfParam; $this->tpl->assign('pdf', $o_pdf); } else { // Add PDF : add a blank page //$paramPdf = array(array (PDF_KEY_FREE_PAGE, "false", "false")); $paramPdf = array(); $o_pdf = new PdfConfig("", $paramPdf, ""); $this->tpl->assign('pdf', $o_pdf); } }
function getLatest() { $cat = getRequestVar('mainGenre'); if (empty($cat)) { $cat = getRequestVar('c'); } if (!empty($cat)) { $request = "/browse"; if (strpos($request, "?")) { $request .= "&c=" . $cat; } else { $request .= "?c=" . $cat; } } else { $request = "/?do=latest"; } if (!empty($this->pg)) { if (strpos($request, "?")) { $request .= "&p=" . $this->pg; } else { $request .= "?p=" . $this->pg; } } $request .= "&o=72"; // Sort Newest to Oldest //$request .= "&o=52"; // Sort Most Seeded if ($this->makeRequest($request)) { return $this->parseResponse(); } else { return $this->msg; } }
function performSearch($searchTerm) { if ($searchTerm == "") { $request = "/"; } else { $searchTerm = str_replace(" ", "+", $searchTerm); $request = "/search.php?terms=" . $searchTerm; } $cat = getRequestVar("cat"); if (empty($cat)) { $cat = getRequestVar("mainGenre"); } if (!empty($cat)) { if (strpos($request, "?")) { $request .= "&cat=" . $cat; } else { $request .= "?cat=" . $cat; } } if (!empty($this->pg)) { if (strpos($request, "?")) { $request .= "&page=" . $this->pg; } else { $request .= "?page=" . $this->pg; } } if ($this->makeRequest($request)) { return $this->parseResponse(); } else { return $this->msg; } }
function needAPdf($idSite) { $idPdf = getRequestVar('idPdf', false, 'int'); if (!$idPdf) { $pdfDb = new PdfConfigDb($idSite); $this->tpl->assign('pdf_available', $pdfDb->getListPdf()); $this->tpl->template = "admin/site_pdf_selection.tpl"; $ret = false; } else { $ret = $idPdf; } return $ret; }
function setPriority($torrent) { global $cfg; // we will use this to determine if we should create a prio file. // if the user passes all 1's then they want the whole thing. // so we don't need to create a prio file. // if there is a -1 in the array then they are requesting // to skip a file. so we will need to create the prio file. $okToCreate = false; if (!empty($torrent)) { $alias = getAliasName($torrent); $fileName = $cfg["torrent_file_path"] . $alias . ".prio"; $result = array(); // b4rt-4 //$files = array_filter($_REQUEST['files'],"getFile"); $files = array(); if (isset($_REQUEST['files'])) { $files = array_filter($_REQUEST['files'], "getFile"); } // b4rt-4 // if there are files to get then process and create a prio file. if (count($files) > 0) { for ($i = 0; $i < getRequestVar('count'); $i++) { if (in_array($i, $files)) { array_push($result, 1); } else { $okToCreate = true; array_push($result, -1); } } $alias = getAliasName($torrent); if ($okToCreate) { $fp = fopen($fileName, "w"); fwrite($fp, getRequestVar('filecount') . ","); fwrite($fp, implode($result, ',')); fclose($fp); } else { // No files to skip so must be wanting them all. // So we will remove the prio file. @unlink($fileName); } } else { // No files selected so must be wanting them all. // So we will remove the prio file. @unlink($fileName); } } }
function showMyProposalPage() { //TODO check for the role of current user $role = getRole(); if (!Users::isStudent()) { echo t('You can only see this page as a student'); return; } //Get my groups $my_proposals = Proposal::getInstance()->getMyProposals(); //::getGroups(_ORGANISATION_GROUP); if (!$my_proposals) { echo t('You have no proposal at the moment.') . '<br/>'; echo "<a href='" . _WEB_URL . "/projects/browse'>" . t('Please find yourself a project') . "</a>."; } else { $current_tab = getRequestVar('new_tab', 0); showMyProposals($my_proposals, $current_tab); } }
function process($indexLang = null) { if (!is_null($indexLang)) { $this->addElement('header', 'headertext', $GLOBALS['lang'][$indexLang]); } $this->addElement('submit', 'submit', $GLOBALS['lang']['install_valider']); $this->addElement('submit', 'back', $GLOBALS['lang']['admin_retour']); if ($this->getSubmitValue('back') === $GLOBALS['lang']['admin_retour']) { $tmpIdSite = getRequestVar('site', -1, 'int'); if ($tmpIdSite > 0) { Request::redirectToModule('admin_index&site=' . $tmpIdSite . '&adminsite=' . $tmpIdSite); } else { Request::redirectToModule('admin_index'); } } else { if ($this->validate()) { $this->postProcess(); return true; } else { $this->display(); return false; } } }
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; }
function parseResponse($latest = true) { $thing = $this->htmlPage; if (strpos($thing, "Not logged in!") > 0) { $tmpStr = substr($thing, strpos($thing, "takelogin")); $tmpStr = substr($tmpStr, strpos($tmpStr, ">") + 1); $tmpStr2 = "<form method=\"post\" action=\"http://" . $this->mainURL . "/takelogin.php\">"; $tmpStr = substr($tmpStr, 0, strpos($tmpStr, "</form>") + strlen("</form>")); $output = $tmpStr2 . str_replace("src=\"", "src=\"http://" . $this->mainURL . "/", $tmpStr) . "</table>"; } else { $output = $this->tableHeader(); if (strpos($thing, "Error:") > 0) { $tmpStr = substr($thing, strpos($thing, "Error:") + strlen("Error:")); $tmpStr = substr($tmpStr, 0, strpos($tmpStr, "</p>")); $this->msg = strip_tags($tmpStr); return $output . "<center>" . $this->msg . "</center><br>"; } // We got a response so display it. // Chop the front end off. $thing = substr($thing, strpos($thing, ">Upped by<")); $thing = substr($thing, strpos($thing, "<tr>") + strlen("<tr>")); //$tmpList = substr($thing,0,strpos($thing,"</table>")); // ok so now we have the listing. $tmpListArr = split("</tr>", $thing); $bg = $this->cfg["bgLight"]; //var_export($tmpListArr); foreach ($tmpListArr as $key => $value) { $buildLine = true; if (strpos($value, "id=")) { $ts = new OinkMe($value); // Determine if we should build this output /*if (is_int(array_search($ts->MainId,$this->catFilter))) { $buildLine = false; } if ($this->hideSeedless == "yes") { if($ts->Seeds == "N/A" || $ts->Seeds == "0") { $buildLine = false; } }*/ if (!empty($ts->torrentFile) && $buildLine) { $output .= trim($ts->BuildOutput($bg, $this->searchURL())); // ok switch colors. if ($bg == $this->cfg["bgLight"]) { $bg = $this->cfg["bgDark"]; } else { $bg = $this->cfg["bgLight"]; } } } } // set thing to end of this table. $thing = substr($thing, strpos($thing, "</table>")); $output .= "</table>"; // is there paging at the bottom? if (strpos($thing, "page=") != false) { // Yes, then lets grab it and display it! ;) $pages = substr($thing, strpos($thing, "<p")); $pages = substr($pages, strpos($pages, ">")); $pages = substr($pages, 0, strpos($pages, "</p>")); $pages = str_replace(" ", '', $pages); $tmpPageArr = split("</a>", $pages); array_pop($tmpPageArr); $pagesout = ''; foreach ($tmpPageArr as $key => $value) { $value .= "</a> "; $tmpVal = substr($value, strpos($value, "browse.php?"), strpos($value, ">") - 1); $pgNum = substr($tmpVal, strpos($tmpVal, "page=") + strlen("page=")); $pagesout .= str_replace($tmpVal, "XXXURLXXX" . $pgNum, $value); } $cat = getRequestVar('mainGenre'); if (strpos($this->curRequest, "LATEST")) { if (!empty($cat)) { $pages = str_replace("XXXURLXXX", $this->searchURL() . "&LATEST=1&cat=" . $cat . "&pg=", $pagesout); } else { $pages = str_replace("XXXURLXXX", $this->searchURL() . "&LATEST=1&pg=", $pagesout); } } else { if (!empty($cat)) { $pages = str_replace("XXXURLXXX", $this->searchURL() . "&searchterm=" . $_REQUEST["searchterm"] . "&cat=" . $cat . "&pg=", $pagesout); } else { $pages = str_replace("XXXURLXXX", $this->searchURL() . "&searchterm=" . $_REQUEST["searchterm"] . "&pg=", $pagesout); } } // $pages = strip_tags($pages,"<a><b>"); $output .= "<div align=center>" . substr($pages, 1) . "</div>"; } } return $output; }
function performSearch($searchTerm) { $searchTerm = str_replace(" ", "+", $searchTerm); $request = "/torrents-search.php?search=" . $searchTerm; if (!empty($cat)) { $request .= "&cat=" . $cat; } $onlyname = getRequestVar('onlyname'); if (empty($onlyname)) { $onlyname = "no"; } $request .= "&onlyname=" . $onlyname; $incldead = getRequestVar('incldead'); if (empty($incldead)) { $incldead = "0"; } $request .= "&incldead=" . $incldead; $request .= "&submit="; if (!empty($this->pg)) { $request .= "&page=" . $this->pg; } if ($this->makeRequest($request)) { return $this->parseResponse(); } else { return $this->msg; } }
/** * dequeueTorrent * @param $torrent name of the torrent */ function dequeueTorrent($torrent) { $torrent = urldecode($torrent); $alias_file = getRequestVar('alias_file'); if (isTorrentRunning($torrent)) { // torrent has been started... try and kill it. AuditAction($this->cfg["constants"]["unqueued_torrent"], $torrent . "has been started -- TRY TO KILL IT"); header("location: index.php?alias_file=" . $alias_file . "&kill=true&kill_torrent=" . urlencode($torrent)); exit; } else { if ($this->isQueueManagerRunning()) { // send command to daemon $this->sendQueueCommand('remove ' . substr($torrent, 0, -8)); // flag the torrent as stopped (in db) stopTorrentSettings($torrent); // update the stat file. parent::updateStatFile($torrent, $alias_file); // log AuditAction($this->cfg["constants"]["unqueued_torrent"], $torrent); } else { header("location: admin.php?op=queueSettings"); exit; } } }
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. To read the license please visit http://www.gnu.org/copyleft/gpl.html *******************************************************************************/ include_once "config.php"; include_once "functions.php"; require_once "metaInfo.php"; // is enabled ? if ($cfg["advanced_start"] != 1) { AuditAction($cfg["constants"]["error"], "ILLEGAL ACCESS: " . $cfg["user"] . " tried to use advanced start"); showErrorPage("advanced start is disabled."); } $torrent = getRequestVar('torrent'); // Load saved settings $btclient_default = $cfg["btclient"]; $torrentExists = loadTorrentSettingsToConfig($torrent); // savepath if (!isset($cfg["savepath"]) || empty($cfg["savepath"])) { $cfg["savepath"] = $cfg["path"] . getOwner($torrent) . '/'; } // torrent exists ? $torrentExists = getTorrentDataSize($torrent) > 0; // display name $displayName = htmlentities($torrent, ENT_QUOTES); if (strlen($displayName) >= 55) { $displayName = substr($displayName, 0, 52) . "..."; } ?>
public function renderGallery() { global $siteWebRoot, $useNiceUrls, $galleryTitle, $galleryDescription, $galleryKeywords, $galleryDate, $galleryRowTemplate, $galleryIndexLink, $olderGalleryLink, $olderGalleryTitle, $newerGalleryLink, $newerGalleryTitle; $newerGalleryLink = null; $olderGalleryLink = null; $newerGalleryTitle = null; $olderGalleryTitle = null; $galleryIndexLink = $useNiceUrls ? sprintf("%s/index/", $siteWebRoot) : sprintf("%s?index=", $siteWebRoot); $galleryId = getRequestVar('galleryID'); if (is_null($galleryId) || empty($galleryId)) { forwardTo($galleryIndexLink); } ob_start(); $keys = array_keys($this->gallerydata); for ($i = 0; $i < count($keys); $i++) { $gallery = $this->gallerydata[$keys[$i]]; if ($gallery->safename == $galleryId) { $galleryTitle = $gallery->title; $galleryDescription = $gallery->description; $galleryKeywords = $gallery->keywords; $galleryDate = $gallery->date; $galleryPath = sprintf('%s/assets/galleries/%s', $siteWebRoot, $gallery->foldername); foreach ($gallery->files as $image) { $row = $galleryRowTemplate; $row = str_replace('IMGSRC', sprintf("%s/%s", $galleryPath, $image), $row); $row = str_replace('ALTTXT', '', $row); $row = str_replace('IMGID', getUrlSafeString(substr($image, 0, strrpos($image, "."))), $row); print $row; } for ($j = $i - 1; $j >= 0; $j--) { $newerGallery = $this->gallerydata[$keys[$j]]; if (is_null($newerGallery->hidden)) { $newerGalleryTitle = $newerGallery->title; $newerGalleryLink = $useNiceUrls ? sprintf('%s/gallery/%s', $siteWebRoot, $newerGallery->safename) : sprintf('%s/?galleryID=%s', $siteWebRoot, $newerGallery->safename); break; } } for ($j = $i + 1; $j < count($keys); $j++) { $olderGallery = $this->gallerydata[$keys[$j]]; if (is_null($olderGallery->hidden)) { $olderGalleryTitle = $olderGallery->title; $olderGalleryLink = $useNiceUrls ? sprintf('%s/gallery/%s', $siteWebRoot, $olderGallery->safename) : sprintf('%s/?galleryID=%s', $siteWebRoot, $olderGallery->safename); break; } } break; } } $this->output = ob_get_clean(); }
if (!empty($return)) { sleep(3); passthru("kill " . $kill); // try to remove the pid file @unlink($cfg["torrent_file_path"] . $alias_file . ".pid"); header("location: " . $return . ".php?op=queueSettings"); exit; } else { header("location: index.php"); exit; } } // Did the user select the option to remove a torrent from the Queue? if (isset($_REQUEST["dQueue"])) { $alias_file = SecurityClean(getRequestVar('alias_file')); $QEntry = getRequestVar('QEntry'); // Is the Qinfo file still there? if (file_exists($cfg["torrent_file_path"] . "queue/" . $alias_file . ".Qinfo")) { // Yes, then delete it and update the stat file. include_once "AliasFile.php"; // We are going to write a '2' on the front of the stat file so that // it will be set back to New Status $the_user = getOwner($QEntry); // read the alias file // create AliasFile object $af = new AliasFile($cfg["torrent_file_path"] . $alias_file, $the_user); if ($af->percent_done > 0 && $af->percent_done < 100) { // has downloaded something at some point, mark it is incomplete $af->running = "0"; $af->time_left = "Torrent Stopped"; }
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. TorrentFlux is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with TorrentFlux; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ include_once "config.php"; include_once "functions.php"; require_once "metaInfo.php"; $torrent = SecurityClean(getRequestVar('torrent')); $displayName = $torrent; if (!file_exists($cfg["torrent_file_path"] . $torrent)) { echo $torrent . " could not be found or does not exist."; die; } if (strlen($displayName) >= 55) { $displayName = substr($displayName, 0, 52) . "..."; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title><?php
/** * Data processing method * only called if template is not cached */ function process() { $request = getRequestVar('request', "", 'string'); $tab = $this->initFunctionTab(); if ($request == "") { $this->tpl->assign("XmlapiFunctionTab", $tab); $this->tpl->assign("PHPMV_URL", PHPMV_URL); } else { // Get function element $fct = $tab[$request]; // Get parameter from url $tabParam = array(); foreach ($fct->fctParameters as $key => $elem) { $tabParam[$elem->fctParamName] = html_entity_decode(getRequestVar($elem->fctParamName, $elem->fctParamDefaultValue, 'string')); //echo "test : " . $tabParam[$elem->fctParamName] . "<br>"; } // Call function with parameters //$data = $this->data->{$fct->fctCodeName}(); $data = call_user_func_array(array(&$this->data, $fct->fctCodeName), $tabParam); // Get anly specific detail if ($fct->fctResultDetail != "") { $resultTab = split("[/.-]", $fct->fctResultDetail); foreach ($resultTab as $key => $elem) { $data = $data[$elem]; } } // Return xml $this->returnAllElemXML($data, $fct->fctApiName); } }
<?php include 'include.php'; //Includes the necessary bootstrapping and the ajax functions // module_load_include('php', 'vals_soc', 'includes/classes/AbstractEntity'); module_load_include('php', 'vals_soc', 'includes/classes/Groups'); module_load_include('php', 'vals_soc', 'includes/classes/Project'); module_load_include('php', 'vals_soc', 'includes/pages/proposals'); module_load_include('php', 'vals_soc', 'includes/classes/Institutes'); switch ($_GET['action']) { case 'list': try { $instName = null; $inst_id = getRequestVar('instid', null); if (isset($_POST['iname'])) { $instName = $_POST['iname']; } //Return result to jTable $jTableResult = array(); $jTableResult['Result'] = "OK"; if ($inst_id) { $institutions = Institutes::getInstance()->getInstituteById($inst_id); $jTableResult['TotalRecordCount'] = count($institutions); $jTableResult['Records'] = $institutions; } else { $jTableResult['TotalRecordCount'] = Institutes::getInstance()->getInstitutesRowCountBySearchCriteria($instName); $jTableResult['Records'] = Institutes::getInstance()->getInstitutesBySearchCriteria($instName, $_GET["jtSorting"], $_GET["jtStartIndex"], $_GET["jtPageSize"]); } print json_encode($jTableResult); } catch (Exception $ex) { //Return error message
} if (Users::isStudent() && !Groups::isOwner(_PROPOSAL_OBJ, $proposal_id)) { echo errorDiv(t('You can only view your own proposals!')); } else { //TODO: find out whether we use the proposal view only in the my proposals and if not whether this //matters: non owners have no right to delete for example and so no reason to do a followup action echo renderProposal($proposal, $target, 'myproposal_page'); } } else { echo errorDiv(t('No proposal identifier submitted!')); } break; case 'mark_proposal': $proposal_id = getRequestVar('proposal_id', 0, 'post'); $project_id = getRequestVar('project_id', 0, 'post'); $is_final = getRequestVar('is_final', 0, 'post'); if (!$project_id) { echo t('The project could not be found'); return; } if (!$proposal_id) { echo t('The proposal could not be found'); return; } if (!$is_final) { $is_final = 0; } // Get the projects current proposal id and state (if set) $project = Project::getProjectById($project_id, FALSE, NULL); $old_proposal = $project->proposal_id; // probably dont need this now
/** * dequeueTorrent * @param $torrent name of the torrent */ function dequeueTorrent($torrent) { $torrent = urldecode($torrent); $alias_file = getRequestVar('alias_file'); // Is the Qinfo file still there? if (file_exists($this->cfg["torrent_file_path"] . "queue/" . $alias_file . ".Qinfo")) { // flag the torrent as stopped (in db) stopTorrentSettings($torrent); // update the stat file. parent::updateStatFile($torrent, $alias_file); // Remove Qinfo file. @unlink($this->cfg["torrent_file_path"] . "queue/" . $alias_file . ".Qinfo"); // log AuditAction($this->cfg["constants"]["unqueued_torrent"], $torrent); } else { // torrent has been started... try and kill it. AuditAction($this->cfg["constants"]["unqueued_torrent"], $torrent . "has been started -- TRY TO KILL IT"); header("location: index.php?alias_file=" . $alias_file . "&kill=true&kill_torrent=" . urlencode($torrent)); exit; } }
function updateSearchSettings() { global $cfg; foreach ($_POST as $key => $value) { if ($key != "searchEngine") { $settings[$key] = $value; } } saveSettings($settings); AuditAction($cfg["constants"]["admin"], " Updating TorrentFlux Search Settings"); $searchEngine = getRequestVar('searchEngine'); if (empty($searchEngine)) { $searchEngine = $cfg["searchEngine"]; } header("location: admin.php?op=searchSettings&searchEngine=" . $searchEngine); }
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; }
/** * 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; }
} if ($_POST['iamhim'] != "") { setcookie("iamhim", $_POST['iamhim'], time() + 60 * 60 * 24 * 30); } } if (empty($user) && empty($iamhim) && !empty($username) && !empty($password)) { $user = strtolower($username); $iamhim = addslashes($password); } break; case 0: /* Form-Based Auth Standard */ /* Form-Based Auth Standard */ default: $user = strtolower(getRequestVar('username')); $iamhim = addslashes(getRequestVar('iamhim')); break; } // time $create_time = time(); // Check for user if (!empty($user) && !empty($iamhim)) { /* First User check */ $next_loc = "index.php"; $sql = "SELECT count(*) FROM tf_users"; $user_count = $db->GetOne($sql); if ($user_count == 0) { // This user is first in DB. Make them super admin. // this is The Super USER, add them to the user table $record = array('user_id' => $user, 'password' => md5($iamhim), 'hits' => 1, 'last_visit' => $create_time, 'time_created' => $create_time, 'user_level' => 2, 'hide_offline' => 0, 'theme' => $cfg["default_theme"], 'language_file' => $cfg["default_language"]); $sTable = 'tf_users';
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with TorrentFlux; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ include_once "config.php"; include_once "functions.php"; include_once "AliasFile.php"; $torrent = getRequestVar('torrent'); $error = ""; $torrentowner = getOwner($torrent); $graph_width = ""; $background = "#000000"; $alias = SecurityClean(getRequestVar('alias')); if (!empty($alias)) { // read the alias file // create AliasFile object $af = new AliasFile($cfg["torrent_file_path"] . $alias, $torrentowner); for ($inx = 0; $inx < sizeof($af->errors); $inx++) { $error .= "<li style=\"font-size:10px;color:#ff0000;\">" . $af->errors[$inx] . "</li>"; } if ($af->seedlimit <= 0) { $af->seedlimit = "none"; } else { $af->seedlimit .= "%"; } } else { die("fatal error torrent file not specified"); }
TorrentFlux is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with TorrentFlux; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ include_once "config.php"; include_once "functions.php"; require_once "metaInfo.php"; global $cfg; $torrent = SecurityClean(getRequestVar('torrent')); DisplayHead(_TORRENTDETAILS); echo "<table width=\"740\" border=0 cellpadding=0 cellspacing=0><tr><td>"; echo displayDriveSpaceBar(getDriveSpace($cfg["path"])); echo "</td></tr></table>"; echo "<br>"; echo "<div align=\"left\" id=\"BodyLayer\" name=\"BodyLayer\" style=\"border: thin solid "; echo $cfg["main_bgcolor"]; echo "; position:relative; width:740; height:500; padding-left: 5px; padding-right: 5px; z-index:1; overflow: scroll; visibility: visible\">"; $als = getRequestVar('als'); if ($als == "false") { showMetaInfo($torrent, false); } else { showMetaInfo($torrent, true); } echo "</div>"; DisplayFoot();
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with TorrentFlux; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ include_once "config.php"; include_once "functions.php"; checkUserPath(); // Setup some defaults if they are not set. $del = getRequestVar('del'); $down = getRequestVar('down'); $tar = getRequestVar('tar'); $dir = stripslashes(urldecode(getRequestVar('dir'))); // ----------------------------------------------------------------------------- // Are we to delete something? if ($del != "") { $current = delDirEntry($del); header("Location: dir.php?dir=" . urlencode($current)); } // Are we to download something? if ($down != "" && $cfg["enable_file_download"]) { $current = ""; // Yes, then download it // we need to strip slashes twice in some circumstances // Ex. If we are trying to download test/tester's file/test.txt // $down will be "test/tester\\\'s file/test.txt" // one strip will give us "test/tester\'s file/test.txt // the second strip will give us the correct
function pretendUser() { //the session_status function is only available from php 5.4 on. We just suppress the possible warning on //double started sessions. In fact this is harmless and php will just start the session it already had (if this is //the case, but still fires a warning. This function will and should nver be called in production, so it is not //an issue there. //if (session_status() == PHP_SESSION_NONE) { @session_start(); //} $user_id = getRequestVar('pretend', altSubValue($_SESSION, 'pretend_user', 0)); if ($user_id) { if (!(isset($_SESSION['pretend_user']) && ($_SESSION['pretend_user'] && $_SESSION['pretend_user'] == $user_id) || verifyUser($user_id))) { return array(0, 0); } $same_pretend = $_SESSION['pretend_user'] == $user_id; $_SESSION['pretend_user'] = $user_id; $original_user = $GLOBALS['user']; $old_state = drupal_save_session(); //drupal_save_session(FALSE); if (isset($_SESSION['pretend_user_obj']) && $_SESSION['pretend_user_obj'] && $same_pretend) { $GLOBALS['user'] = $_SESSION['pretend_user_obj']; } else { $GLOBALS['user'] = user_load($user_id); $GLOBALS['user']->roles = repairRoles($GLOBALS['user']->roles); $_SESSION['pretend_user_obj'] = $GLOBALS['user']; } return array($original_user, $old_state); } else { $_SESSION['pretend_user_obj'] = $_SESSION['pretend_user'] = 0; return array(0, 0); } }
<?php include 'include.php'; //Includes the necessary bootstrapping and the ajax functions // module_load_include('php', 'vals_soc', 'includes/classes/AbstractEntity'); // module_load_include('php', 'vals_soc', 'includes/classes/Groups'); module_load_include('php', 'vals_soc', 'includes/classes/Organisations'); switch ($_GET['action']) { case 'list_organisations': try { $orgName = null; $org_id = getRequestVar('orgid', null); if (isset($_POST['oname'])) { $orgName = $_POST['oname']; } //Return result to jTable $jTableResult = array(); $jTableResult['Result'] = "OK"; if ($org_id) { $organisations = Organisations::getInstance()->getOrganisationById($org_id); $jTableResult['TotalRecordCount'] = count($organisations); $jTableResult['Records'] = $organisations; } else { $jTableResult['TotalRecordCount'] = Organisations::getInstance()->getOrganisationsRowCountBySearchCriteria($orgName); $jTableResult['Records'] = Organisations::getInstance()->getOrganisationsBySearchCriteria($orgName, $_GET["jtSorting"], $_GET["jtStartIndex"], $_GET["jtPageSize"]); } print json_encode($jTableResult); } catch (Exception $ex) { //Return error message $jTableResult = array(); $jTableResult['Result'] = "ERROR";
$tmpCatLinks = ''; $mainStart = true; } if ($mainStart == false) { $tmpCatLinks .= " | "; } $tmpCatLinks .= "<a href=\"torrentSearch.php?searchEngine=" . $searchEngine . "&mainGenre=" . $mainId . "\">" . $mainName . "</a>"; $mainStart = false; } echo $catLinks . $tmpCatLinks; if ($mainStart == false) { echo "<br><br>"; } echo "</div>"; echo "</td></tr>"; $mainGenre = getRequestVar('mainGenre'); if (!empty($mainGenre) && !array_key_exists("subGenre", $_REQUEST)) { $subCats = $sEngine->getSubCategories($mainGenre); if (count($subCats) > 0) { echo "<tr bgcolor=\"" . $cfg["table_header_bg"] . "\">"; echo "<td colspan=6><form method=get id=\"subLatest\" name=\"subLatest\" action=torrentSearch.php?>"; echo "<input type=hidden name=\"searchEngine\" value=\"" . $searchEngine . "\">"; $mainGenreName = $sEngine->GetMainCatName($mainGenre); echo "Category: <b>" . $mainGenreName . "</a></b> -> "; echo "<select name=subGenre>"; foreach ($subCats as $subId => $subName) { echo "<option value=" . $subId . ">" . $subName . "</option>\n"; } echo "</select> "; echo "<input type=submit value='Show Latest'>"; echo "</form>\n";
$result = db_update(tableName('project'))->condition('pid', $project_id)->fields(array('views' => $project['views'] + 1))->execute(); } } jsonGoodResult($project); } catch (Exception $e) { jsonBadResult(t('Could not get details of project') . (_DEBUG ? $e->getMessage() : "")); } } else { jsonBadResult(t("No valid project identifier submitted!")); } break; case 'view': $type = _PROJECT_OBJ; $id = altSubValue($_POST, 'id'); $target = altSubValue($_POST, 'target', ''); $inline = getRequestVar('inline', FALSE); if (!($id && $type && $target)) { die(t('There are missing arguments. Please inform the administrator of this mistake.')); } $project = Project::getProjectById($id, TRUE); if (!$project) { echo t('The project cannot be found'); } else { echo "<div id='msg_{$target}'></div>"; echo renderProject($project, $target, $inline); } break; case 'add': $target = altSubValue($_POST, 'target'); $type = altSubValue($_POST, 'type'); $org = altSubValue($_GET, 'org');