function writePost() { system::setParam("page", "writePost"); news::getAllCats(); $fill = array(); $doRedirect = false; $fill = $_POST; if (!empty($_POST["slug"])) { $fill["slug"] = core::generateSlug($_POST["slug"]); } else { if (!empty($_POST["title"])) { $fill["slug"] = core::generateSlug($_POST["title"]); } } if (isset($_POST["picRealUpload"])) { $uploadedPics = news::uploadOnePicture($fill["slug"]); } // $fill["poster"] = ""; if (isset($_FILES["poster"]) && $_FILES["poster"]["error"] == 0) { $uploadedPics = news::uploadOnePicture($fill["slug"], "posterImages"); if (isset($uploadedPics["poster"]) && $uploadedPics["poster"]) { $fill["poster"] = serialize($uploadedPics["poster"]); } } if (isset($_POST["savePost"])) { $savedPost = news::writePost($fill); if ($savedPost) { drafts::save($savedPost["contentID"], $_SESSION["user"]["userID"], "news"); $doRedirect = true; } } news::showAttachedPics($fill); $fill['key'] = core::generateKey(); $this->smarty->assign("fill", $fill); if ($doRedirect) { system::redirect("/adm/news/posts"); } }
$error_flag = 1; $alert[4] = "Вы ввели неверную комбинацию символов"; } } // если запрошено обновление капчи в PDA $newCaptcha = $_POST['newcaptcha']; if ($newCaptcha) { $alert = array(); } if ($chat_with != $_SESSION['login'] && !$error_flag) { list($alert, $error) = messages::Add(get_uid(), $chat_with, $msg, $files, 0, false, $attachedfiles_session); if (!$error && isNulArray($alert)) { messages::updateSendLog(get_uid(false)); if ($draft_id) { require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/drafts.php"; drafts::DeleteDraft(intval($draft_id), get_uid(false), 2, true); } //Если сообщение фрилансеру то разрешаем отправку сообщений обратно if (!is_emp($chat_user->role)) { messages::setIsAllowed($uid, $chat_user->uid); } unset($msg); header("Location: " . $_SERVER["REQUEST_URI"]); exit; } } break; case "delete": require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/teams.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/ignor.php"; $selected = $_POST['selected'];
/** * Залогинивает юзера. Возвращает UID юзера. Выставляет куки "автологина". * ВНИМАНИЕ! возвращает UID юзера, если находит его. Либо возвращает * 0 - не найден * -1 - аккаунт забанен * -2 - аккаунт неактивирован * -3 - IP не входит в список IP разрешенных пользователем * -4 - требуется 2ой этап авторизации * * @param string $login логин юзера * @param string $pwd пароль * @param integer $autologin флаг "автологина" * @return integer UID юзера */ function login($login, $pwd, $autologin = 0, $annoy_check = true) { require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/annoy.php"; $annoy = new annoy(); $user = new users(); if ($annoy_check) { if (intval($_SESSION['login_wait_time']) > time()) { $redirect_checkpass = true; } else { // Проверить сколько раз воодился пароль if (isset($_SESSION['login_wait_time'])) { $annoy->Clear(getRemoteIP()); } $login_count = $annoy->Check(getRemoteIP()); if ($login_count >= $GLOBALS['max_login_tries']) { $_SESSION['login_wait_time'] = time() + $GLOBALS['login_wait_time'] * 60; $redirect_checkpass = true; } } if ($redirect_checkpass == true) { header("Location: /checkpass.php"); exit; } } //Получаем логин и проверяем счетчик $_uid = $user->getUidByLoginEmailPhone($login); if ($_uid > 0 && !$annoy->allowRepeatPass($_uid)) { header("Location: /banned.php"); exit; } //@todo: нет проверок наличия ключей $t_filter_prj = $_SESSION['f_project_filter']; $t_filter_frl = $_SESSION['f_freelancers_filter']; $t_ref_uri2 = $_SESSION['ref_uri2']; $adCatalog = $_SESSION['toppayed_catalog']; $adMain = $_SESSION['toppayed_main']; $adHead = $_SESSION['toppayed_head']; $adText = $_SESSION['toppayed_text']; $masssending = $_SESSION['masssending']; $newPrjName = $_SESSION['new_project_name']; $newPrjCost = $_SESSION['new_project_cost']; //Сохраняем значение типа 2хэпапной авторизации перед очисткой сессии $_2fa_provider = isset($_SESSION['2fa_provider']) ? $_SESSION['2fa_provider'] : null; $_2fa_redirect = isset($_SESSION['2fa_redirect']) ? $_SESSION['2fa_redirect'] : null; //Переносим хеши ссылок на уже зафиксированные местки для юзера при выходе/входе $_ga_stat_url_hash = isset($_SESSION['ga_stat_url_hash']) ? $_SESSION['ga_stat_url_hash'] : null; //Последняя посещенная страница $_ref_uri = isset($_SESSION['ref_uri']) ? $_SESSION['ref_uri'] : null; $_pda = isset($_SESSION['pda']) ? $_SESSION['pda'] : null; $_customer_wizard = isset($_SESSION['customer_wizard']) ? $_SESSION['customer_wizard'] : null; session_unset(); if ($_customer_wizard) { $_SESSION['customer_wizard'] = $_customer_wizard; } if ($_pda) { $_SESSION['pda'] = $_pda; } if ($_ref_uri) { $_SESSION['ref_uri'] = $_ref_uri; } //Воссанавливаем значение хешей ссылок if ($_ga_stat_url_hash) { $_SESSION['ga_stat_url_hash'] = $_ga_stat_url_hash; } //Востанавливаем значение 2хэпапной авторизации после очистки сессии if ($_2fa_provider !== null) { $_SESSION['2fa_provider'] = $_2fa_provider; } if ($_2fa_redirect !== null) { $_SESSION['2fa_redirect'] = $_2fa_redirect; } //Выключаем проверку 2ого этапа авторизации //если это вход из куки или еще откуда (но неявно от пользователя) //где мы уже уверены что 2этапа пройдены ранее юзером $is_2fa_off = $annoy_check === false; //Авторизация $id = $user->Auth($login, $pwd, $_SESSION, $is_2fa_off); //Считаем и блокируем по количеству неудачных авторизаций if (!$id && $_uid > 0) { $annoy->wrongRepeatPass($_uid); } //Успешная авторизация if ($id > 0) { $annoy->clearRepeatPass($id); require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/payed.php"; $pro_last = payed::ProLast($_SESSION['login']); //Покупал ли пользователь ПРО 1 мес и более или тестовый if (!is_emp()) { $_SESSION['is_was_pro'] = $pro_last ? true : payed::isWasPro($_SESSION['uid']); } $_SESSION['pro_last'] = $pro_last['is_freezed'] ? false : $pro_last['cnt']; if ($_SESSION['pro_last'] && $_SESSION['is_pro_new'] != 't') { payed::checkNewPro($id); } if ($pro_last['freeze_to']) { $_SESSION['freeze_from'] = $pro_last['freeze_from']; $_SESSION['freeze_to'] = $pro_last['freeze_to']; $_SESSION['is_freezed'] = $pro_last['is_freezed']; $_SESSION['payed_to'] = $pro_last['cnt']; } if ($_SESSION['anti_login']) { $pro_last = payed::ProLast($_SESSION['anti_login']); $_SESSION['anti_pro_last'] = $pro_last['freeze_to'] ? false : $pro_last['cnt']; } require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/memBuff.php"; $memBuff = new memBuff(); $memBuff->delete("msgsCnt{$id}"); //Получение спецализаций фрилансера if (!is_emp()) { require_once ABS_PATH . "/classes/freelancer.php"; $specData = freelancer::getAllSpecAndGroup($id, is_pro()); $_SESSION['specs'] = $specData['specs']; //Список специализаций $_SESSION['groups'] = $specData['groups']; //Список групп //@todo: пока не используется //$_SESSION['specs_tree'] = $specData['specs_tree']; //Ввиде древа группа > специализации } require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/drafts.php"; $iDraftsCount = drafts::getCount($id); $_SESSION['drafts_count'] = $iDraftsCount; if ($autologin == 1) { setcookie('id', $id, time() + 60 * 60 * 24 * 30, '/', $GLOBALS['domain4cookie'], COOKIE_SECURE, true); setcookie('name', $login, time() + 60 * 60 * 24 * 30, '/', $GLOBALS['domain4cookie'], COOKIE_SECURE); setcookie('pwd', users::cookieHashPasswd($id), time() + 60 * 60 * 24 * 30, '/', $GLOBALS['domain4cookie'], COOKIE_SECURE, true); } $_SESSION['f_project_filter'] = $t_filter_prj; $_SESSION['f_freelancers_filter'] = $t_filter_frl; $_SESSION['ref_uri2'] = $t_ref_uri2; $_SESSION['toppayed_catalog'] = $adCatalog; $_SESSION['toppayed_main'] = $adMain; $_SESSION['toppayed_head'] = $adHead; $_SESSION['toppayed_text'] = $adText; if ($masssending) { $_SESSION['masssending'] = $masssending; } $_SESSION['new_project_name'] = $newPrjName; $_SESSION['new_project_cost'] = $newPrjCost; if ($t_filter_prj) { require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/projects_filter.php"; $prj_filter = new projects_filters(); $prj_filter->SaveFromAnon(); } if ($t_filter_frl) { require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/freelancers_filter.php"; $frl_filter = new freelancers_filters(); $frl_filter->SaveFromAnon(); } //var_dump($_SESSION['customer_wizard']); //var_dump($_SESSION['customer_wizard_filled']); //exit; //Если заказчик пытается опубликовать проект через мастер то публикуем после авторизации if (is_emp() && isset($_SESSION['customer_wizard']['filled'])) { require_once ABS_PATH . '/guest/models/GuestActivationModel.php'; $_SESSION['ref_uri'] = GuestActivationModel::model()->published($id, $_SESSION['email']); } } // случайное число, используемое в get/post запросах для защиты. if (!$_SESSION['rand']) { $_SESSION['rand'] = csrf_token(); } return $id; }
/** * Проекты. Утверждение/удаление записи * * @param string $stream_id идентификатор потока * @param int $user_id идентификатор модератора * @param int $from_id идентификатор пользователя * @param int $rec_id идентификатор записи * @param int $rec_type тип записи * @param int $action действие: 1 - утверждено, 2 - удалено * @param string $is_sent было ли отправлено уведомление * @param string $reason причина удаления */ function resolveProjects($stream_id = '', $user_id = 0, $from_id = 0, $rec_id = 0, $rec_type = 0, $action = 1, $is_sent = '', $reason = '') { $bRet = false; $sQuery = 'UPDATE moderation SET moder_num = ?i, status = ?i WHERE rec_id = ?i AND rec_type = ?i AND stream_id = ? RETURNING rec_id'; $sRecId = $GLOBALS['DB']->val($sQuery, $this->nResolveCnt, $action, $rec_id, self::MODER_PROJECTS, $stream_id); if ($sRecId) { $bRet = true; $GLOBALS['DB']->update('projects', array('moderator_status' => $user_id), 'id = ?i', $rec_id); require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/admin_log.php'; $projects = new projects(); $project = $projects->GetPrjCust($rec_id); $sObjLink = getFriendlyURL('project', $rec_id); // лог админских действий if ($action == 1 && $project['blocked_time']) { // разблокируем $projects->UnBlocked($rec_id); admin_log::addLog(admin_log::OBJ_CODE_PROJ, 10, $from_id, $rec_id, $project['name'], $sObjLink, 0, '', 0, ''); } elseif ($action == 2 && !$project['blocked_time']) { // блокируем $sBlockId = $projects->Blocked($rec_id, $reason, 0, $user_id, true); // Удаляем черновики жалобы require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/drafts.php'; drafts::DeleteDraftByPrjID($rec_id); $projects->DeleteComplains($rec_id); // пишем лог админских действий admin_log::addLog(admin_log::OBJ_CODE_PROJ, 9, $from_id, $rec_id, $project['name'], $sObjLink, 0, '', 0, $reason, $sBlockId); } } return $bRet; }
</td> </tr> </table> </div> </div> </div> <script type="text/javascript"> (function () { var attachedfiles_list = new Array(); <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/attachedfiles.php"; $attachedfiles_session = $_POST['attachedfiles_session']; $attachedfiles = new attachedfiles($attachedfiles_session); if ($draft_id) { if (!$attachedfiles_session) { $attachedfiles_tmpdraft_files = drafts::getAttachedFiles($draft_id, 2); if ($attachedfiles_tmpdraft_files) { $attachedfiles_prj_files = array(); foreach ($attachedfiles_tmpdraft_files as $attachedfiles_draft_file) { $attachedfiles_draft_files[] = $attachedfiles_draft_file; } $attachedfiles->setFiles($attachedfiles_draft_files, 1); } } } else { if ($action == 'Edit.post' && !$alert) { $attachedfiles_tmpblog_files = commune::getAttachedFiles($top['id']); if ($attachedfiles_tmpblog_files) { $attachedfiles_blog_files = array(); foreach ($attachedfiles_tmpblog_files as $attachedfiles_blog_file) { $attachedfiles_blog_files[] = $attachedfiles_blog_file;
/** * Проверяет туда ли попал пользователь и есть ли у него на это право. * Возвращает адрес переброски пользователя, если он не туда попал, * и если не NULL, то надо будет вызвать header(). * Если NULL, но $error не пуст, то надо будет выдать страницу ошибок __COMMUNES__ERROR и * прекратить операцию. * Заодно заполняет необходимые переменные. * * @global $uid Ид пользователя * @global $id Ид сообщения * @global $top_id Ид вкладки ТОП * @global $site Сайт * @global $action Действие для данной функции при отсылке данных (submit) * * @param string $error Возвращает сообщение об ошибке * @param array $comm Возвращает данные по комментариям * @param array $top Возвращает популярные сообщения * @param integer $restrict_type Возвращает тип пользования * @param integer $user_mod Возвращает битовую маску прав пользователя * @return string если не null, название страницы куда перенести пользователя */ function __commShaolin(&$error, &$comm, &$top, &$restrict_type, &$user_mod) { global $uid, $id, $top_id, $site, $action, $draft_id; $comm = NULL; $user_mod = 0; if ($uid) { $user_mod = commune::MOD_ADMIN * hasPermissions('communes'); $user_mod |= commune::MOD_MODER * ($user_mod & commune::MOD_ADMIN || hasPermissions('communes')); $user_mod |= commune::MOD_PRO * (payed::CheckPro(get_login($uid)) ? 1 : 0); $user_mod |= commune::MOD_EMPLOYER * (int) is_emp(); $user_mod |= commune::MOD_BANNED * is_banned($uid); } if (!$id) { if (!$site) { return NULL; } if ($site == 'Create') { if (!$uid) { return '/fbd.php'; } if (!($user_mod & (commune::MOD_PRO | commune::MOD_ADMIN))) { /*if ($user_mod & commune::MOD_EMPLOYER) return '/payed-emp/';*/ return '/proonly.php'; } if (($limit = commune::GetUserCommunesLimits($uid)) && $limit['user_communes_count']) { if ($limit['user_communes_count'] >= commune::MAX_COUNT) { $error['name'] = 'Создание вашего сообщества'; $error['message'] = 'Вы уже создали максимальное количество сообществ.'; return NULL; } $seconds = $limit['seconds_passed_since_user_created_his_last_commune']; if ($seconds < commune::CREATION_INTERVAL) { $error['name'] = 'Создание вашего сообщества'; $wait = commune::CREATION_INTERVAL - $seconds; $error['message'] = "Подождите {$wait} " . getSymbolicName($wait, 'second') . '.'; return NULL; } } } else { return '/404.php'; } return NULL; } if (!($comm = commune::GetCommune($id, !$uid ? NULL : $uid, $user_mod))) { return '/commune/'; } if (!$uid) { if ($action) { return "/commune/?id={$id}"; } if ($site == 'Topic') { } else { if ($site == 'Join') { return '/fbd.php'; } else { if ($site == 'Members') { return '/fbd.php'; } else { if ($site) { return "/commune/?id={$id}"; } } } } } else { if ($uStatus = commune::GetUserCommuneRel($id, $uid)) { $user_mod |= commune::MOD_COMM_MODERATOR * $uStatus['is_moderator']; $user_mod |= commune::MOD_COMM_MANAGER * $uStatus['is_manager']; $user_mod |= commune::MOD_COMM_ADMIN * ($uStatus['is_admin'] || $uStatus['is_moderator'] || $uStatus['is_manager']); $user_mod |= commune::MOD_COMM_AUTHOR * $uStatus['is_author']; $user_mod |= commune::MOD_COMM_ASKED * $uStatus['is_asked']; $user_mod |= commune::MOD_COMM_ACCEPTED * ($uStatus['is_accepted'] || $user_mod & commune::MOD_COMM_ADMIN); $user_mod |= commune::MOD_COMM_BANNED * $uStatus['is_banned']; } } if ($comm['is_blocked'] && !($user_mod & commune::MOD_MODER)) { if ($comm['author_id'] != $uid || $comm['author_id'] == $uid && ($site && $site != 'Members' || $action)) { return '/commune/'; } } if ($user_mod & commune::MOD_COMM_BANNED && !hasPermissions('communes') && $comm['restrict_type'] != '00') { $error['name'] = 'Нет доступа в сообщество'; $error['message'] = 'Вы находитесь в бан-листе этой группы. Вы можете обратиться к создателю группы:<br/><br/>' . '<div style="float:left">' . __commPrntUsrAvtr($comm, 'author_') . '</div>' . '<div style="padding-left:10px;float:left">' . __commPrntUsrInfo($comm, 'author_') . '</div>'; return NULL; } $restrict_type = bitStr2Int($comm['restrict_type']); if ($restrict_type & commune::RESTRICT_READ_MASK) { if ($site != 'Join' && $action != 'Join' && !($user_mod & (commune::MOD_COMM_AUTHOR | commune::MOD_COMM_ACCEPTED | commune::MOD_ADMIN | commune::MOD_MODER))) { $error['name'] = 'Нет доступа в сообщество'; if ($user_mod & commune::MOD_COMM_ASKED) { $error['message'] = " Администратор сообщества <b>«{$comm['name']}»</b> еще не рассмотрел вашу заявку. Просмотр этого сообщества вам не доступен.<br/><br/>" . __commPrntJoinButton($comm, $uid); } else { $error['message'] = " Вы не являетесь членом сообщества <b>«{$comm['name']}»</b>. Просмотр этого сообщества вам не доступен.<br/><br/>" . __commPrntJoinButton($comm, $uid); } return NULL; } } switch ($site) { case 'Join': // if ( $user_mod & commune::MOD_COMM_AUTHOR ) // return "/commune/?id={$id}"; // if ( $user_mod & commune::MOD_COMM_ASKED ) // return "/commune/?id={$id}"; break; case 'Create': if ($id) { return "/commune/?id={$id}"; } break; case 'Edit': if (!($user_mod & (commune::MOD_ADMIN | commune::MOD_COMM_AUTHOR))) { return "/commune/?id={$id}"; } break; case 'Admin': if (!($user_mod & (commune::MOD_ADMIN | commune::MOD_COMM_AUTHOR))) { if ($user_mod & commune::MOD_COMM_MANAGER) { return "/commune/?id={$id}&site=Admin.members"; } return "/commune/?id={$id}"; } break; case 'Admin.members': if (!($user_mod & (commune::MOD_ADMIN | commune::MOD_COMM_AUTHOR | commune::MOD_COMM_MANAGER) || hasPermissions('communes'))) { return "/commune/?id={$id}"; } break; case 'Topic': if ($action && $action != 'do.Edit.post' && $action != 'do.Create.post' && $action != 'add_comment' && $action != 'edit_comment' && $action != 'wysiwygUploadImage') { //if ($action && $action != 'Edit.post') return "/404.php"; } if (!$top_id || !($top = commune::GetTopMessageByAnyOther($top_id, $uid, $user_mod, TRUE)) || $top['member_is_banned'] && $comm['restrict_type'] != '00' && ($action != 'do.Edit.post' && $action != 'do.Create.post') && !($user_mod & (commune::MOD_ADMIN | commune::MOD_COMM_AUTHOR | commune::MOD_COMM_MANAGER)) || $top['is_private'] == 't' && $top['user_id'] != $uid && !($user_mod & (commune::MOD_ADMIN | commune::MOD_COMM_AUTHOR | commune::MOD_COMM_MANAGER)) || $top['deleted_id'] && !hasPermissions('communes')) { return "/404.php"; } break; case 'Members': break; case 'Newtopic': if (commune::isBannedCommune($user_mod)) { $error['name'] = 'Нет доступа'; $error['message'] = 'Вы находитесь в бан-листе этой группы. Вы можете обратиться к создателю группы:<br/><br/>' . '<div style="float:left">' . __commPrntUsrAvtr($comm, 'author_') . '</div>' . '<div style="padding-left:10px;float:left">' . __commPrntUsrInfo($comm, 'author_') . '</div>'; return NULL; } if (!($user_mod & commune::MOD_COMM_AUTHOR && !$comm['is_blocked']) && !($user_mod & (commune::MOD_ADMIN | commune::MOD_MODER | commune::MOD_COMM_ACCEPTED | commune::MOD_COMM_ADMIN | commune::MOD_COMM_MODERATOR | commune::MOD_COMM_ADMIN))) { return getFriendlyURL('commune_commune', $comm['id']); } break; case 'Editdraft': require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/drafts.php"; $draftData = drafts::getDraft($draft_id, get_uid(false), 4); if (!$draftData) { return getFriendlyURL('commune_commune', $comm['id']); } break; case 'Edittopic': break; default: if ($site) { return "/404.php"; } break; } if ($action) { if ($action == 'Delete' && !($user_mod & commune::MOD_ADMIN)) { return "/commune/?id={$id}"; } if (!$site) { if (($action == 'do.Edit.post' || $action == 'do.Create.post') && $user_mod & (commune::MOD_ADMIN | commune::MOD_COMM_AUTHOR | commune::MOD_COMM_ACCEPTED)) { return NULL; } if ($action == 'Join') { return NULL; } return "/commune/?id={$id}"; } } return NULL; }
/** * Обработка и оплата операций * * @global type $DB * @param type $option * @return boolean */ function billingOperation($option, $transaction_id) { global $DB; $ok = false; $account = new account(); switch ($option['op_code']) { // Аккаунт ПРО у фрилансера case 48: case 49: case 50: case 51: case 76: // Удаляем операции по покупке ответов - публикуем ответы $prof = new payed(); $ok = $prof->SetOrderedTarif($this->uid, $transaction_id, 1, "Аккаунт PRO", $option['op_code'], $error); if ($ok) { $_SESSION['pro_last'] = payed::ProLast($_SESSION['login']); $_SESSION['pro_last'] = $_SESSION['pro_last']['freeze_to'] ? false : $_SESSION['pro_last']['cnt']; $userdata = new users(); $_SESSION['pro_test'] = $userdata->GetField($this->uid, $error2, 'is_pro_test', false); $this->clearBlockedOperations(step_freelancer::OFFERS_OP_CODE); $step_frl = new step_freelancer(); $offers = $step_frl->getWizardOffers($this->uid, 'all', false); if ($offers) { require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/users.php"; $step_frl->log = $this->log; $step_frl->user = new users(); $step_frl->user->GetUserByUID($this->uid); $step_frl->transferOffers($offers); } $this->showProjectsFeedbacks(); } break; // Аккаунт ПРО у работодателя // Аккаунт ПРО у работодателя case 15: $prof = new payed(); $ok = $prof->SetOrderedTarif($this->uid, $transaction_id, 1, "Аккаунт PRO", $option['op_code'], $error); if ($ok) { $_SESSION['pro_last'] = payed::ProLast($_SESSION['login']); $_SESSION['pro_last'] = $_SESSION['pro_last']['freeze_to'] ? false : $_SESSION['pro_last']['cnt']; $userdata = new users(); $_SESSION['pro_test'] = $userdata->GetField($this->uid, $error2, 'is_pro_test', false); } // Обновляем выбор цвета для проектов тк он для ПРО бесплатный $colorProjects = $this->updateColorProject(); $prj = new new_projects(); foreach ($colorProjects as $k => $project) { $delete_color[] = $project['op_id']; if ($project['country'] == null) { $project['country'] = 'null'; } if ($project['city'] == null) { $project['city'] = 'null'; } $project['name'] = addslashes($project['name']); $project['descr'] = addslashes($project['descr']); if ($project['logo_id'] <= 0) { $project['logo_id'] = 'null'; } $project['payed_items'] = $project['payed_items'] | '010'; $project['is_color'] = 't'; $prj->editPrj($project, false); } // Удаляем данные операции if ($delete_color) { $this->deleteDraftAccountOperation($delete_color); } break; // Публикация конкурса // Публикация конкурса case new_projects::OPCODE_KON: case new_projects::OPCODE_KON_NOPRO: require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/wizard/step_wizard_registration.php'; $drafts = new drafts(); $draft = $drafts->getDraft($option['parent_id'], $this->uid, 1); // Если еще не опубликован if (!$draft['prj_id']) { $project_id = $draft['id']; $error = $account->Buy($bill_id, $transaction_id, $option['op_code'], $this->uid, $option['descr'], $option['comment'], 1, 0); $ok = $bill_id > 0; if ($bill_id) { $color = $DB->val("SELECT id FROM draft_account_operations WHERE parent_id = ? AND op_type = 'contest' AND option = 'color' AND uid = ?", $project_id, wizard::getUserIDReg()); $draft['billing_id'] = $bill_id; $draft['folder_id'] = 'null'; $draft['payed'] = '0'; $draft['payed_items'] = '000'; if (is_pro() && $color > 0) { $draft['is_color'] = 't'; } else { $draft['is_color'] = 'f'; } $draft['win_date'] = date('d-m-Y', strtotime($draft['win_date'])); $draft['end_date'] = date('d-m-Y', strtotime($draft['end_date'])); $draft['is_bold'] = 'f'; $draft['user_id'] = $this->uid; if ($draft['country'] == null) { $draft['country'] = 'null'; } if ($draft['city'] == null) { $draft['city'] = 'null'; } $draft['name'] = addslashes($draft['name']); $draft['descr'] = addslashes($draft['descr']); if ($draft['logo_id'] <= 0) { $draft['logo_id'] = 'null'; } $prj = new new_projects(); $attachedfiles_tmpdraft_files = drafts::getAttachedFiles($option['parent_id'], 4); if ($attachedfiles_tmpdraft_files) { $attachedfiles_tmpdraft_files = array_map(create_function('$a', 'return array("id" => $a);'), $attachedfiles_tmpdraft_files); } if ($attachedfiles_tmpdraft_files) { $month = date('Ym'); $dir = 'projects/upload/' . $month . '/'; $files = step_wizard_registration::transferFiles($attachedfiles_tmpdraft_files, 'file_projects', $dir); } $spec = $draft["categories"]; $spec = explode("|", $spec); $spec = array(array('category_id' => $spec[0], 'subcategory_id' => $spec[1])); $prj->addPrj($draft, $files); $prj->saveSpecs($draft["id"], $spec); // смотрим были ли выбраны платные опции для опубликованного конкурса if ($draft['id'] != $project_id && $draft['id'] > 0) { if ($this->sleep[$project_id]) { foreach ($this->sleep[$project_id] as $k => $opt) { $opt['parent_id'] = $draft['id']; $this->billingOperation($opt); } } else { //Обновляем родителя на всякий случай $update = array("parent_id" => $draft['id']); $DB->update("draft_account_operations", $update, "parent_id = ? AND op_type = 'contest' AND uid = ?", $project_id, wizard::getUserIDReg()); $this->sleep_parent[$project_id] = $draft['id']; } $DB->update("draft_projects", array('prj_id' => $draft['id']), "id = ? AND uid = ?", $project_id, wizard::getUserIDReg()); } } } break; // Платный проект/конкурс // Платный проект/конкурс case 53: $prj = new new_projects(); if ($this->sleep_parent[$option['parent_id']]) { $option['parent_id'] = $this->sleep_parent[$option['parent_id']]; } $project = $prj->getProject($option['parent_id']); if (!$project['id']) { $this->sleep[$option['parent_id']][$option['id']] = $option; return true; } else { unset($this->sleep[$option['parent_id']]); } if ($project['country'] == null) { $project['country'] = 'null'; } if ($project['city'] == null) { $project['city'] = 'null'; } $project['name'] = addslashes($project['name']); $project['descr'] = addslashes($project['descr']); if ($project['logo_id'] <= 0) { $project['logo_id'] = 'null'; } $project['folder_id'] = 'null'; $items = array(); switch ($option['option']) { case 'top': $project['top_days'] = $option['op_count']; break; case 'color': $is_pay = $project['payed_items'] & '010'; if ($is_pay != '010') { $project['payed_items'] = $project['payed_items'] | '010'; $project['is_color'] = 't'; $items['color'] = true; if (is_pro()) { $is_payed = true; $prj->SavePayedInfo($items, $project['id'], null, $project['top_days']); $prj->editPrj($project, false); } } else { $is_payed = true; } break; case 'bold': $is_pay = $project['payed_items'] & '001'; if ($is_pay != '001') { $project['payed_items'] = $project['payed_items'] | '001'; $project['is_bold'] = 't'; $items['bold'] = true; } else { $is_payed = true; } break; case 'logo': $is_pay = $project['payed_items'] & '100'; if ($is_pay != '100') { $key = md5(microtime()); $prj = new tmp_project($key); $prj->init(1); $fu = new CFile($option['src_id']); $ext = $fu->getext(); $tmp_dir = $prj->getDstAbsDir(); $tmp_name = $fu->secure_tmpname($tmp_dir, '.' . $ext); $tmp_name = substr_replace($tmp_name, "", 0, strlen($tmp_dir)); $fu->table = 'file_projects'; $r = $fu->_remoteCopy($tmp_dir . $tmp_name); $project['payed_items'] = $project['payed_items'] | '100'; $project['logo_id'] = $fu->id; $items['logo'] = true; if ($option['extra']) { $project['link'] = $option['extra']; } } else { $is_payed = true; } break; } if (!$is_payed) { $error = $account->Buy($bill_id, $transaction_id, $option['op_code'], $this->uid, $option['descr'], $option['comment'], $option['ammount'], 0); $ok = $bill_id > 0; $project['billing_id'] = $bill_id; $prj->SavePayedInfo($items, $project['id'], $bill_id, $project['top_days']); $prj->editPrj($project, false); } else { $ok = true; } break; // Платные ответы на проекты // Платные ответы на проекты case 61: $answers = new projects_offers_answers(); $error = $answers->BuyByFM($this->uid, $option['op_count'], $transaction_id, 0); if (!$error) { $ok = true; $_SESSION['answers_ammount'] = $option['op_count']; // Публикуем ответы $step_frl = new step_freelancer(); $offers = $step_frl->getWizardOffers($this->uid, $option['op_count']); if ($offers) { require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/users.php"; $step_frl->log = $this->log; $step_frl->user = new users(); $step_frl->user->GetUserByUID($this->uid); $step_frl->transferOffers($offers); } } break; } return $ok; }
<?php global $user_mod; ?> <a name="o"></a> <a name="<?php echo !empty($alert) ? 'error' : ''; ?> "></a> <?php $member = commune::GetCommuneByMember($_SESSION['uid']); $draft_id = !$draft_id ? intval($_GET['draft_id']) : $draft_id; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/drafts.php"; $draft_data = drafts::getDraft($draft_id, get_uid(false), 4); if ($draft_data) { $mess['category_id'] = $draft_data['category']; $title = $draft_data['title']; $msgtext = $draft_data['msg']; $youtube_link = $draft_data['yt_link']; $question = $draft_data['poll_question']; $multiple = $draft_data['poll_type'] == 0 ? 'f' : 't'; $draft_answers = $draft_data['poll_answers']; if (empty($draft_answers)) { $draft_answers = array(''); } $edit_msg['poll'] = array(); if ($draft_answers) { foreach ($draft_answers as $draft_answer) { array_push($edit_msg['poll'], array('answer' => htmlspecialchars($draft_answer))); }
/** * Публикация черновика * * @param int $draft_id ID черновика * @param int $type Тип черновика * @param bool $is_edit false - публикация нового поста/прокта, true - публикация существующего поста/проекта */ function PostDraft($draft_id, $type, $is_edit = false) { $objResponse = new xajaxResponse(); session_start(); $draft_id = intval($draft_id); $uid = get_uid(false); if ($uid) { require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/drafts.php"; $draft = drafts::getDraft($draft_id, $uid, $type); if ($draft) { switch ($type) { case 2: // Личка require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/attachedfiles.php"; $attachedfiles = new attachedfiles($attachedfiles_session); $attachedfiles_tmpdraft_files = drafts::getAttachedFiles($draft_id, 3); if ($attachedfiles_tmpdraft_files) { $attachedfiles_draft_files = array(); foreach ($attachedfiles_tmpdraft_files as $attachedfiles_draft_file) { $attachedfiles_draft_files[] = $attachedfiles_draft_file; } $attachedfiles->setFiles($attachedfiles_draft_files); } $objResponse->assign("f_attachedfiles_session", "value", $attachedfiles->getSession()); $objResponse->assign("f_msg", "innerHTML", $draft['msg']); $objResponse->assign("f_msg_to", "value", $draft['to_login']); $objResponse->assign("f_draft_id", "value", $draft['id']); $objResponse->assign("f_to_login", "value", $draft['to_login']); $objResponse->script("var attrAction = document.createAttribute('action'); attrAction.value='/contacts/?from=" . $draft['to_login'] . "'; \$('f_frm').setAttributeNode(attrAction);"); $objResponse->script('$("f_frm").submit();'); break; case 3: // Блоги require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/blogs.php"; $objResponse->assign("f_draft_id", "value", $draft['id']); $objResponse->assign("f_msg", "value", $draft['msgtext']); $objResponse->assign("f_yt_link", "value", $draft['yt_link']); if ($draft['is_close_comments'] == 't') { $objResponse->script('$("f_is_close_comments").set("checked",true);'); } if ($draft['is_private'] == 't') { $objResponse->script('$("f_is_private").set("checked",true);'); } $objResponse->assign("f_category", "value", $draft['category'] . '|0'); if ($is_edit) { $blogmsg = blogs::GetMsgInfo($draft['post_id'], $error, $perm); $objResponse->assign("f_msg_name", "value", $draft['title']); $objResponse->assign("f_tr", "value", $blogmsg['thread_id']); $objResponse->assign("f_olduser", "value", $blogmsg['fromuser_id']); $objResponse->assign("f_reply", "value", $draft['post_id']); $objResponse->assign("f_action", "value", 'change'); $objResponse->assign("f_msg_name", "value", $draft['title']); $objResponse->assign("f_draft_post_id", "value", $draft['post_id']); $objResponse->script("var attrAction = document.createAttribute('action'); attrAction.value='/blogs/view.php?id=" . $draft['post_id'] . "'; \$('f_frm').setAttributeNode(attrAction);"); } else { $objResponse->assign("f_name", "value", $draft['title']); $objResponse->assign("f_sub_ord", "value", 'new'); $objResponse->assign("f_action", "value", 'new_tr'); $objResponse->script("var attrAction = document.createAttribute('action'); attrAction.value='/blogs/viewgroup.php?gr=" . $draft['category'] . "&ord=new&tr='; \$('f_frm').setAttributeNode(attrAction);"); } require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/attachedfiles.php"; $attachedfiles = new attachedfiles($attachedfiles_session); $attachedfiles_tmpdraft_files = drafts::getAttachedFiles($draft_id, 1); if ($attachedfiles_tmpdraft_files) { $attachedfiles_draft_files = array(); foreach ($attachedfiles_tmpdraft_files as $attachedfiles_draft_file) { $attachedfiles_draft_files[] = $attachedfiles_draft_file; } $attachedfiles->setFiles($attachedfiles_draft_files, 1); } $objResponse->assign("f_attachedfiles_session", "value", $attachedfiles->getSession()); $objResponse->assign("f_poll_question", "value", $draft['poll_question']); $objResponse->assign("f_poll_type", "value", $draft['poll_type']); $answers = $draft['poll_answers']; if (count($answers)) { $out = ''; foreach ($answers as $answer) { $out .= '<input type="hidden" value="' . htmlspecialchars($answer, ENT_QUOTES) . '" name="answers[]" />'; } $objResponse->assign("f_poll_answers", "innerHTML", $out); } $objResponse->script('$("f_frm").submit();'); break; case 4: // Сообщества $objResponse->assign("f_id", "value", $draft['commune_id']); $objResponse->assign("f_draft_id", "value", $draft['id']); $objResponse->assign("f_category_id", "value", intval($draft['category'])); $objResponse->assign("f_title", "value", $draft['title']); $objResponse->assign("f_msgtext", "value", $draft['msg']); $objResponse->assign("f_youtube_link", "value", $draft['yt_link']); if ($draft['close_comments'] == 't') { $objResponse->script('$("f_close_comments").set("checked",true);'); } if ($draft['is_private'] == 't') { $objResponse->script('$("f_is_private").set("checked",true);'); } if ($is_edit) { $objResponse->assign("f_draft_post_id", "value", $draft['post_id']); $objResponse->assign("f_top_id", "value", $draft['post_id']); $objResponse->assign("f_message_id", "value", $draft['post_id']); $objResponse->assign("f_page", "value", 0); $objResponse->script("var attrAction = document.createAttribute('action'); attrAction.value='" . getFriendlyURL('commune', $draft['post_id']) . "'; \$('f_frm').setAttributeNode(attrAction);"); $objResponse->assign("f_action", "value", "do.Edit.post"); } else { $objResponse->script("var attrAction = document.createAttribute('action'); attrAction.value='" . getFriendlyURL('commune_commune', $draft['commune_id']) . "#o'; \$('f_frm').setAttributeNode(attrAction);"); $objResponse->assign("f_action", "value", "do.Create.post"); } require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/attachedfiles.php"; $attachedfiles = new attachedfiles($attachedfiles_session); if (!$is_edit) { $attachedfiles_tmpdraft_files = drafts::getAttachedFiles($draft_id, 2); if ($attachedfiles_tmpdraft_files) { $attachedfiles_draft_files = array(); foreach ($attachedfiles_tmpdraft_files as $attachedfiles_draft_file) { $attachedfiles_draft_files[] = $attachedfiles_draft_file; } $attachedfiles->setFiles($attachedfiles_draft_files, 1); } } $objResponse->assign("f_attachedfiles_session", "value", $attachedfiles->getSession()); $objResponse->assign("f_poll_question", "value", $draft['poll_question']); $objResponse->assign("f_poll_type", "value", $draft['poll_type']); $answers = $draft['poll_answers']; if (count($answers)) { $out = ''; foreach ($answers as $answer) { $out .= '<input type="hidden" value="' . htmlspecialchars($answer, ENT_QUOTES) . '" name="answers[]" />'; } $objResponse->assign("f_poll_answers", "innerHTML", $out); } $objResponse->script('$("f_frm").submit();'); break; } } } return $objResponse; }
$no_banner = 1; $enter = true; $header = "../header.php"; $footer = "../footer.html"; $page_title = "Публикация проекта - фриланс, удаленная работа на FL.ru"; $page_keyw = "фрилансер, работодатель, удаленная работа, поиск работы, предложение работы, портфолио фрилансеров, разработка сайтов, программирование, переводы, тексты, дизайн, арт, реклама, маркетинг, прочее, fl.ru"; $page_descr = "Фрилансер. Работодатель.Удаленная работа. Поиск работы. Предложение работы. Портфолио фрилансеров. Разработка сайтов, Программирование, Переводы, Тексты, Дизайн, Арт, Реклама, Маркетинг, Прочее. FL.ru"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/stdf.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/account.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/projects.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/drafts.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/uploader/uploader.php"; session_start(); $uid = get_uid(); $drafts = new drafts(); $step = __paramInit('int', 'step', 'step', -1); $proj_id = __paramInit('int', 'public', 'public', 0); $kind = __paramInit('int', 'kind', 'kind'); if ($kind == 7) { $page_title = "Публикация конкурса - фриланс, удаленная работа на FL.ru"; } $back = __paramInit('string', 'red', 'red', ''); $key = __paramInit('string', 'pk', 'pk'); $draft_id = intval(__paramInit('int', 'draft_id', 'draft_id')); $auto_draft = intval(__paramInit('int', 'auto_draft', 'auto_draft')); if (!$key) { $key = md5(uniqid($uid)); // ключ-идентификатор создаваемого/редактируемого проекта, для хранения в кэше. if ($step == 1 && !$proj_id) { // если с нулевого шага пришли. Не передаем ключ оттуда сразу, т.к. юзер может несколько
public function paidOperation($id) { global $DB; if (!$id) { return false; } require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php'; $operation = $DB->row('SELECT * FROM draft_account_operations WHERE id = ? AND status IS NULL', $id); $account = new account(); $this->_transactionId = $account->start_transaction($_SESSION['uid'], $this->_transactionId); switch ($operation['op_type']) { case 'project': $project = $DB->row('SELECT id, payed_info FROM projects WHERE id = ?i', $operation['parent']); if (!$project['id']) { return 'Ошибка обработки операции.'; } if ($account->sum >= $operation['ammount']) { if ($error = $account->Buy($bill_id, $this->_transactionId, $operation['op_code'], $_SESSION['uid'], trim($operations['descr'], '/'), trim($operations['comments'], '/'), 1, true)) { return $error; } } if (!$bill_id) { return 'Не хватает денег.'; } $update = array(); switch ($operation['option']) { case 'color': $update['is_color'] = true; $update['payed_items'] = $project['payed_info'] | '010'; break; case 'bold': $update['is_bold'] = true; $update['payed_items'] = $project['payed_info'] | '001'; break; case 'top': $update['top_from'] = date('d.m.Y H:i', strtotime('now')); $update['top_to'] = date('d.m.Y H:i', strtotime("now +{$operation['op_count']} day")); break; case 'logo': $update['logo_id'] = $operation['src_id']; $update['payed_items'] = $project['payed_info'] | '100'; break; } $update['billing_id'] = $bill_id; $DB->update('projects', $update, 'id = ?', $operation['parent']); header('Location: /bill/success/'); exit; break; case 'contest': // Публикация конкурса if ($account->sum >= $operation['ammount']) { if ($error = $account->Buy($bill_id, $this->_transactionId, $operation['op_code'], $_SESSION['uid'], trim($operations['descr'], '/'), trim($operations['comments'], '/'), 1, true)) { return $error; } } if (!$bill_id) { return 'Не хватает денег.'; } $key = md5(microtime()); $prj = new tmp_project($key); if (get_uid()) { $prj->init(1); } $draft = new drafts(); $project = $drafts->getDraft($operation['parent'], $_SESSION['uid'], 1); require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php'; $attachedfiles = new attachedfiles(); $attachedfiles_tmpdraft_files = drafts::getAttachedFiles($operation['parent'], 4); if ($attachedfiles_tmpdraft_files) { $attachedfiles_prj_files = array(); foreach ($attachedfiles_tmpdraft_files as $attachedfiles_draft_file) { $attachedfiles_draft_files[] = $attachedfiles_draft_file; } $attachedfiles->setFiles($attachedfiles_draft_files, 1); } $insert = array('user_id' => $_SESSION['uid'], 'name' => $project['name'], 'descr' => $project['descr'], 'kind' => $project['kind'], 'cost' => $project['cost'], 'currency' => $project['currency'], 'country' => $project['country'] > 0 ? $project['country'] : 'NULL', 'city' => $project['city'] > 0 ? $project['city'] : 'NULL', 'payed' => '0', 'pro_only' => $project['pro_only'], 'logo_id' => 'NULL', 'link' => $project['logo_link'], 'is_color' => 'f', 'is_bold' => 'f', 'billing_id' => 0, 'payed_items' => '000', 'folder_id' => 0, 'budget_type' => $project['budget_type'], 'priceby' => $project['priceby'], 'prefer_sbr' => $project['prefer_sbr'], 'end_date' => $project['p_end_date'], 'win_date' => $project['p_win_date']); if (!empty($project['categories'])) { $cat = explode('|', $project['categories']); $categories[0] = array('category_id' => intval($cat[0]), 'subcategory_id' => intval($cat[1])); } $create = $prj->addPrj($insert, $attachedfiles_draft_files, $categories); // Добавляем проект if ($create) { $drafts->DeleteDraft($draft_id, $uid, 1); header('Location: /bill/success/'); exit; } break; case 'account': // Покупка ПРО break; } }
/** * Блокирование/разблокирование проекта * * @param integer $project_id id проекта * @param string $reason причина * @param int $reason_id ID причины, если она выбрана из списка (таблица admin_reasons, где act_id = 9) * @param string $reason_name Краткое описание причины действия (из селекта) для лога админских действий */ function BlockedProject($project_id, $reason, $reason_id = null, $reason_name = '') { global $DB; $objResponse = new xajaxResponse(); $project_id = intval($project_id); session_start(); if (hasPermissions('projects')) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php'; if (is_string($reason) && $reason != '') { if (hasPermissions('projects')) { $count = $DB->val("SELECT COUNT(*) FROM projects WHERE id = ?", $project_id); if ($count) { $projects = new projects(); $project = $projects->GetPrjCust($project_id); $sObjLink = getFriendlyURL('project', $project_id); // лог админских действий $reason_id = $reason_id ? $reason_id : null; $reason = str_replace('%USERNAME%', $project['uname'] . ' ' . $project['usurname'], $reason); $reason = change_q($reason, FALSE, 0, TRUE); $mem = new memBuff(); $mem->delete("prjMsgsCnt{$project['user_id']}"); if ($project['blocked_time']) { $projects->UnBlocked($project_id); // пишем лог админских действий admin_log::addLog(admin_log::OBJ_CODE_PROJ, 10, $project['user_id'], $project_id, $project['name'], $sObjLink, 0, '', $reason_id, $reason); $objResponse->assign("project-reason-{$project_id}", 'innerHTML', ' '); $objResponse->assign("project-reason-{$project_id}", 'style.display', 'none'); $objResponse->assign("project-button-{$project_id}", 'innerHTML', "<a class='b-post__link b-post__link_dot_c10601' href='javascript: void(0);' onclick='banned.blockedProject({$project_id}); return false;'>Заблокировать</a>"); } else { $projects->DeleteComplains($project_id); $sBlockId = $projects->Blocked($project_id, $reason, $reason_id, $_SESSION['uid']); $project = $projects->GetPrjCust($project_id); // Удаляем черновик require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/drafts.php'; drafts::DeleteDraftByPrjID($project_id); // пишем лог админских действий admin_log::addLog(admin_log::OBJ_CODE_PROJ, 9, $project['user_id'], $project_id, $project['name'], $sObjLink, 0, '', $reason_id, $reason, $sBlockId); $reason = reformat($project['blocked_reason'], 24, 0, 0, 1, 24); $html = BlockedProjectHTML($reason, $project['blocked_time'], $_SESSION['login'], "{$_SESSION['name']} {$_SESSION['surname']}"); $objResponse->assign("project-reason-{$project_id}", 'innerHTML', $html); $objResponse->assign("project-reason-{$project_id}", 'style.display', 'block'); $objResponse->assign("project-button-{$project_id}", 'innerHTML', "<a style='color: Red;' href='javascript: void(0);' onclick='banned.unblockedProject({$project_id}); return false;'>Разблокировать</a>"); } } else { $objResponse->alert('Несуществующий проект'); } } } } return $objResponse; }
public function selectdraftbyid($id) { $drafts = drafts::where('id', '=', $id)->get(); if ($drafts) { return $drafts[0]; } }
header('Location: ' . getFriendlyURL('commune_commune', $id) . ($query_string ? "?{$query_string}" : '') . '#o' . $message_id); // exit; } else { // if($action=='do.Create.post') { // if($parent_id) { // $sm = new smail(); // $sm->CommuneNewComment($message_id); // } // } $o = $top_id == $parent_id && $action == 'do.Create.post' ? '-last' : ($message_id ? $message_id : $parent_id); if ($o == 0) { $o = ''; } require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/drafts.php'; if ($draft_id) { drafts::DeleteDraft($draft_id, get_uid(false), 4); } header("Location: /commune/?id={$id}&site=Topic&post={$top_id}" . ($top_id == $message_id ? '' : ".{$message_id}") . ($om ? "&om={$om}" : '') . "&o={$o}" . ($rating ? '&rating=' . $rating : '') . ($o ? "#o{$o}" : '')); // Бежим на страницу комментариев. // exit; } } } break; case 'Create': case 'Edit': break; case 'do.Edit': case 'do.Create': $alert = NULL; $name = __paramInit('string', NULL, 'name', '', commune::NAME_MAX_LENGTH * 2);
public function transferProjects() { $projects = $this->getCreatedProjects(); require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/drafts.php'; if ($projects) { $key = md5(microtime()); $prj = new tmp_project($key); $this->setPath(); foreach ($projects as $k => $project) { $files = $this->getProjectAttach($project['id']); if ($project['kind'] == 7) { $tmp_dir = $this->tmpAbsDir; } else { $tmp_dir = $this->dstAbsDir; } if ($files) { $table = 'file_projects'; $files = $this->transferFiles($files, $table, $tmp_dir); } if ($project['kind'] != 7) { $attach = array_map(create_function('$a', 'return array("file_id" => $a["id"]);'), $files); $insert = array('user_id' => $_SESSION['uid'] ? $_SESSION['uid'] : $_SESSION['RUID'], 'name' => addslashes($project['name']), 'descr' => addslashes($project['descr']), 'kind' => $project['kind'], 'cost' => $project['cost'], 'currency' => $project['currency'], 'country' => $project['country'] > 0 ? $project['country'] : 'NULL', 'city' => $project['city'] > 0 ? $project['city'] : 'NULL', 'payed' => '0', 'pro_only' => $project['pro_only'], 'logo_id' => 'NULL', 'link' => $project['logo_link'], 'is_color' => 'f', 'is_bold' => 'f', 'billing_id' => 0, 'payed_items' => '000', 'folder_id' => 0, 'budget_type' => $project['budget_type'], 'priceby' => $project['priceby'], 'prefer_sbr' => $project['prefer_sbr']); $cat = explode('|', $project['categories']); $categories[0] = array('category_id' => intval($cat[0]), 'subcategory_id' => intval($cat[1])); $prj->addPrj($insert, $attach, $categories); // Добавляем проект if ($insert['id']) { $delete_projects[] = $project['id']; } else { $error_project[] = "Ошибка создания проекта #{$project['id']}"; } // Проверяем платные опции если есть обновляем в отложенных операциях тк выше все операции выбранные там уже ушли туда if ($insert['id'] && ($project['is_color'] || $project['is_bold'] || $project['top_count'] > 0 || $project['logo_id'] > 0)) { $update = array('parent_id' => $insert['id']); $this->_db->update('draft_account_operations', $update, "parent_id = ? AND op_type = 'project' AND uid = ?", $project['id'], wizard::getUserIDReg()); if ($project['logo_link']) { $update = array('extra' => $project['logo_link']); $this->_db->update('draft_account_operations', $update, "parent_id = ? AND op_type = 'contest' AND option = 'logo' AND uid = ?", $contest['id'], wizard::getUserIDReg()); } } // Если это конкурс он сразу идет в черновики } else { $draft = new drafts(); $cat = explode('|', $project['categories']); $insert = array('uid' => $_SESSION['uid'] ? $_SESSION['uid'] : $_SESSION['RUID'], 'name' => addslashes($project['name']), 'descr' => addslashes($project['descr']), 'kind' => $project['kind'], 'cost' => $project['cost'], 'currency' => $project['currency'], 'country' => $project['country'], 'end_date' => $project['end_date'], 'win_date' => $project['win_date'], 'city' => $project['city'], 'pro_only' => $project['pro_only'] == 't' ? 1 : 0, 'budget_type' => $project['budget_type'], 'priceby' => $project['priceby'], 'prefer_sbr' => $project['prefer_sbr'], 'categories' => array(0 => $cat[0]), 'subcategories' => array(0 => $cat[1]), 'logo_id' => $project['logo_id'], 'link' => $project['logo_link']); $contest = $draft->SaveProject($insert, $files); if ($contest['id']) { $delete_projects[] = $project['id']; } else { $error_project[] = "ошибка создания конкурса #{$project['id']}"; } // Проверяем платные опции если есть пишем в отложенные платежи if ($contest['id'] && ($project['is_color'] || $project['is_bold'] || $project['top_count'] > 0 || $project['logo_id'] > 0)) { $update = array('parent_id' => $contest['id']); $this->_db->update('draft_account_operations', $update, "parent_id = ? AND op_type = 'contest' AND uid = ?", $project['id'], wizard::getUserIDReg()); if ($project['logo_link']) { $update = array('extra' => $project['logo_link']); $this->_db->update('draft_account_operations', $update, "parent_id = ? AND op_type = 'contest' AND option = 'logo' AND uid = ?", $contest['id'], wizard::getUserIDReg()); } } } } if ($delete_projects) { $this->_db->query('DELETE FROM wizard_projects WHERE id IN (?l) AND wiz_uid = ?', $delete_projects, $this->getWizardUserID()); } if ($error_projects) { foreach ($error_projects as $error) { $this->log->writeln('Error transfer projects content () - user (' . wizard::getUserIDReg() . '|' . $this->getWizardUserID() . ") - Error: {$error}"); } } } return $error; }
if ($msg === '' && $question === '' && empty($alert[5]) && !($countfiles || $attachedfiles_info['count']) && $yt_link === '') { $error_flag = 1; $alert[2] = 'Ошибка. Сообщение не должно быть пустым!'; } elseif (!$error && !$error_flag && ($msg !== '' || $attach['name'] || $attach_have || $attach_delete || $question || $yt_link || $attachedfiles_info['count'])) { $blog_obj->Edit($_SESSION['uid'], $thread, $msg, $msg_name, $files, getRemoteIP(), $err, $mod, NULL, $gr, $t, $attach_delete, $olduserlogin, $yt_link, $close_comments, $is_private, $ontop, null, $question, $answers, $answers_exists, $multiple); //$nStopWordsCnt = $stop_words->calculate( $msg, $msg_name, $question, $answers, $answers_exists ); $attachedfiles_files = $attachedfiles->getFiles(array(1, 3, 4)); $blog_obj->addAttachedFiles($attachedfiles_files, $thread, $olduserlogin, $draft_id ? true : false); $attachedfiles->clear(); //$blog_obj->insertIntoModeration( $thread, $nStopWordsCnt ); // больше не модерируем if ($err) { $alert = $alert + $err; } if ($draft_id && !($alert || $error || $error_flag)) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/drafts.php'; drafts::DeleteDraft($draft_id, get_uid(false), 3, true); } } if ($site == 'journal') { unset($_SESSION['user.journal.change.result']); if ($alert || $error || $error_flag) { $question = str_replace(array('"', "'", '\\', '<', '>'), array('"', ''', '\', '<', '>'), stripslashes($_POST['question'])); $answers = array(); $answers_exists = array(); if (!empty($_POST['answers']) && is_array($_POST['answers'])) { foreach ($_POST['answers'] as $key => $answer) { $answers[$key] = str_replace(array('"', "'", '\\'), array('"', ''', '\'), stripslashes((string) $answer)); } } if (!empty($_POST['answers_exists']) && is_array($_POST['answers_exists'])) { foreach ($_POST['answers_exists'] as $key => $answer_exist) {
function initFromDraft($draft_id, $uid) { require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/drafts.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/project_exrates.php"; $drafts = new drafts(); $this->_project = $drafts->getDraft($draft_id, $uid, 1); if (!$this->_project['id']) { return false; } if ($this->_project['logo_id'] > 0) { $this->_project['link'] = $this->_project['logo_link']; $LogoFile = new CFile($this->_project['logo_id']); $this->initLogo($LogoFile); } $cat = explode(",", $this->_project['categories']); foreach ($cat as $category) { list($cat_id, $subcat_id) = explode("|", $category); $categories[] = array('category_id' => $cat_id, 'subcategory_id' => $subcat_id); } $this->setCategories($categories); $pExrates = project_exrates::getAll(); if ($this->_project['currency'] === 0) { // USD $costRub = $this->_project['cost'] * $pExrates['24']; // бюджет в рублях } elseif ($this->_project['currency'] === 1) { // EURO $costRub = $this->_project['cost'] * $pExrates['34']; } else { // рубли $costRub = $this->_project['cost']; } $this->setCostRub($costRub); $this->_project['draft_id'] = $this->_project['id']; unset($this->_project['id']); $this->_project['user_id'] = $this->_project['uid']; $this->_project['is_pro'] = is_pro(true, $uid) ? 't' : 'f'; if ($this->_project['top_days'] > 0) { $this->setAddedTopDays($this->_project['top_days']); } if ($this->isKonkurs()) { $this->_project['end_date'] = date('d-m-Y', strtotime($this->_project['end_date'])); $this->_project['win_date'] = date('d-m-Y', strtotime($this->_project['win_date'])); } $attach = drafts::getAttachedFiles($draft_id, 4, $this->_project['uid']); if (!empty($attach)) { foreach ($attach as $file_id) { $ret[$file_id] = array('status' => 1, 'id' => $file_id); } $this->addAttachedFiles($ret, true); } return true; }
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/project_exrates.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/drafts.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/uploader/uploader.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/attachedfiles.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/country.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/city.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/employer.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/freelancer.php"; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/smtp.php'; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/projects_offers.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/guest/models/GuestMemoryModel.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/PromoCodes.php"; session_start(); $uid = get_uid(false); $drafts = new drafts(); $step = __paramInit('int', 'step', 'step', -1); $proj_id = __paramInit('int', 'public', 'public', 0); $kind = __paramInit('int', 'kind', 'kind'); $back = __paramInit('string', 'red', 'red', ''); $key = __paramInit('string', 'pk', 'pk'); $exec = __paramInit('string', 'exec', 'exec'); //Логин выбранного исполнителя в персональном проекте $hash = __paramInit('string', 'hash'); $promo = __paramInit('string', 'promo', 'promo'); $scrollToPay = __paramInit('bool', 'pay_services', 'pay_services', false); $draft_id = intval(__paramInit('int', 'draft_id', 'draft_id')); $auto_draft = intval(__paramInit('int', 'auto_draft', 'auto_draft')); if (!$key) { $key = md5(uniqid($uid)); // ключ-идентификатор создаваемого/редактируемого проекта, для хранения в кэше.
/** * Удаление черновика * * @param integer $id ID черновика * @param integer $uid ID пользователя * @param integer $type Тип черновика */ function DeleteDraft($id, $uid, $type, $delete_files = false) { global $DB; switch ($type) { case 1: // Проекты $sql = "DELETE FROM draft_projects WHERE id=?i AND uid=?i"; break; case 2: // Личка if ($delete_files) { $sql = "SELECT * FROM draft_attaches WHERE draft_id = ?i AND draft_type = 3;"; $attaches = $DB->rows($sql, $id); if ($attaches) { foreach ($attaches as $attach) { $f = new CFile($attach['file_id']); $f->Delete($f->id); } $sql = "DELETE FROM draft_attaches WHERE draft_id = ?i AND draft_type = 3;"; $DB->query($sql, $id); } } $sql = "DELETE FROM draft_contacts WHERE id=?i AND uid=?i"; break; case 3: // Блоги if ($delete_files) { $sql = "SELECT * FROM draft_attaches WHERE draft_id = ?i AND draft_type = 1;"; $attaches = $DB->rows($sql, $id); if ($attaches) { foreach ($attaches as $attach) { $f = new CFile($attach['file_id']); $f->Delete($f->id); } $sql = "DELETE FROM draft_attaches WHERE draft_id = ?i AND draft_type = 1;"; $DB->query($sql, $id); } } $sql = "DELETE FROM draft_blogs WHERE id=?i AND uid=?i"; break; case 4: // Сообщества $sql = "DELETE FROM draft_communes WHERE id=?i AND uid=?i"; break; } $DB->query($sql, $id, $uid); $_SESSION['drafts_count'] = drafts::getCount($uid); }
} switch ($p) { case 'projects': $drafts = drafts::getUserDrafts($uid, 1); $content = 'content_projects.php'; break; case 'contacts': $drafts = drafts::getUserDrafts($uid, 2); $content = 'content_contacts.php'; break; case 'blogs': require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/blogs.php'; $drafts = drafts::getUserDrafts($uid, 3); $u = new users(); $u->GetUserByUID($uid); if ($u->ban_where) { $is_ban = $u->ban_where; $ban = $u->GetBan($uid, $u->ban_where); } $content = 'content_blogs.php'; break; case 'communes': $drafts = drafts::getUserDrafts($uid, 4); $content = 'content_communes.php'; break; } $header = '../header.php'; $footer = '../footer.html'; $css_file = 'drafts.css'; $js_file = array('drafts.js'); include '../template2.php';
public static function setDataType($type) { self::$dataType = $type; }
function getTpl() { $tplName = $this->get["getTpl"]; if ($tplName == "drafts") { $contentID = 0; if (isset($_POST["contentID"]) && $_POST["contentID"]) { $contentID = intval($_POST["contentID"]); } $this->smarty->assign("lists", drafts::getDraftsLists($contentID)); } $file = TPL_PATH . "/ajax/{$tplName}.tpl"; $tplContent = "File not found"; if (file_exists($file)) { $tplContent = $this->smarty->fetch($file); } echo $tplContent; }