コード例 #1
0
                    $lAdmin->AddUpdateError($e->GetString(), $ID);
                }
                break;
            case "deactivate":
            case "activate":
                $cData = new CXDILFScheme();
                $cData->Update($ID, array("ACTIVE" => $action == "deactivate" ? "N" : "Y"));
                break;
            default:
                break;
        }
    }
}
$arHeaders = array(array("id" => "ID", "content" => GetMessage("LFP_SCHEME_LIST_ID"), "sort" => "ID", "align" => "right", "default" => true), array("id" => "NAME", "content" => GetMessage("LFP_SCHEME_LIST_NAME"), "sort" => "NAME", "align" => "left", "default" => true), array("id" => "ACTIVE", "content" => GetMessage("LFP_SCHEME_LIST_ACTIVE"), "sort" => "ACTIVE", "align" => "left", "default" => true), array("id" => "SORT", "content" => GetMessage("LFP_SCHEME_LIST_SORT"), "sort" => "SORT", "align" => "left", "default" => true), array("id" => "LID", "content" => GetMessage("LFP_SCHEME_LIST_LID"), "sort" => "LID", "align" => "left", "default" => true), array("id" => "TYPE", "content" => GetMessage("LFP_SCHEME_LIST_TYPE"), "sort" => "TYPE", "align" => "left", "default" => true));
$lAdmin->AddHeaders($arHeaders);
$rsData = CXDILFScheme::GetList(array($by => $order));
$rsData = new CAdminResult($rsData, $sTableID);
while (is_array($arRes = $rsData->GetNext())) {
    $row =& $lAdmin->AddRow($arRes["ID"], $arRes);
    $row->AddInputField("NAME", array("size" => 20));
    $row->AddViewField("NAME", '<a href="xdi_lf_scheme_edit.php?ID=' . $arRes["ID"] . '&amp;lang=' . LANG . '">' . $arRes["NAME"] . '</a>');
    $row->AddEditField("LID", CLang::SelectBox("FIELDS[" . $arRes["ID"] . "][LID]", $arRes["LID"]));
    $row->AddInputField("SORT", array("size" => 20));
    $row->AddCheckField("ACTIVE");
    $row->AddViewField("ID", '<a href="xdi_lf_scheme_edit.php?lang=' . LANGUAGE_ID . '&ID=' . $arRes["ID"] . '">' . $arRes["ID"] . '</a>');
    $row->AddViewField("TYPE", GetMessage("LFP_SCHEME_LIST_" . $arRes["TYPE"]));
    $arActions = array(array("ICON" => "edit", "DEFAULT" => true, "TEXT" => GetMessage("LFP_SCHEME_LIST_EDIT"), "ACTION" => $lAdmin->ActionRedirect('xdi_lf_scheme_edit.php?lang=' . LANGUAGE_ID . '&ID=' . $arRes["ID"])));
    $arActions[] = array("SEPARATOR" => "Y");
    if ($arRes["ACTIVE"] === "Y") {
        $arActions[] = array("TEXT" => GetMessage("LFP_SCHEME_LIST_DEACTIVATE"), "ACTION" => "if(confirm('" . GetMessage("LFP_SCHEME_LIST_DEACTIVATE_CONF") . "')) " . $lAdmin->ActionDoGroup($arRes["ID"], "deactivate"));
    } else {
コード例 #2
0
ファイル: lf_scheme.php プロジェクト: DarneoStudio/bitrix
 function CheckRequest()
 {
     global $DB;
     $result = "";
     if (!CModule::IncludeModule("socialnetwork")) {
         return $result;
     }
     $current_time = time();
     $time_of_exec = false;
     $rsScheme = CXDILFScheme::GetList(array(), array("ACTIVE" => "Y", "AUTO" => "Y"));
     while (($arScheme = $rsScheme->Fetch()) && $time_of_exec === false) {
         if ($arScheme["LAST_EXECUTED"] == '') {
             continue;
         }
         $last_executed = MakeTimeStamp(ConvertDateTime($arScheme["LAST_EXECUTED"], "DD.MM.YYYY HH:MI:SS"), "DD.MM.YYYY HH:MI:SS");
         if ($last_executed <= 0) {
             continue;
         }
         $arEventTmp = CSocNetLogTools::FindLogEventByID($arScheme["EVENT_ID"]);
         if (array_key_exists("REAL_EVENT_ID", $arEventTmp) && strlen($arEventTmp["REAL_EVENT_ID"]) > 0) {
             $arScheme["EVENT_ID"] = $arEventTmp["REAL_EVENT_ID"];
         }
         //parse schedule
         $arDoM = CXDImport::ParseDaysOfMonth($arScheme["DAYS_OF_MONTH"]);
         $arDoW = CXDImport::ParseDaysOfWeek($arScheme["DAYS_OF_WEEK"]);
         $arToD = CXDImport::ParseTimesOfDay($arScheme["TIMES_OF_DAY"]);
         if ($arToD) {
             sort($arToD, SORT_NUMERIC);
         }
         $arSDate = localtime($last_executed);
         //sdate = truncate(last_execute)
         $sdate = mktime(0, 0, 0, $arSDate[4] + 1, $arSDate[3], $arSDate[5] + 1900);
         while ($sdate < $current_time && $time_of_exec === false) {
             $arSDate = localtime($sdate);
             if ($arSDate[6] == 0) {
                 $arSDate[6] = 7;
             }
             //determine if date is good for execution
             if ($arDoM) {
                 $flag = array_search($arSDate[3], $arDoM);
                 if ($arDoW) {
                     $flag = array_search($arSDate[6], $arDoW);
                 }
             } elseif ($arDoW) {
                 $flag = array_search($arSDate[6], $arDoW);
             } else {
                 $flag = false;
             }
             if ($flag !== false && $arToD) {
                 foreach ($arToD as $intToD) {
                     if ($sdate + $intToD > $last_executed && $sdate + $intToD <= $current_time) {
                         $time_of_exec = $sdate + $intToD;
                         break;
                     }
                 }
             }
             $sdate = mktime(0, 0, 0, date("m", $sdate), date("d", $sdate) + 1, date("Y", $sdate));
             //next day
         }
         if ($time_of_exec !== false) {
             if ($arScheme["TYPE"] == "XML") {
                 $arParams = array();
                 if (strlen($arScheme["PARAMS"]) > 0) {
                     $arTmp = explode("&", $arScheme["PARAMS"]);
                     if (is_array($arTmp) && count($arTmp) > 0) {
                         foreach ($arTmp as $pair) {
                             list($key, $value) = explode("=", $pair);
                             $arParams[$key] = $value;
                         }
                     }
                 }
                 $arResponse = CXDILFSchemeXML::Request($arScheme["HOST"], $arScheme["PAGE"], $arScheme["PORT"], $arScheme["METHOD"], "http://" . $arScheme["HOST"], $arScheme["LOGIN"], $arScheme["PASSWORD"], $arParams);
                 if ($arResponse && is_array($arResponse)) {
                     if (XDI_DEBUG) {
                         CXDImport::WriteToLog("Successful webservice response, scheme ID: " . $arScheme["ID"], "RXML");
                     }
                     $entityName = $arScheme["NAME"];
                     if ($arScheme["EVENT_ID"] == "news") {
                         $rsIBlock = CIBlock::GetList(array("ID" => "ASC"), array("ACTIVE" => "Y", "TYPE" => "news", "ID" => $arScheme["ENTITY_ID"]));
                         if ($arIBlock = $rsIBlock->Fetch()) {
                             $entityName = $arIBlock["NAME"];
                         }
                     }
                     $arLogParams = array("ENTITY_NAME" => $entityName, "ENTITY_URL" => $arResponse["URL"]);
                     $arSonetFields = array("SITE_ID" => $arScheme["LID"], "ENTITY_TYPE" => $arScheme["ENTITY_TYPE"], "ENTITY_ID" => $arScheme["ENTITY_ID"], "EVENT_ID" => $arScheme["EVENT_ID"], "ENABLE_COMMENTS" => $arScheme["ENABLE_COMMENTS"], "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE_TEMPLATE" => $arResponse["TITLE"], "TITLE" => $arResponse["TITLE"], "MESSAGE" => $arResponse["MESSAGE"], "TEXT_MESSAGE" => $arResponse["TEXT_MESSAGE"], "URL" => $arResponse["URL"], "PARAMS" => serialize($arLogParams), "MODULE_ID" => false, "CALLBACK_FUNC" => false);
                     $logID = CSocNetLog::Add($arSonetFields, false);
                     if (intval($logID) > 0) {
                         $arUpdateFields = array("TMP_ID" => $logID, "RATING_TYPE_ID" => "LOG_ENTRY", "RATING_ENTITY_ID" => $logID);
                         CSocNetLog::Update($logID, $arUpdateFields);
                         CXDILFScheme::SetSonetLogRights($logID, $arScheme["ENTITY_TYPE"], $arScheme["ENTITY_ID"], $arScheme["EVENT_ID"]);
                         CSocNetLog::CounterIncrement($logID);
                         if ($arScheme["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP && intval($arScheme["ENTITY_ID"]) > 0) {
                             $notify_title_tmp = str_replace(array("\r\n", "\n"), " ", $arScheme["NAME"]);
                             $notify_title = TruncateText($notify_title_tmp, 100);
                             $notify_title_out = TruncateText($notify_title_tmp, 255);
                             $arNotifyParams = array("LOG_ID" => $logID, "GROUP_ID" => intval($arScheme["ENTITY_ID"]), "NOTIFY_MESSAGE" => "", "URL" => "", "MESSAGE" => GetMessage("LFP_CLASS_SCHEME_IM_ADD", array("#title#" => $notify_title)), "MESSAGE_OUT" => GetMessage("LFP_CLASS_SCHEME_IM_ADD", array("#title#" => $notify_title_out)), "EXCLUDE_USERS" => array());
                             CSocNetSubscription::NotifyGroup($arNotifyParams);
                         }
                     }
                 } else {
                     CXDImport::WriteToLog("ERROR: Incorrect webservice response. Scheme ID: " . $arScheme["ID"] . ", server: " . $arScheme["HOST"] . ", port: " . $arScheme["PORT"] . ", page: " . $arScheme["PAGE"] . ", method: " . $arScheme["METHOD"] . ", params: " . $arScheme["PARAMS"], "RXML");
                 }
             } elseif ($arScheme["TYPE"] == "RSS") {
                 $arResponse = CXDILFSchemeRSS::Request($arScheme["HOST"], $arScheme["PAGE"], $arScheme["PORT"], $arScheme["PARAMS"], $arScheme["URI"]);
                 if ($arResponse && is_array($arResponse) && array_key_exists("item", $arResponse) && is_array($arResponse["item"]) && count($arResponse["item"]) > 0) {
                     if (XDI_DEBUG) {
                         CXDImport::WriteToLog("Successful RSS response. Scheme ID: " . $arScheme["ID"], "RRSS");
                     }
                     foreach ($arResponse["item"] as $arItem) {
                         $checksum = md5(serialize($arItem));
                         $rsLogEvents = CSocNetLog::GetList(array(), array("SITE_ID" => $arScheme["LID"], "ENTITY_TYPE" => $arScheme["ENTITY_TYPE"], "ENTITY_ID" => $arScheme["ENTITY_ID"], "EVENT_ID" => $arScheme["EVENT_ID"], "EXTERNAL_ID" => $checksum), false, array("nTopCount" => 1));
                         $arLogEvent = $rsLogEvents->Fetch();
                         if (!$arLogEvent) {
                             $entityName = $arScheme["NAME"];
                             if ($arScheme["EVENT_ID"] == "news") {
                                 $rsIBlock = CIBlock::GetList(array("ID" => "ASC"), array("ACTIVE" => "Y", "TYPE" => "news", "ID" => $arScheme["ENTITY_ID"]));
                                 if ($arIBlock = $rsIBlock->Fetch()) {
                                     $entityName = $arIBlock["NAME"];
                                 }
                             }
                             $arLogParams = array("SCHEME_ID" => $arScheme["ID"], "ENTITY_NAME" => $entityName, "ENTITY_URL" => $arResponse["link"]);
                             if (strlen($arItem["pubDate"]) > 0) {
                                 $arLogParams["SOURCE_TIMESTAMP"] = strtotime($arItem["pubDate"]);
                             }
                             $description = preg_replace("#^(.*?)([\\s]*<br[\\s]*/>)+[\\s]*[\n]*[\\s]*\$#is", "\\1", $arItem["description"]);
                             $arSonetFields = array("SITE_ID" => $arScheme["LID"], "ENTITY_TYPE" => $arScheme["ENTITY_TYPE"], "ENTITY_ID" => $arScheme["ENTITY_ID"], "EVENT_ID" => $arScheme["EVENT_ID"], "ENABLE_COMMENTS" => $arScheme["ENABLE_COMMENTS"], "TITLE_TEMPLATE" => $arItem["title"], "TITLE" => $arItem["title"], "MESSAGE" => $description, "TEXT_MESSAGE" => "", "URL" => $arItem["link"], "PARAMS" => serialize($arLogParams), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "EXTERNAL_ID" => $checksum, "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction());
                             $logID = CSocNetLog::Add($arSonetFields, false);
                             if (intval($logID) > 0) {
                                 $arUpdateFields = array("TMP_ID" => $logID, "RATING_TYPE_ID" => "LOG_ENTRY", "RATING_ENTITY_ID" => $logID);
                                 CSocNetLog::Update($logID, $arUpdateFields);
                                 CXDILFScheme::SetSonetLogRights($logID, $arScheme["ENTITY_TYPE"], $arScheme["ENTITY_ID"], $arScheme["EVENT_ID"]);
                                 CSocNetLog::CounterIncrement($logID);
                                 if ($arScheme["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP && intval($arScheme["ENTITY_ID"]) > 0) {
                                     $notify_title_tmp = str_replace(array("\r\n", "\n"), " ", $arScheme["NAME"]);
                                     $notify_title = TruncateText($notify_title_tmp, 100);
                                     $notify_title_out = TruncateText($notify_title_tmp, 255);
                                     $arNotifyParams = array("LOG_ID" => $logID, "GROUP_ID" => intval($arScheme["ENTITY_ID"]), "NOTIFY_MESSAGE" => "", "URL" => "", "MESSAGE" => GetMessage("LFP_CLASS_SCHEME_IM_ADD", array("#title#" => $notify_title)), "MESSAGE_OUT" => GetMessage("LFP_CLASS_SCHEME_IM_ADD", array("#title#" => $notify_title_out)), "EXCLUDE_USERS" => array());
                                     CSocNetSubscription::NotifyGroup($arNotifyParams);
                                 }
                             }
                         } elseif (XDI_DEBUG) {
                             CXDImport::WriteToLog("RSS item is already in log. Scheme ID: " . $arScheme["ID"] . ", log ID: " . $arLogEvent["ID"], "RRSS");
                         }
                     }
                 } else {
                     CXDImport::WriteToLog("ERROR: Incorrect RSS response. Scheme ID: " . $arScheme["ID"] . ", server: " . $arScheme["HOST"] . ", port: " . $arScheme["PORT"] . ", page: " . $arScheme["PAGE"] . ", params: " . $arScheme["PARAMS"], "RRSS");
                 }
             }
             $strSql = "UPDATE b_xdi_lf_scheme SET LAST_EXECUTED=" . $DB->GetNowFunction() . " WHERE ID=" . intval($arScheme["ID"]);
             $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         }
         $result = "CXDILFScheme::CheckRequest();";
     }
     return $result;
 }
コード例 #3
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    echo "B_PROLOG_INCLUDED error!";
    die;
}
if (!CModule::IncludeModule("xdimport") || !CModule::IncludeModule("socialnetwork")) {
    echo "Error loading modules!";
    return;
}
if (strlen($_POST["hash"]) > 0) {
    $rsScheme = CXDILFScheme::GetList(array(), array("ACTIVE" => "Y", "HASH" => $_POST["hash"]));
    if ($arScheme = $rsScheme->Fetch()) {
        if (strlen($_POST["title"]) > 0 && strlen($_POST["message"]) > 0) {
            if (XDI_DEBUG) {
                CXDImport::WriteToLog("Successful POST request, scheme ID: " . $arScheme["ID"], "RXML");
            }
            $arEventTmp = CSocNetLogTools::FindLogEventByID($arScheme["EVENT_ID"]);
            if (array_key_exists("REAL_EVENT_ID", $arEventTmp) && strlen($arEventTmp["REAL_EVENT_ID"]) > 0) {
                $arScheme["EVENT_ID"] = $arEventTmp["REAL_EVENT_ID"];
            }
            if ($arScheme["EVENT_ID"] == "news" && CModule::IncludeModule("iblock")) {
                $arLogParams = array("SCHEME_ID" => $arScheme["ID"]);
                $strParams = CharsetConverter::ConvertCharset($_POST["params"], CXDImport::DetectUTF8($_POST["params"]) ? "utf-8" : "windows-1251", SITE_CHARSET);
                $arParamPairs = explode("&", $strParams);
                if (is_array($arParamPairs)) {
                    foreach ($arParamPairs as $strPair) {
                        list($key, $value) = explode("=", $strPair);
                        if (strlen($key) > 0 && strlen($value) > 0) {
                            $arLogParams[$key] = $value;
                        }
コード例 #4
0
ファイル: index.php プロジェクト: mrdeadmouse/u136006
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule("xdimport")) {
    return;
}
$strWarning = "";
$bVarsFromForm = false;
$ob = new CXDILFScheme();
$rsXDILFScheme = CXDILFScheme::GetList(array(), array("TYPE" => "RSS"));
$arXDILFScheme = $rsXDILFScheme->Fetch();
if (empty($arXDILFScheme)) {
    switch (LANGUAGE_ID) {
        case "ru":
            $host = "www.1c-bitrix.ru";
            $page = "/upload/xdimport/xdimport_rss_ru.xml";
            break;
        case "de":
            $host = "www.bitrix.de";
            $page = "/upload/xdimport/xdimport_rss_de.xml";
            break;
        default:
            $host = "www.bitrixsoft.com";
            $page = "/upload/xdimport/xdimport_rss_en.xml";
            break;
    }
    $arFields = array("ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "SORT" => "100", "NAME" => GetMessage("XDI_SCHEME_NAME"), "TYPE" => "RSS", "LID" => WIZARD_SITE_ID, "DAYS_OF_WEEK" => "1,2,3,4,5,6,7", "TIMES_OF_DAY" => "8:00", "ENTITY_TYPE" => "P", "EVENT_ID" => "data", "HOST" => $host, "PAGE" => $page, "LAST_EXECUTED" => ConvertTimeStamp(time() - 86400, "FULL"));
    $res = $ob->Add($arFields);
    if ($res > 0) {