$count = $row[0];
if (!$count && isset($cleansearchstr)) {
    $wherea = $wherebase;
    $searcha = explode(" ", $cleansearchstr);
    $sc = 0;
    foreach ($searcha as $searchss) {
        if (strlen($searchss) <= 1) {
            continue;
        }
        $sc++;
        if ($sc > 5) {
            break;
        }
        $ssa = array();
        foreach (array("torrents.name") as $sss) {
            $ssa[] = "{$sss} LIKE '%" . sqlwildcardesc($searchss) . "%'";
        }
        $wherea[] = "(" . implode(" OR ", $ssa) . ")";
    }
    if ($sc) {
        $where = implode(" AND ", $wherea);
        if ($where != "") {
            $where = "WHERE {$where}";
        }
        $res = SQL_Query_exec("SELECT COUNT(*) FROM torrents {$where} {$parent_check}");
        $row = mysql_fetch_array($res);
        $count = $row[0];
    }
}
//Sort by
if ($addparam != "") {
Example #2
0
// | along with TBDevYSE; if not, write to the Free Software Foundation,      |
// | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            |
// +--------------------------------------------------------------------------+
// |                                               Do not remove above lines! |
// +--------------------------------------------------------------------------+
*/
require "include/bittorrent.php";
dbconn();
loggedinorreturn();
$search = trim($_GET['search']);
$class = $_GET['class'];
if ($class == '-' || !is_valid_user_class($class)) {
    $class = '';
}
if ($search != '' || $class) {
    $query = "username LIKE '%" . sqlwildcardesc("{$search}") . "%' AND status='confirmed'";
    if ($search) {
        $q = "search=" . htmlspecialchars_uni($search);
    }
} else {
    $letter = trim($_GET["letter"]);
    if (strlen($letter) > 1) {
        die;
    }
    /*	if ($letter != "" && strpos("abcdefghijklmnopqrstuvwxyz", $letter) === false)
    		$letter = "a";
    	$query = ( $letter != "" ? "username LIKE '$letter%' AND " : "") . "status='confirmed'";
    	if ($letter == "")
    		$letter = "a";
    	$q = "letter=$letter";*/
    if ($letter != "" && strpos("abcdefghijklmnopqrstuvwxyz" . "абвгдеёжзийклмнопрстуфхцчшщъыьэюя", $letter) === false) {
Example #3
0
$num_torrents = $count;
if (!$count && isset($cleansearchstr)) {
    $wherea = $wherebase;
    //$orderby = "ORDER BY id DESC";
    $searcha = explode(" ", $cleansearchstr);
    $sc = 0;
    foreach ($searcha as $searchss) {
        if (strlen($searchss) <= 1) {
            continue;
        }
        $sc++;
        if ($sc > 5) {
            break;
        }
        $ssa = array();
        $ssa[] = "t.name LIKE '%" . sqlwildcardesc($searchss) . "%'";
    }
    if ($sc) {
        $where = implode(" AND ", $wherea);
        if ($where != "") {
            $where = "WHERE {$where}";
        }
        $res = sql_query("SELECT COUNT(*) FROM torrents AS t {$where}");
        $row = mysql_fetch_array($res);
        $count = $row[0];
    }
}
$torrentsperpage = $CURUSER["torrentsperpage"];
if (!$torrentsperpage) {
    $torrentsperpage = 25;
}
Example #4
0
function search($_GET, $CURUSER)
{
    $cats = genrelist();
    if (isset($_GET["search"])) {
        $searchstr = unesc($_GET["search"]);
        $cleansearchstr = searchfield($searchstr);
        if (empty($cleansearchstr)) {
            unset($cleansearchstr);
        }
    }
    $orderby = "ORDER BY torrents.id DESC";
    $addparam = "";
    $wherea = array();
    $wherecatina = array();
    if (isset($_GET["incldead"]) && $_GET["incldead"] == 1) {
        $addparam .= "incldead=1&amp;";
        if (!isset($CURUSER) || get_user_class() < UC_ADMINISTRATOR) {
            $wherea[] = "banned != 'yes'";
        }
    } else {
        if (isset($_GET["incldead"]) && $_GET["incldead"] == 2) {
            $addparam .= "incldead=2&amp;";
            $wherea[] = "visible = 'no'";
        } else {
            $wherea[] = "visible = 'yes'";
        }
    }
    $category = isset($_GET["cat"]) ? (int) $_GET["cat"] : false;
    $license = isset($_GET["lic"]) ? (int) $_GET["lic"] : false;
    $version = isset($_GET["ver"]) ? (int) $_GET["ver"] : false;
    $user = isset($_GET["user"]) ? (int) $_GET["user"] : false;
    $all = isset($_GET["all"]) ? $_GET["all"] : false;
    $page_limit = isset($_GET["page_limit"]) ? $_GET["page_limit"] : false;
    if (!$all) {
        if (!$_GET && $CURUSER["notifs"]) {
            $all = True;
            foreach ($cats as $cat) {
                $all &= $cat['id'];
                if (strpos($CURUSER["notifs"], "[cat" . $cat['id'] . "]") !== False) {
                    $wherecatina[] = $cat['id'];
                    $addparam .= "c{$cat['id']}=1&amp;";
                }
            }
        } elseif ($category) {
            if (!is_valid_id($category)) {
                stderr("Error", "Invalid category ID.");
            }
            $wherecatina[] = $category;
            $addparam .= "cat={$category}&amp;";
        } else {
            $all = True;
            foreach ($cats as $cat) {
                $all &= isset($_GET["c{$cat['id']}"]);
                if (isset($_GET["c{$cat['id']}"])) {
                    $wherecatina[] = $cat['id'];
                    $addparam .= "c{$cat['id']}=1&amp;";
                }
            }
        }
    }
    if ($all) {
        $wherecatina = array();
        $addparam = "";
    }
    if (count($wherecatina) > 1) {
        $wherecatin = implode(",", $wherecatina);
    } elseif (count($wherecatina) == 1) {
        $wherea[] = "category = {$wherecatina['0']}";
    }
    if ($license > 0) {
        $wherea[] = "license = {$license}";
    }
    if ($user > 0) {
        $wherea[] = "owner = {$user}";
    }
    if ($version > 0) {
        $wherea[] = "version = {$version}";
    }
    $wherebase = $wherea;
    if (isset($cleansearchstr)) {
        $wherea[] = "MATCH (search_text, ori_descr) AGAINST (" . sqlesc($searchstr) . ")";
        //$wherea[] = "0";
        $addparam .= "search=" . urlencode($searchstr) . "&amp;";
        $orderby = "";
        /////////////// SEARCH CLOUD MALARKY //////////////////////
        $searchcloud = sqlesc($cleansearchstr);
        // $r = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM searchcloud WHERE searchedfor = $searchcloud"), MYSQL_NUM);
        //$a = $r[0];
        //if ($a)
        // mysql_query("UPDATE searchcloud SET howmuch = howmuch + 1 WHERE searchedfor = $searchcloud");
        //else
        // mysql_query("INSERT INTO searchcloud (searchedfor, howmuch) VALUES ($searchcloud, 1)");
        mysql_query("INSERT INTO searchcloud (searchedfor, howmuch) VALUES ({$searchcloud}, 1)\n                ON DUPLICATE KEY UPDATE howmuch=howmuch+1");
        /////////////// SEARCH CLOUD MALARKY END ///////////////////
    }
    $where = implode(" AND ", $wherea);
    if (isset($wherecatin)) {
        $where .= ($where ? " AND " : "") . "category IN(" . $wherecatin . ")";
    }
    if ($where != "") {
        $where = "WHERE {$where}";
    }
    $res = mysql_query("SELECT COUNT(*) FROM torrents {$where}") or die(mysql_error());
    $row = mysql_fetch_array($res, MYSQL_NUM);
    $count = $row[0];
    if (!$count && isset($cleansearchstr)) {
        $wherea = $wherebase;
        $orderby = "ORDER BY id DESC";
        $searcha = explode(" ", $cleansearchstr);
        $sc = 0;
        foreach ($searcha as $searchss) {
            if (strlen($searchss) <= 1) {
                continue;
            }
            $sc++;
            if ($sc > 5) {
                break;
            }
            $ssa = array();
            foreach (array("search_text", "ori_descr") as $sss) {
                $ssa[] = "{$sss} LIKE '%" . sqlwildcardesc($searchss) . "%'";
            }
            $wherea[] = "(" . implode(" OR ", $ssa) . ")";
        }
        if ($sc) {
            $where = implode(" AND ", $wherea);
            if ($where != "") {
                $where = "WHERE {$where}";
            }
            $res = mysql_query("SELECT COUNT(*) FROM torrents {$where}");
            $row = mysql_fetch_array($res, MYSQL_NUM);
            $count = $row[0];
        }
    }
    $torrentsperpage = $CURUSER["torrentsperpage"];
    if ($page_limit) {
        $torrentsperpage = $page_limit;
    }
    if (!$torrentsperpage) {
        $torrentsperpage = 15;
    }
    if ($count) {
        //list($pagertop, $pagerbottom, $limit) = pager($torrentsperpage, $count, "browse.php?" . $addparam);
        $pager = pager($torrentsperpage, $count, "browse.php?" . $addparam);
        $query = "SELECT torrents.id, torrents.category, torrents.leechers, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.type,  torrents.comments,torrents.numfiles,torrents.filename,torrents.owner,IF(torrents.nfo <> '', 1, 0) as nfoav," . "categories.name AS cat_name, categories.image AS cat_pic, users.username, torrents.version, torrents.descr,licenses.name AS lic_name,licenses.url AS lic_url,licenses.description AS lic_desc FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id LEFT JOIN licenses ON torrents.license = licenses.id {$where} {$orderby} {$pager['limit']}";
        $res = mysql_query($query) or die(mysql_error());
    } else {
        unset($res);
    }
    if ($count) {
        return array($res, $wherecatina, $pager);
    } else {
        return array("", $wherecatina, "");
    }
}
Example #5
0
         }
         $HTMLOUT .= "</td>";
         $HTMLOUT .= "<td style='white-space: nowrap;'>" . get_date($getdaily['added'], 'LONG', 1, 0) . "</td></tr>";
     }
     mysql_free_result($res);
     $HTMLOUT .= end_table();
     $HTMLOUT .= $pager['pagerbottom'];
     $HTMLOUT .= end_main_frame();
     print stdhead('Today Posts (Last 24 Hours)') . $HTMLOUT . stdfoot();
 } else {
     if ($action == "search") {
         $error = false;
         $found = '';
         $keywords = isset($_GET['keywords']) ? trim($_GET['keywords']) : '';
         if (!empty($keywords)) {
             $res = mysql_query("SELECT COUNT(id) AS c FROM posts WHERE body LIKE " . sqlesc("%" . sqlwildcardesc($keywords) . "%")) or sqlerr(__FILE__, __LINE__);
             $arr = mysql_fetch_assoc($res);
             $count = (int) $arr['c'];
             $keywords = htmlspecialchars($keywords);
             if ($count == 0) {
                 $error = true;
             } else {
                 $perpage = 10;
                 $pager = pager($perpage, $count, $_SERVER['PHP_SELF'] . '?action=' . $action . '&keywords=' . $keywords . '&');
                 $res = mysql_query("SELECT p.id, p.topicid, p.userid, p.added, t.forumid, t.subject, f.name, f.minclassread, u.username " . "FROM posts AS p " . "LEFT JOIN topics AS t ON t.id=p.topicid " . "LEFT JOIN forums AS f ON f.id=t.forumid " . "LEFT JOIN users AS u ON u.id=p.userid " . "WHERE p.body LIKE " . sqlesc("%" . $keywords . "%") . " " . $pager['limit'] . "");
                 $num = mysql_num_rows($res);
                 $HTMLOUT .= $pager['pagertop'];
                 $HTMLOUT .= begin_main_frame();
                 $HTMLOUT .= "<table border='0' cellspacing='0' cellpadding='5' width='100%'>\r\n\t\t\t       <tr align='left'>\r\n            \t<td class='colhead'>Post</td>\r\n                <td class='colhead'>Topic</td>\r\n                <td class='colhead'>Forum</td>\r\n                <td class='colhead'>Posted by</td>\r\n\t\t\t          </tr>";
                 for ($i = 0; $i < $num; ++$i) {
                     $post = mysql_fetch_assoc($res);