includes/sessions.php
changeset 1175 1e2c9819ede3
parent 1173 b5b8e7ab0914
child 1176 5c98b9f181f0
equal deleted inserted replaced
1174:def792dd9b1b 1175:1e2c9819ede3
  2246    */
  2246    */
  2247   
  2247   
  2248   function admin_activation_request($u)
  2248   function admin_activation_request($u)
  2249   {
  2249   {
  2250     global $db;
  2250     global $db;
  2251     $this->sql('INSERT INTO '.table_prefix.'logs(log_type, action, time_id, date_string, author, edit_summary) VALUES(\'admin\', \'activ_req\', '.time().', \''.enano_date(ED_DATE | ED_TIME).'\', \''.$this->username.'\', \''.$db->escape($u).'\');');
  2251     $this->sql('INSERT INTO '.table_prefix.'logs(log_type, action, time_id, date_string, author, author_uid, edit_summary) VALUES(\'admin\', \'activ_req\', '.time().', \''.enano_date(ED_DATE | ED_TIME).'\', \''.$this->username.'\', ' . $session->user_id . ', \''.$db->escape($u).'\');');
  2252   }
  2252   }
  2253   
  2253   
  2254   /**
  2254   /**
  2255    * Activates a user account. If the action fails, a report is sent to the admin.
  2255    * Activates a user account. If the action fails, a report is sent to the admin.
  2256    * @param string $user The username of the user requesting activation
  2256    * @param string $user The username of the user requesting activation
  2258    */
  2258    */
  2259   
  2259   
  2260   function activate_account($user, $key)
  2260   function activate_account($user, $key)
  2261   {
  2261   {
  2262     global $db, $session, $paths, $template, $plugins; // Common objects
  2262     global $db, $session, $paths, $template, $plugins; // Common objects
  2263     $this->sql('UPDATE '.table_prefix.'users SET account_active=1 WHERE username=\''.$db->escape($user).'\' AND activation_key=\''.$db->escape($key).'\';');
  2263     $q = $this->sql('SELECT 1 FROM ' . table_prefix . 'users WHERE username = \''.$db->escape($user).'\' AND activation_key = \''.$db->escape($key).'\'');
  2264     $r = mysql_affected_rows();
  2264     if ( $db->numrows() > 0 )
  2265     if ( $r > 0 )
  2265     {
  2266     {
  2266       $new_key = md5(AESCrypt::randkey());
  2267       $e = $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary) VALUES(\'security\', \'activ_good\', '.time().', \''.enano_date(ED_DATE | ED_TIME).'\', \''.$db->escape($user).'\', \''.$_SERVER['REMOTE_ADDR'].'\')');
  2267       $this->sql('UPDATE ' . table_prefix . 'users SET account_active = 1, activation_key = \'' . $new_key . '\' WHERE username=\''.$db->escape($user).'\' AND activation_key=\''.$db->escape($key).'\';');
       
  2268       $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary) VALUES(\'security\', \'activ_good\', '.time().', \''.enano_date(ED_DATE | ED_TIME).'\', \''.$db->escape($user).'\', \''.$_SERVER['REMOTE_ADDR'].'\')');
  2268     }
  2269     }
  2269     else
  2270     else
  2270     {
  2271     {
  2271       $e = $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary) VALUES(\'security\', \'activ_bad\', '.time().', \''.enano_date(ED_DATE | ED_TIME).'\', \''.$db->escape($user).'\', \''.$_SERVER['REMOTE_ADDR'].'\')');
  2272       $this->sql('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary) VALUES(\'security\', \'activ_bad\', '.time().', \''.enano_date(ED_DATE | ED_TIME).'\', \''.$db->escape($user).'\', \''.$_SERVER['REMOTE_ADDR'].'\')');
  2272     }
  2273     }
  2273     return $r;
  2274     return $r;
  2274   }
  2275   }
  2275   
  2276   
  2276   /**
  2277   /**