Пример #1
0
 /**
  * copies the db form settings into the object
  */
 public function post_db()
 {
     $result = true;
     $this->dbuser = $_POST['dbuser'];
     $this->dbpass = $_POST['dbpass'];
     $this->dbhost = $_POST['dbhost'];
     $this->dbtype = $_POST['dbtype'];
     $this->dbport = $_POST['dbport'];
     $this->dbprefix = $_POST['dbprefix'];
     $this->dbname = $_POST['dbname'];
     if (!PHPWS_DB::allowed($this->dbname)) {
         $this->message[] = dgettext('branch', 'This database name is not allowed.');
         $result = false;
     }
     if (empty($this->dbname)) {
         $this->message[] = dgettext('branch', 'You must type a database name.');
         $result = false;
     }
     if (empty($this->dbuser)) {
         $this->message[] = dgettext('branch', 'You must type a database user.');
         $result = false;
     }
     if (preg_match('/\\W/', $this->dbprefix)) {
         $content[] = dgettext('branch', 'Table prefix must be alphanumeric characters or underscores only');
         $result = false;
     }
     return $result;
 }
Пример #2
0
 function checkLabel($label)
 {
     $restricted = array('id', 'user', 'updated', 'position');
     if (is_numeric($label) || preg_match('/^\\d/', $label)) {
         return false;
     }
     if (!PHPWS_DB::allowed($label) || in_array(strtolower($label), $restricted)) {
         return false;
     }
     if (is_array($this->_elements)) {
         foreach ($this->_elements as $value) {
             $elementInfo = explode(':', $value);
             $element = new $elementInfo[0]($elementInfo[1]);
             if (strcasecmp($label, $element->getLabel()) == 0) {
                 unset($element);
                 return FALSE;
             }
         }
     }
     return TRUE;
 }
 /**
  * Crutch function from old database
  */
 public static function sqlFriendlyName($name)
 {
     if (!PHPWS_DB::allowed($name)) {
         return false;
     }
     return preg_replace('/\\W/', '', $name);
 }