4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: V@no on June 10, 2003, 08:54:50 PM

Title: [MOD] Search between specifyed date
Post by: V@no on June 10, 2003, 08:54:50 PM
Reqested several times mod, that will let visitors search between date they select. (uses dropdown options for day, month, year)


-------- Files to edit ------------
/search.php
/templates/<yourtemplate>/search_form.html
/lang/<yourlanguage>/main.php



-------- Installation -------------

Step 1.
Open /search.php
Find:
Code: [Select]
include(ROOT_PATH.'includes/search_utils.php');Add after:
Code: [Select]
$year_default = 2000;
$year_now = date("Y", time());
$year_start = (isset($HTTP_POST_VARS['year_start']) ) ? intval($HTTP_POST_VARS['year_start']) : ((isset($HTTP_GET_VARS['year_start'])) ? intval($HTTP_GET_VARS['year_start']) : $year_default);
$year_end = (isset($HTTP_POST_VARS['year_end']) ) ? intval($HTTP_POST_VARS['year_end']) : ((isset($HTTP_GET_VARS['year_end'])) ? intval($HTTP_GET_VARS['year_end']) : $year_now);
$month_start = (isset($HTTP_POST_VARS['month_start']) ) ? intval($HTTP_POST_VARS['month_start']) : ((isset($HTTP_GET_VARS['month_start'])) ? intval($HTTP_GET_VARS['month_start']) : 1);
$month_end = (isset($HTTP_POST_VARS['month_end']) ) ? intval($HTTP_POST_VARS['month_end']) : ((isset($HTTP_GET_VARS['month_end'])) ? intval($HTTP_GET_VARS['month_end']) : date("n", time()));
$day_start = (isset($HTTP_POST_VARS['day_start']) ) ? intval($HTTP_POST_VARS['day_start']) : ((isset($HTTP_GET_VARS['day_start'])) ? intval($HTTP_GET_VARS['day_start']) : 1);
$day_end = (isset($HTTP_POST_VARS['day_end']) ) ? intval($HTTP_POST_VARS['day_end']) : ((isset($HTTP_GET_VARS['day_end'])) ? intval($HTTP_GET_VARS['day_end']) : date("j", time()));
$date_start = mktime(0,0,0,$month_start,$day_start,$year_start);
$date_end = mktime(23,59,59,$month_end,$day_end,$year_end);

Step 1.2.
Find:
Code: [Select]
     $sql = "SELECT m.image_id
              FROM ".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m
              WHERE w.word_text LIKE '".addslashes(str_replace("*", "%", $split_words[$i]))."'
              AND m.word_id = w.word_id
              $match_field_sql";
Replace with:
Code: [Select]
     $sql = "SELECT m.image_id, i.image_date
              FROM ".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m
              LEFT JOIN ".IMAGES_TABLE." i ON (m.image_id = i.image_id)
              WHERE w.word_text LIKE '".addslashes(str_replace("*", "%", $split_words[$i]))."'
              AND m.word_id = w.word_id AND i.image_date >= ".$date_start." AND i.image_date <= ".$date_end."
              $match_field_sql";

Step 1.3.
Find:
Code: [Select]
 $site_template->register_vars(array(
    "search_keywords" => htmlspecialchars(stripslashes($org_search_keywords)),
Replace with:
Code: [Select]
 function date_select($start, $end, $now, $text_array = ""){
    $options = "";
    $start = ($start) ? $start : $start + 1;
    for ($i = $start; $i <= $end; $i++){
      $select = ($i == $now) ? " selected" : "";
      $options .= "<option value=\"".$i."\"".$select.">".(($text_array) ? $text_array[$i - 1] : $i)."</option>";
    }
    return $options;
  }

  $site_template->register_vars(array(
    "search_keywords" => stripslashes($org_search_keywords),
    "year_start" => date_select($year_default, $year_now, $year_start),
    "year_end" => date_select($year_default, $year_now, $year_end),
    "month_start" => date_select(1, 12, $month_start, $lang['month_array']),
    "month_end" => date_select(1, 12, $month_end, $lang['month_array']),
    "day_start" => date_select(1, 31, $day_start),
    "day_end" => date_select(1, 31, $day_end),
    "lang_search_date" => $lang['search_date'],
    "lang_search_date_start" => $lang['search_start'],
    "lang_search_date_end" => $lang['search_end'],


Step 2.
Open /templates/<yourtemplate>/search_form.html
Add this:
Code: [Select]
<tr class="row2">
<td><b>{lang_search_date}:</b></td>
<td>
{lang_search_date_start}<br />
<select name="day_start" class="select">{day_start}</select>
<select name="month_start" class="select">{month_start}</select>
<select name="year_start" class="select">{year_start}</select><br /><br />
{lang_search_date_end}<br />
<select name="day_end" class="select">{day_end}</select>
<select name="month_end" class="select">{month_end}</select>
<select name="year_end" class="select">{year_end}</select>
</td>
</tr>


Step 3.
Open /lang/<yourlanguage>/main.php
Add at the end, just before closing ?>
Code: [Select]
$lang['month_array'] = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$lang['search_date'] = "Search between";
$lang['search_start'] = "Start";
$lang['search_end'] = "End";


NOTE:
- If u dont want display name for each month instead of number (1 to 12), then just comment $lang['month_array'] in Step 3.
- U can change minimum year in dropdown: $year_default = 2000; from Step 1.

P.S. I know, design and text - sux, and would really appretiate it if somebody help me with that ;) :D
Title: [MOD] Search between specifyed date
Post by: Bomba on June 10, 2003, 09:37:15 PM
hey v@no this is awesome :)
just what i needed

but i think there's some prob on it cause i went to your demo and tryed to do a search and no results were found, and i've tried many dates

is it me?
Title: [MOD] Search between specifyed date
Post by: V@no on June 10, 2003, 09:38:21 PM
what were u searching?
Title: [MOD] Search between specifyed date
Post by: Bomba on June 10, 2003, 11:12:41 PM
well i wanted to see all images that were submitted in a specified period of time, isn't that what this can do? or does this only search all images with specified keywords in the mentioned period?

if so, how can i put this working like the 1st way?
thanks
Title: [MOD] Search between specifyed date
Post by: V@no on June 10, 2003, 11:19:33 PM
Quote from: Bomba
well i wanted to see all images that were submitted in a specified period of time, isn't that what this can do? or does this only search all images with specified keywords in the mentioned period?

if so, how can i put this working like the 1st way?
thanks
maybe I should have name it as "limit images by date" or something...
yes, it will search from keywords, but limit it by date.
use * to search all images (add as many * as set max keyword lenght)
Title: [MOD] Search between specifyed date
Post by: reson on June 16, 2003, 08:19:56 PM
My error msg........

Fatal error: Call to undefined function: date_select() in /var/www/phpbb/4images/search.php on line 372


 :(
Title: [MOD] Search between specifyed date
Post by: heiko on June 16, 2003, 09:48:46 PM
Quote from: reson
My error msg........

Fatal error: Call to undefined function: date_select() in /var/www/phpbb/4images/search.php on line 372


 :(




Hi V@no...


Where is this function defined :?:

date_select()  


Greetings

Heiko
Title: [MOD] Search between specifyed date
Post by: V@no on June 16, 2003, 09:56:59 PM
omg  :oops: how did I miss that??? :?
I just changed Step1.3.
Title: [MOD] Search between specifyed date
Post by: reson on June 17, 2003, 10:17:20 AM
Thank!! ^_^
Title: Now it works.!!
Post by: heiko on June 17, 2003, 07:39:18 PM
Quote from: V@no
omg  :oops: how did I miss that??? :?
I just changed Step1.3.


 :P  thanx ...like ever.. good job...
Title: [MOD] Search between specifyed date
Post by: bgmurphy on June 18, 2003, 06:48:19 PM
v@no -

i have an original .... /search.php ...  file ...
when i do a search and replace for coding in steps 1.2/1.3 - it does not find the references  :roll:

where does the coding live??  8O

thanx
bruce
Title: [MOD] Search between specifyed date
Post by: V@no on June 18, 2003, 07:27:42 PM
ah, yes, u are right :ops:
I just fixed it.
Title: [MOD] Search between specifyed date
Post by: Bomba on June 27, 2003, 02:29:14 AM
i think i've found some kind of bug in the mod...

i installed it on my site today, and now, that is counting as 27 of June, when i search for all my images on the server (***), it doesn't appear the pics that were submitted after the 0am of June 27.

why's that, why doesn't search images that were submitted on the present day?
they all have words with more than 3 letters...
i don't understand it
Title: [MOD] Search between specifyed date
Post by: V@no on June 27, 2003, 11:56:00 AM
yes, u are right, replace:
Code: [Select]
AND m.word_id = w.word_id AND i.image_date > UNIX_TIMESTAMP('".$date_start."') AND i.image_date < UNIX_TIMESTAMP('".$date_end."')with:
Code: [Select]
AND m.word_id = w.word_id AND i.image_date >= UNIX_TIMESTAMP('".$date_start."') AND i.image_date <= UNIX_TIMESTAMP('".$date_end."')
Title: [MOD] Search between specifyed date
Post by: Bomba on June 27, 2003, 05:37:02 PM
hey v@no, are u sure that that's correct?
cause i replaced my code and everything works the same way as before...

here's my changed code:
Code: [Select]
$sql = "SELECT m.image_id, i.image_date
              FROM ".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m
              LEFT JOIN ".IMAGES_TABLE." i ON (m.image_id = i.image_id)
              WHERE w.word_text LIKE '".addslashes(str_replace("*", "%", $split_words[$i]))."'
              AND m.word_id = w.word_id AND i.image_date >= UNIX_TIMESTAMP('".$date_start."') AND i.image_date < UNIX_TIMESTAMP('".$date_end."')
              $match_field_sql";



edit:

i just noticed that no your step 1.2 it's
Code: [Select]
AND m.word_id = w.word_id AND i.image_date > UNIX_TIMESTAMP('".$date_start."') AND i.image_date < UNIX_TIMESTAMP('".$date_end."')

and now the changed code says that i have to replace this
Code: [Select]
AND m.word_id = w.word_id AND i.image_date > UNIX_TIMESTAMP('".$date_start."') AND i.image_date <= UNIX_TIMESTAMP('".$date_end."')

but as you can see, these codes are not the same just look at this part:
Code: [Select]
AND i.image_date <= UNIX_TIMESTAMP

maybe you posted it wrong
maybe :)
Title: [MOD] Search between specifyed date
Post by: V@no on June 28, 2003, 04:03:43 AM
opsy...yes, my bad, was changing it in the browser...
Title: [MOD] Search between specifyed date
Post by: bgmurphy on June 28, 2003, 04:11:48 AM
v@no -

is the code now corrected to be used by all ???  :D

- bruce
Title: [MOD] Search between specifyed date
Post by: Bomba on June 28, 2003, 05:01:30 AM
im sorry v@no, but this thing really doesn't show the photos of the current day, here's my search.php modified parts:


Code: [Select]
$year_default = 2003;
$year_now = date("Y", time());
$year_start = (isset($HTTP_POST_VARS['year_start']) ) ? intval($HTTP_POST_VARS['year_start']) : ((isset($HTTP_GET_VARS['year_start'])) ? intval($HTTP_GET_VARS['year_start']) : $year_default);
$year_end = (isset($HTTP_POST_VARS['year_end']) ) ? intval($HTTP_POST_VARS['year_end']) : ((isset($HTTP_GET_VARS['year_end'])) ? intval($HTTP_GET_VARS['year_end']) : $year_now);
$month_start = (isset($HTTP_POST_VARS['month_start']) ) ? intval($HTTP_POST_VARS['month_start']) : ((isset($HTTP_GET_VARS['month_start'])) ? intval($HTTP_GET_VARS['month_start']) : 1);
$month_end = (isset($HTTP_POST_VARS['month_end']) ) ? intval($HTTP_POST_VARS['month_end']) : ((isset($HTTP_GET_VARS['month_end'])) ? intval($HTTP_GET_VARS['month_end']) : date("n", time()));
$day_start = (isset($HTTP_POST_VARS['day_start']) ) ? intval($HTTP_POST_VARS['day_start']) : ((isset($HTTP_GET_VARS['day_start'])) ? intval($HTTP_GET_VARS['day_start']) : 1);
$day_end = (isset($HTTP_POST_VARS['day_end']) ) ? intval($HTTP_POST_VARS['day_end']) : ((isset($HTTP_GET_VARS['day_end'])) ? intval($HTTP_GET_VARS['day_end']) : date("j", time()));
$date_start = $year_start."-".$month_start."-".$day_start;
$date_end = $year_end."-".$month_end."-".$day_end;


Code: [Select]
$sql = "SELECT m.image_id, i.image_date
              FROM ".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m
              LEFT JOIN ".IMAGES_TABLE." i ON (m.image_id = i.image_id)
              WHERE w.word_text LIKE '".addslashes(str_replace("*", "%", $split_words[$i]))."'
              AND m.word_id = w.word_id AND i.image_date >= UNIX_TIMESTAMP('".$date_start."') AND i.image_date <= UNIX_TIMESTAMP('".$date_end."')
              $match_field_sql";


Code: [Select]
$site_template->register_vars(array(
    "search_keywords" => stripslashes($org_search_keywords),
    "year_start" => date_select($year_default, $year_now, $year_start),
    "year_end" => date_select($year_default, $year_now, $year_end),
    "month_start" => date_select(1, 12, $month_start, $lang['month_array']),
    "month_end" => date_select(1, 12, $month_end, $lang['month_array']),
    "day_start" => date_select(1, 31, $day_start),
    "day_end" => date_select(1, 31, $day_end),
    "lang_search_date" => $lang['search_date'],
    "lang_search_date_start" => $lang['search_start'],
    "lang_search_date_end" => $lang['search_end'],


i've followed all the steps and maybe i've forgot to post here some changed part, but i think that this is it.
hope that you can help me on this :)

thanks mate
Title: [MOD] Search between specifyed date
Post by: V@no on June 28, 2003, 03:13:35 PM
ok, I got it now ;)
*thx to Jan helped trace this little ...*

in Step 1.
replace
Code: [Select]
$date_start = $year_start."-".$month_start."-".$day_start;
$date_end = $year_end."-".$month_end."-".$day_end;

with:
Code: [Select]
$date_start = mktime(0,0,0,$month_start,$day_start,$year_start);
$date_end = mktime(23,59,59,$month_end,$day_end,$year_end);

then, Step 1.2 replace:
Code: [Select]
     $sql = "SELECT m.image_id, i.image_date
              FROM ".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m
              LEFT JOIN ".IMAGES_TABLE." i ON (m.image_id = i.image_id)
              WHERE i.image_date >= ".$date_start." AND i.image_date <= ".$date_end." AND w.word_text LIKE '".addslashes(str_replace("*", "%", $split_words[$i]))."'
              AND m.word_id = w.word_id
              $match_field_sql";


P.S. original code was updated.
Title: [MOD] Search between specifyed date
Post by: bgmurphy on June 28, 2003, 04:52:35 PM
thanx V@no / Jan !!

this appears to be why i had problems finding fotos that i loaded on the current day ... at the stroke of midnite .. they would magically appear in the search ....

well no pumpkins heres now

cheers
bruce
Title: Re: [MOD] Search between specifyed date
Post by: Vincent on March 11, 2005, 09:02:09 AM
search between specifig date!
which date - date of upload of the picture or date from the IPTC Info?
(http://www.foto-kocher.com/muster/1.jpg)

sincerly
vincent
Title: Re: [MOD] Search between specifyed date
Post by: V@no on March 12, 2005, 01:38:03 AM
sorry, there is nothing about IPTC...
its about date added to the gallery.
Title: Re: [MOD] Search between specifyed date
Post by: vanish on March 16, 2005, 03:33:57 PM
What about search logic with this MOD? When searching by keywords time interval limit my search, but when searching by user name - not...
Title: Re: [MOD] Search between specifyed date
Post by: RuthE on July 02, 2005, 02:21:49 PM
I know this is an older mod, but I really am wanting to get it working. I must have made an error somewhere, because the date searches just don't work. It doesn't return anything regardless of what dates I search. I searched whole years and found nothing, even though I know that's not the case. Maybe someone can help me out ... no clue what i did wrong.

http://www.discoverkate.com/gallery/search.php
Title: Re: [MOD] Search between specifyed date
Post by: V@no on July 02, 2005, 04:06:44 PM
in step 1.2 below the code u've replace add this line:
Code: [Select]
echo $sql;then go and search something, it should show u the query it used on top of the screen. quote it here please.
Title: Re: [MOD] Search between specifyed date
Post by: RuthE on July 02, 2005, 04:19:13 PM
I wish I had something to quote to you, it appears that it's not searching at all. It comes back with no results regardless of what I enter it seems. Maybe I don't understand how to do the search. I am putting a star in, because I really just want it to show me what was added on certain dates. Is that correct?
Title: Re: [MOD] Search between specifyed date
Post by: V@no on July 02, 2005, 04:42:36 PM
there is minimum keyword lenght filter.

anyway, this what I got when searched for "rescue":
Quote
SELECT m.image_id, i.image_date FROM 4images_wordlist w, 4images_wordmatch m LEFT JOIN 4images_images i ON (m.image_id = i.image_id) WHERE w.word_text LIKE 'rescue' AND m.word_id = w.word_id AND i.image_date >= UNIX_TIMESTAMP('946713600') AND i.image_date <= UNIX_TIMESTAMP('1120373999')


I've highlighted the parts that are not supposed to be there, there is no such in the mod's code. are u sure u didnt do something else to it?
Title: Re: [MOD] Search between specifyed date
Post by: dosensteck on July 02, 2005, 04:44:45 PM
hy,

is it possible to adapt the mod for  top images?

top.php&month=may for example

:)

ps: sorry for my bad english...
Title: Re: [MOD] Search between specifyed date
Post by: dosensteck on July 04, 2005, 10:45:53 PM
ok, thx for the code - i ge it alone :)



http://www.hobby-fotografen.at/top.php?


and it works  :) :) :)  :!:
Title: Re: [MOD] Search between specifyed date
Post by: mawenzi on July 05, 2005, 01:39:32 PM
hi V@no,

... thanks for this helpful MOD ....  :D

mawenzi
Title: Re: [MOD] Search between specifyed date
Post by: RuthE on July 06, 2005, 04:30:59 PM
yes, u are right, replace:
Code: [Select]
AND m.word_id = w.word_id AND i.image_date > UNIX_TIMESTAMP('".$date_start."') AND i.image_date < UNIX_TIMESTAMP('".$date_end."')with:
Code: [Select]
AND m.word_id = w.word_id AND i.image_date >= UNIX_TIMESTAMP('".$date_start."') AND i.image_date <= UNIX_TIMESTAMP('".$date_end."')

I think this is where I got the code that seems to be wrong.
Title: Re: [MOD] Search between specifyed date
Post by: V@no on July 06, 2005, 11:58:40 PM
there is no such thing in the original code, it possible was before, but I guess I've updated it with a different approach and u should not change anything in the original code unless u have a problem (thats actualy applyed to anything u do)
Title: Re: [MOD] Search between specifyed date
Post by: RuthE on July 12, 2005, 08:32:25 PM
I feel like an idiot, well, sort of. I was hoping this mod would allow users to see all images added between certain dates, but it doesn't seem to work without a search phrase. Is there a way to make it work without anying in the search box?

Kind of like the edit images works in the admin panel, which simply searches by whichever field (or fields) is filled.
Title: Re: [MOD] Search between specifyed date
Post by: dosensteck on July 19, 2005, 08:51:24 PM
i  try to edit the search form now past 2 days...  i dont get it :(

what i want are buttons for the months. push on the button march search images from 1st march to 31th march. i hope anyone can help me with this? :)

ps: sorry for my bad english  :(

Title: Re: [MOD] Search between specifyed date
Post by: Bear on October 01, 2005, 08:17:18 PM
great mod
thank you
Title: Re: [MOD] Search between specifyed date
Post by: venator on October 30, 2005, 04:31:25 PM
hm... how work search.... i uderstand logiсk of serch... please tell me about search logick (если по русски будет вообще чудесно.)
Title: Re: [MOD] Search between specifyed date
Post by: V@no on October 30, 2005, 04:39:53 PM
hm... how work search.... i uderstand logiсk of serch... please tell me about search logick (если по русски будет вообще чудесно.)
Не понял вопроса...
Title: Re: [MOD] Search between specifyed date
Post by: venator on October 30, 2005, 04:57:34 PM
Quote
Не понял вопроса...
plz see PM...
Title: Re: [MOD] Search between specifyed date
Post by: wallpapers on March 10, 2006, 06:41:34 AM
Easy al always :D
great mod :lol:
thanks 8)
Title: Re: [MOD] Search between specifyed date
Post by: Zyga on May 09, 2006, 11:47:26 PM
I feel like an idiot, well, sort of. I was hoping this mod would allow users to see all images added between certain dates, but it doesn't seem to work without a search phrase. Is there a way to make it work without anying in the search box?

Kind of like the edit images works in the admin panel, which simply searches by whichever field (or fields) is filled.

good sollution could be something like "show all" check box
just select date click on checkbox and....
U see all images added between yyyy-mm-dd and yyyy-mm-dd
Title: Re: [MOD] Search between specifyed date
Post by: awf on July 28, 2006, 10:49:53 PM
странно, но в 1.7.2, если искать фотки допустим за месяц, то в результате выдаются все (за всё время существования галереи) фотки... может я чего-то не так делаю.... надеюсь на помощь.
Спасибо
Title: Re: [MOD] Search between specifyed date
Post by: ccsakuweb on September 28, 2006, 05:21:28 PM
hi! i installed this mod in my gallery 1.7.3 i had to modified some code from search.php because is different than your search version. This mod works correctly but now the comodin * doesn't works then i can't see all images from a day, i need to know some keyword from the images

And there is a change in 1.7.3 version, My code with this mod is:

Code: [Select]
function date_select($start, $end, $now, $text_array = ""){
   $options = "";
   $start = ($start) ? $start : $start + 1;
   for ($i = $start; $i <= $end; $i++){
     $select = ($i == $now) ? " selected" : "";
     $options .= "<option value=\"".$i."\"".$select.">".(($text_array) ? $text_array[$i - 1] : $i)."</option>";
   }
   return $options;
 }

 $site_template->register_vars(array(
   "search_keywords" => format_text(stripslashes($org_search_keywords), 2),
   "year_start" => date_select($year_default, $year_now, $year_start),
   "year_end" => date_select($year_default, $year_now, $year_end),
   "month_start" => date_select(1, 12, $month_start, $lang['month_array']),
   "month_end" => date_select(1, 12, $month_end, $lang['month_array']),
   "day_start" => date_select(1, 31, $day_start),
   "day_end" => date_select(1, 31, $day_end),
   "lang_search_date" => $lang['search_date'],
   "lang_search_date_start" => $lang['search_start'],
   "lang_search_date_end" => $lang['search_end'],   
    "search_user" => format_text(stripslashes($org_search_user), 2),
    "lang_search_by_keyword" => $lang['search_by_keyword'],
    "lang_search_by_username" => $lang['search_by_username'],
    "lang_new_images_only" => $lang['new_images_only'],
    "lang_search_terms" => $lang['search_terms'],
    "lang_or" => $lang['or'],
    "lang_and" => $lang['and'],

Code: [Select]
   "search_keywords" => format_text(stripslashes($org_search_keywords), 2), this line is different than your line
Code: [Select]
   "search_keywords" => htmlspecialchars(stripslashes($org_search_keywords)),
please i need to search with * could you help me?
Title: Re: [MOD] Search between specifyed date
Post by: dplmartin on December 05, 2008, 10:23:28 AM
Did anyone ever figure out how this mod could be changed so that it does not require any keyword or just one * to show all images between set dates?

Dominic
Title: Re: [MOD] Search between specifyed date
Post by: Peter Lehner on March 10, 2019, 10:58:12 AM
Mit der Version 1.8 funktioniert die MOD für Datumsuche nicht, Basis hat sich zu stark verändert.

With the version 4images 1.8 does not work the MOD for the date search, the base code has changed too much.