Author Topic: Please, need total new images count.  (Read 39130 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Please, need total new images count.
« on: January 16, 2003, 05:39:04 PM »
maybe I missed something out there, but I can't find what I can use to count total of new images.
I have found in global.php
Code: [Select]
 $new_cutoff = time() - (60 * 60 * 24 * $config['new_cutoff']);
  $sql = "SELECT c.cat_id, c.cat_name, c.cat_description, c.cat_parent_id, c.cat_hits, c.cat_order, c.auth_viewcat, c.auth_viewimage, c.auth_download, c.auth_upload, c.auth_directupload, c.auth_vote, c.auth_sendpostcard, c.auth_readcomment, c.auth_postcomment, COUNT(i.image_id) AS new_images
          FROM ".CATEGORIES_TABLE." c
          LEFT JOIN ".IMAGES_TABLE." i ON (i.cat_id = c.cat_id AND i.image_date >= $new_cutoff AND i.image_active = 1)
          GROUP BY c.cat_id
          ORDER BY c.cat_order, c.cat_name ASC";
  $result = $site_db->query($sql);
I changed it to count also new images, it worked, but it counts all images without user access control restriction.
I would use something like
Code: [Select]
 $cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
but I dont know how to use it...
if someone would help me out with it.. :wink:
thx.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Please, need total new images count.
« Reply #1 on: January 16, 2003, 11:38:48 PM »
Find this part in includes/constants.php
Code: [Select]
$total_images = 0;
$total_categories = 0;
$auth_cat_sql['auth_viewcat']['IN'] = 0;
$auth_cat_sql['auth_viewcat']['NOTIN'] = 0;
if (!empty($cat_cache)) {
  foreach ($cat_cache as $key => $val) {
    if (check_permission("auth_viewcat", $key)) {
      $total_categories++;
      if (isset($val['num_images'])) {
        $total_images += $val['num_images'];
      }
      else {
        $cat_cache[$key]['num_images'] = 0;
      }
      $auth_cat_sql['auth_viewcat']['IN'] .= ", ".$key;
    }
    else {
      $cat_cache[$key]['num_images'] = 0;
      $auth_cat_sql['auth_viewcat']['NOTIN'] .= ", ".$key;
    }
  }
}

and change it to
Code: [Select]

$total_images = 0;
$total_new_images = 0;
$total_categories = 0;
$auth_cat_sql['auth_viewcat']['IN'] = 0;
$auth_cat_sql['auth_viewcat']['NOTIN'] = 0;
if (!empty($cat_cache)) {
  foreach ($cat_cache as $key => $val) {
    if (check_permission("auth_viewcat", $key)) {
      $total_categories++;
      if (isset($val['num_images'])) {
        $total_images += $val['num_images'];
      }
      else {
        $cat_cache[$key]['num_images'] = 0;
      }

      if (isset($val['new_images'])) {
        $total_new_images += $val['new_images'];
      }

      $auth_cat_sql['auth_viewcat']['IN'] .= ", ".$key;
    }
    else {
      $cat_cache[$key]['num_images'] = 0;
      $auth_cat_sql['auth_viewcat']['NOTIN'] .= ", ".$key;
    }
  }
}

After this part you will have the variable $total_new_image with the number of new images.

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Please, need total new images count.
« Reply #2 on: January 17, 2003, 01:52:24 AM »
Exelent, Jan, thank you very much!
just a little correction: it's in /includes/page_header.php
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Please, need total new images count.
« Reply #3 on: January 18, 2003, 05:15:08 PM »
You're right, sorry ;)

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline pierse

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Please, need total new images count.
« Reply #4 on: November 15, 2005, 05:01:03 PM »
I tried this but then I get other errors regarding the

Quote
} else {
  $data = unserialize($data);

  $total_images = $data['total_images'];
  $total_categories = $data['total_categories'];
  $auth_cat_sql['auth_viewcat']['IN'] = $data['auth_viewcat']['IN'];
  $auth_cat_sql['auth_viewcat']['NOTIN'] = $data['auth_viewcat']['NOTIN'];
}

and then my total numbers all disappear in my stats box.  Would really like to be able to have a total new images added to my stats.

Offline Acidgod

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 2.421
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: Please, need total new images count.
« Reply #5 on: November 15, 2005, 05:38:10 PM »
watch this:
«  am: Januar 16, 2003, 17:39:04 »

so i think it´s don´t work with the 1.7 and 1.7.1

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Please, need total new images count.
« Reply #6 on: November 16, 2005, 12:21:03 AM »
replace
Code: [Select]
$total_images = 0;
$total_categories = 0;
$auth_cat_sql['auth_viewcat']['IN'] = 0;
$auth_cat_sql['auth_viewcat']['NOTIN'] = 0;

$cache_id = create_cache_id(
  'cat.data.auth_and_info',
  array($user_info[$user_table_fields['user_id']])
);

if (!$data = get_cache_file($cache_id, null)) {
  if (!empty($cat_cache)) {
    foreach ($cat_cache as $key => $val) {
      if (check_permission("auth_viewcat", $key)) {
        $total_categories++;
        if (isset($val['num_images'])) {
          $total_images += $val['num_images'];
        }
        else {
          $cat_cache[$key]['num_images'] = 0;
        }
        $auth_cat_sql['auth_viewcat']['IN'] .= ", ".$key;
      }
      else {
        $auth_cat_sql['auth_viewcat']['NOTIN'] .= ", ".$key;
      }
    }
  }

  $data = array();

  $data['total_images'] = $total_images;
  $data['total_categories'] = $total_categories;
  $data['auth_viewcat']['IN'] = $auth_cat_sql['auth_viewcat']['IN'];
  $data['auth_viewcat']['NOTIN'] = $auth_cat_sql['auth_viewcat']['NOTIN'];

  save_cache_file($cache_id, serialize($data));

} else {
  $data = unserialize($data);

  $total_images = $data['total_images'];
  $total_categories = $data['total_categories'];
  $auth_cat_sql['auth_viewcat']['IN'] = $data['auth_viewcat']['IN'];
  $auth_cat_sql['auth_viewcat']['NOTIN'] = $data['auth_viewcat']['NOTIN'];
}
with this:
Code: [Select]
$total_new_images = 0;
$total_images = 0;
$total_categories = 0;
$auth_cat_sql['auth_viewcat']['IN'] = 0;
$auth_cat_sql['auth_viewcat']['NOTIN'] = 0;

$cache_id = create_cache_id(
  'cat.data.auth_and_info',
  array($user_info[$user_table_fields['user_id']])
);

if (!$data = get_cache_file($cache_id, null)) {
  if (!empty($cat_cache)) {
    foreach ($cat_cache as $key => $val) {
      if (check_permission("auth_viewcat", $key)) {
        $total_categories++;
        if (isset($val['num_images'])) {
          $total_images += $val['num_images'];
        }
        else {
          $cat_cache[$key]['num_images'] = 0;
        }
        if (isset($val['new_images'])) {
         $total_new_images += $val['new_images'];
        }
        $auth_cat_sql['auth_viewcat']['IN'] .= ", ".$key;
      }
      else {
        $auth_cat_sql['auth_viewcat']['NOTIN'] .= ", ".$key;
      }
    }
  }

  $data = array();

  $data['total_images'] = $total_images;
  $data['total_new_images'] = $total_images;
  $data['total_categories'] = $total_categories;
  $data['auth_viewcat']['IN'] = $auth_cat_sql['auth_viewcat']['IN'];
  $data['auth_viewcat']['NOTIN'] = $auth_cat_sql['auth_viewcat']['NOTIN'];

  save_cache_file($cache_id, serialize($data));

} else {
  $data = unserialize($data);

  $total_images = $data['total_images'];
  $total_new_images = $data['total_new_images'];
  $total_categories = $data['total_categories'];
  $auth_cat_sql['auth_viewcat']['IN'] = $data['auth_viewcat']['IN'];
  $auth_cat_sql['auth_viewcat']['NOTIN'] = $data['auth_viewcat']['NOTIN'];
}
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline pierse

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Please, need total new images count.
« Reply #7 on: November 18, 2005, 10:06:53 PM »
how do you pull the total_new_images number?  I have everything as Vano has above.... as well as this in my stats_box.html template. 

Quote
<td align="left" width=60%>

           {lang_total_images}<br>
          {lang_new_images}:<br>

           {lang_total_categories}<br>

           {lang_total_users}<br>

           {lang_total_hits}<br>

           {lang_total_downloads}<br>

           {lang_total_votes}<br>

           {lang_total_comments}<br>
 {lang_total_rating}<br>



         </td>

         <td align="right" width="40%">

           <B>{total_images}</B><br>
<B>{total_new_images}</B><br>

           <B>{total_categories}</B><br>

           <B>{total_users}</B><br>

           <B>{total_hits}</B><br>

           <B>{total_downloads}</B><br>

           <B>{total_votes}</B><br>

           <B>{total_comments}</B><br>

<B>{total_rating}</B><br>

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Please, need total new images count.
« Reply #8 on: November 19, 2005, 12:24:03 AM »
You get the number in $total_new_images variable, and you will need register it as a template tag, the same way as $total_images does (you will figure it out) ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline pierse

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Please, need total new images count.
« Reply #9 on: November 19, 2005, 02:45:44 PM »
well... I pieced together this... put it in the stats.php file....

Quote
//-----------------------------------------------------
//----------NEW IMAGES---------------------------------
//-----------------------------------------------------
  $new_cutoff = time() - 60 * 60 * 24 * $new_cutoff;
  $sql = "SELECT COUNT(*) AS total_new_images
          FROM ".IMAGES_TABLE."
          WHERE image_active = 1 AND image_date > ".$new_cutoff;
  $row = $site_db->query_firstrow($sql);
  $show['total_new_images'] = $row['total_new_images'];
$site_template->register_vars(array(
  "new_images" => $total_new_images));
  unset($total_new_images);

And all I get is a fat 0 :(

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: Please, need total new images count.
« Reply #10 on: November 22, 2005, 05:35:36 PM »
hallo,
this is my result in the stats.php
Code: [Select]
// --- Total new images -----
  $new_cutoff = time() - 60 * 60 * 24 * $new_cutoff;
  $sql = "SELECT COUNT(*) AS total_new_images
          FROM ".IMAGES_TABLE."
          WHERE image_active = 1 AND image_date > ".$new_cutoff;
  $row = $site_db->query_firstrow($sql);
  $total_new_images = $row['total_new_images'];
$site_template->register_vars(array(
  "total_new_images" => $total_new_images));
  unset($total_new_images);

And all I get is the total images..  :cry:
any help?

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Please, need total new images count.
« Reply #11 on: November 22, 2005, 05:46:51 PM »
hast du vorher $new_cutoff definiert ?

Code: [Select]
$new_cutoff = $config['new_cutoff']; //Days when images treated as new

mawenzi
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: Please, need total new images count.
« Reply #12 on: November 22, 2005, 07:07:39 PM »
hallo!
danke! jetzt geht's!
------------------------------------------

Thank you!
now it works!

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Please, need total new images count.
« Reply #13 on: November 27, 2005, 08:40:19 PM »
@  ivan

nimm den Code von Loda und setze meine gepostete Codzeile davor ... dann klapps auch ...  :wink:
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Please, need total new images count.
« Reply #14 on: November 27, 2005, 10:30:25 PM »
in main.php ... : $lang['total_new'] = "Neue Bilder:";

in home.html ... : {lang_total_new} {total_new_images}
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...