/** * <p>Удаляет указанный <a href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#event_type">тип события</a>, вместе со всеми событиями данного типа.</p> * * * @param int $type_id ID типа события. * * @return bool <p>Метод возвращает "true" в случае успешного удаления типа события, * либо "false" в противном случае.</p> * * <h4>Example</h4> * <pre> * <? * $type_id = 1; * if (<b>CStatEventType::Delete</b>($type_id)) * echo "Тип события #".$type_id." успешно удалено."; * ?> * </pre> * * * <h4>See Also</h4> * <ul><li> <a href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#event_type">Термин "Тип * события"</a> </li></ul> </ht<a name="examples"></a> * * * @static * @link http://dev.1c-bitrix.ru/api_help/statistic/classes/cstateventtype/delete.php * @author Bitrix */ public static function Delete($ID, $DELETE_EVENT = "Y") { $err_mess = "File: " . __FILE__ . "<br>Line: "; $DB = CDatabase::GetModuleConnection('statistic'); $ID = intval($ID); $strSql = "SELECT ID FROM b_stat_event_list WHERE EVENT_ID='{$ID}'"; $a = $DB->Query($strSql, false, $err_mess . __LINE__); while ($ar = $a->Fetch()) { CStatEvent::Delete($ar["ID"]); } $DB->Query("DELETE FROM b_stat_event_day WHERE EVENT_ID='{$ID}'", false, $err_mess . __LINE__); if ($DELETE_EVENT == "Y") { $DB->Query("DELETE FROM b_stat_event WHERE ID='{$ID}'", false, $err_mess . __LINE__); return true; } else { $DB->Query("UPDATE b_stat_event SET DATE_ENTER=null WHERE ID='{$ID}'", false, $err_mess . __LINE__); return true; } return false; }
function SetEvent($RESULT_ID, $IN_EVENT1 = false, $IN_EVENT2 = false, $IN_EVENT3 = false, $money = "", $currency = "", $goto = "", $chargeback = "N") { $err_mess = CAllFormResult::err_mess() . "<br>Function: SetEvent<br>Line: "; global $DB, $strError; if (CModule::IncludeModule("statistic")) { $RESULT_ID = intval($RESULT_ID); $strSql = "SELECT FORM_ID FROM b_form_result WHERE ID='" . $RESULT_ID . "'"; $z = $DB->Query($strSql, false, $err_mess . __LINE__); if ($zr = $z->Fetch()) { $WEB_FORM_ID = $zr["FORM_ID"]; $strSql = "SELECT SID, STAT_EVENT1, STAT_EVENT2, STAT_EVENT3 FROM b_form WHERE ID = '" . $WEB_FORM_ID . "'"; $z = $DB->Query($strSql, false, $err_mess . __LINE__); $zr = $z->Fetch(); if ($IN_EVENT1 === false) { $event1 = strlen($zr["STAT_EVENT1"]) <= 0 ? "form" : $zr["STAT_EVENT1"]; } else { $event1 = $IN_EVENT1; } if ($IN_EVENT2 === false) { $event2 = strlen($zr["STAT_EVENT2"]) <= 0 ? $zr["SID"] : $zr["STAT_EVENT2"]; } else { $event2 = $IN_EVENT2; } if ($IN_EVENT3 === false) { $event3 = strlen($zr["STAT_EVENT3"]) <= 0 ? ($GLOBALS['APPLICATION']->IsHTTPS() ? "https://" : "http://") . $_SERVER["HTTP_HOST"] . "/bitrix/admin/form_result_list.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID=" . $WEB_FORM_ID . "&find_id=" . $RESULT_ID . "&find_id_exact_match=Y&set_filter=Y" : $zr["STAT_EVENT3"]; } else { $event3 = $IN_EVENT3; } CStatEvent::AddCurrent($event1, $event2, $event3, $money, $currency, $goto, $chargeback); return true; } else { $strError .= GetMessage("FORM_ERROR_RESULT_NOT_FOUND") . "<br>"; } } return false; }
function Set($arFields, &$MID, $id = "", $checkRights = "Y", $sendEmailToAuthor = "Y", $sendEmailToTechsupport = "Y") { global $DB, $APPLICATION, $USER; $err_mess = CAllTicket::err_mess() . "<br>Function: Set<br>Line: "; $v0 = self::Set_InitVar($arFields, $id, $checkRights, $sendEmailToAuthor, $sendEmailToTechsupport); if (!is_array($v0)) { return $v0; } $v = $v0["v"]; /* isNew, CHECK_RIGHTS, SEND_EMAIL_TO_AUTHOR, SEND_EMAIL_TO_TECHSUPPORT, bAdmin, bSupportTeam, bSupportClient, bDemo, bOwner, uid, bActiveCoupon, IsSpam */ /** @var CSupportTableFields $f */ $f = $v0["f"]; /* ID, SITE_ID, MODIFIED_GUEST_ID, OWNER_USER_ID, OWNER_SID, HOLD_ON, IS_SPAM */ // если модифицируем обращение то if (!$v->isNew) { unset($arFields['COUPON']); $arFields['ID'] = $f->ID; $arFields = CTicket::ExecuteEvents('OnBeforeTicketUpdate', $arFields, false); $v->closeDate = isset($arFields["CLOSE"]) && $arFields["CLOSE"] == "Y"; //$close // запоминаем предыдущие важные значения $v->arrOldFields = array(); $arr = array("TITLE" => "T.TITLE", "RESPONSIBLE_USER_ID" => "T.RESPONSIBLE_USER_ID", "SLA_ID" => "T.SLA_ID", "CATEGORY_ID" => "T.CATEGORY_ID", "CRITICALITY_ID" => "T.CRITICALITY_ID", "STATUS_ID" => "T.STATUS_ID", "MARK_ID" => "T.MARK_ID", "DIFFICULTY_ID" => "T.DIFFICULTY_ID", "DATE_CLOSE" => "T.DATE_CLOSE", "HOLD_ON" => "T.HOLD_ON", "RESPONSE_TIME" => "S.RESPONSE_TIME", "RESPONSE_TIME_UNIT" => "S.RESPONSE_TIME_UNIT"); $str = "T.ID"; foreach ($arr as $s) { $str .= "," . $s; } $strSql = "SELECT " . $str . ", SITE_ID FROM b_ticket T LEFT JOIN b_ticket_sla S ON T.SLA_ID = S.ID WHERE T.ID='" . $f->ID . "'"; $z = $DB->Query($strSql, false, $err_mess . __LINE__); if ($zr = $z->Fetch()) { $f->SITE_ID = $zr["SITE_ID"]; if (intval($v->uid) == $zr["RESPONSIBLE_USER_ID"]) { $v->bSupportTeam = "Y"; } foreach ($arr as $key => $s) { $v->arrOldFields[$key] = $zr[$key]; } } $f->FromArray($arFields, "SITE_ID,MODIFIED_MODULE_NAME,SLA_ID,SOURCE_ID", array(CSupportTableFields::MORE0, CSupportTableFields::NOT_EMTY_STR)); if (!$f->MODIFIED_MODULE_NAME) { $f->MODIFIED_MODULE_NAME = ''; } $f->FromArray($arFields, "CATEGORY_ID,RESPONSIBLE_USER_ID,STATUS_ID,DIFFICULTY_ID,CRITICALITY_ID,SUPPORT_COMMENTS"); if (isset($arFields['CHANGE_TITLE'])) { $f->set('TITLE', $arFields['CHANGE_TITLE']); } $f->set("MODIFIED_USER_ID", $v->uid, array(CSupportTableFields::MORE0)); $f->setCurrentTime("TIMESTAMP_X"); if ($v->closeDate) { $f->setCurrentTime("DATE_CLOSE"); } // ?remake? { $v->IS_GROUP_USER = '******'; if ($v->bAdmin) { $IS_GROUP_USER = '******'; } elseif ($v->CHECK_RIGHTS == 'Y' && ($v->bSupportClient || $v->bSupportTeam)) { if ($v->bSupportTeam) { $join_query = '(T.RESPONSIBLE_USER_ID IS NOT NULL AND T.RESPONSIBLE_USER_ID=O.USER_ID)'; } else { $join_query = '(T.OWNER_USER_ID IS NOT NULL AND T.OWNER_USER_ID=O.USER_ID)'; } $strSql = "SELECT 'x'\n\t\t\t\tFROM b_ticket T\n\t\t\t\tINNER JOIN b_ticket_user_ugroup O ON {$join_query}\n\t\t\t\tINNER JOIN b_ticket_user_ugroup C ON (O.GROUP_ID=C.GROUP_ID)\n\t\t\t\tINNER JOIN b_ticket_ugroups G ON (O.GROUP_ID=G.ID)\n\t\t\t\tWHERE T.ID='" . $f->ID . "' AND C.USER_ID='" . $v->uid . "' AND C.CAN_VIEW_GROUP_MESSAGES='Y' AND G.IS_TEAM_GROUP='" . ($v->bSupportTeam ? "Y" : "N") . "'"; $z = $DB->Query($strSql); if ($zr = $z->Fetch()) { $v->IS_GROUP_USER = '******'; } } // } if (isset($arFields["AUTO_CLOSE_DAYS"]) && intval($arFields["AUTO_CLOSE_DAYS"]) >= 0) { if (intval($arFields["AUTO_CLOSE_DAYS"]) == 0) { // get from module settings $f->AUTO_CLOSE_DAYS = COption::GetOptionString('support', "DEFAULT_AUTO_CLOSE_DAYS"); } else { $f->AUTO_CLOSE_DAYS = $arFields["AUTO_CLOSE_DAYS"]; } } if (is_array($v->arrOldFields) && is_array($arFields) && $arFields["CLOSE"] == "N" && strlen($v->arrOldFields["DATE_CLOSE"]) > 0) { $f->DATE_CLOSE = null; $f->REOPEN = "Y"; } // Если есть что и мы Аднины или из группы ТП, запишем в базу $v->FirstUpdateRes = false; if ($v->bSupportTeam || $v->bAdmin) { $arFields_i = $f->ToArray(CSupportTableFields::ALL, array(CSupportTableFields::ONLY_CHANGED), true); if ($v->CHECK_RIGHTS == "N" && isset($arFields["MARK_ID"]) && intval($arFields["MARK_ID"]) > 0) { $arFields_i["MARK_ID"] = intval($arFields["MARK_ID"]); } if (count($arFields_i) > 0) { $v->SupportTeamUpdateRes = $DB->Update("b_ticket", $arFields_i, "WHERE ID='" . $f->ID . "'", $err_mess . __LINE__); //$rows1 $GLOBALS["USER_FIELD_MANAGER"]->Update("SUPPORT", $f->ID, $arFields); // если указана отметка о спаме то установим отметку о спаме if (strlen($f->IS_SPAM) > 0) { CTicket::MarkAsSpam($f->ID, $f->IS_SPAM, $v->CHECK_RIGHTS); } $v->newSLA = isset($arFields_i["SLA_ID"]) && $v->arrOldFields["SLA_ID"] != $arFields_i["SLA_ID"]; } } elseif ($v->bOwner || $v->bSupportClient) { $arFields_i = $f->ToArray("TIMESTAMP_X,DATE_CLOSE,CRITICALITY_ID,MODIFIED_USER_ID,MODIFIED_GUEST_ID,MODIFIED_MODULE_NAME,REOPEN", array(CSupportTableFields::ONLY_CHANGED), true); $arFields_i["MARK_ID"] = intval($arFields["MARK_ID"]); if (count($arFields_i) > 0) { $v->SupportClientUpdateRes = $DB->Update("b_ticket", $arFields_i, "WHERE ID='" . $f->ID . "' AND (OWNER_USER_ID='" . $v->uid . "' OR CREATED_USER_ID='" . $v->uid . "' OR '" . $v->CHECK_RIGHTS . "'='N' OR '" . $v->IS_GROUP_USER . "'='Y')", $err_mess . __LINE__); $GLOBALS["USER_FIELD_MANAGER"]->Update("SUPPORT", $f->ID, $arFields); } } // поля для записи лога /*$arFields_log = array( "LOG" => "Y", "MESSAGE_CREATED_USER_ID" => $MODIFIED_USER_ID, "MESSAGE_CREATED_MODULE_NAME" => $MODIFIED_MODULE_NAME, "MESSAGE_CREATED_GUEST_ID" => $MODIFIED_GUEST_ID, "MESSAGE_SOURCE_ID" => intval($arFields["SOURCE_ID"]) );*/ $v->arFields_log = array("LOG" => "Y", "MESSAGE_CREATED_USER_ID" => $f->MODIFIED_USER_ID, "MESSAGE_CREATED_MODULE_NAME" => $f->MODIFIED_MODULE_NAME, "MESSAGE_CREATED_GUEST_ID" => $f->MODIFIED_GUEST_ID, "MESSAGE_SOURCE_ID" => $f->SOURCE_ID); // если необходимо соблюдать права то if ($v->CHECK_RIGHTS == "Y") { // если update техподдержки не прошел то if (intval($v->SupportTeamUpdateRes) <= 0) { // убираем из массива исходных значений то что может менять только техподдержка unset($v->arrOldFields["RESPONSIBLE_USER_ID"]); unset($v->arrOldFields["SLA_ID"]); unset($v->arrOldFields["CATEGORY_ID"]); unset($v->arrOldFields["DIFFICULTY_ID"]); unset($v->arrOldFields["STATUS_ID"]); } // если update автора не прошел то if (intval($v->SupportClientUpdateRes) <= 0) { // убираем из массива исходных значений то что может менять только автор unset($v->arrOldFields["MARK_ID"]); } } // если состоялся один из updat'ов то if (intval($v->SupportTeamUpdateRes) > 0 || intval($v->SupportClientUpdateRes) > 0) { // добавляем сообщение $arFields["MESSAGE_CREATED_MODULE_NAME"] = $arFields["MODIFIED_MODULE_NAME"]; if (is_set($arFields, "IMAGE")) { $arFields["FILES"][] = $arFields["IMAGE"]; } $arFiles = null; $MID = CTicket::AddMessage($f->ID, $arFields, $arFiles, $v->CHECK_RIGHTS); $v->arrFILES = $arFiles; $MID = intval($MID); $dateType = array(); $dateType["EVENT"] = array(CTicket::UPDATE); if ($v->newSLA) { $dateType["EVENT"][] = CTicket::NEW_SLA; $dateType["OLD_SLA_RESPONSE_TIME"] = $v->arrOldFields["RESPONSE_TIME"]; $dateType["OLD_SLA_RESPONSE_TIME_UNIT"] = $v->arrOldFields["RESPONSE_TIME_UNIT"]; } if ($f->REOPEN == "Y") { $dateType["EVENT"][] = CTicket::REOPEN; } //CTicket::UpdateLastParams2($f->ID, $dateType); CTicket::UpdateLastParamsN($f->ID, $dateType, true, true); /*// если обращение закрывали то if($v->closeDate) { // удалим агентов-напоминальщиков и обновим параметры обращения CTicketReminder::Remove($f->ID); }*/ if (is_array($v->arrOldFields) && is_array($arFields)) { // определяем что изменилось $v->arChange = array(); if ($MID > 0) { if ($arFields["HIDDEN"] != "Y") { $v->arChange["MESSAGE"] = "Y"; } else { $v->arChange["HIDDEN_MESSAGE"] = "Y"; } } if ($arFields["CLOSE"] == "Y" && strlen($v->arrOldFields["DATE_CLOSE"]) <= 0) { $v->arChange["CLOSE"] = "Y"; } elseif ($arFields["CLOSE"] == "N" && strlen($v->arrOldFields["DATE_CLOSE"]) > 0) { $v->arChange["OPEN"] = "Y"; } if (array_key_exists("HOLD_ON", $arFields)) { if ($v->arrOldFields["HOLD_ON"] == null) { $v->arrOldFields["HOLD_ON"] = 'N'; } if ($arFields["HOLD_ON"] == null) { $arFields["HOLD_ON"] = 'N'; } if ($v->arrOldFields["HOLD_ON"] != $arFields["HOLD_ON"]) { if ($arFields["HOLD_ON"] == "Y") { $v->arChange["HOLD_ON_ON"] = "Y"; } else { $v->arChange["HOLD_ON_OFF"] = "Y"; } } unset($v->arrOldFields["HOLD_ON"]); } foreach ($v->arrOldFields as $key => $value) { if (isset($arFields[$key])) { if ($key === 'TITLE' && $value !== $arFields[$key]) { $v->arChange[$key] = "Y"; } elseif (intval($value) != intval($arFields[$key])) { $v->arChange[$key] = "Y"; } } } // получим текущие значения обращения CTimeZone::Disable(); $z = CTicket::GetByID($f->ID, $f->SITE_ID, "N"); CTimeZone::Enable(); if ($zr = $z->Fetch()) { $nf = (object) $zr; $rsSite = CSite::GetByID($nf->SITE_ID); $v->arrSite = $rsSite->Fetch(); self::Set_sendMails($nf, $v, $arFields); //if ($v->arChange['SLA_ID'] == 'Y' || $v->arChange['OPEN'] == 'Y') CTicketReminder::Update($nf->ID, true); } } CTicket::ExecuteEvents('OnAfterTicketUpdate', $arFields, false); } } else { // restrict to set SLA_ID directly, allow through events or automatically if (isset($arFields['SLA_ID']) && !($v->bSupportTeam || $v->bAdmin || $v->bDemo || $v->bActiveCoupon)) { unset($arFields['SLA_ID']); } $arFields = CTicket::ExecuteEvents('OnBeforeTicketAdd', $arFields, false); if (!$arFields) { return false; } if (!((strlen(trim($arFields["OWNER_SID"])) > 0 || intval($arFields["OWNER_USER_ID"]) > 0) && ($v->bSupportTeam || $v->bAdmin))) { $f->OWNER_USER_ID = $v->uid > 0 ? $v->uid : null; $f->OWNER_SID = null; $f->OWNER_GUEST_ID = intval($_SESSION["SESS_GUEST_ID"]) > 0 ? intval($_SESSION["SESS_GUEST_ID"]) : null; } $f->FromArray($arFields, "CREATED_USER_ID,CREATED_MODULE_NAME,CATEGORY_ID,STATUS_ID,DIFFICULTY_ID,CRITICALITY_ID,SOURCE_ID,TITLE", array(CSupportTableFields::MORE0, CSupportTableFields::NOT_EMTY_STR)); if (!$f->CREATED_USER_ID) { $f->set("CREATED_USER_ID", $v->uid, array(CSupportTableFields::MORE0)); } $f->setCurrentTime("LAST_MESSAGE_DATE,DAY_CREATE,TIMESTAMP_X,DEADLINE_SOURCE_DATE"); $f->DATE_CREATE = time() + CTimeZone::GetOffset(); // если обращение создается сотрудником техподдержки, администратором или демо пользователем if ($v->bSupportTeam || $v->bAdmin || $v->Demo) { $f->FromArray($arFields, "SUPPORT_COMMENTS", array(CSupportTableFields::NOT_EMTY_STR)); } if (!self::Set_getCOUPONandSLA($v, $f, $arFields)) { return false; } // $f +SLA_ID $v +V_COUPON +bActiveCoupon if ($v->bActiveCoupon) { $f->COUPON = $v->V_COUPON; } self::Set_getResponsibleUser($v, $f, $arFields); // $f +RESPONSIBLE_USER_ID $v +T_EVENT1 +T_EVENT2 +T_EVENT3 // поля для записи лога $v->arFields_log = array("LOG" => "Y", "MESSAGE_CREATED_USER_ID" => $f->CREATED_USER_ID, "MESSAGE_CREATED_MODULE_NAME" => $f->CREATED_MODULE_NAME, "MESSAGE_CREATED_GUEST_ID" => $f->MODIFIED_GUEST_ID, "MESSAGE_SOURCE_ID" => $f->SOURCE_ID); $acd0 = intval(COption::GetOptionString("support", "DEFAULT_AUTO_CLOSE_DAYS")); $f->AUTO_CLOSE_DAYS = $acd0 <= 0 ? 7 : $acd0; $arFields["AUTO_CLOSE_DAYS"] = $f->AUTO_CLOSE_DAYS; $arFields_i = $f->ToArray(CSupportTableFields::ALL, array(CSupportTableFields::NOT_NULL, CSupportTableFields::NOT_DEFAULT), true); $id = $DB->Insert("b_ticket", $arFields_i, $err_mess . __LINE__); if (!($id > 0)) { return $id; } $f->ID = $id; $GLOBALS["USER_FIELD_MANAGER"]->Update("SUPPORT", $f->ID, $arFields); $arFields["MESSAGE_AUTHOR_SID"] = $f->OWNER_SID; $arFields["MESSAGE_AUTHOR_USER_ID"] = $f->OWNER_USER_ID; $arFields["MESSAGE_CREATED_MODULE_NAME"] = $f->CREATED_MODULE_NAME; $arFields["MESSAGE_SOURCE_ID"] = $f->SOURCE_ID; $arFields["HIDDEN"] = "N"; $arFields["LOG"] = "N"; $arFields["IS_LOG"] = "N"; if (is_set($arFields, "IMAGE")) { $arFields["FILES"][] = $arFields["IMAGE"]; } $arFiles = null; $MID = CTicket::AddMessage($f->ID, $arFields, $arFiles, $v->CHECK_RIGHTS); $v->arrFILES = $arFiles; $MID = intval($MID); if (intval($MID) > 0) { //CTicket::UpdateLastParams2($f->ID, array("EVENT"=>array(CTicket::ADD))); CTicket::UpdateLastParamsN($f->ID, array("EVENT" => array(CTicket::ADD)), true, true); // если указана отметка о спаме то установим отметку о спаме if (strlen($f->IS_SPAM) > 0) { CTicket::MarkAsSpam($f->ID, $f->IS_SPAM, $v->CHECK_RIGHTS); } /******************************************** $nf - Заново прочитанные из базы поля ********************************************/ CTimeZone::Disable(); $z = CTicket::GetByID($f->ID, $f->SITE_ID, "N", "N"); CTimeZone::Enable(); if ($zr = $z->Fetch()) { $nf = (object) $zr; $rsSite = CSite::GetByID($nf->SITE_ID); $v->arrSite = $rsSite->Fetch(); self::Set_sendMails($nf, $v, $arFields); // создаем событие в модуле статистики if (CModule::IncludeModule("statistic")) { if (!$v->category_set) { $v->T_EVENT1 = "ticket"; $v->T_EVENT2 = ""; $v->T_EVENT3 = ""; } if (strlen($v->T_EVENT3) <= 0) { $v->T_EVENT3 = "http://" . $_SERVER["HTTP_HOST"] . "/bitrix/admin/ticket_edit.php?ID=" . $f->ID . "&lang=" . $v->arrSite["LANGUAGE_ID"]; } CStatEvent::AddCurrent($v->T_EVENT1, $v->T_EVENT2, $v->T_EVENT3); } } } // !!! ПРОВЕРИТЬ $arFields ТОЧНО ЛИ ВСЕ $arFields[..] = .. ТАКИЕ ЖЕ КАК В ОРИГИНАЛЕ !!! $arFields['ID'] = $f->ID; $arFields['MID'] = $MID; CTicket::ExecuteEvents('OnAfterTicketAdd', $arFields, true); } return $f->ID; }
public static function KeepVoting() { global $DB, $VOTING_LAMP, $USER_ALREADY_VOTE, $USER_GROUP_PERMISSION, $USER; $err_mess = CAllVote::err_mess() . "<br>Function: KeepVoting<br>Line: "; $VOTING_LAMP = "green"; $USER_ALREADY_VOTE = "N"; $PUBLIC_VOTE_ID = intval($_REQUEST["PUBLIC_VOTE_ID"]); $aMsg = array(); $VOTE_ID = 0; $arVote = array(); $arQuestions = array(); if (!(!empty($_REQUEST["vote"]) && $PUBLIC_VOTE_ID > 0 && check_bitrix_sessid())) { $aMsg[] = array("id" => "bad_params", "text" => GetMessage("VOTE_NOT_FOUND")); } elseif (($VOTE_ID = intVal(GetVoteDataByID($PUBLIC_VOTE_ID, $arChannel, $arVote, $arQuestions, $arAnswers, $arDropDown, $arMultiSelect, $arGroupAnswers, "N"))) && ($VOTE_ID <= 0 || $arVote["LAMP"] != "green")) { $VOTING_LAMP = "red"; if ($VOTE_ID <= 0) { $aMsg[] = array("id" => "VOTE_ID", "text" => GetMessage("VOTE_NOT_FOUND")); } else { $aMsg[] = array("id" => "LAMP", "text" => GetMessage("VOTE_RED_LAMP")); } } elseif ($arChannel["USE_CAPTCHA"] == "Y" && !$USER->IsAuthorized()) { include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/captcha.php"; $cpt = new CCaptcha(); if (!empty($_REQUEST["captcha_word"])) { $captchaPass = COption::GetOptionString("main", "captcha_password", ""); if (!$cpt->CheckCodeCrypt($_REQUEST["captcha_word"], $_REQUEST["captcha_code"], $captchaPass)) { $GLOBALS["BAD_CAPTCHA"] = "Y"; $aMsg[] = array("id" => "CAPTCHA", "text" => GetMessage("VOTE_BAD_CAPTCHA")); } } else { if (!$cpt->CheckCode($_REQUEST["captcha_word"], 0)) { $GLOBALS["NO_CAPTCHA"] = "Y"; $aMsg[] = array("id" => "CAPTCHA", "text" => GetMessage("VOTE_BAD_CAPTCHA")); } } } if (empty($aMsg)) { // get user id $_SESSION["VOTE_USER_ID"] = CVote::SetVoteUserID(); $GLOBALS["VOTING_ID"] = $VOTE_ID; // check: can user vote $UNIQUE_TYPE = $arVote["UNIQUE_TYPE"]; $KEEP_IP_SEC = $arVote["KEEP_IP_SEC"]; $CHANNEL_ID = $arVote["CHANNEL_ID"]; $StatusVote = CVote::UserAlreadyVote($VOTE_ID, $_SESSION["VOTE_USER_ID"], $UNIQUE_TYPE, $KEEP_IP_SEC, $USER->GetID()); $USER_ALREADY_VOTE = $StatusVote != false ? "Y" : "N"; $USER_GROUP_PERMISSION = CVote::UserGroupPermission($CHANNEL_ID); // if user can vote that if (($USER_ALREADY_VOTE == "N" || $StatusVote == 8 && $_REQUEST["REVOTE_ID"] == $VOTE_ID) && $USER_GROUP_PERMISSION >= 2) { $arSqlAnswers = array(); // check answers foreach ($arQuestions as $qID => $arQuestion) { $arSqlAnswers[$arQuestion["ID"]] = array(); $bIndicators = array(); foreach ($arQuestion["ANSWERS"] as $arAnswer) { switch ($arAnswer["FIELD_TYPE"]) { case 0: // radio // radio case 2: // dropdown list $fieldName = ($arAnswer["FIELD_TYPE"] == 0 ? "vote_radio_" : "vote_dropdown_") . $qID; $aID = intval($GLOBALS[$fieldName]); if (!isset($bIndicators[$fieldName]) && array_key_exists($aID, $arQuestion["ANSWERS"])) { if (!empty($arAnswer['MESSAGE'])) { $arSqlAnswers[$qID][$aID] = array("ANSWER_ID" => $aID); } $bIndicators[$fieldName] = "Y"; } break; case 1: // checkbox // checkbox case 3: // multiselect list $fieldName = ($arAnswer["FIELD_TYPE"] == 1 ? "vote_checkbox_" : "vote_multiselect_") . $qID; $res = $GLOBALS[$fieldName]; if (!isset($bIndicators[$fieldName]) && is_array($res) && !empty($res)) { reset($res); foreach ($res as $aID) { if (array_key_exists($aID, $arQuestion["ANSWERS"])) { $arSqlAnswers[$qID][$aID] = array("ANSWER_ID" => $aID); } } $bIndicators[$fieldName] = "Y"; } break; case 4: // field // field case 5: // text $aID = $arAnswer["ID"]; $fieldName = ($arAnswer["FIELD_TYPE"] == 4 ? "vote_field_" : "vote_memo_") . $aID; $MESSAGE = trim($GLOBALS[$fieldName]); if ($MESSAGE != "") { $arSqlAnswers[$qID][$aID] = array("ANSWER_ID" => $aID, "MESSAGE" => "'" . $DB->ForSql(trim($MESSAGE), 2000) . "'"); } break; } } if (empty($arSqlAnswers[$qID])) { unset($arSqlAnswers[$qID]); if ($arQuestion['REQUIRED'] == 'Y') { $aMsg[] = array("id" => "QUESTION_" . $qID, "text" => GetMessage("VOTE_REQUIRED_MISSING")); $GLOBALS["VOTE_REQUIRED_MISSING"] = "Y"; break; } } } if (!empty($aMsg)) { /* do nothing; */ } elseif (!empty($arSqlAnswers)) { // vote event $arFields = array("VOTE_ID" => $VOTE_ID, "VOTE_USER_ID" => intval($_SESSION["VOTE_USER_ID"]), "DATE_VOTE" => $DB->GetNowFunction(), "STAT_SESSION_ID" => intval($_SESSION["SESS_SESSION_ID"]), "IP" => "'" . $DB->ForSql($_SERVER["REMOTE_ADDR"], 15) . "'", "VALID" => "'Y'"); /***************** Event onBeforeVoting ****************************/ foreach (GetModuleEvents("vote", "onBeforeVoting", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array(&$arFields, &$arSqlAnswers)) === false) { return false; } } /***************** /Event ******************************************/ if ($StatusVote == 8 && $_REQUEST["REVOTE_ID"] == $VOTE_ID) { $strSql = "SELECT VE.ID, VEQ.QUESTION_ID, VEA.ANSWER_ID" . " FROM b_vote_event VE " . "\tLEFT JOIN b_vote_event_question VEQ ON (VEQ.EVENT_ID=VE.ID)" . "\tLEFT JOIN b_vote_event_answer VEA ON (VEA.EVENT_QUESTION_ID=VEQ.ID)" . "\tLEFT JOIN b_vote_user VU ON (VE.VOTE_USER_ID = VU.ID)" . " WHERE VE.VOTE_ID=" . $VOTE_ID . " AND VU.AUTH_USER_ID=" . intval($USER->GetID()) . " ORDER BY VE.ID ASC, VEQ.QUESTION_ID ASC"; $db_res = $DB->Query($strSql, false, $err_mess . __LINE__); if ($db_res && ($res = $db_res->Fetch())) { if ($USER->GetID() > 0 && CModule::IncludeModule("im")) { CIMNotify::DeleteByTag("VOTING|" . $VOTE_ID, $USER->GetID()); } $del = false; $delQ = false; do { if ($delQ !== $res["QUESTION_ID"]) { if ($del !== $res["ID"]) { CVoteEvent::Delete($res["ID"]); $del = $res["ID"]; $arVote["COUNTER"] = intval($arVote["COUNTER"]) - 1; } $delQ = $res["QUESTION_ID"]; $arQuestions[$res["QUESTION_ID"]]["COUNTER"] = intval($arQuestions[$res["QUESTION_ID"]]["COUNTER"]) - 1; } $arQuestions[$res["QUESTION_ID"]]["ANSWERS"][$res["ANSWER_ID"]]["COUNTER"] = intval($arQuestions[$res["QUESTION_ID"]]["ANSWERS"][$res["ANSWER_ID"]]["COUNTER"]) - 1; } while ($res = $db_res->Fetch()); } $USER_ALREADY_VOTE = "N"; } unset($GLOBALS["VOTE_CACHE_VOTING"][$VOTE_ID]); unset($GLOBALS["VOTE_CACHE"]["VOTE"][$VOTE_ID]); $EVENT_ID = intval($DB->Insert("b_vote_event", $arFields, $err_mess . __LINE__)); if ($EVENT_ID > 0) { $arSqlQuestionsID = array(); $arSqlAnswersID = array(); foreach ($arSqlAnswers as $qID => $arSqlAnswer) { $arFields = array("EVENT_ID" => $EVENT_ID, "QUESTION_ID" => $qID); $EVENT_QUESTION_ID = intval($DB->Insert("b_vote_event_question", $arFields, $err_mess . __LINE__)); if ($EVENT_QUESTION_ID > 0) { $arSqlQuestionsID[] = $qID; $arQuestions[$qID]["COUNTER"] = intval($arQuestions[$qID]["COUNTER"]) + 1; foreach ($arSqlAnswer as $aID => $res) { $res["EVENT_QUESTION_ID"] = $EVENT_QUESTION_ID; if ($DB->Insert("b_vote_event_answer", $res, $err_mess . __LINE__)) { $arSqlAnswersID[$aID] = $qID; $arQuestions[$qID]["ANSWERS"][$aID]["COUNTER"] = intval($arQuestions[$qID]["ANSWERS"][$aID]["COUNTER"]) + 1; } } } } if (empty($arSqlQuestionsID) || empty($arSqlAnswersID)) { $DB->Query("DELETE FROM b_vote_event WHERE ID=" . $EVENT_ID, $arFields, $err_mess . __LINE__); } else { $arFields = array("COUNTER" => "COUNTER+1"); $DB->Update("b_vote", $arFields, "WHERE ID='" . $VOTE_ID . "'", $err_mess . __LINE__); $arVote["COUNTER"] = intval($arVote["COUNTER"]) + 1; $DB->Update("b_vote_question", $arFields, "WHERE ID in (" . implode(", ", $arSqlQuestionsID) . ")", $err_mess . __LINE__); $DB->Update("b_vote_answer", $arFields, "WHERE ID in (" . implode(", ", array_keys($arSqlAnswersID)) . ")", $err_mess . __LINE__); // increment user counter CVote::UpdateVoteUserID($_SESSION["VOTE_USER_ID"]); $GLOBALS["VOTING_OK"] = "Y"; $_SESSION["VOTE_ARRAY"][] = $VOTE_ID; if ($UNIQUE_TYPE & 8) { $_SESSION["VOTE"]["VOTES"][$VOTE_ID] = $EVENT_ID; } // statistic module if (CModule::IncludeModule("statistic")) { $event3 = $arVote["EVENT3"]; if (!empty($event3)) { $event3 = "http://" . $_SERVER["HTTP_HOST"] . "/bitrix/admin/vote_user_results.php?EVENT_ID=" . $EVENT_ID . "&lang=" . LANGUAGE_ID; } CStatEvent::AddCurrent($arVote["EVENT1"], $arVote["EVENT2"], $event3); } // notification if (!!$arVote["AUTHOR_ID"] && $arVote["AUTHOR_ID"] != $USER->GetID()) { if (empty($arVote["TITLE"])) { $arQuestion = reset($arQuestions); $arVote["TITLE"] = $arQuestion["QUESTION"]; } if ($arVote["NOTIFY"] == "I" && CModule::IncludeModule("im")) { $arVote["TOTAL_URL"] = ""; if (!empty($arVote["URL"])) { if (defined('SITE_SERVER_NAME')) { $arVote["TOTAL_URL"] = SITE_SERVER_NAME; } $arVote["TOTAL_URL"] = !empty($arVote["TOTAL_URL"]) ? $arVote["TOTAL_URL"] : COption::GetOptionString("main", "server_name", $GLOBALS["SERVER_NAME"]); if (!empty($arVote["TOTAL_URL"])) { $arVote["TOTAL_URL"] = (CMain::IsHTTPS() ? "https" : "http") . "://" . $arVote["TOTAL_URL"] . $arVote["URL"]; } } // send notification $gender = $USER->getParam("PERSONAL_GENDER") == "F" ? "_F" : ""; $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => $arVote["AUTHOR_ID"], "FROM_USER_ID" => $USER->GetID(), "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "vote", "NOTIFY_EVENT" => "voting", "NOTIFY_TAG" => "VOTING|" . $VOTE_ID, "NOTIFY_MESSAGE" => !empty($arVote["URL"]) ? GetMessage("V_NOTIFY_MESSAGE_HREF" . $gender, array("#VOTE_TITLE#" => $arVote["TITLE"], "#VOTE_URL#" => $arVote["URL"])) : GetMessage("V_NOTIFY_MESSAGE" . $gender, array("#VOTE_TITLE#" => $arVote["TITLE"])), "NOTIFY_MESSAGE_OUT" => !empty($arVote["TOTAL_URL"]) ? GetMessage("V_NOTIFY_MESSAGE_OUT_HREF" . $gender, array("#VOTE_TITLE#" => $arVote["TITLE"], "#VOTE_URL#" => $arVote["TOTAL_URL"])) : GetMessage("V_NOTIFY_MESSAGE" . $gender, array("#VOTE_TITLE#" => $arVote["TITLE"]))); CIMNotify::Add($arMessageFields); } else { if ($arVote["NOTIFY"] == "Y") { // send e-mail $db_user = CUser::GetById($arVote["AUTHOR_ID"]); if ($db_user && ($arUser = $db_user->Fetch()) && !empty($arUser["EMAIL"])) { $arEventFields = array("EMAIL_TO" => $arUser["EMAIL"], "VOTE_STATISTIC" => "", "ID" => $EVENT_ID, "TIME" => GetTime(time(), "FULL"), "VOTE_TITLE" => $arVote["TITLE"], "VOTE_DESCRIPTION" => $arVote["DESCRIPTION"], "VOTE_ID" => $arVote["ID"], "VOTE_COUNTER" => $arVote["COUNTER"], "URL" => $arVote["URL"], "CHANNEL" => $arChannel["TITLE"], "CHANNEL_ID" => $arChannel["ID"], "VOTER_ID" => $_SESSION["VOTE_USER_ID"], "USER_NAME" => $USER->GetFullName(), "LOGIN" => $USER->GetLogin(), "USER_ID" => $USER->GetID(), "STAT_GUEST_ID" => intval($_SESSION["SESS_GUEST_ID"]), "SESSION_ID" => intval($_SESSION["SESS_SESSION_ID"]), "IP" => $_SERVER["REMOTE_ADDR"]); $arEventFields["USER_NAME"] = !!$arEventFields["USER_NAME"] ? $arEventFields["USER_NAME"] : $arEventFields["LOGIN"]; // VOTE_STATISTIC $text = array(); foreach ($arSqlAnswersID as $aID => $qID) { $text[$qID] = is_array($text[$qID]) ? $text[$qID] : array(); if ($arQuestions[$qID]["ANSWERS"][$aID]["FIELD_TYPE"] == 4 || $arQuestions[$qID]["ANSWERS"][$aID]["FIELD_TYPE"] == 5) { if (!empty($arSqlAnswers[$qID][$aID]["MESSAGE"])) { $text[$qID][] = $arSqlAnswers[$qID][$aID]["MESSAGE"]; } } else { $text[$qID][] = $arQuestions[$qID]["ANSWERS"][$aID]["MESSAGE"]; } } foreach ($text as $qID => $txt) { $text[$qID] = " - " . $arQuestions[$qID]["QUESTION"] . "\n - " . implode(", ", $text[$qID]); } $arEventFields["VOTE_STATISTIC"] = "\n" . implode("\n\n", $text); $arrSites = CVoteChannel::GetSiteArray($arChannel["ID"]); CEvent::Send("VOTE_FOR", $arrSites, $arEventFields, "N"); } } } } } /***************** Event onAfterVoting *****************************/ foreach (GetModuleEvents("vote", "onAfterVoting", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($VOTE_ID, $EVENT_ID)); } /***************** /Event ******************************************/ } } else { $GLOBALS["USER_VOTE_EMPTY"] = "Y"; $aMsg[] = array("id" => "VOTE_ID", "text" => GetMessage("USER_VOTE_EMPTY")); } } else { $aMsg[] = array("id" => "VOTE_ID", "text" => $USER_GROUP_PERMISSION >= 2 ? GetMessage("VOTE_ALREADY_VOTE") : GetMessage("VOTE_ACCESS_DENIED")); } } if (!empty($aMsg)) { $e = new CAdminException($aMsg, "CVote::KeepVoting"); $GLOBALS["APPLICATION"]->ThrowException($e); $GLOBALS["VOTING_OK"] = "N"; return false; } return true; }
<?php //define("STOP_STATISTICS", true); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; if (isset($_SESSION["player_files"]) && is_array($_SESSION["player_files"]) && isset($_REQUEST["id"]) && isset($_SESSION["player_files"][$_REQUEST["id"]])) { $arFile = $_SESSION["player_files"][$_REQUEST["id"]]; if ($arFile["STAT_EVENT"] && !$arFile["WAS_STAT_EVENT"] && strlen($arFile["STAT_EVENT1"]) > 0 && CModule::IncludeModule('statistic')) { CStatEvent::AddCurrent($arFile["STAT_EVENT1"], $arFile["STAT_EVENT2"], $arFile["STAT_EVENT3"]); $_SESSION["player_files"][$_REQUEST["id"]]["WAS_STAT_EVENT"] = true; } if ($arFile["SHOW_COUNTER_EVENT"] && !$arFile["WAS_SHOW_COUNTER_EVENT"] && CModule::IncludeModule('iblock')) { CIBlockElement::CounterInc($_REQUEST["id"]); $_SESSION["player_files"][$_REQUEST["id"]]["WAS_SHOW_COUNTER_EVENT"] = true; } } require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog_after.php";
function CancelOrder($ID, $val, $description = "") { global $DB, $USER, $APPLICATION; $isOrderConverted = \Bitrix\Main\Config\Option::get("main", "~sale_converted_15", 'N'); $ID = IntVal($ID); $val = $val != "Y" ? "N" : "Y"; $description = Trim($description); if ($ID <= 0) { $APPLICATION->ThrowException(Loc::getMessage("SKGO_NO_ORDER_ID1"), "NO_ORDER_ID"); return false; } $arOrder = CSaleOrder::GetByID($ID); if (!$arOrder) { $APPLICATION->ThrowException(str_replace("#ID#", $ID, Loc::getMessage("SKGO_NO_ORDER")), "NO_ORDER"); return false; } if ($arOrder["CANCELED"] == $val) { $APPLICATION->ThrowException(str_replace("#ID#", $ID, Loc::getMessage("SKGO_DUB_CANCEL")), "ALREADY_FLAG"); return false; } if ($isOrderConverted == "Y") { $r = \Bitrix\Sale\Compatible\OrderCompatibility::cancel($ID, $val, $description); if ($r->isSuccess(true)) { $res = true; } else { $errorMessage = ""; foreach ($r->getErrorMessages() as $error) { $errorMessage .= " " . $error; } $APPLICATION->ThrowException(Loc::getMessage("SKGO_CANCEL_ERROR", array("#MESSAGE#" => $errorMessage)), "CANCEL_ERROR"); return false; } } else { foreach (GetModuleEvents("sale", "OnSaleBeforeCancelOrder", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($ID, $val)) === false) { return false; } } if ($val == "Y") { if ($arOrder["DEDUCTED"] == "Y") { if (!CSaleOrder::DeductOrder($ID, "N")) { return false; } } if ($arOrder["RESERVED"] == "Y") { if (!CSaleOrder::ReserveOrder($ID, "N")) { return false; } } if ($arOrder["PAYED"] == "Y") { if (!CSaleOrder::PayOrder($ID, "N", True, True)) { return False; } } else { $arOrder["SUM_PAID"] = DoubleVal($arOrder["SUM_PAID"]); if ($arOrder["SUM_PAID"] > 0) { if (!CSaleUserAccount::UpdateAccount($arOrder["USER_ID"], $arOrder["SUM_PAID"], $arOrder["CURRENCY"], "ORDER_CANCEL_PART", $ID)) { return False; } CSaleOrder::Update($arOrder["ID"], array("SUM_PAID" => 0)); } } if ($arOrder["ALLOW_DELIVERY"] == "Y") { if (!CSaleOrder::DeliverOrder($ID, "N")) { return False; } } } else { if (COption::GetOptionString("sale", "product_reserve_condition", "O") == "O" && $arOrder["RESERVED"] != "Y") { if (!CSaleOrder::ReserveOrder($ID, "Y")) { return false; } } } $arFields = array("CANCELED" => $val, "=DATE_CANCELED" => $DB->GetNowFunction(), "REASON_CANCELED" => strlen($description) > 0 ? $description : false, "EMP_CANCELED_ID" => IntVal($USER->GetID()) > 0 ? IntVal($USER->GetID()) : false); $res = CSaleOrder::Update($ID, $arFields); } unset($GLOBALS["SALE_ORDER"]["SALE_ORDER_CACHE_" . $ID]); if ($isOrderConverted != "Y") { //this method is used only for catalogs without reservation and deduction support CSaleBasket::OrderCanceled($ID, $val == "Y" ? True : False); foreach (GetModuleEvents("sale", "OnSaleCancelOrder", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, $val, $description)); } } if ($val == "Y") { CTimeZone::Disable(); $arOrder = CSaleOrder::GetByID($ID); CTimeZone::Enable(); $userEmail = ""; $dbOrderProp = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $ID, "PROP_IS_EMAIL" => "Y")); if ($arOrderProp = $dbOrderProp->Fetch()) { $userEmail = $arOrderProp["VALUE"]; } if (strlen($userEmail) <= 0) { $dbUser = CUser::GetByID($arOrder["USER_ID"]); if ($arUser = $dbUser->Fetch()) { $userEmail = $arUser["EMAIL"]; } } if (CModule::IncludeModule("statistic")) { CStatEvent::AddByEvents("eStore", "order_cancel", $ID, "", $arOrder["STAT_GID"]); } } return $res; }
if (intval($cur_pos) > 0) { CHTTP::SetStatus("206 Partial Content"); } else { session_cache_limiter(''); session_start(); if (CModule::IncludeModule("statistic") && intval($_SESSION["SESS_SEARCHER_ID"]) <= 0) { if (strlen($event1) <= 0 && strlen($event2) <= 0) { $event1 = "download"; $event2 = "private"; $event3 = $file; } $e = $event1 . "/" . $event2 . "/" . $event3; if (!in_array($e, $_SESSION["DOWNLOAD_EVENTS"])) { $w = CStatEvent::GetByEvents($event1, $event2); $wr = $w->Fetch(); $z = CStatEvent::GetEventsByGuest($_SESSION["SESS_GUEST_ID"], $wr["EVENT_ID"], $event3, 21600); if (!($zr = $z->Fetch())) { CStatistic::Set_Event($event1, $event2, $event3); $_SESSION["DOWNLOAD_EVENTS"][] = $e; } } } ob_end_clean(); session_write_close(); CHTTP::SetStatus("200 OK"); } header("Content-Type: application/force-download; name=\"" . $file . "\""); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . ($size - $cur_pos + 1)); header("Accept-Ranges: bytes"); header("Content-Range: bytes " . $cur_pos . "-" . $size . "/" . $filesize);
function PrologActions() { /** @global CMain $APPLICATION */ global $APPLICATION, $USER; if (defined("BX_CHECK_SHORT_URI") && BX_CHECK_SHORT_URI) { if ($arUri = CBXShortUri::GetUri($_SERVER["REQUEST_URI"])) { CBXShortUri::SetLastUsed($arUri["ID"]); if (CModule::IncludeModule("statistic")) { CStatEvent::AddCurrent("short_uri_redirect", "", "", "", "", $arUri["URI"], "N", SITE_ID); } LocalRedirect($arUri["URI"], true, CBXShortUri::GetHttpStatusCodeText($arUri["STATUS"])); die; } } //session expander if (COption::GetOptionString("main", "session_expand", "Y") != "N" && (!defined("BX_SKIP_SESSION_EXPAND") || BX_SKIP_SESSION_EXPAND == false)) { $arPolicy = $USER->GetSecurityPolicy(); $phpSessTimeout = ini_get("session.gc_maxlifetime"); if ($arPolicy["SESSION_TIMEOUT"] > 0) { $sessTimeout = min($arPolicy["SESSION_TIMEOUT"] * 60, $phpSessTimeout); } else { $sessTimeout = $phpSessTimeout; } $cookie_prefix = COption::GetOptionString('main', 'cookie_name', 'BITRIX_SM'); $salt = $_COOKIE[$cookie_prefix . '_UIDH'] . "|" . $_SERVER["REMOTE_ADDR"] . "|" . @filemtime($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/version.php") . "|" . LICENSE_KEY . "|" . CMain::GetServerUniqID(); $key = md5(bitrix_sessid() . $salt); $bShowMess = $USER->IsAuthorized() && COption::GetOptionString("main", "session_show_message", "Y") != "N"; $ext = array('ajax'); if ($bShowMess) { $ext[] = "fx"; } CUtil::InitJSCore($ext); $jsMsg = '<script type="text/javascript">' . "\n" . ($bShowMess ? 'bxSession.mess.messSessExpired = \'' . CUtil::JSEscape(GetMessage("MAIN_SESS_MESS", array("#TIMEOUT#" => round($sessTimeout / 60)))) . '\';' . "\n" : '') . 'bxSession.Expand(' . $sessTimeout . ', \'' . bitrix_sessid() . '\', ' . ($bShowMess ? 'true' : 'false') . ', \'' . $key . '\');' . "\n" . '</script>'; if ($APPLICATION->IsJSOptimized()) { $APPLICATION->AddHeadScript('/bitrix/js/main/session.js'); $APPLICATION->AddAdditionalJS($jsMsg); } else { $APPLICATION->AddHeadString('<script type="text/javascript" src="' . CUtil::GetAdditionalFileURL('/bitrix/js/main/session.js') . '"></script>' . "\n" . $jsMsg, true); } $_SESSION["BX_SESSION_COUNTER"] = intval($_SESSION["BX_SESSION_COUNTER"]) + 1; if (!defined("BX_SKIP_SESSION_TERMINATE_TIME")) { $_SESSION["BX_SESSION_TERMINATE_TIME"] = time() + $sessTimeout; } } //user auto time zone via js cookies if (CTimeZone::Enabled()) { CTimeZone::SetAutoCookie(); } // check user options set via cookie if ($USER->IsAuthorized()) { $cookieName = COption::GetOptionString("main", "cookie_name", "BITRIX_SM") . "_LAST_SETTINGS"; if (!empty($_COOKIE[$cookieName])) { CUserOptions::SetCookieOptions($cookieName); } } if (COption::GetOptionString("main", "buffer_content", "Y") == "Y" && (!defined("BX_BUFFER_USED") || BX_BUFFER_USED !== true)) { ob_start(array(&$APPLICATION, "EndBufferContent")); $APPLICATION->buffered = true; define("BX_BUFFER_USED", true); register_shutdown_function(create_function('', 'while(@ob_end_flush());')); } foreach (GetModuleEvents("main", "OnProlog", true) as $arEvent) { ExecuteModuleEventEx($arEvent); } }
function CancelOrder($ID, $val, $description = "") { global $DB, $USER; $ID = IntVal($ID); $val = $val != "Y" ? "N" : "Y"; $description = Trim($description); if ($ID <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGO_NO_ORDER_ID1"), "NO_ORDER_ID"); return False; } $arOrder = CSaleOrder::GetByID($ID); if (!$arOrder) { $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("SKGO_NO_ORDER")), "NO_ORDER"); return False; } if ($arOrder["CANCELED"] == $val) { $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $ID, GetMessage("SKGO_DUB_CANCEL")), "ALREADY_FLAG"); return False; } foreach (GetModuleEvents("sale", "OnSaleBeforeCancelOrder", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($ID, $val)) === false) { return false; } } if ($val == "Y") { if ($arOrder["PAYED"] == "Y") { if (!CSaleOrder::PayOrder($ID, "N", True, True)) { return False; } } else { $arOrder["SUM_PAID"] = DoubleVal($arOrder["SUM_PAID"]); if ($arOrder["SUM_PAID"] > 0) { if (!CSaleUserAccount::UpdateAccount($arOrder["USER_ID"], $arOrder["SUM_PAID"], $arOrder["CURRENCY"], "ORDER_CANCEL_PART", $ID)) { return False; } } } if ($arOrder["ALLOW_DELIVERY"] == "Y") { if (!CSaleOrder::DeliverOrder($ID, "N")) { return False; } } } $arFields = array("CANCELED" => $val, "=DATE_CANCELED" => $DB->GetNowFunction(), "REASON_CANCELED" => strlen($description) > 0 ? $description : false, "EMP_CANCELED_ID" => IntVal($USER->GetID()) > 0 ? IntVal($USER->GetID()) : false); $res = CSaleOrder::Update($ID, $arFields); unset($GLOBALS["SALE_ORDER"]["SALE_ORDER_CACHE_" . $ID]); //this method is used only for catalogs without reservation and deduction support CSaleBasket::OrderCanceled($ID, $val == "Y" ? True : False); foreach (GetModuleEvents("sale", "OnSaleCancelOrder", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, $val, $description)); } if ($val == "Y") { CTimeZone::Disable(); $arOrder = CSaleOrder::GetByID($ID); CTimeZone::Enable(); $userEmail = ""; $dbOrderProp = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $ID, "PROP_IS_EMAIL" => "Y")); if ($arOrderProp = $dbOrderProp->Fetch()) { $userEmail = $arOrderProp["VALUE"]; } if (strlen($userEmail) <= 0) { $dbUser = CUser::GetByID($arOrder["USER_ID"]); if ($arUser = $dbUser->Fetch()) { $userEmail = $arUser["EMAIL"]; } } $event = new CEvent(); $arFields = array("ORDER_ID" => $ID, "ORDER_DATE" => $arOrder["DATE_INSERT_FORMAT"], "EMAIL" => $userEmail, "ORDER_CANCEL_DESCRIPTION" => $description, "SALE_EMAIL" => COption::GetOptionString("sale", "order_email", "order@" . $_SERVER["SERVER_NAME"])); $eventName = "SALE_ORDER_CANCEL"; $bSend = true; foreach (GetModuleEvents("sale", "OnOrderCancelSendEmail", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($ID, &$eventName, &$arFields)) === false) { $bSend = false; } } if ($bSend) { $event = new CEvent(); $event->Send($eventName, $arOrder["LID"], $arFields, "N"); } if (CModule::IncludeModule("statistic")) { CStatEvent::AddByEvents("eStore", "order_cancel", $ID, "", $arOrder["STAT_GID"]); } } if ($val == "Y") { if ($arOrder["DEDUCTED"] == "Y") { $rs = CSaleOrder::DeductOrder($ID, "N"); if (!$rs) { return false; } } if ($arOrder["RESERVED"] == "Y") { if (!CSaleOrder::ReserveOrder($ID, "N")) { } return false; } } else { if (COption::GetOptionString("sale", "product_reserve_condition", "O") == "O" && $arOrder["RESERVED"] != "Y") { if (!CSaleOrder::ReserveOrder($ID, "Y")) { } return false; } } return $res; }
function LoadEventsBySteps($csvfile, $time_step, $next_line, &$step_processed, &$step_loaded, &$step_duplicate, $check_unique = "Y", $base_currency = "", &$next_pos) { if ($fp = fopen($csvfile, "rb")) { if ($next_pos > 0) { fseek($fp, $next_pos); } $start = getmicrotime(); $all_loaded = ""; $next_line = intval($next_line); $read_lines = 0; $step_loaded = 0; $step_processed = 0; $step_duplicate = 0; while (!feof($fp)) { $arrCSV = fgetcsv($fp, 4096, ","); if (is_array($arrCSV) && count($arrCSV) > 0) { array_walk($arrCSV, "CleanUpResultCsv"); $read_lines++; $step_processed++; $EVENT_ID = $arrCSV[0]; $EVENT3 = $arrCSV[1]; $DATE_ENTER = $arrCSV[2]; $PARAMETER = $arrCSV[3]; $MONEY = $arrCSV[4]; $CURRENCY = $arrCSV[5]; $CHARGEBACK = $arrCSV[6]; $RES_MONEY = $MONEY; $EVENT_ID = intval($EVENT_ID); $CHARGEBACK = $CHARGEBACK == "Y" ? "Y" : "N"; if ($EVENT_ID > 0) { if (strlen($base_currency) <= 0) { $base_currency = GetStatisticBaseCurrency(); } if (strlen($base_currency) > 0) { if ($CURRENCY != $base_currency && strlen(trim($CURRENCY)) > 0) { if (CModule::IncludeModule("currency")) { $stmp = MkDateTime(ConvertDateTime($DATE_ENTER, "D.M.Y H:I:S"), "d.m.Y H:i:s"); $valDate = date("Y-m-d", $stmp); $rate = CCurrencyRates::GetConvertFactor($CURRENCY, $base_currency, $valDate); if ($rate > 0) { $RES_MONEY = $MONEY * $rate; } } } } $RES_MONEY = round($RES_MONEY, 2); $add_event = "Y"; if ($check_unique == "Y") { $arr = CStatEvent::DecodeGid($PARAMETER); $arFilter = array("EVENT_ID" => $EVENT_ID, "EVENT3" => $EVENT3, "DATE" => $DATE_ENTER, "SESSION_ID" => $arr["SESSION_ID"], "GUEST_ID" => $arr["GUEST_ID"], "COUNTRY_ID" => $arr["COUNTRY_ID"], "ADV_ID" => $arr["ADV_ID"], "ADV_BACK" => $arr["ADV_BACK"], "SITE_ID" => $arr["SITE_ID"]); $rsEvents = CStatEvent::GetListUniqueCheck($arFilter); if ($arEvent = $rsEvents->Fetch()) { $add_event = "N"; $step_duplicate++; } } if ($add_event == "Y") { CStatEvent::AddByID($EVENT_ID, $EVENT3, $DATE_ENTER, $PARAMETER, $RES_MONEY, "", $CHARGEBACK); $step_loaded++; } $end = getmicrotime(); if (intval($time_step) > 0 && $end - $start > intval($time_step)) { $all_loaded = "N"; break; } } } } if ($all_loaded == "N") { $next_pos = ftell($fp); } else { $next_pos = 0; } @fclose($fp); if ($all_loaded != "N") { $all_loaded = "Y"; @unlink($csvfile); } return $all_loaded; } }
/** * <p>Добавляет <a href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#event">событие</a> по заданному <a href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#event_type">типу</a> и <a href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#gid">специальному параметру</a>.</p> <p><b>Примечание</b>. Метод использует внутреннюю транзакцию. Если у вас используется <b>MySQL</b> и <b>InnoDB</b>, и ранее была открыта транзакция, то ее необходимо закрыть до подключения метода.</p> * * * @param int $type_id ID типа события. * * @param string $event3 <a href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#event3">Дополнительный параметр * event3</a> события. * * @param string $date Дата в <a href="http://dev.1c-bitrix.ru/api_help/main/general/constants.php#format_datetime">текущем * формате</a>. * * @param string $gid <a href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#gid">Специальный параметр</a> в * котором закодированы все необходимые данные для добавления * события. * * @param mixed $money = "" Денежная сумма. * * @param string $currency = "" Трехсимвольный идентификатор валюты. Идентификаторы валют * задаются в модуле "Валюты". * * @param string $chargeback = "N" Флаг отрицательной суммы. Используется, когда необходимо * зафиксировать событие о возврате денег (chargeback). Возможные * значения: <ul> <li> <b>Y</b> - денежная сумма отрицательная; </li> <li> <b>N</b> - * денежная сумма положительная. </li> </ul> * * @return int <p>Функция возвращает ID добавленного события в случае успеха и 0 * если событие не было добавлено по каким либо причинам.</p> * * <h4>Example</h4> * <pre> * <? * // добавим событие по типу события #1 * // данный тип должен быть заранее создан * * // специальный параметр события в незакодированном виде * $gid = "BITRIX_SM.995.82.N0.25.N.ru"; * * // дата должна быть заданы в формате текущего сайта или языка * $date = "23.12.2005 18:15:10"; * * <b>CStatEvent::Add</b>(1, "", $date, $gid, 99, "USD"); * ?> * * <? * // добавим событие по типу события #2 * // данный тип должен быть заранее создан * * // специальный параметр события в закодированном виде * $gid = "BITRIX_SM.OTk1LjgyLk4wLjI1Lk4ucnU%3D"; * * // дата должна быть заданы в формате текущего сайта или языка * $date = "01.06.2005"; * * <b>CStatEvent::Add</b>(2, "", $date, $gid, "199", "EUR"); * ?> * </pre> * * * <h4>See Also</h4> * <ul> <li> <a * href="http://dev.1c-bitrix.ru/api_help/statistic/classes/cstatevent/addbyevents.php">CStatEvent::AddByEvents</a> </li> * <li> <a href="http://dev.1c-bitrix.ru/api_help/statistic/classes/cstatevent/addcurrent.php">CStatEvent::AddCurrent</a> * </li> <li> <a href="http://www.1c-bitrix.ru/user_help/statistic/events/event_edit.php">Загрузка * событий</a> </li> <li> <a href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#event">Термин * "Событие"</a> </li> <li> <a href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#event3">Термин * "Дополнительный параметр события (event3)"</a> </li> <li> <a * href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#gid">Термин "Специальный параметр * события"</a> </li> </ul> <a name="examples"></a> * * * @static * @link http://dev.1c-bitrix.ru/api_help/statistic/classes/cstatevent/add.php * @author Bitrix */ public static function Add($EVENT_ID, $EVENT3, $DATE_ENTER, $PARAM, $MONEY = "", $CURRENCY = "", $CHARGEBACK = "N") { $err_mess = "File: " . __FILE__ . "<br>Line: "; $DB = CDatabase::GetModuleConnection('statistic'); $EVENT_ID = intval($EVENT_ID); $EVENT_LIST_ID = 0; $strSql = "SELECT KEEP_DAYS FROM b_stat_event WHERE ID = {$EVENT_ID}"; $rsEvent = $DB->Query($strSql, false, $err_mess . __LINE__); if ($arEvent = $rsEvent->Fetch()) { $MONEY = doubleval($MONEY); // если указана валюта то конвертируем if (strlen(trim($CURRENCY)) > 0) { $base_currency = GetStatisticBaseCurrency(); if (strlen($base_currency) > 0) { if ($CURRENCY != $base_currency) { if (CModule::IncludeModule("currency")) { $rate = CCurrencyRates::GetConvertFactor($CURRENCY, $base_currency); if ($rate > 0 && $rate != 1) { $MONEY = $MONEY * $rate; } } } } } $MONEY = round($MONEY, 2); $arr = CStatEvent::DecodeGid($PARAM); $SESSION_ID = intval($arr["SESSION_ID"]); $GUEST_ID = intval($arr["GUEST_ID"]); $COUNTRY_ID = $arr["COUNTRY_ID"]; $ADV_ID = intval($arr["ADV_ID"]); $ADV_BACK = $arr["ADV_BACK"] == "Y" ? "Y" : "N"; $CHARGEBACK = $CHARGEBACK == "Y" ? "Y" : "N"; $SITE_ID = $arr["SITE_ID"]; $DATE_ENTER = strlen(trim($DATE_ENTER)) > 0 ? $DATE_ENTER : GetTime(time(), "FULL"); $TIME_ENTER_TMSTMP = MakeTimeStamp($DATE_ENTER); if (!$TIME_ENTER_TMSTMP) { $DATE_ENTER = GetTime(time(), "FULL"); $TIME_ENTER_TMSTMP = MakeTimeStamp($DATE_ENTER); } $TIME_ENTER_SQL = "FROM_UNIXTIME('" . $TIME_ENTER_TMSTMP . "')"; $DAY_ENTER_TMSTMP = MakeTimeStamp($DATE_ENTER); $DAY_ENTER_SQL = "FROM_UNIXTIME('" . $DAY_ENTER_TMSTMP . "')"; $DB->StartTransaction(); $arFields = array("EVENT_ID" => $EVENT_ID, "EVENT3" => "'" . $DB->ForSql($EVENT3, 255) . "'", "MONEY" => $MONEY, "DATE_ENTER" => $TIME_ENTER_SQL, "SESSION_ID" => intval($SESSION_ID) > 0 ? intval($SESSION_ID) : "null", "GUEST_ID" => intval($GUEST_ID) > 0 ? intval($GUEST_ID) : "null", "ADV_ID" => intval($ADV_ID) > 0 ? intval($ADV_ID) : "null", "ADV_BACK" => $ADV_BACK == "Y" ? "'Y'" : "'N'", "COUNTRY_ID" => strlen($COUNTRY_ID) > 0 ? "'" . $DB->ForSql($COUNTRY_ID, 2) . "'" : "null", "KEEP_DAYS" => intval($arEvent["KEEP_DAYS"]) > 0 ? intval($arEvent["KEEP_DAYS"]) : "null", "CHARGEBACK" => "'" . $CHARGEBACK . "'", "SITE_ID" => strlen($SITE_ID) > 0 ? "'" . $DB->ForSql($SITE_ID, 2) . "'" : "null"); $EVENT_LIST_ID = $DB->Insert("b_stat_event_list", $arFields, $err_mess . __LINE__); // увеличиваем счетчик для страны if (strlen($COUNTRY_ID) > 0) { CStatistics::UpdateCountry($COUNTRY_ID, array("C_EVENTS" => 1)); } // если нужно обновляем дату первого события для данного типа события $arFields = array("DATE_ENTER" => $DB->GetNowFunction()); $DB->Update("b_stat_event", $arFields, "WHERE ID='" . $EVENT_ID . "' and DATE_ENTER is null", $err_mess . __LINE__); // обновляем счетчик по дням для данного типа события $arFields = array("DATE_LAST" => $DB->GetNowFunction(), "COUNTER" => "COUNTER + 1", "MONEY" => "MONEY + " . $MONEY); $rows = $DB->Update("b_stat_event_day", $arFields, "WHERE EVENT_ID='" . $EVENT_ID . "' and DATE_STAT = " . $DAY_ENTER_SQL, $err_mess . __LINE__); // если обсчета по дням нет то if (intval($rows) <= 0) { // добавляем его $arFields_i = array("DATE_STAT" => $DAY_ENTER_SQL, "DATE_LAST" => $TIME_ENTER_SQL, "EVENT_ID" => $EVENT_ID, "COUNTER" => 1, "MONEY" => $MONEY); $DB->Insert("b_stat_event_day", $arFields_i, $err_mess . __LINE__); } elseif (intval($rows) > 1) { // удалим лишние $strSql = "SELECT ID FROM b_stat_event_day WHERE EVENT_ID='" . $EVENT_ID . "' and DATE_STAT = " . $DAY_ENTER_SQL . " ORDER BY ID"; $i = 0; $rs = $DB->Query($strSql, false, $err_mess . __LINE__); while ($ar = $rs->Fetch()) { $i++; if ($i > 1) { $strSql = "DELETE FROM b_stat_event_day WHERE ID = " . $ar["ID"]; $DB->Query($strSql, false, $err_mess . __LINE__); } } } // обновляем сессию и гостя $arFields = array("C_EVENTS" => "C_EVENTS+1"); $DB->Update("b_stat_session", $arFields, "WHERE ID=" . $SESSION_ID, $err_mess . __LINE__, false, false, false); $DB->Update("b_stat_guest", $arFields, "WHERE ID=" . $GUEST_ID, $err_mess . __LINE__, false, false, false); // обновляем дневной счетчик $arFields = array("C_EVENTS" => "C_EVENTS + 1"); $DB->Update("b_stat_day", $arFields, "WHERE DATE_STAT = " . $DAY_ENTER_SQL, $err_mess . __LINE__, false, false, false); // увеличиваем счетчик траффика CTraffic::IncParam(array("EVENT" => 1), array(), false, $DATE_ENTER); // если сайт определен то if (strlen($SITE_ID) > 0) { // обновляем дневной счетчик $arFields = array("C_EVENTS" => "C_EVENTS+1"); $DB->Update("b_stat_day_site", $arFields, "WHERE SITE_ID='" . $DB->ForSql($SITE_ID, 2) . "' and DATE_STAT = " . $DAY_ENTER_SQL, $err_mess . __LINE__); // увеличиваем счетчик траффика CTraffic::IncParam(array(), array("EVENT" => 1), $SITE_ID, $DATE_ENTER); } if ($ADV_ID > 0) { $a = $DB->Query("SELECT 'x' FROM b_stat_adv WHERE ID='" . $ADV_ID . "'", false, $err_mess . __LINE__); // если есть такая рекламная кампания то if ($ar = $a->Fetch()) { // увеличиваем доход рекламной кампании if ($MONEY != 0) { $sign = $CHARGEBACK == "Y" ? "-" : "+"; $arFields = array("REVENUE" => "REVENUE " . $sign . " " . $MONEY); $DB->Update("b_stat_adv", $arFields, "WHERE ID='{$ADV_ID}'", $err_mess . __LINE__, false, false, false); } // обновляем счетчик связки рекламной кампании и типа события if ($ADV_BACK == "Y") { $arFields = array("COUNTER_BACK" => "COUNTER_BACK + 1", "MONEY_BACK" => "MONEY_BACK + " . $MONEY); } else { $arFields = array("COUNTER" => "COUNTER + 1", "MONEY" => "MONEY + " . $MONEY); } $rows = $DB->Update("b_stat_adv_event", $arFields, "WHERE ADV_ID='{$ADV_ID}' and EVENT_ID='{$EVENT_ID}'", $err_mess . __LINE__); // если связки нет то if (intval($rows) <= 0 && intval($ADV_ID) > 0 && intval($EVENT_ID) > 0) { // вставляем связку $arFields = array("ADV_ID" => "'" . intval($ADV_ID) . "'", "EVENT_ID" => "'" . intval($EVENT_ID) . "'"); if ($ADV_BACK == "Y") { $arFields["COUNTER_BACK"] = 1; $arFields["MONEY_BACK"] = $MONEY; } else { $arFields["COUNTER"] = 1; $arFields["MONEY"] = $MONEY; } $DB->Insert("b_stat_adv_event", $arFields, $err_mess . __LINE__); } // обновляем счетчик связки по дням if ($ADV_BACK == "Y") { $arFields = array("COUNTER_BACK" => "COUNTER_BACK + 1", "MONEY_BACK" => "MONEY_BACK + " . $MONEY); } else { $arFields = array("COUNTER" => "COUNTER + 1", "MONEY" => "MONEY + " . $MONEY); } $rows = $DB->Update("b_stat_adv_event_day", $arFields, "WHERE ADV_ID='{$ADV_ID}' and EVENT_ID='{$EVENT_ID}' and DATE_STAT = " . $DAY_ENTER_SQL, $err_mess . __LINE__, false, false, false); // если нет такой связки то if (intval($rows) <= 0 && intval($ADV_ID) > 0 && intval($EVENT_ID) > 0) { // вставляем ее $arFields = array("DATE_STAT" => $DAY_ENTER_SQL, "ADV_ID" => "'" . $ADV_ID . "'", "EVENT_ID" => "'" . $EVENT_ID . "'"); if ($ADV_BACK == "Y") { $arFields["COUNTER_BACK"] = 1; $arFields["MONEY_BACK"] = $MONEY; } else { $arFields["COUNTER"] = 1; $arFields["MONEY"] = $MONEY; } $DB->Insert("b_stat_adv_event_day", $arFields, $err_mess . __LINE__); } } } $DB->Commit(); } return intval($EVENT_LIST_ID); }
function PrepareHTML($text, $arBanner) { global $nRandom1, $nRandom2, $nRandom3, $nRandom4, $nRandom5; static $search = array("#RANDOM1#", "#RANDOM2#", "#RANDOM3#", "#RANDOM4#", "#RANDOM5#", "#BANNER_NAME#", "#BANNER_ID#", "#CONTRACT_ID#", "#TYPE_SID#"); if (strlen(trim($text)) > 0) { $text = str_replace($search, array($nRandom1, $nRandom2, $nRandom3, $nRandom4, $nRandom5, $arBanner["NAME"], $arBanner["ID"], $arBanner["CONTRACT_ID"], $arBanner["TYPE_SID"]), $text); if (strpos($text, "#EVENT_GID#") !== false) { if (CModule::IncludeModule("statistic")) { $text = str_replace("#EVENT_GID#", CStatEvent::GetGID(), $text); } } } return $text; }
$strJavaCurArray .= "\n\n"; $arrCurrency = array("REFERENCE" => $arrRef, "REFERENCE_ID" => $arrRefID); } } else { $strJavaCurArray = ""; } $upload_dir = $_SERVER["DOCUMENT_ROOT"] . "/" . COption::GetOptionString("main", "upload_dir", "/upload/") . "/statistic"; $upload_dir = str_replace("\\", "/", $upload_dir); $upload_dir = str_replace("//", "/", $upload_dir); if (!file_exists($upload_dir)) { mkdir($upload_dir, BX_DIR_PERMISSIONS); } $md5 = md5($APPLICATION->GetCurPage() . time()); $INPUT_CSV_FILE = $upload_dir . "/" . $md5 . "_in" . ".csv"; $OUTPUT_CSV_FILE = $INPUT_CSV_FILE; $arrHandlers = CStatEvent::GetHandlerList($arUSER_HANDLERS); // prepare file for loading from CSV $CSV_LOADING_OK = false; if ($Load != "" && $tabControl_active_tab == "load_csv_tab" && $REQUEST_METHOD == "POST" && $STAT_RIGHT >= "W" && check_bitrix_sessid()) { $arFile = $HTTP_POST_FILES["file_name"]; $file = $arFile["tmp_name"]; if (move_uploaded_file($file, $INPUT_CSV_FILE)) { // handler was choosen if (strlen($handler) > 0 && $handler != "NOT_REF" && in_array($handler, $arrHandlers["reference_id"])) { // include it $handler_path = $_SERVER["DOCUMENT_ROOT"] . $handler; if (file_exists($handler_path)) { $OUTPUT_CSV_FILE = $upload_dir . "/" . $md5 . "_out" . ".csv"; include $handler_path; @unlink($INPUT_CSV_FILE); }
public static function GetEventsByGuest($GUEST_ID, $EVENT_ID = false, $EVENT3 = false, $SEC = false) { return CStatEvent::GetListByGuest($GUEST_ID, $EVENT_ID, $EVENT3, $SEC); }
<?php define("ADMIN_SECTION", false); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; global $APPLICATION; if (CModule::IncludeModule("statistic")) { if (strlen($site_id) <= 0) { $referer_url = strlen($_SERVER["HTTP_REFERER"]) <= 0 ? $_SESSION["SESS_HTTP_REFERER"] : $_SERVER["HTTP_REFERER"]; if (strlen($referer_url) > 0) { $url = parse_url($referer_url); $rs = CSite::GetList($v1 = "LENDIR", $v2 = "DESC", array("ACTIVE" => "Y", "DOMAIN" => "%" . $url["host"], "IN_DIR" => $url["path"])); $arr = $rs->Fetch(); $site_id = $arr["ID"]; } } if (strlen($site_id) <= 0) { $site_id = false; } $goto = eregi_replace("#EVENT_GID#", urlencode(CStatEvent::GetGID($site_id)), $goto); CStatEvent::AddCurrent($event1, $event2, $event3, $money, $currency, $goto, $chargeback, $site_id); } else { $goto = eregi_replace("#EVENT_GID#", "", $goto); } LocalRedirect($goto);
public static function CheckUri() { if ($arUri = static::GetUri(Bitrix\Main\Context::getCurrent()->getRequest()->getDecodedUri())) { static::SetLastUsed($arUri["ID"]); if (CModule::IncludeModule("statistic")) { CStatEvent::AddCurrent("short_uri_redirect", "", "", "", "", $arUri["URI"], "N", SITE_ID); } LocalRedirect($arUri["URI"], true, static::GetHttpStatusCodeText($arUri["STATUS"])); return true; } return false; }
} $ID = IntVal($ID); switch ($_REQUEST['action']) { case "delete": @set_time_limit(0); $statDB->StartTransaction(); if (!CStatEvent::Delete($ID)) { $statDB->Rollback(); $lAdmin->AddGroupError(GetMessage("STAT_DELETE_ERROR"), $ID); } $statDB->Commit(); break; } } } $cData = new CStatEvent(); $rsData = $cData->GetList($by, $order, $arFilter, $is_filtered); $rsData = new CAdminResult($rsData, $sTableID); $rsData->NavStart(); $lAdmin->NavText($rsData->GetNavPrint(GetMessage("STAT_EVENT_PAGES"))); $arHeaders = array(array("id" => "ID", "content" => "ID", "sort" => "s_id", "align" => "right", "default" => true), array("id" => "TYPE_ID", "content" => GetMessage("STAT_EVENT"), "sort" => "s_event_id", "align" => "right", "default" => true), array("id" => "EVENT1", "content" => "event1", "sort" => "", "default" => true), array("id" => "EVENT2", "content" => "event2", "sort" => "", "default" => true), array("id" => "EVENT3", "content" => "event3", "sort" => ""), array("id" => "DATE_ENTER", "content" => GetMessage("STAT_DATE"), "sort" => "s_date_enter", "default" => true), array("id" => "SESSION_ID", "content" => GetMessage("STAT_SESSION"), "sort" => "s_session_id", "align" => "right", "default" => true), array("id" => "GUEST_ID", "content" => GetMessage("STAT_GUEST"), "sort" => "s_guest_id", "align" => "right", "default" => true), array("id" => "COUNTRY_ID", "content" => GetMessage("STAT_COUNTRY"), "sort" => "s_country_id", "default" => true), array("id" => "ADV_ID", "content" => GetMessage("STAT_ADV"), "sort" => "s_adv_id", "align" => "right", "default" => true), array("id" => "HIT_ID", "content" => GetMessage("STAT_HIT"), "sort" => "s_hit_id", "align" => "right", "default" => true), array("id" => "SITE_ID", "content" => GetMessage("STAT_SITE"), "sort" => "s_site_id", "default" => true), array("id" => "REFERER_URL", "content" => GetMessage("STAT_REFERER_URL"), "sort" => "s_referer_url"), array("id" => "URL", "content" => GetMessage("STAT_URL"), "sort" => "s_url"), array("id" => "REDIRECT_URL", "content" => GetMessage("STAT_REDIRECT_URL"), "sort" => "s_redirect_url")); if ($STAT_RIGHT > "M") { $arHeaders[] = array("id" => "MONEY", "content" => GetMessage("STAT_MONEY") . (strlen($view_currency) > 0 ? "<br>(" . $view_currency . ")" : ""), "sort" => "s_money", "align" => "right", "default" => true); } $lAdmin->AddHeaders($arHeaders); $thousand_sep = $_REQUEST["mode"] == "excel" ? "" : " "; while ($arRes = $rsData->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_ID, $arRes); if ($f_TYPE_ID > 0) { $strHTML = '<a href="event_type_list.php?lang=' . LANG . '&find_id=' . $f_TYPE_ID . '&find_id_exact_match=Y&set_filter=Y" title="ID = ' . $f_TYPE_ID . (strlen($f_EVENT1) > 0 ? "\nevent1 = " . $f_EVENT1 : "") . (strlen($f_EVENT2) > 0 ? "\nevent2 = " . $f_EVENT2 : "") . (strlen($f_NAME) > 0 ? "\n" . GetMessage("STAT_NAME") . " " . $f_NAME : "") . (strlen($f_DESCRIPTION) > 0 ? "\n" . GetMessage("STAT_DESCRIPTION") . " " . $f_DESCRIPTION : "") . '">' . $f_TYPE_ID . '</a>'; } else {
if ($p !== false) { $cur_pos = intval(substr($bytes, 0, $p)); } } include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; if (CModule::IncludeModule("statistic")) { if ($cur_pos <= 0) { if (strlen($event1) <= 0 && strlen($event2) <= 0) { $event1 = "download"; $event2 = $file; } $e = $event1 . "/" . $event2 . "/" . $event3; if (!in_array($e, $_SESSION["DOWNLOAD_EVENTS"])) { $w = CStatEvent::GetByEvents($event1, $event2); $wr = $w->Fetch(); $z = CStatEvent::GetEventsByGuest($_SESSION["SESS_GUEST_ID"], $wr["EVENT_ID"], $event3, $DOWNLOAD_EVENT_INTERVAL); if (!($zr = $z->Fetch())) { CStatistic::Set_Event($event1, $event2, $event3); $_SESSION["DOWNLOAD_EVENTS"][] = $e; } } } } ob_end_clean(); session_write_close(); while (list($key, $value) = each($arrHOSTS)) { $max_weight += intval($key); } mt_srand((double) microtime() * 1000000); $rand = $max_weight * (rand() / getrandmax()); reset($arrHOSTS);
define("ADMIN_SECTION", false); if (!empty($_REQUEST['site_id']) && preg_match('/^[a-z0-9_]{2}$/i', $_REQUEST['site_id'])) { define('SITE_ID', $_REQUEST['site_id']); } require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; global $APPLICATION; if (CModule::IncludeModule("statistic")) { if (strlen($_REQUEST["site_id"]) <= 0) { $site_id = false; $referer_url = strlen($_SERVER["HTTP_REFERER"]) <= 0 ? $_SESSION["SESS_HTTP_REFERER"] : $_SERVER["HTTP_REFERER"]; if (strlen($referer_url)) { $url = @parse_url($referer_url); if ($url) { $rs = CSite::GetList($v1 = "LENDIR", $v2 = "DESC", array("ACTIVE" => "Y", "DOMAIN" => "%" . $url["host"], "IN_DIR" => $url["path"])); if ($arr = $rs->Fetch()) { $site_id = $arr["ID"]; } } } } else { $site_id = $_REQUEST["site_id"]; } $goto = preg_replace("/#EVENT_GID#/i", urlencode(CStatEvent::GetGID($site_id)), $_REQUEST["goto"]); CStatEvent::AddCurrent($_REQUEST["event1"], $_REQUEST["event2"], $_REQUEST["event3"], $_REQUEST["money"], $_REQUEST["currency"], $goto, $_REQUEST["chargeback"], $site_id); } else { $goto = preg_replace("/#EVENT_GID#/i", "", $_REQUEST["goto"]); } if (intval($id) > 0 && CModule::IncludeModule("advertising")) { CAdvBanner::Click($id); } LocalRedirect($goto);
/** * @param Main\Event $event * * @return Main\EventResult */ public static function onSaleOrderCancelSendEmail(Main\Event $event) { $parameters = $event->getParameters(); /** @var Sale\Order $order */ $order = $parameters[0]; if (!$order instanceof Sale\Order) { return new Main\EventResult(Main\EventResult::ERROR, new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_ORDER_CANCEL_SEND_EMAIL_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_CANCEL_SEND_EMAIL_WRONG_ORDER'), 'sale'); } $id = $order->getId(); $value = $order->getField('CANCELED'); $description = $order->getField('REASON_CANCELED'); if ($value == "Y") { $userEmail = ""; /** @var Sale\PropertyValueCollection $propertyCollection */ if ($propertyCollection = $order->getPropertyCollection()) { if ($propUserEmail = $propertyCollection->getUserEmail()) { $userEmail = $propUserEmail->getValue(); } } if (strval($userEmail) == '') { $resUser = \CUser::GetByID($order->getUserId()); if ($userData = $resUser->Fetch()) { $userEmail = $userData["EMAIL"]; } } $fields = array("ORDER_ID" => $order->getField("ACCOUNT_NUMBER"), "ORDER_DATE" => $order->getDateInsert()->toString(), "EMAIL" => $userEmail, "ORDER_CANCEL_DESCRIPTION" => $description, "SALE_EMAIL" => Main\Config\Option::get("sale", "order_email", "order@" . $_SERVER["SERVER_NAME"])); $eventName = "SALE_ORDER_CANCEL"; $send = true; foreach (GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_ORDER_CANCEL_SEND_EMAIL, true) as $oldEvent) { if (ExecuteModuleEventEx($oldEvent, array($id, &$eventName, &$fields)) === false) { $send = false; } } if ($send) { $event = new \CEvent(); $event->Send($eventName, $order->getField('LID'), $fields, "N"); } $orderFields = null; /** @var Sale\Result $r */ $r = OrderCompatibility::getOrderFields($order); if ($r->isSuccess()) { if ($resultOrderFieldsData = $r->getData()) { if (!empty($resultOrderFieldsData['ORDER_FIELDS']) && is_array($resultOrderFieldsData['ORDER_FIELDS'])) { $orderFields = $resultOrderFieldsData['ORDER_FIELDS']; } } } \CSaleMobileOrderPush::send("ORDER_CANCELED", array("ORDER" => $orderFields)); if (Main\Loader::includeModule("statistic")) { \CStatEvent::AddByEvents("eStore", "order_cancel", $id, "", $order->getField("STAT_GID")); } } return new Main\EventResult(Main\EventResult::SUCCESS, null, 'sale'); }
public static function Set_Event($event1, $event2="", $event3="", $goto="", $money="", $currency="", $chargeback="N", $site_id=false) { return CStatEvent::AddCurrent($event1, $event2, $event3, $money, $currency, $goto, $chargeback, $site_id); }