<?php
require_once 'ctrl/BaseCtrl.class.php';
require_once 'xdbx/UsersXdbx.class.php';
require_once 'out/RegisterOut.class.php';
class RegisterCtrl extends BaseCtrl {
function RegisterCtrl() {
}
function process() {
if (isset($_POST['submit'])) {
$username = strip_tags($_POST['username']);
$password = $_POST['password'];
$confirm = $_POST['confirm'];
$email = strip_tags($_POST['email']);
$url = strip_tags($_POST['url']);
$usersXdbx = new UsersXdbx();
if (trim($username) == '') {
$msg = 'you forgot to fill in your username';
} elseif (trim($email) == '') {
$msg = 'you forgot to fill in your email address';
} elseif (trim($url) == '') {
$msg = 'you forgot to fill in your website url';
} elseif ($usersXdbx->getUserByUsername($username)) {
$msg = 'username already exists';
} elseif ($password != $confirm) {
$msg = 'passwords are not identical';
} else {
if (substr($url, 0, 7) != 'http://') {
$url = 'http://'.$url;
}
$code = randomCode();
$ID = $usersXdbx->addUser($username, $password, $email, $url, time(), $code);
$link = 'http://statiqz.space.servehttp.com/index.php?ids=Activate&ID='.$ID.'&code='.$code;
sendMail($email, 'Activate your Statiqz registration', $link);
redirect('index.php?ids=Main');
}
} else {
$msg = ' ';
}
$registerOut = new RegisterOut($msg);
return $registerOut->get();
}
}
?>