'; } if (Validator::Length($fullname, 36, 2) == false) { $msg .= 'Full Name should be between 3 to 25 characters' . '
'; } if (!Validator::Length($password, 35, 2)) { $msg .= 'Password should be between 3 to 35 characters' . '
'; } if ($password != $cpassword) { $msg .= $_L['PasswordsNotMatch'] . '
'; } if(!empty($_c['sms_url'])){ $otpPath .= sha1($username.$db_password).".txt"; if(file_exists($otpPath) && time()-filemtime($otpPath)>300){ unlink($otpPath); r2(U . 'register', 's', 'Verification code expired'); }else if(file_exists($otpPath)){ $code = file_get_contents($otpPath); if($code!=$otp_code){ $ui->assign('username', $username); $ui->assign('fullname', $fullname); $ui->assign('address', $address); $ui->assign('phonenumber', $phonenumber); $ui->assign('notify', '
Verification code is Wrong
'); $ui->display('register-otp.tpl'); exit(); }else{ unlink($otpPath); } }else{ r2(U . 'register', 's', 'No Verification code'); } } $d = ORM::for_table('tbl_customers')->where('username', $username)->find_one(); if ($d) { $msg .= $_L['account_already_exist'] . '
'; } if ($msg == '') { $d = ORM::for_table('tbl_customers')->create(); $d->username = $username; $d->password = $password; $d->fullname = $fullname; $d->address = $address; $d->phonenumber = $phonenumber; if ($d->save()) { $user = $d->id(); r2(U . 'login', 's', $_L['Register_Success']); } else { $ui->assign('username', $username); $ui->assign('fullname', $fullname); $ui->assign('address', $address); $ui->assign('phonenumber', $phonenumber); $ui->assign('notify', '
Failed to register
'); r2(U . 'register', 's', 'Failed to register'); } } else { $ui->assign('username', $username); $ui->assign('fullname', $fullname); $ui->assign('address', $address); $ui->assign('phonenumber', $phonenumber); $ui->assign('notify', '
' . $msg . '
'); $ui->display('register.tpl'); } break; default: if(!empty($_c['sms_url'])){ $username = _post('username'); if(!empty($username)){ $d = ORM::for_table('tbl_customers')->where('username', $username)->find_one(); if ($d) { r2(U . 'register', 's', $_L['account_already_exist']); } if(!file_exists($otpPath)){ mkdir($otpPath); touch($otpPath.'index.html'); } $otpPath .= sha1($username.$db_password).".txt"; if(file_exists($otpPath) && time()-filemtime($otpPath)<120){ $ui->assign('username', $username); $ui->assign('notify', '
Please wait '.(120-(time()-filemtime($otpPath))).' seconds before sending another SMS
'); $ui->display('register-otp.tpl'); }else{ $otp = rand(100000,999999); file_put_contents($otpPath, $otp); sendSMS($username,$_c['CompanyName']."\nYour Verification code are: $otp"); $ui->assign('username', $username); $ui->assign('notify', '
Verification code has been sent to your phone
'); $ui->display('register-otp.tpl'); } }else{ $ui->display('register-rotp.tpl'); } }else{ $ui->assign('username', ""); $ui->assign('fullname', ""); $ui->assign('address', ""); $ui->assign('otp', false); $ui->display('register.tpl'); } break; }