Not Solved [How To?] Search Code
#1
Not Solved
I want to put search code  on plugin. here is search code of mydownload plugin.

can anyone help me to figure it out what is wrong in this code?

i make this code through searching search in plugin file.
i just want to know that is made code for search downloads is right or wrong.
if wrong please anyone help me to sortout this.

if($mybb->input['name'] != '')
{
// Breadcrumb for searching
if($cid <= 0)
add_breadcrumb($lang->mydownloads_search_results." ".htmlspecialchars_uni($mybb->input['name'])." ".$lang->mydownloads_in." ".$lang->mydownloads_all_categories, 'mydownloads.php?action=browse_cat&amp;cid=0&amp;name='.urlencode(htmlspecialchars_uni($mybb->input['name'])));
else
add_breadcrumb($lang->mydownloads_search_results." ".htmlspecialchars_uni($mybb->input['name'])." ".$lang->mydownloads_in." ".$cat['name'], 'mydownloads.php?action=browse_cat&amp;cid=0&amp;name='.urlencode(htmlspecialchars_uni($mybb->input['name'])));
}
{
// Browsing/searching one category
if($mybb->input['name'] != '')
$total_rows = $db->fetch_field($db->simple_select("mydownloads_test", "COUNT(did) as downloads", 'cid='.$cid.' AND name LIKE \'%'.$db->escape_string($mybb->input['name']).'%\''), "downloads");
else
$total_rows = $db->fetch_field($db->simple_select("mydownloads_downloads", "COUNT(did) as downloads", 'cid='.$cid), "downloads");
}
else // We're searching all categories
{
if($mybb->input['name'] != '')
$total_rows = $db->fetch_field($db->simple_select("mydownloads_downloads", "COUNT(did) as downloads", 'name LIKE \'%'.$db->escape_string($mybb->input['name']).'%\''), "downloads");
else
$total_rows = $db->fetch_field($db->simple_select("mydownloads_downloads", "COUNT(did) as downloads"), "downloads");
}

if($cid > 0)
{
// Browsing/searching one category
if($mybb->input['name'] != '')
$query = $db->simple_select('mydownloads_downloads', '*', 'cid='.$cid.' AND name LIKE \'%'.$db->escape_string($mybb->input['name']).'%\''.$hidden.$unviewable, array('limit' => "{$start}, {$per_page}", 'order_by' => $orderby, 'order_dir' => $orderdir));
else
$query = $db->simple_select('mydownloads_downloads', '*', 'cid='.$cid.$hidden.$unviewable, array('limit' => "{$start}, {$per_page}", 'order_by' => $orderby, 'order_dir' => $orderdir));
}
else
{
// Searching all categories
if($mybb->input['name'] != '')
$query = $db->simple_select('mydownloads_downloads', '*', 'cid!=0 AND name LIKE \'%'.$db->escape_string($mybb->input['name']).'%\''.$hidden.$unviewable, array('limit' => "{$start}, {$per_page}", 'order_by' => $orderby, 'order_dir' => $orderdir));
else
$query = $db->simple_select('mydownloads_downloads', '*', 'cid!=0'.$hidden.$unviewable, array('limit' => "{$start}, {$per_page}", 'order_by' => $orderby, 'order_dir' => $orderdir));
}

{
// Table title
if($mybb->input['name'] != '')
{
if($cid <= 0)
$category_name = $lang->mydownloads_search_results." ".htmlspecialchars_uni($mybb->input['name'])." ".$lang->mydownloads_in." ".$lang->mydownloads_all_categories;
else
$category_name = $lang->mydownloads_search_results." ".htmlspecialchars_uni($mybb->input['name'])." ".$lang->mydownloads_in." ".htmlspecialchars_uni($cat['name']);
}
else
$category_name = htmlspecialchars_uni($cat['name']);
}

{
// set page title
if($cid > 0)
$title = $lang->mydownloads .= ' - '.htmlspecialchars_uni($cat['name']);
else
$title = $lang->mydownloads .= ' - '.$lang->mydownloads_search_results." ".htmlspecialchars_uni($mybb->input['name']);

elseif($mybb->input['action'] == 'search')
}

   {
// add breadcrumb
add_breadcrumb($lang->mydownloads_search, 'mydownloads.php?action=search');

if(isset($mybb->input['cid']))
{
// check if category exists
$cid = intval($mybb->input['cid']);
if ($cid <= 0 || (!($cat = mydownloads_get_category($cid))))
error($lang->mydownloads_no_cid);

// verify permissions first
if ($cat['hidden'] == 1)
error($lang->mydownloads_no_permissions);

// are we allowed to view the category?
if (!mydownloads_check_permissions($cat['usergroups']))
{
error($lang->mydownloads_no_permissions);
}
}

// set page title
$title = $lang->mydownloads .= ' - '.$lang->search;

eval("\$search = \"".$templates->get("mydownloads_search")."\";");

output_page($search);

exit; 
}

Please help anyone.
Reply


Messages In This Thread
Search Code - by Dr_The_One - 2015-09-22, 07:51 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)