Browse code

changes to cert login stuff

schokokeks.org web services authored on01/12/2017 14:00:04
Showing3 changed files
... ...
@@ -29,22 +29,9 @@ require_once('inc/base.php');
29 29
 require_once('inc/debug.php');
30 30
 require_once('inc/error.php');
31 31
 require_once('inc/theme.php');
32
+require_once('modules/index/include/x509.php');
32 33
 
33 34
 
34
-function get_logins_by_cert($cert) 
35
-{
36
-	$result = db_query("SELECT type,username,startpage FROM system.clientcert WHERE cert=? ORDER BY type,username", array($cert));
37
-	if ($result->rowCount() < 1)
38
-		return NULL;
39
-	else {
40
-		$ret = array();
41
-		while ($row = $result->fetch()) {
42
-			$ret[] = $row;
43
-		}
44
-		return $ret;
45
-	}
46
-}
47
-
48 35
 DEBUG('$_SERVER:');
49 36
 DEBUG($_SERVER);
50 37
 
... ...
@@ -123,12 +123,14 @@ function require_role($roles)
123 123
 }
124 124
 
125 125
 
126
-function login_screen($why)
126
+function login_screen($why = NULL)
127 127
 {
128
-  if (have_module('index')) {
129
-    if (isset($_COOKIE['CLIENTCERT_AUTOLOGIN']) && $_COOKIE['CLIENTCERT_AUTOLOGIN'] == '1') {
130
-      require_once('modules/index/include/x509.php');
131
-      do_ajax_cert_login();
128
+  if (! $why) {
129
+    if (have_module('index')) {
130
+      if (isset($_COOKIE['CLIENTCERT_AUTOLOGIN']) && $_COOKIE['CLIENTCERT_AUTOLOGIN'] == '1') {
131
+        require_once('modules/index/include/x509.php');
132
+        do_ajax_cert_login();
133
+      }
132 134
     }
133 135
   }
134 136
   require_once('inc/theme.php');
... ...
@@ -24,7 +24,7 @@ function do_ajax_cert_login() {
24 24
 
25 25
 function get_logins_by_cert($cert) 
26 26
 {
27
-	$result = db_query("SELECT type,username,startpage FROM system.clientcert WHERE cert=?", array($cert));
27
+	$result = db_query("SELECT type,username,startpage FROM system.clientcert WHERE cert=? ORDER BY type,username", array($cert));
28 28
 	if ($result->rowCount() < 1)
29 29
 		return NULL;
30 30
 	else {