<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
    <channel>
        <title>BYOND's PHP People</title>
        <link>http://www.byond.com/members/PHP</link>
        <description>PHP help, tips, hints, tricks, and whatever else.</description>
        <lastBuildDate>Sun, 06 Jul 2008 17:40:16 GMT</lastBuildDate>
        <language>en-us</language>
    
                <item>
            <title>Use PHP (and Python) to relaunch DreamDaemon</title>
            <link>http://www.byond.com/members/?command=view_post&amp;post=40251</link>
            <guid>http://www.byond.com/members/?command=view_post&amp;post=40251</guid>
            <pubDate>Tue, 11 Mar 2008 21:45:59 GMT</pubDate>
            
            <comments>http://www.byond.com/members/PHP?command=view_comments&amp;post=40251#comments</comments>
            
            <description>Now, if you're like me and you have a server capable of running BYOND but a host that likes to kill processes once they get over a specific amount CPU usage, you'll know the tiresome pain that is relaunching games when you wake up in the morning (or if you're like me... afternoon).&lt;br/&gt;
&lt;br/&gt;
Not only is this a repetitive and tiresome process, but it also kills your players morale. Your server starts getting popular, players are having a good time and BAM, no more server. This especially kicks in if you're limited on funds and can't afford a server where you have more control.&lt;br/&gt;
&lt;br/&gt;
Well, a small solution is to relaunch DreamDaemon automatically. And here is a small script I whipped up to do so.&lt;br/&gt;
&lt;br/&gt;
&lt;DIV CLASS=&quot;dmcode&quot;&gt;&lt;TABLE WIDTH=100% BORDER=0&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class=&quot;dmcode&quot;&gt;&amp;lt;?
    $port_num = 55678; &lt;span class=dmcomment&gt;//The port in which you want to host the game on.&lt;/span&gt;
    
    $a = shell_exec(&lt;span class=dmstring&gt;&quot;netstat -nlt | grep $port_num&quot;&lt;/span&gt;); &lt;span class=dmcomment&gt;//Check to see if that port is already in use. Or DreamDaemon is still running.&lt;/span&gt;
    &lt;span class=dmkeyword&gt;if&lt;/span&gt;(!$a) { &lt;span class=dmcomment&gt;//If it isn't, relaunch DreamDaemon.&lt;/span&gt;
        popen(&lt;span class=dmstring&gt;&quot;DreamDaemon path/to/your/game.dmb $port_num -trusted &amp;amp;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;r&quot;&lt;/span&gt;);
    }
?&amp;gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;br/&gt;
&lt;br/&gt;
Now that works all fine and dandy, but what about automating that script for a set time limit. I attempted to do this using a Cron Job. But it didn't work. (Audeuro has an untested script to make it work, and once I've tested that, I'll post it here.)&lt;br/&gt;
&lt;br/&gt;
Automating the script needed a finer approach. Seeing as CronDaemon wasn't successfully doing it, I needed something else to kick in. And that's where I sought assistance from BYOND's local Python Guru, Crashed.&lt;br/&gt;
&lt;br/&gt;
With a little script he whipped up (able to work with Python 2.2 and onwards) we were able to automate it.&lt;br/&gt;
&lt;br/&gt;
&lt;DIV CLASS=&quot;dmcode&quot;&gt;&lt;TABLE WIDTH=100% BORDER=0&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class=&quot;dmcode&quot;&gt;from time import sleep 
import os 
&lt;span class=dmkeyword&gt;while&lt;/span&gt; True:  
  os.popen(&lt;span class=dmstring&gt;'php my_php_file.php'&lt;/span&gt;)  
  sleep(1800) #seconds&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;br/&gt;
&lt;br/&gt;
To execute the script, open up your command line client (in my case, PuTtY) and execute it like so: &lt;tt&gt;python my_python_file.py &amp;&lt;/tt&gt;&lt;br/&gt;
If the BYOND server isn't running, you'll receive DreamDaemon's execution message. Then type &lt;tt&gt;exit&lt;/tt&gt; and logout.&lt;br/&gt;
&lt;br/&gt;
Now, that script there will run your PHP script every half an hour to check up on your DreamDaemon. Ever looking to improve it, I'll be revising this script at a later date to check on it all. But at the moment, that should do the trick (it's working so far for me).&lt;br/&gt;
&lt;br/&gt;
I should also say, that script will only work provided both the python and php script are inside your root folder (that is, the one before public_html).</description>
        </item>
                <item>
            <title>Online Games (Updated!)</title>
            <link>http://www.byond.com/members/?command=view_post&amp;post=39268</link>
            <guid>http://www.byond.com/members/?command=view_post&amp;post=39268</guid>
            <pubDate>Sun, 17 Feb 2008 01:24:44 GMT</pubDate>
            
            <comments>http://www.byond.com/members/PHP?command=view_comments&amp;post=39268#comments</comments>
            
            <description>Ever wanted to display the join URL, Players in the game and the server Status on a PHP-enabled website? Now you can!&lt;br/&gt;
&lt;br/&gt;
In addition to my previous post, this little function will grab all the information on hosted servers you need. To use it is pretty simple too, Grab the data using a variable: $servers = hub_get_contents('enigmaster2002.iconultima'); then just put it inside a for($i = 0; $i &lt; count($servers); $i++) loop and display the data with $servers[$i]['url'].&lt;br/&gt;
&lt;br/&gt;
(An example of the script in action can be found: &lt;a href='http://byond.tibbius.com/return_servers.php?hub=enigmaster2002.iconultima'&gt;here&lt;/a&gt;. Just change the ?hub= in the address bar to your game and see how it works.&lt;br/&gt;
&lt;br/&gt;
&lt;DIV CLASS=&quot;dmcode&quot;&gt;&lt;TABLE WIDTH=100% BORDER=0&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class=&quot;dmcode&quot;&gt;function hub_get_contents($hub) {
    $hub_page = file_get_contents(&lt;span class=dmstring&gt;&quot;http://www.byond.com/games/&quot;&lt;/span&gt; . $hub . &lt;span class=dmstring&gt;&quot;&amp;amp;format=text&quot;&lt;/span&gt;);
    $servers = array();

    $i = strpos($hub_page,&lt;span class=dmstring&gt;&quot;world/1&quot;&lt;/span&gt;);
    $disabledline_server = explode(&lt;span class=dmstring&gt;'world/'&lt;/span&gt;, substr($hub_page, $i+9, strlen($hub_page)));
    foreach($online_server &lt;span class=dmkeyword&gt;as&lt;/span&gt; $game) {
        $server = array(
            &lt;span class=dmstring&gt;'url'&lt;/span&gt;		=&amp;gt; &lt;span class=dmstring&gt;''&lt;/span&gt;,
            &lt;span class=dmstring&gt;'status'&lt;/span&gt;	=&amp;gt; &lt;span class=dmstring&gt;''&lt;/span&gt;,
            &lt;span class=dmstring&gt;'users'&lt;/span&gt;		=&amp;gt; &lt;span class=dmstring&gt;''&lt;/span&gt;,
        );
        
        $start = strpos($game, &lt;span class=dmstring&gt;'url'&lt;/span&gt;);
        &lt;span class=dmkeyword&gt;if&lt;/span&gt;($start) {
            $a = strpos($game, &lt;span class=dmstring&gt;'&quot;'&lt;/span&gt;, $start)+1;
            $b = strpos($game, &lt;span class=dmstring&gt;'&quot;'&lt;/span&gt;, $a);
            $server[&lt;span class=dmstring&gt;'url'&lt;/span&gt;] = substr($game, $a, $b - $a);
        }
        
        $start = strpos($game, &lt;span class=dmstring&gt;'status'&lt;/span&gt;);
        &lt;span class=dmkeyword&gt;if&lt;/span&gt;($start) {
            $a = strpos($game, &lt;span class=dmstring&gt;'&quot;'&lt;/span&gt;, $start) +1;
            $b = strpos($game, &lt;span class=dmstring&gt;'&quot;'&lt;/span&gt;, $a);
            $server[&lt;span class=dmstring&gt;'status'&lt;/span&gt;] = substr($game, $a, $b - $a);
        }
        
        $start = strpos($game, &lt;span class=dmstring&gt;'users'&lt;/span&gt;);
        &lt;span class=dmkeyword&gt;if&lt;/span&gt;($start) {
            $start = $start+13;
            $end = strpos($game, &lt;span class=dmstring&gt;')'&lt;/span&gt;, $start);
            $result = str_replace(&lt;span class=dmstring&gt;'&quot;'&lt;/span&gt;, &lt;span class=dmstring&gt;''&lt;/span&gt;, substr($game, $start, $end - ($start)));
            $server[&lt;span class=dmstring&gt;'users'&lt;/span&gt;] = $result;
        }
                    
        $servers[] = $server;
    }
    
    &lt;span class=dmkeyword&gt;return&lt;/span&gt; $servers;
}&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;br/&gt;
&lt;br/&gt;
&lt;b&gt;[Update]&lt;/b&gt;&lt;br/&gt;
One or two people sent me a page because they were having trouble getting the function to work. So I'll give you a complete working script to go with it.&lt;br/&gt;
&lt;br/&gt;
&lt;DIV CLASS=&quot;dmcode&quot;&gt;&lt;TABLE WIDTH=100% BORDER=0&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class=&quot;dmcode&quot;&gt;$servers = hub_get_contents(&lt;span class=dmstring&gt;'enigmaster2002.iconultima'&lt;/span&gt;);
&lt;span class=dmkeyword&gt;for&lt;/span&gt;($i = 0; $i &amp;lt; count($servers); $i++) {
    echo(&lt;span class=dmstring&gt;&quot;&amp;lt;b&amp;gt;URL:&amp;lt;/b&amp;gt; &quot;&lt;/span&gt; . $servers[$i][&lt;span class=dmstring&gt;'url'&lt;/span&gt;] . &lt;span class=dmstring&gt;&quot;&amp;lt;br&amp;gt;&quot;&lt;/span&gt;);
    echo(&lt;span class=dmstring&gt;&quot;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt; &quot;&lt;/span&gt; . $servers[$i][&lt;span class=dmstring&gt;'status'&lt;/span&gt;] . &lt;span class=dmstring&gt;&quot;&amp;lt;br&amp;gt;&quot;&lt;/span&gt;);
    echo(&lt;span class=dmstring&gt;&quot;&amp;lt;b&amp;gt;Users:&amp;lt;/b&amp;gt; &quot;&lt;/span&gt; . $servers[$i][&lt;span class=dmstring&gt;'users'&lt;/span&gt;] . &lt;span class=dmstring&gt;&quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;&lt;/span&gt;);
}

function hub_get_contents($hub) {
    $hub_page = file_get_contents(&lt;span class=dmstring&gt;&quot;&amp;lt;a href=&quot;&lt;/span&gt;http:&lt;span class=dmcomment&gt;//www.byond.com/games/&quot;&amp;gt;http://www.byond.com/games/&amp;lt;/a&amp;gt;&quot; . $hub . &quot;&amp;amp;format=text&quot;);&lt;/span&gt;
    $servers = array();

    $i = strpos($hub_page,&lt;span class=dmstring&gt;&quot;world/1&quot;&lt;/span&gt;);
    $online_server = explode(&lt;span class=dmstring&gt;'world/'&lt;/span&gt;, substr($hub_page, $i+9, strlen($hub_page)));
    foreach($online_server &lt;span class=dmkeyword&gt;as&lt;/span&gt; $game) {
        $server = array(
            &lt;span class=dmstring&gt;'url'&lt;/span&gt;		=&amp;gt; &lt;span class=dmstring&gt;''&lt;/span&gt;,
            &lt;span class=dmstring&gt;'status'&lt;/span&gt;	=&amp;gt; &lt;span class=dmstring&gt;''&lt;/span&gt;,
            &lt;span class=dmstring&gt;'users'&lt;/span&gt;		=&amp;gt; &lt;span class=dmstring&gt;''&lt;/span&gt;,
        );
        
        $start = strpos($game, &lt;span class=dmstring&gt;'url'&lt;/span&gt;);
        &lt;span class=dmkeyword&gt;if&lt;/span&gt;($start) {
            $a = strpos($game, &lt;span class=dmstring&gt;'&quot;'&lt;/span&gt;, $start)+1;
            $b = strpos($game, &lt;span class=dmstring&gt;'&quot;'&lt;/span&gt;, $a);
            $server[&lt;span class=dmstring&gt;'url'&lt;/span&gt;] = substr($game, $a, $b - $a);
        }
        
        $start = strpos($game, &lt;span class=dmstring&gt;'status'&lt;/span&gt;);
        &lt;span class=dmkeyword&gt;if&lt;/span&gt;($start) {
            $a = strpos($game, &lt;span class=dmstring&gt;'&quot;'&lt;/span&gt;, $start) +1;
            $b = strpos($game, &lt;span class=dmstring&gt;'&quot;'&lt;/span&gt;, $a);
            $server[&lt;span class=dmstring&gt;'status'&lt;/span&gt;] = substr($game, $a, $b - $a);
        }
        
        $start = strpos($game, &lt;span class=dmstring&gt;'users'&lt;/span&gt;);
        &lt;span class=dmkeyword&gt;if&lt;/span&gt;($start) {
            $start = $start+13;
            $end = strpos($game, &lt;span class=dmstring&gt;')'&lt;/span&gt;, $start);
            $result = str_replace(&lt;span class=dmstring&gt;'&quot;'&lt;/span&gt;, &lt;span class=dmstring&gt;''&lt;/span&gt;, substr($game, $start, $end - ($start)));
            $server[&lt;span class=dmstring&gt;'users'&lt;/span&gt;] = $result;
        }
                    
        $servers[] = $server;
    }
    
    &lt;span class=dmkeyword&gt;return&lt;/span&gt; $servers;
}&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;</description>
        </item>
                <item>
            <title>hub_get_contents()</title>
            <link>http://www.byond.com/members/?command=view_post&amp;post=37404</link>
            <guid>http://www.byond.com/members/?command=view_post&amp;post=37404</guid>
            <pubDate>Mon, 17 Dec 2007 21:48:06 GMT</pubDate>
            
            <comments>http://www.byond.com/members/PHP?command=view_comments&amp;post=37404#comments</comments>
            
            <description>Due to the lack of activity this guild has been experiencing. I've decided to release three quarters of a PHP function I wrote a while ago.&lt;br/&gt;
&lt;br/&gt;
A lot of people tend to ask how to grab hub page information. The best way is PHP and the BYOND Hub Page text format. With this in mind, I wrote a function some time ago which did it. But it was a crap function.&lt;br/&gt;
&lt;br/&gt;
Since then, I've rewritten it twice. And even released one to a select few of BYOND Users. Now I'm going to release part of that function (after it was revised) to everyone.&lt;br/&gt;
&lt;br/&gt;
And here it is: &lt;b&gt;[Due to a bug inside the DM parser in BYOND Members pages, you'll have to remove the anchor tags inside the file_get_contents() function.]&lt;/b&gt;&lt;br/&gt;
&lt;DIV CLASS=&quot;dmcode&quot;&gt;&lt;TABLE WIDTH=100% BORDER=0&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class=&quot;dmcode&quot;&gt;&amp;lt;?
    &lt;span class=dmcomment&gt;//Using the standard world/hub format. Just type in the key and the game name as shown below.&lt;/span&gt;
    $hub = @hub_get_contents(&lt;span class=dmstring&gt;'tiberath.storytelling'&lt;/span&gt;);

    function hub_get_contents($hub_page) {
        &lt;span class=dmcomment&gt;//We use the file_get_contents() function to grab the text information off the BYOND Hub page.&lt;/span&gt;
        $hub_page = @file_get_contents(&lt;span class=dmstring&gt;'&amp;lt;a href=&quot;http://games.byond.com/hub/hub.cgi?qd=hub;hub=&quot;&amp;gt;http://games.byond.com/hub/hub.cgi?qd=hub;hub=&amp;lt;/a&amp;gt;'&lt;/span&gt; . $hub_page . &lt;span class=dmstring&gt;';format=text'&lt;/span&gt;);
        
        &lt;span class=dmcomment&gt;//We use an array to store the information we wish to return back to the $hub variable. You can remove anything you think you wont need. &lt;/span&gt;
        &lt;span class=dmcomment&gt;//But if you look, you'll notice the words match exactly what is displayed on the text format of a hub page. It has to be that way.&lt;/span&gt;
        &lt;span class=dmcomment&gt;//Bare in mind,  I haven't included the 'subscription_price' option yet. That'll probably come in a later release.&lt;/span&gt;
        $game_info = array(&lt;span class=dmstring&gt;&quot;title&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;icon&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;small_icon&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;short_desc&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;long_desc&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;author&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;registered&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;version&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;status&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;byond_rank&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;);
        
        &lt;span class=dmcomment&gt;//I used to use a while() loop here. But I later learned this makes the code more compact and probably works better.&lt;/span&gt;
        foreach($game_info &lt;span class=dmkeyword&gt;as&lt;/span&gt; $key =&amp;gt; $value) {
            $start = strpos($hub_page, $key);
            
            &lt;span class=dmcomment&gt;//Because BYOND's text format is a pain, it sometimes doesn't enclose it's values in quotation marks. When it doesn't,&lt;/span&gt;
            &lt;span class=dmcomment&gt;//it breaks my function. So we have to distinguish when it does and doesn't. Luckily, it only doesn't once.&lt;/span&gt;
            &lt;span class=dmcomment&gt;//We also have to make sure there is a start value. If the value we're looking for isn't present, there's no sense running&lt;/span&gt;
            &lt;span class=dmcomment&gt;//a function to find it's contents.&lt;/span&gt;
            &lt;span class=dmkeyword&gt;if&lt;/span&gt;($start) {
                &lt;span class=dmkeyword&gt;if&lt;/span&gt;($key == &lt;span class=dmstring&gt;'byond_rank'&lt;/span&gt;) {
                    $start += 3; 
                    $end = strpos($hub_page, (chr(10)), $start);
                } &lt;span class=dmkeyword&gt;else&lt;/span&gt; {
                    $start += 4;
                    $end = strpos($hub_page, (&lt;span class=dmstring&gt;'&quot;'&lt;/span&gt; . chr(10)), $start);
                }
                
                &lt;span class=dmcomment&gt;//To remove the key from the start, we add it's length to the start variable.&lt;/span&gt;
                $start += strlen($key);
                
                &lt;span class=dmcomment&gt;//I used to use Mobius' substring() function here. But I decided there wasn't going to be a need when there wouldn't be an end variable.&lt;/span&gt;
                &lt;span class=dmcomment&gt;//So I just did the logical thing. Take the start from the end. Beautiful no?&lt;/span&gt;
                $game_info[$key] = stripslashes(str_replace(&lt;span class=dmstring&gt;&quot;\\n&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;&amp;lt;br&amp;gt;&quot;&lt;/span&gt;, substr($hub_page, $start, $end - $start)));
            }
        }
        
        &lt;span class=dmcomment&gt;//Return the game_info array so you can use the hub variable as an array.&lt;/span&gt;
        &lt;span class=dmkeyword&gt;return&lt;/span&gt; $game_info;
    }
?&amp;gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;br/&gt;
&lt;br/&gt;
The full function includes server information (who's logged into what server and all that). But I'm not in the mood to give away all my secrets.&lt;br/&gt;
&lt;br/&gt;
(This could probably be done better using Regular Expressions, but because I don't know them, I'm not going to use them.)&lt;br/&gt;
&lt;br/&gt;
To use the function, just call your hub variable like an array: &lt;tt&gt;echo $hub['title'];&lt;/tt&gt; &lt;br/&gt;
Easy done.&lt;br/&gt;
&lt;br/&gt;
--&lt;br/&gt;
&lt;br/&gt;
If you're already PHP compliant, I'm also including a copy of the function without the comments.&lt;br/&gt;
&lt;br/&gt;
&lt;DIV CLASS=&quot;dmcode&quot;&gt;&lt;TABLE WIDTH=100% BORDER=0&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class=&quot;dmcode&quot;&gt;&amp;lt;?
    $hub = @hub_get_contents(&lt;span class=dmstring&gt;'tiberath.storytelling'&lt;/span&gt;);

    function hub_get_contents($hub_page) {
        $hub_page = @file_get_contents(&lt;span class=dmstring&gt;'&amp;lt;a href=&quot;http://games.byond.com/hub/hub.cgi?qd=hub;hub=&quot;&amp;gt;http://games.byond.com/hub/hub.cgi?qd=hub;hub=&amp;lt;/a&amp;gt;'&lt;/span&gt; . $hub_page . &lt;span class=dmstring&gt;';format=text'&lt;/span&gt;);
        $game_info = array(&lt;span class=dmstring&gt;&quot;title&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;icon&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;small_icon&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;short_desc&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;long_desc&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;author&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;registered&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;version&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;status&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;byond_rank&quot;&lt;/span&gt; =&amp;gt; &lt;span class=dmstring&gt;&quot;&quot;&lt;/span&gt;);
        foreach($game_info &lt;span class=dmkeyword&gt;as&lt;/span&gt; $key =&amp;gt; $value) {
            $start = strpos($hub_page, $key);
            &lt;span class=dmkeyword&gt;if&lt;/span&gt;($start) {
                &lt;span class=dmkeyword&gt;if&lt;/span&gt;($key == &lt;span class=dmstring&gt;'byond_rank'&lt;/span&gt;) {
                    $start += 3; 
                    $end = strpos($hub_page, (chr(10)), $start);
                } &lt;span class=dmkeyword&gt;else&lt;/span&gt; {
                    $start += 4;
                    $end = strpos($hub_page, (&lt;span class=dmstring&gt;'&quot;'&lt;/span&gt; . chr(10)), $start);
                }
                $start += strlen($key);
                $game_info[$key] = stripslashes(str_replace(&lt;span class=dmstring&gt;&quot;\\n&quot;&lt;/span&gt;, &lt;span class=dmstring&gt;&quot;&amp;lt;br&amp;gt;&quot;&lt;/span&gt;, substr($hub_page, $start, $end - $start)));
            }
        }
        &lt;span class=dmkeyword&gt;return&lt;/span&gt; $game_info;
    }
?&amp;gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;</description>
        </item>
                <item>
            <title>PHP -&gt; PHP Communication Function</title>
            <link>http://www.byond.com/members/?command=view_post&amp;post=33091</link>
            <guid>http://www.byond.com/members/?command=view_post&amp;post=33091</guid>
            <pubDate>Fri, 27 Jul 2007 23:03:19 GMT</pubDate>
            
            <comments>http://www.byond.com/members/PHP?command=view_comments&amp;post=33091#comments</comments>
            
            <description>This function is used to communicate with a PHP script on another webserver.&lt;br/&gt;
&lt;br/&gt;
&lt;DIV CLASS=&quot;dmcode&quot;&gt;&lt;TABLE WIDTH=100% BORDER=0&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class=&quot;dmcode&quot;&gt;function export($addr, $extra_dir, $get_data = &lt;span class=dmstring&gt;''&lt;/span&gt;)
{
        &lt;span class=dmkeyword&gt;if&lt;/span&gt;(!$addr) error(&lt;span class=dmstring&gt;'export(), '&lt;/span&gt; . __LINE__ . &lt;span class=dmstring&gt;': No server address provided'&lt;/span&gt;);
        $fp = fsockopen($addr, 80);
        &lt;span class=dmkeyword&gt;if&lt;/span&gt;(isset($get_data) &amp;amp;&amp;amp; !is_null($get_data)) $extra_dir .= &lt;span class=dmstring&gt;&quot;?{$get_data}&quot;&lt;/span&gt;;
        &lt;span class=dmkeyword&gt;if&lt;/span&gt;($fp)
        {
                $out = &lt;span class=dmstring&gt;&quot;GET /{$extra_dir} HTTP/1.1\r\n&quot;&lt;/span&gt;;
                $out .= &lt;span class=dmstring&gt;&quot;Host: {$addr}\r\n&quot;&lt;/span&gt;;
                $out .= &lt;span class=dmstring&gt;&quot;Connection: Close\r\n\r\n&quot;&lt;/span&gt;;
                fwrite($fp, $out);
                fclose($fp);
        }
}&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;br/&gt;
&lt;br/&gt;
$addr is a simple subdomain + domain. &lt;br/&gt;
$extra_dir is any directories added on to the domain.&lt;br/&gt;
$get_data is any GET data you'd like to pass.&lt;br/&gt;
&lt;br/&gt;
Example:&lt;br/&gt;
&lt;br/&gt;
I have a script at &lt;a href=&quot;http://www.sineful.com/my_scripts/script.php&quot;&gt;http://www.sineful.com/my_scripts/script.php&lt;/a&gt;, and I want to pass it &quot;action=reload&amp;data=1&quot;&lt;br/&gt;
&lt;br/&gt;
&lt;DIV CLASS=&quot;dmcode&quot;&gt;&lt;TABLE WIDTH=100% BORDER=0&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class=&quot;dmcode&quot;&gt;export(&lt;span class=dmstring&gt;'www.sineful.com'&lt;/span&gt;, &lt;span class=dmstring&gt;'my_scripts/script.php'&lt;/span&gt;, &lt;span class=dmstring&gt;'action=reload&amp;amp;data=1'&lt;/span&gt;);&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;br/&gt;
</description>
        </item>
                <item>
            <title>PHP -&gt; DM Communication Function</title>
            <link>http://www.byond.com/members/?command=view_post&amp;post=33090</link>
            <guid>http://www.byond.com/members/?command=view_post&amp;post=33090</guid>
            <pubDate>Fri, 27 Jul 2007 22:44:44 GMT</pubDate>
            
            <comments>http://www.byond.com/members/PHP?command=view_comments&amp;post=33090#comments</comments>
            
            <description>This is a function to make PHP communicate with DM, courtesy of &lt;a href=&quot;http://members.byond.com/mobiusevalon&quot;&gt;Mobius Evalon&lt;/a&gt; and &lt;a href=&quot;http://members.byond.com/crispy&quot;&gt;Crispy&lt;/a&gt;!&lt;br/&gt;
&lt;br/&gt;
&lt;DIV CLASS=&quot;dmcode&quot;&gt;&lt;TABLE WIDTH=100% BORDER=0&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class=&quot;dmcode&quot;&gt;function export($addr,$port,$str)
{
    &lt;span class=dmkeyword&gt;if&lt;/span&gt;($str{0} != &lt;span class=dmstring&gt;&quot;?&quot;&lt;/span&gt;) $str = (&lt;span class=dmstring&gt;&quot;?&quot;&lt;/span&gt; . $str);
    $query = &lt;span class=dmstring&gt;&quot;\x00\x83&quot;&lt;/span&gt; . pack(&lt;span class=dmstring&gt;&quot;n&quot;&lt;/span&gt;,strlen($str)+6) . &lt;span class=dmstring&gt;&quot;\x00\x00\x00\x00\x00&quot;&lt;/span&gt; . $str . &lt;span class=dmstring&gt;&quot;\x00&quot;&lt;/span&gt;;
    $server = socket_create(AF_INET,SOCK_STREAM,SOL_TCP) or exit(&lt;span class=dmstring&gt;'Unable to create export socket; '&lt;/span&gt; . socket_strerror(socket_last_error()));
    socket_connect($server,$addr,$port) or exit(&lt;span class=dmstring&gt;'Unable to establish socket connection; '&lt;/span&gt; . socket_strerror(socket_last_error()));
    $bytessent = 0;
    &lt;span class=dmkeyword&gt;while&lt;/span&gt;($bytessent &amp;lt; strlen($query))
    {
        $result = socket_write($server,substr($query,$bytessent),strlen($query)-$bytessent);
        &lt;span class=dmkeyword&gt;if&lt;/span&gt;($result === FALSE) exit(&lt;span class=dmstring&gt;'Unable to transfer requested data; '&lt;/span&gt; . socket_strerror(socket_last_error()));
        $bytessent += $result;
    }
    socket_close($server);
}&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;br/&gt;
&lt;br/&gt;
And for an example:&lt;br/&gt;
&lt;br/&gt;
&lt;DIV CLASS=&quot;dmcode&quot;&gt;&lt;TABLE WIDTH=100% BORDER=0&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class=&quot;dmcode&quot;&gt;export(&lt;span class=dmstring&gt;&quot;127.0.0.1&quot;&lt;/span&gt;,1766,&lt;span class=dmstring&gt;&quot;dothisaction&quot;&lt;/span&gt;);&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;br/&gt;
&lt;br/&gt;
This will send 127.0.0.1:1766 a message saying &quot;dothisaction,&quot; which it will receive via world/Topic.</description>
        </item>
                <item>
            <title>PHP Guild</title>
            <link>http://www.byond.com/members/?command=view_post&amp;post=33089</link>
            <guid>http://www.byond.com/members/?command=view_post&amp;post=33089</guid>
            <pubDate>Fri, 27 Jul 2007 22:43:34 GMT</pubDate>
            
            <comments>http://www.byond.com/members/PHP?command=view_comments&amp;post=33089#comments</comments>
            
            <description>I have decided to start up a guild dedicated to PHP, thanks to &lt;a href=&quot;http://members.byond.com/Crispy&quot;&gt;Crispy&lt;/a&gt; for buying the membership.</description>
        </item>
            
    </channel>
</rss>

