부터: 2.4.0
저자: Henry Ruhs
상속: extends Singleton
예제 #1
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();
 }
예제 #2
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();
 }
예제 #3
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();
 }
예제 #4
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')]);
 }
예제 #5
0
 /**
  * testGetAll
  *
  * @since 2.2.0
  */
 public function testGetAll()
 {
     /* result */
     $result = Config::get();
     /* compare */
     $this->assertArrayHasKey('host', $result);
 }
예제 #6
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_');
 }
예제 #7
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;
 }
예제 #9
0
 /**
  * init the class
  *
  * @since 2.2.0
  *
  * @param Config $config instance of the config class
  */
 public static function init(Config $config)
 {
     self::$_config = $config;
     $dbType = $config->get('dbType');
     $dbHost = $config->get('dbHost');
     $dbName = $config->get('dbName');
     $dbUser = $config->get('dbUser');
     $dbPassword = $config->get('dbPassword');
     /* mysql and pgsql */
     if ($dbType === 'mysql' || $dbType === 'pgsql') {
         if ($dbType === 'mysql') {
             self::configure('connection_string', 'mysql:host=' . $dbHost . ';dbname=' . $dbName . ';charset=utf8');
         } else {
             self::configure('connection_string', 'pgsql:host=' . $dbHost . ';dbname=' . $dbName . ';options=--client_encoding=utf8');
         }
         /* username and password */
         self::configure(array('username' => $dbUser, 'password' => $dbPassword));
     }
     /* sqlite */
     if ($dbType === 'sqlite') {
         self::configure('sqlite:' . $dbHost);
     }
     /* general */
     self::configure(array('caching' => true, 'caching_auto_clear' => true, 'return_result_sets' => true));
 }
예제 #10
0
 /**
  * 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();
 }
예제 #11
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);
     }
 }
예제 #12
0
 /**
  * setUp
  *
  * @since 2.4.0
  */
 public function setUp()
 {
     $this->_config = Config::getInstance();
     $this->_config->set('dbPrefix', 'installer_');
     Db::clearCache();
 }
예제 #13
0
 /**
  * setUp
  *
  * @since 3.0.0
  */
 public function setUp()
 {
     $this->_config = Config::getInstance();
     $this->_configArray = $this->_config->get();
     $this->_config->set('dbPrefix', 'installer_');
 }
예제 #14
0
 /**
  * setUp
  *
  * @since 3.0.0
  */
 public function setUp()
 {
     $this->_config = Config::getInstance();
     $this->_configArray = $this->_config->get();
 }
예제 #15
0
파일: Db.php 프로젝트: ITw3/redaxscript
 /**
  * for table with prefix
  *
  * @since 2.2.0
  *
  * @param string $table name of the table
  * @param string $connection which connection to use
  *
  * @return Db
  */
 public static function forPrefixTable($table = null, $connection = self::DEFAULT_CONNECTION)
 {
     self::_setupDb($connection);
     return new self(Config::get('prefix') . $table, array(), $connection);
 }
 /**
  * setUp
  *
  * @since 2.6.0
  */
 public function setUp()
 {
     $this->_config = Config::getInstance();
 }
예제 #17
0
 /**
  * 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;
 }
예제 #18
0
 /**
  * setUp
  *
  * @since 2.2.0
  */
 public function setUp()
 {
     $this->_config = Config::getInstance();
     $this->_config->set('dbRestore', $this->_config->get('dbType'));
 }