<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
    <channel>
        <title>DMCGI Guild</title>
        <link>http://www.byond.com/members/DMCGI</link>
        <description>The source for DMCGI.</description>
        <lastBuildDate>Tue, 02 Dec 2008 00:22:54 GMT</lastBuildDate>
        <language>en-us</language>
    
                <item>
            <title>Calling all DMCGI gurus!</title>
            <link>http://www.byond.com/members/?command=view_post&amp;post=35760</link>
            <guid>http://www.byond.com/members/?command=view_post&amp;post=35760</guid>
            <pubDate>Mon, 15 Oct 2007 16:20:50 GMT</pubDate>
            
            <comments>http://www.byond.com/members/DMCGI?command=view_comments&amp;post=35760#comments</comments>
            
            <description>We need more activity! If you have an idea of an article to write about DMCGI, send me an e-mail at sineful (at) cox (dot) net with &quot;BYOND: DMCGI Guild&quot; as the subject and with the topic of your proposed article, and I'll see about getting you set up with the guild.</description>
        </item>
                <item>
            <title>Installing DMCGI as a normal user on a Linux system w/ Apache</title>
            <link>http://www.byond.com/members/?command=view_post&amp;post=31530</link>
            <guid>http://www.byond.com/members/?command=view_post&amp;post=31530</guid>
            <pubDate>Wed, 13 Jun 2007 01:57:35 GMT</pubDate>
            
            <comments>http://www.byond.com/members/DMCGI?command=view_comments&amp;post=31530#comments</comments>
            
            <description>Installing DMCGI as a normal user on Linux isn't as fun as installing it as root.&lt;br/&gt;
&lt;br/&gt;
First off, as with the &lt;a href=&quot;http://members.byond.com/DMCGI?command=view_post&amp;post=31527&quot;&gt;root installation&lt;/a&gt;, you need to &lt;a href=&quot;http://games.byond.com/download/byond_linux.zip&quot;&gt;download&lt;/a&gt; and install BYOND, by unzipping it then going to the &quot;byond/&quot; directory and running the 'make here' command.&lt;br/&gt;
&lt;br/&gt;
If you try to run a DMCGI application now, you'll undoubtedly fail. First, go to your BYOND installation, and use the `pwd` command to get the working directory to your &quot;byond/bin/&quot; directory. Record this for later usage. For this article, I will use &quot;/home/audeuro/byond/bin&quot; as my working directory.&lt;br/&gt;
&lt;br/&gt;
First off, you need to set up your .htaccess file in your root web directory. In this .htaccess file, put the following:&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;Options +ExecCGI&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;br/&gt;
&lt;br/&gt;
This will tell Apache to allow execution of CGI in that particular web directory (and all children, if not specified otherwise in their .htaccess files). That should take care of that part, on to the next!&lt;br/&gt;
&lt;br/&gt;
Upload your DMCGI application and CHMOD it to 755.  Now there's just one step left.&lt;br/&gt;
&lt;br/&gt;
Since you installed BYOND as a normal user, you'll undoubtedly get errors if you attempt to run this DMCGI application as-is. Next, we must create the last piece of the puzzle: a simple wrapper. The wrapper must be used so that DreamDaemon knows where it will be able to locate the libraries it needs to operate properly. Your wrapper should be a .cgi file. Mine was named index.cgi. You must use this script in order to utilize the DMCGI application. It should look like this:&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;&lt;span class=dmpreprocessor&gt;#!/bin/sh&lt;/span&gt;

&lt;span class=dmpreprocessor&gt;# LD_LIRARY_PATH is where DreamDaemon will look for the libraries.&lt;/span&gt;

&lt;span class=dmpreprocessor&gt;# Set it to the above located working directory. Mine was /home/audeuro/byond/bin.&lt;/span&gt;

export LD_LIBRARY_PATH=/home/audeuro/byond/bin

&lt;span class=dmpreprocessor&gt;# Now we execute DreamDaemon, which is where our world/executor was pointed at.&lt;/span&gt;

exec /home/audeuro/byond/bin/DreamDaemon /home/audeuro/www/index.dmb -CGI -logself -trusted&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;br/&gt;
&lt;br/&gt;
Now, CHMOD the just-created index.cgi to 755, and you should be good to go!</description>
        </item>
                <item>
            <title>Installing DMCGI as root on an Apache Linux system.</title>
            <link>http://www.byond.com/members/?command=view_post&amp;post=31527</link>
            <guid>http://www.byond.com/members/?command=view_post&amp;post=31527</guid>
            <pubDate>Wed, 13 Jun 2007 00:24:59 GMT</pubDate>
            
            <comments>http://www.byond.com/members/DMCGI?command=view_comments&amp;post=31527#comments</comments>
            
            <description>Installing DMCGI as root is pretty simple, this will show you how to install DMCGI as root on any Linux server running Apache.&lt;br/&gt;
&lt;br/&gt;
First you need to download and install BYOND as root, this is accomplished by unzipping the byond_linux.zip file, navigating to the newly created 'byond' directory and running the 'make install' command. &lt;br/&gt;
&lt;br/&gt;
After that you need to configure Apache to recognize the .dmb extension as a valid CGI extension. Open your 'apache2.conf' or 'httpd.conf' file in your favorite text editor and search for the line 'AddHandler cgi-script' if found uncomment it (if commented) and add 'dmb' to the end of it. If you don't find it simply add the line &lt;br/&gt;
&lt;br/&gt;
AddHandler cgi-script dmb&lt;br/&gt;
&lt;br/&gt;
Next you'll want to find the 'DirectoryIndex' line and add index.dmb as a valid index file. After that's all done save the file and restart Apache.&lt;br/&gt;
&lt;br/&gt;
Now upload your DMCGI file and CHMOD it to 755, you should be ready to rock. If you encounter any problems just head on over to the Installation forum and we'll give you a hand.</description>
        </item>
                <item>
            <title>Connecting to MySQL databases with DMCGI</title>
            <link>http://www.byond.com/members/?command=view_post&amp;post=31526</link>
            <guid>http://www.byond.com/members/?command=view_post&amp;post=31526</guid>
            <pubDate>Wed, 13 Jun 2007 00:17:58 GMT</pubDate>
            
            <comments>http://www.byond.com/members/DMCGI?command=view_comments&amp;post=31526#comments</comments>
            
            <description>Here's a little diddy showing how to connect to a MySQL database using DMCGI.&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;&lt;span class=dmpreprocessor&gt;#include &amp;lt;dantom\db\db.dme&amp;gt; &lt;/span&gt;&lt;span class=dmcomment&gt;// Include the DB library.&lt;/span&gt;

CGI/Topic(href,href_list[])
    &lt;span class=dmkeyword&gt;var&lt;/span&gt;/output = &lt;span class=dmstring&gt;&quot;&amp;lt;HTML&amp;gt;&amp;amp;lt;BODY&amp;amp;gt;&quot;&lt;/span&gt;
    &lt;span class=dmkeyword&gt;if&lt;/span&gt;(href_list[&lt;span class=dmstring&gt;&quot;getdata&quot;&lt;/span&gt;])
        &lt;span class=dmkeyword&gt;var&lt;/span&gt;
            data = href_list[&lt;span class=dmstring&gt;&quot;getdata&quot;&lt;/span&gt;]
            DBConnection/dbcon = &lt;span class=dmkeyword&gt;new&lt;/span&gt;() &lt;span class=dmcomment&gt;//  New connection object.&lt;/span&gt;
            connected = dbcon.Connect(&lt;span class=dmstring&gt;&quot;dbi:mysql:my_database:localhost:3306&quot;&lt;/span&gt;,&lt;span class=dmstring&gt;&quot;username&quot;&lt;/span&gt;,&lt;span class=dmstring&gt;&quot;password&quot;&lt;/span&gt;)
            &lt;span class=dmcomment&gt;// The Connect() proc hooks you up to the database using MySQL's 'dbi' handler.&lt;/span&gt;
        &lt;span class=dmkeyword&gt;if&lt;/span&gt;(!connected) &lt;span class=dmcomment&gt;// No connection.&lt;/span&gt;
            usr &amp;lt;&amp;lt; connected.ErrorMsg() &lt;span class=dmcomment&gt;// Error.&lt;/span&gt;
            &lt;span class=dmkeyword&gt;return&lt;/span&gt;
        &lt;span class=dmkeyword&gt;var&lt;/span&gt;/sql = &lt;span class=dmstring&gt;&quot;SELECT '&lt;/span&gt;&lt;span class=dmbrace&gt;[data]&lt;/span&gt;&lt;span class=dmstring&gt;' FROM my_table&quot;&lt;/span&gt; &lt;span class=dmcomment&gt;// Simple MySQL query.&lt;/span&gt;
        &lt;span class=dmkeyword&gt;var&lt;/span&gt;/DBQuery/query = &lt;span class=dmkeyword&gt;new&lt;/span&gt;() &lt;span class=dmcomment&gt;// Creates a new query object.&lt;/span&gt;
        connected = query.Execute(sql) &lt;span class=dmcomment&gt;// Reuse the connected var.&lt;/span&gt;
        &lt;span class=dmkeyword&gt;if&lt;/span&gt;(!connected)  &lt;span class=dmcomment&gt;// Query failed.&lt;/span&gt;
            usr &amp;lt;&amp;lt; query.ErrorMsg() &lt;span class=dmcomment&gt;// Error.&lt;/span&gt;
            &lt;span class=dmkeyword&gt;return&lt;/span&gt;
        &lt;span class=dmkeyword&gt;while&lt;/span&gt;(query.NextRow()) &lt;span class=dmcomment&gt;// Loops over the rows matching your query&lt;/span&gt;
            &lt;span class=dmkeyword&gt;var&lt;/span&gt;/rdat = query.GetColumnData() &lt;span class=dmcomment&gt;// Little proc that converts the data from numbers to text indexes.&lt;/span&gt;
            &lt;span class=dmkeyword&gt;for&lt;/span&gt;(&lt;span class=dmkeyword&gt;var&lt;/span&gt;/R &lt;span class=dmkeyword&gt;in&lt;/span&gt; rdat) &lt;span class=dmcomment&gt;// Loop over everything it finds.&lt;/span&gt;
                output += &lt;span class=dmstring&gt;&quot;&lt;/span&gt;&lt;span class=dmbrace&gt;[R]&lt;/span&gt;&lt;span class=dmstring&gt;: &lt;/span&gt;&lt;span class=dmbrace&gt;[rdat[R]]&lt;/span&gt;&lt;span class=dmstring&gt;&quot;&lt;/span&gt; &lt;span class=dmcomment&gt;// And output it.&lt;/span&gt;
        &lt;span class=dmcomment&gt;// Close up the database connections and whatnot&lt;/span&gt;
        query.Close()
        dbcon.Close()
        &lt;span class=dmkeyword&gt;del&lt;/span&gt;(query)
        &lt;span class=dmkeyword&gt;del&lt;/span&gt;(dbcon)
    &lt;span class=dmkeyword&gt;else&lt;/span&gt; &lt;span class=dmcomment&gt;// Simple form to select which information you want&lt;/span&gt;
        output += &lt;span class=dmstring&gt;{&quot;&amp;lt;form action=&quot;?&quot; method=&quot;GET&quot;&amp;gt;
                  Get Some Data: &amp;lt;input type=&quot;text&quot; value=&quot;getdata&quot;&amp;gt;
                  &amp;lt;input type=&quot;submit&quot;&amp;gt;&amp;lt;/form&amp;gt;&quot;}&lt;/span&gt;
    output += &lt;span class=dmstring&gt;&quot;&amp;amp;lt;/BODY&amp;amp;gt;&amp;lt;/HTML&amp;gt;&quot;&lt;/span&gt;
    usr &amp;lt;&amp;lt; output&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;br/&gt;
&lt;br/&gt;
Note: This is to LEARN from, this code won't work just because. Various values must be changed for it to even connect to your database.</description>
        </item>
                <item>
            <title>Communicating with your game using DMCGI.</title>
            <link>http://www.byond.com/members/?command=view_post&amp;post=31525</link>
            <guid>http://www.byond.com/members/?command=view_post&amp;post=31525</guid>
            <pubDate>Wed, 13 Jun 2007 00:16:36 GMT</pubDate>
            
            <comments>http://www.byond.com/members/DMCGI?command=view_comments&amp;post=31525#comments</comments>
            
            <description>Say you want to communicate with your game with a DMCGI script, no problem -- it's easy!&lt;br/&gt;
&lt;br/&gt;
&lt;b&gt;This will be your game's source&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;world/Topic(href)
    &lt;span class=dmkeyword&gt;var&lt;/span&gt;/list/hlist = params2list(href) &lt;span class=dmcomment&gt;// Similar to href_list[] in CGI/Topic()&lt;/span&gt;
    &lt;span class=dmkeyword&gt;if&lt;/span&gt;(hlist[&lt;span class=dmstring&gt;&quot;message&quot;&lt;/span&gt;])
        world &amp;lt;&amp;lt; &lt;span class=dmstring&gt;&quot;Remote message: &lt;/span&gt;&lt;span class=dmbrace&gt;[hlist[&quot;message&quot;]]&lt;/span&gt;&lt;span class=dmstring&gt;&quot;&lt;/span&gt;
        . = &lt;span class=dmstring&gt;&quot;Message sent.&quot;&lt;/span&gt;
    &lt;span class=dmkeyword&gt;else&lt;/span&gt;
        . = &lt;span class=dmstring&gt;&quot;Something didn't work...&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;
&lt;b&gt;This will be your DMCGI source&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;&lt;span class=dmpreprocessor&gt;#define GAME_ADDR &quot;localhost:1234&quot; &lt;/span&gt;&lt;span class=dmcomment&gt;// Address to your game&lt;/span&gt;

CGI/Topic(href,href_list[])
    &lt;span class=dmkeyword&gt;if&lt;/span&gt;(!href)
        usr &amp;lt;&amp;lt; &lt;span class=dmstring&gt;{&quot;&amp;lt;form action=&quot;?&quot; method=&quot;GET&quot;&amp;gt;
Message: &amp;lt;input type=&quot;text&quot; value=&quot;message&quot;&amp;gt; &amp;lt;input type=&quot;submit&quot;&amp;gt;&amp;lt;/form&amp;gt;&quot;}&lt;/span&gt;
    &lt;span class=dmkeyword&gt;else&lt;/span&gt;
        &lt;span class=dmkeyword&gt;if&lt;/span&gt;(href_list[&lt;span class=dmstring&gt;&quot;message&quot;&lt;/span&gt;])
            usr &amp;lt;&amp;lt; world.Export(&lt;span class=dmstring&gt;&quot;byond://&lt;/span&gt;&lt;span class=dmbrace&gt;[GAME_ADDR]&lt;/span&gt;&lt;span class=dmstring&gt;?message=&lt;/span&gt;&lt;span class=dmbrace&gt;[href_list[&quot;message&quot;]]&lt;/span&gt;&lt;span class=dmstring&gt;&quot;&lt;/span&gt;)
        &lt;span class=dmkeyword&gt;else&lt;/span&gt;
            usr &amp;lt;&amp;lt; &lt;span class=dmstring&gt;&quot;Hmm, that didn't work!&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;
Something like that should get you on your way to having nice DMCGI/Game communications, enjoy!</description>
        </item>
                <item>
            <title>Using HTML forms.</title>
            <link>http://www.byond.com/members/?command=view_post&amp;post=31524</link>
            <guid>http://www.byond.com/members/?command=view_post&amp;post=31524</guid>
            <pubDate>Wed, 13 Jun 2007 00:15:21 GMT</pubDate>
            
            <comments>http://www.byond.com/members/DMCGI?command=view_comments&amp;post=31524#comments</comments>
            
            <description>&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;&lt;span class=dmcomment&gt;// This is an example of how to use HTML forms with DMCGI&lt;/span&gt;

CGI
    Topic(href,href_list[])
        &lt;span class=dmkeyword&gt;if&lt;/span&gt;(href) &lt;span class=dmcomment&gt;// Sanity check&lt;/span&gt;
            &lt;span class=dmkeyword&gt;if&lt;/span&gt;(href_list[&lt;span class=dmstring&gt;&quot;value&quot;&lt;/span&gt;])
                usr &amp;lt;&amp;lt; &lt;span class=dmstring&gt;&quot;You entered: &lt;/span&gt;&lt;span class=dmbrace&gt;[href_list[&quot;value&quot;]]&lt;/span&gt;&lt;span class=dmstring&gt;&quot;&lt;/span&gt;
            &lt;span class=dmkeyword&gt;else&lt;/span&gt;
                usr &amp;lt;&amp;lt; &lt;span class=dmstring&gt;&quot;You brokerated it, fiend!&quot;&lt;/span&gt;
        &lt;span class=dmkeyword&gt;else&lt;/span&gt;
            usr &amp;lt;&amp;lt; &lt;span class=dmstring&gt;{&quot;Please enter a value: 
&amp;lt;form action=&quot;?&quot; method=&quot;GET&quot;&amp;gt;
&amp;lt;input type=&quot;text&quot; name=&quot;value&quot;&amp;gt;
&amp;lt;input type=&quot;submit&quot;&amp;gt;&amp;lt;/form&amp;gt;&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;
href and href_list are simply the arguments passed to your DMCGI application. href is a simple text version and href_list is the result of params2list(href).</description>
        </item>
                <item>
            <title>Hello World!</title>
            <link>http://www.byond.com/members/?command=view_post&amp;post=31523</link>
            <guid>http://www.byond.com/members/?command=view_post&amp;post=31523</guid>
            <pubDate>Tue, 12 Jun 2007 23:58:29 GMT</pubDate>
            
            <comments>http://www.byond.com/members/DMCGI?command=view_comments&amp;post=31523#comments</comments>
            
            <description>&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;&lt;span class=dmcomment&gt;// This is a simple DMCGI 'Hello World' program&lt;/span&gt;

&lt;span class=dmpreprocessor&gt;#include &amp;lt;dantom\cgi\CGI.dme&amp;gt;&lt;/span&gt;

CGI
    Topic() &lt;span class=dmcomment&gt;// This is called everytime a page is loaded&lt;/span&gt;
        usr &amp;lt;&amp;lt; browse(&lt;span class=dmstring&gt;&quot;Hello world!&quot;&lt;/span&gt;) &lt;span class=dmcomment&gt;// Outputs 'Hello world!' to the user.&lt;/span&gt;


&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;br/&gt;
&lt;br/&gt;
As a note, in pure CGI mode simply using &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;usr &amp;lt;&amp;lt; &lt;span class=dmstring&gt;&quot;Hello world!&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;
Would have the same effect, using browse() is helpful for testing within Dream Seeker.</description>
        </item>
            
    </channel>
</rss>

