コード例 #1
0
ファイル: Auth.php プロジェクト: hukumonline/idh
 public function login_reader()
 {
     if (isset($_COOKIE[$this->cookie_name])) {
         $obj = new Kutu_Crypt_Password();
         $cookie_parts = explode(chr(31), $_COOKIE[$this->cookie_name]);
         $this->user = $cookie_parts[0];
         $this->user_pw = $obj->decryptPassword($cookie_parts[1]);
         $this->is_cookie = true;
     }
 }
コード例 #2
0
ファイル: User.php プロジェクト: psykomo/kutump
 public function forgetPassword($username, $emailAddress)
 {
     $tblUser = new Kutu_Core_Orm_Table_User();
     $row = $tblUser->fetchRow("email='{$emailAddress}' AND username='******'");
     if (empty($username)) {
         throw new Zend_Exception("Username can not be empty.");
     }
     if (empty($emailAddress)) {
         throw new Zend_Exception("Email address can not be empty.");
     }
     if (empty($row)) {
         throw new Zend_Exception("We can not find your account. No data was saved.");
     } else {
         $obj = new Kutu_Crypt_Password();
         $oldPassword = $obj->decryptPassword($row->password);
         $gman = new Kutu_Core_Guid();
         $randomPassword = $gman->generateGuid();
         $this->changePassword($row->guid, $oldPassword, $randomPassword);
         //Send email notification
         $bodyMail = "\nDear {$row->firstname} {$row->lastname}, \n\nYour password has been successfully reseted.\n\nPlease use your temporary password below to login.\n\nUsername: {$row->username}\nNew Password: {$randomPassword}\n\nAfter you are logged in, please use Change Password facility to change the password to your desired password.\n\nRegards,\nLGS Online\n";
         $config = new Zend_Config_Ini(KUTU_ROOT_DIR . '/application/configs/mail.ini', 'general');
         $options = array('auth' => $config->mail->auth, 'username' => $config->mail->username, 'password' => $config->mail->password);
         $transport = new Zend_Mail_Transport_Smtp($config->mail->host, $options);
         $mail = new Zend_Mail();
         $mail->setBodyText($bodyMail);
         $mail->setFrom($config->mail->sender->support->email, $config->mail->sender->support->name);
         $mail->addTo($row->email, $row->firstname . ' ' . $row->lastname);
         $mail->setSubject('Your password has been reseted');
         try {
             //echo $config->mail->auth;
             //die();
             $mailTransport = Kutu_Application::getResource('mail');
             $mail->send($mailTransport);
         } catch (Zend_Exception $e) {
             //no need to do anything. The error is only about sending email.
             //maybe, we may set status in table user indicating that we never send
             // the user with welcome email.
             echo $e->getMessage();
             die;
         }
     }
 }
コード例 #3
0
ファイル: Loader.php プロジェクト: psykomo/kutump-enhanced
 function loadWidget($widgetUrl, $widgetAuthActionUrl)
 {
     Zend_Loader::loadClass('Zend_Http_Client');
     Zend_Loader::loadClass('Kutu_Crypt_Password');
     $auth = Zend_Auth::getInstance();
     $password = '';
     $userName = '';
     if ($auth->hasIdentity()) {
         $crypt = new Kutu_Crypt_Password();
         $password = $crypt->decryptPassword($auth->getIdentity()->password);
         $userName = $auth->getIdentity()->username;
     }
     $client = new Zend_Http_Client($widgetUrl, array('keepalive' => true));
     $client->setCookieJar();
     $client->setUri($widgetAuthActionUrl);
     $client->setParameterPost(array('username' => $userName, 'password' => $password));
     $userAgent = $_SERVER['HTTP_USER_AGENT'];
     $client->setHeaders("User-Agent: {$userAgent}");
     $response = $client->request(Zend_Http_Client::POST);
     $client->setUri($widgetUrl);
     $response = $client->request(Zend_Http_Client::GET);
     return $response->getBody();
 }
コード例 #4
0
ファイル: User.php プロジェクト: hukumonline/idh
 /**
  * _writeConfirmCorporateEmail
  * @return JSON
  */
 function _writeConfirmCorporateEmail($mailcontent, $fullname, $company, $payment, $disc, $total, $username, $guid, $email)
 {
     $obj = new Kutu_Crypt_Password();
     $mailcontent = str_replace('$fullname', $fullname, $mailcontent);
     $mailcontent = str_replace('$company', $company, $mailcontent);
     $mailcontent = str_replace('$timeline', $payment, $mailcontent);
     $mailcontent = str_replace('$disc', $disc, $mailcontent);
     $mailcontent = str_replace('$price', number_format($total), $mailcontent);
     $mailcontent = str_replace('$username1', $username, $mailcontent);
     $mailcontent = str_replace('$guid', $guid, $mailcontent);
     // table User
     $tblUser = new Kutu_Core_Orm_Table_User();
     $where = $tblUser->getAdapter()->quoteInto('company=?', $company);
     $rowUser = $tblUser->fetchAll($where, 'username ASC');
     $tag = '<table>';
     $tag .= '<tr><td><b>Username</b></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td><b>Password</b></td></tr>';
     foreach ($rowUser as $rowsetUser) {
         $tag .= '<tr><td>' . $rowsetUser->username . '</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>' . $obj->decryptPassword($rowsetUser->password) . '</td></tr>';
     }
     $tag .= '</table>';
     $mailcontent = str_replace('$tag', $tag, $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, $config->mail->sender->support->name, $mail_body);
     // try to save mail before send
     if ($mailAttempt) {
         $sendAttempt = $this->send_mail();
         if ($sendAttempt) {
             $message = "Please check your email at {$email}!";
             // update user
             $rowUser = $tblUser->find($obj->decryptPassword($guid))->current();
             if ($rowUser) {
                 $rowUser->isEmailSent = 'Y';
                 $rowUser->save();
             }
         } else {
             $message = "Error send mail but register user successfully!<br>Please contact our customer service for more information";
         }
     } else {
         $message = "Error saving mail!";
     }
     return $message;
 }
コード例 #5
0
ファイル: Formater.php プロジェクト: psykomo/kutump-enhanced
 function _writeConfirmCorporateEmail($mailcontent, $company, $payment, $disc, $total, $username, $guid, $email)
 {
     $formater = new Kutu_Lib_Formater();
     $obj = new Kutu_Crypt_Password();
     $mailcontent = str_replace('$company', $company, $mailcontent);
     $mailcontent = str_replace('$timeline', $payment, $mailcontent);
     $mailcontent = str_replace('$disc', $disc, $mailcontent);
     $mailcontent = str_replace('$price', number_format($total), $mailcontent);
     $mailcontent = str_replace('$username1', $username, $mailcontent);
     $mailcontent = str_replace('$guid', $guid, $mailcontent);
     // table User
     $tblUser = new Kutu_Core_Orm_Table_User();
     $where = $tblUser->getAdapter()->quoteInto('company=?', $company);
     $rowUser = $tblUser->fetchAll($where, 'username ASC');
     $tag = '<table>';
     $tag .= '<tr><td><b>Username</b></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td><b>Password</b></td></tr>';
     foreach ($rowUser as $rowsetUser) {
         $tag .= '<tr><td>' . $rowsetUser->username . '</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>' . $obj->decryptPassword($rowsetUser->password) . '</td></tr>';
     }
     $tag .= '</table>';
     $mailcontent = str_replace('$tag', $tag, $mailcontent);
     $mail_body = $mailcontent;
     // parse ini_file
     $config = new Zend_Config_Ini(KUTU_ROOT_DIR . '/app/config/config.ini', 'mail');
     $mailAttempt = $formater->add_mail($config->from, $email, $username, 'Hukumonline-ID', $mail_body);
     // try to save mail before send
     if ($mailAttempt) {
         $sendAttempt = $formater->send_mail();
         if ($sendAttempt) {
             $response['success'] = true;
             $response['message'] = "Please check your email at {$email}!";
         } else {
             ob_clean();
             $response['failure'] = false;
             $response['message'] = "Error send mail but register user successfully!<br>Please contact our customer service for more information";
         }
     } else {
         $response['failure'] = true;
         $response['message'] = "Error saving mail!";
     }
     echo Zend_Json::encode($response);
 }