function __construct() { if ($this->getParamsObject()) { $params = $this->getParamsObject(); $this->setVar('params', $params); $this->_commentsPerPage = $params->commentsPerPage; $this->_onlyRegistered = $params->onlyRegistered; $this->_premoderation = $params->premoderation; $this->_showComments = $params->_get('showComments', $params->showComments); $user = $this->getCurrentUser(); $allowComments = $params->onlyRegistered && empty($this->getCurrentUser()->u_id) ? false : true; $this->setVar('allowComments', $allowComments); $this->setVar('premoderation', $this->_premoderation); } $this->setVar('user', $this->getCurrentUser()); /* Add a new comment */ $action = $this->request('action'); if ($allowComments && $action == 'comment_add') { if (empty($this->getCurrentUser()->u_id)) { $captcha = new model_coresession_captcha('product'); if ($captcha->check($this->request('captcha'))) { $this->addComment(); } else { $this->setVar('message', $this->lang('wrongcaptcha.session.error')); //die($this->lang('wrongcaptcha.session.error')); die('captcha'); } } else { $this->addComment(); } } $this->setVar('action', $this->request('action')); $this->setVar('curr', model_corecatalog_currcalc::$_curcours); $this->assignProduct(); $this->assignParams(); }
protected function checkCapcha() { if (!$this->request('fromSA')) { $modelCaptcha = rad_instances::get('model_coresession_captcha'); } else { $modelCaptcha = $modelCaptcha = new model_coresession_captcha($this->request('fromSA')); } return $modelCaptcha->check(trim($this->request('captcha_fld', $this->request('capcha_fld')))); }
/** * Final order! * return HTML to AJAX */ function order() { $isNewUser = false; $item = new struct_corecatalog_orders(); $item->order_userid = ($user = $this->getCurrentUser()) ? $user->u_id : 0; if ($this->_showCaptcha or $this->_OrderScheme[self::ORDER_REG]) { $captcha = new model_coresession_captcha(SITE_ALIAS); if (!$captcha->check($this->request('captcha_text'))) { $this->setVar('message', $this->lang('wrongcaptcha.session.error')); $this->startPage(); $this->setVar('wrong_capcha', true); return; } } $item->order_address = $this->request('address', ''); $item->order_comments = $this->request('order_comment'); $item->order_email = $this->getCurrentUser()->u_email ?: $this->request('email'); $item->order_fio = $this->request('fio'); $item->order_phone = $this->request('contact_phone'); $item->order_langid = $this->getCurrentLangID(); if ($this->request('delivery')) { $item->order_delivery = (int) $this->request('delivery'); } if ($item->order_userid === 0) { //type of the order - 3 is the quick order $item->order_type = 3; $isNewUser = true; } else { if ($this->_OrderScheme[self::ORDER_FAST_REG]) { //type of the order - 2 is the quick & registration $item->order_type = 2; } else { //type of the order - 1 is the registration $item->order_type = 1; } } $item->order_dt = now(); $item->order_num = date("ymdHis"); $item->order_num .= $this->getCurrentUser() ? 'u' . $this->getCurrentUser()->u_id : 's'; $item->order_sessid = $this->getCurrentSessID(); //Link to the tree_id $item->order_status = $this->_defStatus; //calc the order summ $model_bin = rad_instances::get('model_corecatalog_bin'); $ct_showing = $this->getParamsObject() ? $this->getParamsObject()->ct_showing : NULL; $items = $model_bin->getCartProducts(NULL, NULL, $ct_showing); $bin_pos = $model_bin->getItemsCart(); $counts = array(); $bin_ids = array(); $total_count = 0; $total_costs = 0; if (count($bin_pos)) { foreach ($bin_pos as $id) { $counts[$id->bp_catid] = $id->bp_count; $bin_ids[$id->bp_catid] = $id->bp_id; } } for ($i = 0; $i < count($items); $i++) { $items[$i]->cat_cost = model_corecatalog_currcalc::calcCours($items[$i]->cat_cost, $items[$i]->cat_currency_id); $items[$i]->cat_count = $counts[$items[$i]->cat_id]; $total_count += $items[$i]->cat_count; $total_costs += $items[$i]->cat_cost * $items[$i]->cat_count; $items[$i]->bp_id = $bin_ids[$items[$i]->cat_id]; } if ($this->_showDelivery and $this->request('delivery')) { $delivery = new struct_corecatalog_delivery(array('rdl_id' => (int) $this->request('delivery'))); $delivery->load(); $totalCostsWithoutDelivery = $total_costs; $total_costs += model_corecatalog_currcalc::calcCours($delivery->rdl_cost, $delivery->rdl_currency); $item->delivery = $delivery; } $item->order_summ = $total_costs; $item->order_currency = model_corecatalog_currcalc::$_curcours->cur_ind; $item->order_curid = model_corecatalog_currcalc::$_curcours->cur_id; if ($isNewUser && $this->_addtoclients) { //try, maybe user already exists $modelUsers = rad_instances::get('model_core_users'); $exUser = $modelUsers->setState('u_email', $item->order_email)->getItem(); if (!empty($exUser->u_id)) { $item->order_userid = (int) $exUser->u_id; $isNewUser = false; } else { $user = new struct_core_users(array('u_group' => $this->_clientsPID, 'u_login' => $item->order_email, 'u_email' => $item->order_email, 'u_fio' => $item->order_fio, 'u_phone' => $item->order_phone, 'u_address' => $item->order_address, 'u_isadmin' => 0)); $modelUsers->register($user, $this->config('registration.class') != 'registerphpbb'); $item->order_userid = $user->u_id; } } $model = rad_instances::get('model_corecatalog_order'); if ($rows = $model->insertItem($item)) { $item->order_id = $rows; $item->order_num .= $item->order_id; $item->save(); rad_instances::get('model_corecatalog_bin')->clearItemsCart(); /*assign to the referals*/ if ($this->config('referals.on') and class_exists('struct_coresession_referals_orders')) { //TODO Учесть что пользователь до этого уже приведен был другим партнером и взять с user_id if ($this->cookie($this->config('referals.cookieName')) or !empty($item->order_userid)) { if ($item->order_userid !== 0) { $refUser = rad_instances::get('model_coresession_referals')->getUserPartner($item->order_userid); } if (!empty($refUser->u_id)) { $referalId = $refUser->rru_referal_id; } elseif ($referal = rad_instances::get('model_coresession_referals')->setState('cookie', $this->cookie($this->config('referals.cookieName')))->getItem()) { $referalId = $referal->rrf_id; } if (!empty($referalId)) { $percent = rad_instances::get('model_coresession_referals')->getParntnerPercent($referalId); $orderSum = isset($totalCostsWithoutDelivery) ? $totalCostsWithoutDelivery : $item->order_summ; $refOfder = new struct_coresession_referals_orders(array('rro_referals_id' => $referalId, 'rro_order_id' => $item->order_id, 'rro_percent' => $percent, 'rro_currency_id' => $item->order_curid, 'rro_order_sum' => $orderSum)); rad_instances::get('model_coresession_referals')->insertOrder($refOfder); } } } } $item->order_positions = $bin_pos; if ($isNewUser) { $this->_sendMail($item, 'order_new'); } else { $this->_sendMail($item, 'order_new_auth'); } $this->redirect($this->makeURL('action=success')); }
/** * При попытке зарегистрироваться, проверяются данные и шлётся мыло */ protected function tryRegister() { $item = $this->_verifyInputData($this->getCurrentUser()); if ($this->request('change')) { $this->setVar('change', true); } if ($item) { $this->setVar('item', $item); $modelCaptcha = new model_coresession_captcha(SITE_ALIAS); if (!$modelCaptcha->check(trim($this->request('captcha')))) { $this->setVar('captcha_error', $this->lang('wrongcaptcha.session.error')); $this->setVar('action'); } else { $model = rad_instances::get('model_core_users'); $model->setState('u_email', $item->u_email)->setState('u_active', 1); $tmp = $model->getItems(1); if (!empty($tmp[0]->u_id)) { if ($this->request('change') and $tmp[0]->u_active) { $model->updateItem($item); rad_session::setUser($item); $this->setVar('item', $item); $this->setVar('message', $this->lang('yourdatesuccupdated.session.message')); } elseif ($tmp[0]->u_active and $tmp[0]->u_email_confirmed) { //RESEND EMAIL $this->setVar('message', $this->lang($this->config('registration.mail_already_registred_text'))); } else { $this->sendActivationCode($item); $this->setVar('message', $this->lang($this->config('registration.mail_regsended_text'))); $this->setVar('onlymessage', true); } } else { //REGISTER! $item->u_group = $this->_treestart; $this->register($item); $this->redirect($this->makeURL('a=success')); } } } else { $this->setVar('item', new struct_core_users($this->getAllRequest())); } }
protected function showCaptcha() { $model = new model_coresession_captcha($this->request('page')); $model->show(); }
/** * Проверка полей */ function validator() { $rs = false; if ($this->request('sender_email') and $this->request('sender_fio') and $this->request('message_body')) { $modelCaptcha = new model_coresession_captcha(SITE_ALIAS); if (!php_mail_check($this->request('sender_email'))) { $this->setVar('error_message', $this->lang('entervalidemail.feedback.error', null, true)); $rs = false; } elseif (mb_strlen($this->request('message_body')) < 3) { $this->setVar('error_message', $this->lang('entercorrectbody.feedback.error', null, true)); $rs = false; } elseif (!$modelCaptcha->check($this->request('captcha_text'))) { $this->setVar('error_message', $this->lang('wrongcaptcha.session.error', null, true)); $rs = false; } else { $rs = true; } } elseif ($this->request('phone') and $this->request('sender_fio') and $this->request('captcha_text')) { $modelCaptcha = new model_coresession_captcha('index.html'); $jsonResult = array(); if (mb_strlen($this->request('sender_fio')) < 3) { $jsonResult['error_message'] = $this->lang('entercorrectfio.feedback.error', null, true); $this->setVar('error_message', json_encode($jsonResult)); $rs = false; } elseif (!preg_match('/^[+]7[(]\\d{3}[)]\\d{3}-\\d{2}-\\d{2}$/', $this->request('phone'))) { $jsonResult['error_message'] = $this->lang('entercorrectphone.callback.error'); $this->setVar('error_message', json_encode($jsonResult)); $rs = false; } elseif (!$modelCaptcha->check($this->request('captcha_text'))) { $jsonResult['error_message'] = $this->lang('wrongcaptcha.session.error', null, true); $this->setVar('error_message', json_encode($jsonResult)); $rs = false; } else { $rs = true; $res = array(); $res['error_message'] = 'error_none'; $this->setVar('error_message', json_encode($res)); } } else { $jsonResult['error_message'] = "error_occurred"; $this->setVar('error_message', json_encode($jsonResult)); $rs = false; } return $rs; }