public static void Login(Wiki wiki, string username, string password, string fileName) { if (!WikiCache.LoadCookies(wiki, fileName)) { wiki.Login(username, password); WikiCache.CacheCookies(wiki, fileName); } else { wiki.Login(); if (!wiki.IsBot) { wiki.Logout(); wiki.Login(username, password); WikiCache.CacheCookies(wiki, fileName); } } }
public MWFS(string serverUrl, string serverUser, string serverPassword) { wiki = new Wiki("http://"+serverUrl); if (!String.IsNullOrEmpty(serverUser)) { wiki.Login(serverUser, serverPassword); } //Init directories TopDirectory = new Dictionary<string, string>(); TopDirectory["Categories"] = "Categories"; TopDirectory["Main namespace"] = "Main namespace"; TopDirectory["Templates"] = "Templates"; TopDirectory["Forms"] = "Forms"; TopDirectory["Properties"] = "Properties"; DirCache = new Dictionary<string, Dictionary<string, int>>(); DirCache["Categories"] = new Dictionary<string, int>(); DirCache["Main namespace"] = new Dictionary<string, int>(); DirCache["Templates"] = new Dictionary<string, int>(); DirCache["Forms"] = new Dictionary<string, int>(); DirCache["Properties"] = new Dictionary<string, int>(); }
static void welcome() { Console.WriteLine("Please specify mediawiki url (eg: server.com): "); serverUrl = Console.ReadLine(); Console.WriteLine("Please specify login (leave empty for guest):"); serverUser = Console.ReadLine(); if (!String.IsNullOrEmpty(serverUser)) { Console.WriteLine("Please specify password:"******"Connecting to " + serverUrl + " .."); Wiki w; try { w = new Wiki("http://" + serverUrl); if (!String.IsNullOrEmpty(serverUser)) { if (!w.Login(serverUser, serverPassword)) { Console.WriteLine("ERROR: Can not login with specified credentials."); Console.ReadLine(); return; } } } catch (System.Net.WebException) { Console.WriteLine("ERROR: Can not connect to specified host."); Console.ReadLine(); return; } Console.WriteLine("Mediawiki connected, version: " + w.Capabilities.Version); Console.WriteLine("Is logged in: " + w.IsLoggedIn()); Console.WriteLine("Ready to mount, press ENTER key .."); Console.ReadLine(); Console.WriteLine("Mounting remote FS to R:"); w = null; mountFS(); }