Ejemplo n.º 1
0
 /**
  * Обработка и оплата операций
  * 
  * @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;
 }
Ejemplo n.º 2
0
<?php

$g_page_id = "0|9";
$rpath = "../";
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/smail.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/projects_offers_answers.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/payed.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/account.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/rating.php";
session_start();
$uid = get_uid(false);
$account = new account();
$answers = new projects_offers_answers();
$op_codes = $answers->GetOpCodes();
$action = trim($_POST['action']);
if (!$action) {
    header("Location: ./");
}
$payed = new payed();
$tr_id = __paramInit('int', NULL, 'transaction_id');
$answer_pay = __paramInit('bool', NULL, 'answer_pay');
$spec_pay = __paramInit('bool', NULL, 'spec_pay');
$spec_prolong = __paramInit('bool', NULL, 'prolong_specs');
if ($spec_prolong) {
    return;
    // #0022795
    if ($err = professions::prolongSpecs($uid)) {
        $error['prolong_specs'] = $err;
    }
    $answer_pay = null;
Ejemplo n.º 3
0
$showMainDiv = true;
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/stdf.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects_offers_answers.php';
header('Location: /404.php');
exit;
session_start();
get_uid();
if (!$_SESSION['uid']) {
    header("Location: /fbd.php");
    exit;
}
if (is_emp()) {
    header("Location: /frl_only.php");
    exit;
}
$answers = new projects_offers_answers();
$action = isset($_GET['action']) ? $_GET['action'] : '';
if ($action == 'buy') {
    if (isset($_POST['back_uri'])) {
        $_SESSION['bill.GET']['back'] = $_POST['back_uri'];
    }
    $ammount = $_POST['ammount'];
    $cost = $answers->op_codes[$ammount];
    if (!($error = $answers->BuyByFM($_SESSION['uid'], $ammount))) {
        $_SESSION['answers_ammount'] = $_POST['ammount'];
        header("Location: /service/offers/offers_payed.php?answers={$ammount}&cost={$cost}");
        exit;
    }
}
$page_title = "Ответы на проекты - фриланс, удаленная работа на FL.ru";
$css_file = "projects.css";
Ejemplo n.º 4
0
 /**
  * Оплата выбранного сервиса и ответ пользователю об успехе или ошибке.
  */
 public function processRequest()
 {
     if (!$this->_isValidated) {
         $this->validate();
     }
     // Блокируем входящие запросы с данным ид., пока текущая операция не выполнится (см. self::_response())
     $mcache = new memBuff();
     $mkey = 'ifreepay.evtId' . $this->_request['evtId'];
     if ($mcache->get($mkey)) {
         $this->_errorif(TRUE, 'Предыдущий запрос в процессе обработки.');
     }
     $mcache->set($mkey, 1, 60);
     $this->_oplock = $mkey;
     $op_id = 0;
     $dup = 0;
     $profit = floatval($this->_request['profit']);
     $currency_str = trim(strtoupper($this->_request['profitCurrency']));
     // Внимание! Прежде чем менять текст описания операции, загляните в account::getSmsInfo() и sms_service::checkEvtId().
     $descr = "SMS #{$this->_request['evtId']} с номера {$this->_request['phone']} ({$this->_request['country']})" . " на номер {$this->_request['serviceNumber']}, ID абонента {$this->_request['abonentId']}," . " оператор {$this->_request['operator']}, текст: {$this->_smsDecoded}, обработан {$this->_request['now']}," . " профит {$profit} {$currency_str}," . " номер попытки: " . intval($this->_request['retry']);
     // Для обработки повторных запросов (в случае сбоев на одной из сторон).
     if (intval($this->_request['retry']) > 0) {
         $dup = sms_services::checkEvtId($this->_request['evtId'], $op_id);
     }
     switch ($this->_type) {
         case 1:
             if (!$dup && $operator != 'i-Free') {
                 $this->GetInfo($this->_user->uid);
                 $this->_errorif(!$this->id, 'Счет пользователя не открыт.');
                 $error = $this->deposit($op_id, $this->id, $this->_tariff['fm_sum'], $descr, self::PAYMENT_SYS, $this->_tariff['usd_sum'], $this->_opcode);
                 $this->_errorif(!!$error, $error);
             }
             $res_text = "Ваш счет пополнен на {$this->_tariff['fm_sum']} FM";
         case 2:
             $new_password = users::ResetPasswordSMS($this->_user->uid, $this->_request['phone']);
             $this->_errorif(!$new_password, "Неверный логин или телефон не привязан к аккаунту.");
             if (!$dup) {
                 $this->_errorif(!($tr_id = $this->start_transaction($this->_user->uid)), "Ошибка при проведении операции по счету.");
                 $this->_errorif($this->BuyFromSMS($op_id, $tr_id, $this->_opcode, $this->_user->uid, $descr, '', $this->_tariff['usd_sum'], 1, self::PAYMENT_SYS), "Ошибка при проведении денежной операции.");
             }
             $res_text = "Ваш новый пароль: {$new_password}";
         case 3:
             if (!$dup) {
                 $answers = new projects_offers_answers();
                 $this->_errorif(!$answers->AddPayAnswers($this->_user->uid, 1), "Ошибка добавления ответа.");
                 $this->_errorif(!($tr_id = $this->start_transaction($this->_user->uid)), "Ошибка при проведении операции по счету.");
                 $this->_errorif($this->BuyFromSMS($op_id, $tr_id, $this->_opcode, $this->_user->uid, $descr, '', $this->_tariff['usd_sum'], 1, self::PAYMENT_SYS), "Ошибка при проведении денежной операции.");
             }
             $res_text = 'Спасибо за покупку. Теперь вы можете ответить на проект.';
         default:
             $this->_errorif(true, "Тип услуги не найден.");
     }
     if (!$dup || $dup == sms_services::DUP_OP_NOTSAVED) {
         $sms_opid = sms_services::saveEvtId($op_id, $profit, $currency_str, $this->_request['evtId']);
     }
     $this->_response($res_text);
 }
Ejemplo n.º 5
0
 /**
  * Блокирует проект
  *
  * @param integer $project_id  id проекта
  * @param string  $reason      причина
  * @param string  $reason_id   id причины, если она выбрана из списка
  * @param integer $uid         uid администратора (если 0, используется $_SESSION['uid'])
  * @param boolean $from_stream true - блокировка из потока, false - на сайте
  * @return int                ID блокировки
  */
 function Blocked($project_id, $reason, $reason_id = null, $uid = 0, $from_stream = false)
 {
     global $DB;
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/messages.php';
     if (!$uid && !($uid = $_SESSION['uid'])) {
         return 'Недостаточно прав';
     }
     if (!$from_stream) {
         $this->cancelModeration($project_id);
         $DB->query('UPDATE projects SET moderator_status = ?i WHERE id = ?i', $uid, $project_id);
     }
     $sql = "INSERT INTO projects_blocked (project_id, \"admin\", reason, reason_id, blocked_time) VALUES(?i, ?i, ?, ?, NOW()) RETURNING id";
     $sId = $DB->val($sql, $project_id, $uid, $reason, $reason_id);
     if (!$from_stream) {
         messages::SendBlockedProject($project_id, $reason);
     }
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects_offers_answers.php';
     $off = new projects_offers_answers();
     $off->ReturnAnswers($project_id);
     return $sId;
 }
Ejemplo n.º 6
0
 */
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/freelancer.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/projects_offers_answers.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/op_codes.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/rating.php";
if ($uid) {
    $op_codes = new op_codes();
    $opcodes = $op_codes->getCodes('80,16,65');
    if ($paid_specs = professions::getPaidSpecs($uid)) {
        $paid_spec_cnt = count($paid_specs);
    }
    $free_spec_cnt = is_pro() ? 5 : 1;
    $spec_cnt = $paid_spec_cnt + $free_spec_cnt;
    $paid_spec_price = $opcodes[professions::OP_PAID_SPEC]['sum'] * $paid_spec_cnt;
    $poa = new projects_offers_answers();
    $poa->GetInfo($uid);
    $poa_codes = $poa->GetOpCodes();
    $user = new freelancer();
    // Изменяем авто продление PRO, если нужно
    if (strtolower($_GET['pro_auto_prolong']) == 'on') {
        $user->setPROAutoProlong('on', $uid);
    }
    if (strtolower($_GET['pro_auto_prolong']) == 'off') {
        $user->setPROAutoProlong('off', $uid);
    }
    $user->GetUser($_SESSION['login']);
    require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/account.php";
    $account = new account();
    $ok = $account->GetInfo($uid, true);
    $u_is_pro_auto_prolong = $user->GetField($uid, $e, 'is_pro_auto_prolong', false);
Ejemplo n.º 7
0
                        <li class="b-menu__item <?php 
echo $kind == 2 || $kind == 7 ? 'b-menu__item_active' : '';
?>
" <?php 
echo $kind == 2 || $kind == 7 ? 'data-menu-opener="true" data-menu-descriptor="nav"' : '';
?>
><a class="b-menu__link" href="/konkurs/">Конкурсы</a></li>
                </ul>
            </div><!-- b-menu_tabs -->
            
    </div><!--b-page__filter-->
    <?php 
// блок ответов на проекты
if (get_uid(0) && !is_emp() && !is_pro()) {
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects_offers_answers.php';
    $user_answers = new projects_offers_answers();
    $user_answers->GetInfo($_SESSION['uid']);
    $free_answers = $user_answers->free_offers;
    $op_codes = $user_answers->GetOpCodes();
    $is_block_pro = true;
    include TPL_ANSWERS_DIR . '/tpl.answers-item.php';
}
?>
<!--<div class="b-page__lenta <?php 
echo $cls;
?>
">-->
    <div class="b-page__lenta ">
        <?php 
if ($kind == 8) {
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/freelancer_offers.php';
Ejemplo n.º 8
0
 if ($project['user_id'] && $usr->GetField($project['user_id'], $ban_error, 'is_banned') > 0 && !hasPermissions('projects')) {
     include ABS_PATH . '/404.php';
     exit;
 }
 //Если не участник персонального проекта
 if ($project['kind'] == 9 && (!$uid || !(hasPermissions('projects') || $project['user_id'] == $uid || $project['exec_id'] == $uid || projects_offers::IsPrjOfferExists($project['id'], get_uid(false))))) {
     include ABS_PATH . '/404.php';
     exit;
 }
 //404 если проект заблокирован
 if ($project['is_blocked'] && $_SESSION['uid'] != $project['user_id'] && !hasPermissions('projects')) {
     include ABS_PATH . '/prj_blocked.php';
     exit;
 }
 // Платные ответы
 $answers = new projects_offers_answers();
 $answers->GetInfo($uid);
 $pr_emp = is_emp($project['role']);
 require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/stop_words.php';
 $stop_words = new stop_words(hasPermissions('projects'));
 $title = $project['moderator_status'] === '0' && $project['kind'] != 4 && $project['is_pro'] != 't' ? $stop_words->replace($project['name'], 'plain', false) : $project['name'];
 $sTitle = htmlspecialchars($title, ENT_QUOTES, 'CP1251', false);
 if ($project['cost'] != 0) {
     switch ($project['priceby']) {
         case '1':
             $priceby_str = '/час';
             break;
         case '2':
             $priceby_str = '/день';
             break;
         case '3':
 private function setAnswers()
 {
     global $DB;
     $uid = (int) $_POST['uid'];
     $amount = (int) $_POST['amount'];
     if ($amount != 1 && $amount != 5 && $amount != 10) {
         $this->jsonError('Некорректное значение количества FM');
     }
     $role = $DB->val("SELECT role FROM users WHERE uid = {$uid}");
     $role = $role[0];
     if ($role === '0') {
         $answers = new projects_offers_answers();
         $error = $answers->BuyByFM($uid, $amount);
         if ($error === 0) {
             $this->jsonOk();
         } else {
             $this->jsonError($error ? $error : 'Произошла неизвестная ошибка');
         }
     } else {
         $this->jsonError('Пользователь не найден или является работодателем');
     }
 }