Example #1
0
 function _getPath($path, $sef_folder)
 {
     static $dav;
     if (empty($dav)) {
         $dav = CWebDavBase::IsDavHeaders('check_all') ? 'D' : 'W';
     }
     if ($dav == 'W') {
         $spath = substr($path, strlen($sef_folder) - 1);
         if (empty($spath)) {
             $spath .= '/';
         }
         return $spath;
     } else {
         return $path;
     }
 }
Example #2
0
function GetRequestTupe($arParams)
{
    $pageQ = $_SERVER['REQUEST_URI'];
    if ($arParsedUrl = parse_url(CWebDavBase::get_request_url())) {
        $pageQ = $arParsedUrl['path'];
    }
    $pageQ = str_replace($arParams["SEF_FOLDER"], "", $pageQ);
    $arU0 = explode("/", $pageQ);
    $arU = array();
    foreach ($arU0 as $v) {
        if (strlen($v) > 0) {
            $arU[] = $v;
        }
    }
    return $arU;
}
Example #3
0
 function _get_fileinfo($path)
 {
     $io = self::GetIo();
     if (strpos($path, $this->real_path_full) === 0) {
         $path = CWebDavBase::ConvertPathToRelative($path, $this->real_path_full);
     }
     $path = CWebDavBase::CleanRelativePathString($path);
     if ($path === false) {
         return false;
     }
     $fspath = $io->CombinePath($this->real_path_full, $path);
     //$fspath = $path;
     //if (strpos($path, $this->real_path_full) === false)
     //$fspath = str_replace(array("///", "//"), "/", $this->real_path_full."/".$path);
     //else
     //$path = str_replace(array($this->real_path_full, "///", "//"), "/", $path);
     $bDir = $io->DirectoryExists($fspath);
     $info = array();
     $info['path'] = $bDir ? $this->_slashify($path) : $path;
     $info['path'] = $this->MetaNamesReverse(explode('/', $info['path']), 'name', 'alias');
     if (SITE_CHARSET != "UTF-8") {
         $info['path'] = $GLOBALS["APPLICATION"]->ConvertCharset($info['path'], SITE_CHARSET, "UTF-8");
     }
     $info['props'] = array();
     if ($bDir) {
         $ioObj = $io->GetDirectory($fspath);
     } else {
         $ioObj = $io->GetFile($fspath);
     }
     $tzOffset = CTimeZone::GetOffset();
     $info['props'][] = $this->_mkprop('creationdate', $ioObj->GetCreationTime() + $tzOffset);
     $info['props'][] = $this->_mkprop('getlastmodified', $ioObj->GetModificationTime() + $tzOffset);
     if ($bDir) {
         $info['props'][] = $this->_mkprop('resourcetype', 'collection');
         $info['props'][] = $this->_mkprop('getcontenttype', 'httpd/unix-directory');
     } else {
         $info['props'][] = $this->_mkprop('resourcetype', '');
         if ($ioObj->IsReadable()) {
             $info['props'][] = $this->_mkprop('getcontenttype', $this->_mimetype($fspath));
         } else {
             $info['props'][] = $this->_mkprop('getcontenttype', 'application/x-non-readable');
         }
         $info['props'][] = $this->_mkprop('getcontentlength', $ioObj->GetFileSize());
     }
     $arProps = $this->_get_props($path);
     if (is_array($arProps)) {
         foreach ($arProps as $name => $prop) {
             if ($name != "LOCK") {
                 $info["props"][] = CWebDavBase::_mkprop($prop["ns"], $prop["name"], $prop["value"]);
             }
         }
     }
     return $info;
 }
Example #4
0
$arError = array();
/********************************************************************
				Check Socnet Permission and Main Data
********************************************************************/
/************** Can View *******************************************/
if ($arParams["PERMISSION"] < "R") {
    $arError[] = array("id" => "access_denied", "text" => GetMessage("SONET_ACCESS_DENIED"));
    /************** Active Feature *************************************/
} elseif ($object == "user" && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arResult["VARIABLES"]["user_id"], "files") || $object == "group" && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arResult["VARIABLES"]["group_id"], "files")) {
    $arError[] = array("id" => "fiture_is_not_active", "text" => GetMessage("SONET_FILES_IS_NOT_ACTIVE"));
    /************** Check Iblock ID ************************************/
} elseif ($object == "user" && $arParams["FILES_USER_IBLOCK_ID"] <= 0 || $object == "group" && $arParams["FILES_GROUP_IBLOCK_ID"] <= 0) {
    $arError[] = array("id" => "iblock_id_empty", "text" => GetMessage("SONET_IBLOCK_ID_EMPTY"));
} elseif ($arParams["USE_AUTH"] == "Y" && (CWebDavBase::IsDavHeaders() || $_SERVER['REQUEST_METHOD'] != "GET" && $_SERVER['REQUEST_METHOD'] != "POST") && !$USER->IsAuthorized()) {
    $APPLICATION->RestartBuffer();
    CWebDavBase::SetAuthHeader();
    header('Content-length: 0');
    die;
}
/************** Set Page Title or Add Navigation *******************/
if ($arParams["SET_NAV_CHAIN"] == "Y" || $arParams["SET_TITLE"] == "Y") {
    $strTitle = "";
    if ($object == "group") {
        $arResult["GROUP"] = $arGroup = CSocNetGroup::GetByID($arResult["VARIABLES"]["group_id"]);
        $db_res = CSocNetFeatures::GetList(array(), array("ENTITY_ID" => $arResult["GROUP"]["ID"], "ENTITY_TYPE" => SONET_ENTITY_GROUP, "FEATURE" => "files"));
        if ($db_res && ($arResult["GROUP"]["FEATURE"] = $db_res->GetNext())) {
            $arParams["STR_TITLE"] = $arResult["GROUP"]["FEATURE"]["FEATURE_NAME"] = empty($arResult["GROUP"]["FEATURE"]["FEATURE_NAME"]) ? $arParams["STR_TITLE"] : $arResult["GROUP"]["FEATURE"]["FEATURE_NAME"];
        } else {
            $arResult["GROUP"]["FEATURE"] = array("FEATURE_NAME" => $arParams["STR_TITLE"]);
        }
        $strTitle = $arGroup["~NAME"] . ": " . $arParams["STR_TITLE"];
Example #5
0
 static function GetIo()
 {
     if (self::$io == null) {
         self::$io = CBXVirtualIo::GetInstance();
     }
     return self::$io;
 }
Example #6
0
 function CheckRights($method = "", $strong = false, $path = "")
 {
     $result = true;
     if (!parent::CheckRights($method, $strong)) {
         $result = false;
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage('WD_ACCESS_DENIED'), 'ACCESS_DENIED');
     } elseif (!empty($path)) {
         $path = $this->_udecode($path);
         $strFileName = basename($path);
         $extention = strtolower(strrchr($strFileName, '.'));
         if (in_array($method, array("COPY", "MOVE", "PUT"))) {
             if (IsFileUnsafe($strFileName) || $strFileName == "index.php") {
                 $result = false;
                 $GLOBALS['APPLICATION']->ThrowException(GetMessage("WD_FILE_ERROR14"), "FORBIDDEN_NAME");
             }
         }
     }
     return $result;
 }
Example #7
0
         }
     }
     $userPerms = CIBlockWebdavSocnet::GetUserMaxPermission('user', $userID, $currentUserID, $arParams['IBLOCK_USER_ID']);
     foreach (array('PERMISSION', 'CHECK_CREATOR') as $propName) {
         $arParams[$propName] = $userPerms[$propName];
     }
     $arParams["DOCUMENT_TYPE"] = array("webdav", "CIBlockDocumentWebdavSocnet", "iblock_" . $arParams['IBLOCK_USER_ID'] . "_user_" . intVal($userID));
     $basementPath = $rootPath . '/' . $arLocalPath[0];
     $obGroup = new CWebDavIblock($arParams['IBLOCK_USER_ID'], $basementPath, $arParams);
     $obGroup->SetRootSection($sectionID);
     $currentPageUrl = str_replace(array('#USER_ID#', '#PATH#'), array($userID, ''), $arParams["USER_FILE_PATH"]);
     MakeDavRedirect($obGroup, $currentPageUrl, $rootPath . '/' . $arLocalPath[0], '/' . implode('/', array_slice($arLocalPath, 1)) . '/', false);
 } else {
     // user list
     $userTree = array();
     $CACHE_ID = SITE_ID . '|' . $requestURL . '|' . $currentUserID . '|' . (CWebDavBase::IsDavHeaders('check_all') ? 'D' : 'W') . '|USERLIST';
     $userCache = new CPHPCache();
     if ($userCache->InitCache($arParams["CACHE_TIME"], $CACHE_ID, $cachePath)) {
         $vars = $userCache->GetVars();
         $userTree = $vars['USER_TREE'];
     } else {
         $arFilter = array("IBLOCK_ID" => $arParams["IBLOCK_USER_ID"], "SOCNET_GROUP_ID" => false, "CHECK_PERMISSIONS" => "N", "SECTION_ID" => 0);
         $dbSection = CIBlockSection::GetList(array(), $arFilter);
         while ($arSection = $dbSection->Fetch()) {
             $userID = $arSection['CREATED_BY'];
             if (!CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $userID, "files")) {
                 continue;
             }
             $userPerms = CIBlockWebdavSocnet::GetUserMaxPermission('user', $userID, $currentUserID, $arParams['IBLOCK_USER_ID']);
             if ($userPerms["PERMISSION"] < "R") {
                 continue;
Example #8
0
		{
			if ($match[3] == '5.0') $serverParams['CLIENT_OS'] = "Windows 2000";
			elseif ($match[3] == '5.1') $serverParams['CLIENT_OS'] = "Windows XP";
			elseif ($match[3] == '5.2') $serverParams['CLIENT_OS'] = "Windows 2003";
			elseif ($match[3] == '6.0' && strpos($client, 'SLCC1') !== false) $serverParams['CLIENT_OS'] = "Windows Vista";
			elseif ($match[3] == '6.0' && strpos($client, 'SLCC2') !== false) $serverParams['CLIENT_OS'] = "Windows 2008";
			elseif ($match[3] == '6.0') $serverParams['CLIENT_OS'] = "Windows Vista"; // may be 2008
			elseif ($match[3] == '6.1') $serverParams['CLIENT_OS'] = "Windows 7";
			else $serverParams['CLIENT_OS'] = "Windows";
		} else {
			$serverParams['CLIENT_OS'] = "Windows";
		}
	}
	elseif (preg_match("/mac/i", $client))
		$serverParams['CLIENT_OS'] = "Mac";
	*/
$clientOS = CWebDavBase::GetClientOS();
if ($clientOS !== null) {
    $serverParams['CLIENT_OS'] = $clientOS;
}
$arResult['serverParams'] = $serverParams;
/********************************************************************
				/Diagnostics
********************************************************************/
if ($arParams["SET_TITLE"] == "Y") {
    $APPLICATION->SetTitle(GetMessage("WD_TITLE"));
}
if ($arParams["DISPLAY_PANEL"] == "Y" && $USER->IsAuthorized() && CModule::IncludeModule("iblock")) {
    CIBlock::ShowPanel($arParams["IBLOCK_ID"], 0, $arParams["SECTION_ID"], $arParams["IBLOCK_TYPE"], false, $this->GetName());
}
$this->IncludeComponentTemplate();
 public static function GetFileForHistory($documentId, $propertyValue, $historyIndex)
 {
     $newFileID = $propertyValue['VALUE'];
     $bNewFile = true;
     $history = self::GetHistoryService();
     $dbDoc = $history->GetHistoryList(array("ID" => "DESC"), array("DOCUMENT_ID" => $documentId), false, false, array("ID", "DOCUMENT_ID", "NAME", "MODIFIED", "USER_ID", "USER_NAME", "USER_LAST_NAME", "USER_LOGIN", "DOCUMENT"));
     $newFileHash = CWebDavBase::_get_file_hash($newFileID);
     $oldFileHash = null;
     if ($newFileHash !== null) {
         if ($dbDoc && ($arTmpDoc = $dbDoc->Fetch())) {
             while ($arDoc = $dbDoc->Fetch()) {
                 $oldFileHash = $arDoc['DOCUMENT']['PROPERTIES']['FILE']['HASH'];
                 if ($oldFileHash == $newFileHash) {
                     $bNewFile = false;
                     $result = $arDoc['DOCUMENT']['PROPERTIES']['FILE'];
                     break;
                 }
             }
         }
     }
     if ($oldFileHash == null || $newFileHash == null) {
         $bNewFile = true;
     }
     // add new copy to history
     if ($bNewFile) {
         $result = array("VALUE" => CBPDocument::PrepareFileForHistory($documentId, $propertyValue["VALUE"], $historyIndex), "DESCRIPTION" => $propertyValue["DESCRIPTION"], "HASH" => $newFileHash);
     }
     return $result;
 }
Example #10
0
    		"Microsoft Office Existence Discovery",
    		"Microsoft-WebDAV-MiniRedir/6.1.7600",
    		"Microsoft Office Core Storage Infrastructure/1.0",
    
    		);
    */
}
if (__webdav_is_dav_headers() && $bNeedInclude) {
    if (CModule::includeModule('ldap') && CLdapUtil::isBitrixVMAuthSupported()) {
        CLdapUtil::bitrixVMAuthorize();
    }
    if (!$_SERVER['PHP_AUTH_USER'] || !$_SERVER['PHP_AUTH_USER']) {
        $res = !empty($_SERVER['REDIRECT_REMOTE_USER']) ? $_SERVER['REDIRECT_REMOTE_USER'] : $_SERVER['REMOTE_USER'];
        if (!empty($res) && preg_match('/(?<=(basic\\s))(.*)$/is', $res, $matches)) {
            $res = trim($matches[0]);
            list($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"]) = explode(':', base64_decode($res));
        }
    }
    if (!is_array($GLOBALS["APPLICATION"]->arComponentMatch)) {
        $GLOBALS["APPLICATION"]->arComponentMatch = array();
    }
    $GLOBALS["APPLICATION"]->arComponentMatch[] = 'webdav';
    $GLOBALS["APPLICATION"]->arComponentMatch[] = 'socialnetwork';
    define("STOP_STATISTICS", true);
    define("NO_AGENT_STATISTIC", "Y");
    define("NO_AGENT_CHECK", true);
    $GLOBALS["APPLICATION"]->ShowPanel = false;
    if (CModule::IncludeModule("webdav")) {
        CWebDavBase::OnBeforeProlog();
    }
}
Example #11
0
 public function getMimeType()
 {
     return CWebDavBase::get_mime_type($this->type['ext']);
 }
 protected function saveNewFile(array $fileData)
 {
     $filename = CTempFile::GetFileName(uniqid('_wd'));
     CheckDirPath($filename);
     $doc = $this->getDocHandler()->downloadFile(array('id' => $this->getFileId(), 'mimeType' => $this->getWebdav()->get_mime_type('1.' . $fileData['createType'])));
     file_put_contents($filename, $doc['content']);
     global $USER;
     $dataUserSection = CWebDavIblock::getRootSectionDataForUser($USER->GetID());
     if (!$dataUserSection) {
         return array('status' => 'error');
     }
     $createdDocFolderId = CIBlockWebdavSocnet::createCreatedDocFolder($dataUserSection['IBLOCK_ID'], $dataUserSection['SECTION_ID'], $USER->GetID());
     if (!$createdDocFolderId) {
         return array('status' => 'error');
     }
     $storage = new CWebDavStorageCore();
     $storage->setStorageId(array('IBLOCK_ID' => $dataUserSection['IBLOCK_ID'], 'IBLOCK_SECTION_ID' => $dataUserSection['SECTION_ID']));
     $nameToSavedFile = $storage->regenerateNameIfNonUnique($doc['name'], $createdDocFolderId);
     $tmpFile = new CWebDavStubTmpFile();
     $tmpFile->path = $filename;
     try {
         $fileData = $storage->addFile($nameToSavedFile, $createdDocFolderId, $tmpFile);
         $response = array('status' => 'success', 'elementId' => $fileData['extra']['id'], 'sectionId' => $fileData['extra']['sectionId'], 'name' => $nameToSavedFile, 'sizeInt' => $fileData['size'], 'type' => CWebDavBase::get_mime_type($nameToSavedFile), 'link' => str_replace('#element_id#', $fileData['extra']['id'], CWebDavSocNetEvent::getRuntime()->arPath['ELEMENT_EDIT_INLINE_URL']), 'nameWithoutExtension' => GetFileNameWithoutExtension($nameToSavedFile));
     } catch (Exception $e) {
         $response = array('status' => 'error');
     }
     return $response;
 }
Example #13
0
 function MakeDavRedirect($ob, $currentPageUrl, $baseURL, $path, $is_root = false)
 {
     global $APPLICATION, $USER;
     if ($ob->IsDavHeaders('check_all') || $_SERVER['REQUEST_METHOD'] == 'DELETE') {
         if (!$USER->IsAuthorized()) {
             $APPLICATION->RestartBuffer();
             CWebDavBase::SetAuthHeader();
             header('Content-length: 0');
             die;
         }
         if (!$ob->CheckWebRights()) {
             $ob->SetStatus('403 Forbidden');
             ShowError(GetMessage("WD_DAV_INSUFFICIENT_RIGHTS"));
             die;
         } elseif (!$ob->IsMethodAllow($_SERVER['REQUEST_METHOD'])) {
             CHTTP::SetStatus('405 Method not allowed');
             header('Allow: ' . join(',', array_keys($ob->allow)));
             ShowError(GetMessage("WD_DAV_UNSUPORTED_METHOD"));
             die;
         } else {
             $APPLICATION->RestartBuffer();
             if (isset($_SERVER['HTTP_DESTINATION'])) {
                 $pu = parse_url(CWebDavBase::get_request_url($_SERVER['HTTP_DESTINATION']));
                 $ob->SetBaseURL($baseURL);
                 $pu['path'] = urldecode($pu['path']);
                 if (strpos($pu['path'], $baseURL) === false) {
                     CHTTP::SetStatus('405 Method not allowed');
                     header('Allow: ' . join(',', array_keys($ob->allow)));
                     ShowError(GetMessage("WD_DAV_UNSUPORTED_METHOD"));
                     die;
                 }
             } else {
                 $ob->SetBaseURL($baseURL);
             }
             $ob->SetPath($path);
             $fn = 'base_' . $_SERVER['REQUEST_METHOD'];
             call_user_func(array(&$ob, $fn));
             die;
         }
     } else {
         $ob->SetBaseURL($baseURL);
         $ob->SetPath(rtrim($path, '/'));
         if ($is_root) {
             return;
         }
         $ob->IsDir();
         if ($ob->arParams['is_file']) {
             $APPLICATION->RestartBuffer();
             $ob->base_GET();
             die;
         } else {
             LocalRedirect($currentPageUrl);
         }
     }
 }
Example #14
0
}
?>

<script>
BX.ready(function() {
	if (BX('WDMappingButton')) {
		BX('WDMappingButton').style.display = 'none';
		if (/*@cc_on ! @*/ false)
		{
			//try {
				//if (new ActiveXObject("SharePoint.OpenDocuments.2"))
				//{
					BX('WDMappingButton').style.display = 'block';
					BX.bind(BX('WDMappingButton'), 'click', function() {
						WDMappingDrive("<?php 
echo CUtil::JSEscape(str_replace(":443", "", CWebDavBase::get_request_url($arParams["BASE_URL"])));
?>
");
						BX.WindowManager.Get().Close();
					});
				//}
			//} catch(e) { }
		}
	}
});

var WDToggleCollapseable = function(link, div)
{
	if (div.style.display != 'block')
	{
		div.style.display = 'block';