ID:134645
 
Is there some way I can control the DMCGI style login using PHP?

Making the login screen in BYOND return to my website was easy.

Which in PHP would be done like:
<?
echo("<a href='https://secure.byond.com/console.cgi?qd=login;url=http://www.tibbius.com/'>Login</a>");
?>


But is there a way for me to display, at least, the users keyname in PHP?

(Nadrew suggested I ask in this forum)
Yep, although it can get a little messy if things aren't setup properly.

Basically what you want to do is use a PHP script and shell_exec() a DMCGI world. Make the DMCGI world output the users key, then back in your PHP script take the value shell_exec() returns and get the key out of it.

Here's something Mike H showed me that demonstrates it much better than my explaination. whoami.dmb is just a simple little DMCGI application that outputs the users key (and nothing else).


#!/dh/cgi-system/php.cgi
<html>
<head><title>BYOND login test</title></head>
<body>
">Log in


<?php
// Login auth stuff
$exec_string="/home/byond/whoami.dmb | tail -1";
$authinfo=shell_exec($exec_string);
// remove newline character
$endchar = substr("$authinfo", strlen("$authinfo") - 1, 1);
if ($endchar == "\n") {
$authinfo = substr("$authinfo", 0, -1);
}
echo "Hello, $authinfo!";
?>
</body>
</html>

In response to DarkView
Is there a way that doesn't require me to install DMCGI on my server? Having to call a DMCGI script defeats the idea. I might aswell make the site in DMCGI <.<

Thanks anyways =P
In response to Tiberath
Oh sorry. I assumed you had a DMCGI enabled server. Short answer no, long answer yes but it requires the same access level as installing DMCGI and much more work. So if you can't install DMCGI then it's not possible.
In response to DarkView
I can install DMCGI no problem. The server specs will accept it. I'd just rather not.
In response to Tiberath
Tiberath wrote:
I can install DMCGI no problem. The server specs will accept it. I'd just rather not.

Why not? DMCGI is great. :D
In response to Jon88
So is PHP :P
In response to Scoobert
Scoobert wrote:
So is PHP :P

PHP has neither DM's savefiles nor the BYOND key system. :P
In response to Jon88
Good thing you can use MySQL databases to save information and create your own authentication system (Although it is nice to keep the same key database if your site is directly BYOND releated).
In response to Jon88
You'll find that working with both together is the best solution. You do as much work in PHP as possible, then shell into DMCGI for stuff like keys.
That way you barely need to compile, but you can still make use of all DMCGI's great features.


As for the original topic, if you can install DMCGI do it. You're not going to find an easier or better way than that method (Mike H's). Trust me, I've spent a lot of time trying to get DMCGI and PHP to play nice. =P
In response to Scoobert
Scoobert wrote:
Good thing you can use MySQL databases to save information

DMCGI can too. It does a fairly good job of it thanks to Nadrew's modifications to hub://Dantom.DB
In response to Jon88
Well, savefiles are probably best left out of DMCGI unless you have no other option. There are just too many file access issues to use it with total confidence.
In response to Nadrew
Right, I guess I have no option but to install DMCGI. Alas.
Not that it matters, I'm not making a BYOND releated system, at this moment. It was more a question for the future. Incase, for some reason, I decided to make a funny looking BYOND fansite with fancy thingers.

Try not to trun this into "OMG PHP VS DMCGI ROYAL RUMBLE!" <.<
In response to Jon88
Jon88 wrote:
Scoobert wrote:
So is PHP :P

PHP has neither DM's savefiles nor the BYOND key system. :P

1) PHP can potentially do better a better savefile system than DM can (IMHO);

2) as pointed out earlier, you can interact with the BYOND key system, it just takes a bit of work.

3) PHP/DMcgi can be a very powerful combination.