[sork] update to sql.php to support virtual domains (domain_field)

Ilya mail at krel.org
Fri Aug 29 10:59:05 PDT 2003


see patch

-------------- next part --------------
--- sql.php	Fri Aug 29 13:56:26 2003
+++ sql.php.new	Fri Aug 29 13:56:12 2003
@@ -106,12 +106,18 @@
 
         if (!empty($this->_params['query_lookup'])) {
             $sql = $this->_parseQuery($this->_params['query_lookup'], $user, $old_password);
+        } elseif (isset($this->_params['domain_col'])){
+            list($name,$domain)=explode('@',$user);
+            $sql  = 'SELECT ' . $this->_params['pass_col'];
+            $sql .= ' FROM ' . $this->_params['table'];
+            $sql .= ' WHERE ' . $this->_params['user_col'] . ' = ' . $this->_db->quote($name);
+            $sql .= 'and ' . $this->_params['domain_col'] . ' = ' . $this->_db->quote($domain);
+Horde::logMessage("SQL Query" . $sql , __FILE__, __LINE__, PEAR_LOG_DEBUG);
         } else {
             /* Build the SQL query. */
             $sql  = 'SELECT ' . $this->_params['pass_col'] . ' FROM ' . $this->_params['table'];
             $sql .= ' WHERE ' . $this->_params['user_col'] . ' = ' . $this->_db->quote($user);
         }
-        Horde::logMessage('SQL Query by Passwd_Driver_sql::_lookup(): ' . $sql, __FILE__, __LINE__, PEAR_LOG_DEBUG);
 
         /* Execute the query. */
         $result = $this->_db->query($sql);
@@ -147,6 +153,18 @@
 
         if (!empty($this->_params['query_modify'])) {
             $sql = $this->_parseQuery($this->_params['query_modify'], $user, $new_password);
+        } elseif (isset($this->_params['domain_col'])){
+            /* Encrypt the password. */
+            $new_password = $this->encryptPassword($new_password, $this->_params['show_encryption']);
+
+            /* Split the user name. */
+            list($name,$domain)=explode('@',$user);
+
+            /* Build the SQL query. */
+            $sql = 'UPDATE ' . $this->_params['table'];
+            $sql .= ' SET ' . $this->_params['pass_col'] . ' = ' . $this->_db->quote($new_password);
+            $sql .= ' WHERE ' . $this->_params['user_col'] . ' = ' . $this->_db->quote($name);
+            $sql .= ' and ' . $this->_params['domain_col'] . ' = ' . $this->_db->quote($domain);
         } else {
             /* Encrypt the password. */
             $new_password = $this->encryptPassword($new_password, $this->_params['show_encryption']);


More information about the sork mailing list