Пример #1
0
 /**
  * Create new company
  *
  * @param array $add_values
  * @return int
  */
 public function NewCompany(array $add_values)
 {
     $this->add_value = $add_values;
     if (CheckGroupAllow('company_add_capcha')) {
         if (!$this->CheckCapcha()) {
             return false;
         }
     }
     if (!$this->member['id'] && $this->config['company_allow_reg']) {
         $this->CheckRegisterUser();
     }
     if ($this->dbase->SelectOne('job_companies', array("company_id"), array("name" => $this->add_value['name']))) {
         $this->Errors[] = $this->lang['company_error_name_exist'];
     }
     $this->CheckCompanyError();
     if (!$this->Errors && !$this->member['id'] && $this->config['company_allow_reg']) {
         $this->RegisterUser();
     }
     $this->add_value['xfields'] = $this->xfields->EncodeFields($this->add_value);
     $this->Errors = $this->Errors + $this->xfields->getErrors();
     if (!$this->Errors) {
         $this->add_value['user_id'] = $this->member['id'];
         $this->add_value['user_name'] = $this->member['name'];
         return $this->AddCompany();
     } else {
         return 0;
     }
 }
Пример #2
0
 public function Add($value_array)
 {
     $this->values = $value_array;
     $this->CheckError();
     require_once ENGINE_DIR . '/car-market/classes/Fields.php';
     $xfields = new Fields($this->base, $this);
     $this->values['xfields'] = $xfields->EncodeFields($this->values);
     $this->Errors = $this->Errors + $xfields->getErrors();
     if ($this->Errors) {
         return false;
     }
     $this->PreparationValues();
     $this->values['add_date'] = $this->values['update_date'] = $this->base->timer->cur_time;
     $this->values['author'] = $this->member['name'];
     $this->values['author_id'] = $this->member['id'];
     $this->values['author_ip'] = $this->member['ip'];
     $id = $this->base->Insert('auto_autos', $this->values);
     if (!empty($this->values['images'])) {
         $this->values['images'] = array_slice($this->values['images'], 0, $this->config['count_photo'][$this->member['group']]);
         if ($this->values['images']) {
             $this->base->SetWhere('id', $this->values['images'], 'IN', 'auto_images');
             $this->base->Update('auto_images', array('auto_id' => $id), array('auto_id' => 0));
             if (!(int) $this->values['main_photo']) {
                 $this->values['main_photo'] = reset($this->values['images']);
             }
             $this->base->Update('auto_autos', array('photo' => $this->values['main_photo'], 'photo_count' => count($this->values['images'])), array('id' => $id));
         }
     }
     if (!empty($_FILES['photo']['name'][0]) && $this->UploadPhoto($id)) {
         $this->base->Update('auto_autos', array('photo' => $this->values['photo'], 'photo_count' => $this->values['photo_count']), array('id' => $id));
     }
     if (!empty($this->values['allow_site'])) {
         $this->IncrementCounter($this->values['mark_id'], $this->values['model_id']);
         Cache::ClearAllCache();
     }
     return $id;
 }
Пример #3
0
 public function Add($values_array)
 {
     if (!in_array($this->member['group'], $this->config['user_int_allow_no_code'])) {
         $sec_code_session = $_SESSION['sec_code_session'] != '' ? $_SESSION['sec_code_session'] : false;
         $_SESSION['sec_code_session'] = false;
         if ($_POST['sec_code'] != $sec_code_session or !$sec_code_session) {
             $this->Errors[] = $this->lang['error_code'];
         }
     }
     if (!$GLOBALS['is_logged'] && $this->config['general_allow_reg']) {
         $parse = new ParseFilter(array(), array(), 1, 1);
         $password1 = $this->base->EscapeString($parse->process($_POST['password1']));
         $password2 = $this->base->EscapeString($parse->process($_POST['password2']));
         $name = $this->base->EscapeString($parse->process(htmlspecialchars(trim($_POST['name']))));
         $email = $this->base->EscapeString($parse->process(htmlspecialchars(trim($_POST['email']))));
         $member_id = $GLOBALS['db']->super_query("SELECT * FROM " . USERPREFIX . "_users where name='{$name}' and password='******'");
         if ($member_id) {
             $this->LoginIn($password1);
             $GLOBALS['member_id'] = $member_id;
             $this->member['id'] = $member_id['user_id'];
             $this->member['name'] = $member_id['name'];
             $this->member['group'] = $member_id['user_group'];
             $this->member['ip'] = $member_id['logged_ip'];
             $this->guest_session = '';
         } else {
             auto_check_reg($name, $email, $password1, $password2);
         }
     }
     $this->values = $values_array;
     $this->CheckError();
     require_once ENGINE_DIR . '/car-market/classes/Fields.php';
     $xfields = new Fields($this->base, $this);
     $this->values['xfields'] = $xfields->EncodeFields($this->values);
     $this->Errors = $this->Errors + $xfields->getErrors();
     if ($this->Errors) {
         return false;
     }
     if (!$GLOBALS['is_logged'] && $this->config['general_allow_reg']) {
         if (intval($GLOBALS['config']['reg_group']) < 3) {
             $GLOBALS['config']['reg_group'] = 4;
         }
         $regpassword = md5(md5($password1));
         $GLOBALS['db']->query("INSERT INTO " . USERPREFIX . "_users (name, password, email, reg_date, lastdate, user_group, info, signature, favorites, xfields, logged_ip) VALUES ('{$name}', '{$regpassword}', '{$email}', '{$this->base->timer->cur_time}', '{$this->base->timer->cur_time}', '" . $GLOBALS['config']['reg_group'] . "', '', '', '', '', '" . $this->member['ip'] . "')");
         $this->member['id'] = $GLOBALS['db']->insert_id();
         $this->member['name'] = $name;
         $this->member['group'] = $GLOBALS['config']['reg_group'];
         $guest_session = $this->guest_session;
         $this->guest_session = '';
         $this->LoginIn($password1);
     }
     //        if ($this->values['capacity_motor'] > 1000)
     //        {
     //            $this->values['capacity_motor'] = $this->values['capacity_motor']/1000;
     //        }
     $this->PreparationValues();
     if (in_array($this->member['group'], $this->config['user_int_allow_change_exp'])) {
         if ($this->values['count_day']) {
             $this->values['exp_date'] = $this->base->timer->cur_time + (int) $this->values['count_day'] * 24 * 60 * 60;
         } else {
             $this->values['exp_date'] = 0;
         }
     } elseif ($this->config['user_int_default_day_count']) {
         $this->values['exp_date'] = $this->base->timer->cur_time + (int) $this->config['user_int_default_day_count'] * 24 * 60 * 60;
     } else {
         $this->values['exp_date'] = 0;
     }
     if (in_array($this->member['group'], $this->config['user_int_allow_no_moder'])) {
         $this->values['allow_site'] = 1;
     }
     $this->values['guest_session'] = $this->guest_session;
     $this->values['add_date'] = $this->values['update_date'] = $this->base->timer->cur_time;
     $this->values['author'] = $this->member['name'];
     $this->values['author_id'] = $this->member['id'];
     $this->values['author_ip'] = $this->member['ip'];
     $id = $this->base->Insert('auto_autos', $this->values);
     if (!empty($this->values['images'])) {
         $this->values['images'] = array_slice($this->values['images'], 0, $this->config['count_photo'][$this->member['group']]);
         if ($this->values['images']) {
             $this->base->SetWhere('id', $this->values['images'], 'IN', 'auto_images');
             if ($this->member['id']) {
                 $this->base->Update('auto_images', array('auto_id' => $id), array('auto_id' => 0, 'user_id' => $this->member['id']));
             } else {
                 if (!empty($guest_session)) {
                     $this->base->Update('auto_images', array('auto_id' => $id, 'user_id' => $this->member['id'], 'guest_session' => ''), array('auto_id' => 0, 'guest_session' => $guest_session));
                 } else {
                     $this->base->Update('auto_images', array('auto_id' => $id), array('auto_id' => 0, 'guest_session' => $this->guest_session));
                 }
             }
             if (!(int) $this->values['main_photo']) {
                 $this->values['main_photo'] = reset($this->values['images']);
             }
             $this->base->Update('auto_autos', array('photo' => $this->values['main_photo'], 'photo_count' => count($this->values['images'])), array('id' => $id));
         }
     }
     if (!empty($_FILES['photo']['name'][0]) && $this->UploadPhoto($id)) {
         $this->base->Update('auto_autos', array('photo' => $this->values['photo'], 'photo_count' => $this->values['photo_count']), array('id' => $id));
     }
     if (!empty($this->values['allow_site'])) {
         $this->IncrementCounter($this->values['mark_id'], $this->values['model_id']);
         Cache::ClearAllCache();
     }
     if ($this->config['general_inform'] && $this->config['general_email']) {
         if ($data = @file_get_contents(ENGINE_DIR . "/car-market/mail.txt")) {
             include_once DLE_CLASSES . 'mail.class.php';
             $mail = new dle_mail($GLOBALS['config']);
             $mail->from = $GLOBALS['config']['admin_mail'];
             $data = str_replace("{%site_url%}", $GLOBALS['config']['http_home_url'], $data);
             $data = str_replace("{%auto_link%}", $this->tpl->GetUrl(array("action" => 'auto', "id" => $id)), $data);
             $mail->send($this->config['general_email'], $this->lang['mail_subj'], $data);
         }
     }
     return $id;
 }
Пример #4
0
 /**
  * Create new resume
  *
  * @param array $add_values
  */
 public function NewResume(array $add_values)
 {
     $this->add_value = $add_values;
     $this->CheckResumeError();
     $xfields = new Fields(XFIELDS_RESUME, $this);
     $this->add_value['xfields'] = $xfields->EncodeFields($this->add_value);
     $this->Errors = $this->Errors + $xfields->getErrors();
     $this->add_value['date_exp'] = strtotime($this->add_value['date_exp']);
     if (!$this->Errors) {
         return $this->AddResume();
     } else {
         return 0;
     }
 }
Пример #5
0
 public function Save($values_array, $old = array())
 {
     if (empty($values_array['id'])) {
         return false;
     }
     $this->values = $values_array;
     $this->CheckError();
     require_once ENGINE_DIR . '/car-market/classes/Fields.php';
     $xfields = new Fields($this->base, $this);
     $this->values['xfields'] = $xfields->EncodeFields($this->values);
     $this->Errors = $this->Errors + $xfields->getErrors();
     if ($this->Errors) {
         return false;
     }
     if ($old) {
         $this->old_values = $old;
     } elseif (!($this->old_values = $this->base->SelectOne('auto_autos', array('*'), array('id' => $this->values['id'])))) {
         throw new ExceptionAllError("Автомобиль не обнаружен");
     }
     $this->PreparationValues();
     $this->values['update_date'] = $this->base->timer->cur_time;
     if (!empty($this->values['images'])) {
         $this->values['images'] = array_slice($this->values['images'], 0, $this->config['count_photo'][$this->member['group']]);
         if ($this->values['images']) {
             if (!(int) $this->values['main_photo']) {
                 $this->values['main_photo'] = reset($this->values['images']);
             }
             $this->base->Update('auto_autos', array('photo' => $this->values['main_photo'], 'photo_count' => count($this->values['images'])), array('id' => $this->values['id']));
         }
     }
     if (!empty($_FILES['photo']['name'][0])) {
         $this->UploadPhoto($this->values['id'], $this->old_values['photo_count']);
     }
     $this->base->Update('auto_autos', $this->values, array('id' => $this->values['id']));
     if ($this->values['allow_site']) {
         if (!$this->old_values['allow_site']) {
             $this->IncrementCounter($this->values['mark_id'], $this->values['model_id']);
         } elseif ($this->values['model_id'] != $this->old_values['model_id']) {
             $this->DecrementCounter($this->old_values['mark_id'], $this->old_values['model_id']);
             $this->IncrementCounter($this->values['mark_id'], $this->values['model_id']);
         }
         Cache::ClearHTMLCache();
     } elseif ($this->old_values['allow_site']) {
         $this->DecrementCounter($this->old_values['mark_id'], $this->old_values['model_id']);
     }
     return true;
 }
Пример #6
0
 /**
  * Save editing resume
  *
  * @param int $id
  * @return boolean
  */
 protected function SaveResume($id)
 {
     $this->CheckResumeError();
     $xfields = new Fields(XFIELDS_RESUME, $this);
     $this->add_value['xfields'] = $xfields->EncodeFields($this->add_value);
     $this->Errors = $this->Errors + $xfields->getErrors();
     if (!$this->Errors) {
         $this->PreparationResumeValues();
         if (!empty($_FILES['photo']['name']) || !empty($this->add_value['del_photo']) && $this->old_value['photo']) {
             @unlink(PHOTO_PATCH . $this->old_value['photo']);
         }
         $this->dbase->Update('job_resumes', $this->add_value, array('id' => $id));
         return true;
     } else {
         return false;
     }
 }