Example #1
0
 public function reg()
 {
     global $config;
     View::$title = 'Registrasi';
     if (isset($_POST['submit'])) {
         if (strpos($_POST['email'], '@') === FALSE) {
             $_SESSION['ERR_FORM'] = 'Alamat email tidak valid';
             return $this;
         }
         if (User::uidExists($_POST['email'])) {
             $_SESSION['ERR_FORM'] = 'Alamat email anda sudah terdaftar, silahkan langsung <a href="/user/login/">login</a>';
             return $this->model;
         }
         if ($this->model->saveReg($_POST)) {
             $mailfrom = sprintf('%s <%s>', $config['site'], $config['mail']);
             $headers['From'] =& $mailfrom;
             $headers['To'] = $_POST['email'];
             $headers['Subject'] = $config['mail']['reg_subject'];
             $body = sprintf($config['mail']['reg_body'], $_POST['name'], session_id());
             require_once 'Mail.php';
             $mail =& Mail::factory('sendmail', array('sendmail_path' => '/usr/sbin/sendmail'));
             $mail->send($_POST['email'], $headers, $body);
             return '/user/regsuccess/';
         } else {
             $_SESSION['ERR_FORM'] = 'Internal sistem Error';
         }
     }
     return $this->model;
 }
Example #2
0
 public function post()
 {
     if ($this->folder->config['anonPost']) {
         if (!($anonId = User::uidExists('anonymous'))) {
             return $this->folder->path;
         }
         if (isset($_POST['submit'])) {
             $data = $this->model->insert($_POST, $anonId);
             if ($data->id) {
                 return $data->permalink;
             }
         }
         return $this->model;
     } elseif ($this->folder->config['publicPost']) {
         if (!User::$id) {
             $_SESSION['error_uri'] = $_SERVER['REQUEST_URI'];
             $_SESSION['error_msg'] = 'Silahkan <a href="/user/login/">Login</a> sebelum mengirim ' . $this->folder->name;
             return '/error/reqlogin/';
         }
         if (isset($_POST['submit'])) {
             $data = $this->model->insert($_POST);
             if ($data->id) {
                 return $data->permalink;
             }
         }
         return $this->model;
     } else {
         return $this->folder->path;
     }
 }