Esempio n. 1
0
 public function save()
 {
     if (!isset($this->contact_name) || empty($this->contact_name)) {
         $this->errors[] = "Contact Name is Required";
     }
     if (isset($this->contact_telephone) && !empty($this->contact_telephone)) {
         $this->contact_telephone = phone_number($this->contact_telephone);
         if (!$this->contact_telephone) {
             $this->errors[] = "Invalid phone number " . $this->contact_telephone;
         }
     }
     if (!isset($this->poster_email) || empty($this->poster_email)) {
         $this->errors[] = "Email address is Required";
     }
     if (isset($this->poster_email) && !empty($this->poster_email)) {
         $this->poster_email = check_email($this->poster_email);
         if ($this->poster_email == "") {
             $this->errors[] = "Invalid email address e.g user@domain.com/co.uk/net";
         }
     }
     if (!empty($this->site_link)) {
         if (validateURL($this->site_link)) {
             $this->site_link = check_http($this->site_link);
         } else {
             $this->errors[] = "Invalid URL address e.g www.domain.com/co.uk/net";
         }
     }
     if (!isset($this->job_title) || empty($this->job_title)) {
         $this->errors[] = "Job Title is Required";
     }
     $allowedTags = '<p><strong><em><u><img><span><style><blockquote>';
     $allowedTags .= '<li><ol><ul><span><div><br><ins><del><a><span>';
     $this->job_description = strip_tags(stripslashes($this->job_description), $allowedTags);
     if (!isset($this->job_description) || empty($this->job_description)) {
         $this->errors[] = "Job Description is Required";
     }
     if (!isset($this->job_type) || empty($this->job_type) || $this->job_type <= 0) {
         $this->errors[] = "Job Type is Required";
     }
     if (!isset($this->j_status) || empty($this->j_status) || $this->j_status <= 0) {
         $this->errors[] = "Job Status is Required";
     }
     if (empty($this->state_province) || empty($this->county) || (!isset($this->city) || empty($this->city))) {
         $this->errors[] = "Job Location is Required";
     }
     if (!isset($this->category) || empty($this->category) || $this->category <= 0) {
         $this->errors[] = "Job Category is Required";
     }
     if ($this->category > 10) {
         $this->errors[] = "MAX 10 categories allowed";
     }
     if (sizeof($this->errors) == 0) {
         // A new record won't have an id yet.
         if (isset($this->id)) {
             return $this->update();
         } else {
             $this->var_name = $this->mod_write_check($this->job_title, null);
             if (ENABLE_NEW_JOBS == "Y" || ENABLE_NEW_JOBS == "1") {
                 $this->is_active = "Y";
             }
             if (APPROVE_JOB == "Y" || APPROVE_JOB == "1") {
                 $this->job_status = "approved";
             }
             $this->created_at = strftime(" %Y-%m-%d %H:%M:%S ", time());
             if ($this->create()) {
                 return true;
             } else {
                 $this->errors[] = "Problem occur.Please make sure all fields have been complated";
                 return false;
             }
         }
     }
 }
 public function save()
 {
     /** company_name **/
     if (empty($this->company_name)) {
         $this->errors[] = "Please enter company name";
     }
     if (!empty($this->temp_path) && !empty($this->filename)) {
         $this->company_logo = $this->username . "." . $this->exe;
         // Determine the target_path
         $target_path = COM_IMAGES_PATH . DS . $this->company_logo;
         $size = getimagesize($this->temp_path);
         $width = $size[0];
         $height = $size[1];
         if ($width > PIC_WIDTH || $height > PIC_HEIGHT) {
             $this->errors[] = "File size needs to be smaller then " . PIC_WIDTH . "x" . PIC_HEIGHT;
         }
         // Make sure a file doesn't already exist in the target location
         if (file_exists($target_path)) {
             $this->errors[] = "The file {$this->filename} already exists.";
             //return false;
         }
     }
     if (!empty($this->site_link)) {
         if (validateURL($this->site_link)) {
             $this->site_link = check_http($this->site_link);
         } else {
             $this->errors[] = "Please enter valid URL e.g. http://wwww.domain.com/uk/org";
         }
     }
     if (empty($this->country) || $this->country == 'AA') {
         $this->errors[] = "Please select country from list";
     }
     if (!empty($this->phone_number)) {
         $this->phone_number = phone_number($this->phone_number);
         if (!$this->phone_number) {
             $this->errors[] = "Please enter vaild phone number";
         }
     }
     // A new record won't have an id yet.
     if (isset($this->id)) {
         if (empty($this->contact_name)) {
             $this->errors[] = "Please enter contact name";
         }
         if (empty($this->address)) {
             $this->errors[] = "Please enter first line of address";
         }
         if (empty($this->state_province)) {
             $this->errors[] = "Please select state from list";
         }
         if (empty($this->county)) {
             $this->errors[] = "Please select county from list";
         }
         if (empty($this->city)) {
             $this->errors[] = "Please select city from list";
         }
         if (empty($this->phone_number)) {
             $this->errors[] = "Please enter contact telephone number";
         }
         if (!empty($this->phone_number)) {
             $this->phone_number = phone_number($this->phone_number);
             if (!$this->phone_number) {
                 $this->errors[] = "Please enter vaild phone number";
             }
         }
         if (sizeof($this->errors) == 0) {
             if (!empty($this->temp_path) && !empty($this->filename)) {
                 // Attempt to move the file
                 if (!move_uploaded_file($this->temp_path, $target_path)) {
                     $this->errors[] = "Unable to save company logo";
                     return false;
                 }
             }
             // if no errors update
             if ($this->update()) {
                 // We are done with temp_path, the file isn't there anymore
                 unset($this->temp_path);
                 return true;
             } else {
                 // File was not moved.
                 $this->errors[] = "Problem try to update your details. Please make sure all fields have been complated";
                 return false;
             }
         }
         //add new record
     } else {
         if (empty($this->username)) {
             $this->errors[] = "Please enter username";
         }
         //if username enter check username
         if (!empty($this->username)) {
             $username_found = self::check_username($this->username);
             if ($username_found && $username_found->username != $_SESSION['uname']) {
                 $this->errors[] = "Username already existed";
             }
             if (!check_username($this->username)) {
                 $this->errors[] = "The username should contain only letters, numbers and underscores";
             }
             if (strlen($this->username) < 4 || strlen($this->username) > 30) {
                 $this->errors[] = "The username must be between 4 - 30 characters";
             }
         }
         /*** Email validation */
         if (empty($this->email_address)) {
             $this->errors[] = "Please enter email address";
         }
         /* email**/
         if (!empty($this->email_address)) {
             if (!check_email($this->email_address)) {
                 $this->errors[] = "Invalid Email address e.g user@domain.com/co.uk/net";
             } else {
                 $email_found = self::check_email($this->email_address);
                 if ($email_found && $email_found->email_address != $_SESSION['email']) {
                     $this->errors[] = "Email address already existed";
                 }
             }
         }
         /** check password and conform password **/
         if ($this->passwd != $this->confirm_password || empty($this->passwd)) {
             $this->errors[] = "Password and Confirm Password does not match";
         }
         if (strlen($this->passwd) < 6 || strlen($this->passwd) > 20) {
             $this->errors[] = "Password must be between 6 - 20 characters ";
         }
         /*** check code */
         if (!$this->CAPTCHA) {
             $this->errors[] = "The security code you entered does not match the image.";
         }
         if ($this->terms == "" || empty($this->terms)) {
             $this->errors[] = "Please accept <a href='" . BASE_URL . "employer/page/terms/'>Terms of Use</a>";
         }
         if (sizeof($this->errors) == 0) {
             if (!empty($this->temp_path) && !empty($this->filename)) {
                 // Attempt to move the file
                 if (!move_uploaded_file($this->temp_path, $target_path)) {
                     $this->errors[] = "Unable to save company logo";
                     return false;
                 }
             }
             /** add credits to user account */
             $this->job_qty = START_CREDIT_POST;
             $this->cv_qty = START_CREDIT_CV_SEARCH;
             $this->spotlight_qty = START_CREDIT_SPOTLIGHT;
             $this->is_active = ACTIVE_EMPLOYER_AUTO;
             $this->passwd = md5($this->passwd);
             $this->date_register = strftime(" %Y-%m-%d %H:%M:%S ", time());
             $this->actkey = md5(session_id());
             if ($this->create()) {
                 // We are done with temp_path, the file isn't there anymore
                 unset($this->temp_path);
                 return true;
             } else {
                 // File was not moved.
                 $this->errors[] = "Problem try to register your details. \r\n\t\t\t\t\t\t\t\t\t\tPlease make sure all fields have been complated";
                 return false;
             }
         }
     }
 }