コード例 #1
0
ファイル: login.php プロジェクト: buxiaoyang/EmailArchive
 public function index()
 {
     $this->id = "content";
     $this->template = "login/login.tpl";
     $this->layout = "common/layout-empty";
     if (Registry::get('username')) {
         header("Location: search.php");
         exit;
     }
     $request = Registry::get('request');
     $session = Registry::get('session');
     $db = Registry::get('db');
     $this->load->model('user/auth');
     $this->load->model('user/user');
     $this->load->model('user/prefs');
     $this->load->model('domain/domain');
     $this->load->model('folder/folder');
     if (ENABLE_SAAS == 1) {
         $this->load->model('saas/ldap');
         $this->load->model('saas/customer');
     }
     $this->data['title'] = $this->data['text_login'];
     $this->data['title_prefix'] = TITLE_PREFIX;
     $this->data['failed_login_count'] = $this->model_user_auth->get_failed_login_count();
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate() == true) {
         if ($this->model_user_auth->checkLogin($this->request->post['username'], $_POST['password']) == 1) {
             if ($session->get("ga_block") == 1) {
                 header("Location: " . SITE_URL . "index.php?route=login/ga");
                 exit;
             } else {
                 $this->model_user_prefs->get_user_preferences($session->get('username'));
                 if (ENABLE_SAAS == 1) {
                     $this->model_saas_customer->online($session->get('email'));
                 }
                 LOGGER('logged in');
                 if (isAdminUser() == 1) {
                     header("Location: " . SITE_URL . "index.php?route=health/health");
                     exit;
                 }
                 header("Location: " . SITE_URL . "search.php");
                 exit;
             }
         } else {
             $this->model_user_auth->increment_failed_login_count($this->data['failed_login_count']);
             $this->data['failed_login_count']++;
         }
         $this->data['x'] = $this->data['text_invalid_email_or_password'];
     }
     if (ENABLE_GOOGLE_LOGIN == 1) {
         $client = new apiClient();
         $client->setApplicationName(GOOGLE_APPLICATION_NAME);
         $client->setScopes(array('https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://mail.google.com/'));
         $client->setClientId(GOOGLE_CLIENT_ID);
         $client->setClientSecret(GOOGLE_CLIENT_SECRET);
         $client->setRedirectUri(GOOGLE_REDIRECT_URL);
         $client->setDeveloperKey(GOOGLE_DEVELOPER_KEY);
         $this->data['auth_url'] = $client->createAuthUrl();
     }
     $this->render();
 }
コード例 #2
0
ファイル: auto.php プロジェクト: buxiaoyang/EmailArchive
 public function remove($id = 0)
 {
     if ($id == 0) {
         return 0;
     }
     $query = $this->db->query("DELETE FROM " . TABLE_AUTOSEARCH . " WHERE id=?", array($id));
     $rc = $this->db->countAffected();
     LOGGER("remove autosearch: {$id} (rc={$rc})");
     return $rc;
 }
コード例 #3
0
ファイル: import.php プロジェクト: buxiaoyang/EmailArchive
 public function delete($id = 0, $description = '')
 {
     if ($id == 0) {
         return 0;
     }
     $query = $this->db->query("DELETE FROM " . TABLE_IMPORT . " WHERE id=?", array($id));
     $rc = $this->db->countAffected();
     LOGGER("remove import entry: #{$id}, {$description}  (rc={$rc})");
     return $rc;
 }
コード例 #4
0
ファイル: ldap.php プロジェクト: buxiaoyang/EmailArchive
 public function add($arr = array())
 {
     if (!isset($arr['description']) || !isset($arr['ldap_host'])) {
         return 0;
     }
     $query = $this->db->query("INSERT INTO " . TABLE_LDAP . " (description, ldap_host, ldap_base_dn, ldap_bind_dn, ldap_bind_pw, ldap_type, ldap_auditor_member_dn, ldap_mail_attr, ldap_account_objectclass, ldap_distributionlist_attr, ldap_distributionlist_objectclass) VALUES (?,?,?,?,?,?,?,?,?,?,?)", array($arr['description'], $arr['ldap_host'], $arr['ldap_base_dn'], $arr['ldap_bind_dn'], $arr['ldap_bind_pw'], $arr['ldap_type'], $arr['ldap_auditor_member_dn'], $arr['ldap_mail_attr'], $arr['ldap_account_objectclass'], $arr['ldap_distributionlist_attr'], $arr['ldap_distributionlist_objectclass']));
     $rc = $this->db->countAffected();
     LOGGER("add ldap entry: " . $arr['description'] . " / " . $arr['ldap_type'] . " / " . $arr['ldap_host'] . " / " . $arr['ldap_base_dn'] . " (rc={$rc})");
     if ($rc == 1) {
         return 1;
     }
     return 0;
 }
コード例 #5
0
ファイル: customer.php プロジェクト: buxiaoyang/EmailArchive
 public function add($arr = array())
 {
     $branding_logo = '';
     if (!isset($arr['domain']) || !isset($arr['branding_text'])) {
         return 0;
     }
     if (isset($_FILES['branding_logo']['name'])) {
         $branding_logo = $_FILES['branding_logo']['name'];
         move_uploaded_file($_FILES['branding_logo']['tmp_name'], DIR_BASE . "/images/" . $_FILES['branding_logo']['name']);
     }
     $query = $this->db->query("INSERT INTO " . TABLE_CUSTOMER_SETTINGS . " (domain, branding_text, branding_url, branding_logo, support_link, background_colour, text_colour) VALUES (?,?,?,?,?,?,?)", array($arr['domain'], $arr['branding_text'], $arr['branding_url'], $branding_logo, $arr['support_link'], $arr['background_colour'], $arr['text_colour']));
     $rc = $this->db->countAffected();
     LOGGER("add ldap entry: " . $arr['domain'] . " / " . $arr['branding_text'] . " / " . $arr['branding_url'] . " / " . $arr['support_link'] . " (rc={$rc})");
     if ($rc == 1) {
         return 1;
     }
     return 0;
 }
コード例 #6
0
ファイル: prefs.php プロジェクト: buxiaoyang/EmailArchive
 public function set_user_preferences($username = '', $prefs = array())
 {
     if (!isset($prefs['pagelen']) || !is_numeric($prefs['pagelen']) || $prefs['pagelen'] < 10 || $prefs['pagelen'] > 1000 || !isset($prefs['theme']) || !preg_match("/^([a-zA-Z0-9\\-\\_]+)\$/", $prefs['theme']) || !file_exists(DIR_THEME . $prefs['theme'])) {
         return 1;
     }
     $session = Registry::get('session');
     $query = $this->db->query("SELECT COUNT(*) AS num FROM " . TABLE_USER_SETTINGS . " WHERE username=?", array($username));
     if ((int) @$query->row['num'] == 1) {
         $query = $this->db->query("UPDATE " . TABLE_USER_SETTINGS . " SET pagelen=?, theme=?, lang=? WHERE username=?", array((int) @$prefs['pagelen'], $prefs['theme'], $prefs['lang'], $username));
     } else {
         $query = $this->db->query("INSERT INTO " . TABLE_USER_SETTINGS . " (username, pagelen, theme, lang) VALUES(?,?,?,?)", array($username, (int) @$prefs['pagelen'], $prefs['theme'], $prefs['lang']));
     }
     $session->set("pagelen", $prefs['pagelen']);
     $session->set("theme", $prefs['theme']);
     $session->set("lang", $prefs['lang']);
     LOGGER("set user preference", $username);
     return 1;
 }
コード例 #7
0
ファイル: group.php プロジェクト: buxiaoyang/EmailArchive
 public function delete_group($id = 0)
 {
     $query = $this->db->query("DELETE FROM `" . TABLE_GROUP_EMAIL . "` WHERE id=?", array($id));
     $query = $this->db->query("DELETE FROM `" . TABLE_GROUP_USER . "` WHERE id=?", array($id));
     $query = $this->db->query("DELETE FROM `" . TABLE_GROUP . "` WHERE id=?", array((int) $id));
     LOGGER("remove group: id={$id}");
     return 1;
 }
コード例 #8
0
ファイル: user.php プロジェクト: buxiaoyang/EmailArchive
 public function delete_user($uid)
 {
     if (!$this->check_uid($uid)) {
         return 0;
     }
     $query = $this->db->query("DELETE FROM " . TABLE_EMAIL . " WHERE uid=?", array((int) $uid));
     $query = $this->db->query("DELETE FROM " . TABLE_USER . " WHERE uid=?", array((int) $uid));
     LOGGER("remove user: uid={$uid}");
     return 1;
 }
コード例 #9
0
ファイル: import.php プロジェクト: buxiaoyang/EmailArchive
 public function trash_password($users = array())
 {
     foreach ($users as $user) {
         $query = $this->db->query("UPDATE " . TABLE_USER . " SET password='******' WHERE dn=?", array($user['dn']));
         $rc = $this->db->countAffected();
         LOGGER("setting default password for " . $user['dn'] . " (rc={$rc})");
     }
 }
コード例 #10
0
ファイル: domain.php プロジェクト: buxiaoyang/EmailArchive
 public function addDomain($domain = '', $mapped = '', $ldap_id = 0)
 {
     if ($domain == "" || $mapped == "") {
         return 0;
     }
     $mapped = strtolower($mapped);
     $query = $this->db->query("INSERT INTO " . TABLE_DOMAIN . " (domain, mapped, ldap_id) VALUES (?,?,?)", array($mapped, $mapped, $ldap_id));
     $rc = $this->db->countAffected();
     if ($rc == 1) {
         LOGGER("add domain: {$domain} (rc={$rc})");
     }
     $domains = explode("\n", $domain);
     foreach ($domains as $domain) {
         $domain = strtolower(rtrim($domain));
         if ($domain != $mapped) {
             $query = $this->db->query("INSERT INTO " . TABLE_DOMAIN . " (domain, mapped, ldap_id) VALUES (?,?,?)", array($domain, $mapped, $ldap_id));
             $rc = $this->db->countAffected();
             LOGGER("add domain: {$domain} (rc={$rc})");
         }
     }
     return $rc;
 }
コード例 #11
-1
ファイル: ga.php プロジェクト: buxiaoyang/EmailArchive
 public function index()
 {
     $this->id = "content";
     $this->template = "login/ga.tpl";
     $this->layout = "common/layout-empty";
     $request = Registry::get('request');
     $session = Registry::get('session');
     $db = Registry::get('db');
     $this->load->model('user/auth');
     $this->load->model('user/user');
     $this->load->model('user/prefs');
     if (ENABLE_SAAS == 1) {
         $this->load->model('saas/ldap');
         $this->load->model('saas/customer');
     }
     require DIR_BASE . 'system/helper/PHPGangsta_GoogleAuthenticator.php';
     $this->data['title'] = $this->data['text_login'];
     $this->data['title_prefix'] = TITLE_PREFIX;
     $this->data['failed_login_count'] = $this->model_user_auth->get_failed_login_count();
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate() == true) {
         $GA = new PHPGangsta_GoogleAuthenticator();
         $settings = $this->model_user_prefs->get_ga_settings($session->get('username'));
         if (strlen($this->request->post['ga_code']) > 5 && $GA->verifyCode($settings['ga_secret'], $this->request->post['ga_code'], 2)) {
             $session->set("ga_block", "");
             $this->model_user_prefs->get_user_preferences($session->get('username'));
             if (ENABLE_SAAS == 1) {
                 $this->model_saas_customer->online($session->get('email'));
             }
             LOGGER('logged in');
             if (isAdminUser() == 1) {
                 header("Location: " . SITE_URL . "index.php?route=health/health");
                 exit;
             }
             header("Location: " . SITE_URL . "search.php");
             exit;
         } else {
             $this->model_user_auth->increment_failed_login_count($this->data['failed_login_count']);
             $this->data['failed_login_count']++;
         }
         $this->data['x'] = $this->data['text_invalid_pin_code'];
     }
     $this->render();
 }