Author Topic: [MOD] - Categories users sessions  (Read 23226 times)

0 Members and 1 Guest are viewing this topic.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
[MOD] - Categories users sessions
« on: September 09, 2007, 02:10:45 PM »
Hi, I create MOD for categories users sessions. Each user visit categories can see for session in categories foreach category ID (live). 8)

If category active - show.
If category no active - no show.
If user invisible - show * (same includes/sessions.php file). No show for user (is admin).
No HTML in PHP - all HTML template.

// Step 1

In categories.php file,

find:

Quote
unset($thumbnails);

add after:

Code: [Select]
// MOD: Categories users sessions.
$categories_time_out = time() - 300;
$categories_guest_level_sessions_counter = 0;

$additional_sql = "";
$additional_sql_array = array();
if (isset($additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
    foreach ($additional_user_fields as $key => $val) {
        $additional_sql .= ", u." . $key;
        $additional_sql_array[] = $key;
    }
}

if (function_exists('get_categories_sessions_info') && $user_info['user_level'] == GUEST) {
    get_categories_sessions_info($site_sess->session_id, 'check_sessions_table');
}

if (function_exists('get_categories_sessions_info') && $user_info['user_level'] >= USER) {
    get_categories_sessions_info($user_info['user_id'], 'check_sessions_table');
}

$sql1 = "

SELECT cst.cat_id, s.session_user_id" . get_user_table_field(", u.", "user_name") . get_user_table_field(", u.", "user_level") . get_user_table_field(", u.", "user_invisible") . $additional_sql . "
FROM (" . SESSIONS_TABLE . " s, " . CATEGORIES_SESSIONS_TABLE . " cst)
LEFT JOIN " . USERS_TABLE . " u ON (" . get_user_table_field("u.", "user_id") . " = s.session_user_id)
WHERE cst.user_id = s.session_user_id AND cst.cat_id = " . $cat_id . " AND cst.cat_sessions_microtime >= " . $categories_time_out . " AND s.session_user_id > '" . GUEST . "'
GROUP BY s.session_user_id
ORDER BY " . get_user_table_field("u.", "user_id") . " ASC, s.session_ip ASC";

$sessions_categories_result = $site_db->query($sql1);
$categories_num_rows = $site_db->get_numrows($sessions_categories_result);

if (isset($categories_num_rows) && $categories_num_rows > 0) {

$categories_sessions_template = "";

$categories_invisible_sessions_counter = 0;
$categories_registered_users_sessions_counter = 0;
$session_categories_id = 0;
while ($sessions_category_row = $site_db->fetch_array($sessions_categories_result)) {
    if ($sessions_category_row[$user_table_fields['user_invisible']] == 1) {
        $categories_invisible_sessions_counter++;
    }
    if ($sessions_category_row[$user_table_fields['user_level']] >= USER) {
        $categories_registered_users_sessions_counter++;
    }    
    $session_categories_user_id = $sessions_category_row['session_user_id'];
    $session_categories_id .= $sessions_category_row['cat_id'];
    $session_categories_name = $sessions_category_row[$user_table_fields['user_name']];
    $session_categories_invisible = $sessions_category_row[$user_table_fields['user_invisible']];
    
    $site_template->register_vars(array(
    "session_categories_user_url" => $site_sess->url(ROOT_PATH . "member.php?action=showprofile&" . URL_USER_ID . "=" . $session_categories_user_id),
    "session_categories_user_id" => (int)$session_categories_user_id,    
    "session_categories_name" => format_text(stripslashes($session_categories_name), 2),
    "session_categories_invisible" => ($session_categories_invisible == 1) ? 1 : 0,
    "invisible_categories_chars" => $lang['categories_notify_invisible_chars'],
    "need_separator" => (isset($categories_num_rows) && $categories_num_rows > 1) ? true : false
    ));
    
    if (isset($additional_sql_array) && is_array($additional_sql_array) && !empty($additional_sql_array)) {
        foreach ($additional_sql_array as $key => $val) {
            if ($val == $sessions_category_row[$val]) {
                $site_template->register_vars($val, $sessions_category_row[$val]);
            }
        }
    }
    $categories_sessions_template .= $site_template->parse_template("categories_sessions_content");
    
    }
    }

$sql2 = "

SELECT s.session_user_id" . $additional_sql . "
FROM (" . SESSIONS_TABLE . " s, " . CATEGORIES_SESSIONS_TABLE . " cst)
LEFT JOIN " . USERS_TABLE . " u ON (" . get_user_table_field("u.", "user_id") . " = s.session_user_id)
WHERE cst.cat_id = " . $cat_id . " AND cst.cat_sessions_microtime >= " . $categories_time_out . " AND s.session_user_id = '" . GUEST . "'
GROUP BY s.session_ip";

$sessions_guest_categories_result = $site_db->query($sql2);
$sessions_guest_num_rows = $site_db->get_numrows($sessions_guest_categories_result);

if (isset($sessions_guest_num_rows) && $sessions_guest_num_rows > 0) {
    while ($sessions_categories_guest_row = $site_db->fetch_array($sessions_guest_categories_result)) {
        $categories_guest_level_sessions_counter++;
    }
}
$total_categories_sessions = $categories_registered_users_sessions_counter + $categories_guest_level_sessions_counter;

// End of MOD: Categories users sessions.

Find:

Quote
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream

replace:

Code: [Select]
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream,
  // MOD: Image users sessions.  
  "lang_categories_notify_sessions_title" => $lang['categories_notify_sessions_title'],
  "lang_categories_notify_current_sessions_title" => $lang['categories_notify_current_sessions_title'],
  "categories_sessions_template" => (isset($categories_sessions_template)) ? trim($categories_sessions_template) : "",
  "total_invisible_categories_sessions" => (isset($categories_invisible_sessions_counter)) ? preg_replace("/" . $site_template->start . "invisible_count" . $site_template->end . "/siU", (int)$categories_invisible_sessions_counter, $lang['categories_notify_invisible_count']) : preg_replace("/" . $site_template->start . "invisible_count" . $site_template->end . "/siU", 0, $lang['categories_notify_invisible_count']),
  "total_registered_users_categories_sessions" => (isset($categories_registered_users_sessions_counter)) ? preg_replace("/" . $site_template->start . "registered_users_count" . $site_template->end . "/siU", (int)$categories_registered_users_sessions_counter, $lang['categories_notify_registered_users_count']) : preg_replace("/" . $site_template->start . "registered_users_count" . $site_template->end . "/siU", 0, $lang['categories_notify_registered_users_count']),
  "total_guest_level_categories_sessions" => (isset($categories_guest_level_sessions_counter)) ? preg_replace("/" . $site_template->start . "guest_level_count" . $site_template->end . "/siU", (int)$categories_guest_level_sessions_counter, $lang['categories_notify_guest_level_count']) : preg_replace("/" . $site_template->start . "guest_level_count" . $site_template->end . "/siU", 0, $lang['categories_notify_guest_level_count']),
  "total_categories_sessions" => (isset($total_categories_sessions)) ? (int)$total_categories_sessions : false,  
  // End of MOD: Image users sessions.

// Step 2

In includes/functions.php file,

add top ?>:

Code: [Select]
// MOD: Categories sessions user.
function get_categories_sessions_info($user_id = -1, $status = "") {
    global $site_db, $session_info, $cat_id, $user_table_fields, $table_prefix;

    if (!isset($user_id) || $user_id == -1) {
        return;
    }    

    if (!isset($status) || $status == "") {
        return;
    }    

    if (isset($user_id) && $user_id > 0) {
        $user_id = preg_replace("/[^0-9]+/i", "", $user_id);

        if ($user_row = get_user_info($user_id)) {
            if ($user_id != $user_row[$user_table_fields['user_id']]) {
                return;
            }
            unset ($user_row);
        }
        $status = preg_replace("/[^A-Za-z0-9\_]+/i", "", $status);

        

        $date = date('Y-m-d');
        $time = date('H:i:s');
        $microtime = time();        

        switch($status) {            

            case 'check_sessions_table' :            

            if (!defined('CATEGORIES_SESSIONS_TABLE')) {                
                define('CATEGORIES_SESSIONS_TABLE', $table_prefix . "categories_sessions");
            }              

                $sql = "              

                CREATE TABLE IF NOT EXISTS " . CATEGORIES_SESSIONS_TABLE . " (
                field_id INT(11) NOT NULL AUTO_INCREMENT,
                user_id VARCHAR(32) NOT NULL DEFAULT '0',
                cat_id INT(11) NOT NULL DEFAULT '0',
                cat_sessions_date VARCHAR(48) NOT NULL DEFAULT '0000-00-00',
                cat_sessions_time VARCHAR(48) NOT NULL DEFAULT '00:00:00',
                cat_sessions_microtime VARCHAR(255) NOT NULL DEFAULT '0',
                cat_sessions_ip VARCHAR(48) NOT NULL DEFAULT '0.0.0.0',
                PRIMARY KEY (field_id)
                ) TYPE=MyISAM;              

                ";              

                $result = $site_db->query($sql);

                $sql = "SELECT user_id, cat_id FROM " . CATEGORIES_SESSIONS_TABLE . " WHERE user_id = " . $user_id . " AND cat_id = " . $cat_id;
                $result = $site_db->query($sql);
                $num_rows = $site_db->get_numrows($result);
                
                if (isset($num_rows) && $num_rows <= 0) {
                    
                    $cat_sessions_ip = $session_info['session_ip'];

                    $sql1 = "                  

                    INSERT INTO " . CATEGORIES_SESSIONS_TABLE . "
                    (field_id, user_id, cat_id, cat_sessions_date, cat_sessions_time, cat_sessions_microtime, cat_sessions_ip)
                    VALUES (NULL, '" . $user_id . "', '" . $cat_id . "', '" . $date . "', '" . $time . "', '" . $microtime . "', '" . $cat_sessions_ip . "')

                    ";                  

                    $result = $site_db->query($sql1);                    
                }
                
                $get_sessions_microtime = $microtime - 300;
                
                if (isset($num_rows) && $num_rows > 0) {                    
                        $site_db->query("DELETE FROM " . CATEGORIES_SESSIONS_TABLE . " WHERE cat_sessions_microtime < " . $get_sessions_microtime);
                        //$site_db->query("UPDATE " . CATEGORIES_SESSIONS_TABLE . " SET cat_sessions_microtime = '" . $microtime . "', cat_id = '" . $cat_id . "' WHERE user_id = '" . $user_id . "'");
                }
                
                return $user_id;
                break;        
        }
    }
}
// End of MOD: Categories sessions user.

// Step 3

If no install:

http://www.4homepages.de/forum/index.php?topic=18572.0
or
http://www.4homepages.de/forum/index.php?topic=18573.0

find:

Quote
$this->current_time = time();

add before:

Code: [Select]
$this->current_date = date('Y-m-d');
$this->current_clocktime = date('H:i:s');

Find:

Quote
function logout($user_id) {
    global $site_db;
    $sql = "DELETE FROM ".SESSIONS_TABLE."
            WHERE session_id = '".addslashes($this->session_id)."' OR session_user_id = " . $user_id;
    $site_db->query($sql);    
    
    $this->set_cookie_data("userpass", "", 0);
    $this->set_cookie_data("userid", GUEST);

    $this->session_info = array();

    return true;
  }

replace:

Code: [Select]
function logout($user_id) {
    global $site_db;
    $sql = "DELETE FROM ".SESSIONS_TABLE."
            WHERE session_id = '".addslashes($this->session_id)."' OR session_user_id = " . $user_id;
    $site_db->query($sql);
    $sql = "DELETE FROM " . CATEGORIES_SESSIONS_TABLE . "
            WHERE user_id = '" . addslashes($this->session_id) ."' OR user_id = " . $user_id;
    $site_db->query($sql);
    
    $this->set_cookie_data("userpass", "", 0);
    $this->set_cookie_data("userid", GUEST);

    $this->session_info = array();

    return true;
  }

Find:

Quote
function update_session() {
    global $site_db;

replace:

Code: [Select]
function update_session() {
    global $site_db, $cat_id, $url;

If no install:

http://www.4homepages.de/forum/index.php?topic=18572.0
or
http://www.4homepages.de/forum/index.php?topic=18573.0

replace:

Code: [Select]
function update_session() {
    global $site_db, $cat_id, $image_id, $url;

Find:

Quote
$this->session_info['session_lastaction'] = $this->current_time;
$this->session_info['session_location'] = $this->user_location;
$this->session_info['session_ip'] = $this->user_ip;

add after:

Code: [Select]
if (preg_match("/categories.php/", $url)) {          
    
    $sql = "REPLACE INTO " . CATEGORIES_SESSIONS_TABLE . "
            (field_id, user_id, cat_id, cat_sessions_date, cat_sessions_time, cat_sessions_microtime)
            VALUES (NULL, '" . addslashes($this->session_id) . "', '" . $cat_id . "', '" . $this->current_date . "', '" . $this->current_clocktime . "', $this->current_time)                  
            
           ";          
    $site_db->query($sql);
    
    }

Find:

Quote
if ($this->user_info['user_id'] != GUEST) {
      $sql = "UPDATE ".USERS_TABLE."
              SET ".get_user_table_field("", "user_lastaction")." = $this->current_time, ".get_user_table_field("", "user_location")." = '$this->user_location'
              WHERE ".get_user_table_field("", "user_id")." = ".$this->user_info['user_id'];
      $site_db->query($sql);            
    }

replace:

Code: [Select]
if ($this->user_info['user_id'] != GUEST) {
      $sql = "UPDATE ".USERS_TABLE."
              SET ".get_user_table_field("", "user_lastaction")." = $this->current_time, ".get_user_table_field("", "user_location")." = '$this->user_location'
              WHERE ".get_user_table_field("", "user_id")." = ".$this->user_info['user_id'];
      $site_db->query($sql);                  
      $sql3 = "DELETE FROM " . CATEGORIES_SESSIONS_TABLE . " WHERE user_id = '" . GUEST . "' AND cat_sessions_ip = '" . $this->user_ip . "'";
      $site_db->query($sql3);
}

// Step 4

In lang/english/main.php file,

add top ?>:

Code: [Select]
// MOD: Categories sessions.
//-----------------------------------------------------
//--- Categories sessions -----------------------------
//-----------------------------------------------------
$lang['categories_notify_count'] = "Total: {count}";
$lang['categories_notify_sessions_title'] = "Currently active image users: ";
$lang['categories_notify_invisible_chars'] = "*";
$lang['categories_notify_current_sessions_title'] = "There are currently ";
$lang['categories_notify_registered_users_count'] = "<b>{registered_users_count}</b> registered user(s) ";
$lang['categories_notify_invisible_count'] = "({invisible_count} among them invisible) ";
$lang['categories_notify_guest_level_count'] = "and <b>{guest_level_count}</b> guest(s) online.";

// Step 5

In templates/your_template/categories.html file,

find:

Quote
{paging}
<br />
<br />

add after:

Code: [Select]
{if is_admin}<! -- Categories users sessions -- >{endif is_admin}  
<table width="100%" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <td valign="top" class="head1">&nbsp;{lang_categories_notify_sessions_title} {total_categories_sessions}</td>
 </tr>
   </table>  
 <table width="100%" border="0" cellpadding="0" cellspacing="0">
 <tr>  
   <td class="row1">&nbsp;{lang_categories_notify_current_sessions_title} {total_registered_users_categories_sessions} {total_invisible_categories_sessions} {total_guest_level_categories_sessions}</td>
 </tr>
    </table>
 <table width="100%" border="0" cellpadding="0" cellspacing="0">
 <tr>
  {if categories_sessions_template}<td width="100%" class="row1" />&nbsp;{categories_sessions_template}</td>{endif categories_sessions_template}
  {if sessions_categories_no_content_msg}<td width="100%" class="row1" align="center" /><b>{sessions_categories_no_content_msg}</b></td>{endif sessions_categories_no_content_msg}
 </tr>  
                        </table>          
 <br />
 {if is_admin}<! -- End of Categories users sessions -- >{endif is_admin}

// Step 6

In includes/constants.php file,

find:

Quote
define('CATEGORIES_TABLE', $table_prefix.'categories');

add after:

Code: [Select]
define('CATEGORIES_SESSIONS_TABLE', $table_prefix . "categories_sessions");

// Step 7

In templates/your_template , create file: categories_sessions_content.html.

Add:

Code: [Select]
{if is_admin}{if session_comment_invisible}<a href="{session_comment_user_url}"><b>{session_comment_name}</b></a>{invisible_comment_chars}{if need_separator} {endif need_separator}&nbsp;{endif session_comment_invisible}{endif is_admin}
{if user_loggedin}{ifnot session_comment_invisible}<a href="{session_comment_user_url}"><b>{session_comment_name}</b></a>{if need_separator} {endif need_separator}&nbsp;{endifnot session_comment_invisible}{endif user_loggedin}

All done. 8)

(For fix - reset table).
« Last Edit: February 18, 2011, 02:03:50 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] - Categories users sessions
« Reply #1 on: September 09, 2007, 02:59:03 PM »
/* Fix */

- Step 1 (09/09/2007)
- Step 2 (09/09/2007)
- Step 3 (09/09/2007)
- Step 7 (09/09/2007)
« Last Edit: September 09, 2007, 05:31:22 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 ccsakuweb

  • Sr. Member
  • ****
  • Posts: 498
  • Patri
    • View Profile
    • My Art
Re: [MOD] - Categories users sessions
« Reply #2 on: February 02, 2008, 05:59:20 PM »
hi, i installed this mod.. but im not sure.. i dont know what you means with categories users sessions.. em.. i thought that in each category i would see how many users see the same category like me. but i think that the number is the people that see all categories right? is posible only see the number of people that see only the current category?

there is a lot of different between number of people from yout mod (in categories) that inde.php. why?? the number of index is only the number of people visiting index.php??
:arrow: 4images Paid Mods: Links, Blog, Albums, Subdomains for users, Diferent templates for user profile, Related picture in details, Last pictures in details.
And the mod that you request me.   Demo: http://www.myart.es

A website dedicated to artist people who loves drawing, design, writing and more

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Categories users sessions
« Reply #3 on: February 02, 2008, 06:23:27 PM »
Quote
is posible only see the number of people that see only the current category?

This MOD is work this way. Each visit is see for each user name session for each category page.

Quote
the number of index is only the number of people visiting index.php??

No - this is for categories.php file.
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 ccsakuweb

  • Sr. Member
  • ****
  • Posts: 498
  • Patri
    • View Profile
    • My Art
Re: [MOD] - Categories users sessions
« Reply #4 on: February 04, 2008, 12:39:58 PM »
Quote

This MOD is work this way. Each visit is see for each user name session for each category page.

sure?? i saw in admin control panel and i the total of people online, it was less than the number in one category with your mod.
i think the number in the category should be lower that the number in control panel home, right? but it isnt
:arrow: 4images Paid Mods: Links, Blog, Albums, Subdomains for users, Diferent templates for user profile, Related picture in details, Last pictures in details.
And the mod that you request me.   Demo: http://www.myart.es

A website dedicated to artist people who loves drawing, design, writing and more

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - Categories users sessions
« Reply #5 on: February 04, 2008, 01:37:02 PM »
Quote
i think the number in the category should be lower that the number in control panel home, right? but it isnt

Admin panel ? What admin panel ? This MOD is for gallery category page. Nothing is say in first post for admin panel. Please read instruction again. :?
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.408
    • View Profile
    • 4images - Image Gallery Management System
Re: [MOD] - Categories users sessions
« Reply #6 on: February 05, 2008, 02:39:11 PM »
Any demo of this mod 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] - Categories users sessions
« Reply #7 on: February 05, 2008, 02:42:38 PM »
No.
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 Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [MOD] - Categories users sessions
« Reply #8 on: February 05, 2008, 07:19:25 PM »
dear thunderstrike,

it would be fine to setup one/more galleries with your mods to show what they do?
« Last Edit: February 07, 2008, 05:31:49 PM by Nicky »
cheers
Nicky
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 ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline Benny Change

  • Addicted member
  • ******
  • Posts: 1.788
  • #WWG1WGA
    • View Profile
    • Qlobal-Change
Re: [MOD] - Categories users sessions
« Reply #9 on: June 04, 2009, 09:16:00 AM »
Wow!
Das klappt wirklich sehr gut. Aber wie kann ich das auch in der category_bit.html anzeigen?
Ich bitte um Hilfe!

----

Wow!
That works really good. But how can I category_bit.html also in the show?
I ask for help!
Beste Grüße
Benny

Offline Benny Change

  • Addicted member
  • ******
  • Posts: 1.788
  • #WWG1WGA
    • View Profile
    • Qlobal-Change
Re: [MOD] - Categories users sessions
« Reply #10 on: June 04, 2009, 11:31:28 AM »
Please help me :(
Beste Grüße
Benny

Offline Benny Change

  • Addicted member
  • ******
  • Posts: 1.788
  • #WWG1WGA
    • View Profile
    • Qlobal-Change
 :flag-de: Information


Die Modifikation basiert auf den Code von Thunderstrike
Mit dieser Modifikation wird in der Kategorieansicht gezeigt, welche User online sind.

- Unsichtbare User werden gelistet
- Gesamt aktive User
- Und Gäste


:flag-en: Information


Mod Based on Thunderstrikes Code
With this modification is in Category View shows which users are online.

- Invisible users are listed
- Total active users
- And Guests

// Step 1

Open / Öffne: categories.php
Find / Finde:


unset($thumbnails);


add after / füge darunter:


// MOD: Categories users sessions.
$categories_time_out time() - 300;
$categories_guest_level_sessions_counter 0;

$additional_sql "";
$additional_sql_array = array();
if (isset(
$additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
    foreach (
$additional_user_fields as $key => $val) {
        
$additional_sql .= ", u." $key;
        
$additional_sql_array[] = $key;
    }
}

if (
function_exists('get_categories_sessions_info') && $user_info['user_level'] == GUEST) {
    
get_categories_sessions_info($site_sess->session_id'check_sessions_table');
}

if (
function_exists('get_categories_sessions_info') && $user_info['user_level'] >= USER) {
    
get_categories_sessions_info($user_info['user_id'], 'check_sessions_table');
}

$sql1 "

SELECT cst.cat_id, s.session_user_id" 
get_user_table_field(", u.""user_name") . get_user_table_field(", u.""user_level") . get_user_table_field(", u.""user_invisible") . $additional_sql "
FROM (" 
SESSIONS_TABLE " s, " CATEGORIES_SESSIONS_TABLE " cst)
LEFT JOIN " 
USERS_TABLE " u ON (" get_user_table_field("u.""user_id") . " = s.session_user_id)
WHERE cst.user_id = s.session_user_id AND cst.cat_id = " 
$cat_id " AND cst.cat_sessions_microtime >= " $categories_time_out " AND s.session_user_id > '" GUEST "'
GROUP BY s.session_user_id
ORDER BY " 
get_user_table_field("u.""user_id") . " ASC, s.session_ip ASC";

$sessions_categories_result $site_db->query($sql1);
$categories_num_rows $site_db->get_numrows($sessions_categories_result);

if (isset(
$categories_num_rows) && $categories_num_rows 0) {

$categories_sessions_template "";

$categories_invisible_sessions_counter 0;
$categories_registered_users_sessions_counter 0;
$session_categories_id 0;
while (
$sessions_category_row $site_db->fetch_array($sessions_categories_result)) {
    if (
$sessions_category_row[$user_table_fields['user_invisible']] == 1) {
        
$categories_invisible_sessions_counter++;
    }
    if (
$sessions_category_row[$user_table_fields['user_level']] >= USER) {
        
$categories_registered_users_sessions_counter++;
    }    
    
$session_categories_user_id $sessions_category_row['session_user_id'];
    
$session_categories_id .= $sessions_category_row['cat_id'];
    
$session_categories_name $sessions_category_row[$user_table_fields['user_name']];
    
$session_categories_invisible $sessions_category_row[$user_table_fields['user_invisible']];
    
    
$site_template->register_vars(array(
    
"session_categories_user_url" => $site_sess->url(ROOT_PATH "member.php?action=showprofile&" URL_USER_ID "=" $session_categories_user_id),
    
"session_categories_user_id" => (int)$session_categories_user_id,    
    
"session_categories_name" => format_text(stripslashes($session_categories_name), 2),
    
"session_categories_invisible" => ($session_categories_invisible == 1) ? 0,
    
"invisible_categories_chars" => $lang['categories_notify_invisible_chars'],
    
"need_separator" => (isset($categories_num_rows) && $categories_num_rows 1) ? true false
    
));
    
    if (isset(
$additional_sql_array) && is_array($additional_sql_array) && !empty($additional_sql_array)) {
        foreach (
$additional_sql_array as $key => $val) {
            if (
$val == $sessions_category_row[$val]) {
                
$site_template->register_vars($val$sessions_category_row[$val]);
            }
        }
    }
    
$categories_sessions_template .= $site_template->parse_template("categories_sessions_content");
    
    }
    }

$sql2 "

SELECT s.session_user_id" 
$additional_sql "
FROM (" 
SESSIONS_TABLE " s, " CATEGORIES_SESSIONS_TABLE " cst)
LEFT JOIN " 
USERS_TABLE " u ON (" get_user_table_field("u.""user_id") . " = s.session_user_id)
WHERE cst.cat_id = " 
$cat_id " AND cst.cat_sessions_microtime >= " $categories_time_out " AND s.session_user_id = '" GUEST "'
GROUP BY s.session_ip"
;

$sessions_guest_categories_result $site_db->query($sql2);
$sessions_guest_num_rows $site_db->get_numrows($sessions_guest_categories_result);

if (isset(
$sessions_guest_num_rows) && $sessions_guest_num_rows 0) {
    while (
$sessions_categories_guest_row $site_db->fetch_array($sessions_guest_categories_result)) {
        
$categories_guest_level_sessions_counter++;
    }
}
$total_categories_sessions $categories_registered_users_sessions_counter $categories_guest_level_sessions_counter;

// End of MOD: Categories users sessions.


Find / Finde:


$site_template
->register_vars(array(
  
"msg" => $msg,
  
"clickstream" => $clickstream


replace / ersetze mit:


$site_template
->register_vars(array(
  
"msg" => $msg,
  
"clickstream" => $clickstream,
  
// MOD: Image users sessions.  
  
"lang_categories_notify_sessions_title" => $lang['categories_notify_sessions_title'],
  
"lang_categories_notify_current_sessions_title" => $lang['categories_notify_current_sessions_title'],
  
"categories_sessions_template" => (isset($categories_sessions_template)) ? trim($categories_sessions_template) : "",
  
"total_invisible_categories_sessions" => (isset($categories_invisible_sessions_counter)) ? preg_replace("/" $site_template->start "invisible_count" $site_template->end "/siU", (int)$categories_invisible_sessions_counter$lang['categories_notify_invisible_count']) : preg_replace("/" $site_template->start "invisible_count" $site_template->end "/siU"0$lang['categories_notify_invisible_count']),
  
"total_registered_users_categories_sessions" => (isset($categories_registered_users_sessions_counter)) ? preg_replace("/" $site_template->start "registered_users_count" $site_template->end "/siU", (int)$categories_registered_users_sessions_counter$lang['categories_notify_registered_users_count']) : preg_replace("/" $site_template->start "registered_users_count" $site_template->end "/siU"0$lang['categories_notify_registered_users_count']),
  
"total_guest_level_categories_sessions" => (isset($categories_guest_level_sessions_counter)) ? preg_replace("/" $site_template->start "guest_level_count" $site_template->end "/siU", (int)$categories_guest_level_sessions_counter$lang['categories_notify_guest_level_count']) : preg_replace("/" $site_template->start "guest_level_count" $site_template->end "/siU"0$lang['categories_notify_guest_level_count']),
  
"total_categories_sessions" => (isset($total_categories_sessions)) ? (int)$total_categories_sessions false,  
  
// End of MOD: Image users sessions.


// Step 2

Open / Öffne: includes/functions.php
Add top / Füge vor:
?>
this / das ein:


// MOD: Categories sessions user.
function get_categories_sessions_info($user_id = -1$status "") {
    global 
$site_db$session_info$cat_id$user_table_fields$table_prefix;

    if (!isset(
$user_id) || $user_id == -1) {
        return;
    }    

    if (!isset(
$status) || $status == "") {
        return;
    }    

    if (isset(
$user_id) && $user_id 0) {
        
$user_id preg_replace("/[^0-9]+/i"""$user_id);

        if (
$user_row get_user_info($user_id)) {
            if (
$user_id != $user_row[$user_table_fields['user_id']]) {
                return;
            }
            unset (
$user_row);
        }
        
$status preg_replace("/[^A-Za-z0-9\_]+/i"""$status);

        

        
$date date('Y-m-d');
        
$time date('H:i:s');
        
$microtime time();        

        switch(
$status) {            

            case 
'check_sessions_table' :            

            if (!
defined('CATEGORIES_SESSIONS_TABLE')) {                
                
define('CATEGORIES_SESSIONS_TABLE'$table_prefix "categories_sessions");
            }               

                
$sql "               

                CREATE TABLE IF NOT EXISTS " 
CATEGORIES_SESSIONS_TABLE " (
                field_id INT(11) NOT NULL AUTO_INCREMENT,
                user_id VARCHAR(32) NOT NULL DEFAULT '0',
                cat_id INT(11) NOT NULL DEFAULT '0',
                cat_sessions_date VARCHAR(48) NOT NULL DEFAULT '0000-00-00',
                cat_sessions_time VARCHAR(48) NOT NULL DEFAULT '00:00:00',
                cat_sessions_microtime VARCHAR(255) NOT NULL DEFAULT '0',
                cat_sessions_ip VARCHAR(48) NOT NULL DEFAULT '0.0.0.0',
                PRIMARY KEY (field_id)
                ) TYPE=MyISAM;              

                "
;               

                
$result $site_db->query($sql);

                
$sql "SELECT user_id, cat_id FROM " CATEGORIES_SESSIONS_TABLE " WHERE user_id = " $user_id " AND cat_id = " $cat_id;
                
$result $site_db->query($sql);
                
$num_rows $site_db->get_numrows($result);
                
                if (isset(
$num_rows) && $num_rows <= 0) {
                    
                    
$cat_sessions_ip $session_info['session_ip'];

                    
$sql1 "                   

                    INSERT INTO " 
CATEGORIES_SESSIONS_TABLE "
                    (field_id, user_id, cat_id, cat_sessions_date, cat_sessions_time, cat_sessions_microtime, cat_sessions_ip)
                    VALUES (NULL, '" 
$user_id "', '" $cat_id "', '" $date "', '" $time "', '" $microtime "', '" $cat_sessions_ip "')

                    "
;                   

                    
$result $site_db->query($sql1);                    
                }
                
                
$get_sessions_microtime $microtime 300;
                
                if (isset(
$num_rows) && $num_rows 0) {                    
                        
$site_db->query("DELETE FROM " CATEGORIES_SESSIONS_TABLE " WHERE cat_sessions_microtime < " $get_sessions_microtime);
                        
//$site_db->query("UPDATE " . CATEGORIES_SESSIONS_TABLE . " SET cat_sessions_microtime = '" . $microtime . "', cat_id = '" . $cat_id . "' WHERE user_id = '" . $user_id . "'");
                
}
                
                return 
$user_id;
                break;        
        }
    }
}
// End of MOD: Categories sessions user.


// Step 3

Open / Öffne: inlcude/sessions.php

find / finde:


$this
->current_time time();


add before / füge davor ein:


$this
->current_date date('Y-m-d');
$this->current_clocktime date('H:i:s');


Find / Finde:


function logout($user_id) {
    global 
$site_db;
    
$sql "DELETE FROM ".SESSIONS_TABLE."
            WHERE session_id = '"
.addslashes($this->session_id)."' OR session_user_id = " $user_id;
    
$site_db->query($sql);    
    
    
$this->set_cookie_data("userpass"""0);
    
$this->set_cookie_data("userid"GUEST);

    
$this->session_info = array();

    return 
true;
  }


replace / ersetze mit:


function logout($user_id) {
    global 
$site_db;
    
$sql "DELETE FROM ".SESSIONS_TABLE."
            WHERE session_id = '"
.addslashes($this->session_id)."' OR session_user_id = " $user_id;
    
$site_db->query($sql);
    
$sql "DELETE FROM " CATEGORIES_SESSIONS_TABLE "
            WHERE user_id = '" 
addslashes($this->session_id) ."' OR user_id = " $user_id;
    
$site_db->query($sql);
    
    
$this->set_cookie_data("userpass"""0);
    
$this->set_cookie_data("userid"GUEST);

    
$this->session_info = array();

    return 
true;
  }


Find / Finde:


function update_session() {
    global 
$site_db;


replace / ersetze mit:


function update_session() {
     global 
$site_db$cat_id$image_id$url;



Find / Finde:


$this
->session_info['session_lastaction'] = $this->current_time;
$this->session_info['session_location'] = $this->user_location;
$this->session_info['session_ip'] = $this->user_ip;


add after / füge darunter:


if (ereg("categories.php"$url)) {           
    
    
$sql "REPLACE INTO " CATEGORIES_SESSIONS_TABLE "
            (field_id, user_id, cat_id, cat_sessions_date, cat_sessions_time, cat_sessions_microtime)
            VALUES (NULL, '" 
addslashes($this->session_id) . "', '" $cat_id "', '" $this->current_date "', '" $this->current_clocktime "', $this->current_time)                   
            
           "
;           
    
$site_db->query($sql);
    
    }


Find / Finde:


if ($this->user_info['user_id'] != GUEST) {
      
$sql "UPDATE ".USERS_TABLE."
              SET "
.get_user_table_field("""user_lastaction")." = $this->current_time, ".get_user_table_field("""user_location")." = '$this->user_location'
              WHERE "
.get_user_table_field("""user_id")." = ".$this->user_info['user_id'];
      
$site_db->query($sql);            
    }


replace / ersetze mit:


if ($this->user_info['user_id'] != GUEST) {
      
$sql "UPDATE ".USERS_TABLE."
              SET "
.get_user_table_field("""user_lastaction")." = $this->current_time, ".get_user_table_field("""user_location")." = '$this->user_location'
              WHERE "
.get_user_table_field("""user_id")." = ".$this->user_info['user_id'];
      
$site_db->query($sql);                  
      
$sql3 "DELETE FROM " CATEGORIES_SESSIONS_TABLE " WHERE user_id = '" GUEST "' AND cat_sessions_ip = '" $this->user_ip "'";
      
$site_db->query($sql3);
}


// Step 4

Open / Öffne: lang/YOUR-LANGUAGE/main.php
Add Top / Füge vor:
?>
this / das ein:


// MOD: Categories sessions.
//-----------------------------------------------------
//--- Categories sessions -----------------------------
//-----------------------------------------------------
$lang['categories_notify_count'] = "Total: {count}";
$lang['categories_notify_sessions_title'] = "Currently active image users: ";
$lang['categories_notify_invisible_chars'] = "*";
$lang['categories_notify_current_sessions_title'] = "There are currently ";
$lang['categories_notify_registered_users_count'] = "<b>{registered_users_count}</b> registered user(s) ";
$lang['categories_notify_invisible_count'] = "({invisible_count} among them invisible) ";
$lang['categories_notify_guest_level_count'] = "and <b>{guest_level_count}</b> guest(s) online.";


// Step 5

Open / Öffne: templates/your_template/categories.html

find / finde:

Code: [Select]
{paging}
<br />
<br />

add after / füge darunter das ein:

Code: [Select]
{if is_admin}<! -- Categories users sessions -- >{endif is_admin}  
<table width="100%" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <td valign="top" class="head1">&nbsp;{lang_categories_notify_sessions_title} {total_categories_sessions}</td>
  </tr>
    </table>    
  <table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>  
    <td class="row1">&nbsp;{lang_categories_notify_current_sessions_title} {total_registered_users_categories_sessions} {total_invisible_categories_sessions} {total_guest_level_categories_sessions}</td>
  </tr>
    </table>
  <table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
   {if categories_sessions_template}<td width="100%" class="row1" />&nbsp;{categories_sessions_template}</td>{endif categories_sessions_template}
   {if sessions_categories_no_content_msg}<td width="100%" class="row1" align="center" /><b>{sessions_categories_no_content_msg}</b></td>{endif sessions_categories_no_content_msg}
  </tr>  
                        </table>          
  <br />
  {if is_admin}<! -- End of Categories users sessions -- >{endif is_admin}

// Step 6

Open / Öffne: includes/constants.php

find / finde:


define
('CATEGORIES_TABLE'$table_prefix.'categories');


add after / füge danach ein:


define
('CATEGORIES_SESSIONS_TABLE'$table_prefix "categories_sessions");


// Step 7


Create file / Erstelle eine Datei: categories_sessions_content.html
Add this Code / Füge diesen Code ein:

Code: [Select]
{if is_admin}{if session_comment_invisible}<a href="{session_comment_user_url}"><b>{session_comment_name}</b></a>{invisible_comment_chars}{if need_separator} {endif need_separator}&nbsp;{endif session_comment_invisible}{endif is_admin}
{if user_loggedin}{ifnot session_comment_invisible}<a href="{session_comment_user_url}"><b>{session_comment_name}</b></a>{if need_separator} {endif need_separator}&nbsp;{endifnot session_comment_invisible}{endif user_loggedin}

Load the File to / Lade die Datei nach: templates/YOUR-TEMPLATE/
Beste Grüße
Benny

Offline Benny Change

  • Addicted member
  • ******
  • Posts: 1.788
  • #WWG1WGA
    • View Profile
    • Qlobal-Change
Re: [MOD] - Categories users sessions
« Reply #12 on: June 04, 2009, 01:01:54 PM »
Wie kann ich das auch in der category_bit.html anzeigen?
Ich bitte um Hilfe!

----

But how can i show in category_bit.html?
I ask for help!
Beste Grüße
Benny

Offline Jasi

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
Re: [MOD] - Categories users sessions
« Reply #13 on: September 05, 2015, 02:06:02 PM »
@ ALL

Ich schätze mir fehlen für diesen MOD die dazugehörigen Datenbank-Tabellen?


DB Error
Bad SQL QueryCREATE TABLE IF NOT EXISTS 4images_categories_sessions field_id INT(11NOT NULL AUTO_INCREMENTuser_id VARCHAR(32NOT NULL DEFAULT '0'cat_id INT(11NOT NULL DEFAULT '0'cat_sessions_date VARCHAR(48NOT NULL DEFAULT '0000-00-00'cat_sessions_time VARCHAR(48NOT NULL DEFAULT '00:00:00'cat_sessions_microtime VARCHAR(255NOT NULL DEFAULT '0'cat_sessions_ip VARCHAR(48NOT NULL DEFAULT '0.0.0.0'PRIMARY KEY (field_id) ) TYPE=MyISAM
You have an error in your SQL syntaxcheck the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM' at line 10

DB Error
Bad SQL QuerySELECT user_idcat_id FROM 4images_categories_sessions WHERE user_id AND cat_id 27
Table 
'usr_web5_1.4images_categories_sessions' doesn't exist

DB Error: Bad SQL Query: SELECT cst.cat_id, s.session_user_id, u.user_name, u.user_level, u.user_invisible, u.user_vorname, u.user_nachname, u.userpic, u.user_profile_hits, u.user_gender, u.user_country, u.user_bundesland, u.birthday FROM (4images_sessions s, 4images_categories_sessions cst) LEFT JOIN 4images_users u ON (u.user_id = s.session_user_id) WHERE cst.user_id = s.session_user_id AND cst.cat_id = 27 AND cst.cat_sessions_microtime >= 1441453671 AND s.session_user_id > '
-1' GROUP BY s.session_user_id ORDER BY u.user_id ASC, s.session_ip ASC
Table '
usr_web5_1.4images_categories_sessions' doesn't exist

DB Error
Bad SQL QuerySELECT s.session_user_idu.user_vornameu.user_nachnameu.userpicu.user_profile_hitsu.user_genderu.user_countryu.user_bundeslandu.birthday FROM (4images_sessions s4images_categories_sessions cstLEFT JOIN 4images_users u ON (u.user_id s.session_user_idWHERE cst.cat_id 27 AND cst.cat_sessions_microtime >= 1441453671 AND s.session_user_id '-1' GROUP BY s.session_ip
Table 
'usr_web5_1.4images_categories_sessions' doesn't exist


Wer hat das SQL bzw. Create Table für diesen MOD?

Danke Euch allen für Eure Hilfe :-)

Nachtrag - habe folgendes im Code für die Prüfung ob die MySQL-DB-Tabelle existiert bei mir geändert:

CREATE TABLE 4images_categories_sessions 
field_id INT(11NOT NULL AUTO_INCREMENTuser_id VARCHAR(32NOT NULL DEFAULT '0'cat_id INT(11NOT NULL DEFAULT '0'cat_sessions_date VARCHAR(48NOT NULL DEFAULT '0000-00-00'cat_sessions_time VARCHAR(48NOT NULL DEFAULT '00:00:00'cat_sessions_microtime VARCHAR(255NOT NULL DEFAULT '0'cat_sessions_ip VARCHAR(48NOT NULL DEFAULT '0.0.0.0'PRIMARY KEY (field_id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;


Geändert:
ENGINE=MyISAM DEFAULT CHARSET=latin1;

Hier das SQL für die DB:

#
# Structure for Table 4images_categories_sessions
#
DROP TABLE IF EXISTS 4images_categories_sessions;
CREATE TABLE 4images_categories_sessions (
  
field_id int(11NOT NULL AUTO_INCREMENT,
  
user_id varchar(32NOT NULL DEFAULT '0',
  
cat_id int(11NOT NULL DEFAULT '0',
  
cat_sessions_date varchar(48NOT NULL DEFAULT '0000-00-00',
  
cat_sessions_time varchar(48NOT NULL DEFAULT '00:00:00',
  
cat_sessions_microtime varchar(255NOT NULL DEFAULT '0',
  
cat_sessions_ip varchar(48NOT NULL DEFAULT '0.0.0.0',
  
PRIMARY KEY (field_id)
ENGINE=MyISAM DEFAULT CHARSET=latin1;
« Last Edit: September 05, 2015, 05:10:44 PM by Jasi »
LG Jasi

Rembrandt

  • Guest
Re: [MOD] - Categories users sessions
« Reply #14 on: September 08, 2015, 04:18:20 PM »
in Step 2 suche:

TYPE
=MyISAM;

ändere es auf

ENGINE
=MyISAM;

 

Post your comments here