function showGallery() { // Builds main gallery page global $file, $gallery_address, $gallery_root, $user_level, $lg_text_domain; get_currentuserinfo(); echo "<div id='gallery'>"; // get_image_comments(); if (!validateFile()) { echo "<div class='error'>"; echo "<p><b>" . __('WARNING', $lg_text_domain) . ": </b>" . __('Unable to access to the Gallery Folder', $lg_text_domain); echo "</p>"; echo "<p>" . __('Check your settings', $lg_text_domain); if ($user_level >= 8) { echo "<a href='" . get_option('siteurl') . "/wp-admin/" . LG_ADM_PAGE . "'>"; _e('here', $lg_text_domain); echo "</a>"; } echo "</p></div>"; return; } createNavigation(); $path = pathinfo($file); if ($path['extension'] == '') { //Display Dir(s) (if any) showDirs(); //Display Thumb(s) (if any) showThumbs(); } else { showSlide($file); } if ($user_level >= 8) { echo "<div class='lg_admin'>"; echo "<a href='" . get_option('siteurl') . "/wp-admin/" . LG_ADM_PAGE . "'>"; _e('» Administrate Gallery', $lg_text_domain); echo "</a>"; echo "</div>"; } //echo "<div id='lg_powered'> // <div class='lgpow'>Powered by <a href='http://lazyest.keytwo.net'>Lazyest Gallery ". LG_VERSION ."</a> - Copyright (C) <a href='http://www.keytwo.net'>Keytwo.net</a></div> // </div>"; // comments_template(); echo "</div>"; }
function validateTrack($values, $type) { // Type 0: For Edit Page // Type 1: For Upload Page // Validate Release date if (!empty($values['day']) && !empty($values['month']) && !empty($values['year'])) { $values['release'] = date("Y-m-d", mktime(0, 0, 0, $values['month'], $values['day'], $values['year'])); } else { $values['release'] = 0; } // Validate License if ($values['license']) { if ($values['license-nc'] != 0) { $values['license-nc'] = 1; } // License Types $licenseTypes = array(0, 1, 2); if (!in_array($values['license-nd-sa'], $licenseTypes)) { $values['license-nd-sa'] = 0; } $values['license'] = '1' . $values['license-nc'] . $values['license-nd-sa']; } else { $value['license'] = 0; } // Unset unwated fields unset($values['day']); unset($values['month']); unset($values['year']); unset($values['license-nc']); unset($values['license-nd-sa']); if ($type) { $allowedColumns = array('title', 'description', 'name', 'art', 'tag', 'buy', 'record', 'release', 'license', 'size', 'download', 'public'); } else { $allowedColumns = array('title', 'description', 'art', 'tag', 'buy', 'record', 'release', 'license', 'download', 'public'); } // Strip unwated columns foreach ($values as $key => $value) { if (!in_array($key, $allowedColumns)) { unset($values[$key]); } } // Validate Description $values['description'] = htmlspecialchars(trim(nl2clean($values['description']))); $desclimit = 5000; if (strlen($values['description']) > $desclimit) { $error[] = array(6, $desclimit); } // Validate URL if (!filter_var($values['buy'], FILTER_VALIDATE_URL) && !empty($values['buy'])) { $error[] = array(7); } // Validate Tags $tags = array_filter(explode(',', $values['tag'])); foreach ($tags as $key => $tag) { $tag = strtolower($tag); // Array { Replace any unwated characters, Replace consecutive "-" characters } $tag = preg_replace(array('/[^[:alnum:]-]/u', '/--+/'), array('', '-'), $tag); // Remove tags that has only "-" characters if ($tag == '-') { unset($tags[$key]); } else { $tags[$key] = $tag; } } // Remove duplicated tags $tags = array_unique($tags); $tagmax = 30; $tagmin = 1; if (count($tags) > $tagmax) { $error[] = array(8, $tagmax); } elseif (count($tags) < $tagmin) { $error[] = array(9, $tagmin); } $values['tag'] = implode(',', $tags) . ','; // Validate Title $titlelimit = 100; if (empty($values['title'])) { $error[] = array(10); } elseif (strlen($values['title']) > $titlelimit) { $error[] = array(11, $titlelimit); } else { $values['title'] = htmlspecialchars(trim(nl2clean($values['title']))); } // Validate Download if ($values['download'] != 0) { $values['download'] = 1; } // Validate Privacy if ($values['public'] != 0) { $values['public'] = 1; } // Validate the files to be uploaded if (empty($error)) { if ($type) { if (isset($_FILES['track']['name'])) { // Get the total uploaded size $query = $this->db->query(sprintf("SELECT (SELECT SUM(`size`) FROM `tracks` WHERE `uid` = %s) as upload_size", $this->db->real_escape_string($this->id))); $result = $query->fetch_assoc(); foreach ($_FILES['track']['error'] as $key => $err) { $ext = pathinfo($_FILES['track']['name'][$key], PATHINFO_EXTENSION); $size = $_FILES['track']['size'][$key]; $allowedExt = explode(',', $this->track_format); $maxsize = $this->track_size; // Validate the total upload size allowed if ($result['upload_size'] + $size > $this->track_size_total) { $error[] = array(0); } // Get file type validation $track = validateFile($_FILES['track']['tmp_name'][$key], $_FILES['track']['name'][$key], $allowedExt, 1); if ($track['valid'] && $size < $maxsize && $size > 0) { $rand = mt_rand(); $tmp_name = $_FILES['track']['tmp_name'][$key]; $name = pathinfo($_FILES['track']['name'][$key], PATHINFO_FILENAME); $fullname = $_FILES['track']['name'][$key]; $size = $_FILES['track']['size'][$key]; $finalName = mt_rand() . '_' . mt_rand() . '_' . mt_rand() . '.' . $this->db->real_escape_string($ext); // Move the file into the uploaded folder move_uploaded_file($tmp_name, '../uploads/tracks/' . $finalName); // Send the track name in array format to the function $values['name'] = $finalName; $values['size'] = $size; } elseif ($_FILES['track']['name'][$key] == '') { // If the file size is higher than allowed or 0 $error[] = array(1); } if (!empty($ext) && ($size > $maxsize || $size == 0)) { // If the file size is higher than allowed or 0 $error[] = array(2, fsize($maxsize)); } if (!empty($ext) && !$track['valid']) { // If the file format is not allowed $error[] = array(3, implode(', ', $allowedExt)); } } } } if (isset($_FILES['art']['name'])) { foreach ($_FILES['art']['error'] as $key => $err) { $ext = pathinfo($_FILES['art']['name'][$key], PATHINFO_EXTENSION); $size = $_FILES['art']['size'][$key]; $allowedExt = explode(',', $this->art_format); $maxsize = $this->art_size; // Get file type validation $image = validateFile($_FILES['art']['tmp_name'][$key], $_FILES['art']['name'][$key], $allowedExt, 0); if ($image['valid'] && $size < $maxsize && $size > 0 && !empty($image['width']) && !empty($image['height'])) { $rand = mt_rand(); $tmp_name = $_FILES['art']['tmp_name'][$key]; $name = pathinfo($_FILES['art']['name'][$key], PATHINFO_FILENAME); $fullname = $_FILES['art']['name'][$key]; $size = $_FILES['art']['size'][$key]; $finalName = mt_rand() . '_' . mt_rand() . '_' . mt_rand() . '.' . $this->db->real_escape_string($ext); // Move the file into the uploaded folder if ($type) { move_uploaded_file($tmp_name, '../uploads/media/' . $finalName); } else { move_uploaded_file($tmp_name, 'uploads/media/' . $finalName); } // Send the image name in array format to the function $values['art'] = $finalName; } elseif ($_FILES['art']['name'][$key] == '') { // If no file is selected if ($type) { $values['art'] = 'default.png'; } else { // If the cover artwork is not selected, unset the image so that it doesn't update the current one unset($values['art']); } } if (!empty($ext) && ($size > $maxsize || $size == 0)) { // If the file size is higher than allowed or 0 $error[] = array(4, fsize($maxsize)); } if (!empty($ext) && !$image['valid']) { // If the file format is not allowed $error[] = array(5, implode(', ', $allowedExt)); } } } } if (!empty($error)) { return array(0, $error); } else { return array(1, $values); } }
if (count($candidate) == 0) { $candidate = ''; } else { $candidate = $candidate[0]; } } } sort($namesWithCandidates); // print_r($namesWithCandidates); exit(); /* if (count($uses) > 0) { */ /* $line = $uses[0]->getAttribute('startLine') - 1; */ /* } */ $output = ''; foreach ($namesWithCandidates as $name) { if (strlen($name) > 0) { $output .= 'use ' . $name . ";\n"; } } $src = file($inputFile); $data = validateFile($tree); if (is_null($data['begin'])) { $data['begin'] = $data['end'] = 3; } array_splice($src, $data['begin'] - 1, $data['end'] - $data['begin'], $output); if ($argv[2] == '-w') { file_put_contents($inputFile, implode('', $src)); } else { echo implode('', $src); } // dumpNode($tree); // var_dump(getUseStatements(getSourceTree(file_get_contents(__FILE__))));
function queueSettings() { global $cfg; include_once "AliasFile.php"; include_once "RunningTorrent.php"; include_once "QueueManager.php"; $queueManager = QueueManager::getQueueManagerInstance($cfg); // QueueManager Running ? $queueManagerRunning = false; $shutdown = getRequestVar('s'); if (isset($shutdown) && $shutdown == "1") { $queueManagerRunning = false; } else { if ($queueManager->isQueueManagerRunning()) { $queueManagerRunning = true; } else { if ($queueManager->managerName == "tfqmgr") { if ($queueManager->isQueueManagerReadyToStart()) { $queueManagerRunning = false; } else { $queueManagerRunning = true; } } else { $queueManagerRunning = false; } } } // head DisplayHead("Administration - Queue Settings"); // Admin Menu displayMenu(); // message section $message = getRequestVar('m'); if (isset($message) && $message != "") { echo '<table cellpadding="5" cellspacing="0" border="0" width="100%">'; echo '<tr><td align="center" bgcolor="' . $cfg["table_header_bg"] . '"><strong>'; echo urldecode($message); echo '</strong></td></tr></table>'; } // Queue Manager Section echo "<div align=\"center\">"; echo "<a name=\"QManager\" id=\"QManager\"></a>"; echo "<table width=\"100%\" border=1 bordercolor=\"" . $cfg["table_admin_border"] . "\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"" . $cfg["table_data_bg"] . "\">"; echo "<tr><td bgcolor=\"" . $cfg["table_header_bg"] . "\" background=\"themes/" . $cfg["theme"] . "/images/bar.gif\">"; echo "<font class=\"title\">"; //if(checkQManager() > 0) // echo " <img src=\"images/green.gif\" align=\"absmiddle\" align=\"absmiddle\"> Queue Manager Running [PID=".getQManagerPID()." with ".strval(getRunningTorrentCount())." torrent(s)]"; if ($queueManagerRunning) { echo " <img src=\"images/green.gif\" align=\"absmiddle\" align=\"absmiddle\"> Queue Manager Running (" . $queueManager->managerName . "; pid: " . $queueManager->getQueueManagerPid() . ")"; } else { echo " <img src=\"images/black.gif\" align=\"absmiddle\"> Queue Manager Off"; } echo "</font>"; echo "</td></tr><tr><td align=\"center\">"; ?> <script language="JavaScript"> function validateSettings() { var rtnValue = true; var msg = ""; if (isNumber(document.theForm.maxServerThreads.value) == false) { msg = msg + "* Max Server Threads must be a valid number.\n"; document.theForm.maxServerThreads.focus(); } if (isNumber(document.theForm.maxUserThreads.value) == false) { msg = msg + "* Max User Threads must be a valid number.\n"; document.theForm.maxUserThreads.focus(); } if (isNumber(document.theForm.sleepInterval.value) == false) { msg = msg + "* Sleep Interval must be a valid number.\n"; document.theForm.sleepInterval.focus(); } if (msg != "") { rtnValue = false; alert("Please check the following:\n\n" + msg); } return rtnValue; } function isNumber(sText) { var ValidChars = "0123456789."; var IsNumber = true; var Char; for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) { IsNumber = false; } } return IsNumber; } </script> <div align="center"> <table cellpadding="5" cellspacing="0" border="0" width="100%"> <?php //if ((! $queueManager->isQueueManagerRunning()) && ( !$queueManager->isQueueManagerReadyToStart())) { if (isset($shutdown) && $shutdown == "1") { echo '<tr><br>'; echo '<td align="center" colspan="2">'; echo 'QueueManager going down... Please Wait.'; echo '<br><br></td>'; echo '</tr>'; } else { echo '<form name="controlForm" action="admin.php?op=controlQueueManager" method="post">'; if ($queueManagerRunning) { echo '<input type="Hidden" name="a" value="stop">'; echo '<tr><br>'; echo '<td align="center" colspan="2">'; echo '<input type="Submit" value="Stop QueueManager">'; echo '<br><br></td>'; echo '</tr>'; } else { echo '<input type="Hidden" name="a" value="start">'; echo '<tr>'; echo '<td align="left" width="350" valign="top"><strong>Choose Queue Manager</strong><br>'; echo '<u>Note</u> : tfQManager only supports tornado-clients.'; echo '</td>'; echo '<td>'; echo '<select name="queuemanager">'; echo '<option value="tfqmgr"'; if ($cfg["queuemanager"] == "tfqmgr") { echo " selected"; } echo '>tfqmgr</option>'; echo '<option value="Qmgr"'; if ($cfg["queuemanager"] == "Qmgr") { echo " selected"; } echo '>Qmgr</option>'; echo '<option value="tfQManager"'; if ($cfg["queuemanager"] == "tfQManager") { echo " selected"; } echo '>tfQManager</option>'; echo '</select>'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td align="center" colspan="2">'; echo '<input type="Submit" value="Start QueueManager">'; echo '<br><br></td>'; echo '</tr>'; } echo '</form>'; } ?> <form name="theForm" action="admin.php?op=updateQueueSettings" method="post" onsubmit="return validateSettings()"> <tr> <td colspan="2" align="center" bgcolor="<?php echo $cfg["table_header_bg"]; ?> "> <strong>tfqmgr</strong> <?php echo '('; printSuperAdminLink('?q=1', 'log'); echo ' | '; printSuperAdminLink('?q=2', 'ps'); if (isset($shutdown) && $shutdown == "1") { } else { if ($queueManagerRunning && $queueManager->managerName == "tfqmgr") { echo ' | '; printSuperAdminLink('?q=3', 'status'); } } echo ' )'; ?> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>perl Path</strong><br> Specify the path to perl (/usr/bin/perl): </td> <td valign="top"> <input name="perlCmd" type="Text" maxlength="254" value="<?php echo $cfg["perlCmd"]; ?> " size="55"><?php echo validateFile($cfg["perlCmd"]); ?> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>tfqmgr Path</strong><br> Specify the path of tfqmgr (/var/www/tfqmgr): </td> <td valign="top"> <input name="tfqmgr_path" type="Text" maxlength="254" value="<?php echo $cfg["tfqmgr_path"]; ?> " size="55"><?php echo validateFile($cfg["tfqmgr_path"] . "/tfqmgr.pl"); ?> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>fluxcli Path</strong><br> Specify the path where fluxcli.php is. (/var/www): </td> <td valign="top"> <input name="tfqmgr_path_fluxcli" type="Text" maxlength="254" value="<?php echo $cfg["tfqmgr_path_fluxcli"]; ?> " size="55"><?php echo validateFile($cfg["tfqmgr_path_fluxcli"] . "/fluxcli.php"); ?> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>Limit Torrent Global</strong><br> Specify the maximum number of torrents the server will allow to run at one time (admins may override this): </td> <td valign="top"> <input name="tfqmgr_limit_global" type="Text" maxlength="3" value="<?php echo $cfg["tfqmgr_limit_global"]; ?> " size="3"> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>Limit Torrent Per User</strong><br> Specify the maximum number of torrents a single user may run at one time: </td> <td valign="top"> <input name="tfqmgr_limit_user" type="Text" maxlength="3" value="<?php echo $cfg["tfqmgr_limit_user"]; ?> " size="3"> </td> </tr> <tr><td colspan="2" align="center" bgcolor="<?php echo $cfg["table_header_bg"]; ?> "><strong>Qmgr</strong></td></tr> <tr> <td align="left" width="350" valign="top"><strong>Path to Qmgr scripts</strong><br> Specify the path to the Qmgr.pl and Qmgrd.pl scripts: </td> <td valign="top"> <input name="Qmgr_path" type="Text" maxlength="254" value="<?php echo $cfg["Qmgr_path"]; ?> " size="55"><?php echo validateFile($cfg["Qmgr_path"] . "/Qmgrd.pl"); ?> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>Max User Torrents</strong><br> Total number of torrents to allow a single user at once: </td> <td valign="top"> <input name="Qmgr_maxUserTorrents" type="Text" maxlength="3" value="<?php echo $cfg["Qmgr_maxUserTorrents"]; ?> " size="3"> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>Max Total Torrents</strong><br> Total number of torrents the server will run at once: </td> <td valign="top"> <input name="Qmgr_maxTotalTorrents" type="Text" maxlength="3" value="<?php echo $cfg["Qmgr_maxTotalTorrents"]; ?> " size="3"> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>Perl's Path</strong><br> Specify the path to perl: </td> <td valign="top"> <input name="Qmgr_perl" type="Text" maxlength="254" value="<?php echo $cfg["Qmgr_perl"]; ?> " size="55"><?php echo validateFile($cfg["Qmgr_perl"]); ?> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>Fluxcli.php path</strong><br> Specify the path to the fluxcli executable: </td> <td valign="top"> <input name="Qmgr_fluxcli" type="Text" maxlength="254" value="<?php echo $cfg["Qmgr_fluxcli"]; ?> " size="55"><?php echo validateFile($cfg["Qmgr_fluxcli"] . "/fluxcli.php"); ?> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>Qmgrd host</strong><br> The host running the Qmgrd.pl script, probably localhost: </td> <td valign="top"> <input name="Qmgr_host" type="Text" maxlength="254" value="<?php echo $cfg["Qmgr_host"]; ?> " size="15"> </td> </tr> <tr> <td align="left" width="250" valign="top"><strong>Qmgrd port</strong><br> the port number to run the Qmgrd.pl script on: </td> <td valign="top"> <input name="Qmgr_port" type="Text" maxlength="5" value="<?php echo $cfg["Qmgr_port"]; ?> " size="5"> </td> </tr> <tr><td colspan="2" align="center" bgcolor="<?php echo $cfg["table_header_bg"]; ?> "><strong>tfQManager</strong></td></tr> <tr> <td align="left" width="350" valign="top"><strong>tfQManager Path</strong><br> Specify the path to the tfQManager.py python script: </td> <td valign="top"> <input name="tfQManager" type="Text" maxlength="254" value="<?php echo $cfg["tfQManager"]; ?> " size="55"><?php echo validateFile($cfg["tfQManager"]); ?> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>Max Server Threads</strong><br> Specify the maximum number of torrents the server will allow to run at one time (admins may override this): </td> <td valign="top"> <input name="maxServerThreads" type="Text" maxlength="3" value="<?php echo $cfg["maxServerThreads"]; ?> " size="3"> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>Max User Threads</strong><br> Specify the maximum number of torrents a single user may run at one time: </td> <td valign="top"> <input name="maxUserThreads" type="Text" maxlength="3" value="<?php echo $cfg["maxUserThreads"]; ?> " size="3"> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>Polling Interval</strong><br> Number of seconds the Queue Manager will sleep before checking for new torrents to run: </td> <td valign="top"> <input name="sleepInterval" type="Text" maxlength="3" value="<?php echo $cfg["sleepInterval"]; ?> " size="3"> </td> </tr> <tr><td colspan="2"><hr noshade></td></tr> <tr> <td align="center" colspan="2"> <input type="Submit" value="Update Settings"> </td> </tr> </form> </table> </div> <br> <?php echo "</td></tr>"; echo "</table></div>"; $displayQueue = True; $displayRunningTorrents = True; // Its a timming thing. if ($displayRunningTorrents) { // get Running Torrents. $runningTorrents = getRunningTorrents(); } // _queue_ if ($displayQueue) { echo "\n"; echo "<table width=\"760\" border=1 bordercolor=\"" . $cfg["table_admin_border"] . "\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"" . $cfg["table_data_bg"] . "\">"; echo "<tr><td colspan=6 bgcolor=\"" . $cfg["table_header_bg"] . "\" background=\"themes/" . $cfg["theme"] . "/images/bar.gif\">"; echo "<table width=\"100%\" cellpadding=0 cellspacing=0 border=0><tr>"; echo "<td><img src=\"images/properties.png\" width=18 height=13 border=0> <font class=\"title\"> Queued Items </font></td>"; echo "</tr></table>"; echo "</td></tr>"; echo "<tr>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\" width=\"15%\"><div align=center class=\"title\">" . _USER . "</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _FILE . "</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\" width=\"15%\"><div align=center class=\"title\">" . _TIMESTAMP . "</div></td>"; echo "</tr>"; echo "\n"; echo $queueManager->formattedQueueList(); echo "</table>"; } // _queue_ if ($displayRunningTorrents) { $output = ""; echo "\n"; echo "<table width=\"760\" border=1 bordercolor=\"" . $cfg["table_admin_border"] . "\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"" . $cfg["table_data_bg"] . "\">"; echo "<tr><td colspan=6 bgcolor=\"" . $cfg["table_header_bg"] . "\" background=\"themes/" . $cfg["theme"] . "/images/bar.gif\">"; echo "<table width=\"100%\" cellpadding=0 cellspacing=0 border=0><tr>"; echo "<td><img src=\"images/properties.png\" width=18 height=13 border=0> <font class=\"title\"> Running Items </font></td>"; echo "</tr></table>"; echo "</td></tr>"; echo "<tr>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\" width=\"15%\"><div align=center class=\"title\">" . _USER . "</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _FILE . "</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\" width=\"1%\"><div align=center class=\"title\">" . str_replace(" ", "<br>", _FORCESTOP) . "</div></td>"; echo "</tr>"; echo "\n"; // get running tornado torrents and List them out. $runningTorrents = getRunningTorrents("tornado"); foreach ($runningTorrents as $key => $value) { $rt = RunningTorrent::getRunningTorrentInstance($value, $cfg, "tornado"); $output .= $rt->BuildAdminOutput(); } // get running transmission torrents and List them out. $runningTorrents = getRunningTorrents("transmission"); foreach ($runningTorrents as $key => $value) { $rt = RunningTorrent::getRunningTorrentInstance($value, $cfg, "transmission"); $output .= $rt->BuildAdminOutput(); } if (strlen($output) == 0) { $output = "<tr><td colspan=3><div class=\"tiny\" align=center>No Running Torrents</div></td></tr>"; } echo $output; echo "</table>"; } DisplayFoot(true, true); }
<?php require_once "lib/common.php"; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $errors = validateFile(); if (!count($errors)) { header("Location: index.php"); exit; } } else { $errors = array(); } require_once "inc/header.inc.php"; ?> <div class="container"> <form class="form-horizontal" method="post" enctype="multipart/form-data"> <div class="form-group"> <label for="inputEmail3" class="col-sm-2 control-label">Выберите файл</label> <div class="col-sm-10"> <input type="file" name="file" class="form-control" id="inputEmail3" placeholder="Ds,thbnt"> <?php if (isset($errors["file"])) { ?> <span class="errmess"><?php echo $errors['file']; ?> </span> <?php } ?>
function PageMain() { global $TMPL, $LNG, $CONF, $db, $loggedIn, $settings; unset($_POST['suspended']); if (isset($_SESSION['username']) && isset($_SESSION['password']) || isset($_COOKIE['username']) && isset($_COOKIE['password'])) { $verify = $loggedIn->verify(); if ($verify['username']) { $TMPL_old = $TMPL; $TMPL = array(); $TMPL['url'] = $CONF['url']; if ($_GET['b'] == 'security') { $skin = new skin('settings/security'); $page = ''; // Create the class instance $updateUserSettings = new updateUserSettings(); $updateUserSettings->db = $db; $updateUserSettings->id = $verify['idu']; if (!empty($_POST)) { $TMPL['message'] = $updateUserSettings->query_array('users', $_POST); } $userSettings = $updateUserSettings->getSettings(); } elseif ($_GET['b'] == 'avatar') { $skin = new skin('settings/avatar'); $page = ''; // Create the class instance $updateUserSettings = new updateUserSettings(); $updateUserSettings->db = $db; $updateUserSettings->id = $verify['idu']; $TMPL['image'] = '<img src="' . $CONF['url'] . '/thumb.php?src=' . $verify['image'] . '&t=a" width="80" height="80" />'; $TMPL['cover'] = '<img src="' . $CONF['url'] . '/thumb.php?src=' . $verify['cover'] . '&t=c&w=900&h=200" />'; $maxsize = $settings['size']; if (isset($_FILES['avatarselect']['name'])) { foreach ($_FILES['avatarselect']['error'] as $key => $error) { $ext = pathinfo($_FILES['avatarselect']['name'][$key], PATHINFO_EXTENSION); $size = $_FILES['avatarselect']['size'][$key]; $allowedExt = explode(',', strtolower($settings['format'])); // Get file type validation $image = validateFile($_FILES['avatarselect']['tmp_name'][$key], $_FILES['avatarselect']['name'][$key], $allowedExt, 0); if ($image['valid'] && $size < $maxsize && $size > 0 && !empty($image['width']) && !empty($image['height'])) { $rand = mt_rand(); $tmp_name = $_FILES['avatarselect']['tmp_name'][$key]; $name = pathinfo($_FILES['avatarselect']['name'][$key], PATHINFO_FILENAME); $fullname = $_FILES['avatarselect']['name'][$key]; $size = $_FILES['avatarselect']['size'][$key]; $type = pathinfo($_FILES['avatarselect']['name'][$key], PATHINFO_EXTENSION); $finalName = mt_rand() . '_' . mt_rand() . '_' . mt_rand() . '.' . $db->real_escape_string($ext); // Fix image orientation if possible imageOrientation($tmp_name); // Move the file into the uploaded folder move_uploaded_file($tmp_name, 'uploads/avatars/' . $finalName); // Send the image name in array format to the function $image = array('image' => $finalName); $updateUserSettings->query_array('users', $image); header("Location: " . $CONF['url'] . "/index.php?a=settings&b=avatar&m=s"); } elseif ($_FILES['avatarselect']['name'][$key] == '') { // If no file is selected header("Location: " . $CONF['url'] . "/index.php?a=settings&b=avatar&m=nf"); } elseif ($size > $maxsize || $size == 0) { // If the file size is higher than allowed or 0 header("Location: " . $CONF['url'] . "/index.php?a=settings&b=avatar&m=fs"); } else { // If the file format is not allowed header("Location: " . $CONF['url'] . "/index.php?a=settings&b=avatar&m=wf"); } } } if (isset($_FILES['coverselect']['name'])) { foreach ($_FILES['coverselect']['error'] as $key => $error) { $ext = pathinfo($_FILES['coverselect']['name'][$key], PATHINFO_EXTENSION); $size = $_FILES['coverselect']['size'][$key]; $allowedExt = explode(',', strtolower($settings['format'])); // Get file type validation $image = validateFile($_FILES['coverselect']['tmp_name'][$key], $_FILES['coverselect']['name'][$key], $allowedExt, 0); if ($image['valid'] && $size < $maxsize && $size > 0 && !empty($image['width']) && !empty($image['height'])) { $rand = mt_rand(); $tmp_name = $_FILES['coverselect']['tmp_name'][$key]; $name = pathinfo($_FILES['coverselect']['name'][$key], PATHINFO_FILENAME); $fullname = $_FILES['coverselect']['name'][$key]; $size = $_FILES['coverselect']['size'][$key]; $type = pathinfo($_FILES['coverselect']['name'][$key], PATHINFO_EXTENSION); $finalName = mt_rand() . '_' . mt_rand() . '_' . mt_rand() . '.' . $db->real_escape_string($ext); // Fix image orientation if possible imageOrientation($tmp_name); // Move the file into the uploaded folder move_uploaded_file($tmp_name, 'uploads/covers/' . $finalName); // Send the image name in array format to the function $image = array('cover' => $finalName); $updateUserSettings->query_array('users', $image); header("Location: " . $CONF['url'] . "/index.php?a=settings&b=avatar&m=s"); } elseif ($_FILES['coverselect']['name'][$key] == '') { // If no file is selected header("Location: " . $CONF['url'] . "/index.php?a=settings&b=avatar&m=nf"); } elseif ($size > $maxsize || $size == 0) { // If the file size is higher than allowed or 0 header("Location: " . $CONF['url'] . "/index.php?a=settings&b=avatar&m=fs"); } else { // If the file format is not allowed header("Location: " . $CONF['url'] . "/index.php?a=settings&b=avatar&m=wf"); } } } if ($_GET['m'] == 's') { $TMPL['message'] = notificationBox('success', $LNG['profile_picture_saved']); } elseif ($_GET['m'] == 'nf') { $TMPL['message'] = notificationBox('error', $LNG['no_file']); } elseif ($_GET['m'] == 'fs') { $TMPL['message'] = notificationBox('error', sprintf($LNG['file_exceeded'], round($maxsize / 1048576, 2))); } elseif ($_GET['m'] == 'wf') { $TMPL['message'] = notificationBox('error', sprintf($LNG['file_format'], $settings['format'])); } } elseif ($_GET['b'] == 'social') { $skin = new skin('settings/social'); $page = ''; // Create the class instance $updateUserSettings = new updateUserSettings(); $updateUserSettings->db = $db; $updateUserSettings->id = $verify['idu']; if (!empty($_POST)) { $TMPL['message'] = $updateUserSettings->query_array('users', array_map("strip_tags_array", $_POST)); } $userSettings = $updateUserSettings->getSettings(); $TMPL['currentFacebook'] = $userSettings['facebook']; $TMPL['currentTwitter'] = $userSettings['twitter']; $TMPL['currentGplus'] = $userSettings['gplus']; $TMPL['currentYouTube'] = $userSettings['youtube']; $TMPL['currentSoundCloud'] = $userSettings['soundcloud']; $TMPL['currentLastfm'] = $userSettings['lastfm']; $TMPL['currentMySpace'] = $userSettings['myspace']; $TMPL['currentVimeo'] = $userSettings['vimeo']; $TMPL['currentTumblr'] = $userSettings['tumblr']; } elseif ($_GET['b'] == 'notifications') { $skin = new skin('settings/notifications'); $page = ''; // Create the class instance $updateUserSettings = new updateUserSettings(); $updateUserSettings->db = $db; $updateUserSettings->id = $verify['idu']; if (!empty($_POST)) { $TMPL['message'] = $updateUserSettings->query_array('users', array_map("strip_tags_array", $_POST)); } $userSettings = $updateUserSettings->getSettings(); if ($userSettings['notificationl'] == '0') { $TMPL['loff'] = 'selected="selected"'; } else { $TMPL['lon'] = 'selected="selected"'; } if ($userSettings['notificationc'] == '0') { $TMPL['coff'] = 'selected="selected"'; } else { $TMPL['con'] = 'selected="selected"'; } if ($userSettings['notificationd'] == '0') { $TMPL['doff'] = 'selected="selected"'; } else { $TMPL['don'] = 'selected="selected"'; } if ($userSettings['notificationf'] == '0') { $TMPL['foff'] = 'selected="selected"'; } else { $TMPL['fon'] = 'selected="selected"'; } if ($userSettings['email_comment'] == '0') { $TMPL['ecoff'] = 'selected="selected"'; } else { $TMPL['econ'] = 'selected="selected"'; } if ($userSettings['email_like'] == '0') { $TMPL['eloff'] = 'selected="selected"'; } else { $TMPL['elon'] = 'selected="selected"'; } if ($userSettings['email_new_friend'] == '0') { $TMPL['enfoff'] = 'selected="selected"'; } else { $TMPL['enfon'] = 'selected="selected"'; } } else { $skin = new skin('settings/general'); $page = ''; // Create the class instance $updateUserSettings = new updateUserSettings(); $updateUserSettings->db = $db; $updateUserSettings->id = $verify['idu']; if (!empty($_POST)) { $TMPL['message'] = $updateUserSettings->query_array('users', array_map("strip_tags_array", $_POST)); } $userSettings = $updateUserSettings->getSettings(); $TMPL['countries'] = countries(1, $userSettings['country']); $TMPL['currentFirstName'] = $userSettings['first_name']; $TMPL['currentLastName'] = $userSettings['last_name']; $TMPL['currentEmail'] = $userSettings['email']; $TMPL['currentCity'] = $userSettings['city']; $TMPL['currentWebsite'] = $userSettings['website']; $TMPL['currentDescription'] = $userSettings['description']; if ($userSettings['private'] == '1') { $TMPL['on'] = 'selected="selected"'; } elseif ($userSettings['private'] == '2') { $TMPL['semi'] = 'selected="selected"'; } else { $TMPL['off'] = 'selected="selected"'; } if ($userSettings['offline'] == '1') { $TMPL['con'] = 'selected="selected"'; } else { $TMPL['coff'] = 'selected="selected"'; } } $page .= $skin->make(); $TMPL = $TMPL_old; unset($TMPL_old); $TMPL['settings'] = $page; } else { // If fake cookies are set, or they are set wrong, delete everything and redirect to home-page $loggedIn->logOut(); header("Location: " . $CONF['url'] . "/index.php?a=welcome"); } } else { // If the session or cookies are not set, redirect to home-page header("Location: " . $CONF['url'] . "/index.php?a=welcome"); } // Bold the current link if (isset($_GET['b'])) { $LNG["user_menu_{$_GET['b']}"] = '<strong>' . $LNG["user_menu_{$_GET['b']}"] . '</strong>'; $TMPL['welcome'] = $LNG["user_ttl_{$_GET['b']}"]; } else { $LNG["user_menu_general"] = '<strong>' . $LNG["user_menu_general"] . '</strong>'; $TMPL['welcome'] = $LNG["user_ttl_general"]; } $TMPL['user_menu'] = ' <a href="' . $CONF['url'] . '/index.php?a=settings" rel="loadpage">' . $LNG['user_menu_general'] . '</a> <a href="' . $CONF['url'] . '/index.php?a=settings&b=avatar" rel="loadpage">' . $LNG['user_menu_avatar'] . '</a> <a href="' . $CONF['url'] . '/index.php?a=settings&b=notifications" rel="loadpage">' . $LNG['user_menu_notifications'] . '</a> <a href="' . $CONF['url'] . '/index.php?a=settings&b=social" rel="loadpage">' . $LNG['user_menu_social'] . '</a> <a href="' . $CONF['url'] . '/index.php?a=settings&b=security" rel="loadpage">' . $LNG['user_menu_security'] . '</a> ' . ($settings['paypalapp'] ? '<a href="' . $CONF['url'] . '/index.php?a=pro" rel="loadpage">' . $LNG['user_menu_plan'] . '</a>' : ''); $TMPL['title'] = $LNG['title_settings'] . ' - ' . $settings['title']; $skin = new skin('settings/content'); return $skin->make(); }
$tmpl->setvar('bin_uudeview', $cfg["bin_uudeview"]); $tmpl->setvar('validate_uudeview', validateBinary($cfg["bin_uudeview"])); $tmpl->setvar('bin_unzip', $cfg["bin_unzip"]); $tmpl->setvar('validate_unzip', validateBinary($cfg["bin_unzip"])); $tmpl->setvar('bin_cksfv', $cfg["bin_cksfv"]); $tmpl->setvar('validate_cksfv', validateBinary($cfg["bin_cksfv"])); $tmpl->setvar('bin_vlc', $cfg["bin_vlc"]); $tmpl->setvar('validate_vlc', validateBinary($cfg["bin_vlc"])); $tmpl->setvar('php_uname1', php_uname('s')); $tmpl->setvar('php_uname2', php_uname('r')); $tmpl->setvar('bin_unrar', $cfg["bin_unrar"]); $tmpl->setvar('validate_unrar', validateBinary($cfg["bin_unrar"])); switch ($cfg["_OS"]) { case 1: $tmpl->setvar('loadavg_path', $cfg["loadavg_path"]); $tmpl->setvar('validate_loadavg', validateFile($cfg["loadavg_path"])); $tmpl->setvar('bin_netstat', $cfg["bin_netstat"]); $tmpl->setvar('validate_netstat', validateBinary($cfg["bin_netstat"])); break; case 2: $tmpl->setvar('bin_sockstat', $cfg["bin_sockstat"]); $tmpl->setvar('validate_sockstat', validateBinary($cfg["bin_sockstat"])); break; } // $tmpl->setvar('_OS', $cfg["_OS"]); // tmplSetTitleBar("Administration - Server Settings"); tmplSetAdminMenu(); tmplSetFoot(); tmplSetIidVars();
function queueSettings() { global $cfg; include_once "AliasFile.php"; include_once "RunningTorrent.php"; DisplayHead("Administration - Search Settings"); // Admin Menu displayMenu(); // Queue Manager Section echo "<div align=\"center\">"; echo "<a name=\"QManager\" id=\"QManager\"></a>"; echo "<table width=\"100%\" border=1 bordercolor=\"" . $cfg["table_admin_border"] . "\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"" . $cfg["table_data_bg"] . "\">"; echo "<tr><td bgcolor=\"" . $cfg["table_header_bg"] . "\" background=\"themes/" . $cfg["theme"] . "/images/bar.gif\">"; echo "<font class=\"title\">"; if (checkQManager() > 0) { echo " <img src=\"images/green.gif\" align=\"absmiddle\" align=\"absmiddle\"> Queue Manager Running [PID=" . getQManagerPID() . " with " . strval(getRunningTorrentCount()) . " torrent(s)]"; } else { echo " <img src=\"images/black.gif\" align=\"absmiddle\"> Queue Manager Off"; } echo "</font>"; echo "</td></tr><tr><td align=\"center\">"; ?> <script language="JavaScript"> function validateSettings() { var rtnValue = true; var msg = ""; if (isNumber(document.theForm.maxServerThreads.value) == false) { msg = msg + "* Max Server Threads must be a valid number.\n"; document.theForm.maxServerThreads.focus(); } if (isNumber(document.theForm.maxUserThreads.value) == false) { msg = msg + "* Max User Threads must be a valid number.\n"; document.theForm.maxUserThreads.focus(); } if (isNumber(document.theForm.sleepInterval.value) == false) { msg = msg + "* Sleep Interval must be a valid number.\n"; document.theForm.sleepInterval.focus(); } if (msg != "") { rtnValue = false; alert("Please check the following:\n\n" + msg); } return rtnValue; } function isNumber(sText) { var ValidChars = "0123456789."; var IsNumber = true; var Char; for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) { IsNumber = false; } } return IsNumber; } </script> <div align="center"> <table cellpadding="5" cellspacing="0" border="0" width="100%"> <form name="theForm" action="admin.php?op=updateConfigSettings" method="post" onsubmit="return validateSettings()"> <input type="Hidden" name="continue" value="queueSettings"> <tr> <td align="left" width="350" valign="top"><strong>Enable Queue Manager</strong><br> Enable the Queue Manager to allow users to queue torrents: </td> <td> <select name="AllowQueing"> <option value="1">true</option> <option value="0" <?php if (!$cfg["AllowQueing"]) { echo "selected"; } ?> >false</option> </select> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>tfQManager Path</strong><br> Specify the path to the tfQManager python script: </td> <td valign="top"> <input name="tfQManager" type="Text" maxlength="254" value="<?php echo $cfg["tfQManager"]; ?> " size="55"><?php echo validateFile($cfg["tfQManager"]); ?> </td> </tr> <!-- Only used for develpment or if you really really know what you are doing <tr> <td align="left" width="350" valign="top"><strong>Enable Queue Manager Debugging</strong><br> Creates huge log files only for debugging. DO NOT KEEP THIS MODE ON: </td> <td> <select name="debugTorrents"> <option value="1">true</option> <option value="0" <?php if (array_key_exists("debugTorrents", $cfg)) { if (!$cfg["debugTorrents"]) { echo "selected"; } } else { insertSetting("debugTorrents", false); echo "selected"; } ?> >false</option> </select> </td> </tr> --> <tr> <td align="left" width="350" valign="top"><strong>Max Server Threads</strong><br> Specify the maximum number of torrents the server will allow to run at one time (admins may override this): </td> <td valign="top"> <input name="maxServerThreads" type="Text" maxlength="3" value="<?php echo $cfg["maxServerThreads"]; ?> " size="3"> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>Max User Threads</strong><br> Specify the maximum number of torrents a single user may run at one time: </td> <td valign="top"> <input name="maxUserThreads" type="Text" maxlength="3" value="<?php echo $cfg["maxUserThreads"]; ?> " size="3"> </td> </tr> <tr> <td align="left" width="350" valign="top"><strong>Polling Interval</strong><br> Number of seconds the Queue Manager will sleep before checking for new torrents to run: </td> <td valign="top"> <input name="sleepInterval" type="Text" maxlength="3" value="<?php echo $cfg["sleepInterval"]; ?> " size="3"> </td> </tr> <tr> <td align="center" colspan="2"> <br><br> <input type="Submit" value="Update Settings"> </td> </tr> </form> </table> </div> <br> <?php echo "</td></tr>"; echo "</table></div>"; $displayQueue = True; $displayRunningTorrents = True; // Its a timming thing. if ($displayRunningTorrents) { // get Running Torrents. $runningTorrents = getRunningTorrents(); } if ($displayQueue) { $output = ""; echo "\n"; echo "<table width=\"760\" border=1 bordercolor=\"" . $cfg["table_admin_border"] . "\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"" . $cfg["table_data_bg"] . "\">"; echo "<tr><td colspan=6 bgcolor=\"" . $cfg["table_header_bg"] . "\" background=\"themes/" . $cfg["theme"] . "/images/bar.gif\">"; echo "<table width=\"100%\" cellpadding=0 cellspacing=0 border=0><tr>"; echo "<td><img src=\"images/properties.png\" width=18 height=13 border=0> <font class=\"title\"> Queued Items </font></td>"; echo "</tr></table>"; echo "</td></tr>"; echo "<tr>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\" width=\"15%\"><div align=center class=\"title\">" . _USER . "</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _FILE . "</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\" width=\"15%\"><div align=center class=\"title\">" . _TIMESTAMP . "</div></td>"; echo "</tr>"; echo "\n"; $qDir = $cfg["torrent_file_path"] . "queue/"; if (is_dir($cfg["torrent_file_path"])) { if (is_writable($cfg["torrent_file_path"]) && !is_dir($qDir)) { @mkdir($qDir, 0777); } // get Queued Items and List them out. $output .= ""; $handle = @opendir($qDir); while ($filename = readdir($handle)) { if ($filename != "tfQManager.log") { if ($filename != "." && $filename != ".." && strpos($filename, ".pid") == 0) { $output .= "<tr>"; $output .= "<td><div class=\"tiny\">"; $af = new AliasFile(str_replace("queue/", "", $qDir) . str_replace(".Qinfo", "", $filename), ""); $output .= $af->torrentowner; $output .= "</div></td>"; $output .= "<td><div align=center><div class=\"tiny\" align=\"left\">" . str_replace(array(".Qinfo", ".stat"), "", $filename) . "</div></td>"; $output .= "<td><div class=\"tiny\" align=\"center\">" . date(_DATETIMEFORMAT, strval(filectime($qDir . $filename))) . "</div></td>"; $output .= "</tr>"; $output .= "\n"; } } } closedir($handle); } if (strlen($output) == 0) { $output = "<tr><td colspan=3><div class=\"tiny\" align=center>Queue is Empty</div></td></tr>"; } echo $output; echo "</table>"; } if ($displayRunningTorrents) { $output = ""; echo "\n"; echo "<table width=\"760\" border=1 bordercolor=\"" . $cfg["table_admin_border"] . "\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"" . $cfg["table_data_bg"] . "\">"; echo "<tr><td colspan=6 bgcolor=\"" . $cfg["table_header_bg"] . "\" background=\"themes/" . $cfg["theme"] . "/images/bar.gif\">"; echo "<table width=\"100%\" cellpadding=0 cellspacing=0 border=0><tr>"; echo "<td><img src=\"images/properties.png\" width=18 height=13 border=0> <font class=\"title\"> Running Items </font></td>"; echo "</tr></table>"; echo "</td></tr>"; echo "<tr>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\" width=\"15%\"><div align=center class=\"title\">" . _USER . "</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\"><div align=center class=\"title\">" . _FILE . "</div></td>"; echo "<td bgcolor=\"" . $cfg["table_header_bg"] . "\" width=\"1%\"><div align=center class=\"title\">" . str_replace(" ", "<br>", _FORCESTOP) . "</div></td>"; echo "</tr>"; echo "\n"; // get running torrents and List them out. $runningTorrents = getRunningTorrents(); if (is_array($runningTorrents)) { foreach ($runningTorrents as $key => $value) { $rt = new RunningTorrent($value); $output .= $rt->BuildAdminOutput(); } } if (strlen($output) == 0) { $output = "<tr><td colspan=3><div class=\"tiny\" align=center>No Running Torrents</div></td></tr>"; } echo $output; echo "</table>"; } DisplayFoot(); }