[mw-devel] MW3 r1231 - trunk/webclient
dez at sucs.org
dez at sucs.org
Sat Nov 13 12:18:35 GMT 2010
Author: dez
Date: 2010-11-13 12:18:35 +0000 (Sat, 13 Nov 2010)
New Revision: 1231
Modified:
trunk/webclient/poll.php
trunk/webclient/send.php
trunk/webclient/startup.php
Log:
Switch to the poller at /var/lib64/mw/mwpoll done correctly.
Modified: trunk/webclient/poll.php
===================================================================
--- trunk/webclient/poll.php 2010-11-12 21:08:39 UTC (rev 1230)
+++ trunk/webclient/poll.php 2010-11-13 12:18:35 UTC (rev 1231)
@@ -12,7 +12,7 @@
$log = fopen("poll.log", "a");
fwrite($log, "Poll hit pid='$sess' auth='$auth'\n");
-$path = sprintf("/tmp/mwnoddy.%d", $sess);
+$path = "/var/run/mw/mwpoll.".$sess;
header("Content-type: application/json; charset=utf-8");
Modified: trunk/webclient/send.php
===================================================================
--- trunk/webclient/send.php 2010-11-12 21:08:39 UTC (rev 1230)
+++ trunk/webclient/send.php 2010-11-13 12:18:35 UTC (rev 1231)
@@ -12,7 +12,7 @@
$log = fopen("poll.log", "a");
fwrite($log, "Send hit pid='$sess' auth='$auth'\n");
-$path = sprintf("/tmp/mwnoddy.%d", $sess);
+$path = "/var/run/mw/mwpoll.".$sess;
header("Content-type: application/json");
Modified: trunk/webclient/startup.php
===================================================================
--- trunk/webclient/startup.php 2010-11-12 21:08:39 UTC (rev 1230)
+++ trunk/webclient/startup.php 2010-11-13 12:18:35 UTC (rev 1231)
@@ -3,6 +3,10 @@
$username = trim($_REQUEST['username']);
$password = trim($_REQUEST['password']);
+### Preliminary checks
+
+# Have we been passed SUCSsite cookies?
+# If not, test that the login details make sense.
if (@$_REQUEST['sucssite_loggedin']!="true") {
if (empty($username) || empty($password)) {
$smarty->assign("error", "username and password must both be not empty");
@@ -19,6 +23,8 @@
}
}
+# Have we been asked to create a new Milliways account?
+# If so, make sure that the password supplied is suitable.
if ($action=="create") {
$pass1 = @$_REQUEST['password1'];
$pass2 = @$_REQUEST['password2'];
@@ -54,9 +60,14 @@
);
$pipes = array();
+# Have we got SUCSsite cookies?
+# And no login attempt?
+# If so, fetch the user details and try to log in without a password.
if (@$_REQUEST['sucssite_loggedin']=="true" && empty($username)) {
+# Do we appear to be in the SUCSsite environment?
+# There's only any point trying if we do.
+if (file_exists("../settings.php")) {
# Do the bare minimum of SUCSsite init to retrieve the username for the session we've been passed
- # We should probably do this more intelligently to fail silently if it doesn't work...
include("../settings.php");
// Initialise the database
require("/usr/share/php/adodb/adodb.inc.php");
@@ -69,17 +80,24 @@
$session = new Session;
$smarty->assign_by_ref("session", $session);
$realuser = $session->username;
-
if ($action == "create") {
$p = proc_open($mwpoll." -a -u ".$realuser." -s", $desc, $pipes);
} else {
$p = proc_open($mwpoll." -u ".$realuser." -s", $desc, $pipes);
}
+}
} else {
+# If not, try logging in with a password.
$p = proc_open($mwpoll." -u $username", $desc, $pipes);
}
+if (empty($p)) {
+ $smarty->assign_by_ref("body", $smarty->fetch("login.html"));
+ $smarty->display("main.html");
+ exit;
+}
+
if ($p === FALSE) {
$smarty->assign("error", "failed to exec mwpoll");
$smarty->assign_by_ref("body", $smarty->fetch("login.html"));
More information about the mw-devel
mailing list