08.24
php
saved
PhpNut
Note
After using security component, page is blank after POST.
After using security component, page is blank after POST.
- <?php
- /**
- * @author Kunthar
- * @name AccountsController
- * @package accounts
- * @todo Protector will be added, i18n will be implemented, all constants will be converted to __d(), mailer,
- *
- **/
- class AccountsController extends AppController {
- var $name = 'Accounts';
- var $cacheAction = false;
- /**
- *@example smtp connection methods
- * $this->SwiftMailer->smtp_host = 'localhost';
- * $this->SwiftMailer->smtp_type = 'open';
- * $this->SwiftMailer->username = 'user@mail.com';
- * $this->SwiftMailer->password = 'passwd';
- */
- function beforeFilter(){
- $this->Security->requireAuth('add', 'login');
- $this->Security->requirePost('add', 'login');
- // Before filter startup tan sonra başlıyor, bu durumda burada kullanılacak her comp için kendisini başlatmak gerekiyor...
- $this->Conf->startup(&$this);
- $this->Conf->set('weee.bar','chocolat',null,'true','true');
- $this->Conf->set('app.foo','Cake sucks!');
- }
- function mailToRegistrant(){
- $this->log('mailToRegistrant starts', 3);
- $this->SwiftMailer->connection = 'native';
- if($this->SwiftMailer->connect())
- {
- $this->SwiftMailer->addTo('to',"kunthar@gmail.com","Kunthar");
- $this->SwiftMailer->addTo('from',"shop@mira-soft.com","Shop test mail");
- if(!$this->SwiftMailer->sendView("Someone registers :) " . $this->Session->read('account.email'),"email",'both'))
- {
- $this->log('Mail failed errors: ', 3);
- echo "The mailer failed to Send. Errors:";
- pr($this->SwiftMailer->errors());
- }
- $this->log('Mail sent okay. cHECK Inbox');
- //pr($this->SwiftMailer->transactions());
- }
- else
- {
- $this->log('The mailer failed to connect. ', 3);
- echo "The mailer failed to connect. Errors:";
- pr($this->SwiftMailer->errors());
- }
- }
- function login()
- {
- //Don't show the error message if no data has been submitted.
- $this->set('error', false);
- // Check if we're already logged in
- if($user = $this->Session->read('Account'))
- {
- $this->Session->setFlash(__d('default','Zaten giriş yapmışsınız, hoşgeldiniz'.$user['email'], false));
- $this->redirect('/account/dashboard/' . $user['id']);
- }
- // If a user has submitted form data:
- {
- $someone = $this->Account->findByEmail($this->data['Account']['email']);
- $this->data['Account']['account_pass'] = $this->data['Account']['account_pass'];
- if(!empty($someone['Account']['account_pass']) && $someone['Account']['account_pass'] == $this->data['Account']['account_pass'] && $someone['Account']['account'] == '1')
- {
- $this->Session->setFlash('Hoşgeldiniz... Lütfen bekleyin.');
- $this->Session->write('Account', $someone['Account']);
- $this->redirect('/front/' . $someone['Account']['id']);
- // The user is trying to retrieve their password so send a copy of the
- // password to the email address provided.
- } else {
- // else, they supplied incorrect data:
- $this->Session->setFlash('Girdiğiniz bilgi eksik ya da yanlış, lütfen tekrar deneyiniz.');
- $this->redirect('/accounts/login');
- }
- }
- }
- function logout()
- {
- $this->Session->delete('Account');
- $this->redirect('/');
- }
- function add(){
- $this->set('title', 'Kaydolun bedava hediyeler kazanin- FotoWeb24');
- $this->set('error', false);
- // Let the validations begins
- {
- //Datayı model datasına eşle, validation için kullanıldı
- $this->Account->data = $this->data;
- // Modelde ele alınamayacak validation işlerini hallet, modelde ayrica valiaditon rules var.
- $this->set('error', true);
- $this->set('fn_error', SH_FIRSTNAME_ERROR);
- }
- $this->set('ln_error', SH_LASTNAME_ERROR);
- $this->set('error', true);
- }
- // Cake 1.2 style validation
- if ($this->Account->validates())
- {
- if ($this->Account->findByEmail($this->data['Account']['email']))
- {
- $this->set('email_exist_error', SH_EMAIL_EXIST);
- $this->set('error', true);
- }
- if ($this->data['Account']['account_pass'] != $this->data['Account']['account_pass2']){
- $this->set('pw_error', SH_PASSWORDS_NOT_MATCH);
- $this->set('error', true);
- }
- $this->set('accept_error', SH_ACCEPT_ERROR);
- $this->set('error', true);
- }
- else {
- if ($this->Account->save($this->data))
- {
- /**
- * @todo aro aco will be added, void_leenux bro gonna handle this
- */
- //$aro = new Aro();
- //$aro->create($this->Account->id, 'Accounts', $this->data['Account']['email']);
- $this->Session->write('account.email', $this->data['Account']['email']);
- $this->Session->write('account.id', $this->Account->getLastInsertID());
- //$this->mailToRegistrant();
- $this->redirect('/front');
- } else {
- $this->flash(SH_REGISTER_ERROR, '/registration');
- }
- }
- } else {
- $this->validateErrors($this->Account);
- }
- }
- }
- function registration() {
- $this->set('title', 'Kaydolun bedava hediyeler kazanin- FotoWeb24');
- $this->set('error', false);
- }
- }
- ?>
Parsed in 0.299 seconds, using GeSHi 1.0.7.14