Second strike: Convert permission check
authorJoey Schulze <joey@infodrom.org>
Mon, 16 Sep 2013 21:23:47 +0000 (23:23 +0200)
committerJoey Schulze <joey@infodrom.org>
Mon, 16 Sep 2013 21:23:47 +0000 (23:23 +0200)
lib/general.php

index 69810bf..7df4c8f 100644 (file)
@@ -78,20 +78,14 @@ function check_permissions($name)
                 . "WHERE sys_group_mask.gid = %d AND fname = %s",
                 $_SESSION['sys']['group'], $db->quote($form));
 
-  $sth = $db->query($sql);
-
-  if ($sth === false) {
-    error_log('Unauthorised access to ' . $form);
-    return false;
-  }
+  $count = $db->fetchValue($sql);
 
-  $row = $sth->fetch();
-  if ($row === false) {
+  if ($count === false) {
     error_log('Unauthorised access to ' . $form);
     return false;
   }
 
-  if ($row['count'] == 0) {
+  if ($count == 0) {
     error_log('Unauthorised access to ' . $form);
     return false;
   }