public function display($tpl = null) { $state = $this->get('State'); $item = $this->get('Item'); $user = JFactory::getUser(); $app = JFactory::getApplication(); $params = $app->getParams(); $this->form = $this->get('Form'); if ($user->get('guest') && !$params->get('allow_guest')) { $app->redirect('index.php', JText::_('COM_TRACKER_NOT_LOGGED_IN'), 'error'); } if (TrackerHelper::user_permissions('upload_torrents', $user->id) == 0) { $app->redirect('index.php', JText::_('COM_TRACKER_USER_CANT_UPLOAD'), 'error'); } $this->assignRef('state', $state); $this->assignRef('item', $item); $this->assignRef('params', $params); parent::display($tpl); }
/** * Display the view */ public function display($tpl = null) { $state = $this->get('State'); $item = $this->get('Item'); $user = JFactory::getUser(); $app = JFactory::getApplication(); $params = $app->getParams(); $this->form = $this->get('Form'); $document = JFactory::getDocument(); $document->addScript('includes/js/joomla.javascript.js'); if ($user->get('guest') && !$params->get('allow_guest')) { $app->redirect('index.php', JText::_('COM_TRACKER_NOT_LOGGED_IN'), 'error'); } if (TrackerHelper::user_permissions('write_comments', $user->id_level) == 0) { $app->redirect('index.php', JText::_('COM_XBT_TRACKER_USER_CANNOT_COMMENT_TORRENT'), 'error'); } $this->assignRef('state', $state); $this->assignRef('item', $item); $this->assignRef('user', $user); parent::display($tpl); }
public function commented() { $app = JFactory::getApplication(); $db = JFactory::getDBO(); $torrentid = (int) $_POST['torrentid']; $userid = (int) $_POST['userid']; $description = $_POST['jform']['description']; $query = $db->getQuery(true); $query->insert('#__tracker_comments'); $query->set('torrentid = ' . $db->quote($torrentid)); $query->set('userid = ' . $db->quote($userid)); $query->set('commentdate = ' . $db->quote(date("Y-m-d"))); $query->set('description = ' . $db->quote($description)); if (TrackerHelper::user_permissions('autopublish_comments', $userid, 1)) { $query->set('state = 1'); } else { $query->set('state = 0'); } $db->setQuery($query); if (!$db->query()) { JError::raiseError(500, $db->getErrorMsg()); } $app->redirect(JRoute::_('index.php?option=com_tracker&view=torrent&id=' . (int) $torrentid), JText::_('COM_XBT_TRACKER_COMMENT_COMMENT_ADDED'), 'notice'); }
if (TrackerHelper::user_permissions('edit_torrents', $user->id)) { echo '<input type="text" style="text-align:right;" id="download_multiplier" name="download_multiplier" class="inputbox" size="10" value="' . $this->item->download_multiplier . '" />'; } else { echo $this->item->download_multiplier . " " . JText::_('COM_TRACKER_TORRENT_TIMES'); echo '<input type="hidden" name="download_multiplier" value="' . $this->item->download_multiplier . '" />'; } ?> </span> <span> </span> <span style="width:1%; wrap:nowrap; align:right;"><?php echo JText::_('COM_TRACKER_UPLOAD_MULTIPLIER'); ?> :</span> <span style="width:1%; wrap:nowrap; align:left;"> <?php if (TrackerHelper::user_permissions('edit_torrents', $user->id)) { echo '<input type="text" style="text-align:right;" id="upload_multiplier" name="upload_multiplier" class="inputbox" size="10" value="' . $this->item->upload_multiplier . '" />'; } else { echo $this->item->upload_multiplier . " " . JText::_('COM_TRACKER_TORRENT_TIMES'); echo '<input type="hidden" name="upload_multiplier" value="' . $this->item->upload_multiplier . '" />'; } ?> </span> </div> <div style="clear: both;"><br /></div> <?php } else { ?> <input type="hidden" name="download_multiplier" value="<?php echo $this->item->download_multiplier; ?>
} if ($params->get('worst_completed_torrents') && count($tracker_stats->worst_completed_torrents)) { echo '<br /><div id="container">'; echo '<div id="row">'; echo '<div id="value-center"><b> ' . JText::_('COM_TRACKER_STATS_NAME') . ' </b></div>'; echo '<div id="value-center"><b> ' . JText::_('COM_TRACKER_STATS_SIZE') . ' </b></div>'; echo '<div id="value-center"><b> ' . JText::_('COM_TRACKER_STATS_CREATED_TIME') . ' </b></div>'; echo '<div id="value-center"><b> ' . JText::_('COM_TRACKER_TORRENT_SEEDERS_SMALL') . ' </b></div>'; echo '<div id="value-center"><b> ' . JText::_('COM_TRACKER_TORRENT_LEECHERS_SMALL') . ' </b></div>'; echo '<div id="value-center"><b> ' . JText::_('COM_TRACKER_TORRENT_COMPLETED_SMALL') . ' </b></div>'; echo '<div id="value-center"><b> ' . JText::_('JCATEGORY') . ' </b></div>'; echo '</div>'; foreach ($tracker_stats->worst_completed_torrents as $worst_completed_torrents) { echo '<div id="row">'; echo '<div id="value" style="overflow: hidden; white-space: pre-wrap;"> '; if (TrackerHelper::user_permissions('download_torrents', $session->get('user')->id, 1)) { echo '<a href="index.php?option=com_tracker&view=torrent&id=' . $worst_completed_torrents->fid . '">' . $worst_completed_torrents->name . '</a>'; } else { echo $worst_completed_torrents->name; } echo ' </div>'; echo '<div id="value-right"> ' . TrackerHelper::make_size($worst_completed_torrents->size) . ' </div>'; echo '<div id="value-center"> ' . date('Y.m.d', strtotime($worst_completed_torrents->created_time)) . ' </div>'; echo '<div id="value-center"> ' . $worst_completed_torrents->seeders . ' </div>'; echo '<div id="value-center"> ' . $worst_completed_torrents->leechers . ' </div>'; echo '<div id="value-center"> ' . $worst_completed_torrents->completed . ' </div>'; //if (empty($tracker_stats->country)) $tracker_stats->country = TrackerHelper::getCountryFlag($params->get('defaultcountry')); $category_params = new JRegistry(); $category_params->loadString($worst_completed_torrents->cat_params); echo '<div id="value-center"> '; if (is_file($_SERVER['DOCUMENT_ROOT'] . DS . JUri::root(true) . $category_params->get('image'))) {
public function download() { $app = JFactory::getApplication(); $params = JComponentHelper::getParams('com_tracker'); $torrent_id = $this->getState('torrent.id'); $db = $this->getDbo(); $user = JFactory::getUser(); $config = new JConfig(); if ($user->get('guest') && $params->get('allow_guest') == 0 || !TrackerHelper::user_permissions('download_torrents', $user->id)) { echo "<script> alert(\"" . JText::_("COM_TRACKER_USER_CANNOT_DOWNLOAD_TORRENT") . "\"); window.history.go(-1);</script>\n"; return; } # Get the total number of records $query = $db->getQuery(true); $query->select('count(*)'); $query->from('#__tracker_torrents'); $query->where('fid = ' . (int) $torrent_id); $db->setQuery($query); $total = $db->loadResult(); if (!$total) { echo "<script> alert('" . JText::_('COM_TRACKER_INVALID_TORRENT') . "'); window.history.go(-1);</script>\n"; return; } // All OK so far, let's continue # Get the torrent $query->clear(); $query->select('*'); $query->from('#__tracker_torrents'); $query->where('fid = ' . (int) $torrent_id); $db->setQuery($query); $row = $db->loadObjectList(); $row = $row[0]; $torrentfile = $row->fid . "_" . $row->filename; if (!is_file(JPATH_SITE . DS . $params->get('torrent_dir') . $torrentfile)) { echo "<script> alert(\"" . JText::_('COM_TRACKER_FILE_DOESNT_EXIST') . "\"); window.history.go(-1);</script>\n"; exit; } clearstatcache(); if (!is_readable(JPATH_SITE . DS . $params->get('torrent_dir') . $torrentfile)) { echo "<script> alert(\"" . JText::_('COM_TRACKER_FILE_ISNT_READABLE') . "\"); window.history.go(-1);</script>\n"; exit; } clearstatcache(); # Get the xbt tracker config $query->clear(); $query->select('name, value'); $query->from('xbt_config'); $db->setQuery($query); $tracker = $db->loadObjectList('name'); // ############################################################################################################################### // New Torrent pass version use // ############################################################################################################################### $uid = $user->id; $torrent_pass_private_key = $tracker['torrent_pass_private_key']->value; # Get the user torrent pass version $query->clear(); $query->select('torrent_pass_version'); $query->from('#__tracker_users'); $query->where('id = ' . $user->id); $db->setQuery($query); $torrent_pass_version = $db->loadResult(); $torrent = new Torrent(JPATH_SITE . DS . $params->get('torrent_dir') . $torrentfile); // ############################################################################################################################### // reset announce trackers $torrent->announce(false); // Private Torrents if ($params->get('make_private') == 1 && !$torrent->is_private()) { $torrent->is_private(true); } // Generate the new torrent passkey from the newly modified torrent $torrent_pass = sprintf('%08x%s', $user->id, substr(sha1(sprintf('%s %d %d %s', $torrent_pass_private_key, $torrent_pass_version, $user->id, pack('H*', $torrent->hash_info()))), 0, 24)); // Check if we have several trackers if ($params->get('trackers_address') == '') { $announceurl = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $tracker['listen_port']->value . '/' . $torrent_pass . '/announce'; // adds the default "site" tracker $torrent->announce($announceurl); } else { $trackers_address = explode(",", $params->get('trackers_address')); $trackers_address = str_replace(" ", "", $trackers_address); for ($i = 0; $i < count($trackers_address); $i++) { $other_trackers = 'http://' . $trackers_address[$i] . ':' . $tracker['listen_port']->value . '/' . $torrent_pass . '/announce'; $torrent->announce($other_trackers); } } // Put some comment in the torrent $torrent->comment('Torrent downloaded from ' . $config->sitename); // If we have tags enabled, put the site name in a Tag and send the torrent filename if ($params->get('tag_in_torrent') == 1) { $torrent->send('[' . $config->sitename . ']' . $row->name . '.torrent'); } else { $torrent->send(); } }
public function getItem($pk = null) { $app = JFactory::getApplication(); $session = JFactory::getSession(); $db = JFactory::getDBO(); $params = JComponentHelper::getParams('com_tracker'); $user_profile = null; if (JRequest::getVar('id', '', 'get', 'int')) { $userID = JRequest::getVar('id', '', 'get', 'int'); } else { $userID = $session->get('user')->id; } // In case the user is new, check the database and add it to the #__tracker_users TrackerHelper::get_new_users(); // Load the user from the database (and check if the id exists) $query = $db->getQuery(true); $query->clear(); $query->select('id'); $query->from('#__users'); $query->where('id = ' . (int) $userID); $query->limit('0,1'); $db->setQuery($query); $user_profileID = $db->loadResult(); if ($user_profileID != 0) { $user_profile = JFactory::getUser($user_profileID); // load the logged in user // Get the user tracker information $query = $db->getQuery(true); $query->clear(); $query->select('*'); $query->from('#__tracker_users'); $query->where('id = ' . (int) $user_profile->id); $query->limit('0,1'); $db->setQuery($query); $user_profile->tracker_info = $db->loadNextObject(); if ($params->get('enable_countries')) { // If the user doesn't have the country defined, get the default country for component parameters if ($user_profile->tracker_info->countryID == 0) { $user_profile->tracker_info->countryID == $params->get('defaultcountry'); } $query = $db->getQuery(true); // Get the user country $query->select('name, image'); $query->from('#__tracker_countries'); $query->where('id = ' . (int) $user_profile->tracker_info->countryID); $query->limit('0,1'); $db->setQuery($query); $user_profile->country_info = $db->loadNextObject(); } if ($params->get('enable_thankyou')) { // Get the number of times the user was thanked $query->clear(); $query->select('COUNT(u.id) as total_thanks'); $query->from('`#__tracker_torrent_thanks` AS ttt'); $query->join('LEFT', '`#__tracker_torrents` AS tt ON tt.fid = ttt.torrentID'); $query->join('LEFT', '`#__users` AS u ON u.id = tt.uploader'); $query->where('u.id = ' . (int) $user_profile->id); $db->setQuery($query); $user_profile->total_thanks = $db->loadResult(); // Get the number of thanks the user gave $query->clear(); $query->select('COUNT(uid) as thanker'); $query->from('#__tracker_torrent_thanks'); $query->where('uid = ' . (int) $user_profile->id); $db->setQuery($query); $user_profile->thanker = $db->loadResult(); } // Get the user last IP and tracker activity $query->clear(); $query->select('ipa, mtime'); $query->from('#__tracker_announce_log'); $query->where('uid = ' . (int) $user_profile->id); $query->order('id DESC'); $query->limit('0,1'); $db->setQuery($query); $user_profile->announce = $db->loadNextObject(); if (!$user_profile->announce) { $user_profile->lastseen = JText::_('COM_TRACKER_LAST_TRACKER_ACTIVITY_NEVER'); $user_profile->announce = new stdClass(); $user_profile->announce->ipa = JText::_('COM_TRACKER_NO_LAST_IP'); } else { $user_profile->lastseen = date('Y-m-d H:i:s', $user_profile->announce->mtime) . ' - ' . TrackerHelper::last_activity(date('Y-m-d H:i:s', $user_profile->announce->mtime), 1, 1); $user_profile->announce->ipa = long2ip($user_profile->announce->ipa); } // Get the user group $query->clear(); $query->select('*'); $query->from('#__tracker_groups'); $query->where('id = ' . (int) $user_profile->tracker_info->groupID); $query->order('id DESC'); $query->limit('0,1'); $db->setQuery($query); $user_profile->group_info = $db->loadNextObject(); if ($params->get('enable_donations')) { // Get the user donations $query->clear(); $query->select('sum(donated) as donated, sum(credited) as credited'); $query->from('#__tracker_donations'); $query->where('uid = ' . (int) $user_profile->id); $query->where('state = 1'); $db->setQuery($query); $user_profile->user_donations = $db->loadNextObject(); } // ---------------------------------------- Snatched Torrents // Get total number of snatches $query->clear(); $query->select('count(fu.fid)'); $query->from('#__tracker_files_users AS fu'); $query->join('LEFT', '#__tracker_torrents as t on t.fid = fu.fid'); $query->where('fu.uid = ' . (int) $user_profile->id); $query->where('fu.completed > 0'); $query->where('t.uploader <> ' . (int) $user_profile->id); $db->setQuery($query); if ($user_profile->total_snatch = $db->loadResult()) { // Get the user snatched torrents $query->clear(); $query->select('DISTINCT(fu.fid), t.name, t.leechers, t.seeders, t.completed, fu.downloaded, fu.uploaded'); $query->from('#__tracker_files_users AS fu'); $query->join('LEFT', '#__tracker_torrents as t on t.fid = fu.fid'); $query->where('fu.uid = ' . (int) $user_profile->id); $query->where('fu.completed > 0'); $query->where('t.uploader <> ' . (int) $user_profile->id); $query->order('fu.fid DESC'); $db->setQuery($query); $user_profile->user_snatches = $db->loadObjectList(); } // ---------------------------------------- Uploaded Torrents # Get total number of uploaded torrents $query->clear(); $query->select('count(t.fid)'); $query->from('#__tracker_torrents AS t'); $query->join('LEFT', '#__users as u on u.id = t.uploader'); $query->where('t.uploader = ' . (int) $user_profile->id); $query->where('t.name <> \'\''); $query->order('t.fid DESC'); $db->setQuery($query); if ($user_profile->total_uploads = $db->loadResult()) { # Get the user uploaded torrents $query->clear(); $query->select('t.fid, t.name, t.leechers, t.seeders, t.completed'); $query->from('#__tracker_torrents AS t'); $query->join('LEFT', '#__users AS u ON u.id = t.uploader'); $query->where('t.uploader = ' . (int) $user_profile->id); $query->where('t.name <> \'\''); // Show the anonymous uploaded torrent if the user is the owner. If it's another user it keeps the anonymous torrents hidden if ($user_profile->id != $session->get('user')->id || TrackerHelper::user_permissions('edit_torrents', $user_profile->tracker_info->groupID) == 0) { $query->where('t.uploader_anonymous = 0'); } $query->order('t.fid DESC'); $db->setQuery($query); $user_profile->user_uploads = $db->loadObjectList(); } // ---------------------------------------- Seeded Torrents # Get the user seeded torrents $query->clear(); $query->select('count(fu.fid)'); $query->from('#__tracker_files_users AS fu'); $query->join('LEFT', '#__tracker_torrents as t on fu.fid = t.fid'); $query->where('fu.uid = ' . (int) $user_profile->id); $query->where('fu.left = 0'); $query->where('fu.active = 1'); $query->where('t.name <> \'\''); $query->order('fu.fid DESC'); $db->setQuery($query); if ($user_profile->total_seeds = $db->loadResult()) { # Get the user seeded torrents $query->clear(); $query->select('DISTINCT(fu.fid), t.name, t.leechers, t.seeders, t.completed'); $query->from('#__tracker_files_users AS fu'); $query->join('LEFT', '#__tracker_torrents as t on fu.fid = t.fid'); $query->where('fu.uid = ' . (int) $user_profile->id); $query->where('fu.left = 0'); $query->where('fu.active = 1'); $query->where('t.name <> \'\''); $query->order('fu.fid DESC'); $db->setQuery($query); $user_profile->user_seeds = $db->loadObjectList(); } // ---------------------------------------- Leeched and Ran # Get the leeched and run torrents $query->clear(); $query->select('count(fu.fid)'); $query->from('#__tracker_files_users AS fu'); $query->join('LEFT', '#__tracker_torrents as t on fu.fid = t.fid'); $query->where('fu.uid = ' . (int) $user_profile->id); $query->where('fu.left = 0'); $query->where('fu.active = 0'); $query->where('fu.uploaded = 0'); $query->where('fu.downloaded > 0'); $query->where('t.name <> \'\''); $query->order('fu.fid DESC'); $db->setQuery($query); if ($user_profile->total_hitandran = $db->loadResult()) { # Get the leeched and run torrents $query->clear(); $query->select('DISTINCT(fu.fid), t.name, t.leechers, t.seeders, t.completed, fu.downloaded, fu.uploaded'); $query->from('#__tracker_files_users AS fu'); $query->join('LEFT', '#__tracker_torrents as t on fu.fid = t.fid'); $query->where('fu.uid = ' . (int) $user_profile->id); $query->where('fu.left = 0'); $query->where('fu.active = 0'); $query->where('fu.uploaded = 0'); $query->where('fu.downloaded > 0'); $query->where('t.name <> \'\''); $query->order('fu.fid DESC'); $db->setQuery($query); $user_profile->user_hitruns = $db->loadObjectList(); } } else { $user_profile->id = 0; return $user_profile; } return $user_profile; }
?> </td><?php } ?> <?php if ($this->params->get('tl_upload_multiplier')) { ?> <td width="1%" align="center" nowrap> <?php echo $item->upload_multiplier; ?> </td><?php } ?> <?php if (TrackerHelper::user_permissions('download_torrents', $this->user->id) && $this->params->get('tl_download_image')) { ?> <td width="1%" align="center"> <a href="<?php echo JRoute::_('index.php?option=com_tracker&task=torrent.download&id=' . $item->fid); ?> "> <img src="<?php echo JURI::base(); ?> components/com_tracker/assets/images/download.gif" alt="<?php echo JText::_('TORRENT_DOWNLOAD_TORRENT_LIST_ALT'); ?> " border="0" /> </a> </td>
?> <tr> <td class="row1" align="right"><b><?php echo ' ' . JText::_('COM_TRACKER_USER_CAN_DOWNLOAD'); ?> :</b></td> <td class="row0" align="left"><?php echo ' ' . JText::_('COM_TRACKER_USER_CANNOT_DOWNLOAD'); ?> </td> </tr> <?php } } if ($this->params->get('enable_donations')) { if ((TrackerHelper::user_permissions('edit_torrents', $this->session->get('user')->id, 1) || $this->session->get('user')->id == $this->item->id) && $this->item->user_donations->donated) { ?> <tr> <td class="row1" align="right"><b><?php echo JText::_('COM_TRACKER_DONATED'); ?> :</b></td> <td class="row0" align="left"> <?php echo ' $' . number_format($this->item->user_donations->donated, 2, ',', ' '); echo ' (' . TrackerHelper::make_size($this->item->user_donations->credited * 1073741824) . ')'; ?> </td> </tr> <?php }
" src="<?php echo JURI::base() . $this->hitrunner->countryimage; ?> " width="32" /> </td> <td width="10%" nowrap align="right"><?php echo TrackerHelper::make_size($this->hitrunner->downloaded); ?> </td> <td width="10%" nowrap align="right"><?php echo TrackerHelper::make_size($this->hitrunner->uploaded); ?> </td> </tr> <?php $k = 1 - $k; } ?> </table> </div> <?php } ?> </div> <?php // Enable the commenting system if we have it enabled if ($params->get('enable_comments') && TrackerHelper::user_permissions('view_comments', $user->get('id'), 1)) { TrackerHelper::comments($this->item->fid, $this->item->name); }
$items .= '<div id="value-center"> ' . $item->torrent_license . ' </div>'; } if ($params->get('image_file_field')) { $items .= '<div id="value-center"> ' . $item->image_file . ' </div>'; } if ($params->get('torrent_owner_field')) { $items .= '<div id="value-center"> ' . $item->torrent_owner . ' </div>'; } if ($params->get('torrent_category_field')) { $items .= '<div id="value-center"> ' . $item->torrent_category . ' </div>'; } if ($params->get('category_image_field')) { $category_params = new JRegistry(); $category_params->loadString($item->category_params); if (is_file($_SERVER['DOCUMENT_ROOT'] . JUri::root(true) . DS . $category_params->get('image'))) { $items .= '<div id="value-center"> <img id="image' . $item->fid . '" alt="' . $item->torrent_category . '" src="' . JUri::root(true) . DS . $category_params->get('image') . '" width="36" /> </div>'; } else { $items .= '<div id="value"> ' . $item->torrent_category . ' </div>'; } } if ($params->get('download_button') && TrackerHelper::user_permissions('can_leech', $user->id)) { $items .= '<div id="value-center"> <a href="' . JRoute::_("index.php?option=com_tracker&task=torrent.download&id=" . $item->fid) . '">'; $items .= '<img src="' . JURI::base() . 'components/com_tracker/assets/images/download.gif" alt="' . JText::_('TORRENT_DOWNLOAD_TORRENT_LIST_ALT') . '" border="0" /></a> </div>'; } $items .= '</div>'; } echo $head . $items; ?> </div> </div>