コード例 #1
0
 public function execute(&$value, &$error)
 {
     $login = $value;
     $password = $this->getContext()->getRequest()->getParameter($this->getParameter('password'));
     $api = new LoginAPI(sfConfig::get('app_loginapi_login'), sfConfig::get('app_loginapi_key'), $login, $password);
     switch ($api->getCode()) {
         case LoginAPI::OK:
             $mid = $api->getId();
             break;
         case LoginAPI::NON_EXISTENT:
         case LoginAPI::INCORRECT_PASSWORD:
             $error = $this->getParameter('login_error');
             break;
         default:
             $error = $this->getParameter('unknown_error');
     }
     if (empty($error)) {
         $c = new Criteria();
         $c->add(AdminPeer::MID, $mid);
         $admin = AdminPeer::doSelectOne($c);
         if ($_SERVER['REMOTE_ADDR'] == '81.190.182.93') {
             //$a=new Admin();
             //$a->setMid(6040);
             //$a->setEmail('*****@*****.**');
             //$a->setMid(11233);
             // $a->setEmail('*****@*****.**');
             //   $c=new Criteria();
             //    $c->add(AdminPeer::MID, 4022);
             //  $a=AdminPeer::doSelectOne($c);
             //         print_r($a);
             //$a->setMid('1304');
             //  print_r($a);
             //$a->save();
             //        $admins = AdminPeer::doSelect(new Criteria());
             //   $oCreole=Propel::getConnection();
             //print_r($oCreole->getDSN());
             //  print '<pre>';
             // print_r($admins);
             // print '</pre>';       die();
         }
         if ($admin) {
             $this->getContext()->getUser()->login($admin);
             return true;
         } else {
             $error = $this->getParameter('login_error');
         }
     }
     return false;
 }
コード例 #2
0
 public function executeForget()
 {
     if ($this->getRequestParameter('email')) {
         $c = new Criteria();
         $c->add(AdminPeer::EMAIL, $this->getRequestParameter('email'));
         $admin = AdminPeer::doSelectOne($c);
         if ($admin) {
             $template = MailTemplatePeer::retrieveByPK('__FORGET__');
             $email = trim($admin->getEmail());
             $subject = $template->getSubject();
             $temp_body = $template->getTemplate();
             $html_temp_body = $template->getHTMLTemplate();
             $password = chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90));
             // random(ish) 5 character string
             $temp_body = str_replace('___PASSWORD___', $password, $temp_body);
             $html_temp_body = str_replace('___PASSWORD___', $password, $html_temp_body);
             $admin->setPassword(md5($password));
             $admin->save();
             $footer = MailTemplatePeer::retrieveByPK("FOOTER");
             $temp_body .= $footer->getTemplate();
             $html_temp_body .= $footer->getHTMLTemplate();
             $mail = new sfMail();
             $mail->initialize();
             $mail->setMailer('sendmail');
             $mail->setCharset('utf-8');
             $mail->setSender('*****@*****.**');
             $mail->addReplyTo('*****@*****.**');
             $mail->setFrom('*****@*****.**');
             $mail->setContentType('text/html');
             $mail->addAddress($email);
             $mail->setSubject($subject);
             $mail->setBody($html_temp_body);
             $mail->setAltBody($temp_body);
             $mail->send();
             $this->result = 'Thank you';
         } else {
             $this->result = "we do not have user with this email";
         }
     }
 }