The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Advanced Search (search by exact date range) Details »» | |||||||||||||||||||||||||||
Advanced Search (search by exact date range)
Developer Last Online: Jun 2007
This is a very simple but powerful mod that allows you to add the option to allow users to
search by (date range) instead of just using the default limited vB options! This allows for much better control of search results, allowing for exact searches by date range! INSTALLER SUPPORTS supports : vB 3.0.3, 3.0.4, 3.0.5, 3.0.6 language : English (US) OS support: Linux/Unix/Windows (because of line endings) The installer.... 1. The installer will (install and or uninstall) this mod, with install and uninstall tester! 2. What it will install... A. Installs the Admin Panel (Advance Date Option) This allows for the administrator to configure the date range format from the Admin Panel! (dynamic control) 1/2/3 -> mm/dd/yyyy 3.2.1 -> yyyy.dd.mm 2-1-3 -> dd-mm-yyyy B. Installs a full error control handler... This gives members helpful information when a search error is encounted! C. Auto loads the language phrases! The installer checks the datastore and language groups, making sure all data to run the Advance Search is present, if not it updates the caches so the language phrases are auto loaded! D. Installs a (smart search date relevance control) The relevance control, is designed to allow each member to search for results based on their own time zone! The control also uses a cache system, so searches can be loaded into the exsiting vB search table, but are indexed by the date and not by the standard vB search control! This allows for each search to be more unique in regards to the query matching the starting and ending date range! E. Add the option to the users search pref control NOTES: Each directory contains a read_me files, giving detailed information about that install process! Other Notes! Time to install : 2 minutes! Test Installer : YES Test Uninstaller: YES Auto Installer : YES Auto Uninstaller: YES DB CHANGES : NONE SCRIPT CHANGES : 1 script 'search.php' -> adds (1) main function 'q_builder()', and replaces and adds (8) sections of code within the rest of 'search.php'! The template 'search_forums' is the only thing you must install via the Admin Panel! Images showing the control are below! Any questions, just ask! I have been overseas for a while, but I am back now, so I will always be around to help anyone needing help with installing this! Here is the step by step install, for the template and the search.php script! Also a simple DB installer for the admin panel and language phrases! EDITING and INSTALLING THE TEMPLATE go to your Admin Panel left nav -> left click -> Styles & Templates scroll down to -> Search in Templates -> left click right window -> select box -> Search in Style select the style to add this Advanced Search Option to... in the -> tex box -> Search for Text enter -> search_forums check the -> radio button -> Search Titles Only -> check -> yes click the submit button -> Find Style Manager Opens! left click on the template -> search_forums The template should now be open! Notes: Because you may have edited this template, we will search, add and replace by finding code patterns that we will add the Advanced Search Option before or after the code pattern that we are looking for... 1. ADD FIND THIS Code:
<legend>$vbphrase[find_posts_from]</legend> <div style="padding:$stylevar[formspacer]px"> REPLACE WITH Code:
<legend>$vbphrase[find_posts_from]</legend> <div style="padding:$stylevar[formspacer]px"><label for='s_opt_one'><input type='radio' name='find_opt' value='0' id="s_opt_one" $find_optchecked[0]/>$vbphrase[find_opt_one]</label></div> <div align='center'> FIND THIS Code:
<option value="before" $beforeafterselected[before]>$vbphrase[and_older]</option> </select> </div> </fieldset> REPLACE WITH Code:
<option value="before" $beforeafterselected[before]>$vbphrase[and_older]</option> </select></div><div style="padding:$stylevar[formspacer]px"><label for='s_opt_two'><input type='radio' name='find_opt' value='1' id="s_opt_two" $find_optchecked[1]/>$vbphrase[find_opt_two]</label></div><div width='100%' style="text-align: center"> <table width='100%' cellpadding='1' cellspacing='0' align='center'> <tr> <td width='50%'>$vbphrase[find_date_one]</td> <td width='50%'>$vbphrase[find_date_two]</td> </tr> <tr> <td width='50%'><input type='text' class='bginput' style='font-size:11px' name='soptdate' size='10' value='$soptdate' maxlength='10' /></td> <td width='50%'><input type='text' class='bginput' style='font-size:11px' name='eoptdate' size='10' value='$eoptdate' maxlength='10' /></td> </tr> <tr> <td colspan='2' height='18'>$vbphrase[date_format]$conf_dformat</td> </tr> </table> </div> </fieldset> FIND THIS Code:
<select style="width:100%" name="forumchoice[]" size="13" multiple="multiple"> REPLACE WITH Code:
<select style="width:100%" name="forumchoice[]" size="18" multiple="multiple"> All done with the template edits! click the 'Save' button to save the changes! Go back to the Admin Panel! Now lets install the changes to 'search.php'... NOTE: Make a backup of 'search.php', NOW!!! EDITING search.php Notes: Each Find This contains line numbers for REF! open -> 'vB install folder/search.php' FIND THIS Starting @ -> line 64 Code:
64 $globalize = array( 65 'query' => STR, 66 'searchuser' => STR, 67 'exactname' => INT, 68 'starteronly' => INT, 69 'forumchoice', 70 'childforums' => INT, 71 'titleonly' => INT, 72 'showposts' => INT, 73 'searchdate' => STR, 74 'beforeafter' => STR, 75 'sortby' => STR, 76 'sortorder' => STR, 77 'replyless' => INT, 78 'replylimit' => INT, 79 'searchthread' => INT, 80 'searchthreadid' => INT, 81 'saveprefs' => INT 82 ); Code:
$globalize = array( 'query' => STR, 'searchuser' => STR, 'exactname' => INT, 'starteronly' => INT, 'forumchoice', 'childforums' => INT, 'titleonly' => INT, 'showposts' => INT, 'searchdate' => STR, 'beforeafter' => STR, 'sortby' => STR, 'sortorder' => STR, 'replyless' => INT, 'replylimit' => INT, 'searchthread' => INT, 'searchthreadid' => INT, 'saveprefs' => INT, 'find_opt' => INT, 'soptdate' => STR, 'eoptdate' => STR ); FIND THIS Starting @ -> line 139 Code:
139 globalize($_REQUEST, array( 140 'query' => STR, 141 'searchuser' => STR, 142 'forumid' => STR, 143 'forumchoice' 144 )); Code:
globalize($_REQUEST, array( 'query' => STR, 'searchuser' => STR, 'forumid' => STR, 'soptdate' => STR, 'eoptdate' => STR, 'forumchoice' )); FIND THIS Starting @ -> line 163 Code:
163 $prefs = array( 164 'exactname' => 1, 165 'starteronly' => 0, 166 'childforums' => 1, 167 'showposts' => 0, 168 'titleonly' => 0, 169 'searchdate' => 0, 170 'beforeafter' => 'after', 171 'sortby' => 'lastpost', 172 'sortorder' => 'descending', 173 'replyless' => 0, 174 'replylimit' => 0 175 ); Code:
$prefs = array( 'exactname' => 1, 'starteronly' => 0, 'childforums' => 1, 'showposts' => 0, 'titleonly' => 0, 'searchdate' => 0, 'beforeafter' => 'after', 'sortby' => 'lastpost', 'sortorder' => 'descending', 'replyless' => 0, 'replylimit' => 0, 'find_opt' => 0 ); FIND THIS @ -> line 188 Code:
188 if ($varname != 'query' AND $varname != 'searchuser') Code:
if ($varname != 'query' AND $varname != 'searchuser' AND $varname != 'eoptdate' AND $varname != 'soptdate') FIND THIS Starting @ -> line 198 Code:
198 $query = htmlspecialchars_uni($query); 199 $searchuser = htmlspecialchars_uni($searchuser); Code:
$query = htmlspecialchars_uni($query); $searchuser = htmlspecialchars_uni($searchuser); $soptdate = htmlspecialchars_uni($soptdate); $eoptdate = htmlspecialchars_uni($eoptdate); $conf_dformat = str_replace ( '1', 'mm', str_replace ( '2', 'dd', str_replace ( '3', 'yyyy', $vboptions['searchdateformat'] ) ) ); FIND THIS @ -> line 395 Code:
395 $searchhash = md5(strtolower(iif($phrasequery, '"' . $query . '"', $query)) . "||" . strtolower($searchuser) . "||$exactname||$starteronly||$forumchoice||$childforums||$titleonly||$showposts||$searchdate||$beforeafter||$replyless||$replylimit||$searchthreadid"); Code:
$searchhash = md5(strtolower(iif($phrasequery, '"' . $query . '"', $query)) . "||" . strtolower($searchuser) . "||$exactname||$starteronly||$forumchoice||$childforums||$titleonly||$showposts||" . ( $find_opt > 0 ? $soptdate . chr ( 124 ) . chr ( 124 ) . $eoptdate : $searchdate . chr ( 124 ) . chr ( 124 ) . $beforeafter ) . "||$replyless||$replylimit||$searchthreadid"); FIND THIS Starting @ -> line 1101 Code:
1101 if ($searchdate != 'lastvisit') 1102 { 1103 $searchdate = intval($searchdate); 1104 } Code:
if ( $find_opt == 0 ) { if ($searchdate != 'lastvisit') { $searchdate = intval($searchdate); } FIND THIS Starting @ -> line 1137 Code:
1137 unset($datecut); 1138 } Code:
unset($datecut); } } else { $fdo = q_builder ( $soptdate, $eoptdate, $bbuserinfo['tzoffset'], $vboptions['searchdateformat'] ); if ( $fdo[0] == true ) { $postQueryLogic[] = $fdo[1]; } else { eval ( print_standard_error ( 'error_' . $fdo[1] ) ); } unset ( $fdo ); } FIND THIS Starting @ -> line 2339 Code:
2339 $prefs = addslashes(serialize(array( 2340 'exactname' => $exactname, 2341 'starteronly' => $starteronly, 2342 'childforums' => $childforums, 2343 'showposts' => $showposts, 2344 'titleonly' => $titleonly, 2345 'searchdate' => $searchdate, 2346 'beforeafter' => $beforeafter, 2347 'sortby' => $sortby, 2348 'sortorder' => $sortorder, 2349 'replyless' => $replyless, 2350 'replylimit' => $replylimit 2351 ))); Code:
$prefs = addslashes(serialize(array( 'exactname' => $exactname, 'starteronly' => $starteronly, 'childforums' => $childforums, 'showposts' => $showposts, 'titleonly' => $titleonly, 'searchdate' => $searchdate, 'beforeafter' => $beforeafter, 'sortby' => $sortby, 'sortorder' => $sortorder, 'replyless' => $replyless, 'replylimit' => $replylimit, 'find_opt' => $find_opt ))); FIND THIS @ -> line 2403 ( the end of the 'search'php' file! Code:
2403 ?> Code:
function q_builder ( $start, $end, $ut, $tf ) { $errors = array ( 0 => array ( 1 => 'srmissing', 2 => 'ermissing', 3 => 'brmissing' ), 1 => array ( 1 => 'srinvalid', 2 => 'erinvalid', 3 => 'brinvalid' ), 2 => array ( 1 => 'srwindows', 2 => 'erwindows', 3 => 'brwindows' ), 3 => array ( 1 => 'sraftered', 2 => 'srgreater' ) ); $time = array ( 1 => '(0+[1-9]{1}|1+[1-2]{1})', 2 => '(0+[1-9]{1}|1+[0-9]{1}|2+[0-9]{1}|3+[0-1]{1})', 3 => '(19+[0-9]{2}|20+[0-9]{2})' ); $seperator = ( $tf[1] == chr ( 47 ) || $tf[1] == chr ( 46 ) ? chr ( 92 ) . $tf[1] : $tf[1] ); $vt = '^' . $time[$tf[0]] . $seperator . $time[$tf[2]] . $seperator . $time[$tf[4]] . '+$'; $out = array (); $ref = 0; if ( empty ( $start ) ) { $erro += 1; } if ( empty ( $end ) ) { $erro += 2; } if ( empty ( $erro ) ) { $ref = 1; if ( !preg_match ( "/" . $vt . "/", $start ) ) { $erro += 1; } if ( !preg_match ( "/" . $vt . "/", $end ) ) { $erro += 2; } if ( empty ( $erro ) ) { $ref = 2; $daa = explode ( $tf[1], $start ); $dab = explode ( $tf[1], $end ); for ( $i = 0; $i <= 2; $i++ ) { if ( $tf[$x] == 1 ) { $rma = $daa[$i]; $rmb = $dab[$i]; } else if ( $tf[$x] == 2 ) { $rda = $daa[$i]; $rdb = $dab[$i]; } else if ( $tf[$x] == 3 ) { $rya = $daa[$i]; $ryb = $dab[$i]; } $x += 2; } $sday = @gmmktime ( 0, 0, 0, $rma, $rda, $rya ); $eday = @gmmktime ( 0, 0, 0, $rmb, $rdb, $ryb ); if ( $sday < 0 ) { $erro += 1; } if ( $eday < 0 ) { $erro += 2; } if ( empty ( $erro ) ) { $ref = 3; $eday += 86400; $st = substr ( $ut, 0, 1 ); if ( $st != '0' ) { $st = ( $st == '-' ? '+' : '-' ) . substr ( $ut, 1 ); } $sday = ( $sday + ( 3600 * $st ) ); $eday = ( $eday + ( 3600 * $st ) ); if ( $sday > $eday ) { $erro += 1; } else if ( ( gmmktime ( 0, 0, 0, date ( 'n' ), date ( 'j' ), date ( 'Y' ) ) + ( 3600 * $st ) ) < $sday ) { $erro += 2; } if ( empty ( $erro ) ) { $out[] = true; $out[] = 'post.dateline >= ' . $sday . ' AND post.dateline <= ' . $eday; return ( $out ); } } } } $out[] = false; $out[] = $errors[$ref][$erro]; return ( $out ); } ?> ALL DONE with 'search.php'.... Save changes close 'search.php' Now copy this script and place it in the vB install directory! Then run it from your browser! http://www.site.com/install.php After delete this script! Code:
<?php // install the admin panel, and language phrases! include_once ( './includes/config.php' ); function add_mod_search ( $db_sys, $name, $pass, $dbn, $tab ) { $insert = array ( "setting VALUES ('searchdateformat', 'datetime', '1/2/3', '1/2/3', '', 90, 0, 1);", "adminhelp VALUES ('', 'options', 'options', 'searchdateformat', 316, 1);", "phrase VALUES ('', -1, 'setting_searchdateformat_desc', 'The date format allowed to be entered in the advance search form...<br /><br /><strong>1</strong> = Month<br /><strong>2</strong> = Day<br /><strong>3</strong> = Year<br /><br >The (Month, Day, Year) separator can be one of the following.<br /><br /><strong>comma</strong> = <strong>1,2,3</strong><br /><strong>period</strong> = <strong>1.2.3</strong><br /><strong>hyphen</strong> = <strong>1-2-3</strong><br /><strong>forward slash</strong> = <strong>1/2/3</strong>', 5000);", "phrase VALUES ('', -1, 'setting_searchdateformat_title', 'Advance Search (Date Range Format)', 5000);", "phrase VALUES ('', -1, 'options_options_searchdateformat_text', 'This is the format of dates allowed to be entered in the <strong>Advance Search</strong> (Date Range) option. This allows for members to refine their search results. This also uses each members timezone setting, so that the search only returns exact dates matching each members time zone. If a guest or member is not in a active session and is using the advance search, then the configured board time will be used!', 6000);", "phrase VALUES ('', -1, 'options_options_searchdateformat_title', 'Advance Search (Date Range Format)', 6000);", "phrase VALUES ('', -1, 'date_format', '<strong>Date Format:</strong> ', 40);", "phrase VALUES ('', -1, 'find_date_one', 'Starting Date', 40);", "phrase VALUES ('', -1, 'find_date_two', 'Ending Date', 40);", "phrase VALUES ('', -1, 'find_opt_one', 'Find posts by a predefined selected option!', 40);", "phrase VALUES ('', -1, 'find_opt_two', 'Find posts by a specific inputted date range!', 40);", "phrase VALUES ('', 1, 'date_format', '<strong>Date Format:</strong> ', 40);", "phrase VALUES ('', 1, 'find_date_one', 'Starting Date', 40);", "phrase VALUES ('', 1, 'find_date_two', 'Ending Date', 40);", "phrase VALUES ('', 1, 'find_opt_one', 'Find posts by a predefined selected option!', 40);", "phrase VALUES ('', 1, 'find_opt_two', 'Find posts by a specific inputted date range!', 40);", "phrase VALUES ('', -1, 'srmissing', 'The <strong>Starting Date Range</strong> was not entered, use your browser back button to add a starting date or change the <strong>Find Threads</strong> option to not use a date range.', 1000);", "phrase VALUES ('', -1, 'ermissing', 'The <strong>Ending Date Range</strong> was not entered, use your browser back button to add a starting date or change the <strong>Find Threads</strong> option to not use a date range.', 1000);", "phrase VALUES ('', -1, 'brmissing', 'Both the <strong>Starting</strong> and <strong>Ending</strong> date range were not entered, use your browser back button to add both starting and ending dates or change the <strong>Find Threads</strong> option to not use a date range.', 1000);", "phrase VALUES ('', -1, 'srinvalid', 'The <strong>Starting Date Range</strong> entered was invalid, use your browser back button to correct the starting date range...', 1000);", "phrase VALUES ('', -1, 'erinvalid', 'The <strong>Ending Date Range</strong> entered was invalid, use your browser back button to correct the ending date range...', 1000);", "phrase VALUES ('', -1, 'brinvalid', 'Both the <strong>Starting</strong> and <strong>Ending</strong> date range you entered were invalid, use your browser back button to correct the starting and ending date ranges...', 1000);", "phrase VALUES ('', -1, 'srwindows', 'The <strong>Starting Date Range</strong> entered is out of range, Valid dates are from the creation of ths forum to the present day, please correct the starting date and then try your search again.', 1000);", "phrase VALUES ('', -1, 'erwindows', 'The <strong>Ending Date Range</strong> entered is out of range, Valid dates are from the creation time of ths forum to the present day, please correct the ending date and then try your search again.', 1000);", "phrase VALUES ('', -1, 'brwindows', 'Both the <strong>Starting</strong> and <strong>Ending</strong> date range entered are out of range, Valid dates are from the creation time of ths forum to the present day, please correct the starting and ending dates and then try your search again.', 1000);", "phrase VALUES ('', -1, 'sraftered', 'The <strong>Starting Date Range</strong> entered is after the <strong>Ending Date Range</strong>, the starting date must be a date that is before the ending date. Please correct the starting or ending date range, then try you request again', 1000);", "phrase VALUES ('', -1, 'srgreater', 'The <strong>Starting Date Range</strong> entered is greater than today! The date range can be any date up until today! Please correct the starting date range, then try you request again', 1000);" ); $con = mysql_connect ( $db_sys, $name, $pass ) or die ( mysql_error () ); mysql_select_db ( $dbn, $con ) or die ( mysql_error () ); for ( $z = 0; $z < sizeof ( $insert ); $z++ ) { $sql = "INSERT INTO " . $tab . $insert[$z]; mysql_query ( $sql ) or die ( mysql_error () ); } $sql = "SELECT data FROM " . $tab . "datastore WHERE title = 'options'"; $rq = mysql_query ( $sql ) or die ( mysql_error () ); $row = mysql_fetch_assoc ( $rq ); $temp = unserialize ( $row['data'] ); $temp['searchdateformat'] = '1/2/3'; $sql = "UPDATE " . $tab . "datastore SET data = '" . addslashes ( serialize ( $temp ) ) . "' WHERE title = 'options'"; mysql_query ( $sql ) or die ( mysql_error () ); $sql = "SELECT phrasegroup_search FROM " . $tab . "language WHERE languageid = '1'"; $rq = mysql_query ( $sql ) or die ( mysql_error () ); $row = mysql_fetch_assoc ( $rq ); $temp = unserialize ( $row['phrasegroup_search'] ); $temp['date_format'] = '<strong>Date Format:</strong> '; $temp['find_date_one'] = 'Starting Date'; $temp['find_date_two'] = 'Ending Date'; $temp['find_opt_one'] = 'Find posts by a predefined selected option!'; $temp['find_opt_two'] = 'Find posts by a specific inputted date range!'; $sql = "UPDATE " . $tab . "language SET phrasegroup_search = '" . addslashes ( serialize ( $temp ) ) . "' WHERE languageid = '1'"; mysql_query ( $sql ) or die ( mysql_error () ); echo 'ALL DONE, delete this file now!'; } add_mod_search ( $servername, $dbusername, $dbpassword, $dbname, $tableprefix ); ?> After the install is done, you will find the Advance Search Control in the Admin Panel! vBulletin Options >> Date and Time Options >> at the bottom! You now have the 'Advanced Search By Date Range', installed on your forum! C, ya... Sonia Show Your Support
|
Comments |
#2
|
||||
|
||||
I tried running this in my root directory and got this:
"MODIFICATION REPORT INSTALL ERROR: can not READ OR WRITE to ./search.php install has failed The above is the result of your last action, if any error is found, please report to me on the forum!" I know you mentioned that in your instructions, but how would I go about changing the permissions of the install file? Instead of an automatic install file, it would be more helpful to me to have it go through the steps like other install hacks have done. |
#3
|
|||
|
|||
@fridayweb... just chmod the search.php file to 777...
btw, this installer is a real pain dear Sonya... this would be more efficient to have a text documentation with the steps of changes... because it's not working... if we even had a luck to hack our search.php file, the hack simply scrap everything, and this is not a big deal! i'll try to recover the bug... EDIT: found the problem here... when the new function was added in search.php, the installed deleted the last " } " on my file, so this messed out the entire file! |
#4
|
|||
|
|||
Hi
Could you send me the search file after doing the install, when you get the error! I think it because, I do a -2 on the last change, I am going to my Unix server to test this now! Send to fataqui@ya-right.com I will also post a step by step in a few minutes! Fo those that want to do it by hand! I just ran the install and uninstall on 7 different servers, 2 Unix, 3 Linux, 2 windows, and I don't get any errors running the install or uninstall! Let me finish writing the step by step version! C, ya... Sonia |
#5
|
|||
|
|||
Hi Sonya... it would be useless to send you my serach.php, as the problem is the EOF... mine was edited before!... that's all
good work though! |
#6
|
||||
|
||||
Thanks for the step by step! I was able to get everything done except when it came to the very last part and the new install.php.
This is the error I got: "Column count doesn't match value count at row 1" Any suggestions? |
#7
|
|||
|
|||
Ok, maybe I'm missing something here...
I imported the xml per the instructions. I've installed using the installer per the instructions. The search.php shows the new options. The admincp does not show the admin menu for this mod. And if I try to search by date it will not allow it as no text was entered into the search field. (default vb option) Amy I missing something on the install? Am I missing the point of the mod altogether? I thought this mod will allow users to simply search by date and not have to enter any search "text" in. This is the functionality that we need. Thoughts? |
#8
|
|||
|
|||
Nevermind! I found a better one that does what I need it to and I only have to edit 1 line of code...
https://vborg.vbsupport.ru/showthrea...ht=search+date |
#9
|
|||
|
|||
This should be built into VB. Don't know why it's not.
However, got this error on install: Code:
INSTALL ERROR: can not find replace search pattern(s) -> 3, install has failed Edit: Found the source of the problem. I'm using VB 3.03, patched up to 3.07. This line: Quote:
The code is entirely different. |
#10
|
|||
|
|||
Hello,
You have an error in your time array: Code:
'(0+[1-9]{1}|1+[1-2]{1})' The correct code should be: Code:
'(0+[1-9]{1}|1+[0-2]{1})' Thanks, Ronald |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|