/**
  * Обработка запросов на странице
  * 
  * @param array $project данные проекта по которому идет ответ
  * @return array 
  */
 public function actionProcessingProjects($action, $project)
 {
     switch ($action) {
         case 'create_offer':
             $insert['project_id'] = $project['id'];
             $insert['wiz_uid'] = $this->getWizardUserID();
             $insert['post_date'] = "NOW()";
             $insert['descr'] = __paramInit('string', null, 'answer');
             $insert['cost_from'] = __paramInit('float', null, 'from_budget');
             $insert['cost_to'] = __paramInit('float', null, 'to_budget');
             $insert['cost_currency'] = __paramInit('integer', null, 'currency_db_id');
             $insert['time_from'] = __paramInit('float', null, 'from_time');
             $insert['time_to'] = __paramInit('float', null, 'to_time');
             $insert['time_type'] = __paramInit('integer', null, 'time_db_id');
             foreach ($_POST['work_namefile'] as $pos => $filename) {
                 $prev[$pos] = __paramValue('string', $filename);
                 if ($_POST['work_idfile'][$pos] > 0) {
                     $previd[] = intval($_POST['work_idfile'][$pos]);
                 }
             }
             $insert['pict1'] = $prev[1];
             $insert['pict2'] = $prev[2];
             $insert['pict3'] = $prev[3];
             if ($insert['descr'] == '' && !$previd) {
                 $error['answer'] = 'Введите описание предложения';
             }
             if (strlen(stripslashes($_POST['answer'])) > 1000) {
                 $error['answer'] = 'Исчерпан лимит символов для поля (1000 символов)';
             }
             // проверка бюджета
             if (strlen($insert['cost_to']) > 6) {
                 $insert['cost_to'] = 999999;
                 $error['cost_to'] = 'Слишком большая сумма';
             }
             if (strlen($insert['cost_from']) > 6) {
                 $insert['cost_from'] = 999998;
                 $error['cost_from'] = 'Слишком большая сумма';
             }
             // проверка срока
             if (strlen($insert['time_to']) > 3) {
                 $insert['time_to'] = 999;
                 $error['time_to'] = 'Слишком большой срок';
             }
             if (strlen($insert['time_from']) > 3) {
                 $insert['time_from'] = 998;
                 $error['time_from'] = 'Слишком большой срок';
             }
             if (!$error) {
                 $id_offer = $this->createOffer($insert);
                 if ($id_offer) {
                     // Обновляем ид родителя файлов
                     $this->_db->update("file_wizard", array("src_id" => $id_offer, "type" => 2), "id IN (?l)", $previd);
                     header("Location: /wizard/registration/?action=next&complited=1");
                     exit;
                 }
             }
             return $error;
             break;
         case 'paid_offer':
             $answer = __paramInit("integer", null, "answer");
             $payed = array("op_code" => step_freelancer::OFFERS_OP_CODE, "wiz_uid" => $this->getWizardUserID());
             // Количество платных ответов
             switch ($answer) {
                 case 1:
                     $payed['ammount'] = 1;
                     $payed['option'] = 1;
                     break;
                 case 5:
                     $payed['ammount'] = 4;
                     $payed['option'] = 5;
                     break;
                 case 10:
                     $payed['ammount'] = 7;
                     $payed['option'] = 10;
                     break;
                 default:
                     $error = "Ошибка операции";
                     break;
             }
             if (!$error) {
                 $bill_id = wizard_billing::addPaidOption($payed);
                 // Если операция удачна возвращаем на тот же проект для ответа на него
                 if ($bill_id > 0) {
                     header("Location: /wizard/registration/?project={$project['id']}");
                     exit;
                 } else {
                     $error = "Ошибка записи операции";
                 }
             }
             return $error;
             break;
         default:
             return "Неопознанная операция";
             break;
     }
 }
 public function completeData($type_role = 1)
 {
     if ($this->isDisable()) {
         header("Location: /wizard/registration/?step=1");
         exit;
     }
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/employer.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/freelancer.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/city.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/country.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/blogs.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/commune.php";
     $themes_blogs = blogs::getRandomThemes(5);
     $themes_commune = commune::getRandomCommunes(3);
     $month = array('1' => 'января', '2' => 'февраля', '3' => 'марта', '4' => 'апреля', '5' => 'мая', '6' => 'июня', '7' => 'июля', '8' => 'августа', '9' => 'сентября', '10' => 'октября', '11' => 'ноября', '12' => 'декабря');
     if ($type_role == step_wizard_registration::TYPE_WIZARD_EMP) {
         $user = new employer();
         $checkPRO = $this->checkWizardPRO(array(step_employer::OP_CODE_PRO));
         $pro_emp = $checkPRO['id'] > 0 ? 1 : 0;
         if ($pro_emp) {
             $week_pro = round($checkPRO['ammount'] / 10);
         }
     } else {
         $user = new freelancer();
         $checkPRO = $this->checkWizardPRO(step_freelancer::getOperationCodePRO());
         $pro_frl = $checkPRO['id'] > 0 ? 1 : 0;
         if ($pro_frl) {
             $op_code = $checkPRO['op_code'];
         }
     }
     $user->GetUserByUID(wizard::getUserIDReg());
     $info_for_reg = unserialize($user->info_for_reg);
     $uname = $user->uname;
     $usurname = $user->usurname;
     $sex = $user->sex == 't' ? 1 : ($user->sex == 'f' ? 0 : -1);
     $birthday = strtotime($user->birthday);
     if ($birthday) {
         $bday = date('d', $birthday);
         $bmonth = (int) date('m', $birthday);
         $bmonth_value = $month[$bmonth];
         $byear = date('Y', $birthday);
     } else {
         $bday = '';
         $bmonth = (int) date('m', $birthday);
         $bmonth_value = $month[$bmonth];
         $byear = '';
     }
     $city = $user->city;
     if ($city) {
         $city_value = city::GetCityName($city);
     }
     $country = $user->country;
     if ($country) {
         $country_value = country::GetCountryName($country);
     }
     if ($type_role == step_wizard_registration::TYPE_WIZARD_EMP) {
         $company = $user->compname;
         $about_company = $user->company;
         $logo_name = $user->logo;
         $dir = "users/" . substr($user->login, 0, 2) . "/" . $user->login . "/logo/";
         $logo_path = WDCPREFIX . "/" . $dir . $user->logo;
     }
     $info['site'] = $this->loadMultiVal('site', 'site', $user);
     $info['email'] = $this->loadMultiVal('second_email', 'email', $user);
     $info['phone'] = $this->loadMultiVal('phone', 'phone', $user);
     $info['icq'] = $this->loadMultiVal('icq', 'icq', $user);
     $info['skype'] = $this->loadMultiVal('skype', 'skype', $user);
     $info['jabber'] = $this->loadMultiVal('jabber', 'jabber', $user);
     $info['lj'] = $this->loadMultiVal('ljuser', 'lj', $user);
     $action = __paramInit('string', null, 'action');
     if ($action == 'upd_info') {
         $info_for_reg = $_POST['info_for_reg'];
         if ($info_for_reg['email_0'] !== null) {
             $info_for_reg['second_email'] = $info_for_reg['email_0'];
             unset($info_for_reg['email_0']);
         }
         if ($info_for_reg['phone_0'] !== null) {
             $info_for_reg['phone'] = $info_for_reg['phone_0'];
             unset($info_for_reg['phone_0']);
         }
         if ($info_for_reg['site_0'] !== null) {
             $info_for_reg['site'] = $info_for_reg['site_0'];
             unset($info_for_reg['site_0']);
         }
         if ($info_for_reg['lj_0'] !== null) {
             $info_for_reg['ljuser'] = $info_for_reg['lj_0'];
             unset($info_for_reg['lj_0']);
         }
         if ($info_for_reg['jabber_0'] !== null) {
             $info_for_reg['jabber'] = $info_for_reg['jabber_0'];
             unset($info_for_reg['jabber_0']);
         }
         if ($info_for_reg['skype_0'] !== null) {
             $info_for_reg['skype'] = $info_for_reg['skype_0'];
             unset($info_for_reg['skype_0']);
         }
         if ($info_for_reg['icq_0'] !== null) {
             $info_for_reg['icq'] = $info_for_reg['icq_0'];
             unset($info_for_reg['icq_0']);
         }
         if ($info_for_reg['compname'] !== null) {
             $info_for_reg['company'] = $info_for_reg['compname'];
             unset($info_for_reg['compname']);
         }
         $info_for_reg = array_map('intval', $info_for_reg);
         $user->info_for_reg = serialize($info_for_reg);
         $uname = __paramInit('string', null, 'uname', null, 21);
         $usurname = __paramInit('string', null, 'usurname', null, 21);
         if ($uname == '') {
             $error['uname'] = "Поле заполнено некорректно";
         }
         if ($usurname == '') {
             $error['usurname'] = "Поле заполнено некорректно";
         }
         if (!preg_match("/^[-a-zA-Zа-яёА-ЯЁ]+\$/", $uname)) {
             $error['uname'] = "Поле заполнено некорректно";
         } else {
             $user->uname = $uname;
         }
         if (!preg_match("/^[-a-zA-Zа-яёА-ЯЁ]+\$/", $usurname)) {
             $error['usurname'] = "Поле заполнено некорректно";
         } else {
             $user->usurname = $usurname;
         }
         $sex = __paramInit('int', null, 'sex', 1);
         // по умолчанию мужской пол
         $user->sex = $sex == 1 ? 't' : 'f';
         $bday = __paramInit('int', null, 'bday', null);
         $bmonth = __paramInit('int', null, 'bmonth_db_id', 1);
         $bmonth_value = __paramInit('string', null, 'bmonth');
         $byear = __paramInit('int', null, 'byear', null);
         if ($bday != null && $byear != null) {
             if (!is_numeric($bday) || !is_numeric($byear) || !checkdate($bmonth, $bday, $byear) || $byear < 1945 || $byear > date('Y')) {
                 $error['birthday'] = "Поле заполнено некорректно";
             } else {
                 $user->birthday = dateFormat("Y-m-d", $byear . "-" . $bmonth . "-" . $bday);
             }
         } else {
             $user->birthday = "1910-01-01";
         }
         if (!$error['birthday'] && $user->birthday && date("Y", strtotime($user->birthday)) >= date("Y")) {
             $error['birthday'] = "Поле заполнено некорректно";
         }
         $city = __paramInit('int', null, 'city_db_id', 0);
         $city_value = __paramInit('string', null, 'city', false);
         $country = __paramInit('int', null, 'country_db_id', 0);
         $country_value = __paramInit('string', null, 'country', false);
         if ($city == 0 && strlen($city_value) != 0) {
             $error['city'] = 'Поле заполнено некорректно';
         }
         if ($country == 0 && strlen($country_value) != 0) {
             $error['country'] = 'Поле заполнено некорректно';
         }
         $user->country = $country;
         $user->city = $city;
         $company = __paramInit('string', null, 'company') ? substr(__paramInit('string', null, 'company'), 0, 64) : '';
         $about_company = __paramInit('string', null, 'about_company');
         $user->compname = $company;
         if (strlen($about_company) > 500) {
             $error['company'] = "Количество знаков в тексте о компании превышает допустимое значение";
         } else {
             $user->company = $about_company;
         }
         $logo_id = __paramInit('int', null, 'logo_company');
         $logo_name = __paramInit('string', null, 'logo_name');
         if ($logo_name) {
             $user->logo = $logo_name;
             $user->Update(wizard::getUserIDReg(), $res);
         }
         $info['site'] = $this->initMultiVal('site');
         $info['email'] = $this->initMultiVal('email');
         $info['phone'] = $this->initMultiVal('phone');
         $info['icq'] = $this->initMultiVal('icq');
         $info['skype'] = $this->initMultiVal('skype');
         $info['jabber'] = $this->initMultiVal('jabber');
         $info['lj'] = $this->initMultiVal('lj');
         if (!empty($info['site'])) {
             foreach ($info['site'] as $i => $value) {
                 $name = 'site' . ($i != 0 ? "_{$i}" : "");
                 if (!url_validate(addhttp($value), true) && trimhttp($value) != '') {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name} = addhttp($value);
                 }
             }
         }
         if (!empty($info['email'])) {
             foreach ($info['email'] as $i => $value) {
                 if ($i == 0) {
                     $name_save = "second_email";
                 } else {
                     $name_save = "email_{$i}";
                 }
                 $name = 'email' . ($i != 0 ? "_{$i}" : "");
                 if (!is_email($value) && $value != '') {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name_save} = $value;
                 }
             }
         }
         if (!empty($info['phone'])) {
             foreach ($info['phone'] as $i => $value) {
                 $name = 'phone' . ($i != 0 ? "_{$i}" : "");
                 if (!preg_match("/^[-+0-9)( #]*\$/", $value)) {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name} = $value;
                 }
             }
         }
         if (!empty($info['icq'])) {
             foreach ($info['icq'] as $i => $value) {
                 $name = 'icq' . ($i != 0 ? "_{$i}" : "");
                 if (!preg_match("/^[-0-9\\s]*\$/", $value) && !is_email($value)) {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name} = $value;
                 }
             }
         }
         if (!empty($info['skype'])) {
             foreach ($info['skype'] as $i => $value) {
                 $name = 'skype' . ($i != 0 ? "_{$i}" : "");
                 $user->{$name} = $value;
             }
         }
         if (!empty($info['jabber'])) {
             foreach ($info['jabber'] as $i => $value) {
                 $name = 'jabber' . ($i != 0 ? "_{$i}" : "");
                 if (strlen($value) > 255) {
                     $error[$name] = "Количество знаков превышает допустимое значение";
                 } else {
                     $user->{$name} = $value;
                 }
             }
         }
         if (!empty($info['lj'])) {
             foreach ($info['lj'] as $i => $value) {
                 if ($i == 0) {
                     $name_save = "ljuser";
                 } else {
                     $name_save = "lj_{$i}";
                 }
                 $name = 'lj' . ($i != 0 ? "_{$i}" : "");
                 if (!preg_match("/^[a-zA-Z0-9_-]*\$/", $value)) {
                     $error[$name] = "Поле заполнено некорректно";
                 } else {
                     $user->{$name_save} = $value;
                 }
             }
         }
         if ($type_role == step_wizard_registration::TYPE_WIZARD_EMP) {
             $pro_emp = __paramInit('int', null, 'pro-emp', false);
             if ($pro_emp) {
                 $week_pro = round(__paramInit('int', null, 'week_pro', 0));
             }
         } else {
             $ammount = 0;
             $pro_frl = __paramInit('int', null, 'pro-frl', false);
             if ($pro_frl) {
                 $pro = __paramInit('string', null, 'pro', -1);
                 switch ($pro) {
                     case "1week":
                         $op_code = 76;
                         $ammount = 7;
                         break;
                     case "1":
                         $op_code = 48;
                         $ammount = 19;
                         break;
                     case "3":
                         $op_code = 49;
                         $ammount = 54;
                         break;
                     case "6":
                         $op_code = 50;
                         $ammount = 102;
                         break;
                     case "12":
                         $op_code = 51;
                         $ammount = 180;
                         break;
                     case "-1":
                     default:
                         $ammount = 0;
                         break;
                 }
             }
         }
         if (!$error && wizard::getUserIDReg()) {
             $error['save'] = $user->Update(wizard::getUserIDReg(), $res);
             if (!$error['save']) {
                 if ($type_role == step_wizard_registration::TYPE_WIZARD_EMP) {
                     $ammount = $week_pro * 10;
                     if ($ammount > 0) {
                         $checkPRO = $this->checkWizardPRO(step_employer::OP_CODE_PRO);
                         if ($checkPRO['id'] > 0) {
                             $update = array("ammount" => $ammount);
                             wizard_billing::editPaidOption($update, $checkPRO['id']);
                         } else {
                             $insert = array("wiz_uid" => step_wizard::getWizardUserID(), "op_code" => step_employer::OP_CODE_PRO, "type" => 3, "ammount" => $ammount, "parent" => wizard::getUserIDReg());
                             wizard_billing::addPaidOption($insert);
                         }
                     } else {
                         $sql = "DELETE FROM wizard_billing WHERE wiz_uid = ? AND op_code = ?";
                         $this->_db->query($sql, step_wizard::getWizardUserID(), step_employer::OP_CODE_PRO);
                     }
                 } else {
                     // Чистим
                     $sql = "DELETE FROM wizard_billing WHERE wiz_uid = ? AND op_code IN (?l)";
                     $this->_db->query($sql, step_wizard::getWizardUserID(), step_freelancer::getOperationCodePRO());
                     if ($ammount > 0) {
                         $insert = array("wiz_uid" => step_wizard::getWizardUserID(), "op_code" => $op_code, "type" => 4, "ammount" => $ammount, "parent" => wizard::getUserIDReg());
                         wizard_billing::addPaidOption($insert);
                     }
                 }
                 $this->parent->setCompliteStep(true);
                 $this->parent->setNextStep($this->parent->getPosition() + 1);
                 header("Location: /wizard/registration/");
                 exit;
             }
         }
         if ($logo_id > 0) {
             $file = new CFile($logo_id);
             $logo_path = WDCPREFIX . "/" . $file->path . $file->name;
         }
     }
     include $_SERVER['DOCUMENT_ROOT'] . "/wizard/registration/steps/tpl.step.info.php";
 }
Exemple #3
0
 /**
  * Обработка информации шага проекты.
  */
 public function actionProjects()
 {
     $prj_id = $_SESSION['view_wizard_project'];
     if (!$prj_id) {
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php';
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/project_exrates.php';
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php';
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php';
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/country.php';
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/city.php';
         $prj_exrates = project_exrates::GetAll();
         $categories = professions::GetAllGroupsLite();
         $professions = professions::GetAllProfessions();
         array_group($professions, 'groupid');
         $professions[0] = array();
         $addedPrc = is_pro() ? 0 : new_projects::PRICE_ADDED;
         $colorPrc = new_projects::PRICE_COLOR * ($addedPrc > 0 ? 1 : 0);
         $boldPrc = new_projects::PRICE_BOLD + $addedPrc;
         $logoPrc = new_projects::PRICE_LOGO + $addedPrc;
         $cTopPrice = new_projects::PRICE_CONTEST_TOP1DAY + $addedPrc;
         $pTopPrice = new_projects::PRICE_TOP1DAY + $addedPrc;
         $action = __paramInit('string', 'action', 'action', null);
         $attachedfiles_session = __paramInit('string', 'attachedfiles_session', 'attachedfiles_session', false);
         // проверяем есть ли уже созданый проект
         $projects = $this->getCreatedProjects();
         $existPrjID = count($projects) > 0 ? $projects[0][id] : null;
         // выводим ранее сохраненный проект
         if ($action != 'create_project' && $existPrjID) {
             $data = $projects[0];
             list($category, $subcategory) = explode('|', $data['categories']);
             $currency_name = $this->CURRENCY_TYPE[$data['currency']];
             $priceby_name = $this->PRICEBY_TYPE[$data['priceby']];
             $data['pro_only'] = $data['pro_only'] === 't';
             $price = $data['payed'];
             $option = array();
             $option['top'] = $data['top_count'] > 0;
             $option['top_count'] = $data['top_count'];
             $option['color'] = $data['is_color'] === 't';
             $option['bold'] = $data['is_bold'] === 't';
             $option['logo'] = $data['logo_id'] > 0;
         } elseif ($action == 'create_project') {
             // сохраняем новый проект или изменяем старый
             $in_office = __paramInit('int', null, 'in_office', 0);
             $type = __paramInit('string', null, 'kind');
             if ($type == 'contest') {
                 $data['kind'] = 7;
                 $data['end_date'] = date('d-m-Y', strtotime(__paramInit('string', null, 'end_date_eng_format', 0)));
                 $data['win_date'] = date('d-m-Y', strtotime(__paramInit('string', null, 'win_date_eng_format', 0)));
             } elseif ($in_office == 1) {
                 $location = __paramInit('integer', null, 'location_column_id');
                 if ($location == 1) {
                     $data['city'] = __paramInit('integer', null, 'location_db_id');
                     $data['country'] = country::getCountryByCityId($data['city']);
                 } else {
                     $data['country'] = __paramInit('integer', null, 'location_db_id');
                 }
                 $data['kind'] = 4;
             } else {
                 $data['kind'] = 1;
             }
             $data['name'] = __paramInit('string', null, 'name');
             $data['descr'] = __paramInit('string', null, 'descr');
             $category = __paramInit('int', null, 'r_category');
             $subcategory = __paramInit('int', null, 'r_subcategory');
             $agreement = __paramInit('int', null, 'agreement', 0);
             $data['pro_only'] = __paramInit('int', null, 'pro_only', 0) == 1 ? true : false;
             if ($agreement != 1) {
                 $data['cost'] = __paramInit('int', null, 'cost', 0);
                 $data['priceby'] = __paramInit('int', null, 'r_priceby', 0);
                 $data['currency'] = __paramInit('int', null, 'r_currency', 0);
                 $data['budget_type'] = __paramInit('int', null, 'budget_type', 0);
             }
             if (is_empty_html($data['descr'])) {
                 $error['descr'] = 'Поле не заполнено';
             }
             if (is_empty_html($data['name'])) {
                 $error['name'] = 'Поле не заполнено';
             }
             // проверяем длину необработанной строки, а иначе спецсимволы считаются как несколько символов
             if (strlen(stripslashes($_POST['name'])) > 60) {
                 $error['name'] = 'Превышен лимит - 60 символов';
             }
             if (!$category) {
                 $error['category'] = 'Не выбран раздел';
             } elseif ($subcategory) {
                 $data['categories'] = "{$category}|{$subcategory}";
             } else {
                 $data['categories'] = $category;
             }
             if ($data['cost'] < 0) {
                 $error['cost'] = 'Введите положительную сумму';
             }
             if ($data['cost'] > 999999) {
                 $error['cost'] = 'Слишком большая сумма';
             }
             if ($data['cost'] > 0 && ($data['currency'] < 0 || $data['currency'] > 3)) {
                 $error['currency'] = 'Валюта не определена';
             }
             if ($data['cost'] > 0 && ($data['priceby'] < 1 || $data['priceby'] > 4)) {
                 $error['priceby'] = 'Вид бюджета не определен';
             }
             $descr_limit = projects::LIMIT_DESCR;
             if (strlen_real($data['descr']) > $descr_limit) {
                 $error['descr'] = "Исчерпан лимит символов ({$descr_limit})";
             }
             if ($data['kind'] == 7) {
                 if (!preg_match("/^([0-9]{1,2})\\-([0-9]{1,2})\\-([0-9]{4})\$/", $data['end_date'], $o1) || !checkdate($o1[2], $o1[1], $o1[3])) {
                     $error['end_date'] = 'Неправильная дата';
                 }
                 if (!preg_match("/^([0-9]{1,2})\\-([0-9]{1,2})\\-([0-9]{4})\$/", $data['win_date'], $o2) || !checkdate($o2[2], $o2[1], $o2[3])) {
                     $error['win_date'] = 'Неправильная дата';
                 }
                 if (!$error['end_date'] && mktime(0, 0, 0, $o1[2], $o1[1], $o1[3]) <= mktime(0, 0, 0)) {
                     $error['end_date'] = 'Дата окончания конкурса не может находиться  в прошлом';
                 }
                 if (!$error['win_date'] && mktime(0, 0, 0, $o2[2], $o2[1], $o2[3]) <= mktime(0, 0, 0, $o1[2], $o1[1], $o1[3])) {
                     $error['win_date'] = 'Дата определения победителя должна быть больше даты окончания конкурса';
                 }
             }
             $option['top'] = __paramInit('int', null, 'option_top', 0);
             $option['top_count'] = __paramInit('int', null, 'option_top_count', 0);
             $option['color'] = __paramInit('int', null, 'option_color', 0);
             $option['bold'] = __paramInit('int', null, 'option_bold', 0);
             $option['logo'] = __paramInit('int', null, 'option_logo', 0);
             // логотип
             if ($option['logo'] == 1) {
                 $data['logo_link'] = str_replace('http://', '', __paramInit('string', null, 'logo_link', null));
                 $data['logo_id'] = __paramInit('int', null, 'logo_id', null);
                 // если выбрана опция "Логотип со ссылкой", то картинка должна быть обязательно
                 if (!$data['logo_id']) {
                     $error['logo_image'] = 'Отсутствует логотип';
                 }
                 if ($data['logo_link'] === 'Адрес сайта') {
                     $data['logo_link'] = '';
                 }
                 if ($data['logo_link'] !== '' && !is_url($data['logo_link'])) {
                     $error['logo_link'] = 'Не верно введен адрес';
                 }
             } else {
                 $data['logo_id'] = null;
             }
             $price = 0;
             // закрепление на верху
             if ($option['top'] == 1 && $option['top_count'] > 0) {
                 if ($option['top_count'] > 999) {
                     $option['top_count'] = 999;
                 }
                 $price = (int) $option['top_count'] * ($data['kind'] == 7 ? $cTopPrice : $pTopPrice);
                 $data['top_count'] = (int) $option['top_count'];
                 $pay_option[] = array('wiz_uid' => $this->getWizardUserID(), 'op_code' => new_projects::OPCODE_PAYED, 'option' => self::PROJECT_OPTION_TOP, 'type' => $data['kind'] == 7 ? self::BILL_TYPE_CONTEST : self::BILL_TYPE_PROJECT, 'ammount' => $price);
             } else {
                 $data['top_count'] = 0;
             }
             // выделение цветом
             if ($option['color'] == 1) {
                 $price += (int) $colorPrc;
                 $data['is_color'] = true;
                 $pay_option[] = array('wiz_uid' => $this->getWizardUserID(), 'op_code' => new_projects::OPCODE_PAYED, 'option' => self::PROJECT_OPTION_COLOR, 'type' => $data['kind'] == 7 ? self::BILL_TYPE_CONTEST : self::BILL_TYPE_PROJECT, 'ammount' => $colorPrc);
             } else {
                 $data['is_color'] = false;
             }
             // выделение жирным
             if ($option['bold'] == 1) {
                 $price += (int) $boldPrc;
                 $data['is_bold'] = true;
                 $pay_option[] = array('wiz_uid' => $this->getWizardUserID(), 'op_code' => new_projects::OPCODE_PAYED, 'option' => self::PROJECT_OPTION_BOLD, 'type' => $data['kind'] == 7 ? self::BILL_TYPE_CONTEST : self::BILL_TYPE_PROJECT, 'ammount' => $boldPrc);
             } else {
                 $data['is_bold'] = false;
             }
             if ($option['logo'] == 1) {
                 $price += (int) $logoPrc;
                 $pay_option[] = array('wiz_uid' => $this->getWizardUserID(), 'op_code' => new_projects::OPCODE_PAYED, 'option' => self::PROJECT_OPTION_LOGO, 'type' => $data['kind'] == 7 ? self::BILL_TYPE_CONTEST : self::BILL_TYPE_PROJECT, 'ammount' => $logoPrc);
             }
             if ($price > 0) {
                 $data['payed'] = (int) $price;
             }
             if (!$error) {
                 $data['wiz_uid'] = $this->getWizardUserID();
                 // если проект уже есть
                 if ($existPrjID) {
                     // то просто обновляем его
                     $prj_id = $this->updateProject($data, $existPrjID);
                     // и очищаем все платные опции для этого проекта
                     wizard_billing::clearPayedOptions($prj_id);
                 } else {
                     $prj_id = $this->createProject($data);
                 }
                 if ($prj_id && $_POST['attachedfiles_session']) {
                     $attachedfiles = new attachedfiles($_POST['attachedfiles_session']);
                     $files = $attachedfiles->getFiles(array(1, 2, 3, 4));
                     $this->parent->addAttachedFiles($files, $prj_id);
                     $attachedfiles->clear();
                 }
                 if ($prj_id && $data['kind'] == 7) {
                     $insert = array('wiz_uid' => $data['wiz_uid'], 'op_code' => new_projects::OPCODE_KON_NOPRO, 'type' => self::BILL_TYPE_CONTEST, 'ammount' => new_projects::getKonkursPrice(), 'parent' => $prj_id);
                     wizard_billing::addPaidOption($insert);
                 }
                 if ($price > 0 && $prj_id) {
                     foreach ($pay_option as $k => $opt) {
                         $opt['parent'] = $prj_id;
                         wizard_billing::addPaidOption($opt);
                     }
                 }
                 if ($prj_id) {
                     $_SESSION['view_wizard_project'] = $prj_id;
                     header('Location: /wizard/registration/');
                     exit;
                 } else {
                     $error['project'] = 'Ошибка записи проекта';
                 }
             }
             $currency_name = __paramInit('string', null, 'currency');
             $priceby_name = __paramInit('string', null, 'priceby');
         }
         // Генерируем данные для вывода ошибок и заполнения полей
         $loc[] = country::GetCountryName($data['country']);
         if ($data['city']) {
             $loc[] = city::GetCityName($data['city']);
         }
         $location_name = implode(': ', $loc);
         $cat[] = professions::GetGroupName($category);
         if ($subcategory) {
             $cat[] = professions::GetProfName($subcategory);
         }
         $category_name = implode(': ', $cat);
         if ($data['logo_id']) {
             $file = new CFile($data['logo_id']);
             $logo_path = WDCPREFIX . '/' . $file->path . $file->name;
         }
         include $_SERVER['DOCUMENT_ROOT'] . '/wizard/registration/steps/tpl.step.project.php';
     } else {
         $project = $this->getProjectById($prj_id);
         $attached = $this->getProjectAttach($prj_id);
         include $_SERVER['DOCUMENT_ROOT'] . '/wizard/registration/steps/tpl.step.project.view.php';
     }
 }