コード例 #1
0
ファイル: User.php プロジェクト: hukumonline/idh
 /**
  * _writeConfirmIndividualEmail
  * @return JSON
  */
 function _writeForgotPassword($mailcontent, $username, $email)
 {
     $obj = new Kutu_Crypt_Password();
     $generateGuid = new Kutu_Core_Guid();
     $newPassword = $generateGuid->generateGuid();
     $mailcontent = str_replace('$fullname', $username, $mailcontent);
     $mailcontent = str_replace('$password', $newPassword, $mailcontent);
     $mail_body = $mailcontent;
     // parse ini_file
     $config = new Zend_Config_Ini(KUTU_ROOT_DIR . '/application/configs/mail.ini', 'mail');
     $mailAttempt = $this->add_mail($config->mail->sender->support->email, $email, $username, 'Bantuan Hukumonline', $mail_body);
     // try to save mail before send
     if ($mailAttempt) {
         $sendAttempt = $this->send_mail();
         if ($sendAttempt) {
             // update user password
             $tblUser = new Kutu_Core_Orm_Table_User();
             $tblUser->update(array('password' => $obj->encryptPassword($newPassword)), "username='******'");
             // send confirm to client
             echo "Please check your email at {$email}!";
         } else {
             echo "Error saving mail DB!";
         }
     } else {
         echo "Email not provided!";
     }
 }
コード例 #2
0
 public function addAction()
 {
     $modDir = $this->getFrontController()->getModuleDirectory();
     require_once $modDir . '/components/user/UserMainMenu.php';
     $w = new UserMainMenu();
     $this->view->userMainMenu = $w->render();
     $r = $this->getRequest();
     if ($r->isPost()) {
         $username = $r->getParam('username');
         if (empty($username)) {
             die('ERROR: Username can not be empty!');
         }
         $password = $r->getParam('password');
         $crypt = new Kutu_Crypt_Password();
         $password = $crypt->encryptPassword($password);
         $firstname = $r->getParam('firstname');
         $lastname = $r->getParam('lastname');
         $email = $r->getParam('email');
         $tblUser = new Kutu_Core_Orm_Table_User();
         $row = $tblUser->createRow();
         $row->username = $username;
         $row->password = $password;
         $row->firstname = $firstname;
         $row->lastname = $lastname;
         $row->email = $email;
         $row->save();
         $this->_helper->viewRenderer->setScriptAction('add-success');
     }
 }
コード例 #3
0
ファイル: ManagerController.php プロジェクト: hukumonline/idh
 public function authenticateAction()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get('config');
     $request = $this->getRequest();
     $username = $request->getParam('identity');
     $password = $request->getParam('credential');
     //$db = Zend_Db::factory($config->db->adapter, $config->db->config->toArray());
     /*
     $db = Zend_Db::factory('Pdo_Mysql', array(
          'host'     => 'localhost'
         ,'username' => 'root'
         ,'password' => ''
         ,'dbname'   => 'hid'
     ));
     */
     $dbAdapters = Zend_Registry::get('dbAdapters');
     $config1 = $dbAdapters['hol'];
     $config2 = $dbAdapters['identity'];
     //$a = $db->fetchAll("SELECT * FROM KutuUser WHERE username ='******' AND isActive=1");
     //$b = $db->fetchAll("SELECT sessionId FROM session WHERE sessionData LIKE '%$username%'");
     $a = $config2->fetchAll("SELECT * FROM KutuUser WHERE username ='******' AND isActive=1");
     //$b = Zend_Db_Table::getDefaultAdapter()->fetchAll("SELECT sessionId FROM session WHERE sessionData LIKE '%$username%'");
     $b = $config1->fetchAll("SELECT sessionId FROM session WHERE sessionData LIKE '%{$username}%'");
     if (count($b) >= 1) {
         $b[0]['password'] = '******';
         $b[0]['username'] = '******';
         $b[0]['packageId'] = '---';
         $b[0]['picture'] = '---';
         $b[0]['kopel'] = 'XXISLOGINXX';
         echo Zend_Json::encode($b);
     } else {
         if (count($a) < 1) {
             echo '[]';
             //dummy data for the remote auth adapter
         } else {
             if (count($a) > 1) {
                 echo '[{"id":"xx"},{"id":"yy"}]';
                 //dummy data for the remote auth adapter
             } else {
                 $obj = new Kutu_Crypt_Password();
                 $resultIdentity = $a[0];
                 if (strtoupper(substr(sha1($password), 0, 30)) == $resultIdentity['password']) {
                     $resultIdentity['password'] = $obj->encryptPassword($password);
                     $config2->update('KutuUser', $resultIdentity, "username='******'");
                     $this->authenticateAction();
                 } elseif ($obj->matchPassword($password, $resultIdentity['password'])) {
                     echo Zend_Json::encode($a);
                 } else {
                     $a[0]['password'] = '******';
                     $a[0]['username'] = '******';
                     $a[0]['kopel'] = '---';
                     echo Zend_Json::encode($a);
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: Auth.php プロジェクト: hukumonline/idh
 public function login_saver()
 {
     if ($this->save_login == "no" || $this->save_login == "undefined") {
         if (isset($_COOKIE[$this->cookie_name])) {
             $expire = time() - 3600;
         } else {
             return;
         }
     } else {
         $expire = time() + 2592000;
     }
     $obj = new Kutu_Crypt_Password();
     $cookie_str = $this->user . chr(31) . $obj->encryptPassword($this->user_pw);
     setcookie($this->cookie_name, $cookie_str, $expire, $this->cookie_path);
 }
コード例 #5
0
ファイル: AccountController.php プロジェクト: hukumonline/idh
 function signupAction()
 {
     $this->_helper->layout->setLayout('layout-newhukumonlineid-daftar');
     $this->view->identity = 'Daftar';
     $r = $this->getRequest();
     if ($r->isPost()) {
         $fullName = $r->getParam('fullname');
         $username = $r->getParam('username');
         $password = $r->getParam('password');
         $email = $r->getParam('email');
         $package = $r->getParam('aro_groups');
         $kopel = $this->generateKopel();
         $obj = new Kutu_Crypt_Password();
         $data = array('kopel' => $kopel, 'username' => $username, 'password' => $obj->encryptPassword($password), 'fullName' => $fullName, 'email' => $email, 'packageId' => $package, 'periodeId' => 1, 'createdDate' => date('Y-m-d H:i:s'), 'createdBy' => $username);
         $modelUser = new Kutu_Core_Orm_Table_User();
         $modelUser->insert($data);
         $this->updateKopel();
         $acl = new Kutu_Acl_Adapter_Local();
         //$acl->addUser($username,"Free");
         $acl->addUserToGroup($username, "Free");
         $formater = new Kutu_Core_Hol_User();
         $mailcontent = $formater->getMailContent('konfirmasi email gratis');
         $m = $formater->_writeConfirmFreeEmail($mailcontent, $fullName, $username, $password, base64_encode($kopel), $email, 'gratis');
         $this->view->message = $m;
     }
     $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     $rowset = $tblCatalog->fetchRow("shortTitle='halaman-depan-login' AND status=99");
     if (!empty($rowset)) {
         $rowsetCatalogAttribute = $rowset->findDependentRowsetCatalogAttribute();
         $fixedContent = $rowsetCatalogAttribute->findByAttributeGuid('fixedContent')->value;
     } else {
         $fixedContent = '';
     }
     $this->view->content = $fixedContent;
 }
コード例 #6
0
ファイル: User.php プロジェクト: psykomo/kutump
 public function save($aData)
 {
     if (isset($aData['fullname']) && !empty($aData['fullname'])) {
         $aData['firstname'] = $aData['fullname'];
     }
     if (empty($aData['firstname'])) {
         throw new Zend_Exception('Firstname can not be EMPTY!');
     }
     $tblUser = new Kutu_Core_Orm_Table_User();
     $gman = new Kutu_Core_Guid();
     $guid = isset($aData['guid']) && !empty($aData['guid']) ? $aData['guid'] : $gman->generateGuid();
     //if not empty, there are 2 possibilities
     $tblUser = new Kutu_Core_Orm_Table_User();
     $row = $tblUser->fetchRow("guid='{$guid}'");
     if (empty($row)) {
         if (empty($aData['username'])) {
             throw new Zend_Exception('Username can not be EMPTY!');
         }
         if (empty($aData['password'])) {
             throw new Zend_Exception('Password can not be EMPTY!');
         }
         $row = $tblUser->createRow();
         if (isset($aData['username']) && !empty($aData['username'])) {
             //check if username was already taken
             $username = $aData['username'];
             $tblUser = new Kutu_Core_Orm_Table_User();
             $rowUsername = $tblUser->fetchRow("username='******'");
             if ($rowUsername) {
                 throw new Zend_Exception('Username exists');
             }
             $row->username = $aData['username'];
         }
         if (isset($aData['password']) && !empty($aData['password'])) {
             $password = $aData['password'];
             $crypt = new Kutu_Crypt_Password();
             $password = $crypt->encryptPassword($password);
             $row->password = $password;
         }
     }
     if (isset($aData['firstname'])) {
         $row->firstname = $aData['firstname'];
     }
     if (isset($aData['lastname'])) {
         $row->lastname = $aData['lastname'];
     }
     if (isset($aData['email'])) {
         $row->email = $aData['email'];
     }
     if (isset($aData['bbPin'])) {
         $row->bbPin = $aData['bbPin'];
     }
     if (isset($aData['clientId'])) {
         $row->clientId = $aData['clientId'];
     }
     if (isset($aData['mainAddress'])) {
         $row->mainAddress = $aData['mainAddress'];
     }
     if (isset($aData['city'])) {
         $row->city = $aData['city'];
     }
     if (isset($aData['state'])) {
         $row->state = $aData['state'];
     }
     if (isset($aData['zip'])) {
         $row->zip = $aData['zip'];
     }
     if (isset($aData['phone'])) {
         $row->phone = $aData['phone'];
     }
     if (isset($aData['fax'])) {
         $row->fax = $aData['fax'];
     }
     if (isset($aData['url'])) {
         $row->url = $aData['url'];
     }
     if (isset($aData['countryId'])) {
         $row->countryId = $aData['countryId'];
     }
     if (isset($aData['company'])) {
         $row->company = $aData['company'];
     }
     if (isset($aData['companySizeId'])) {
         $row->companySizeId = $aData['companySizeId'];
     }
     if (isset($aData['jobId'])) {
         $row->jobId = $aData['jobId'];
     }
     if (isset($aData['industryId'])) {
         $row->industryId = $aData['industryId'];
     }
     if (isset($aData['isActive'])) {
         $row->isActive = $aData['isActive'];
     }
     if (isset($aData['registrationDate'])) {
         $row->registrationDate = $aData['registrationDate'];
     }
     if (isset($aData['activationDate'])) {
         $row->activationDate = $aData['activationDate'];
     }
     if (isset($aData['activationCode'])) {
         $row->activationCode = $aData['activationCode'];
     }
     if (isset($aData['expirationDate'])) {
         $row->expirationDate = $aData['expirationDate'];
     }
     $row->save();
     return $row;
 }