public function actionSignup() { if (isset($_POST['register'])) { if (trim($_POST['compName']) == "") { $_SESSION['compName'] = $_POST['compName']; $_SESSION['error'] = "Please provide your company or individual name"; header("location: {$_SERVER['HTTP_REFERER']}"); exit; } if (trim($_POST['password']) == "") { $_SESSION['error'] = "Password field cannot be blank!"; header("location: {$_SERVER['HTTP_REFERER']}"); exit; } if ($_POST['location'] == "") { $_SESSION['error'] = "Specify your location"; header("location: {$_SERVER['HTTP_REFERER']}"); exit; } if (trim($_POST['email']) == "" || filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) == false) { $_SESSION['email'] = $_POST['email']; $_SESSION['error'] = "The email you provided was invalid"; header("location: {$_SERVER['HTTP_REFERER']}"); exit; } if (!ctype_alnum($_POST['location'])) { $_SESSION['error'] = "Location is NOT sensible!"; header("location: {$_SERVER['HTTP_REFERER']}"); exit; } if (User::checker($_POST['email']) != 0) { $_SESSION['error'] = "Sorry, a user already exists with the email you provided. Forgot your password? <a href='#'>Get a new one</a>"; header("location: {$_SERVER['HTTP_REFERER']}"); exit; } if (trim($_POST['tel']) != "") { if (!isPhoneNumber($_POST['tel'])) { $_SESSION['tel'] = $_POST['tel']; $_SESSION['error'] = "Invalid phone number"; header("location: {$_SERVER['HTTP_REFERER']}"); exit; } } $x = new Employer($_POST); $x->utype = $this->user_type; if (!$x->create()) { //Log the next line and simply show an error message $_SESSION['error'] = "Oops! Something went wrong!"; } else { UserController::redirectToLogin("Account has been created. Please login to continue"); exit; } } $type = $this->user_type; //passed to the view for toggling include __VIEWPATH__ . "employer/signup.php"; }
exit; } } else { $employer = new Employer($_POST['user_id']); $new_password = generate_random_string_of(6); $hash = md5($new_password); $data['password'] = $hash; $data['registered_by'] = $employee->getId(); $data['registered_through'] = 'M'; $data['joined_on'] = $today; // $data['free_postings_left'] = $_POST['free_postings']; // $subscription_expire_on = $data['joined_on']; // if ($_POST['subscription_period'] > 0) { // $subscription_expire_on = sql_date_add($data['joined_on'], $_POST['subscription_period'], 'month'); // } if ($employer->create($data) === false) { echo 'ko'; exit; } $lines = file(dirname(__FILE__) . '/../private/mail/employer_welcome.txt'); $message = ''; foreach ($lines as $line) { $message .= $line; } $message = str_replace('%company%', $_POST['name'], $message); $message = str_replace('%user_id%', $_POST['user_id'], $message); $message = str_replace('%temporary_password%', $new_password, $message); $message = str_replace('%protocol%', $GLOBALS['protocol'], $message); $message = str_replace('%root%', $GLOBALS['root'], $message); $subject = "Welcome To Yellow Elevator!"; $headers = 'From: YellowElevator.com <*****@*****.**>' . "\n";
?> </p><p style="font-weight: bold;">Add an employer... </p><p><?php $employer_id = 'ken123'; $data = array(); $data['password'] = md5('new_password'); $data['license_num'] = 'my license'; $data['name'] = 'Fatt Choy Shopping Center'; $data['phone_num'] = '888 888 888 888'; $data['email_addr'] = '*****@*****.**'; $data['contact_person'] = 'Kenny Lee'; $data['zip'] = '11399'; $data['country'] = 'MY'; $data['registerby'] = 'M'; $id = 0; $employer = new Employer($employer_id); if ($employer->create($data)) { print_array(Employer::find(array('match' => 'id = \'' . $employer->id() . '\''))); } else { echo "failed"; exit; } ?> </p><p style="font-weight: bold;">Add a stack of employer fees for ken123... </p><p><?php $fees = array(); $data = array(); $data['employer'] = $employer_id; $data['service_fee'] = 1.5; $data['premier_fee'] = 0.0; $data['discount'] = 0.05; $data['salary_start'] = 1.0; $data['salary_end'] = 30000.0;