Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Releases
Non-local Online Users Script -- Evaluate my Code
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Brackson" data-source="post: 227034" data-attributes="member: 34747"><p>[PHP]</p><p><!DOCTYPE html></p><p><body></p><p><?php</p><p>require_once 'simple_html_dom.php';</p><p>// Download here http://sourceforge.net/projects/simplehtmldom/files/simple_html_dom.php/download // It parses the HTML so we can get the div from the source easier thank using regular expression.</p><p> </p><p>$url = "http://xenon.pw/?novote";</p><p>// The URL of the retro that you want to use.</p><p> </p><p>$html = file_get_html($url);</p><p>// Gets the HTML source of that link and stores it in a variable.</p><p> </p><p>$ret = $html->find('div[id=online]');</p><p>// Finds the div where online user count is stored.</p><p> </p><p>$onlineusers = (strip_tags($ret[0]));</p><p>// Converts the div into non-markup'ed text.</p><p> </p><p>$onlineusercount = filter_var($onlineusers, FILTER_SANITIZE_NUMBER_INT);</p><p>// Takes the number of users online in just number format and stores it in a variable.</p><p> </p><p>echo $onlineusercount;</p><p>echo " users online!";</p><p>// This is what comes after the number of users.</p><p>?></p><p></body></p><p></html></p><p>[/PHP]</p><p> </p><p>If someone wanted to use the PHP code without it being in the HTML markup, then they can. I'd rather not though. I fixed the body tags, although I only put <html> in there to show that it was an .html file. I took your advice and used require_once, as it's more efficient.</p><p> </p><p>I also added where you take only the numbers of the users online and then you can add something after it. (ex: "7 user(s) online", vs "7 users online!", or honestly pretty much "7" anything), becuase I realized that this could cause some conflict with the diversity of how retros display this type of information.</p></blockquote><p></p>
[QUOTE="Brackson, post: 227034, member: 34747"] [PHP] <!DOCTYPE html> <body> <?php require_once 'simple_html_dom.php'; // Download here http://sourceforge.net/projects/simplehtmldom/files/simple_html_dom.php/download // It parses the HTML so we can get the div from the source easier thank using regular expression. $url = "http://xenon.pw/?novote"; // The URL of the retro that you want to use. $html = file_get_html($url); // Gets the HTML source of that link and stores it in a variable. $ret = $html->find('div[id=online]'); // Finds the div where online user count is stored. $onlineusers = (strip_tags($ret[0])); // Converts the div into non-markup'ed text. $onlineusercount = filter_var($onlineusers, FILTER_SANITIZE_NUMBER_INT); // Takes the number of users online in just number format and stores it in a variable. echo $onlineusercount; echo " users online!"; // This is what comes after the number of users. ?> </body> </html> [/PHP] If someone wanted to use the PHP code without it being in the HTML markup, then they can. I'd rather not though. I fixed the body tags, although I only put <html> in there to show that it was an .html file. I took your advice and used require_once, as it's more efficient. I also added where you take only the numbers of the users online and then you can add something after it. (ex: "7 user(s) online", vs "7 users online!", or honestly pretty much "7" anything), becuase I realized that this could cause some conflict with the diversity of how retros display this type of information. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Releases
Non-local Online Users Script -- Evaluate my Code
Top