Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 03-07-2010, 07:41 AM
Snakehill Snakehill is offline
 
Join Date: Feb 2010
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to put this in the menu

I made this little screen scrape to see how many users there are in my (external) Videochat:
PHP Code:
<?php
$url 
'http://www.mtgstream.com/online_amount.php';
$output file_get_contents($url); 
echo 
$output
?>
The link to the Videochat in the header-template is:
Code:
<td>
<a href="http://www.magiciansthegathering.com/forums/chat.php">Videochat</a>
</td>
I would like to put the PHP in there so it shows up like 'Videochat (4)' with the '4' being the amount of users in the chat. I know how to put the brackets around the PHP but I can't just copy/paste the PHP in there because the number simply won't show up.

So how do I do this?

Thanks in advance!
Reply With Quote
  #2  
Old 03-07-2010, 07:18 PM
Anseur's Avatar
Anseur Anseur is offline
 
Join Date: Jun 2004
Location: Nottingham, UK.
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

get rid of the last line of the code, put it in a plugin, and use the $output in your template.

Edit, re-reading your above post, it depends whats in that chat .php file. I think we need to know a bit more to help. Do you have direct access to that chat php file?
Reply With Quote
  #3  
Old 03-08-2010, 09:29 AM
Snakehill Snakehill is offline
 
Join Date: Feb 2010
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's just a number which changes when there are more people in the chat room.

This is the original PHP (the php in question only got the 'online_users' from this):
PHP Code:
<?php

// sets the include files
include("globals.php");
include(
"includes/inc.php");
doDB();
doLicence();
include(
"config.php");

// set expire time 
// eg. lets display active users in the last 60 seconds
$expire_secs=date("U")-60;

// ignore any admins if the invisible plugin is enabled
if($invisible_admins && file_exists("invisible/index.php"))
{
    
$hide_admins "AND admin != 'yes'";
}

// get the data
$tmp=mysql_query("SELECT user_name FROM prochatrooms_users WHERE online_time >='$expire_secs' ".$hide_admins.""); 
$online_users mysql_num_rows($tmp);

// display the user count
echo "Chat Room Users: ".$online_users;

?>
Keep in mind both PHPs are located at an external server (otherwise this all would've been way easier).

I tried to make a plugin but I didn't get it to work (but that could be just me).
Reply With Quote
  #4  
Old 03-08-2010, 10:45 AM
Anseur's Avatar
Anseur Anseur is offline
 
Join Date: Jun 2004
Location: Nottingham, UK.
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, I can see what that does,

So just to clarify, which site/page are you trying to display this number of online users?

somewhere on http://mtgstream.com/ or somewhere on http://www.magiciansthegathering.com?

I'm guessing the 2nd as that looks like a vb installation.

If so, I assume you own both sites? or just the 2nd one? Are they both hosted on the same server?

You could perhaps give http://www.magiciansthegathering.com access remotly to the other sites database (cpanel etc can do that if hosted solution), then make a modified version of the code you posted above, but instead of all the

Code:
include("globals.php"); 
include("includes/inc.php"); 
doDB(); 
doLicence(); 
include("config.php");
you write out the mysql connect that is probably in one of those other files at the moment, then you have basicly a copy of your http://mtgstream.com/online.php on http://www.magiciansthegathering.com

After that it becomes much easier to intergrate with vB, and you can then start to do what I mentioned in my first post.
Reply With Quote
  #5  
Old 03-08-2010, 11:45 AM
Snakehill Snakehill is offline
 
Join Date: Feb 2010
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, wait, I'm getting slightly confused now, so let me answer the questions.

Both sites are owned by me but they are not hosted on the same server. The chat (mtgstream.com) is hosted on a dedicated flash server because the chat application requires that. This one does have cPanel but magiciansthegathering.com doesn't.

I would like the PHP output to show in the menu (header-template) like 'Videochat (2)' in which 2 should be the amount of people online in the chat on mtgstream.com.

So what exactly should I do? Also, I was wondering about the hook the plugin should be linked to.

Thanks a lot for the help!
Reply With Quote
  #6  
Old 03-08-2010, 12:42 PM
Anseur's Avatar
Anseur Anseur is offline
 
Join Date: Jun 2004
Location: Nottingham, UK.
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, at the moment, your PHP hosted on mtgstream.com is only able to connect to the database and pull the data in the query because it contains the lines of code I posted above. Somewhere in one of those other files mentioned in those lines, there will be some lines of code establishing a connection to that websites database in order to run the query:

Code:
SELECT user_name FROM prochatrooms_users WHERE online_time >='$expire_secs' ".$hide_admins."
what I'm saying is, you need to log into whatever sort of control panel or SSH access you have on mtgstream.com and allow your website http://www.magiciansthegathering.com to access http://mtgstream.com/'s database. (Perhaps your host could help with that?)

Once you have done that, you can re-write your php you posted above, miss out the lines of code I quoted and instead pull the data directly from mtgstream.com's.

If your not sure how to do that, you can learn how to do this here:
http://php.net/manual/en/function.mysql-connect.php

Once you have done that, you can use most of the rest of your existing code to arrive at having the number of users online in your chat in a vairable. For example your PHP you posted above uses the "$online_users" vairable to store the number of uses online in your chat.

You can't use the 'echo' command with vB, you instead need to refrence your $online_users vairable in your template, after you have added your finalised php to a plugin.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:32 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03797 seconds
  • Memory Usage 2,214KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete