Author Topic: [MOD] - Universal field date - gallery and admin  (Read 26452 times)

0 Members and 1 Guest are viewing this topic.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
[MOD] - Universal field date - gallery and admin
« on: January 13, 2008, 01:13:10 AM »
Hi,

I like MOD so much - I publish FREE ! ;)
Some user is ask this before in forum. Is plan I code today. Is look right.

// Is do ?

MOD is check for today and yesterday (day before - I find definition !! :)). If upload date for image is same day now, is say: today . If user upload image day before - is say: yesterday image date. After 48 hour, is back for normal date. ;)

// Universal ?

This is right. Is no single 4images. Use for all MOD in forum with use: format_date and replace . ;)
Note: date field is MUST for microtime type.

// Test ?

Yes - here: http://www.4homepages.de/forum/index.php?topic=9598.msg109730#msg109730

[v1.0 - 01/12/2008]

Please backup all file:

- member.php
- details.php
- lightbox.php
- admin/home.php
- admin/users.php
- admin/admin_functions.php
- admin/images.php
- admin/comments.php
- admin/validateimages.php
- includes/functions.php

// Step 1

In member.php file

find:

Code: [Select]
"user_join_date" => (isset($user_row['user_joindate'])) ? format_date($config['date_format'], $user_row['user_joindate']) : REPLACE_EMPTY,
"user_last_action" => (isset($user_row['user_lastaction'])) ? format_date($config['date_format']." ".$config['time_format'], $user_row['user_lastaction']) : REPLACE_EMPTY,

replace:

Code: [Select]
"user_join_date" => (isset($user_row['user_joindate'])) ? get_universal_field_date($user_row['user_joindate']) : REPLACE_EMPTY,
"user_last_action" => (isset($user_row['user_lastaction'])) ? get_universal_field_date($user_row['user_lastaction']) : REPLACE_EMPTY,

// Step 2

In details.php file,

find:

Code: [Select]
$comment_user_info .= (isset($comment_row[$i][$user_table_fields['user_joindate']])) ? "<br />".$lang['join_date']." ".format_date($config['date_format'], $comment_row[$i][$user_table_fields['user_joindate']]) : "";

replace:

Code: [Select]
$comment_user_info .= (isset($comment_row[$i][$user_table_fields['user_joindate']])) ? "<br />".$lang['join_date']." ".get_universal_field_date($comment_row[$i][$user_table_fields['user_joindate']]) : "";

// Step 2.1

find:

Code: [Select]
"comment_date" => format_date($config['date_format']." ".$config['time_format'], $comment_row[$i]['comment_date']),

replace:

Code: [Select]
"comment_date" => get_universal_field_date($comment_row[$i]['comment_date']),

// Step 3

In lightbox.php file,

find:

Code: [Select]
$lightbox_lastaction = format_date($config['date_format']." ".$config['time_format'], $user_info['lightbox_lastaction']);

replace:

Code: [Select]
$lightbox_lastaction = get_universal_field_date($user_info['lightbox_lastaction']);

// Step 4

In admin/home.php file,

find:

Code: [Select]
echo "<td>".format_date($config['date_format']." ".$config['time_format'], $row[$user_table_fields['user_lastaction']])."</td>\n";

replace:

Code: [Select]
echo "<td>".get_universal_field_date($row[$user_table_fields['user_lastaction']])."</td>\n";

// Step 4.1

find:

Code: [Select]
echo "<td>".format_date($config['date_format']." ".$config['time_format'], $row['session_lastaction'])."</td>\n";

replace:

Code: [Select]
echo "<td>".get_universal_field_date($row['session_lastaction'])."</td>\n";

// Step 5

In admin/users.php file,

find:

Code: [Select]
echo "<td>".format_date($config['date_format']." ".$config['time_format'], $user_row[$user_table_fields['user_joindate']])."</td>\n";
echo "<td>".format_date($config['date_format']." ".$config['time_format'], $user_row[$user_table_fields['user_lastaction']])."</td>\n";

replace:

Code: [Select]
echo "<td>".get_universal_field_date($user_row[$user_table_fields['user_joindate']])."</td>\n";
echo "<td>".get_universal_field_date($user_row[$user_table_fields['user_lastaction']])."</td>\n";

// Step 6

In admin/admin_functions.php file,

add in top ?>:

Code: [Select]
if (!function_exists('get_universal_field_date')) {
    function get_universal_field_date($image_date) {
        global $lang, $config;
       
        $date_separator = preg_replace("/[a-zA-Z]+/i", "", $config['date_format']);               
       
        $day = getdate();
       
        // Today date.       
        $today_image_date = format_date($config['date_format'], $image_date);
       
        if ($config['date_format'][0] == "d" && $config['date_format'][2] == "m" && $config['date_format'][4] == "Y") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $date_separator[0] . $today_image_date[6] . $today_image_date[7] . $today_image_date[8] . $today_image_date[9];
            $today = $day['mday'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['year'];           
           
        } elseif ($config['date_format'][0] == "d" && $config['date_format'][2] == "Y" && $config['date_format'][4] == "m") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = $day['mday'] . $date_separator[0] . $day['year'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']);
       
        } elseif ($config['date_format'][0] == "m" && $config['date_format'][2] == "d" && $config['date_format'][4] == "Y") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $date_separator[0] . $today_image_date[6] . $today_image_date[7] . $today_image_date[8] . $today_image_date[9];
            $today = (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['mday'] . $date_separator[0] . $day['year'];
           
        } elseif ($config['date_format'][0] == "m" && $config['date_format'][2] == "Y" && $config['date_format'][4] == "d") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['year'] . $date_separator[0] . $day['mday'];
           
        } elseif ($config['date_format'][0] == "Y" && $config['date_format'][2] == "m" && $config['date_format'][4] == "d") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $today_image_date[2] . $today_image_date[3] . $date_separator[0] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = $day['year'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['mday'];
           
        } elseif ($config['date_format'][0] == "Y" && $config['date_format'][2] == "d" && $config['date_format'][4] == "m") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $today_image_date[2] . $today_image_date[3] . $date_separator[0] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = $day['year'] . $date_separator[0] . $day['mday'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']);           
        }
       
        $yesterday_upload = format_date($config['date_format'], time() + 60 * 60 * 24 * 1);       
               
        // Show today image date if uploaded in same day.
        if ($today == $today_upload_image) {
            return str_replace(array("{uploaded_today_date}"), array(format_date($config['time_format'], $image_date)), $lang['uploaded_images_today']);
           
        } elseif ($today_upload_image == $yesterday_upload) {
            $calc_past_upload = $yesterday_upload - $today + 1 - 1;           
            if ($calc_past_upload == 1) {
                return str_replace(array("{uploaded_yesterday_date}"), array(format_date($config['time_format'], $image_date)), $lang['uploaded_images_yesterday']);
            }
       
        } elseif ($today_upload_image > $yesterday_upload || $today_upload_image < $yesterday_upload) {
            return format_date($config['date_format'] . " " . $config['time_format'], $image_date);           
        }
    }   
}

// Step 7

In admin/images.php file,

find:

Code: [Select]
echo "<td>".format_date($config['date_format'], $image_row['image_date'])."</td>\n";

replace:

Code: [Select]
echo "<td>".get_universal_field_date($image_row['image_date'])."</td>\n";

// Step 8

In admin/comments.php file,

find:

Code: [Select]
echo "<td>".format_date($config['date_format']." ".$config['time_format'], $comment_row['comment_date'])."</td>\n";

replace:

Code: [Select]
echo "<td>".get_universal_field_date($comment_row['comment_date'])."</td>\n";

// Step 9

In admin/validateimages.php file,

find:

Code: [Select]
echo "<td>".format_date($config['date_format']." ".$config['time_format'], $image_row['image_date'])."</td>\n";

replace:

Code: [Select]
echo "<td>".get_universal_field_date($image_row['image_date'])."</td>\n";

// Step 10

In includes/functions.php file,

add in top ?>:

Code: [Select]
if (!function_exists('get_universal_field_date')) {
    function get_universal_field_date($image_date) {
        global $lang, $config;
       
        $date_separator = preg_replace("/[a-zA-Z]+/i", "", $config['date_format']);               
       
        $day = getdate();
       
        // Today date.       
        $today_image_date = format_date($config['date_format'], $image_date);
       
        if ($config['date_format'][0] == "d" && $config['date_format'][2] == "m" && $config['date_format'][4] == "Y") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $date_separator[0] . $today_image_date[6] . $today_image_date[7] . $today_image_date[8] . $today_image_date[9];
            $today = $day['mday'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['year'];           
           
        } elseif ($config['date_format'][0] == "d" && $config['date_format'][2] == "Y" && $config['date_format'][4] == "m") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = $day['mday'] . $date_separator[0] . $day['year'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']);
       
        } elseif ($config['date_format'][0] == "m" && $config['date_format'][2] == "d" && $config['date_format'][4] == "Y") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $date_separator[0] . $today_image_date[6] . $today_image_date[7] . $today_image_date[8] . $today_image_date[9];
            $today = (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['mday'] . $date_separator[0] . $day['year'];
           
        } elseif ($config['date_format'][0] == "m" && $config['date_format'][2] == "Y" && $config['date_format'][4] == "d") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['year'] . $date_separator[0] . $day['mday'];
           
        } elseif ($config['date_format'][0] == "Y" && $config['date_format'][2] == "m" && $config['date_format'][4] == "d") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $today_image_date[2] . $today_image_date[3] . $date_separator[0] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = $day['year'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['mday'];
           
        } elseif ($config['date_format'][0] == "Y" && $config['date_format'][2] == "d" && $config['date_format'][4] == "m") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $today_image_date[2] . $today_image_date[3] . $date_separator[0] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = $day['year'] . $date_separator[0] . $day['mday'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']);           
        }
       
        $yesterday_upload = format_date($config['date_format'], time() + 60 * 60 * 24 * 1);       
               
        // Show today image date if uploaded in same day.
        if ($today == $today_upload_image) {
            return str_replace(array("{uploaded_today_date}"), array(format_date($config['time_format'], $image_date)), $lang['uploaded_images_today']);
           
        } elseif ($today_upload_image == $yesterday_upload) {
            $calc_past_upload = $yesterday_upload - $today + 1 - 1;           
            if ($calc_past_upload == 1) {
                return str_replace(array("{uploaded_yesterday_date}"), array(format_date($config['time_format'], $image_date)), $lang['uploaded_images_yesterday']);
            }
       
        } elseif ($today_upload_image > $yesterday_upload || $today_upload_image < $yesterday_upload) {
            return format_date($config['date_format'] . " " . $config['time_format'], $image_date);           
        }
    }   
}

// Step 11

In lang/english/main.php file,

add in top ?>:

Code: [Select]
$lang['uploaded_images_today'] = "<b>Today</b> at: {uploaded_today_date}";
$lang['uploaded_images_yesterday'] = "<b>Yesterday</b> at: {uploaded_yesterday_date}";

// INTEGRATION

If use memberlist:

In memberlist.php file,

find:

Code: [Select]
format_date($config['date_format'], $user_row['user_joindate'])

replace:

Code: [Select]
get_universal_field_date($user_row[$user_table_fields['user_joindate']])

[v1.1 - upgrade - 01/13/2008]

I code upgrade (fix include with addon) .

// Is do ?

Is now say: today, yesterday, x days ago (if image is old - start of 2 days), x day(s) in near future (if image date is change from image owner or admin for after same day upload date). :)

// Upgrade file:

- includes/functions.php.
- admin/admin_functions.php
- lang/english/main.php

// Step 1

In includes/functions.php file,

replace full function with this:

Code: [Select]
if (!function_exists('get_universal_field_date')) {
    function get_universal_field_date($image_date) {
        global $lang, $config;
       
        $start_time = $image_date;
        $now = time();
       
        $total_secs = ($now - $start_time);
        $total_days = intval($total_secs / 86400);       
           
        // Show today image date if uploaded in same day.       
        if ($total_days == 0) {
            return str_replace(array("{uploaded_today_time}"), array(format_date($config['time_format'], $image_date)), $lang['uploaded_images_today']);
           
        // Show yesterday image (if upload yesterday).
        } elseif ($total_days == 1) {
            return str_replace(array("{uploaded_yesterday_date}", "{uploaded_yesterday_time}"), array(format_date($config['date_format'], $image_date), format_date($config['time_format'], $image_date)), $lang['uploaded_images_yesterday']);
           
        // Show after 2 days image upload date.
        } elseif ($total_days > 1) {                       
            return str_replace(array("{total_days}", "{uploaded_days_ago_date}", "{uploaded_days_ago_time}"), array($total_days, format_date($config['date_format'], $image_date), format_date($config['time_format'], $image_date)), $lang['uploaded_images_days_ago']);
               
        // Show invalid date set from image owner or admin (if set after date upload).
        } else {
            $total_days = preg_replace("/[^0-9]+/i", "", $total_days);
            return str_replace(array("{total_days}"), array($total_days), $lang['uploaded_images_near_future']);
        }
    }   
}

// Step 2

Replace full function but with this:

Code: [Select]
if (!function_exists('get_universal_field_date')) {
    function get_universal_field_date($image_date) {
        global $lang, $config;
       
        $start_time = $image_date;
        $now = time();
       
        $total_secs = ($now - $start_time);
        $total_days = intval($total_secs / 86400);       
           
        // Show today image date if uploaded in same day.       
        if ($total_days == 0) {
            return str_replace(array("{uploaded_today_time}"), array(format_date($config['time_format'], $image_date)), $lang['uploaded_images_today']);
           
        // Show yesterday image (if upload yesterday).
        } elseif ($total_days == 1) {
            return str_replace(array("{uploaded_yesterday_date}", "{uploaded_yesterday_time}"), array(format_date($config['date_format'], $image_date), format_date($config['time_format'], $image_date)), $lang['uploaded_images_yesterday']);
           
        // Show after 2 days image upload date.
        } elseif ($total_days > 1) {                       
            return str_replace(array("{total_days}", "{uploaded_days_ago_date}", "{uploaded_days_ago_time}"), array($total_days, format_date($config['date_format'], $image_date), format_date($config['time_format'], $image_date)), $lang['uploaded_images_days_ago']);
               
        // Show invalid date set from image owner or admin (if set after date upload).
        } else {
            $total_days = preg_replace("/[^0-9]+/i", "", $total_days);
            return str_replace(array("{total_days}"), array($total_days), $lang['uploaded_images_near_future']);
        }
    }   
}

// Step 3

In lang/english/main.php file,

find:

Code: [Select]
$lang['uploaded_images_today'] = "<b>Today</b> at {uploaded_today_date}";
$lang['uploaded_images_yesterday'] = "<b>Yesterday</b> at {uploaded_yesterday_date}";

add after:

Code: [Select]
$lang['uploaded_images_days_ago'] = "<b>{calc_distant_days} days ago</b> at: {uploaded_days_ago_time}";
$lang['uploaded_images_near_future'] = "<b>{calc_distant_days}</b> day(s) in the near future";

[v1.1 - End upgrade - 01/13/2008]

[v1.2 - Upgrade - 01/13/2008]

Do same thing for v1.1 (replace code in includes/functions.php and admin/functions.php file). Fix and addon. Function is small for same thing now. ;)

Note: I post screenshot. ;)

After - in lang/english/main.php file,

find:

Code: [Select]
$lang['uploaded_images_today'] = "<b>Today</b> at {uploaded_today_date}";
$lang['uploaded_images_yesterday'] = "<b>Yesterday</b> at {uploaded_yesterday_date}";
$lang['uploaded_images_days_ago'] = "<b>{calc_distant_days} days ago</b> at: {uploaded_days_ago_time}";
$lang['uploaded_images_near_future'] = "<b>{calc_distant_days}</b> day(s) in the near future";

replace:

Code: [Select]
$lang['uploaded_images_today'] = "<b>Today</b> at {uploaded_today_time}";
$lang['uploaded_images_yesterday'] = "<b>Yesterday</b> ({uploaded_yesterday_date}) at {uploaded_yesterday_time}";
$lang['uploaded_images_days_ago'] = "<b>{total_days} days ago</b> ({uploaded_days_ago_date}) at {uploaded_days_ago_time}";
$lang['uploaded_images_near_future'] = "<b>{total_days}</b> day(s) in the near future";

Screenshot 1: Today image date.
Screenshot 2: Yesterday image date.
Screenshot 3: If more 2 day upload image date.
Screenshot 4: If image owner or admin is set image date day after today.

[v1.2 - End upgrade - 01/13/2008]

Finish.
« Last Edit: January 20, 2008, 03:48:27 PM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Universal field date - gallery and admin
« Reply #1 on: January 13, 2008, 11:38:50 AM »
I add step 11. Now, is work right. ;)
I fix Step 2.
« Last Edit: January 13, 2008, 02:34:08 PM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Universal field date - gallery and admin
« Reply #2 on: January 13, 2008, 03:35:49 PM »
I code upgrade (fix and addon include). ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline kai

  • Administrator
  • Addicted member
  • *****
  • Posts: 1.423
    • View Profile
    • 4images - Image Gallery Management System
Re: [MOD] - Universal field date - gallery and admin
« Reply #3 on: January 13, 2008, 04:36:31 PM »
Any demo available?
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Universal field date - gallery and admin
« Reply #4 on: January 13, 2008, 08:44:58 PM »
V1.2 - FINAL upgrade ready. ;)
Fix and addon include.
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline www.katzen.ag

  • Jr. Member
  • **
  • Posts: 75
  • KatzenAG - das grosse Katzenportal im Internet
    • View Profile
    • KatzenAG - das grosse Katzenportal im Internet
Re: [MOD] - Universal field date - gallery and admin
« Reply #5 on: January 20, 2008, 07:40:14 PM »
Hallo thunderstrike,

as you know I added this MOD for my dreamboard.
It works fine but just "today" is shown. "yestserday" does not?!? Also in comments and images...

I checked my files two times but it seems ok, like your description...

I Use vers. 1.7.1

 
KatzenAG - das grosse Katzenportal im Internet

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Universal field date - gallery and admin
« Reply #6 on: January 20, 2008, 07:45:25 PM »
1 - You install all step (include upgrade) ?
2 - I use fresh 4images v1.74 for test this ...
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline www.katzen.ag

  • Jr. Member
  • **
  • Posts: 75
  • KatzenAG - das grosse Katzenportal im Internet
    • View Profile
    • KatzenAG - das grosse Katzenportal im Internet
Re: [MOD] - Universal field date - gallery and admin
« Reply #7 on: January 20, 2008, 07:58:15 PM »
After upgrade:

 "today"- not work
"Yesterday" - ok, work
"days ago" - not work

For me its ok when today and yesterday is working
KatzenAG - das grosse Katzenportal im Internet

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Universal field date - gallery and admin
« Reply #8 on: January 20, 2008, 08:26:37 PM »
Quote
"today"- not work
"days ago" - not work

Please check screenshot.

Quote
For me its ok when today and yesterday is working

If install fresh 4images v1.74 in test folder - is work ?
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline www.katzen.ag

  • Jr. Member
  • **
  • Posts: 75
  • KatzenAG - das grosse Katzenportal im Internet
    • View Profile
    • KatzenAG - das grosse Katzenportal im Internet
Re: [MOD] - Universal field date - gallery and admin
« Reply #9 on: January 20, 2008, 08:33:55 PM »
hmm... I have no posibility to test it on 1.7.4 at the monent.
I will try to combine your MOD without upgrate with the upgrade version, because today works in standard and yesterday works with the upgrade version.

However, thank you very much for your help.

 
KatzenAG - das grosse Katzenportal im Internet

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Universal field date - gallery and admin
« Reply #10 on: January 20, 2008, 08:44:07 PM »
Is no problem. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline www.katzen.ag

  • Jr. Member
  • **
  • Posts: 75
  • KatzenAG - das grosse Katzenportal im Internet
    • View Profile
    • KatzenAG - das grosse Katzenportal im Internet
Re: [MOD] - Universal field date - gallery and admin
« Reply #11 on: January 20, 2008, 09:25:16 PM »
I made it!


Quote
if (!function_exists('get_universal_field_date')) {
    function get_universal_field_date($image_date) {
        global $lang, $config;
       
        $start_time = $image_date;
        $now = time();
       
        $total_secs = ($now - $start_time);
        $total_days = intval($total_secs / 86400);       
           
        // Show today image date if uploaded in same day.       
        if ($total_days == 0) {
            return str_replace(array("{uploaded_today_date}"), array(format_date($config['time_format'], $image_date)), $lang['uploaded_images_today']);
           
        // Show yesterday image (if upload yesterday).
        } elseif ($total_days == 1) {
            return str_replace(array("{uploaded_yesterday_date}", "{uploaded_yesterday_time}"), array(format_date($config['date_format'], $image_date), format_date($config['time_format'], $image_date)), $lang['uploaded_images_yesterday']);
           
        // Show after 2 days image upload date.
        } elseif ($total_days > 1) {                       
            return format_date($config['date_format'] . " " . $config['time_format'], $image_date);
               
        // Show invalid date set from image owner or admin (if set after date upload).
        } else {
            $total_days = preg_replace("/[^0-9]+/i", "", $total_days);
            return str_replace(array("{total_days}"), array($total_days), $lang['uploaded_images_near_future']);
        }
    }   
}

for all 1.7.1 users  :D :D :lol:
KatzenAG - das grosse Katzenportal im Internet

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Universal field date - gallery and admin
« Reply #12 on: January 20, 2008, 09:57:31 PM »
What is change in this code ? ...
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline www.katzen.ag

  • Jr. Member
  • **
  • Posts: 75
  • KatzenAG - das grosse Katzenportal im Internet
    • View Profile
    • KatzenAG - das grosse Katzenportal im Internet
Re: [MOD] - Universal field date - gallery and admin
« Reply #13 on: January 20, 2008, 10:23:20 PM »
Quote
if (!function_exists('get_universal_field_date')) {
    function get_universal_field_date($image_date) {
        global $lang, $config;
       
        $start_time = $image_date;
        $now = time();
       
        $total_secs = ($now - $start_time);
        $total_days = intval($total_secs / 86400);       
           
        // Show today image date if uploaded in same day.       
        if ($total_days == 0) {
            return str_replace(array("{uploaded_today_date}"), array(format_date($config['time_format'], $image_date)), $lang['uploaded_images_today']);
           
        // Show yesterday image (if upload yesterday).
        } elseif ($total_days == 1) {
            return str_replace(array("{uploaded_yesterday_date}", "{uploaded_yesterday_time}"), array(format_date($config['date_format'], $image_date), format_date($config['time_format'], $image_date)), $lang['uploaded_images_yesterday']);
           
        // Show after 2 days image upload date.
        } elseif ($total_days > 1) {                       
            return format_date($config['date_format'] . " " . $config['time_format'], $image_date);
               
        // Show invalid date set from image owner or admin (if set after date upload).
        } else {
            $total_days = preg_replace("/[^0-9]+/i", "", $total_days);
            return str_replace(array("{total_days}"), array($total_days), $lang['uploaded_images_near_future']);
        }
    }   
}


...and it works - live Demo:
http://www.katzen.ag/board.php
KatzenAG - das grosse Katzenportal im Internet

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Universal field date - gallery and admin
« Reply #14 on: January 20, 2008, 11:04:11 PM »
I no see what is in live demo ... but the line you change is no show xx days ago ...
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?