Example #1
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $params = $app->getParams();
     // Initialise variables
     $items = $this->get('Items');
     // No guests allowed
     if (!$params->get('allow_guest') && $user->get('guest')) {
         $app->redirect('index.php', JText::_('COM_TRACKER_NOT_LOGGED_IN'), 'error');
     }
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     $this->assignRef('items', $items);
     $this->assignRef('params', $params);
     $rss = JRequest::getVar('rss');
     if (!empty($rss)) {
         header('Content-Type: application/rss+xml; charset=ISO-8859-1');
         echo TrackerHelper::getRSS($items[0]);
         die;
     } else {
         parent::display($tpl);
     }
 }
Example #2
0
 protected function addToolbar()
 {
     JRequest::setVar('hidemainmenu', true);
     $user = JFactory::getUser();
     $isNew = $this->item->id == 0;
     $checkedOut = false;
     $canDo = TrackerHelper::getActions();
     JToolBarHelper::title(JText::_('COM_TRACKER_GROUPS'), 'groups');
     // If not checked out, can save the item.
     if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) {
         JToolBarHelper::apply('group.apply', 'JTOOLBAR_APPLY');
         JToolBarHelper::save('group.save', 'JTOOLBAR_SAVE');
     }
     if (!$checkedOut && $canDo->get('core.create')) {
         JToolBarHelper::custom('group.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
     }
     // If an existing item, can save to a copy.
     if (!$isNew && $canDo->get('core.create')) {
         JToolBarHelper::custom('group.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
     }
     if (empty($this->item->id)) {
         JToolBarHelper::cancel('group.cancel', 'JTOOLBAR_CANCEL');
     } else {
         JToolBarHelper::cancel('group.cancel', 'JTOOLBAR_CLOSE');
     }
 }
Example #3
0
 protected function addToolbar()
 {
     $canDo = TrackerHelper::getActions();
     $params = JComponentHelper::getParams('com_tracker');
     JToolBarHelper::title(JText::_('COM_TRACKER_GROUPS'), 'groups');
     if ($canDo->get('core.create') && !$params->get('forum_integration')) {
         JToolBarHelper::addNew('group.add', 'JTOOLBAR_NEW');
     }
     if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
         JToolBarHelper::editList('group.edit', 'JTOOLBAR_EDIT');
     }
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::divider();
         JToolBarHelper::custom('groups.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
         JToolBarHelper::custom('groups.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
     }
     if ($canDo->get('core.delete') && !$params->get('forum_integration')) {
         JToolBarHelper::divider();
         JToolBarHelper::deleteList('', 'groups.delete', 'JTOOLBAR_DELETE');
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences('com_tracker');
     }
 }
Example #4
0
 protected function addToolbar()
 {
     $canDo = TrackerHelper::getActions();
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_tracker');
     }
 }
Example #5
0
 protected function addToolbar()
 {
     $canDo = TrackerHelper::getActions();
     JToolBarHelper::title(JText::_('COM_TRACKER_UTILITIES'), 'utilities');
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences('com_tracker');
     }
 }
Example #6
0
 public function display($cachable = false, $urlparams = false)
 {
     require_once JPATH_COMPONENT . '/helpers/tracker.php';
     // set default view if not set
     JRequest::setVar('view', JRequest::getCmd('view', 'trackerpanel'));
     // Load the submenu.
     TrackerHelper::addSubmenu(JRequest::getCmd('view', 'trackerpanel'));
     // call parent behavior
     return parent::display($cachable);
 }
Example #7
0
 protected function addToolbar()
 {
     $canDo = TrackerHelper::getActions();
     JToolBarHelper::title(JText::_('COM_TRACKER_SETTINGS'), 'settings.png');
     if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
         JToolBarHelper::editList('setting.edit', 'JTOOLBAR_EDIT');
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences('com_tracker');
     }
 }
Example #8
0
 protected function addToolbar()
 {
     $canDo = TrackerHelper::getActions();
     JToolBarHelper::title(JText::_('COM_TRACKER_TORRENTS'), 'torrents');
     if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
         JToolBarHelper::editList('torrent.edit', 'JTOOLBAR_EDIT');
     }
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::deleteList('', 'torrents.delete', 'JTOOLBAR_DELETE');
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences('com_tracker');
     }
 }
Example #9
0
 protected function addToolbar()
 {
     JRequest::setVar('hidemainmenu', true);
     $user = JFactory::getUser();
     $checkedOut = false;
     $canDo = TrackerHelper::getActions();
     JToolBarHelper::title(JText::_('COM_TRACKER_TORRENTS'), 'torrents');
     // If not checked out, can save the item.
     if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) {
         JToolBarHelper::apply('torrent.apply', 'JTOOLBAR_APPLY');
         JToolBarHelper::save('torrent.save', 'JTOOLBAR_SAVE');
     }
     if (empty($this->item->id)) {
         JToolBarHelper::cancel('torrent.cancel', 'JTOOLBAR_CANCEL');
     } else {
         JToolBarHelper::cancel('torrent.cancel', 'JTOOLBAR_CLOSE');
     }
 }
Example #10
0
 protected function addToolbar()
 {
     $canDo = TrackerHelper::getActions();
     JToolBarHelper::title(JText::_('COM_TRACKER_THANKYOUS'), 'thankyou');
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::divider();
         JToolBarHelper::custom('thankyous.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
         JToolBarHelper::custom('thankyous.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
     }
     if ($canDo->get('core.delete')) {
         JToolBarHelper::divider();
         JToolBarHelper::deleteList('', 'thankyous.delete', 'JTOOLBAR_DELETE');
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences('com_tracker');
     }
 }
Example #11
0
 protected function addToolbar()
 {
     $canDo = TrackerHelper::getActions();
     JToolBarHelper::title(JText::_('COM_TRACKER_BANHOSTS'), 'ipban.png');
     if ($canDo->get('core.create')) {
         JToolBarHelper::addNew('banhost.add', 'JTOOLBAR_NEW');
     }
     if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
         JToolBarHelper::editList('banhost.edit', 'JTOOLBAR_EDIT');
     }
     if ($canDo->get('core.delete')) {
         JToolBarHelper::divider();
         JToolBarHelper::deleteList('', 'banhost.delete', 'JTOOLBAR_DELETE');
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences('com_tracker');
     }
 }
Example #12
0
 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);
 }
Example #13
0
 protected function addToolbar()
 {
     $canDo = TrackerHelper::getActions();
     JToolBarHelper::title(JText::_('COM_TRACKER_USERS'), 'users');
     if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
         JToolBarHelper::editList('user.edit', 'JTOOLBAR_EDIT');
     }
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::divider();
         JToolBarHelper::custom('users.unblock', 'publish.png', 'publish_f2.png', 'unblock', true);
         JToolBarHelper::custom('users.block', 'unpublish.png', 'unpublish_f2.png', 'block', true);
         JToolBarHelper::divider();
         JToolBarHelper::custom('users.leech', 'publish.png', 'publish_f2.png', 'leech', true);
         JToolBarHelper::custom('users.unleech', 'unpublish.png', 'unpublish_f2.png', 'unleech', true);
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences('com_tracker');
     }
 }
Example #14
0
 /**
  * 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);
 }
Example #15
0
 public function changeTypeYES()
 {
     // Check for request forgeries.
     JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     // Initialise variables.
     $ids = JRequest::getVar('cid', array(), '', 'array');
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('COM_TRACKER_GROUPS_NO_GROUP_SELECTED'));
     } else {
         // Add the ability to leech from the users of the specified group
         if ($this->task == 'can_leech') {
             TrackerHelper::changeUsersPermission('can_leech', $ids, 1);
         }
         // Get the model.
         $model = $this->getModel();
         // Change the state of the records.
         if (!$model->changeValue($ids, $this->task, 1)) {
             JError::raiseWarning(500, $model->getError());
         } else {
             $this->setMessage(JText::_('COM_TRACKER_GROUP_CHANGE_' . strtoupper($this->task) . '_YES'));
         }
     }
     $this->setRedirect('index.php?option=com_tracker&view=groups');
 }
Example #16
0
 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');
 }
Example #17
0
 protected function addToolbar()
 {
     $canDo = TrackerHelper::getActions();
     JToolBarHelper::title(JText::_('COM_TRACKER_COUNTRIES'), 'countries');
     if ($canDo->get('core.create')) {
         JToolBarHelper::addNew('country.add', 'JTOOLBAR_NEW');
     }
     if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
         JToolBarHelper::editList('country.edit', 'JTOOLBAR_EDIT');
     }
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::divider();
         JToolBarHelper::custom('countries.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
         JToolBarHelper::custom('countries.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
     }
     if ($canDo->get('core.delete')) {
         JToolBarHelper::divider();
         JToolBarHelper::deleteList('', 'countries.delete', 'JTOOLBAR_DELETE');
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences('com_tracker');
     }
 }
Example #18
0
 public function bulk_import()
 {
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/tracker.php';
     require_once JPATH_COMPONENT_SITE . '/helpers/Torrent.php';
     $db = JFactory::getDBO();
     $params = JComponentHelper::getParams('com_tracker');
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $filename = $params->get('import_filename');
     $source_folder = $params->get('import_source_folder');
     if (empty($filename) || $filename == '-1') {
         $this->setError(JText::_('COM_TRACKER_UTILITY_IMPORT_INVALID_FILE'));
         return false;
     }
     $filename = JUri::root() . DS . 'tmp' . DS . $filename;
     @($handle = fopen($filename, "r"));
     $header = NULL;
     $data = array();
     if (($handle = fopen($filename, 'r')) !== FALSE) {
         while (($row = fgetcsv($handle, 1000, $params->get('field_separator'))) !== FALSE) {
             if (!$header) {
                 $header = $row;
             } else {
                 $data[] = array_combine($header, $row);
             }
         }
         fclose($handle);
     }
     foreach ($data as &$imported_torrent) {
         // Let's start to play with it
         $temp_torrent['name'] = $imported_torrent['Name'];
         $temp_torrent['categoryID'] = $imported_torrent['CategoryID'];
         $temp_torrent['description'] = $imported_torrent['Description'];
         if (empty($imported_torrent['Uploader'])) {
             $temp_torrent['uploader'] = $user->id;
         } else {
             $temp_torrent['uploader'] = $imported_torrent['Uploader'];
         }
         if ($params->get('enable_licenses') == 1) {
             $temp_torrent['licenseID'] = $imported_torrent['LicenseID'];
         } else {
             $temp_torrent['licenseID'] = 0;
         }
         if ($params->get('forum_post_id') == 1) {
             $temp_torrent['forum_post'] = $imported_torrent['ForumPost'];
         } else {
             $temp_torrent['forum_post'] = 0;
         }
         if ($params->get('torrent_information') == 1) {
             $temp_torrent['info_post'] = $imported_torrent['InfoPost'];
         } else {
             $temp_torrent['info_post'] = 0;
         }
         if ($params->get('allow_upload_anonymous') == 1) {
             $temp_torrent['uploader_anonymous'] = $imported_torrent['UploaderAnonymous'];
         } else {
             $temp_torrent['uploader_anonymous'] = 0;
         }
         if ($params->get('torrent_tags') == 1) {
             $temp_torrent['tags'] = $imported_torrent['Tags'];
         } else {
             $temp_torrent['tags'] = '';
         }
         if ($params->get('freeleech') == 1) {
             $temp_torrent['download_multiplier'] = 0;
         } else {
             $temp_torrent['download_multiplier'] = 1;
         }
         // ------------------------------------------------------------------------------------------------------------------------
         // Let's take care of the .torrent file first
         $torrent_file = JPATH_ROOT . DS . $source_folder . DS . $imported_torrent['Filename'];
         $temp_torrent['filename'] = $imported_torrent['Filename'];
         // If we try to use an empty file
         if (@filesize($torrent_file) == 0) {
             $this->setError(JText::_('COM_TRACKER_UTILITY_IMPORT_TORRENT') . ' - ' . JText::_('COM_TRACKER_UTILITY_IMPORT_EMPTY_FILE') . ' ( ' . $imported_torrent['Filename'] . ' )');
             return false;
         }
         // Check if the torrent file is really a valid torrent file
         if (!Torrent::is_torrent($torrent_file)) {
             $this->setError(JText::_('COM_TRACKER_UTILITY_IMPORT_TORRENT') . ' - ' . JText::_('COM_TRACKER_UTILITY_IMPORT_NOT_BENCODED_FILE') . ' ( ' . $imported_torrent['Filename'] . ' )');
             return false;
         }
         // Let's create our new torrent object
         $torrent = new Torrent($torrent_file);
         // And check for errors. Need to find a way to test them all :)
         if ($errors = $torrent->errors()) {
             var_dump($errors);
         }
         // Private Torrents
         if ($params->get('make_private') == 1 && !$torrent->is_private()) {
             $torrent->is_private(true);
         }
         // If the user didnt wrote a name for the torrent, we get it from the filename
         if (empty($temp_torrent['name'])) {
             $filename = pathinfo($torrent_file);
             $torrent->name($filename['filename']);
         }
         $query = $db->getQuery(true);
         $query->select('count(fid)');
         $query->from('#__tracker_torrents');
         $query->where('info_hash = UNHEX("' . $torrent->hash_info() . '")');
         $db->setQuery($query);
         if ($db->loadResult() > 0) {
             $this->setError(JText::_('COM_TRACKER_UTILITY_IMPORT_ALREADY_EXISTS') . ' - ' . $imported_torrent['Filename']);
             return false;
         }
         // ------------------------------------------------------------------------------------------------------------------------
         // The .torrent file is valid, let's continue to our image file (if we choose to use it)
         $image_type = $imported_torrent['ImageType'];
         if ($params->get('use_image_file')) {
             // When image_type is 'don't use image'
             if ($image_type == 0) {
                 $image_file_query_value = "";
             }
             // When image file is 'uploaded file'
             if ($image_type == 1) {
                 $image_file = JPATH_ROOT . DS . $source_folder . DS . $imported_torrent['Image'];
                 if (!is_file($image_file)) {
                     $this->setError(JText::_('COM_TRACKER_UTILITY_IMPORT_OPS_SOMETHING_HAPPENED_IMAGE') . ' - ' . $imported_torrent['Image']);
                     return false;
                 }
                 if (!filesize($image_file)) {
                     $this->setError(JText::_('COM_TRACKER_UTILITY_IMPORT_EMPTY_FILE_IMAGE') . ' - ' . $imported_torrent['Image']);
                     return false;
                 }
                 if (!TrackerHelper::is_image($image_file)) {
                     $this->setError(JText::_('COM_TRACKER_UTILITY_IMPORT_NOT_AN_IMAGE_FILE') . ' - ' . $imported_torrent['Image']);
                     return false;
                 }
                 $image_file_extension = end(explode(".", $image_file));
                 $image_file_query_value = $torrent->hash_info() . '.' . $image_file_extension;
                 $image_file_file = $image_file;
             }
             // When image file is an external link
             if ($image_type == 2) {
                 // If the remote file is unavailable
                 if (@(!file_get_contents($imported_torrent['Image'], 0, NULL, 0, 1))) {
                     echo JText::_('COM_TRACKER_UTILITY_IMPORT_REMOTE_IMAGE_INVALID_FILE');
                     continue 3;
                 }
                 // check if the remote file is not an image
                 if (!is_array(@getimagesize($imported_torrent['Image']))) {
                     echo JText::_('COM_TRACKER_UTILITY_IMPORT_REMOTE_IMAGE_NOT_IMAGE');
                     continue 3;
                 }
                 $image_file_query_value = $imported_torrent['Image'];
             }
         } else {
             $image_file_query_value = "";
         }
         // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         // All is good, let's insert the record in the database
         // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         //Insert the torrent into the table
         $query->clear();
         $query = $db->getQuery(true);
         $query->insert('#__tracker_torrents');
         $query->set('info_hash = UNHEX("' . $torrent->hash_info() . '")');
         $query->set('ctime = unix_timestamp()');
         $query->set('name = ' . $db->quote($temp_torrent['name']));
         $query->set('alias = ' . $db->quote($temp_torrent['name']));
         $query->set('filename = ' . $db->quote($temp_torrent['filename']));
         $query->set('description = ' . $db->quote($temp_torrent['description']));
         $query->set('categoryID = ' . $db->quote($temp_torrent['categoryID']));
         $query->set('size = ' . $db->quote($torrent->size()));
         $query->set('created_time = ' . $db->quote(date("Y-m-d H:i:s")));
         $query->set('uploader = ' . $db->quote($user->id));
         $query->set('number_files = ' . $db->quote(count($torrent->content())));
         $query->set('uploader_anonymous = ' . $db->quote($temp_torrent['uploader_anonymous']));
         $query->set('forum_post = ' . $db->quote($temp_torrent['forum_post']));
         $query->set('info_post = ' . $db->quote($temp_torrent['info_post']));
         $query->set('licenseID = ' . $db->quote($temp_torrent['licenseID']));
         $query->set('upload_multiplier = 1');
         $query->set('download_multiplier = ' . $db->quote($temp_torrent['download_multiplier']));
         $query->set('image_file = ' . $db->quote($image_file_query_value));
         $query->set('tags = ' . $db->quote($temp_torrent['tags']));
         $query->set('state = 1');
         $db->setQuery($query);
         if (!$db->query()) {
             JError::raiseError(500, $db->getErrorMsg());
         }
         // Get the torrent ID that we've just inserted in the database
         $torrent_id = $db->insertid();
         // Insert the list of files of the torrent in the database
         foreach ($torrent->content() as $filename => $filesize) {
             $query->clear();
             $query = $db->getQuery(true);
             $query->insert('#__tracker_files_in_torrents');
             $query->set('torrentID = ' . $db->quote($torrent_id));
             $query->set('filename = ' . $db->quote($filename));
             $query->set('size = ' . $db->quote($filesize));
             $db->setQuery($query);
             if (!$db->query()) {
                 JError::raiseError(500, $db->getErrorMsg());
             }
         }
         // If we're in freeleech we need to add the record of the new torrent to the freeleech table
         if ($params->get('freeleech') == 1) {
             $query->clear();
             $query = $db->getQuery(true);
             $query->insert('#__tracker_torrents_freeleech');
             $query->set('fid = ' . $db->quote($torrent_id));
             $query->set('download_multiplier = 1');
             $db->setQuery($query);
             if (!$db->query()) {
                 JError::raiseError(500, $db->getErrorMsg());
             }
         }
         $upload_error = 0;
         // Lets try to save the torrent before we continue
         if (!copy($torrent_file, JPATH_SITE . DS . $params->get('torrent_dir') . $torrent_id . "_" . $temp_torrent['filename'])) {
             $upload_error = 1;
             echo JText::_('COM_TRACKER_UTILITY_IMPORT_COULDNT_COPY_TORRENT');
             continue;
         } else {
             unlink($torrent_file);
         }
         // And we should also move the image file if we're using it with the option of uploading an image file
         if ($params->get('use_image_file') && $imported_torrent['ImageType'] == 1) {
             if (!copy($image_file, JPATH_SITE . DS . 'images/tracker/torrent_image/' . $image_file_query_value)) {
                 $upload_error = 1;
                 echo JText::_('COM_TRACKER_UTILITY_IMPORT_COULDNT_COPY_TORRENT_IMAGE');
                 continue 2;
             } else {
                 unlink($image_file);
             }
         }
         if ($upload_error == 1) {
             $query->clear();
             $query = $db->getQuery(true);
             $query->delete('#__tracker_files_in_torrents');
             $query->where('torrent=' . $db->quote($torrent_id));
             $db->setQuery($query);
             $db->query();
             if ($error = $db->getErrorMsg()) {
                 $this->setError($error);
                 return false;
             }
             $query->clear();
             $query = $db->getQuery(true);
             $query->delete('#__tracker_torrents');
             $query->where('fid=' . $db->quote($torrent_id));
             $db->setQuery($query);
             $db->query();
             @unlink(JPATH_SITE . DS . $params->get('torrent_dir') . $torrent_id . "_" . $temp_torrent['filename']);
             if ($image_type == 1) {
                 @unlink(JPATH_SITE . DS . 'images/tracker/torrent_image/' . $image_file_query_value);
             }
             continue;
         }
         JFactory::getApplication()->enqueueMessage(JText::_('COM_TRACKER_UTILITY_IMPORT_TORRENT') . ' \'' . $temp_torrent['filename'] . '\' ' . JText::_('COM_TRACKER_UTILITY_IMPORT_TORRENT_SUCCESS') . '<br>');
     }
     return true;
 }
Example #19
0
        echo "user_hitrun{$k}";
        ?>
">
				<td width="75%"><a href='<?php 
        echo JRoute::_("index.php?option=com_tracker&view=torrent&amp;id=" . $this->item_hitrun->fid);
        ?>
'><?php 
        echo htmlspecialchars(str_replace("_", " ", $this->item_hitrun->name));
        ?>
</a></td>
				<td width="5%" nowrap align="right">&nbsp;<?php 
        echo TrackerHelper::make_size($this->item_hitrun->uploaded);
        ?>
&nbsp;</td>
				<td width="5%" nowrap align="right">&nbsp;<?php 
        echo TrackerHelper::make_size($this->item_hitrun->downloaded);
        ?>
&nbsp;</td>
				<td width="5%" nowrap align="right">&nbsp;<?php 
        echo $this->item_hitrun->completed;
        ?>
&nbsp;</td>
				<td width="5%" nowrap align="right">&nbsp;<?php 
        echo $this->item_hitrun->seeders;
        ?>
&nbsp;</td>
				<td width="5%" nowrap align="right">&nbsp;<?php 
        echo $this->item_hitrun->leechers;
        ?>
&nbsp;</td>
			</tr>
Example #20
0
 public function edited()
 {
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/tracker.php';
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $params = JComponentHelper::getParams('com_tracker');
     $app = JFactory::getApplication();
     $upload_error = 0;
     $torrent['fid'] = (int) $_POST['fid'];
     $torrent['name'] = $_POST['name'];
     $torrent['filename'] = $_POST['filename'];
     $torrent['old_filename'] = $_POST['old_filename'];
     $torrent['description'] = $_POST['description'];
     $torrent['categoryID'] = (int) $_POST['categoryID'];
     $torrent['licenseID'] = (int) $_POST['licenseID'];
     $uploader['anonymous'] = (int) $_POST['uploader_anonymous'];
     $torrent['upload_multiplier'] = (double) $_POST['upload_multiplier'];
     $torrent['forum_post'] = (int) $_POST['forum_post'];
     $torrent['info_post'] = (int) $_POST['info_post'];
     $torrent['tags'] = $_POST['tags'];
     // If we're in freeleech
     if ($params->get('freeleech') == 1) {
         $torrent['download_multiplier'] = 0;
     } else {
         $torrent['download_multiplier'] = (double) $_POST['download_multiplier'];
     }
     // ------------------------------------------------------------------------------------------------------------------------
     // Now let's see if we've uploaded a new torrent file or choose to keep the old one
     // ------------------------------------------------------------------------------------------------------------------------
     if ($_POST['default_torrent_file'] == 0) {
         // We're keeping the original torrent
         if (empty($torrent['name'])) {
             $torrent['name'] = $torrent['old_filename'];
         }
         if (empty($torrent['filename'])) {
             $torrent['filename'] = $torrent['name'] . '.torrent';
         } else {
             $torrent['filename'] = $torrent['filename'] . '.torrent';
         }
         // Rename the filename if we've changed it
         if ($torrent['filename'] != $torrent['old_filename'] . '.torrent') {
             $pre_file = JPATH_SITE . DS . $params->get('torrent_dir') . $torrent['fid'] . '_';
             rename($pre_file . $torrent['old_filename'] . '.torrent', $pre_file . $torrent['filename']);
         }
     } else {
         // We've uploaded a new torrent file to replace the old one
         // Sanitize the filename
         $torrent['filename'] = TrackerHelper::sanitize_filename($_FILES['filename']['name']);
         // If something wrong happened during the file upload, we go back to the editing
         if (!is_uploaded_file($_FILES['filename']['tmp_name'])) {
             $app->redirect(JRoute::_('index.php?option=com_tracker&view=edit&id=' . $torrent['fid']), JText::_('COM_TRACKER_UPLOAD_OPS_SOMETHING_HAPPENED'), 'error');
         }
         // If we try to upload an empty file (0 bytes size)
         if ($_FILES['filename']['size'] == 0) {
             $app->redirect(JRoute::_('index.php?option=com_tracker&view=edit&id=' . $torrent['fid']), JText::_('COM_TRACKER_UPLOAD_EMPTY_FILE'), 'error');
         }
         // Check if the torrent file is really a valid torrent file
         if (!Torrent::is_torrent($_FILES['filename']['tmp_name'])) {
             $app->redirect(JRoute::_('index.php?option=com_tracker&view=edit&id=' . $torrent['fid']), JText::_('COM_TRACKER_UPLOAD_NOT_BENCODED_FILE'), 'error');
         }
         // Let's create our new torrent object
         $new_torrent = new Torrent($_FILES['filename']['tmp_name']);
         // And check for errors. Need to find a way to test them all :)
         if ($errors = $new_torrent->errors()) {
             var_dump($errors);
         }
         // Private Torrents
         if ($params->get('make_private') == 1 && !$new_torrent->is_private()) {
             $new_torrent->is_private(true);
         }
         // If the user didnt wrote a name for the torrent, we get it from the filename
         if (empty($_POST['filename'])) {
             $filename = pathinfo($_FILES['filename']['name']);
             $torrent['filename'] = $filename['filename'];
         }
         if (empty($torrent['name'])) {
             $torrent['name'] = $new_torrent->name();
         }
         // Since we're updating the torrent, we must check if we're not updating it with another one that already exists
         $query = $db->getQuery(true);
         $query->select('count(fid)');
         $query->from('#__tracker_torrents');
         $query->where('info_hash = UNHEX("' . $new_torrent->hash_info() . '")');
         $query->where('fid <> ' . (int) $torrent['fid']);
         $db->setQuery($query);
         if ($db->loadResult() > 0) {
             $app->redirect(JRoute::_('index.php?option=com_tracker&view=edit&id=' . $torrent['fid']), JText::_('COM_TRACKER_EDIT_TORRENT_ALREADY_EXISTS'), 'error');
         }
     }
     // ------------------------------------------------------------------------------------------------------------------------
     if ($params->get('use_image_file') == 1) {
         // When image_type is don't use image
         if ($_POST['default_image_type'] == 0) {
             $torrent['image_file'] = $_POST['image_file'];
         }
         // When image file is an uploaded file
         if ($_POST['default_image_type'] == 1) {
             if (!is_uploaded_file($_FILES['image_file']['tmp_name'])) {
                 $app->redirect(JRoute::_('index.php?option=com_tracker&view=edit&id=' . $torrent['fid']), JText::_('COM_TRACKER_UPLOAD_OPS_SOMETHING_HAPPENED_IMAGE'), 'error');
             }
             if (!filesize($_FILES['image_file']['tmp_name']) || $_FILES['image_file']['size'] == 0) {
                 $app->redirect(JRoute::_('index.php?option=com_tracker&view=edit&id=' . $torrent['fid']), JText::_('COM_TRACKER_UPLOAD_EMPTY_FILE_IMAGE'), 'error');
             }
             if (!TrackerHelper::is_image($_FILES['image_file']['tmp_name'])) {
                 $app->redirect(JRoute::_('index.php?option=com_tracker&view=edit&id=' . $torrent['fid']), JText::_('COM_TRACKER_UPLOAD_NOT_AN_IMAGE_FILE'), 'error');
             }
             if (file_exists('file://' . JPATH_SITE . DS . 'images/tracker/torrent_image/' . $_POST['image_file']) && !empty($_POST['image_file'])) {
                 // Delete the previous image file from disk
                 @unlink(JPATH_SITE . DS . 'images/tracker/torrent_image/' . $_POST['image_file']);
             }
             $image_file_extension = end(explode(".", $_FILES['image_file']['name']));
             $torrent['image_file'] = $_POST['info_hash'] . '.' . $image_file_extension;
             $image_file_file = $_FILES['jform']['tmp_name']['image_file'];
             // And we should also move the image file if we're using it with the option of uploading an image file
             if (!move_uploaded_file($_FILES['image_file']['tmp_name'], JPATH_SITE . DS . 'images/tracker/torrent_image/' . $torrent['image_file'])) {
                 $app->redirect(JRoute::_('index.php?option=com_tracker&view=edit&id=' . $torrent['fid']), JText::_('COM_TRACKER_UPLOAD_PROBLEM_MOVING_FILE'), 'error');
             }
         }
         // When image file is an external link
         if ($_POST['default_image_type'] == 2) {
             // If the remote file is unavailable
             if (@(!file_get_contents($_POST['image_file'], 0, NULL, 0, 1))) {
                 $app->redirect(JRoute::_('index.php?option=com_tracker&amp;view=edit&id=' . $torrent['fid']), JText::_('COM_TRACKER_UPLOAD_REMOTE_IMAGE_INVALID_FILE'), 'error');
             }
             // check if the remote file is not an image
             if (!is_array(@getimagesize($_POST['image_file']))) {
                 $app->redirect(JRoute::_('index.php?option=com_tracker&amp;view=edit&id=' . $torrent['fid']), JText::_('COM_TRACKER_UPLOAD_REMOTE_IMAGE_NOT_IMAGE'), 'error');
             }
             if (file_exists('file://' . JPATH_SITE . DS . 'images/tracker/torrent_image/' . $_POST['image_file']) && !empty($_POST['image_file'])) {
                 // Delete the previous image file from disk
                 @unlink(JPATH_SITE . DS . 'images/tracker/torrent_image/' . $_POST['image_file']);
             }
             $torrent['image_file'] = $_POST['image_file'];
         }
         if ($_POST['default_image_type'] == 3) {
             if (file_exists('file://' . JPATH_SITE . DS . 'images/tracker/torrent_image/' . $_POST['image_file']) && !empty($_POST['image_file'])) {
                 // Delete the previous image file from disk
                 @unlink(JPATH_SITE . DS . 'images/tracker/torrent_image/' . $_POST['image_file']);
             }
             $torrent['image_file'] = "";
         }
     } else {
         $torrent['image_file'] = $_POST['image_file'];
     }
     // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     // All is good, let's update the record in the database
     // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     $query = $db->getQuery(true);
     $query->update('#__tracker_torrents');
     $query->set('name = ' . $db->quote($torrent['name']));
     $query->set('alias = ' . $db->quote($torrent['name']));
     $query->set('filename = ' . $db->quote($torrent['filename']));
     $query->set('description = ' . $db->quote($torrent['description']));
     $query->set('categoryID = ' . $db->quote($torrent['categoryID']));
     $query->set('licenseID = ' . $db->quote($torrent['licenseID']));
     $query->set('uploader_anonymous = ' . $db->quote($uploader['anonymous']));
     $query->set('download_multiplier = ' . $db->quote($torrent['download_multiplier']));
     $query->set('upload_multiplier = ' . $db->quote($torrent['upload_multiplier']));
     $query->set('forum_post = ' . $db->quote($torrent['forum_post']));
     $query->set('info_post = ' . $db->quote($torrent['info_post']));
     $query->set('image_file = ' . $db->quote($torrent['image_file']));
     $query->set('tags = ' . $db->quote($torrent['tags']));
     $query->set('flags = 2');
     // Since we're updating the torrent file we must change some values
     if ($_POST['default_torrent_file'] == 1) {
         $query->set('info_hash = UNHEX("' . $new_torrent->hash_info() . '")');
         $query->set('size = ' . $db->quote($new_torrent->size()));
         $query->set('number_files = ' . $db->quote(count($new_torrent->content())));
     }
     $query->where('fid = ' . (int) $torrent['fid']);
     $db->setQuery($query);
     if (!$db->query()) {
         JError::raiseError(500, $db->getErrorMsg());
         $upload_error = $upload_error + 1;
     }
     // We're uploading a new torrent file, the torrent contents probably changed
     if ($_POST['default_torrent_file'] == 1) {
         // We need to delete the old values
         $query->clear();
         $query = $db->getQuery(true);
         $query->delete('#__tracker_files_in_torrents');
         $query->where('torrentID =' . $db->quote($torrent['fid']));
         $db->setQuery($query);
         $db->query();
         if ($error = $db->getErrorMsg()) {
             $this->setError($error);
             return false;
         }
         // And add the new ones
         foreach ($new_torrent->content() as $filename => $filesize) {
             $query->clear();
             $query = $db->getQuery(true);
             $query->insert('#__tracker_files_in_torrents');
             $query->set('torrentID = ' . $db->quote($torrent['fid']));
             $query->set('filename = ' . $db->quote($filename));
             $query->set('size = ' . $db->quote($filesize));
             $db->setQuery($query);
             if (!$db->query()) {
                 JError::raiseError(500, $db->getErrorMsg());
             }
         }
         // And we need to overwrite the previous torrent from the server with the new one
         if (!move_uploaded_file($_FILES['filename']['tmp_name'], JPATH_SITE . DS . $params->get('torrent_dir') . $torrent['fid'] . "_" . $_FILES['filename']['name'])) {
             $app->redirect(JRoute::_('index.php?option=com_tracker&view=edit&id=' . $torrent['fid']), JText::_('COM_TRACKER_UPLOAD_PROBLEM_MOVING_FILE'), 'error');
         }
         // But we also need to delete the old torrent file
         @unlink(JPATH_SITE . DS . $params->get('torrent_dir') . $torrent['fid'] . "_" . $torrent['old_filename'] . '.torrent');
     }
     // If we're in freeleech we need to edit the record of the torrent in the freeleech table
     if ($params->get('freeleech') == 1) {
         $query->clear();
         $query = $db->getQuery(true);
         $query->update('#__tracker_torrents_freeleech');
         $query->set('download_multiplier = ' . $_POST['download_multiplier']);
         $query->where('fid = ' . (int) $torrent['fid']);
         $db->setQuery($query);
         if (!$db->query()) {
             JError::raiseError(500, $db->getErrorMsg());
         }
     }
     if ($upload_error == 0) {
         $app->redirect(JRoute::_('index.php?option=com_tracker&view=torrent&id=' . $torrent['fid']), JText::_('COM_TRACKER_EDIT_OK'), 'message');
     } else {
         $app->redirect(JRoute::_('index.php?option=com_tracker&view=edit&id=' . $torrent['fid']), JText::_('COM_TRACKER_EDIT_NOK'), 'error');
     }
 }
Example #21
0
    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>&nbsp;&nbsp;&nbsp;</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;
    ?>
Example #22
0
 public static function get_ratio($upload, $download)
 {
     if ($upload == 0 && $download == 0) {
         return JText::_('COM_TRACKER_NO_DOWNLOAD_UPLOAD');
     } elseif ($upload > 0 && $download < 1) {
         return JText::_('COM_TRACKER_JUST_SEEDED');
     } elseif ($upload < 1 && $download > 0) {
         return JText::_('COM_TRACKER_JUST_LEECHEED');
     } else {
         return '<span style="color: ' . TrackerHelper::get_ratio_color($upload / $download) . ';">' . number_format($upload / $download, 2) . '</span>';
     }
 }
Example #23
0
					<?php 
    if ($params->get('enable_donations') && $item->credited > 0) {
        echo TrackerHelper::make_size($item->uploaded + $item->credited * 1073741824);
        echo ' - (' . $item->credited . ')';
    } else {
        echo TrackerHelper::make_size($item->uploaded);
    }
    ?>
				</td>

				<td align="center" nowrap>
					<?php 
    if ($params->get('enable_donations') && $item->credited > 0) {
        echo TrackerHelper::make_ratio($item->downloaded, $item->uploaded + $item->credited * 1073741824);
    } else {
        echo TrackerHelper::make_ratio($item->downloaded, $item->uploaded);
    }
    ?>
				</td>

				<?php 
    if ($params->get('enable_donations')) {
        ?>
					<td align="center" nowrap>
						<?php 
        if ($item->donated > 0) {
            echo '$' . $item->donated;
        } else {
            echo JText::_('COM_TRACKER_NOTHING');
        }
        ?>
Example #24
0
        ?>
&nbsp;</td><?php 
    }
    ?>
				<?php 
    if ($this->params->get('tl_upload_multiplier')) {
        ?>
<td width="1%" align="center" nowrap>&nbsp;<?php 
        echo $item->upload_multiplier;
        ?>
&nbsp;</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>
Example #25
0
 echo '<div id="value-center"><b>&nbsp;' . JText::_('COM_TRACKER_STATS_CREATED_TIME') . '&nbsp;</b></div>';
 echo '<div id="value-center"><b>&nbsp;' . JText::_('COM_TRACKER_TORRENT_SEEDERS_SMALL') . '&nbsp;</b></div>';
 echo '<div id="value-center"><b>&nbsp;' . JText::_('COM_TRACKER_TORRENT_LEECHERS_SMALL') . '&nbsp;</b></div>';
 echo '<div id="value-center"><b>&nbsp;' . JText::_('COM_TRACKER_TORRENT_COMPLETED_SMALL') . '&nbsp;</b></div>';
 echo '<div id="value-center"><b>&nbsp;' . JText::_('JCATEGORY') . '&nbsp;</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;">&nbsp;';
     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 '&nbsp;</div>';
     echo '<div id="value-right">&nbsp;' . TrackerHelper::make_size($worst_completed_torrents->size) . '&nbsp;</div>';
     echo '<div id="value-center">&nbsp;' . date('Y.m.d', strtotime($worst_completed_torrents->created_time)) . '&nbsp;</div>';
     echo '<div id="value-center">&nbsp;' . $worst_completed_torrents->seeders . '&nbsp;</div>';
     echo '<div id="value-center">&nbsp;' . $worst_completed_torrents->leechers . '&nbsp;</div>';
     echo '<div id="value-center">&nbsp;' . $worst_completed_torrents->completed . '&nbsp;</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">&nbsp;';
     if (is_file($_SERVER['DOCUMENT_ROOT'] . DS . JUri::root(true) . $category_params->get('image'))) {
         echo '<img style="vertical-align:middle;"  id="tacatimage' . $worst_completed_torrents->fid . '" alt="' . $worst_completed_torrents->cat_title . '" src="' . JUri::root(true) . DS . $category_params->get('image') . '" width="36" />';
     } else {
         echo $worst_completed_torrents->cat_title;
     }
     echo '&nbsp;</div>';
     echo '</div>';
Example #26
0
 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) . '&nbsp;&nbsp;-&nbsp;&nbsp;' . 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;
 }
Example #27
0
'><?php 
                echo $item->name;
                ?>
</a>&nbsp;</div>
			<?php 
            } else {
                ?>
				<div id="value" style="overflow: hidden; white-space: pre-wrap;">&nbsp;<?php 
                echo $item->name;
                ?>
&nbsp;</div>
			<?php 
            }
            ?>
			<div id="value-right" style="white-space: nowrap;">&nbsp;<?php 
            echo TrackerHelper::make_size($item->size);
            ?>
&nbsp;</div>
			<div id="value-center">&nbsp;<?php 
            echo date('Y.m.d', strtotime($item->created_time));
            ?>
&nbsp;</div>
			<div id="value-center">&nbsp;<?php 
            echo $item->seeders;
            ?>
&nbsp;</div>
			<div id="value-center">&nbsp;<?php 
            echo $item->leechers;
            ?>
&nbsp;</div>
			<div id="value-center">&nbsp;<?php 
Example #28
0
" 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);
}
Example #29
0
					<label><?php 
    echo JText::_('COM_TRACKER_USER_DONATED');
    ?>
</label>
					<input disabled value="<?php 
    echo $this->item->donated ? '$' . $this->item->donated : JText::_('COM_TRACKER_USER_NOTHING_DONATED');
    ?>
" />
				</li>
				<li>
					<label><?php 
    echo JText::_('COM_TRACKER_USER_CREDITED');
    ?>
</label>
					<input disabled value="<?php 
    echo $this->item->credited ? TrackerHelper::make_size($this->item->credited * 1073741824) : JText::_('COM_TRACKER_USER_NOTHING_CREDITED');
    ?>
" />
				</li>
				<?php 
}
?>
				<li>
					<?php 
echo $this->form->getLabel('torrent_pass_version');
?>
					<input type="text" name="jform[torrent_pass_version]" id="jform_torrent_pass_version" value="<?php 
echo $this->item->torrent_pass_version;
?>
" class="inputbox" size="5"/>
				</li>
Example #30
0
 public function uploaded()
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $params = JComponentHelper::getParams('com_tracker');
     $app = JFactory::getApplication();
     // Let's start to play with it
     $temp_torrent['name'] = $_POST['jform']['name'];
     $temp_torrent['categoryID'] = $_POST['jform']['categoryID'];
     $temp_torrent['description'] = $_POST['jform']['description'];
     if ($params->get('torrent_tags') == 1) {
         $temp_torrent['tags'] = $_POST['jform']['tags'];
     } else {
         $temp_torrent['tags'] = '';
     }
     if ($params->get('enable_licenses') == 1) {
         $licenseID = $_POST['jform']['licenseID'];
     } else {
         $licenseID = 0;
     }
     if ($params->get('forum_post_id') == 1) {
         $forum_post = $_POST['jform']['forum_post'];
     } else {
         $forum_post = 0;
     }
     if ($params->get('torrent_information') == 1) {
         $info_post = $_POST['jform']['info_post'];
     } else {
         $info_post = 0;
     }
     if ($params->get('allow_upload_anonymous') == 1) {
         $uploader_anonymous = $_POST['jform']['uploader_anonymous'];
     } else {
         $uploader_anonymous = 0;
     }
     if ($params->get('freeleech') == 1) {
         $download_multiplier = 0;
     } else {
         $download_multiplier = 1;
     }
     // ------------------------------------------------------------------------------------------------------------------------
     // Let's take care of the .torrent file first
     $temp_torrent['filename'] = $_FILES['jform']['name']['filename'];
     $temp_torrent['temp_file'] = $_FILES['jform']['tmp_name']['filename'];
     // Sanitize the filename
     $temp_torrent['filename'] = TrackerHelper::sanitize_filename($temp_torrent['filename']);
     // If something wrong happened during the file upload, we bail out
     if (!is_uploaded_file($_FILES['jform']['tmp_name']['filename'])) {
         $app->redirect(JRoute::_('index.php?option=com_tracker&view=upload'), JText::_('COM_TRACKER_UPLOAD_OPS_SOMETHING_HAPPENED'), 'error');
     }
     // If we try to upload an empty file (0 bytes size)
     if ($_FILES['jform']['size']['filename'] == 0) {
         $app->redirect(JRoute::_('index.php?option=com_tracker&view=upload'), JText::_('COM_TRACKER_UPLOAD_EMPTY_FILE'), 'error');
     }
     // Check if the torrent file is really a valid torrent file
     if (!Torrent::is_torrent($_FILES['jform']['tmp_name']['filename'])) {
         $app->redirect(JRoute::_('index.php?option=com_tracker&view=upload'), JText::_('COM_TRACKER_UPLOAD_NOT_BENCODED_FILE'), 'error');
     }
     // Let's create our new torrent object
     $torrent = new Torrent($_FILES['jform']['tmp_name']['filename']);
     // And check for errors. Need to find a way to test them all :)
     if ($errors = $torrent->errors()) {
         var_dump($errors);
     }
     // Private Torrents
     if ($params->get('make_private') == 1 && !$torrent->is_private()) {
         $torrent->is_private(true);
     }
     // If the user didnt wrote a name for the torrent, we get it from the filename
     if (empty($_POST['jform']['name'])) {
         $filename = pathinfo($_FILES['jform']['name']['filename']);
         $torrent->name($filename['filename']);
     } else {
         $torrent->name($_POST['jform']['name']);
     }
     $query = $db->getQuery(true);
     $query->select('count(fid)');
     $query->from('#__tracker_torrents');
     $query->where('info_hash = UNHEX("' . $torrent->hash_info() . '")');
     $db->setQuery($query);
     if ($db->loadResult() > 0) {
         $app->redirect(JRoute::_('index.php?option=com_tracker&view=upload'), JText::_('COM_TRACKER_UPLOAD_ALREADY_EXISTS'), 'error');
     }
     // ------------------------------------------------------------------------------------------------------------------------
     // The .torrent file is valid, let's continue to our image file (if we choose to use it)
     if ($params->get('use_image_file')) {
         // When image_type is don't use image
         if ($_POST['jform']['image_type'] == 0) {
             $image_file_query_value = "";
         }
         // When image file is an uploaded file
         if ($_POST['jform']['image_type'] == 1) {
             if (!is_uploaded_file($_FILES['jform']['tmp_name']['image_file'])) {
                 $app->redirect(JRoute::_('index.php?option=com_tracker&view=upload'), JText::_('COM_TRACKER_UPLOAD_OPS_SOMETHING_HAPPENED_IMAGE'), 'error');
             }
             if (!filesize($_FILES['jform']['tmp_name']['image_file']) || $_FILES['jform']['size']['image_file'] == 0) {
                 $app->redirect(JRoute::_('index.php?option=com_tracker&view=upload'), JText::_('COM_TRACKER_UPLOAD_EMPTY_FILE_IMAGE'), 'error');
             }
             if (!TrackerHelper::is_image($_FILES['jform']['tmp_name']['image_file'])) {
                 $app->redirect(JRoute::_('index.php?option=com_tracker&view=upload'), JText::_('COM_TRACKER_UPLOAD_NOT_AN_IMAGE_FILE'), 'error');
             }
             $image_file_extension = end(explode(".", $_FILES['jform']['name']['image_file']));
             $image_file_query_value = $torrent->hash_info() . '.' . $image_file_extension;
             $image_file_file = $_FILES['jform']['tmp_name']['image_file'];
         }
         // When image file is an external link
         if ($_POST['jform']['image_type'] == 2) {
             // If the remote file is unavailable
             if (@(!file_get_contents($_POST['jform']['image_link'], 0, NULL, 0, 1))) {
                 $app->redirect(JRoute::_('index.php?option=com_tracker&view=upload'), JText::_('COM_TRACKER_UPLOAD_REMOTE_IMAGE_INVALID_FILE'), 'error');
             }
             // check if the remote file is not an image
             if (!is_array(@getimagesize($_POST['jform']['image_link']))) {
                 $app->redirect(JRoute::_('index.php?option=com_tracker&view=upload'), JText::_('COM_TRACKER_UPLOAD_REMOTE_IMAGE_NOT_IMAGE'), 'error');
             }
             $image_file_query_value = $_POST['jform']['image_link'];
         }
     } else {
         $image_file_query_value = "";
     }
     // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     // All is good, let's insert the record in the database
     // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     //TODO: INSERT THE ORDERING EQUAL TO THE TORRENT ID
     //Insert the torrent into the table
     $query->clear();
     $query = $db->getQuery(true);
     $query->insert('#__tracker_torrents');
     $query->set('info_hash = UNHEX("' . $torrent->hash_info() . '")');
     $query->set('ctime = unix_timestamp()');
     $query->set('name = ' . $db->quote($torrent->name()));
     $query->set('alias = ' . $db->quote($torrent->name()));
     $query->set('filename = ' . $db->quote($_FILES['jform']['name']['filename']));
     $query->set('description = ' . $db->quote($_POST['jform']['description']));
     $query->set('categoryID = ' . $db->quote($_POST['jform']['categoryID']));
     $query->set('size = ' . $db->quote($torrent->size()));
     $query->set('created_time = ' . $db->quote(date("Y-m-d H:i:s")));
     $query->set('uploader = ' . $db->quote($user->id));
     $query->set('number_files = ' . $db->quote(count($torrent->content())));
     $query->set('uploader_anonymous = ' . $db->quote($uploader_anonymous));
     $query->set('forum_post = ' . $db->quote($forum_post));
     $query->set('info_post = ' . $db->quote($info_post));
     $query->set('licenseID = ' . $db->quote($licenseID));
     $query->set('upload_multiplier = 1');
     $query->set('download_multiplier = ' . $db->quote($download_multiplier));
     $query->set('image_file = ' . $db->quote($image_file_query_value));
     $query->set('tags = ' . $db->quote($temp_torrent['tags']));
     $query->set('state = 1');
     $db->setQuery($query);
     if (!$db->query()) {
         JError::raiseError(500, $db->getErrorMsg());
     }
     // Get the torrent ID that we've just inserted in the database
     $torrent_id = $db->insertid();
     /* Need to check this.
     	Wrong info for single file torrent
     	Wrong filenames for multi file torrent
     	*/
     // Insert the list of files of the torrent in the database
     foreach ($torrent->content() as $filename => $filesize) {
         $query->clear();
         $query = $db->getQuery(true);
         $query->insert('#__tracker_files_in_torrents');
         $query->set('torrentID = ' . $db->quote($torrent_id));
         $query->set('filename = ' . $db->quote($filename));
         $query->set('size = ' . $db->quote($filesize));
         $db->setQuery($query);
         if (!$db->query()) {
             JError::raiseError(500, $db->getErrorMsg());
         }
     }
     // If we're in freeleech we need to add the record of the new torrent to the freeleech table
     if ($params->get('freeleech') == 1) {
         $query->clear();
         $query = $db->getQuery(true);
         $query->insert('#__tracker_torrents_freeleech');
         $query->set('fid = ' . $db->quote($torrent_id));
         $query->set('download_multiplier = 1');
         $db->setQuery($query);
         if (!$db->query()) {
             JError::raiseError(500, $db->getErrorMsg());
         }
     }
     $upload_error = 0;
     // Lets try to save the torrent before we continue
     if (!move_uploaded_file($_FILES['jform']['tmp_name']['filename'], JPATH_SITE . DS . $params->get('torrent_dir') . $torrent_id . "_" . $_FILES['jform']['name']['filename'])) {
         $upload_error = 1;
     }
     // And we should also move the image file if we're using it with the option of uploading an image file
     if ($params->get('use_image_file') && $_POST['jform']['image_type'] == 1) {
         if (!move_uploaded_file($_FILES['jform']['tmp_name']['image_file'], JPATH_SITE . DS . 'images/tracker/torrent_image/' . $image_file_query_value)) {
             $upload_error = 1;
         }
     }
     if ($upload_error == 0) {
         JFactory::getApplication()->setUserState('com_tracker.uploaded.torrent.data', 0);
         $app->redirect(JRoute::_('index.php?option=com_tracker&view=torrent&id=' . $torrent_id), JText::_('COM_TRACKER_UPLOAD_OK'), 'message');
     } else {
         $query->clear();
         $query = $db->getQuery(true);
         $query->delete('#__tracker_files_in_torrents');
         $query->where('torrent=' . $db->quote($torrent_id));
         $db->setQuery($query);
         $db->query();
         if ($error = $db->getErrorMsg()) {
             $this->setError($error);
             return false;
         }
         $query->clear();
         $query = $db->getQuery(true);
         $query->delete('#__tracker_torrents');
         $query->where('fid=' . $db->quote($torrent_id));
         $db->setQuery($query);
         $db->query();
         unlink(JPATH_SITE . DS . $params->get('torrent_dir') . $torrent_id . "_*");
         $app->redirect(JRoute::_('index.php?option=com_tracker&view=upload'), JText::_('COM_TRACKER_UPLOAD_PROBLEM_MOVING_FILE'), 'error');
     }
 }