//this code is written by M.Emran function useradd(){ nav(t('Users/Add User')); section_content('
'); } function useraddpost(){ $_POST['username'] = strtolower($_POST['username']); if (strlen($_POST['username']) < 4 || strlen($_POST['username']) > 18 || !ereg("^[0-9a-z]+$",$_POST['username'])) { $errors[] = t('Username').': '.t('from 4 to 18 characters, only 0-9,a-z'); } if (!$_POST['email'] || !$_POST['fullname'] || !$_POST['username'] || !$_POST['password']) { $errors[] = t('Please fill in all the required blanks'); } if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) { $errors[] = t('Unavailable email address'); } $password = md5($_POST['password'].'jcow'); $timeline = time(); $res = sql_query("select * from `".tb()."accounts` where email='{$_POST['email']}'"); if (sql_counts($res)) { $errors[] = t('You have registered with this email address before.'); } $res = sql_query("select * from `".tb()."accounts` where username='{$_POST['username']}'"); if (sql_counts($res)) { $errors[] = t('The Username has already been used'); } if(!is_array($errors)){ sql_query("insert into `".tb()."accounts` (hide_age,gender,disabled,password,email,username,fullname,created) values ('1',".$_POST['gender'].",".$_POST['disabled'].",'$password','".$_POST['email']."','".$_POST['username']."','".$_POST['fullname']."','".$timeline."')"); $uid = insert_id(); sql_query("insert into `".tb()."profiles` (id,style_ids) values($uid,'3|3|3')"); stream_publish(t('Signed Up'),'','',$uid); t('Congratulations! You have successfully created user.'); redirect("admin/users"); }else { foreach ($errors as $error) { $error_msg .= '