} $torder = $torder == 1 ? 'ASC' : 'DESC'; $order .= ' ' . $torder; /* WHERE */ $where = "WHERE id<>1505"; switch ($field) { case "sourcetype": $type = escape_sql($type, $conn); $pids = Plugin_sid::get_plugins_by_type($conn, $type); $plugin_list = implode(",", $pids); $plugin_list = $plugin_list != '' ? $plugin_list : "''"; $where .= " AND id in ({$plugin_list})"; break; case "category_id": $type = escape_sql($type, $conn); $pids = Plugin_sid::get_plugins_by_category($conn, $type, $subcategory_id); $plugin_list = implode(",", $pids); $plugin_list = $plugin_list != '' ? $plugin_list : "''"; $where .= " AND id in ({$plugin_list})"; break; } if (!empty($search)) { $search = mb_detect_encoding($search . " ", 'UTF-8,ISO-8859-1') == 'UTF-8' ? Util::utf8entities($search) : $search; $search = escape_sql($search, $conn); $where .= " AND (name like '%{$search}%' OR id='{$search}' OR description like '%{$search}%') "; } /* LIMIT */ $limit = "LIMIT {$from}, {$maxrows}"; $results = array(); if ($plugin_list = Plugin::get_list($conn, "{$where} ORDER BY {$order} {$limit}")) { $total = $plugin_list[0]->get_foundrows();