4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started 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:include(ROOT_PATH.'includes/search_utils.php');
Add after:$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: $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: $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: $site_template->register_vars(array(
"search_keywords" => htmlspecialchars(stripslashes($org_search_keywords)),
Replace with: 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: <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 ?>$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
-
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?
-
what were u searching?
-
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
-
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)
-
My error msg........
Fatal error: Call to undefined function: date_select() in /var/www/phpbb/4images/search.php on line 372
:(
-
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
-
omg :oops: how did I miss that??? :?
I just changed Step1.3.
-
Thank!! ^_^
-
omg :oops: how did I miss that??? :?
I just changed Step1.3.
:P thanx ...like ever.. good job...
-
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
-
ah, yes, u are right :ops:
I just fixed it.
-
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
-
yes, u are right, replace:
AND m.word_id = w.word_id AND i.image_date > UNIX_TIMESTAMP('".$date_start."') AND i.image_date < UNIX_TIMESTAMP('".$date_end."')
with:AND m.word_id = w.word_id AND i.image_date >= UNIX_TIMESTAMP('".$date_start."') AND i.image_date <= UNIX_TIMESTAMP('".$date_end."')
-
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:
$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
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
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: AND i.image_date <= UNIX_TIMESTAMP
maybe you posted it wrong
maybe :)
-
opsy...yes, my bad, was changing it in the browser...
-
v@no -
is the code now corrected to be used by all ??? :D
- bruce
-
im sorry v@no, but this thing really doesn't show the photos of the current day, here's my search.php modified parts:
$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;
$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";
$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
-
ok, I got it now ;)
*thx to Jan helped trace this little ...*
in Step 1.
replace $date_start = $year_start."-".$month_start."-".$day_start;
$date_end = $year_end."-".$month_end."-".$day_end;
with:$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: $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.
-
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
-
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
-
sorry, there is nothing about IPTC...
its about date added to the gallery.
-
What about search logic with this MOD? When searching by keywords time interval limit my search, but when searching by user name - not...
-
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
-
in step 1.2 below the code u've replace add this line:
echo $sql;
then go and search something, it should show u the query it used on top of the screen. quote it here please.
-
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?
-
there is minimum keyword lenght filter.
anyway, this what I got when searched for "rescue":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?
-
hy,
is it possible to adapt the mod for top images?
top.php&month=may for example
:)
ps: sorry for my bad english...
-
ok, thx for the code - i ge it alone :)
http://www.hobby-fotografen.at/top.php?
and it works :) :) :) :!:
-
hi V@no,
... thanks for this helpful MOD .... :D
mawenzi
-
yes, u are right, replace:AND m.word_id = w.word_id AND i.image_date > UNIX_TIMESTAMP('".$date_start."') AND i.image_date < UNIX_TIMESTAMP('".$date_end."')
with: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.
-
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)
-
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.
-
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 :(
-
great mod
thank you
-
hm... how work search.... i uderstand logiсk of serch... please tell me about search logick (если по русски будет вообще чудесно.)
-
hm... how work search.... i uderstand logiсk of serch... please tell me about search logick (если по русски будет вообще чудесно.)
Не понял вопроса...
-
Не понял вопроса...
plz see PM...
-
Easy al always :D
great mod :lol:
thanks 8)
-
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
-
странно, но в 1.7.2, если искать фотки допустим за месяц, то в результате выдаются все (за всё время существования галереи) фотки... может я чего-то не так делаю.... надеюсь на помощь.
Спасибо
-
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:
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'],
"search_keywords" => format_text(stripslashes($org_search_keywords), 2),
this line is different than your line
"search_keywords" => htmlspecialchars(stripslashes($org_search_keywords)),
please i need to search with * could you help me?
-
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
-
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.