Your IP : 172.28.240.42


Current Path : /var/www/html/clients/amz.e-nk.ru/bitrix/modules/main/classes/general/
Upload File :
Current File : /var/www/html/clients/amz.e-nk.ru/bitrix/modules/main/classes/general/update_functions.php

<?
// GetUpdatedFiles(BX_ROOT."/updates/forum", $pFiles);
function GetUpdatedFiles($path, &$pFiles, $kill_prefix="")
{
	global $DOCUMENT_ROOT;

	$arDirs = Array();

	$path = $path[strlen($path)-1]=="/" ? substr($path, 0, strlen($path)-1) : $path;
//	$abs_path = $DOCUMENT_ROOT.$path;

	if (!file_exists($path) || !is_dir($path))
		return False;

	$handle  = @opendir($path);
	$file    = @readdir($handle);      // ÷èòàåì .
	$file    = @readdir($handle);      // ÷èòàåì ..
	while ($file = @readdir($handle))
	{
		$strFile = $path."/".$file;
		if (is_dir($path."/".$file))
		{
			$arDirs[] = $strFile;
		}
		else
		{
			if ($kill_prefix == substr($strFile, 0, strlen($kill_prefix)))
			{
				$strFile = substr($strFile, strlen($kill_prefix));
			}
			if (strtoupper(substr($strFile, 0, 13))!="/DESCRIPTION." && strtoupper(substr($strFile, 0, 20))!="/VERSION_CONTROL.TXT" && strpos(strtoupper($strFile), "/DEMO.")===false)
			{
				$pFiles[] = $strFile;
			}
		}
	}
	closedir($handle);

	for ($i=0; $i<count($arDirs); $i++)
	{
		GetUpdatedFiles($arDirs[$i], $pFiles, $kill_prefix);
	}
}

function getHTTPPage($page, $strVars, &$strError)
{
	global $SERVER_NAME, $CONNECTION_OPENED, $FP;

	$ServerIP = COption::GetOptionString("main", "update_site", "www.bitrixsoft.com");
	$ServerPort = "80";

	if ($CONNECTION_OPENED!="Y" || !$FP)
	{
		$FP = fsockopen($ServerIP, IntVal($ServerPort), $errno, $errstr, 120);
		$CONNECTION_OPENED = "Y";
	}

	if ($FP)
	{
		$strRequest = "POST /bitrix/updates/$page HTTP/1.0\r\n";
		$strRequest.= "User-Agent: BitrixSMUpdater\r\n";
		$strRequest.= "Accept: */*\r\n";
		$strRequest.= "Host: $ServerIP\r\n";
		$strRequest.= "Accept-Language: en\r\n";
		$strRequest.= "Content-type: application/x-www-form-urlencoded\r\n";
		$strRequest.= "Content-length: ".strlen($strVars)."\r\n\r\n";
		$strRequest.= "$strVars";
		$strRequest.= "\r\n";

		fputs($FP, $strRequest);

		while (($line = fgets($FP, 4096)) && $line!="\r\n");

		$arAll = "";
		while ($line = fread($FP, 4096))
		{
			$arAll .= $line;
		}

		$content = $arAll;
		$CONNECTION_OPENED = "N";
		fclose($FP);
	}
	else
	{
		$content = "";
		$strError = "Error ".$errno.": ".$errstr;
		if (IntVal($errno)<=0) $strError = "Connection failed. ";
	}
	return $content;
}

function CloseConnection()
{
	global $CONNECTION_OPENED, $FP;
	if ($CONNECTION_OPENED=="Y" && $FP)
	{
		$CONNECTION_OPENED = "N";
		fclose($FP);
	}
}

function xmlize($data)
{
	$data = trim($data);
	$vals = $index = $array = array();
	$parser = xml_parser_create();
	xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
	xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
	xml_parse_into_struct($parser, $data, $vals, $index);
	xml_parser_free($parser);

	$i = 0; 

	$tagname = $vals[$i]['tag'];
	if ( isset ($vals[$i]['attributes'] ) )
	{
		$array[$tagname]['@'] = $vals[$i]['attributes'];
	} else {
		$array[$tagname]['@'] = array();
	}

	$array[$tagname]["#"] = xml_depth($vals, $i);

	return $array;
}

function xml_depth($vals, &$i)
{
	$children = array(); 

	if ( isset($vals[$i]['value']) )
	{
		array_push($children, $vals[$i]['value']);
	}

	while (++$i < count($vals)) { 

		switch ($vals[$i]['type']) { 

		   case 'open': 

				if ( isset ( $vals[$i]['tag'] ) )
				{
					$tagname = $vals[$i]['tag'];
				} else {
					$tagname = '';
				}

				if ( isset ( $children[$tagname] ) )
				{
					$size = sizeof($children[$tagname]);
				} else {
					$size = 0;
				}

				if ( isset ( $vals[$i]['attributes'] ) ) {
					$children[$tagname][$size]['@'] = $vals[$i]["attributes"];
				}

				$children[$tagname][$size]['#'] = xml_depth($vals, $i);

			break; 

			case 'cdata':
				array_push($children, $vals[$i]['value']); 
			break; 

			case 'complete': 
				$tagname = $vals[$i]['tag'];

				if( isset ($children[$tagname]) )
				{
					$size = sizeof($children[$tagname]);
				} else {
					$size = 0;
				}

				if( isset ( $vals[$i]['value'] ) )
				{
					$children[$tagname][$size]["#"] = $vals[$i]['value'];
				} else {
					$children[$tagname][$size]["#"] = '';
				}

				if ( isset ($vals[$i]['attributes']) ) {
					$children[$tagname][$size]['@']
											 = $vals[$i]['attributes'];
				}			

			break; 

			case 'close':
				return $children; 
			break;
		} 

	} 

	return $children;
}

function IsGzipInstalled()
{
	if (function_exists("gzcompress")) return True;
	return False;
}

?>