That looks interesting yes, quite nice o.o I will try to incorporate it somehow xD
What errors are you getting? I had troubles when I accidentely closed the Comment field, so the script wouldn't even run and I didn't understand why lol If there's a little small error somewhere in the javascript, no script will run. For example I was trying to use <font color> and since it was deprecated it made the script not run at all
register.php:
PHP Code:
<?php
use Resource\Native\String;
use Resource\Collection\HashMap;
class RegisterController extends AppController{
public function __construct(){
parent::__construct("guest");
}
public function checkusername(){
$mysidia = Registry::get("mysidia");
if($mysidia->input->post("username") == NULL)
{
throw new NoPermissionException("You specified an invalid action that cannot be completed.");
}
$document = $mysidia->frame->getDocument();
$document->setTitle("error");
$username = $mysidia->input->post('username');
$count = $mysidia->db->select("users",array("uid"),"username = '{$username}' LIMIT 1")->rowCount();
echo $count;
}
public function checkemail(){
$mysidia = Registry::get("mysidia");
if($mysidia->input->post("email") === NULL)
{
throw new NoPermissionException("You specified an invalid action that cannot be completed.");
}
$document = $mysidia->frame->getDocument();
$document->setTitle("error");
$email = $mysidia->input->post("email");
$count = $mysidia->db->select("users",array("uid"),"email = '{$email}' LIMIT 1")->rowCount();
echo $count;
}
public function index(){
$mysidia = Registry::get("mysidia");
if($mysidia->input->post("submit")){
throw new NoPermissionException("No registrations please");
$mysidia->session->validate("register");
$validinput = array("username" => $mysidia->input->post("username"), "password" => $mysidia->input->post("pass1"), "email" => $mysidia->input->post("email"), "birthday" => $mysidia->input->post("birthday"),
"ip" => $mysidia->input->post("ip"), "answer" => $mysidia->input->post("answer"), "tos" => $mysidia->input->post("tos"));
$validator = new RegisterValidator($mysidia->user, $validinput);
$validator->validate();
if(!$validator->triggererror()){
$mysidia->user->register();
include("inc/config_forums.php");
if($mybbenabled == 1){
include_once("functions/functions_forums.php");
mybbregister();
mybbrebuildstats();
}
$mysidia->user->login($mysidia->input->post("username"));
}
else throw new RegisterException($validator->triggererror());
$mysidia->session->terminate("register");
return;
}
$mysidia->session->assign("register", 1, TRUE);
}
}
?>
registerview.php:
PHP Code:
<?php
class RegisterView extends View{
public function index(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
if($mysidia->input->post("submit")){
$document->setTitle($this->lang->success_title);
$document->addLangvar($this->lang->success.$mysidia->input->post("username").$this->lang->success2);
return;
}
$document->setTitle($this->lang->title);
$document->addLangvar($this->lang->default);
$registerForm = new Form("regform", "", "post");
$registerDiv = new Comment("<div class='div07'>");
$registerDiv1 = new Comment("</div>");
$requiredField = new FieldSet("required");
$requiredField->add(new Legend("Required Info"));
$requiredField->add(new Comment("
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
<script>
function checkinput(input, type){
switch(type){
case 1://username
var res = input.match(/^[a-zA-Z0-9][a-zA-Z0-9\s]{1,18}[a-zA-Z0-9]$/);
if(input.length > 20)
{
$('.divUsername').html('<i>Username has too many characters:</i>' + input);
return;
}
if(res == null)
{
$('.divUsername').html('<i>Username can only contain letters, numbers and spaces:</i>' + input);
return;
}
$.post('/register/checkusername', {username:input},function(result) {
if(result[0] != '0'){
$('.divUsername').html('<i>Username is empty or is already being used:</i>' + input)
}
else
{
$('.divUsername').html('<i>Username can be used:</i>' + input)
}
});
return 0;
break;
case 2:
var res = input.match(/^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,4}$/);
if(res == null)
{
$('.divEmail').html('<i>E-mail is not in the correct format: </i>' + input);
return;
}
$.post('/register/checkemail', {email:input},function(result) {
if(result[0] != '0')
{
$('.divEmail').html('<i>E-mail is empty or is already being used:</i>' + input);
}
else
{
$('.divEmail').html('<i>E-mail can be used:</i>' + input);
}
});
break;
case 3:
var res = input.match(/^\d{2}\/\d{2}\/\d{4}$/);
if(res == null)
{
$('.divBirthday').html('<i>Birthday is not in the correct format:</i>' + input);
return;
}
else
{
$('.divBirthday').html('<i>Birthday is in the correct format and can be used:</i>' + input);
return;
}
break;
case 0:
if(input.length <= 0 || input.length > 20)
{
$('.divPassword').html('<i>Password is not the correct size (either empty or bigger than 20 characters)</i>');
return;
}
else
{
$('.divPassword').html('<i>Password is in the correct format and can be used</i>');
return;
}
break;
default:
break;
}
}
$(document).ready(function(){
//alert('hey');
$('input#username').keydown(function(e){
$('.divUsername').html('<i>Loading...</i>');
});
$('input#email').keydown(function(e){
$('.divEmail').html('<i>Loading...</i>');
});
$('input#pass1').keydown(function(e){
$('.divPassword').html('<i>Loading...</i>');
});
$('input#birthday').keydown(function(e){
$('.divBirthday').html('<i>Loading...</i>');
});
$('input#username').focusout(function(){
username = $(this).val();
checkinput(username,1);
});
$('input#email').focusout(function(){
var email = $(this).val();
checkinput(email,2);
});
$('input#pass1').focusout(function(){
var pass = $(this).val();
checkinput(pass,0);
});
$('input#birthday').focusout(function(){
var birthday = $(this).val();
checkinput(birthday,3);
});
})
</script>
",FALSE));
$requiredField->add(new Comment("Username: ", FALSE, "b"));
$requiredField->add(new Comment("Your username may be up to 20 characters long with letters, numbers and spaces only.",FALSE));
$requiredField->add(new TextField("username"));
$requiredField->add(new Comment("<div class='divUsername'></div>",FALSE));//USERNAME DIV ADD THIS LINE
$requiredField->add(new Comment("Password: ", FALSE, "b"));
$requiredField->add(new Comment("Your password may be up to 20 characters long and may contain letters, numbers, spaces and special characters. The use of a special character, such as * or ! is recommended for increased security. "));
$requiredField->add(new Comment("Enter Password ", FALSE));
$requiredField->add(new PasswordField("password", "pass1", "", FALSE));
$requiredField->add(new Comment(" Confirm Password ", FALSE));
$requiredField->add(new PasswordField("password", "pass2", "", TRUE));
$requiredField->add(new Comment("<div class='divPassword'></div>",FALSE));
$requiredField->add(new Comment("Email Address: ", FALSE, "b"));
$requiredField->add(new Comment("Enter a valid email address for yourself."));
$requiredField->add(new PasswordField("email", "email", "", TRUE));
$requiredField->add(new Comment("<div class='divEmail'></div>",FALSE));
$registerForm->add($requiredField);
$additionalField = new FieldSet("additional");
$additionalField->add(new Legend("Additional Info"));
$additionalField->add(new Comment("Birthday: ", FALSE, "b"));
$additionalField->add(new Comment("(mm/dd/yyyy)"));
$additionalField->add(new TextField("birthday"));
$additionalField->add(new Comment("<div class='divBirthday'></div>",FALSE));
$additionalField->add(new Comment("Avatar: ", FALSE, "b"));
$additionalField->add(new Comment("Enter the url of your avatar beginning with http://www."));
$additionalField->add(new TextField("avatar", "templates/icons/default_avatar.gif"));
$additionalField->add(new Comment("Nickname: ", FALSE, "b"));
$additionalField->add(new Comment("A nickname for yourself, do not use inappropriate words! "));
$additionalField->add(new TextField("nickname"));
$additionalField->add(new Comment("Gender: ", FALSE, "b"));
$additionalField->add(new Comment("Male, Female or Not specified"));
$genderList = new RadioList("gender");
$genderList->add(new RadioButton("Male", "gender", "male"));
$genderList->add(new RadioButton("Female", "gender", "female"));
$genderList->add(new RadioButton("Unknown", "gender", "unknown"));
$genderList->check("unknown");
$additionalField->add($genderList);
$additionalField->add(new Comment("Favorite Color: ", FALSE, "b"));
$additionalField->add(new Comment("Your favorite color. Red, Yellow, Blue, who knows? "));
$additionalField->add(new TextField("color"));
$additionalField->add(new Comment("Biography: ", FALSE, "b"));
$additionalField->add(new Comment("Enter a bio for yourself, if you want to."));
$additionalField->add(new TextArea("bio", "", 4, 50));
$registerForm->add($additionalField);
$securityField = new FieldSet("security");
$securityField->add(new Legend("Anti-Spam Security Question"));
$securityField->add(new Comment("Question: ", FALSE, "b"));
$securityField->add(new Comment($mysidia->settings->securityquestion));
$securityField->add(new Comment("Answer: ", FALSE, "b"));
$securityField->add(new TextField("answer"));
$securityField->add(new CheckBox("I agree to the <a href='tos' target='_blank'>Terms of Service", "tos", "yes"));
$securityField->add(new PasswordField("hidden", "ip", $_SERVER['REMOTE_ADDR'], TRUE));
$securityField->add(new Button("Register", "submit", "submit"));
$registerForm->add($securityField);
$document->add($registerForm);
}
}
?>
__________________
 
asp.net stole my soul.
|