display('header.tpl'); $form = new HTML_QuickForm('frmTest', 'post'); $form->addElement('header', 'hdrTesting', 'testing form'); $form->addElement('text', 'email', _("Email").":"); $form->addElement('password', 'pass1', _("Password").":"); $form->addElement('password', 'pass2', _("Repeat").":"); $form->addElement('submit', 'submit', _("Signup")); $form->addRule('email', _("Email is a required field"), 'required', '', 'client'); $form->addRule('email', _("Must be a valid email address."), 'email', '', 'client'); $form->addRule('pass1', _("Password is a required field"), 'required', '', 'client'); $form->addRule('pass1', _("Password can only be alphanumeric"), 'regex', '/^(?:[a-zA-Z0-9]+)$/', 'client'); $form->addRule('pass2', _("Repeat is a required field"), 'required', '', 'client'); $form->addRule('pass2', _("Password can only be alphanumeric"), 'regex', '/^(?:[a-zA-Z0-9]+)$/', 'client'); $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->accept($renderer); $smarty->assign('form', $renderer->toArray()); if($form->validate()) $process = 1; if($form->validate() && $form->exportValue('pass1') != $form->exportValue('pass2')) { $process = 0; $smarty->assign('errmsg', _("The passwords you supplied didn't match each other.")); } if($form->validate() && $process == 1) { $users =& new DataObject_Users(); $users->email = $form->exportValue('email'); if($users->count() > 0) { $process = 0; $smarty->assign('errmsg', _("The email address you supplied has already been used to create an account. Please try using the lost password option, or using a different email address.")); } } if($form->validate() && $process == 1) { $rnd = fopen("/dev/urandom", "r"); $hash = md5(fgets($rnd, 64)); fclose($rnd); $users->hash = $hash; $users->password = md5($form->exportValue('pass1')); $uid = $users->insert(); $body = _("Welcome to")." TransLingo!\n\n"._("Below you'll find a URL, once you open that in your browser your TransLingo account will be verified and you will be able to start adding projects, and/or translating them.")."\n\nhttp://translingo.cacert.org/verify.php?uid=$uid&hash=$hash\n\n"._("Best Regards")."\n\nTransLingo Support\n"; mail($users->email, "[translingo.cacert.org] Account Verification", $body, "From: support@cacert.org\nReply-To: support@cacert.org"); $smarty->display('signup-confirm.tpl'); } else { $smarty->display('signup.tpl'); } $smarty->display('footer.tpl'); ?>