View Single Post
  #22  
Old 08-17-2004, 10:58 PM
tamarian tamarian is offline
 
Join Date: Oct 2001
Location: Canada
Posts: 1,205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

O.k., here goes:

Note: You need the chat_global.php from the sigma chat hack provided by sigmachat.

1. Create a new file called chat_cache.php or something else, and paste this into it:

PHP Code:
<?php
  
  
// replace with actual path to your forum main directory, no trailing slash
          
chdir("/path/to/forum");
  
        require_once(
"./global.php");
        require_once(
"./chat_global.php");
  
        
error_reporting(E_ALL & ~E_NOTICE);
        
define('NO_REGISTER_GLOBALS'1);
        
define('THIS_SCRIPT','chat_online');
  
        
$globaltemplates = array("sigmachat_chatting",);
  
        
$SIGMACHAT_CP_PASSWORD_MD5 md5($SIGMACHAT_CP_PASSWORD);
      
$womurl "http://$SIGMACHAT_SERVER/vbwho.pl?id=$SIGMACHAT_CHAT_ROOM_ID&pw=$SIGMACHAT_CP_PASSWORD_MD5";
  
        
$users = array();
        
$user_count = -1;
        
$wom_hits_remaining 0;
        
$wom_message '';
        if(
$womh fopen($womurl'r'))
        {
           while(!
feof($womh))
           {
              
$womcontent fgets($womh1048576);
              if(
$user_count == -1)
              {
                 
$wom_hits_remaining $womcontent;
                 
$user_count++;
              }
              else if( (
$user_count == 0) && ($wom_hits_remaining 0) )
              {
                 die;
              }
              else
              {
                 if(
$womcontent != '')
                  
$users[] = rtrim($womcontent);
                 
$user_count++;
              }
           }
           
fclose($womh);
        }
        else
        {
           die;
        }
  
        
$SIGMACHAT_CHATTING_COUNT $user_count;
      if (
$SIGMACHAT_CHATTING_COUNT 0$SIGMACHAT_CHATTING_COUNT "Chatting: " $SIGMACHAT_CHATTING_COUNT;
          else 
$SIGMACHAT_CHATTING_COUNT "";
  
          foreach(
$users as $username)
        {
           
$SIGMACHAT_USERNAME "$username";
  
          if (
$bbuserinfo $DB_site->query_first('SELECT userid, usergroupid, username, salt FROM ' TABLE_PREFIX 'user WHERE username = "' addslashes(htmlspecialchars_uni($username)) . '"'))
           {
          
$SIGMACHAT_USERNAME "<a href=\"member.php?u=" $bbuserinfo[userid] . "\">" $bbuserinfo[username] . "";
           }
  
      
$chat_names .= "<a href=\"member.php?u=" $bbuserinfo[userid] . "\">" $bbuserinfo[username] . "" ", ";
  
        }
          
$chat_names addslashes($chat_names);
      
$DB_site->query("UPDATE " TABLE_PREFIX "template SET template=\"$SIGMACHAT_CHATTING_COUNT\", template_un=\"$SIGMACHAT_CHATTING_COUNT\" WHERE title='sigmachat_chatting_cache_bit'");
      
$DB_site->query("UPDATE " TABLE_PREFIX "template SET template=\"$chat_names\", template_un=\"$chat_names\" WHERE title='sigmachat_chatting_cache'");
  
?>
2. Update the first line in the code above with the right path to your forum home dir on your server.

3. Create two empty templates: sigmachat_chatting_cache_bit and sigmachat_chatting_cache

4. Edit index.php

Find:

PHP Code:
'FORUMHOME'
Add after:
PHP Code:
         'sigmachat_chatting_cache',
         
'sigmachat_chatting_cache_bit'
Find:

PHP Code:
$today vbdate('Y-m-d'TIMENOWfalsefalse); 
Add after:

PHP Code:
$sigmachat_chatting =  $templatecache['sigmachat_chatting_cache'];
 
$sigmachat_chatting_bit =  $templatecache['sigmachat_chatting_cache_bit']; 
5. Use $sigmachat_chatting_bit and $sigmachat_chatting in your FORUMHOME template. The first has the number of members in the chat room, and the second has the list of the members and their profile links.

6. Add a cron job to your server, ever 10 minutes. Example:

*/10 * * * * /usr/bin/php /path/to/forum/chat_cache.php > /dev/null 2>&1

7. If you have a problem, feel free to ask, but keep in mind that you need to back up your files and templates in case it doesn't work for you.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01392 seconds
  • Memory Usage 1,820KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete