Example #1
0
 /**
  * process the class
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function process()
 {
     $specialFilter = new Filter\Special();
     /* process post */
     $postArray = ['id' => $specialFilter->sanitize($this->_request->getPost('id')), 'password' => $specialFilter->sanitize($this->_request->getPost('password')), 'task' => $this->_request->getPost('task'), 'solution' => $this->_request->getPost('solution')];
     /* query user */
     $user = Db::forTablePrefix('users')->where(['id' => $postArray['id'], 'status' => 1])->findOne();
     /* handle error */
     $messageArray = $this->_validate($postArray, $user);
     if ($messageArray) {
         return $this->_error(['message' => $messageArray]);
     }
     /* handle success */
     $passwordHash = new Hash(Config::getInstance());
     $passwordHash->init(uniqid());
     $resetArray = ['id' => $user->id, 'password' => $passwordHash->getHash()];
     $mailArray = ['name' => $user->name, 'email' => $user->email, 'password' => $passwordHash->getRaw()];
     /* reset */
     if (!$this->_reset($resetArray)) {
         return $this->_error(['message' => $this->_language->get('something_wrong')]);
     }
     /* mail */
     if (!$this->_mail($mailArray)) {
         return $this->_error(['message' => $this->_language->get('email_failed')]);
     }
     return $this->_success();
 }
Example #2
0
 /**
  * process
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function process()
 {
     $specialFilter = new Filter\Special();
     $emailFilter = new Filter\Email();
     /* process post */
     $postArray = ['name' => $specialFilter->sanitize($this->_request->getPost('name')), 'user' => $specialFilter->sanitize($this->_request->getPost('user')), 'email' => $emailFilter->sanitize($this->_request->getPost('email')), 'task' => $this->_request->getPost('task'), 'solution' => $this->_request->getPost('solution')];
     /* handle error */
     $messageArray = $this->_validate($postArray);
     if ($messageArray) {
         return $this->_error(['message' => $messageArray]);
     }
     /* handle success */
     $passwordHash = new Hash(Config::getInstance());
     $passwordHash->init(uniqid());
     $createArray = ['name' => $postArray['name'], 'user' => $postArray['user'], 'password' => $passwordHash->getHash(), 'email' => $postArray['email'], 'language' => $this->_registry->get('language'), 'groups' => Db::forTablePrefix('groups')->where('alias', 'members')->findOne()->id, 'status' => Db::getSetting('verification') ? 0 : 1];
     $mailArray = ['name' => $postArray['name'], 'user' => $postArray['user'], 'password' => $passwordHash->getRaw(), 'email' => $postArray['email']];
     /* create */
     if (!$this->_create($createArray)) {
         return $this->_error(['message' => $this->_language->get('something_wrong')]);
     }
     /* mail */
     if (!$this->_mail($mailArray)) {
         return $this->_error(['message' => $this->_language->get('email_failed')]);
     }
     return $this->_success(['message' => Db::getSetting('verification') ? $this->_language->get('registration_verification') : $this->_language->get('registration_sent')]);
 }
Example #3
0
 /**
  * setUp
  *
  * @since 3.0.0
  */
 public function setUp()
 {
     $this->_registry = Registry::getInstance();
     $this->_request = Request::getInstance();
     $this->_config = Config::getInstance();
     $this->_configArray = $this->_config->get();
 }
Example #4
0
 /**
  * setUpBeforeClass
  *
  * @since 3.0.0
  */
 public static function setUpBeforeClass()
 {
     $passwordHash = new Hash(Config::getInstance());
     $passwordHash->init('test');
     Db::setSetting('captcha', 1);
     Db::forTablePrefix('users')->whereIdIs(1)->findOne()->set('password', $passwordHash->getHash())->save();
 }
Example #5
0
 /**
  * setUp
  *
  * @since 3.0.0
  */
 public function setUp()
 {
     $this->_registry = Registry::getInstance();
     $this->_language = Language::getInstance();
     $this->_request = Request::getInstance();
     $this->_config = Config::getInstance();
     $this->_configArray = $this->_config->get();
     $this->_config->set('dbPrefix', 'controller_');
 }
Example #6
0
 /**
  * validate the captcha
  *
  * @since 2.2.0
  *
  * @param string $task plain task
  * @param string $hash hashed solution
  *
  * @return integer
  */
 public function validate($task = null, $hash = null)
 {
     $output = ValidatorInterface::FAILED;
     $captchaHash = new Hash(Config::getInstance());
     /* validate captcha */
     if ($task && $captchaHash->validate($task, $hash)) {
         $output = ValidatorInterface::PASSED;
     }
     return $output;
 }
 /**
  * validate the password
  *
  * @since 2.6.0
  *
  * @param string $password plain password
  * @param string $hash hashed password
  *
  * @return integer
  */
 public function validate($password = null, $hash = null)
 {
     $output = ValidatorInterface::FAILED;
     $passwordHash = new Hash(Config::getInstance());
     /* validate password */
     if ($password && $passwordHash->validate($password, $hash)) {
         $output = ValidatorInterface::PASSED;
     }
     return $output;
 }
 /**
  * reinstall
  *
  * @since 2.4.0
  */
 protected static function _reinstall()
 {
     $installer = new Installer(GlobalConfig::getInstance());
     $installer->init();
     $installer->rawDrop();
     $installer->rawCreate();
     $installer->insertData(array('adminName' => 'Admin', 'adminUser' => 'admin', 'adminPassword' => 'admin', 'adminEmail' => 'admin@localhost'));
     /* process modules */
     foreach (self::$_config['modules'] as $key => $value) {
         if (is_dir('modules/' . $key)) {
             $module = new $value();
             $module->install();
         }
     }
     /* access and filter */
     Db::forTablePrefix('groups')->findMany()->set(array('modules' => null, 'filter' => 1))->save();
 }
Example #9
0
 /**
  * console line
  *
  * @since 3.0.0
  *
  * @return string
  */
 public static function consoleLine()
 {
     $console = new Console\Console(Registry::getInstance(), Request::getInstance(), Config::getInstance());
     $output = $console->init('template');
     if (is_string($output)) {
         return htmlentities($output);
     }
 }
 /**
  * setUp
  *
  * @since 2.4.0
  */
 public function setUp()
 {
     $this->_config = Config::getInstance();
     $this->_config->set('dbPrefix', 'installer_');
     Db::clearCache();
 }
Example #11
0
 /**
  * setUp
  *
  * @since 3.0.0
  */
 public function setUp()
 {
     $this->_config = Config::getInstance();
     $this->_configArray = $this->_config->get();
 }
 /**
  * append the captcha
  *
  * @since 2.6.0
  *
  * @param string $type type of the captcha
  *
  * @return Form
  */
 public function captcha($type = null)
 {
     /* task */
     if ($type === 'task') {
         $this->label($this->_captcha->getTask(), array('for' => 'task'));
         /* number */
         $this->number(array('id' => 'task', 'min' => $this->_captcha->getMin(), 'max' => $this->_captcha->getMax() * 2, 'name' => 'task', 'required' => 'required'));
     }
     /* solution */
     if ($type === 'solution') {
         $captchaHash = new Hash(Config::getInstance());
         $captchaHash->init($this->_captcha->getSolution());
         /* hidden */
         $this->hidden(array('name' => 'solution', 'value' => $captchaHash->getHash()));
     }
     return $this;
 }
Example #13
0
 /**
  * setUp
  *
  * @since 2.2.0
  */
 public function setUp()
 {
     $this->_config = Config::getInstance();
     $this->_config->set('dbRestore', $this->_config->get('dbType'));
 }
 /**
  * setUp
  *
  * @since 2.6.0
  */
 public function setUp()
 {
     $this->_config = Config::getInstance();
 }
Example #15
0
 /**
  * setUp
  *
  * @since 3.0.0
  */
 public function setUp()
 {
     $this->_config = Config::getInstance();
     $this->_configArray = $this->_config->get();
     $this->_config->set('dbPrefix', 'installer_');
 }