Esempio n. 1
0
 /// <remarks/>
 public void UpdateFolderAsync(string siteId, WebFolder folder) {
     this.UpdateFolderAsync(siteId, folder, null);
 }
Esempio n. 2
0
 /// <remarks/>
 public void UpdateFolderAsync(string siteId, WebFolder folder, object userState) {
     if ((this.UpdateFolderOperationCompleted == null)) {
         this.UpdateFolderOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateFolderOperationCompleted);
     }
     this.InvokeAsync("UpdateFolder", new object[] {
                 siteId,
                 folder}, this.UpdateFolderOperationCompleted, userState);
 }
Esempio n. 3
0
 public void UpdateFolder(string siteId, WebFolder folder) {
     this.Invoke("UpdateFolder", new object[] {
                 siteId,
                 folder});
 }
Esempio n. 4
0
 /// <remarks/>
 public System.IAsyncResult BeginUpdateFolder(string siteId, WebFolder folder, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("UpdateFolder", new object[] {
                 siteId,
                 folder}, callback, asyncState);
 }
Esempio n. 5
0
 public int UpdateSecuredFolder(int siteItemId, WebFolder folder)
 {
     object[] results = this.Invoke("UpdateSecuredFolder", new object[] {
                 siteItemId,
                 folder});
     return ((int)(results[0]));
 }
Esempio n. 6
0
 /// <remarks/>
 public void UpdateSecuredFolderAsync(int siteItemId, WebFolder folder)
 {
     this.UpdateSecuredFolderAsync(siteItemId, folder, null);
 }
Esempio n. 7
0
 public void UpdateFolder(string siteId, WebFolder folder)
 {
     try
     {
         Log.WriteStart("'{0}' UpdateFolder", ProviderSettings.ProviderName);
         WebProvider.UpdateFolder(siteId, folder);
         Log.WriteEnd("'{0}' UpdateFolder", ProviderSettings.ProviderName);
     }
     catch (Exception ex)
     {
         Log.WriteError(String.Format("'{0}' UpdateFolder", ProviderSettings.ProviderName), ex);
         throw;
     }
 }
        public static int UpdateFolder(int siteItemId, WebFolder folder)
        {
            // load site item
            WebSite siteItem = (WebSite)PackageController.GetPackageItem(siteItemId);
            if (siteItem == null)
                return BusinessErrorCodes.ERROR_WEB_SITE_PACKAGE_ITEM_NOT_FOUND;

            folder.Path = FilesController.CorrectRelativePath(folder.Path);

            // place log record
            TaskManager.StartTask("WEB_SITE", "UPDATE_SECURED_FOLDER", siteItem.Name);
            TaskManager.ItemId = siteItemId;
            TaskManager.WriteParameter("Folder", folder.Path);

            try
            {
                // update folder
                WebServer web = GetWebServer(siteItem.ServiceId);
                web.UpdateFolder(siteItem.SiteId, folder);

                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
Esempio n. 9
0
		private void UpdateFolder(string siteId, WebFolder folder, bool deleteFolder)
		{
			// file path
			string rootPath = GetSiteContentPath(siteId);
			string normalizedPath = NormalizeFolderPath(folder.Path);

			string path = Path.Combine(rootPath, normalizedPath);
			path = Path.Combine(path, ProtectedAccessFile);

			if (!deleteFolder)
			{
				// create .htaccess file
				List<string> accessLines = new List<string>();

				// title
				if (!String.IsNullOrEmpty(folder.Title))
					accessLines.Add(AUTH_NAME_DIRECTIVE + folder.Title);

				// link to users file
				string usersFile = Path.Combine(rootPath, ProtectedUsersFile);
				if (!File.Exists(usersFile))
					WriteFile(usersFile, new List<string>());
				accessLines.Add(ProtectedUsersFile_DIRECTIVE + usersFile);

				// link to groups file
				string groupsFile = Path.Combine(rootPath, ProtectedGroupsFile);
				if (!File.Exists(groupsFile))
					WriteFile(groupsFile, new List<string>());
				accessLines.Add(ProtectedGroupsFile_DIRECTIVE + groupsFile);

				// require users
				if (folder.Users != null && folder.Users.Length > 0)
					accessLines.Add(REQUIRE_USER_DIRECTIVE + String.Join(" ", folder.Users));

				// require groups
				if (folder.Groups != null && folder.Groups.Length > 0)
					accessLines.Add(REQUIRE_GROUP_DIRECTIVE + String.Join(" ", folder.Groups));

				// write access file
				WriteFile(path, accessLines);
			}
			else
			{
				if (File.Exists(path))
					File.Delete(path);
			}

			// update folders list
			List<WebFolder> folders = GetFolders(siteId);
			List<string> updatedFolders = new List<string>();
			bool exists = false;
			string folderName = "\\" + normalizedPath;
			foreach (WebFolder f in folders)
			{
				if (String.Compare(f.Path, folderName, true) == 0)
				{
					// exists
					exists = true;

					if (deleteFolder)
						continue;
				}

				updatedFolders.Add(f.Path);
			}

			if (!exists && !deleteFolder)
				updatedFolders.Add(folderName);

			// save folders list
			string foldersFile = Path.Combine(rootPath, ProtectedFoldersFile);
			WriteFile(foldersFile, updatedFolders);
		}
Esempio n. 10
0
		public void DeleteFolder(string siteId, string folderPath)
		{
			WebFolder folder = new WebFolder();
			folder.Path = folderPath;

			// delete folder
			UpdateFolder(siteId, folder, true);
		}
Esempio n. 11
0
		public void UpdateFolder(string siteId, WebFolder folder)
		{
			UpdateFolder(siteId, folder, false);
		}
Esempio n. 12
0
		public WebFolder GetFolder(string siteId, string folderPath)
		{
			// read folder file
			string rootPath = GetSiteContentPath(siteId);
			string normalizedPath = NormalizeFolderPath(folderPath);
			string path = Path.Combine(rootPath, normalizedPath);
			path = Path.Combine(path, ProtectedAccessFile);

			List<string> folderLines = ReadFile(path);
			if (folderLines.Count == 0)
				return null;

			// parse file
			WebFolder folder = new WebFolder();
			folder.Path = "\\" + normalizedPath;
			folder.Title = "";
			folder.Users = new string[] { };
			folder.Groups = new string[] { };

			foreach (string line in folderLines)
			{
				string lowerLine = line.ToLower();
				if (lowerLine.StartsWith(AUTH_NAME_DIRECTIVE.ToLower()))
				{
					folder.Title = line.Substring(AUTH_NAME_DIRECTIVE.Length);
					continue;
				}
				else if (lowerLine.StartsWith(REQUIRE_USER_DIRECTIVE.ToLower()))
				{
					string users = line.Substring(REQUIRE_USER_DIRECTIVE.Length);
					folder.Users = users.Split(' ');
					continue;
				}
				else if (lowerLine.StartsWith(REQUIRE_GROUP_DIRECTIVE.ToLower()))
				{
					string groups = line.Substring(REQUIRE_GROUP_DIRECTIVE.Length);
					folder.Groups = groups.Split(' ');
					continue;
				}
			}

			return folder;
		}
Esempio n. 13
0
		public List<WebFolder> GetFolders(string siteId)
		{
			string rootPath = GetSiteContentPath(siteId);
			List<WebFolder> folders = new List<WebFolder>();

			string foldersFile = Path.Combine(rootPath, ProtectedFoldersFile);
			if (File.Exists(foldersFile))
			{
				List<string> list = ReadFile(foldersFile);

				// read the list of secured folders
				foreach (string f in list)
				{
					WebFolder folder = new WebFolder();
					folder.Title = "";
					folder.Path = f;
					folder.Groups = new string[] { };
					folder.Users = new string[] { };
					folders.Add(folder);
				}
			}

			return folders;
		}
Esempio n. 14
0
 public int UpdateSecuredFolder(int siteItemId, WebFolder folder)
 {
     return WebServerController.UpdateFolder(siteItemId, folder);
 }
        private void SaveFolder()
        {
            WebFolder folder = new WebFolder();
            folder.Title = txtTitle.Text.Trim();
            folder.Path = folderPath.SelectedFile;

            List<string> users = new List<string>();
            foreach (ListItem li in dlUsers.Items)
                if (li.Selected)
                    users.Add(li.Value);

            List<string> groups = new List<string>();
            foreach (ListItem li in dlGroups.Items)
                if (li.Selected)
                    groups.Add(li.Value);

            folder.Users = users.ToArray();
            folder.Groups = groups.ToArray();

            try
            {
                int result = ES.Services.WebServers.UpdateSecuredFolder(PanelRequest.ItemID, folder);
                if (result < 0)
                {
                    ShowResultMessage(result);
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("WEB_UPDATE_SECURED_FOLDER", ex);
                return;
            }

            ReturnBack();
        }