set_filenames(array( 'body' => 'trader_body.tpl') ); } else { $template->set_filenames(array( 'body' => 'trader_body_ajax.tpl') ); } // we display the search box $search_category = ''; foreach ($categories as $value) { $search_category .=''; } // Now build content $content = ''; // if not exists already, we create it if (!file_exists($mvModule_root_path . 'data/torrents.dat')) { touch($mvModule_root_path . 'data/torrents.dat'); } $source = fopen($mvModule_root_path . 'data/torrents.dat','r'); flock($source, LOCK_EX) ; $cnt = 0; $total = 0; while ($info = fscanf ($source, "%s %s %s %ld %d %s %s %d %d %d %d\n")) { if (!file_exists($mvModule_root_path . 'data/'.$info_hash.'.lock')) { $total++; } } rewind($source); list($quotient,$reste) = euclidivision($total,$torrents_per_page); if ($page == "") { $page = 0; } // we process the search form and display the results while ($info = fscanf ($source, "%s %s %s %ld %d %s %s %d %d %d %d\n")) { list ($info_hash, $filename, $name,$size,$numfiles,$descr,$category,$seeders,$leechers,$completed,$hits) = $info; // has the torrent been banned from server ? if (file_exists($mvModule_root_path . 'data/'.$info_hash.'.lock')) { continue; } $totseeders += $seeders; $totleechers += $leechers; $category = "".$category.""; $newname = substr($name, 0, 35); if ($newname != $name) { $name = $newname . "..."; } else { $name = $newname; } $health = ''.$lang['TR_health'].''; if ($cnt >= $page*$torrents_per_page && $cnt < ($page+1)*$torrents_per_page) { // user entered a word to search and changed the default category if ($keywords != "" && ($cat != "" && $cat != $lang['TR_search_all_category']) ) { if (eregi($cat,$category) && (eregi($keywords,$name) || eregi($keywords,$filename) || eregi($keywords,$descr))) { //echo "1"; $content .= '  '. INDEX_MORE .' '.$name.' ('. INDEX_DETAILS. ') '; $cnt++; } } // user just changed the default category else if ($keywords == "" && ($cat != "" && $cat != "All Categories") ) { if (eregi($cat,$category)) { //echo "2"; $content .= '  '. INDEX_MORE .' '.$name.' ('. INDEX_DETAILS .') '; } } // user set category to "All Categories" but is looking for a special torrent else if ( $keywords != "" && ($cat == "" || $cat == "All Categories")) { if ( (eregi($keywords,$name) || eregi($keywords,$filename) || eregi($keywords,$descr))) { //echo "3"; $content .= '  '. INDEX_MORE .' '.$name.' ('. INDEX_MORE .') '. LOADING_PLEASE_WAIT .' '; } } // user is not doing a search else { //echo "4"; $content .= '  '. INDEX_MORE .' '.$name.' ('. INDEX_MORE .') '; } } $cnt++; $i = $cnt; $row_class = ( !($i % 2) ) ? 'row1' : 'row2'; $template->assign_block_vars('torrents', array( 'CLASS' => $row_class, 'TR_CATEGORY' => $category, 'TR_SIZE' => tt_filesize($size), 'TR_SEEDERS' => $seeders, 'TR_LEECHERS' => $leechers, 'TR_HEALTH' => $health, 'TR_NAME' => $name, 'TR_HASH' => $info_hash, //'U_TR_HASH' => append_sid('details.'.$phpEx.'?info_hash=' . $info_hash), 'U_TR_HASH' => ( $ajax_browse ) ? "javascript:sndAjaxReq('" .append_sid('details.'.$phpEx.'?info_hash=' . $info_hash) . "');" : append_sid('details.'.$phpEx.'?info_hash=' . $info_hash), ) //end array ); } flock($source, LOCK_UN); fclose($source); // no result was found if ($cnt == 0) { $template->assign_block_vars('switch_no_torrents', array()); } $content .=' '; if ($quotient > 0) { $content .= '

'.INDEX_PAGE.': '; if ($reste==0) $lim = $quotient-1; else $lim = $quotient; if ($page > 0) $content .= ''. INDEX_FIRST . ''; if ($page > 1) $content .= ''. INDEX_PREVIOUS . ''; for ($i=0;$i<=$lim;$i++) { if ($i == $page) $content .= ''.($i+1).' '; else $content .= ''.($i+1).' '; } if ($page < $lim-1) $content .= ''. INDEX_NEXT . ''; if ($page < $lim) $content .= ''. INDEX_LAST . ''; $content .= '
'; } $content .='
'; //stats if (!isset($totseeders)) $totseeders = 0; if (!isset($totleechers)) $totleechers = 0; //$content .= '

'.sprintf(INDEX_TRACKING,$cnt,$totseeders + $totleechers,$totseeders,$totleechers).'
'; //Torrents News if (isset($news_array)) { foreach ($new_array as $new) { $news .= "".$new['title']." (Posted on ".$new['date']." by ".$new['author'].")"; $news .= "

".$new['content'].'

'; $template->assign_block_vars('news_torrents', array( 'CLASS' => $row_class, 'TR_NEWS_TITLE' => $new['title'], 'TR_NEWS_DATE' => $new['date'], 'TR_NEWS_AUTHOR' => $new['author'], 'TR_NEWS_CONTENT' => $new['content'], //'TR_HEALTH' => $health, //'TR_NAME' => $name, //'TR_HASH' => $info_hash, //'U_TR_HASH' => append_sid('details.'.$phpEx.'?info_hash=' . $info_hash), ) //end array ); } } //main_box($mainbox_title,$news.$content); $template->assign_vars(array( 'TR_TITLE' => $title, 'TR_CONTENT' => $content, 'L_TR_TITLE' => $lang['TR_title'], 'L_TR_INDEX' => $lang['TR_index'], 'U_TR_INDEX' => ( $ajax_browse ) ? "javascript:sndAjaxReq('index.php?module=trader');" : "index.php?module=trader", 'L_TR_UPLOAD' => $lang['TR_upload'], 'U_TR_UPLOAD' => ( $ajax_browse ) ? "javascript:sndAjaxReq('index.php?module=trader&file=upload');" : "index.php?module=trader&file=upload", 'L_TR_FAQ' => $lang['TR_faq'], 'U_TR_FAQ' => ( $ajax_browse ) ? "javascript:sndAjaxReq('index.php?module=trader&file=faq');" : "index.php?module=trader&file=faq", 'L_SEARCH' => $lang['Search'], 'L_NO_RESULTS' => $lang['TR_noresults'], 'L_TR_SEARCH_KEYWORDS' => $lang['TR_search_keywords'], 'L_TR_SEARCH_CATEGORY' => $lang['TR_search_category'], 'L_TR_SEARCH_ALL_CATEGORIES' => $lang['TR_search_all_category'], 'TR_SEARCH_CATEGORY' => $search_category, 'TR_KEYWORDS' => $keywords, 'L_TR_TYPE' => $lang['TR_type'], 'L_TR_NAME' => $lang['TR_name'], 'L_TR_SIZE' => $lang['TR_size'], 'L_TR_SEEDERS' => $lang['TR_seeders'], 'L_TR_LEECHERS' => $lang['TR_leechers'], 'L_TR_HEALTH' => $lang['TR_health'], 'L_TR_PLEASE_WAIT' => $lang['TR_please_wait'], 'L_TR_MORE' => $lang['TR_more'], 'U_TR_RELOAD' => append_sid('trader.'.$phpEx), 'TR_STATS_FOOTER' => sprintf($lang['TR_tracking'],$cnt,$totseeders + $totleechers,$totseeders,$totleechers), ) ); if ($mode == "ajax") { header('Content-type: text/html; charset=UTF-8'); echo "title|Торрент|inside|"; } $template->pparse('body'); if ($mode != "ajax") { page_footer(); } ?>