Browse code

stringlänge mit strlen und nicht mit count messen

git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1467 87cf0b9e-d624-0410-a070-f6ee81989793

bernd authored on 14/09/2009 18:28:25
Showing 2 changed files
... ...
@@ -56,6 +56,18 @@ function set_mysql_access($db, $account, $status)
56 56
   {
57 57
     if (get_mysql_access($db, $account))
58 58
       return NULL;
59
+    $result = db_query("SELECT id FROM misc.mysql_database WHERE name='{$db}' AND useraccount={$uid} LIMIT 1");
60
+    if (mysql_num_rows($result) != 1)
61
+    {
62
+      logger(LOG_ERR, "modules/mysql/include/mysql", "mysql", "cannot find database {$db}");
63
+      system_failure("cannot find database »{$db}«");
64
+    }
65
+    $result = db_query("SELECT id FROM misc.mysql_database WHERE username='{$account}' AND useraccount={$uid} LIMIT 1");
66
+    if (mysql_num_rows($result) != 1)
67
+    {
68
+      logger(LOG_ERR, "modules/mysql/include/mysql", "mysql", "cannot find user {$account}");
69
+      system_failure("cannot find database user »{$account}«");
70
+    }
59 71
     $query = "INSERT INTO misc.mysql_access (`database`,user) VALUES ((SELECT id FROM misc.mysql_database WHERE name='{$db}' AND useraccount={$uid} LIMIT 1), (SELECT id FROM misc.mysql_accounts WHERE username='{$account}' AND useraccount={$uid}));";
60 72
     logger(LOG_INFO, "modules/mysql/include/mysql", "mysql", "granting access on »{$db}« to »{$account}«");
61 73
   }
... ...
@@ -129,7 +141,7 @@ function validate_mysql_dbname($dbname)
129 141
 
130 142
 function validate_mysql_username($username)
131 143
 {
132
-  return validate_mysql_dbname($username) && (count($username) <= 16);
144
+  return validate_mysql_dbname($username) && (strlen($username) <= 16);
133 145
 }
134 146
 
135 147
 
... ...
@@ -91,6 +91,7 @@ function create_webapp_mysqldb($application, $sitename)
91 91
   
92 92
   if (validate_mysql_username($handle) && validate_mysql_dbname($handle) && ! (has_mysql_user($handle) || has_mysql_database($handle)))
93 93
   {
94
+    logger(LOG_INFO, "webapps/include/webapp-installer", "create", "creating db and user »{$handle}«");
94 95
     create_mysql_database($handle, $description);
95 96
     create_mysql_account($handle, $description);
96 97
     set_mysql_access($handle, $handle, true);
... ...
@@ -103,6 +104,7 @@ function create_webapp_mysqldb($application, $sitename)
103 104
     $handle = $username.'_'.$i;
104 105
     if (validate_mysql_username($handle) && validate_mysql_dbname($handle) && ! (has_mysql_user($handle) || has_mysql_database($handle)))
105 106
     {
107
+      logger(LOG_INFO, "webapps/include/webapp-installer", "create", "creating db and user »{$handle}«");
106 108
       create_mysql_database($handle, $description);
107 109
       create_mysql_account($handle, $description);
108 110
       set_mysql_access($handle, $handle, true);