4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Rembrandt on February 16, 2011, 06:37:48 PM

Title: [Mod] Search all images since (Date)
Post by: Rembrandt on February 16, 2011, 06:37:48 PM
Hi!

This Mod enabled it search all images since "date".

Files to be Modified:
1.) your Templates/search_form.html
2.) root/search.php
3.) lang/your lang/main.php

Optional: If user login, display how many new images since last visit
4.) includes/page_header.php
5.) lang/yourlang/main.php
6.) templates/your Templates/user_logininfo.html


1.) search in your templates/search_form.html
Code: [Select]
           <td colspan="2" valign="top" class="head1">{lang_search}</td>
          </tr>
insert below:
Code: [Select]
         <tr>
            <td valign="top" class="row1"><b>{lang_search_by_date}</b></td>
            <td class="row1" valign="top">
              <input type="text" name="search_date" size="40" value="{search_date}" class="input">
            </td>
          </tr>

2.)  search in root/search.php:

if ($search_keywords != "" && $show_result == 1) {

insert above:

//########################## Start Mod Search all images since (Date) ################################
if(isset($HTTP_POST_VARS['search_date']) || isset($HTTP_GET_VARS['search_date'])){
$search_date= (isset($HTTP_POST_VARS['search_date'])) ? trim($HTTP_POST_VARS['search_date']) : trim($HTTP_GET_VARS['search_date']);
$search_date = preg_replace("#[^-0-9:]#","-", $search_date);

  if(!empty($search_date)){
    $format = preg_replace("#[^a-zA-Z0-9]#","",$config['date_format']);

    $day = strpos($format, 'd');
    $month = strpos($format, 'm');
    $year = strpos($format, 'Y');

    $search_date = explode("-", $search_date);

    $hour =  0;
    $min =  0;
    if((array_key_exists('3', $search_date))){
      $search_time = explode(":", $search_date[3]);
      $hour = (isset($search_time[0]))? $search_time[0]:0;
      $min = (isset($search_time[1]))? $search_time[1]:0;
    }
    $search_id['search_date'] = "";
    if(@checkdate($search_date[$month],$search_date[$day],$search_date[$year]) ==  true){
      $search_id['search_date'] = @mktime($hour,$min, 0, $search_date[$month],$search_date[$day],$search_date[$year]);

      $show_result =1;
    }
    else{
      $search_date="";
    }
  }
}
else{
  $search_date="";
}
  $search_in = array();
  $search_in[0] = '/d/';
  $search_in[1] = '/m/';
  $search_in[2] = '/Y/';
  $search_in[3] = '/H/';
  $search_in[4] = '/i/';
  $search_out = array();
  $search_out[0] = 'dd';
  $search_out[1] = 'mm';
  $search_out[2] = 'YYYY';
  $search_out[3] = 'HH';
  $search_out[4] = 'ii';

  $date_format = preg_replace($search_in,$search_out,$config['date_format']);
  $time_format = preg_replace($search_in,$search_out,$config['time_format']);
  
  $site_template->register_vars("date_format", $date_format."&nbsp;&nbsp;".$time_format);
//########################## End Mod Search all images since (Date) ################################
2.1) search:

if (!empty($search_id )) {
  $site_sess->set_session_var("search_id", serialize($search_id));

insert above:

//############### Start Mod Search all images since (Date) #############
 if ($search_date && $show_result == 1) {
  $search_id['search_date'] = $search_id['search_date'];
}
//############### End Mod Search all images since (Date) ###############

2.2) search:

$sql_where_query = "";

insert below:

//################## End Mod Search all images since (Date) #################
if(!empty($search_id['search_date'])) {
    $sql_where_query .= "AND i.image_date >= ".$search_id['search_date']." ";
  }
//################## End Mod Search all images since (Date) #################

2.3) search:

else {
  $site_template->register_vars(array(

insert below:

//######### Start Mod Search all images since (Date) ##########
  "date_format" => $config['date_format'],
  "lang_search_by_date" => $lang['search_by_date'],
//######### End Mod Search all images since (Date) ##########


3.) search in lang/your lang/main.php

//--- Search ------------------------------------------
//-----------------------------------------------------

insert below:
(english)

//########################## Start Mod Search all images since (Date) ################################
$lang['search_by_date'] = "search all images since:<br><span class=\"smalltext\">(Format: <b>{date_format}</b>  ) time can be omitted</span>";
//########################## End Mod Search all images since (Date) ##################################

(deutsch)

//########################## Start Mod Search all images since (Date) ##############################
$lang['search_by_date'] = "Suche alle Bilder seit:<br><span class=\"smalltext\">(Format: <b>{date_format}</b>  ) Uhrzeit kann weggelassen werden.</span>";
//########################## End Mod Search all images since (Date) ################################



Optional: If user login, display how many new images since last visit.

4.) search in includes/page_header.php:

//-----------------------------------------------------
//--- User Box ----------------------------------------

insert above:

if ($user_info['user_level'] >= USER) {
  $sql = "SELECT COUNT(image_id) AS new_images
          FROM ".IMAGES_TABLE."
          WHERE image_active = 1 AND image_date >= ".$user_info['user_lastvisit']."
          ";
  $result = $site_db->query($sql);
  $row = mysql_fetch_object($result);
  $how_new = $row->new_images;
  $format_date = preg_replace("#[^a-zA-Z0-9]#",".",$config['date_format']);
  $format_time = preg_replace("#[^a-zA-Z0-9]#",":",$config['time_format']);
  $date_time = $format_date." ".$format_time;
  
  $user_lastvisit = (date('d.m.Y H:i',$user_info['user_lastvisit']));
  $search_date_link = ($how_new > 0) ?"<a href=\"".$site_sess->url(ROOT_PATH."search.php?search_date=".$user_lastvisit)." \">".$how_new."</a>": $how_new;
  $loginmsg = $lang['last_visit']."<b> ".$search_date_link."</b><br>";

  $site_template->register_vars("last_visit",$loginmsg);
}


5.) search in lang/yourlang/main.php:

//--- Search ------------------------------------------
//-----------------------------------------------------

insert below:
(deutsch)

$lang['last_visit'] = "Neue Bilder seit deinen letzten Besuch:";

(english)

$lang['last_visit'] = "New images since your last visit:";


6.)  search in templates/your Templates/user_logininfo.html
Code: [Select]
     » <a href="{url_logout}">{lang_logout}</a><br>&nbsp;</td>
  </tr>
insert below:
Code: [Select]
 <tr>
    <td valign="top" align="left">
    {last_visit}
    </td>
  </tr>

mfg Andi
Title: Re: [Mod] Search all images since (Date)
Post by: kubiczek on February 16, 2011, 07:58:49 PM
Hi,

geht einwandfrei in 1.7.4, 1.7.6

wenn mann das datum falsch eingibt kommt dann folgendes

Notice: Undefined offset: 3 in /www/htdocs/w00aca3c/gp/search.php on line 83


man könnte doch ein Auswahlkalender einbauen, dann währe eine falscheingabe ausgeschlossen.

gruß
Title: Re: [Mod] Search all images since (Date)
Post by: Rembrandt on February 16, 2011, 08:03:11 PM
...
wenn mann das datum falsch eingibt kommt dann folgendes
...
ok...
suche in den code:

  $search_time = explode(":", $search_date[3]);

  $hour = ($search_time[0]) ? $search_time[0]: 0;
  $min = ($search_time[0]) ? $search_time[1]: 0;

und ersetze es mit:

if(array_key_exists('3', $search_date)){
  $search_time = explode(":", $search_date[3]);
  $hour = $search_time[0];
  $min = $search_time[1];
}
else{
  $hour =  0;
  $min =  0;
}

suche "checkdate" und setze ein "@" davor.
Title: Re: [Mod] Search all images since (Date)
Post by: kubiczek on February 16, 2011, 09:08:27 PM
noch eine kleinichkeit

search_date müsste noch definiert werden

Notice: Undefined index: search_date in /www/htdocs/w00aca3c/gp/search.php on line 72


habe es versucht einzubinden in dem abschnitt von search.php  ohne erfolg

$site_template->register_vars(array(
  //######### Start Mod Search all images since (Date) ##########
  "date_format" => $config['date_format'],
  "lang_search_by_date" => $lang['search_by_date'],
//######### End Mod Search all images since (Date) ##########

    "search_keywords" => format_text(stripslashes($org_search_keywords), 2),
    "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'],
    "lang_category" => $lang['category'],
    "lang_search_fields" => $lang['search_fields'],
    "lang_all_fields" => $lang['all_fields'],
    "lang_name_only" => $lang['name_only'],
    "lang_description_only" => $lang['description_only'],
    "lang_keywords_only" => $lang['keywords_only'],
    "category_dropdown" => get_category_dropdown($cat_id)
  ));

Title: Re: [Mod] Search all images since (Date)
Post by: Rembrandt on February 16, 2011, 09:20:22 PM
sehe ich mir noch an, hast du in deiner search.php diese zeile drinnen stehn?
error_reporting(E_ALL);
die könntest du auskommentieren dann siehst du notiz nicht mehr.
Title: Re: [Mod] Search all images since (Date)
Post by: Jan-Lukas on February 16, 2011, 10:28:19 PM
Klappt ohne Probleme, keine Fehlermeldung vorhanden. Version 1.7.7

bei falschem Datum kommt "Die Suche ergab leider keine Treffer."

ganz dickes Dankeschön

LG Harald

Edit: doch noch einen Fehler gefunden, und zwar die Blätterfunktion.
Findet man Bilder über z.B. 2 Seiten, wird ab Seite 2 "Die Suche ergab leider keine Treffer." ausgegeben.
Hier wird der Wert nicht weiter gegeben
Title: Re: [Mod] Search all images since (Date)
Post by: kubiczek on February 17, 2011, 11:01:09 AM
Hallo

etwas stimmt nicht
ich habe heute 17.02.2011 14 Bilder Hochgeladen.

wenn ich Sie jetzt suche, werden Sie auch angezeigt.

1-12   ok

klicke ich dann auf seite 2  (13-14)
es werden dann 42 Bilder angezeigt (alle neuen Bilder)

sehe selbst http://www.grosspeterwitz.org/gp/search.php?l=deutsch   (suche nach 17.02.2011 )


ist mir in der Galerie 1.7.6 aufgefallen,

@ Jan-Lukas müsste das mal bei sich testen

gruß

Title: Re: [Mod] Search all images since (Date)
Post by: Jan-Lukas on February 17, 2011, 11:43:49 AM


@ Jan-Lukas müsste das mal bei sich testen

gruß



Habe ja schon geschrieben, bei mir wird keine Seite 2 aufgerufen
kannst ja mal testen

LG

Bei dir auch nicht, gebe mal als Datum 01.01.2011 ein

LG
Title: Re: [Mod] Search all images since (Date)
Post by: Rembrandt on February 17, 2011, 12:51:16 PM
tja leider, im moment habe ich auch keine lösung dafür...
so wie es aussieht habe ich doch eine lösung gefunden.

ich habe meinen ersten post editiert.
step 2.), 2.1), 2.2.), 2.3)
sry dafür und danke euch beiden @Jan-Lukas und @kubiczek fürs testen.

mfg Andi
Title: Re: [Mod] Search all images since (Date)
Post by: kubiczek on February 17, 2011, 05:36:40 PM
danke

es funzt :D :D :D
Title: Re: [Mod] Search all images since (Date)
Post by: Rembrandt on February 17, 2011, 05:42:54 PM
danke

es funzt :D :D :D
eh kloa..  :mrgreen:
Title: Re: [Mod] Search all images since (Date)
Post by: Jan-Lukas on February 17, 2011, 07:52:18 PM
PERFEKT  :wink:

Danke
Title: Re: [Mod] Search all images since (Date)
Post by: Rembrandt on February 18, 2011, 07:57:33 AM
Hi!

Neu Optional  Step 4.), 5.), 6.) hinzugefügt: "Wieviele Bilder seit dem letzten Besuch".

mfg Andi
Title: Re: [Mod] Search all images since (Date)
Post by: kubiczek on February 18, 2011, 01:28:24 PM
Hi

Weihnachten war doch erst........... :D

@ optional funktioniert in 1.7.6 sehr gut.

gruß
Title: Re: [Mod] Search all images since (Date)
Post by: Rembrandt on February 18, 2011, 05:20:07 PM
...@ optional funktioniert in 1.7.6 sehr gut.
...
Danke für dein Feedback, aus dem ganzen mod lässt sich noch einiges andere machen, mal sehn...  :D

mfg Andi
Title: Re: [Mod] Search all images since (Date)
Post by: Jan-Lukas on February 18, 2011, 05:42:15 PM
Du machst das schon, mir selber reicht die erste Variante  :wink:
aber mal sehen was noch kommt

LG
Title: Re: [Mod] Search all images since (Date)
Post by: bma2004 on August 06, 2011, 07:51:29 PM
I have a problem. Today 06.08.2011. if I ask to find photos added today - everything is normal output. if I choose another date - the photo shows all added between a given number and current.
Title: Re: [Mod] Search all images since (Date)
Post by: Rembrandt on August 06, 2011, 08:26:07 PM
I have a problem. ....

link
Title: Re: [Mod] Search all images since (Date)
Post by: bma2004 on August 06, 2011, 10:10:40 PM
I have a problem. ....

link
http://etpetersburg.ru/www/search.php
Title: Re: [Mod] Search all images since (Date)
Post by: Rembrandt on August 07, 2011, 05:32:24 AM
link not work
Title: Re: [Mod] Search all images since (Date)
Post by: bma2004 on August 07, 2011, 11:56:30 AM
link not work
now works.
just the server is offline: (
Title: Re: [Mod] Search all images since (Date)
Post by: Rembrandt on August 07, 2011, 02:31:57 PM
i think the mod work, but your thumbnail not :)
Title: Re: [Mod] Search all images since (Date)
Post by: bma2004 on August 07, 2011, 06:44:24 PM
i think the mod work, but your thumbnail not :)
alas.

MOD set to the original 1.7.10. Photos do not appear as I did not copy the folder "data". But the problem is not the slightest relationship has not.

if you type in your search:
08/07/2011, will not bring any photos. as they are not loaded into this number.
06/08/2011 photo-prints all over this day.
08/05/2011 - 08/06/2011 for photo displays.
08/02/2011 - displays all photos in between 02.08.2011-06.08.2011 ...

other mods are not installed.
Title: Re: [Mod] Search all images since (Date)
Post by: Rembrandt on August 07, 2011, 06:56:07 PM
this is the correct searchstring:
Quote
01.08.2011
and not:
Quote
08/02/2011
your images are stored with this format:
day.month.year
and not:
day/month/year
Title: Re: [Mod] Search all images since (Date)
Post by: bma2004 on August 07, 2011, 09:02:41 PM
sorry.

in such a format the date translated the Google-Translate.

I enter the date it was through "."
Title: Re: [Mod] Search all images since (Date)
Post by: Crazymodder on August 15, 2011, 08:50:12 PM
Hey very nice mod.
Is there a way to show Image since last visit also for guests? I think the Date is saved in a cookie?
If I remove the
if USER the date isn't correct for guest for users everythink works fine:)

EDIT:
The Date in Cookie is set correctly. Can't I use the function from 4images? Or did I need to read out the cookie with a seperator php snipet?

Did someone have an solution?

Thanks
Crazymodder
Title: Re: [Mod] Search all images since (Date)
Post by: SweD on April 25, 2012, 11:56:57 AM
Russian

3.) search in lang/your lang/main.php
//--- Search ------------------------------------------
//-----------------------------------------------------
insert below:
(russian)
//########################## Start Mod Search all images since (Date) ################################
$lang['search_by_date'] = "Поиск по дате:<br><span class=\"smalltext\">(Формат: <b>{date_format}</b>  ) время можно не указывать</span>";
//########################## End Mod Search all images since (Date) ##################################

5.) search in lang/yourlang/main.php:
//--- Search ------------------------------------------
//-----------------------------------------------------
insert below:
(russia)
$lang['last_visit'] = "Новых фотографий, после последнего посещения:";