Beispiel #1
0
	public static function AddByChannel($channelId, $arMessage)
	{
		global $DB;

		if (strlen($arMessage['module_id'])<=0 || strlen($arMessage['command'])<=0)
			return false;


		$arData = Array(
			'module_id' => $arMessage['module_id'],
			'command' => $arMessage['command'],
			'params' => is_array($arMessage['params'])?$arMessage['params']: Array(),
		);
		if (CPullOptions::GetNginxStatus())
		{
			$message = CUtil::PhpToJsObject(Array('CHANNEL_ID' => $channelId, 'MESSAGE' => Array($arData), 'ERROR' => ''));
			if (!defined('BX_UTF') || !BX_UTF)
				$message = $GLOBALS['APPLICATION']->ConvertCharset($message, SITE_CHARSET,'utf-8');

			$CHTTP = new CHTTP();
			$CHTTP->http_timeout = 10;
			if ($CHTTP->HTTPQuery('POST', CPullOptions::GetPublishUrl($channelId), str_replace("\n", " ", $message)))
				$result = $CHTTP->result;
		}
		else
		{
			$arParams = Array(
				'CHANNEL_ID' => $channelId,
				'MESSAGE' => str_replace("\n", " ", serialize($arData)),
				'~DATE_CREATE' => $DB->CurrentTimeFunction(),
			);
			$id = IntVal($DB->Add("b_pull_stack", $arParams, Array("MESSAGE")));
			$result = $id? '{"channel": "'.$channelId.'", "id": "'.$id.'"}': false;
		}

		if (isset($arMessage['push_text']) && strlen($arMessage['push_text'])>0
		&& isset($arMessage['push_user']) && intval($arMessage['push_user'])>0)
		{
			$CPushManager = new CPushManager();
			$CPushManager->AddQueue(Array(
				'USER_ID' => $arMessage['push_user'],
				'MESSAGE' => str_replace("\n", " ", $arMessage['push_text']),
				'PARAMS' => $arMessage['push_params'],
				'TAG' => isset($arMessage['push_tag'])? $arMessage['push_tag']: '',
			));
		}

		return $result;
	}
Beispiel #2
0
 public function removeFile(array $fileData)
 {
     $accessToken = $this->getAccessToken();
     $fileId = $fileData['id'];
     $http = new CHTTP();
     $http->http_timeout = 10;
     if (!$http->HTTPQuery('DELETE', "https://apis.live.net/v5.0/{$fileId}?access_token=" . urlencode($accessToken))) {
         return false;
     }
     // error checking
     if ($http->status != "200") {
         return false;
     }
     return true;
 }
 public static function Add($userId)
 {
     global $DB, $APPLICATION;
     $channelId = md5(uniqid() . $_SERVER["REMOTE_ADDR"] . $_SERVER["SERVER_NAME"] . (is_object($APPLICATION) ? $APPLICATION->GetServerUniqID() : ''));
     $arParams = array('USER_ID' => intval($userId), 'CHANNEL_ID' => $channelId, 'LAST_ID' => 0, '~DATE_CREATE' => $DB->CurrentTimeFunction());
     $result = IntVal($DB->Add("b_pull_channel", $arParams, array()));
     if (CPullOptions::GetNginxStatus()) {
         $result = false;
         $arData = array('module_id' => 'pull', 'command' => 'open', 'params' => array());
         $CHTTP = new CHTTP();
         $CHTTP->http_timeout = 10;
         if ($CHTTP->HTTPQuery('POST', CPullOptions::GetPublishUrl($channelId), CUtil::PhpToJsObject(array('MESSAGE' => array($arData), 'ERROR' => '')))) {
             $result = $CHTTP->result;
         }
     }
     return $result ? $channelId : false;
 }
 public static function AddByChannel($channelId, $arMessage)
 {
     global $DB;
     if (strlen($arMessage['module_id']) <= 0 || strlen($arMessage['command']) <= 0) {
         return false;
     }
     $arData = array('module_id' => $arMessage['module_id'], 'command' => $arMessage['command'], 'params' => is_array($arMessage['params']) ? $arMessage['params'] : array());
     if (CPullOptions::GetNginxStatus()) {
         $CHTTP = new CHTTP();
         $CHTTP->http_timeout = 10;
         if ($CHTTP->HTTPQuery('POST', CPullOptions::GetPublishUrl($channelId), str_replace("\n", " ", CUtil::PhpToJsObject(array('CHANNEL_ID' => $channelId, 'MESSAGE' => array($arData), 'ERROR' => ''))))) {
             $result = $CHTTP->result;
         }
     } else {
         $arParams = array('CHANNEL_ID' => $channelId, 'MESSAGE' => str_replace("\n", " ", serialize($arData)), '~DATE_CREATE' => $DB->CurrentTimeFunction());
         $id = IntVal($DB->Add("b_pull_stack", $arParams, array("MESSAGE")));
         $result = $id ? '{"channel": "' . $channelId . '", "id": "' . $id . '"}' : false;
     }
     if (isset($arMessage['push_text']) && strlen($arMessage['push_text']) > 0 && isset($arMessage['push_user']) && intval($arMessage['push_user']) > 0) {
         $CPushManager = new CPushManager();
         $CPushManager->AddQueue(array('USER_ID' => $arMessage['push_user'], 'MESSAGE' => str_replace("\n", " ", $arMessage['push_text']), 'PARAMS' => $arMessage['push_params'], 'TAG' => isset($arMessage['push_tag']) ? $arMessage['push_tag'] : ''));
     }
     return $result;
 }
Beispiel #5
0
function gdGetRss($rss_url, $cache_time = 0)
{
    /** @global CMain $APPLICATION */
    global $APPLICATION;
    $cache = new CPHPCache();
    if (!$cache->StartDataCache($cache_time, 'c' . $rss_url, "gdrss")) {
        $v = $cache->GetVars();
        return $v['oRss'];
    }
    $oRssFeeds = new gdRssFeeds();
    $ob = new CHTTP();
    $ob->http_timeout = 10;
    $ob->setFollowRedirect(true);
    $ob->HTTPQuery("GET", $rss_url);
    $res = $ob->result;
    if (!$res) {
        $cache->EndDataCache(array("oRss" => false));
        return false;
    }
    if (preg_match("/<" . "\\?XML[^>]{1,}encoding=[\"']([^>\"']{1,})[\"'][^>]{0,}\\?" . ">/i", $res, $matches)) {
        $charset = trim($matches[1]);
        $res = $APPLICATION->ConvertCharset($res, $charset, SITE_CHARSET);
    }
    $xml = new CDataXML();
    $xml->LoadString($res);
    $oNode = $xml->SelectNodes("/rss/channel/title");
    if (!$oNode) {
        $cache->EndDataCache(array("oRss" => false));
        return false;
    }
    $oRssFeeds->title = $oNode->content;
    if (trim($oRssFeeds->title) == '') {
        if ($oSubNode = $oNode->elementsByName("cdata-section")) {
            $oRssFeeds->title = $oSubNode[0]->content;
        }
    }
    if ($oNode = $xml->SelectNodes("/rss/channel/link")) {
        $oRssFeeds->link = $oNode->content;
    }
    if ($oNode = $xml->SelectNodes("/rss/channel/description")) {
        $oRssFeeds->description = $oNode->content;
    }
    if (trim($oRssFeeds->description) == '') {
        if ($oNode && ($oSubNode = $oNode->elementsByName("cdata-section"))) {
            $oRssFeeds->description = $oSubNode[0]->content;
        }
    }
    if ($oNode = $xml->SelectNodes("/rss/channel/pubDate")) {
        $oRssFeeds->pubDate = $oNode->content;
    } elseif ($oNode = $xml->SelectNodes("/rss/channel/lastBuildDate")) {
        $oRssFeeds->pubDate = $oNode->content;
    }
    if ($oNode = $xml->SelectNodes("/rss/channel")) {
        $oNodes = $oNode->elementsByName("item");
        foreach ($oNodes as $oNode) {
            $item = array();
            if ($oSubNode = $oNode->elementsByName("title")) {
                $item["TITLE"] = $oSubNode[0]->content;
            }
            if (trim($item["TITLE"]) == '' && !empty($oSubNode)) {
                if ($oSubNode = $oSubNode[0]->elementsByName("cdata-section")) {
                    $item["TITLE"] = $oSubNode[0]->content;
                }
            }
            if ($oSubNode = $oNode->elementsByName("link")) {
                $item["LINK"] = $oSubNode[0]->content;
            }
            if ($oSubNode = $oNode->elementsByName("pubDate")) {
                $item["PUBDATE"] = $oSubNode[0]->content;
            }
            if ($oSubNode = $oNode->elementsByName("description")) {
                $item["DESCRIPTION"] = $oSubNode[0]->content;
            }
            if (trim($item["DESCRIPTION"]) == '' && !empty($oSubNode)) {
                if ($oSubNode = $oSubNode[0]->elementsByName("cdata-section")) {
                    $item["DESCRIPTION"] = $oSubNode[0]->content;
                }
            }
            if ($oSubNode = $oNode->elementsByName("author")) {
                $item["AUTHOR"] = $oSubNode[0]->content;
            }
            if (trim($item["AUTHOR"]) == '' && !empty($oSubNode)) {
                if ($oSubNode = $oSubNode[0]->elementsByName("cdata-section")) {
                    $item["AUTHOR"] = $oSubNode[0]->content;
                }
            }
            $oRssFeeds->items[] = $item;
        }
    }
    $cache->EndDataCache(array("oRss" => $oRssFeeds));
    return $oRssFeeds;
}
 //1M
 $arFile = CFile::GetFileArray($ar["ID"]);
 $filePath = preg_replace("#[\\\\\\/]+#", "/", "/" . $arFile["SUBDIR"] . "/" . $arFile["FILE_NAME"]);
 $absPath = preg_replace("#[\\\\\\/]+#", "/", $_SERVER["DOCUMENT_ROOT"] . "/" . COption::GetOptionString("main", "upload_dir", "upload") . $filePath);
 $absPath = $io->GetPhysicalName($absPath);
 $absTempPath = $absPath . "~";
 if (!file_exists($absPath)) {
     CheckDirPath($absTempPath);
     $obRequest = new CHTTP();
     $obRequest->follow_redirect = true;
     $obRequest->fp = fopen($absTempPath, "ab");
     if (is_resource($obRequest->fp)) {
         if ($arFile["FILE_SIZE"] > $maxPartSize) {
             $obRequest->additional_headers["Range"] = sprintf("bytes=%u-%u", $last_file_pos, ($last_file_pos + $maxPartSize > $arFile["FILE_SIZE"] ? $arFile["FILE_SIZE"] : $last_file_pos + $maxPartSize) - 1);
         }
         $res = $obRequest->HTTPQuery('GET', $ob->GetFileSRC($arFile));
         fclose($obRequest->fp);
         unset($obRequest->fp);
         if ($res && ($obRequest->status == 200 || $obRequest->status == 206)) {
             $bFileMoved = true;
             if ($arFile["FILE_SIZE"] > $maxPartSize) {
                 $last_file_pos += $maxPartSize;
                 $_SESSION["last_file_pos"] = $last_file_pos;
                 $bNextFile = false;
             } else {
                 $last_file_pos = $arFile["FILE_SIZE"];
             }
             if (array_key_exists("Content-Range", $obRequest->headers) && preg_match("/(\\d+)-(\\d+)\\/(\\d+)\$/", $obRequest->headers["Content-Range"], $match)) {
                 $FILE_SIZE = $match[3];
             } elseif (array_key_exists("Content-Length", $obRequest->headers) && preg_match("/^(\\d+)\$/", $obRequest->headers["Content-Length"], $match) && $match[1] > $maxPartSize) {
                 $FILE_SIZE = 0;