/**
  * @param \Concrete\Core\Http\Request $req
  * @return Error
  */
 public function validateRequest(\Concrete\Core\Http\Request $req)
 {
     $e = new Error();
     $data = $req->get('fslType');
     $this->path = $data['path'];
     if (!$this->path) {
         $e->add(t("You must include a root path for this storage location."));
     } else {
         if (!is_dir($this->path)) {
             $e->add(t("The specified root path does not exist."));
         }
     }
     return $e;
 }
 public function validateUploadedFile(array $file, Error &$error)
 {
     if ($file['type'] != 'text/xml') {
         $error->add(t('File does not appear to be an XML file.'));
     }
     libxml_use_internal_errors(true);
     $this->wxr = simplexml_load_file($file['tmp_name']);
     $XMLErrors = libxml_get_errors();
     foreach ($XMLErrors as $XMLError) {
         $error->add(t('XML format error. ' . $XMLError->message));
     }
     if ($this->wxr) {
         $this->namespaces = $this->wxr->getDocNamespaces();
         $wxrVersion = $this->wxr->xpath('/rss/channel/wp:wxr_version');
         if (!$wxrVersion || !preg_match('/^\\d+\\.\\d+$/', (string) $wxrVersion[0])) {
             $error->add(t('Missing or invalid WXR version number'));
         }
     }
 }
예제 #3
0
파일: User.php 프로젝트: ngreimel/kovent
 /**
  * @param string $password
  * @param null|\Concrete\Core\Error\Error $errorObj
  * @return bool
  */
 public function validNewPassword($password, $errorObj = null)
 {
     $invalid = false;
     if (strlen($password) < Config::get('concrete.user.password.minimum') || strlen($password) > Config::get('concrete.user.password.maximum')) {
         if ($errorObj) {
             $errorObj->add(t('A password must be between %s and %s characters', Config::get('concrete.user.password.minimum'), Config::get('concrete.user.password.maximum')));
         }
         $invalid = 1;
     }
     if ($invalid) {
         return false;
     }
     return true;
 }
예제 #4
0
파일: install.php 프로젝트: a3020/concrete5
 protected function validateDatabase(Error $e)
 {
     if (!extension_loaded('pdo')) {
         $e->add($this->getDBErrorMsg());
     } else {
         $DB_SERVER = isset($_POST['DB_SERVER']) ? $_POST['DB_SERVER'] : null;
         $DB_DATABASE = isset($_POST['DB_DATABASE']) ? $_POST['DB_DATABASE'] : null;
         $db = \Database::getFactory()->createConnection(array('host' => $DB_SERVER, 'user' => isset($_POST['DB_USERNAME']) ? $_POST['DB_USERNAME'] : null, 'password' => isset($_POST['DB_PASSWORD']) ? $_POST['DB_PASSWORD'] : null, 'database' => $DB_DATABASE));
         if ($DB_SERVER && $DB_DATABASE) {
             if (!$db) {
                 $e->add(t('Unable to connect to database.'));
             } elseif (!$this->isAutoAttachEnabled()) {
                 $num = $db->GetCol("show tables");
                 if (count($num) > 0) {
                     $e->add(t('There are already %s tables in this database. concrete5 must be installed in an empty database.', count($num)));
                 }
                 try {
                     $support = $db->GetAll('show engines');
                     $supported = false;
                     foreach ($support as $engine) {
                         $engine = array_change_key_case($engine, CASE_LOWER);
                         if (isset($engine['engine']) && strtolower($engine['engine']) == 'innodb') {
                             $supported = true;
                         }
                     }
                     if (!$supported) {
                         $e->add(t('Your MySQL database does not support InnoDB database tables. These are required.'));
                     }
                 } catch (\Exception $exception) {
                     // we're going to just proceed and hope for the best.
                 }
             }
         }
     }
     return $e;
 }
예제 #5
0
 public function validateUploadedFile(array $file, Error &$error)
 {
     if ($file['type'] != 'text/xml') {
         $error->add(t('File does not appear to be an XML file.'));
     }
 }