public function execute()
 {
     $name = rtrim(waRequest::post('name'), '/');
     $domain_model = new siteDomainModel();
     $data = array();
     if (!preg_match('!^[a-z0-9/\\._-]+$!i', $name)) {
         $data['title'] = $name;
         $idna = new waIdna();
         $name = $idna->encode($name);
     }
     $data['name'] = $name;
     $this->response['id'] = $domain_model->insert($data);
     $this->log('site_add');
     // add default routing
     $path = $this->getConfig()->getPath('config', 'routing');
     if (file_exists($path)) {
         $routes = (include $path);
     } else {
         $routes = array();
     }
     if (!isset($routes[$name])) {
         $routes[$name]['site'] = array('url' => '*', 'app' => 'site');
         waUtils::varExportToFile($routes, $path);
     }
 }
Exemplo n.º 2
0
 public function encodeEmail($email)
 {
     if (!self::$_idna) {
         self::$_idna = new waIdna();
     }
     return self::$_idna->encode($email);
 }
 public function execute()
 {
     $name = mb_strtolower(rtrim(waRequest::post('name'), '/'));
     $domain_model = new siteDomainModel();
     $data = array();
     if (!preg_match('!^[a-z0-9/\\._-]+$!i', $name)) {
         $data['title'] = $name;
         $idna = new waIdna();
         $name = $idna->encode($name);
     }
     $data['name'] = $name;
     if ($domain_model->getByName($name)) {
         $this->errors = sprintf(_w("Website with a domain name %s is already registered in this Webasyst installation. Delete %s website (Site app > Settings > %s) to be able to use it's domain name for another website."), $name, $name, $name);
         return;
     }
     $this->response['id'] = $domain_model->insert($data);
     $this->log('site_add');
     // add default routing
     $path = $this->getConfig()->getPath('config', 'routing');
     if (file_exists($path)) {
         $routes = (include $path);
     } else {
         $routes = array();
     }
     if (!isset($routes[$name])) {
         $routes[$name]['site'] = array('url' => '*', 'app' => 'site');
         waUtils::varExportToFile($routes, $path);
     }
 }
Exemplo n.º 4
0
 public function isValid($value)
 {
     if (!preg_match("/^[a-z0-9~@+:\\[\\]\\.-]+\$/i", $value)) {
         $idna = new waIdna();
         $value = $idna->encode($value);
     }
     return parent::isValid($value);
 }
Exemplo n.º 5
0
 public function getIdnaName($punycode)
 {
     $idna = new waIdna();
     return $idna->decode($punycode);
 }