input->clean_array_gpc('r', array( 'page' => TYPE_UINT, 'pp' => TYPE_UINT, 'q' => TYPE_STR )); $photoplog_page_num = $vbulletin->GPC['page']; $photoplog_per_page = $vbulletin->GPC['pp']; $photoplog_search_query = $vbulletin->GPC['q']; if (vbstrlen($photoplog_search_query) < intval($vbulletin->options['minsearchlength'])) { photoplog_output_page('photoplog_error_page',$vbphrase['photoplog_error'],$vbphrase['photoplog_too_short']); } $photoplog_search_query_link = urlencode($photoplog_search_query); $photoplog_search_query_form = htmlspecialchars_uni($photoplog_search_query); $photoplog_search_highlight = $photoplog_search_query; $photoplog_search_cats = array(); if (!empty($photoplog_ds_catopts)) { foreach ($photoplog_ds_catopts AS $photoplog_ds_catid => $photoplog_ds_value) { $photoplog_categorybit = $photoplog_ds_catopts["$photoplog_ds_catid"]['options']; $photoplog_catoptions = convert_bits_to_array($photoplog_categorybit, $photoplog_categoryoptions); $photoplog_do_searches = ($photoplog_catoptions['issearchable']) ? true : false; if ($photoplog_do_searches) { $photoplog_search_cats[] = intval($photoplog_ds_catid); } } } $photoplog_sql = ''; if (!empty($photoplog_search_cats)) { $photoplog_sql = "WHERE catid IN (" . implode(",",$photoplog_search_cats) . ")"; } else { photoplog_output_page('photoplog_error_page',$vbphrase['photoplog_error'],$vbphrase['photoplog_no_results']); } $photoplog_search_highlight = preg_replace('#\*+#s','*',$photoplog_search_highlight); $photoplog_search_highlight_array = array(); if ($photoplog_search_highlight != '*') { $photoplog_search_highlight = preg_quote(strtolower($photoplog_search_highlight), '#'); $photoplog_from_chars = array('\*', '\<', '\>'); $photoplog_to_chars = array('[\s\w.:@*/?=]*?', '<', '>'); $photoplog_search_highlight = str_replace($photoplog_from_chars,$photoplog_to_chars,$photoplog_search_highlight); $photoplog_search_highlight = '[\w.:@*/?=]*?'.$photoplog_search_highlight.'[\w.:@*/?=]*?'; $photoplog_search_highlight = htmlspecialchars_uni($photoplog_search_highlight); $photoplog_search_highlight_array[] = $photoplog_search_highlight; } $photoplog_from_chars = array('%','_'); $photoplog_to_chars = array('\%','\_'); $photoplog_search_query = str_replace($photoplog_from_chars, $photoplog_to_chars, $photoplog_search_query); if ($vbulletin->options['allowwildcards']) { $photoplog_search_query = str_replace('*','%',$photoplog_search_query); } else { $photoplog_search_query = str_replace('*','',$photoplog_search_query); } $photoplog_file_infos = $db->query_read("SELECT * FROM photoplog_fileuploads $photoplog_sql AND moderate = 0 AND ( title LIKE '%".$db->escape_string($photoplog_search_query)."%' OR description LIKE '%".$db->escape_string($photoplog_search_query)."%' ) "); $photoplog_fid_bits = array(); while ($photoplog_file_info = $db->fetch_array($photoplog_file_infos)) { $photoplog_hidden_bit = 0; $photoplog_catid = $photoplog_file_info['catid']; if (!in_array($photoplog_catid,array_keys($photoplog_ds_catopts))) { $photoplog_category_title = $vbphrase['photoplog_not_available']; $photoplog_hidden_bit = 1; } else { $photoplog_category_title = htmlspecialchars_uni($photoplog_ds_catopts[$photoplog_catid]['title']); if ($photoplog_ds_catopts[$photoplog_catid]['displayorder'] == 0) { $photoplog_hidden_bit = 1; } } if (!$photoplog_hidden_bit) { $photoplog_fileid = $photoplog_file_info['fileid']; $photoplog_title = $photoplog_file_info['title']; $photoplog_description = $photoplog_file_info['description']; $photoplog_add_dots = false; if ($vbulletin->options['lastthreadchars'] != 0 && vbstrlen($photoplog_title) > $vbulletin->options['lastthreadchars']) { $photoplog_add_dots = true; $photoplog_title = substr($photoplog_title, 0, $vbulletin->options['lastthreadchars']); $photoplog_title = photoplog_regexp_text($photoplog_title); } $photoplog_title = photoplog_process_text($photoplog_title, $photoplog_catid, true, $photoplog_add_dots); if ($photoplog_title == $vbphrase['photoplog_not_available']) { $photoplog_title = $vbphrase['photoplog_untitled']; } $photoplog_add_dots = false; if ($vbulletin->options['lastthreadchars'] != 0 && vbstrlen($photoplog_description) > $vbulletin->options['lastthreadchars'] * 2) { $photoplog_add_dots = true; $photoplog_description = substr($photoplog_description, 0, $vbulletin->options['lastthreadchars'] * 2); $photoplog_description = photoplog_regexp_text($photoplog_description); } $photoplog_description = photoplog_process_text($photoplog_description, $photoplog_catid, false, $photoplog_add_dots); if (!empty($photoplog_search_highlight_array)) { if (!class_exists('vB_Postbit_Post')) { require_once(DIR . '/includes/class_postbit.php'); $photoplog_postbit_class =& new vB_Postbit_Post(); } $photoplog_title = preg_replace('#(^|>)([^<]+)(?=<|$)#sUe', "\$photoplog_postbit_class->process_highlight_postbit('\\2', \$photoplog_search_highlight_array, '\\1')", $photoplog_title); $photoplog_description = preg_replace('#(^|>)([^<]+)(?=<|$)#sUe', "\$photoplog_postbit_class->process_highlight_postbit('\\2', \$photoplog_search_highlight_array, '\\1')", $photoplog_description); if (eregi('',$photoplog_title) || eregi('',$photoplog_description)) { $photoplog_fid_bits[] = intval($photoplog_fileid); } } } } $db->free_result($photoplog_file_infos); $photoplog_search_tot = count($photoplog_fid_bits); $photoplog_catbit_info = array(); $photoplog_catbit_subcats = ''; $photoplog_subcat_bar = ''; if (!$photoplog_search_tot) { photoplog_output_page('photoplog_error_page',$vbphrase['photoplog_error'],$vbphrase['photoplog_no_results']); } sanitize_pageresults($photoplog_search_tot, $photoplog_page_num, $photoplog_per_page, 10, 10); $photoplog_search_limit_lower = ($photoplog_page_num - 1) * $photoplog_per_page; if ($photoplog_search_limit_lower < 0) { $photoplog_search_limit_lower = 0; } $photoplog_file_infos = $db->query_read("SELECT * FROM photoplog_fileuploads WHERE fileid IN (". implode(",",$photoplog_fid_bits) .") ORDER BY dateline DESC LIMIT $photoplog_search_limit_lower,$photoplog_per_page "); $photoplog_sort_url = $photoplog_location.'/search.php?'.$vbulletin->session->vars['sessionurl'].'do=view&q='.$photoplog_search_query_link; $photoplog_pagenav = construct_page_nav($photoplog_page_num, $photoplog_per_page, $photoplog_search_tot, $photoplog_sort_url, ''); $photoplog_cnt_bits = 0; $photoplog_file_bits = ''; while ($photoplog_file_info = $db->fetch_array($photoplog_file_infos)) { $photoplog_hidden_bit = 0; $photoplog_catid = $photoplog_file_info['catid']; if (!in_array($photoplog_catid,array_keys($photoplog_ds_catopts))) { $photoplog_category_title = $vbphrase['photoplog_not_available']; $photoplog_hidden_bit = 1; } else { $photoplog_category_title = htmlspecialchars_uni($photoplog_ds_catopts[$photoplog_catid]['title']); if ($photoplog_ds_catopts[$photoplog_catid]['displayorder'] == 0) { $photoplog_hidden_bit = 1; } } if (!$photoplog_hidden_bit) { $photoplog_cnt_bits++; $photoplog_catid = $photoplog_file_info['catid']; $photoplog_do_comments = 0; if (in_array($photoplog_catid,array_keys($photoplog_ds_catopts))) { $photoplog_categorybit = $photoplog_ds_catopts["$photoplog_catid"]['options']; $photoplog_catoptions = convert_bits_to_array($photoplog_categorybit, $photoplog_categoryoptions); $photoplog_do_comments = ($photoplog_catoptions['allowcomments']) ? 1 : 0; } $photoplog_fileid = $photoplog_file_info['fileid']; $photoplog_userid = $photoplog_file_info['userid']; $photoplog_username = $photoplog_file_info['username']; $photoplog_title = $photoplog_file_info['title']; $photoplog_description = $photoplog_file_info['description']; $photoplog_filename = $photoplog_file_info['filename']; $photoplog_filesize = vb_number_format($photoplog_file_info['filesize'],1,true); $photoplog_date = vbdate($vbulletin->options['dateformat'],$photoplog_file_info['dateline']); $photoplog_time = vbdate($vbulletin->options['timeformat'],$photoplog_file_info['dateline']); $photoplog_views = $photoplog_file_info['views']; $photoplog_add_dots = false; if ($vbulletin->options['lastthreadchars'] != 0 && vbstrlen($photoplog_title) > $vbulletin->options['lastthreadchars']) { $photoplog_add_dots = true; $photoplog_title = substr($photoplog_title, 0, $vbulletin->options['lastthreadchars']); $photoplog_title = photoplog_regexp_text($photoplog_title); } $photoplog_title = photoplog_process_text($photoplog_title, $photoplog_catid, true, $photoplog_add_dots); if ($photoplog_title == $vbphrase['photoplog_not_available']) { $photoplog_title = $vbphrase['photoplog_untitled']; } $photoplog_add_dots = false; if ($vbulletin->options['lastthreadchars'] != 0 && vbstrlen($photoplog_description) > $vbulletin->options['lastthreadchars'] * 2) { $photoplog_add_dots = true; $photoplog_description = substr($photoplog_description, 0, $vbulletin->options['lastthreadchars'] * 2); $photoplog_description = photoplog_regexp_text($photoplog_description); } $photoplog_description = photoplog_process_text($photoplog_description, $photoplog_catid, false, $photoplog_add_dots); if (!empty($photoplog_search_highlight_array)) { if (!class_exists('vB_Postbit_Post')) { require_once(DIR . '/includes/class_postbit.php'); $photoplog_postbit_class =& new vB_Postbit_Post(); } $photoplog_title = preg_replace('#(^|>)([^<]+)(?=<|$)#sUe', "\$photoplog_postbit_class->process_highlight_postbit('\\2', \$photoplog_search_highlight_array, '\\1')", $photoplog_title); $photoplog_title = preg_replace('#(.*)#siU', '$1', $photoplog_title); $photoplog_description = preg_replace('#(^|>)([^<]+)(?=<|$)#sUe', "\$photoplog_postbit_class->process_highlight_postbit('\\2', \$photoplog_search_highlight_array, '\\1')", $photoplog_description); $photoplog_description = preg_replace('#(.*)#siU', '$1', $photoplog_description); } $photoplog_comment_count = 0; $photoplog_comment_pagenum = ''; $photoplog_last_comment_info_cnt = $db->query_first("SELECT COUNT(*) AS num FROM photoplog_ratecomment WHERE fileid = ".intval($photoplog_fileid)." AND moderate = 0 "); if ($photoplog_last_comment_info_cnt) { $photoplog_comment_count = intval($photoplog_last_comment_info_cnt['num']); $photoplog_comment_pagenum = '&page='.ceil($photoplog_last_comment_info_cnt['num'] / 5); } $db->free_result($photoplog_last_comment_info_cnt); $photoplog_comment_raw_average = '0.00'; $photoplog_comment_img_average = 0; $photoplog_last_comment_info_ave = $db->query_first("SELECT IF(SUM(photoplog_ratecomment.rating) > 0, SUM(photoplog_ratecomment.rating) / SUM(IF(photoplog_ratecomment.rating > 0, 1, 0)), 0) AS ave FROM photoplog_ratecomment WHERE fileid = ".intval($photoplog_fileid)." AND moderate = 0 "); if($photoplog_last_comment_info_ave) { $photoplog_comment_raw_average = sprintf("%.2f",round($photoplog_last_comment_info_ave['ave'],2)); $photoplog_comment_img_average = intval(round($photoplog_last_comment_info_ave['ave'],0)); } $db->free_result($photoplog_last_comment_info_ave); $photoplog_last_comment_info = $db->query_first("SELECT * FROM photoplog_ratecomment WHERE fileid = ".intval($photoplog_fileid)." AND moderate = 0 ORDER BY dateline DESC LIMIT 1 "); $photoplog_comment_userid = ''; $photoplog_comment_username = ''; $photoplog_comment_title = ''; $photoplog_comment_date = ''; $photoplog_comment_time = ''; $photoplog_comment_commentid = ''; $photoplog_comment_page = ''; if ($photoplog_last_comment_info) { $photoplog_comment_userid = $photoplog_last_comment_info['userid']; $photoplog_comment_username = $photoplog_last_comment_info['username']; $photoplog_comment_title = $photoplog_last_comment_info['title']; $photoplog_comment_date = vbdate($vbulletin->options['dateformat'],$photoplog_last_comment_info['dateline']); $photoplog_comment_time = vbdate($vbulletin->options['timeformat'],$photoplog_last_comment_info['dateline']); $photoplog_comment_commentid = '#comment'.$photoplog_last_comment_info['commentid']; $photoplog_comment_page = $photoplog_comment_pagenum.$photoplog_comment_commentid; } $db->free_result($photoplog_last_comment_info); $photoplog_add_dots = false; if ($vbulletin->options['lastthreadchars'] != 0 && vbstrlen($photoplog_comment_title) > $vbulletin->options['lastthreadchars']) { $photoplog_add_dots = true; $photoplog_comment_title = substr($photoplog_comment_title, 0, $vbulletin->options['lastthreadchars']); $photoplog_comment_title = photoplog_regexp_text($photoplog_comment_title); } $photoplog_comment_title = photoplog_process_text($photoplog_comment_title, $photoplog_catid, true, $photoplog_add_dots); if ($photoplog_comment_title == $vbphrase['photoplog_not_available']) { $photoplog_comment_title_temp = $db->query_first("SELECT * FROM photoplog_fileuploads WHERE fileid = ".intval($photoplog_fileid)." AND moderate = 0 "); $photoplog_comment_title = $photoplog_comment_title_temp['title']; $db->free_result($photoplog_comment_title_temp); $photoplog_add_dots = false; if ($vbulletin->options['lastthreadchars'] != 0 && vbstrlen($photoplog_comment_title) > $vbulletin->options['lastthreadchars']) { $photoplog_add_dots = true; $photoplog_comment_title = substr($photoplog_comment_title, 0, $vbulletin->options['lastthreadchars']); $photoplog_comment_title = photoplog_regexp_text($photoplog_comment_title); } $photoplog_comment_title = photoplog_process_text($photoplog_comment_title, $photoplog_catid, true, $photoplog_add_dots); } if ($photoplog_comment_title == $vbphrase['photoplog_not_available']) { $photoplog_comment_title = $vbphrase['photoplog_untitled']; } eval('$photoplog_file_bits .= "' . fetch_template('photoplog_file_bit') . '";'); } } $db->free_result($photoplog_file_infos); if (!$photoplog_cnt_bits) { $photoplog_file_bits = ''.$vbphrase['photoplog_not_available'].''; } photoplog_output_page('photoplog_file_list', $vbphrase['photoplog_file_list']); } if ($_REQUEST['do'] != 'query' && $_REQUEST['do'] != 'view') { photoplog_index_bounce(); } ?>