Exemple #1
0
 public function actionSaveInfo()
 {
     $bday = __paramInit('int', null, 'bday', null);
     $bmonth = __paramInit('int', null, 'bmonth_db_id', 1);
     $byear = __paramInit('int', null, 'byear', null);
     $ukey = __paramInit('string', 'ukey', null);
     if ($bday != null && $byear != null) {
         if (!is_numeric($bday) || !is_numeric($byear) || !checkdate($bmonth, $bday, $byear) || $byear < 1945 || $byear > date('Y')) {
             $this->error['birthday'] = "Поле заполнено некорректно";
         } else {
             $birthday = dateFormat("Y-m-d", $byear . "-" . $bmonth . "-" . $bday);
         }
     } else {
         $birthday = "1910-01-01";
     }
     $info_for_reg = $_POST['info_for_reg'];
     $info_for_reg = array_map('intval', $info_for_reg);
     $this->setFieldInfo('uname', __paramInit('string', null, 'uname'));
     $this->setFieldInfo('usurname', __paramInit('string', null, 'usurname'));
     $this->setFieldInfo('birthday', $birthday);
     $this->setFieldInfo('country', __paramInit('string', null, 'country_db_id'));
     $this->setFieldInfo('country_name', __paramInit('string', null, 'country'));
     $this->setFieldInfo('city', __paramInit('string', null, 'city_db_id'));
     $this->setFieldInfo('city_name', __paramInit('string', null, 'city'));
     $this->setFieldInfo('sex', __paramInit('string', null, 'sex', 1));
     // по умолчанию мужской пол
     $this->setFieldInfo('info_for_reg', $info_for_reg);
     $this->checkedFields();
     if ($this->is_validate) {
         if (!is_emp()) {
             require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/freelancer.php";
             $user = new freelancer();
         } else {
             require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/employer.php";
             $user = new employer();
         }
         $user->info_for_reg = serialize($this->info_for_reg);
         $user->uname = $this->uname;
         $user->usurname = $this->usurname;
         $user->sex = $this->sex;
         $user->birthday = $this->birthday;
         $user->country = $this->country;
         $user->city = $this->city;
         $this->error['save'] = $user->Update($_SESSION['uid'], $res);
         if (!$ukey) {
             if (get_uid(0) && is_emp()) {
                 header("Location: /registration/welcome_employer.php");
             } elseif (get_uid(0) && !is_emp()) {
                 header("Location: /registration/welcome_free-lancer.php");
             }
             exit;
         } elseif (!$this->error['save']) {
             $_SESSION['check_user_access'] = true;
             $this->action_form = $_SESSION['action_form'][$ukey];
             if (count($_SESSION['post_cache'][$ukey]) > 0) {
                 $this->is_post = true;
                 $this->generate_post = $_SESSION['post_cache'][$ukey];
                 if (count($_SESSION['files_cache'][$ukey])) {
                     $this->generate_files = $_SESSION['files_cache'][$ukey];
                 }
             } else {
                 header("Location: {$this->action_form}");
                 exit;
             }
         }
     }
 }