Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

wrong date in photo albums

Asked Modified Viewed 2,077 times
A
adrianu89
A
  • Newbie, joined since
  • Contributed 9 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
asked
Newbie

i added this code to photogallery.php. in one case it shows the correct date, but it in second - the wrond date (ex: 01 january 1970)

<li class='date'>".showdate("shortdate", $data['album_datestamp'])."</li>
.

why? what to do? what I missed in the second case?

thanks in advance
0 replies

4 posts

R
Rimelek
R
  • Senior Member, joined since
  • Contributed 301 posts on the community forums.
  • Started 23 threads in the forums
answered
Senior Member

It can happen when the album_datestamp is 0. 0 is the default value of album_datestamp but should have a valid value after creating an album. What is the value in the field? Can you show an example for both case?
0 replies
A
adrianu89
A
  • Newbie, joined since
  • Contributed 9 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
answered
Newbie

i attached the code of photogallery.php and a screenshot of the page

first case, correct - line 160
second case, wrong - line 191

<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright (C) 2002 - 2011 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: photogallery.php
| Author: Nick Jones (Digitanium)
| Co-Author: Robert Gaudyn (Wooya)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEM ES."templates/headerg.php";
include LOCALE.LOCALESET."photogallery.php";

define("SAFEMODE", @ini_get("safe_mode") ? true : false);

set_title("Blogul lui Adrian :: Activitate fotografic&#259;");

if (isset($_GET['photo_id']) && isnum($_GET['photo_id'])){
   $result = dbquery(
      "SELECT tp.photo_title, tp.photo_description, tp.photo_filename, tp.photo_thumb2, tp.photo_datestamp, tp.photo_views,
      tp.photo_order, tp.photo_allow_comments, tp.photo_allow_ratings, ta.album_id, ta.album_title, ta.album_access, ta.album_datestamp, ta.album_views,
      tu.user_id, tu.user_name, tu.user_status, SUM(tr.rating_vote) AS sum_rating, COUNT(tr.rating_item_id) AS count_votes
      FROM ".DB_PHOTOS." tp
      LEFT JOIN ".DB_PHOTO_ALBUMS." ta USING (album_id)
      LEFT JOIN ".DB_USERS." tu ON tp.photo_user=tu.user_id
      LEFT JOIN ".DB_RATINGS." tr ON tr.rating_item_id = tp.photo_id AND tr.rating_type='P'
      WHERE photo_id='".$_GET['photo_id']."' GROUP BY tp.photo_id"
   );
   $data = dbarray($result);
   if (!checkgroup($data['album_access'])) {
      redirect(FUSION_SELF);
   } else {
      define("PHOTODIR", PHOTOS.(!SAFEMODE ? "album_".$data['album_id']."/" : ""));
      include INCLUDES."comments_include.php";
      include INCLUDES."ratings_include.php";
      $result=dbquery("UPDATE ".DB_PHOTOS." SET photo_views=(photo_views+1) WHERE photo_id='".$_GET['photo_id']."'");

      $pres = dbquery("SELECT photo_id FROM ".DB_PHOTOS." WHERE photo_order='".($data['photo_order']-1)."' AND album_id='".$data['album_id']."'");
      $nres = dbquery("SELECT photo_id FROM ".DB_PHOTOS." WHERE photo_order='".($data['photo_order']+1)."' AND album_id='".$data['album_id']."'");
      $fres = dbquery("SELECT photo_id FROM ".DB_PHOTOS." WHERE photo_order='1' AND album_id='".$data['album_id']."'");
      $lastres = dbresult(dbquery("SELECT MAX(photo_order) FROM ".DB_PHOTOS." WHERE album_id='".$data['album_id']."'"), 0);
      $lres = dbquery("SELECT photo_id FROM ".DB_PHOTOS." WHERE photo_order>='".$lastres."' AND album_id='".$data['album_id']."'");
      if (dbrows($pres)) $prev = dbarray($pres);
      if (dbrows($nres)) $next = dbarray($nres);
      if (dbrows($fres)) $first = dbarray($fres);
      if (dbrows($lres)) $last = dbarray($lres);

      openphoto($locale['450']);
         echo "<!--pre_photo-->";
      if ($settings['photo_watermark']) {
         if ($settings['photo_watermark_save']) {
            $parts = explode(".", $data['photo_filename']);
            $wm_file1 = $parts[0]."_w1.".$parts[1];
            $wm_file2 = $parts[0]."_w2.".$parts[1];
            if (!file_exists(PHOTODIR.$wm_file1)) {
               if ($data['photo_thumb2']) { $photo_thumb = "photo.php?photo_id=".$_GET['photo_id']; }
               $photo_file = "photo.php?photo_id=".$_GET['photo_id']."&amp;full";
            } else {
               if ($data['photo_thumb2']) { $photo_thumb = PHOTODIR.$wm_file1; }
               $photo_file = PHOTODIR.$wm_file2;
            }
         } else {
            if ($data['photo_thumb2']) { $photo_thumb = "photo.php?photo_id=".$_GET['photo_id']; }
            $photo_file = "photo.php?photo_id=".$_GET['photo_id']."&amp;full";
         }
         $photo_size = @getimagesize(PHOTODIR.$data['photo_filename']);
      } else {
         $photo_thumb = $data['photo_thumb2'] ? PHOTODIR.$data['photo_thumb2'] : "";
         $photo_file = PHOTODIR.$data['photo_filename'];
         $photo_size = @getimagesize($photo_file);
      }
      set_title($data['photo_title']." :: Blogul lui Adrian");

      add_to_head("<link rel='stylesheet' href='".INCLUDES."jquery/colorbox/colorbox.css' type='text/css' media='screen' />");
      add_to_head("<script type='text/javascript' src='".INCLUDES."jquery/colorbox/jquery.colorbox.js'></script>");
      add_to_head("<script type='text/javascript'>\n
         /* <![CDATA[ */\n
            jQuery(document).ready(function(){
               jQuery('a.photogallery_photo_link').colorbox({
                  width:'80%', height:'80%', photo:true
               });
            });\n
         /* ]]>*/\n
      </script>\n");
      echo "<table cellpadding='0' cellspacing='0' width='100%'>\n<tr>\n<td class='tbl2'>\n";
      echo "<a href='".FUSION_SELF."'>".$locale['400']."</a> &gt;\n";
      echo "<a href='".FUSION_SELF."?album_id=".$data['album_id']."'>".$data['album_title']."</a>\n";
      echo ($data['photo_title'] ? " &gt; <strong>".$data['photo_title']."</strong>" : "")."\n</td>\n";
      if ((isset($prev['photo_id']) && isnum($prev['photo_id'])) || (isset($next['photo_id']) && isnum($next['photo_id']))) {
         if (isset($prev)) { echo "<td width='15%' class='tbl2'><a href='".FUSION_SELF."?photo_id=".$prev['photo_id']."' title='".$locale['451']."'><b>".$locale['451']."</b></a></td>\n"; }
         if (isset($next)) { echo "<td width='15%' class='tbl2'><a href='".FUSION_SELF."?photo_id=".$next['photo_id']."' title='".$locale['452']."'><b>".$locale['452']."</b></a></td>\n"; }
      }
      echo "</tr>\n</table>\n";

      echo "<div id='photogallery' align='center' style='margin:5px;'>\n";
      echo "<img src='".$photo_file."' alt='".(!empty($data['photo_title']) ? $data['photo_title'] : $data['photo_filename'])."' border='1px' class='photogallery_photo' />\n";
      echo "</div>\n";
      echo "<div align='center' style='margin:5px 0px 5px 0px' class='photogallery_photo_desc'><!--photogallery_photo_desc-->\n";
      if ($data['photo_description']) {
         echo "<font color=green size=2><b>".nl2br(parseubb($data['photo_description'], "b|i|u|center|small|url|mail|img|quote"))."</b></font><br /><br />\n";
      }
                echo "<table width='100%' cellpadding='0' cellspacing='0'>\n<tr>\n";
                echo "<td align='center' class='news-footer middle-border'>\n";
      echo "<li class='user'>".$locale['434']."<b>".$data['user_name']."</b></li>\n";      
                echo "<li class='date'>".showdate("shortdate", $data['photo_datestamp'])."</li>\n";
           echo "<li class='views'>".$locale['435'].$data['photo_views']."</span></li>\n";
   
if (!iGUEST) {
echo "<a href='administration/photos.php".$aidlink."&amp;action=edit&amp;album_id=".$data['album_id']."&amp;photo_id=".$_GET['photo_id']."'><img src='".get_image("edit")."' style='vertical-align:middle;border:0;' align='right'/></a>";
}


                echo "</td>\n";
           echo "</tr></table>\n";      
                echo "<!--sub_photo-->";

         if ($data['photo_allow_ratings']) { showratings("P", $_GET['photo_id'], FUSION_SELF."?photo_id=".$_GET['photo_id']); }
   }
} elseif (isset($_GET['album_id']) && isnum($_GET['album_id'])) {
dbquery("UPDATE ".DB_PHOTO_ALBUMS." SET album_views=album_views+1 WHERE album_id='".$_GET['album_id']."'");
   define("PHOTODIR", PHOTOS.(!SAFEMODE ? "album_".$_GET['album_id']."/" : ""));
   $result = dbquery(
      "SELECT album_title, album_description, album_datestamp, album_thumb, album_views, album_access FROM ".DB_PHOTO_ALBUMS." WHERE album_id='".$_GET['album_id']."'"
   );
   if (!dbrows($result)) {
      redirect(FUSION_SELF);
   } else {
      $data = dbarray($result);
      if (!checkgroup($data['album_access'])) {
         redirect(FUSION_SELF);
      } else {
         $rows = dbcount("(photo_id)", DB_PHOTOS, "album_id='".$_GET['album_id']."'");
         set_title($data['album_title']." :: Blogul lui Adrian");
         
         if ($rows) {

            openalbum($data['album_title']);
            if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; }
            $result = dbquery(
               "SELECT tp.photo_id, tp.photo_title, tp.photo_thumb1, tp.photo_views, tp.photo_datestamp, tp.photo_allow_comments, tp.photo_allow_ratings,
               tu.user_id, tu.user_name, tu.user_status, SUM(tr.rating_vote) AS sum_rating, COUNT(tr.rating_item_id) AS count_votes
               FROM ".DB_PHOTOS." tp
               LEFT JOIN ".DB_USERS." tu ON tp.photo_user=tu.user_id
               LEFT JOIN ".DB_RATINGS." tr ON tr.rating_item_id = tp.photo_id AND tr.rating_type='P'
               WHERE album_id='".$_GET['album_id']."' GROUP BY photo_id ORDER BY photo_order LIMIT ".$_GET['rowstart'].",".$settings['thumb_per_page']
            );
            $counter = 0;

echo "<table cellpadding='0' cellspacing='1' width='100%' style='margin-bottom: 5px';>\n<tr>\n";
     echo "<td class='news-footer middle-border'>\n";      
     echo "<li class='photodesc1'><b> - ".showdate("shortdate", $data['album_datestamp'])." - </b><font color=black>".nl2br(parseubb($data['album_description'], "b|i|u|center|small|url|mail|img|quote"))."</font></li> \n";   
     echo "</td>\n";
           echo "</tr></table>\n"; 


            if ($rows > $settings['thumb_per_page']) { echo "<div align='center' style='margin-top:5px;'>\n".makepagenav($_GET['rowstart'], $settings['thumb_per_page'], $rows, 3, FUSION_SELF."?album_id=".$_GET['album_id']."&amp;")."\n</div>\n"; }
            echo "<table cellpadding='0' cellspacing='1' width='100%'>\n<tr>\n";
            while ($data = dbarray($result)) {
               if ($counter != 0 && ($counter % $settings['thumbs_per_row'] == 0)) { echo "</tr>\n<tr>\n"; }
               echo "<td align='center' valign='top' class='tbl'>\n";
               echo "<a href='".FUSION_SELF."?photo_id=".$data['photo_id']."' class='photogallery_album_photo_link'><!--photogallery_album_photo_".$data['photo_id']."-->";
               if ($data['photo_thumb1'] && file_exists(PHOTODIR.$data['photo_thumb1'])){
                  echo "<img width='200px' src='".PHOTODIR.$data['photo_thumb1']."' alt='".$data['photo_thumb1']."' title='".$locale['431']."' class='photogallery_album_photo' style='border:5px ridge rgb(221, 221, 221)'/>";
               } else {
                  echo $locale['432'];
               }

               echo "</a>\n";


            
                                      $counter++;

            }


closetable();        }  } 
 

echo "<hr>

<li class='date'>".showdate("shortdate", $data['album_datestamp'])."</li>

 <a href='http://adrianplaton.com/photogallery.php?album_id=".$_GET['album_id']."' class='twitter-share-button' data-lang='en'>Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src='https://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document,'script','twitter-wjs');</script>";

global $aidlink;
      if (iADMIN) { echo "<!--article_news_opts--> <a href='".ADMIN."photoalbums.php".$aidlink."&amp;action=edit&amp;album_id=".$_GET['album_id']."'><img src='".get_image("edit")."' style='vertical-align:middle;border:0;float: right;margin-top: 2px;margin-right: 1px;margin-left: 5px;' /></a>\n"; }

echo "<div style='float: right' class='fb-like' data-href='http://adrianplaton.com/photogallery.php?album_id=".$_GET['album_id']."' data-width='500' data-layout='button_count' data-action='like' data-show-faces='false' data-share='true'></div>";
            echo "</tr>\n</table>\n";

echo "<a id='comments' name='comments'></a>";
opencomment($locale['cip001']);
echo "<div align='center' class='tbl'>\n";
echo "<div class='fb-comments' data-href='http://adrianplaton.com/photogallery.php?album_id=".$_GET['album_id']."' data-num-posts='10' data-width='685'></div>\n";
echo "</div>\n";

closetable();             


}


} else {
   opengallery($locale['400']);
     

   $rows = dbcount("(album_id)", DB_PHOTO_ALBUMS, groupaccess('album_access'));
   if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; }
   if ($rows) {
      $result = dbquery(
         "SELECT ta.album_id, ta.album_title, ta.album_thumb, ta.album_datestamp, tu.user_id, tu.user_name, tu.user_status
         FROM ".DB_PHOTO_ALBUMS." ta
         LEFT JOIN ".DB_USERS." tu ON ta.album_user=tu.user_id
         WHERE album_access='0' ORDER BY album_order
         LIMIT ".$_GET['rowstart'].",".$settings['thumbs_per_page']
      );
      $counter = 0; $r = 0; $k = 1;
      if ($rows > $settings['thumbs_per_page']) { echo "<div align='center' style='margin-top:5px;'>\n".makepagenav($_GET['rowstart'], $settings['thumbs_per_page'], $rows, 3)."\n</div>\n"; }
      echo "<table cellpadding='0' cellspacing='1' width='100%'>\n<tr>\n";
      while ($data = dbarray($result)) {
         if ($counter != 0 && ($counter % $settings['thumbs_per_row'] == 0)) { echo "</tr>\n<tr>\n"; }
         echo "<td align='center' valign='top' class='tbl'>\n";
         echo "<a href='".FUSION_SELF."?album_id=".$data['album_id']."'>";
         if ($data['album_thumb'] && file_exists(PHOTOS.$data['album_thumb'])){
            echo "<img width='200px' src='".PHOTOS.$data['album_thumb']."' alt='".$data['album_thumb']."' title='".$locale['401']."' style='border:5px solid rgb(221, 221, 221)' />";
         } else {
            echo $locale['402'];
         }
         echo "</a><table width='210px' border='0' style='border-radius: 0px 0px 5px 5px' height='25px'><tbody>
<tr><td><center><strong><font color='black'>".$data['album_title']."</font></strong></center></td></tr></tbody></table>";
         echo "</td>\n";
         $counter++; $k++;
      }
 if ($rows > $settings['thumbs_per_page']) { echo "</tr><tr><td></td><td><div align='center' style='margin-top:5px;'>\n".makepagenav($_GET['rowstart'], $settings['thumbs_per_page'], $rows, 3)."\n</div></td><td></td>\n"; }


      echo "</tr></tr>\n</table>\n";
      closetable();
      
   }else{
      echo "<div style='text-align:center'><br />".$locale['406']."<br /><br /></div>\n";
      closetable();
   }
}

require_once THEMES."templates/footer.php";
?>
Edited by adrianu89 on 10-12-2014 00:57,
adrianu89 attached the following file:
example_1.png [No information available / 79 Downloads]
0 replies
R
Rimelek
R
  • Senior Member, joined since
  • Contributed 301 posts on the community forums.
  • Started 23 threads in the forums
answered
Senior Member

I see the reason. You have placed the second date after this loop on line 167:
while ($data = dbarray($result)) {

The loop will end when $data is empty. An error message must be in your error log like "undefined index 'album_datestamp'"
If you want to show the date of the album after listing photos, you have to save the variable before listing or use another variable for storing the records of photos. For example $data_photos or just $data_p to avoid overriding the original variable.

            while ($data_p = dbarray($result)) {
               if ($counter != 0 && ($counter % $settings['thumbs_per_row'] == 0)) { echo "</tr>\n<tr>\n"; }
               echo "<td align='center' valign='top' class='tbl'>\n";
               echo "<a href='".FUSION_SELF."?photo_id=".$data_p['photo_id']."' class='photogallery_album_photo_link'><!--photogallery_album_photo_".$data_p['photo_id']."-->";
               if ($data_p['photo_thumb1'] && file_exists(PHOTODIR.$data_p['photo_thumb1'])){
                  echo "<img width='200px' src='".PHOTODIR.$data_p['photo_thumb1']."' alt='".$data_p['photo_thumb1']."' title='".$locale['431']."' class='photogallery_album_photo' style='border:5px ridge rgb(221, 221, 221)'/>";
               } else {
                  echo $locale['432'];
               }

               echo "</a>\n";


           
                                      $counter++;

            }
0 replies
A
adrianu89
A
  • Newbie, joined since
  • Contributed 9 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
answered
Newbie

thanks. it works :)
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 4 posts
  • Votes 0 votes
  • Topic users 2 members

2 participants

A
A
  • Newbie, joined since
  • Contributed 9 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
R
R
  • Senior Member, joined since
  • Contributed 301 posts on the community forums.
  • Started 23 threads in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet