Changes to rewriting; Adding Signup
This commit is contained in:
+8
-16
@@ -30,26 +30,18 @@
|
||||
// The culture was once set here for localization, but Mono resets CultureInfo before entering the page cycle.
|
||||
// Setting the CultureInfo has been moved to PageV5Base.OnPreInit().
|
||||
|
||||
// If we've been called as "/Default.aspx", strip it mercilessly and redirect
|
||||
|
||||
/* -- DISABLED -- This didn't work on Mono -- more testing needed
|
||||
|
||||
string callUrl = Request.Url.ToString();
|
||||
|
||||
if (callUrl.EndsWith("/Default.aspx"))
|
||||
{
|
||||
Response.Redirect(callUrl.Substring(0, callUrl.Length - "/Default.aspx".Length), true); // "true" prevents further processing
|
||||
} */
|
||||
|
||||
// TODO: PLUGIN REWRITES
|
||||
|
||||
// Testing for page rewrite. Tests IN ORDER.
|
||||
|
||||
string[] rewriteCandidates =
|
||||
{
|
||||
"{0}/Default.aspx", // for dev.swarmops.com
|
||||
"{0}Default.aspx", // for dev.swarmops.com/
|
||||
"{0}.aspx", // for dev.swarmops.com/Security/Login
|
||||
"/Pages/v5{0}.aspx", // for dev.swarmops.com/User/SelectLanguage
|
||||
"/Pages/v5{0}" // for dev.swarmops.com/Ledgers/Json-SomethingData.aspx
|
||||
"{0}/Default.aspx", // for dev.swarmops.com
|
||||
"{0}Default.aspx", // for dev.swarmops.com/
|
||||
"{0}.aspx", // for dev.swarmops.com/Security/Login
|
||||
"/Pages/v5/Public{0}.aspx", // for dev.swarmops.com/Signup (and others under Public)
|
||||
"/Pages/v5{0}.aspx", // for dev.swarmops.com/User/SelectLanguage
|
||||
"/Pages/v5{0}" // for dev.swarmops.com/Ledgers/Json-SomethingData.aspx
|
||||
};
|
||||
|
||||
foreach (string stringCandidate in rewriteCandidates)
|
||||
|
||||
@@ -1,781 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.Services;
|
||||
using System.Web.SessionState;
|
||||
using System.Web.UI;
|
||||
using Resources;
|
||||
using Swarmops.Common.Enums;
|
||||
using Swarmops.Database;
|
||||
using Swarmops.Logic.Cache;
|
||||
using Swarmops.Logic.Financial;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Support;
|
||||
using Swarmops.Logic.Swarm;
|
||||
using Swarmops.Logic.Automation;
|
||||
using City = Swarmops.Logic.Automation.City;
|
||||
using Country = Swarmops.Logic.Automation.Country;
|
||||
using Geography = Swarmops.Logic.Automation.Geography;
|
||||
using PostalCode = Swarmops.Logic.Automation.PostalCode;
|
||||
|
||||
public partial class Pages_v5_Init_Default : Page
|
||||
{
|
||||
private static SwarmDb.Credentials _testReadCredentials;
|
||||
private static SwarmDb.Credentials _testWriteCredentials;
|
||||
private static SwarmDb.Credentials _testAdminCredentials;
|
||||
private static int _initProgress;
|
||||
private static string _initMessage = "Initializing...";
|
||||
private static readonly Random GetRandom = new Random();
|
||||
private static readonly object syncLock = new object();
|
||||
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
this.ImageCultureIndicator.Style[HtmlTextWriterStyle.MarginTop] = "-3px";
|
||||
this.ImageCultureIndicator.Style[HtmlTextWriterStyle.MarginRight] = "3px";
|
||||
this.ImageCultureIndicator.Style[HtmlTextWriterStyle.Cursor] = "pointer";
|
||||
|
||||
this.TextCredentialsReadDatabase.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsReadServer.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsReadUser.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsReadPassword.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
|
||||
this.TextCredentialsWriteDatabase.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsWriteServer.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsWriteUser.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsWritePassword.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
|
||||
this.TextCredentialsAdminDatabase.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsAdminServer.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsAdminUser.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsAdminPassword.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
|
||||
this.DropFavoriteColor.Style[HtmlTextWriterStyle.Width] = "155px";
|
||||
|
||||
// this.LanguageSelector.LanguageChanged += new EventHandler(LanguageSelector_LanguageChanged);
|
||||
|
||||
Localize();
|
||||
}
|
||||
|
||||
protected override void OnPreInit (EventArgs e)
|
||||
{
|
||||
// This OnPreInit is copied from master page base
|
||||
|
||||
// Localization
|
||||
|
||||
string preferredCulture = "en-US";
|
||||
|
||||
// ----------- SET CULTURE ------------
|
||||
|
||||
// Does the user have a culture preference?
|
||||
|
||||
if (Request.Cookies["PreferredCulture"] != null)
|
||||
{
|
||||
// Yes, set it
|
||||
preferredCulture = Request.Cookies["PreferredCulture"].Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No, determine from browser
|
||||
string browserPreference = "en-GB";
|
||||
if (Request.UserLanguages != null && Request.UserLanguages.Length > 0)
|
||||
{
|
||||
browserPreference = Request.UserLanguages[0];
|
||||
preferredCulture = browserPreference;
|
||||
}
|
||||
|
||||
if (preferredCulture == "en-US")
|
||||
{
|
||||
preferredCulture = "en-GB"; // Hack because of malfunctioning Telerik popup
|
||||
}
|
||||
|
||||
/*
|
||||
string[] languages = (string[])Application["Cultures"];
|
||||
for (int index = 0; index < languages.Length; index++)
|
||||
{
|
||||
if (languages[index].StartsWith(browserPreference))
|
||||
{
|
||||
preferredCulture = languages[index];
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
GregorianCalendar normalizedCalendar = new GregorianCalendar();
|
||||
normalizedCalendar.CalendarType = GregorianCalendarTypes.USEnglish;
|
||||
|
||||
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture (preferredCulture);
|
||||
Thread.CurrentThread.CurrentCulture.DateTimeFormat.Calendar = normalizedCalendar;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new Exception ("Could not set culture \"" + preferredCulture + "\"", exception);
|
||||
// Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
|
||||
}
|
||||
|
||||
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
|
||||
|
||||
base.OnPreInit (e);
|
||||
}
|
||||
|
||||
public event EventHandler LanguageChanged;
|
||||
|
||||
private void LanguageSelector_LanguageChanged (object sender, EventArgs e)
|
||||
{
|
||||
// Received event from control - refire
|
||||
|
||||
if (LanguageChanged != null)
|
||||
{
|
||||
LanguageChanged (this, new EventArgs());
|
||||
}
|
||||
|
||||
Localize();
|
||||
}
|
||||
|
||||
|
||||
private void Localize()
|
||||
{
|
||||
this.LabelCurrentUserName.Text = Resources.Pages.Init.Init_UserInfo_InstallingAdmin;
|
||||
this.LabelCurrentOrganizationName.Text = Resources.Pages.Init.Init_UserInfo_NoOrgsYet;
|
||||
this.LabelPreferences.Text = Global.CurrentUserInfo_Preferences;
|
||||
this.LabelSidebarInfoHeader.Text = Global.Sidebar_Information;
|
||||
this.LabelSidebarInfoContent.Text = Resources.Pages.Init.Init_SidebarInfo_Welcome;
|
||||
this.LabelSidebarActionsHeader.Text = Global.Sidebar_Actions;
|
||||
this.LabelSidebarActionsContent.Text = Resources.Pages.Init.Init_SidebarActions_None;
|
||||
this.LabelSidebarTodoHeader.Text = Global.Sidebar_Todo;
|
||||
this.LabelSidebarTodoConnectDatabase.Text = Resources.Pages.Init.Init_SidebarTodo_CompleteSetup;
|
||||
|
||||
this.DropFavoriteColor.Items.Clear();
|
||||
this.DropFavoriteColor.Items.Add (" -- Select one --");
|
||||
this.DropFavoriteColor.Items.Add ("Blue!");
|
||||
this.DropFavoriteColor.Items.Add ("No, wait, yellow!");
|
||||
|
||||
// SetupMenuItems();
|
||||
|
||||
string flagName = "uk";
|
||||
|
||||
string cultureString = Thread.CurrentThread.CurrentCulture.ToString();
|
||||
string cultureStringLower = cultureString.ToLowerInvariant();
|
||||
|
||||
if (cultureStringLower != "en-gb" && cultureString.Length > 3)
|
||||
{
|
||||
flagName = cultureStringLower.Substring (3);
|
||||
}
|
||||
this.ImageCultureIndicator.ImageUrl = "~/Images/Flags/" + flagName + "-24px.png";
|
||||
}
|
||||
|
||||
|
||||
[WebMethod]
|
||||
public static bool CreateDatabaseFromRoot (string mysqlHostName, string rootPassword, string serverName, string ipAddress)
|
||||
{
|
||||
if (!(VerifyHostName(serverName) && VerifyHostAddress(ipAddress)))
|
||||
{
|
||||
if (!Debugger.IsAttached)
|
||||
{
|
||||
return true; // Probable hack attempt - fail silently
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string random = Authentication.CreateRandomPassword(5);
|
||||
|
||||
SwarmDb.Credentials rootCredentials = new SwarmDb.Credentials("mysql", new SwarmDb.ServerSet(mysqlHostName), "root", rootPassword);
|
||||
|
||||
string readPass = GenerateLongPassword();
|
||||
string writePass = GenerateLongPassword();
|
||||
string adminPass = GenerateLongPassword();
|
||||
|
||||
string[] initInstructions =
|
||||
DbCreateScript.Replace ("[random]", random)
|
||||
.Replace ("[readpass]", readPass)
|
||||
.Replace ("[writepass]", writePass)
|
||||
.Replace ("[adminpass]", adminPass).Split ('#');
|
||||
|
||||
SwarmDb.GetTestDatabase (rootCredentials).ExecuteAdminCommands (initInstructions);
|
||||
|
||||
PermissionsAnalysis permissionsResult = FirstCredentialsTest (
|
||||
"Swarmops-" + random, mysqlHostName, "Swarmops-R-" + random, readPass,
|
||||
"Swarmops-" + random, mysqlHostName, "Swarmops-W-" + random, writePass,
|
||||
"Swarmops-" + random, mysqlHostName, "Swarmops-A-" + random, adminPass,
|
||||
serverName, ipAddress);
|
||||
|
||||
if (!permissionsResult.AllPermissionsOk)
|
||||
{
|
||||
throw new InvalidOperationException("waaaaaah");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const string DbCreateScript =
|
||||
"CREATE DATABASE `Swarmops-[random]`#" +
|
||||
"CREATE USER `Swarmops-R-[random]` IDENTIFIED BY '[readpass]'#" +
|
||||
"CREATE USER `Swarmops-W-[random]` IDENTIFIED BY '[writepass]'#" +
|
||||
"CREATE USER `Swarmops-A-[random]` IDENTIFIED BY '[adminpass]'#" +
|
||||
"GRANT SELECT ON mysql.proc TO `Swarmops-W-[random]`#" +
|
||||
"GRANT SELECT ON mysql.proc TO `Swarmops-A-[random]`#" +
|
||||
"USE `Swarmops-[random]`#" +
|
||||
"GRANT ALL ON `Swarmops-[random]`.* TO `Swarmops-A-[random]`#" +
|
||||
"GRANT SELECT ON `Swarmops-[random]`.* TO `Swarmops-W-[random]`#" +
|
||||
"GRANT EXECUTE ON `Swarmops-[random]`.* TO `Swarmops-W-[random]`#" +
|
||||
"GRANT SELECT ON `Swarmops-[random]`.* TO `Swarmops-R-[random]`#" +
|
||||
"FLUSH PRIVILEGES";
|
||||
|
||||
|
||||
|
||||
static private string GenerateLongPassword()
|
||||
{
|
||||
return Guid.NewGuid().ToString ("N") + Guid.NewGuid().ToString ("N");
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public static PermissionsAnalysis FirstCredentialsTest
|
||||
(string readDatabase, string readServer, string readUser, string readPassword,
|
||||
string writeDatabase, string writeServer, string writeUser, string writePassword,
|
||||
string adminDatabase, string adminServer, string adminUser, string adminPassword,
|
||||
string serverName, string ipAddress)
|
||||
{
|
||||
if (!(VerifyHostName (serverName) && VerifyHostAddress (ipAddress)))
|
||||
{
|
||||
if (!Debugger.IsAttached)
|
||||
{
|
||||
return null; // Probable hack attempt - fail silently
|
||||
}
|
||||
}
|
||||
|
||||
_testReadCredentials = new SwarmDb.Credentials (
|
||||
readDatabase, new SwarmDb.ServerSet (readServer), readUser, readPassword);
|
||||
_testWriteCredentials = new SwarmDb.Credentials (
|
||||
writeDatabase, new SwarmDb.ServerSet (writeServer), writeUser, writePassword);
|
||||
_testAdminCredentials = new SwarmDb.Credentials (
|
||||
adminDatabase, new SwarmDb.ServerSet (adminServer), adminUser, adminPassword);
|
||||
|
||||
return RecheckDatabasePermissions(); // Subsequent tests only call this function
|
||||
}
|
||||
|
||||
|
||||
[WebMethod (true)]
|
||||
public static void ResetTestCredentials()
|
||||
{
|
||||
_testReadCredentials =
|
||||
_testWriteCredentials =
|
||||
_testAdminCredentials = null;
|
||||
}
|
||||
|
||||
|
||||
[WebMethod (true)]
|
||||
public static PermissionsAnalysis RecheckDatabasePermissions()
|
||||
{
|
||||
while (_testReadCredentials == null || _testWriteCredentials == null || _testAdminCredentials == null)
|
||||
{
|
||||
Thread.Sleep (100);
|
||||
// A couple of async race conditions happen as this is called, we need to wait for credentials
|
||||
}
|
||||
|
||||
PermissionsAnalysis result = new PermissionsAnalysis();
|
||||
|
||||
// First, test ADMIN
|
||||
|
||||
SwarmDb adminDb = SwarmDb.GetTestDatabase (_testAdminCredentials);
|
||||
|
||||
// Drop table, procedure first just in case there's garbage left behind. Ignore result.
|
||||
adminDb.TestDropTable();
|
||||
adminDb.TestDropProcedure();
|
||||
|
||||
// All these should pass.
|
||||
result.AdminCredentialsCanLogin = adminDb.TestLogin();
|
||||
result.AdminCredentialsCanAdmin = adminDb.TestCreateTable();
|
||||
result.AdminCredentialsCanAdmin &= adminDb.TestDropTable();
|
||||
result.AdminCredentialsCanAdmin &= adminDb.TestCreateTable();
|
||||
result.AdminCredentialsCanAdmin &= adminDb.TestAlterTable();
|
||||
result.AdminCredentialsCanAdmin &= adminDb.TestCreateProcedure(); // AND -- all must succeed
|
||||
result.AdminCredentialsCanAdmin &= adminDb.TestDropProcedure();
|
||||
// Test DROP before we mess up the state of the table, procedure
|
||||
result.AdminCredentialsCanAdmin &= adminDb.TestCreateProcedure(); // therefore, recreate it after the drop
|
||||
|
||||
if (result.AdminCredentialsCanAdmin) // if we have a created table and procedure, otherwise default fail
|
||||
{
|
||||
result.AdminCredentialsCanExecute = adminDb.TestExecute ("Admin Execute");
|
||||
result.AdminCredentialsCanSelect = adminDb.TestSelect();
|
||||
}
|
||||
|
||||
// Within the created table, test WRITE and READ accounts before testing them on excessive rights.
|
||||
|
||||
SwarmDb writeDb = SwarmDb.GetTestDatabase (_testWriteCredentials);
|
||||
|
||||
result.WriteCredentialsCanLogin = writeDb.TestLogin();
|
||||
|
||||
if (result.WriteCredentialsCanLogin && result.AdminCredentialsCanAdmin)
|
||||
{
|
||||
result.WriteCredentialsCanExecute = writeDb.TestExecute ("Write Execute");
|
||||
result.WriteCredentialsCanSelect = writeDb.TestSelect();
|
||||
}
|
||||
|
||||
SwarmDb readDb = SwarmDb.GetTestDatabase (_testReadCredentials);
|
||||
|
||||
result.ReadCredentialsCanLogin = readDb.TestLogin();
|
||||
|
||||
if (result.ReadCredentialsCanLogin && result.AdminCredentialsCanAdmin)
|
||||
{
|
||||
result.ReadCredentialsCanExecute = readDb.TestExecute ("Read Execute");
|
||||
result.ReadCredentialsCanSelect = readDb.TestSelect();
|
||||
}
|
||||
|
||||
// Finally, test the write and read accounts for admin rights. Note the "OR" here rather than "AND" -
|
||||
// any one of these rights present should return a true, because it's a fail.
|
||||
|
||||
if (result.ReadCredentialsCanLogin)
|
||||
{
|
||||
result.ReadCredentialsCanAdmin = readDb.TestDropProcedure();
|
||||
result.ReadCredentialsCanAdmin |= readDb.TestDropTable();
|
||||
result.ReadCredentialsCanAdmin |= readDb.TestCreateTable();
|
||||
result.ReadCredentialsCanAdmin |= readDb.TestCreateProcedure();
|
||||
}
|
||||
|
||||
if (result.WriteCredentialsCanLogin)
|
||||
{
|
||||
result.WriteCredentialsCanAdmin = writeDb.TestDropProcedure();
|
||||
result.WriteCredentialsCanAdmin |= writeDb.TestDropTable();
|
||||
result.WriteCredentialsCanAdmin |= writeDb.TestCreateTable();
|
||||
result.WriteCredentialsCanAdmin |= writeDb.TestCreateProcedure();
|
||||
}
|
||||
|
||||
// Clean up
|
||||
|
||||
adminDb.TestDropTable(); // ignore result
|
||||
adminDb.TestDropProcedure();
|
||||
|
||||
result.AllPermissionsOk =
|
||||
result.AdminCredentialsCanLogin &&
|
||||
result.AdminCredentialsCanSelect &&
|
||||
result.AdminCredentialsCanExecute &&
|
||||
result.AdminCredentialsCanAdmin &&
|
||||
result.WriteCredentialsCanLogin &&
|
||||
result.WriteCredentialsCanSelect &&
|
||||
result.WriteCredentialsCanExecute &&
|
||||
!result.WriteCredentialsCanAdmin && // not this
|
||||
result.ReadCredentialsCanLogin &&
|
||||
result.ReadCredentialsCanSelect &&
|
||||
!result.ReadCredentialsCanExecute && // not this
|
||||
!result.ReadCredentialsCanAdmin; // not this
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
[WebMethod (true)]
|
||||
public static void InitDatabase()
|
||||
{
|
||||
// Make sure we're uninitialized
|
||||
|
||||
bool organizationOneExists = false;
|
||||
Organization organizationOne = null;
|
||||
|
||||
try
|
||||
{
|
||||
organizationOne = Organization.FromIdentity (1);
|
||||
organizationOneExists = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// We expect this to throw
|
||||
}
|
||||
|
||||
if (organizationOneExists || organizationOne != null)
|
||||
{
|
||||
throw new InvalidOperationException ("Cannot re-initialize database");
|
||||
}
|
||||
|
||||
// Store database credentials
|
||||
|
||||
SwarmDb.Configuration.Set (
|
||||
new SwarmDb.Configuration (
|
||||
_testReadCredentials,
|
||||
_testWriteCredentials,
|
||||
_testAdminCredentials));
|
||||
|
||||
// SECURITY: Set machine token crypto keys to randomized values
|
||||
|
||||
if (!Debugger.IsAttached) // (but not while debugging in a non-live environment)
|
||||
{
|
||||
string machineKeyXml =
|
||||
"<?xml version=\"1.0\" ?>\n" +
|
||||
"<!--\n" +
|
||||
" The MachineKey is the key used to encrypt/decrypt the cookie containing\n" +
|
||||
" authentication information. When you have multiple front-end web servers\n" +
|
||||
" serving a single Swarmops installation, this key must be identical on\n" +
|
||||
" all front-end machines - otherwise, authentication won't follow from\n" +
|
||||
" one server to the next.\n\n" +
|
||||
" This particular MachineKey was randomized at the time of initial\n" +
|
||||
" installation of this Swarmops database, and is unique. If you have\n" +
|
||||
" multiple front-ends, you need to copy this file to /etc/swarmops\n" +
|
||||
" on each of them.\n" +
|
||||
"-->\n" +
|
||||
GetMachineKey() + "\n";
|
||||
|
||||
File.WriteAllText ("/etc/swarmops/machineKey.config", machineKeyXml, Encoding.GetEncoding (1252));
|
||||
}
|
||||
|
||||
// Start an async thread that does all the initialization work, then return
|
||||
|
||||
Thread initThread = new Thread (InitDatabaseThread);
|
||||
initThread.Start();
|
||||
}
|
||||
|
||||
|
||||
private static string GetMachineKey()
|
||||
{
|
||||
StringBuilder machineKey = new StringBuilder();
|
||||
machineKey.Append("<machineKey \n");
|
||||
machineKey.Append("validationKey=\"" + SupportFunctions.GenerateSecureRandomKey (64) + "\"\n");
|
||||
machineKey.Append("decryptionKey=\"" + SupportFunctions.GenerateSecureRandomKey (32) + "\"\n");
|
||||
machineKey.Append("validation=\"HMACSHA512\" decryption=\"AES\"\n");
|
||||
machineKey.Append("/>\n");
|
||||
return machineKey.ToString();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This function copies the schemas and geography data off an existing Swarmops installation. Runs in its own thread.
|
||||
/// </summary>
|
||||
public static void InitDatabaseThread()
|
||||
{
|
||||
// Ignore the session object, that method of sharing data didn't work, but a static variable did.
|
||||
|
||||
_initProgress = 1;
|
||||
_initMessage = "Loading schema from Swarmops servers; creating tables and procs...";
|
||||
Thread.Sleep (100);
|
||||
|
||||
try
|
||||
{
|
||||
// Get the schema and initialize the database structures. Requires ADMIN access to database.
|
||||
|
||||
DatabaseMaintenance.FirstInitialization();
|
||||
|
||||
_initProgress = 3;
|
||||
_initMessage = "Applying all post-baseline database schema upgrades...";
|
||||
DatabaseMaintenance.UpgradeSchemata();
|
||||
Thread.Sleep (100);
|
||||
|
||||
_initProgress = 5;
|
||||
_initMessage = "Getting list of countries from Swarmops servers...";
|
||||
Thread.Sleep (100);
|
||||
|
||||
// Create translation lists
|
||||
|
||||
Dictionary<string, int> countryIdTranslation = new Dictionary<string, int>();
|
||||
|
||||
// Initialize the root geography (which becomes #1 if everything works)
|
||||
|
||||
int rootGeographyId = SwarmDb.GetDatabaseForWriting().CreateGeography ("[LOC]World", 0);
|
||||
|
||||
// Get the list of countries
|
||||
|
||||
GetGeographyData geoDataFetcher = new GetGeographyData();
|
||||
|
||||
Country[] countries = geoDataFetcher.GetCountries();
|
||||
|
||||
_initProgress = 7;
|
||||
_initMessage = "Creating all countries on local server...";
|
||||
Thread.Sleep (100);
|
||||
int count = 0;
|
||||
int total = countries.Length;
|
||||
|
||||
// Create all countries in our own database
|
||||
|
||||
foreach (Country country in countries)
|
||||
{
|
||||
countryIdTranslation[country.Code] = SwarmDb.GetDatabaseForWriting().CreateCountry (country.Name,
|
||||
country.Code,
|
||||
country.Culture,
|
||||
rootGeographyId, country.PostalCodeLength,
|
||||
string.Empty);
|
||||
|
||||
count++;
|
||||
_initMessage = String.Format ("Creating all countries on local server... ({0}%)", count*100/total);
|
||||
}
|
||||
|
||||
_initProgress = 10;
|
||||
|
||||
// Construct list of countries that have geographic data
|
||||
|
||||
List<string> initializableCountries = new List<string>();
|
||||
|
||||
foreach (Country country in countries)
|
||||
{
|
||||
if (country.GeographyId != 1)
|
||||
{
|
||||
initializableCountries.Add (country.Code);
|
||||
}
|
||||
}
|
||||
|
||||
float initStepPerCountry = 90f/initializableCountries.Count;
|
||||
int countryCount = 0;
|
||||
|
||||
// For each country...
|
||||
|
||||
foreach (string countryCode in initializableCountries)
|
||||
{
|
||||
// Get the geography layout
|
||||
|
||||
_initMessage = "Initializing geography for country " + countryCode + "... ";
|
||||
Thread.Sleep (100);
|
||||
|
||||
GeographyUpdate.PrimeCountry (countryCode);
|
||||
GuidCache.Set ("DbInitProgress", string.Empty);
|
||||
|
||||
countryCount++;
|
||||
|
||||
_initProgress = 10 + (int) (countryCount*initStepPerCountry);
|
||||
}
|
||||
|
||||
// Set Geography at baseline (TODO: Ask for what baseline we got)
|
||||
|
||||
Persistence.Key["LastGeographyUpdateId"] = "0";
|
||||
Persistence.Key["LastGeographyUpdate"] = "1900-01-01";
|
||||
|
||||
// Set an installation ID
|
||||
|
||||
Persistence.Key["SwarmopsInstallationId"] = Guid.NewGuid().ToString();
|
||||
|
||||
_initMessage = "Initializing currencies...";
|
||||
|
||||
// Create initial currencies (European et al)
|
||||
|
||||
Currency.Create ("EUR", "Euros", "€");
|
||||
Currency.Create ("USD", "US Dollars", "$");
|
||||
Currency.Create ("CAD", "Canadian Dollars", "CA$");
|
||||
Currency.Create ("SEK", "Swedish Krona", string.Empty);
|
||||
Currency.Create ("NOK", "Norwegian Krona", string.Empty);
|
||||
Currency.Create ("DKK", "Danish Krona", string.Empty);
|
||||
Currency.Create ("ISK", "Icelandic Krona", string.Empty);
|
||||
Currency.Create ("CHF", "Swiss Franc", string.Empty);
|
||||
Currency.Create ("GBP", "Pounds Sterling", "£");
|
||||
Currency.Create ("BTC", "Bitcoin", "฿");
|
||||
|
||||
// Fetch the first set of exchange rates, completing the currency collection
|
||||
|
||||
ExchangeRateSnapshot.Create();
|
||||
|
||||
// Create the sandbox
|
||||
|
||||
Organization.Create (0, "Sandbox", "Sandbox", "Sandbox", "swarmops.com", "Ops",
|
||||
rootGeographyId, true,
|
||||
true, 0).EnableEconomy (Currency.FromCode ("EUR"));
|
||||
|
||||
_initProgress = 100;
|
||||
_initMessage = "Complete.";
|
||||
}
|
||||
catch (Exception failedException)
|
||||
{
|
||||
// Use initMessage to push info about what went wrong to the user
|
||||
|
||||
_initMessage = failedException.ToString();
|
||||
}
|
||||
|
||||
Thread.Sleep (1000); // give some time for static var to stick and web interface to react before killing thread
|
||||
}
|
||||
|
||||
|
||||
[WebMethod]
|
||||
public static int GetInitProgress()
|
||||
{
|
||||
HttpSessionState state = HttpContext.Current.Session;
|
||||
object progressObject = state["PercentInitComplete"];
|
||||
|
||||
try
|
||||
{
|
||||
int progress = (int) HttpContext.Current.Session["PercentInitComplete"];
|
||||
|
||||
return progress;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return _initProgress;
|
||||
}
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public static string GetInitProgressMessage()
|
||||
{
|
||||
return _initMessage + GuidCache.Get ("DbInitProgress");
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public static bool VerifyHostName (string input)
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
return true; // Cannot read "/etc/hostname" in Windows environment
|
||||
}
|
||||
|
||||
// validate against /etc/hostname
|
||||
|
||||
string realHostName;
|
||||
|
||||
using (TextReader reader = new StreamReader ("/etc/hostname")) // This will throw in a Windows dev environment
|
||||
{
|
||||
realHostName = reader.ReadLine();
|
||||
}
|
||||
|
||||
if (String.Compare (input, realHostName, true, CultureInfo.InvariantCulture) == 0) // case-insensitive compare
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[WebMethod (true)]
|
||||
public static bool VerifyHostAddress (string input)
|
||||
{
|
||||
string localAddress = HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"];
|
||||
|
||||
if (input == localAddress)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[WebMethod (true)]
|
||||
public static bool VerifyHostNameAndAddress (string name, string address)
|
||||
{
|
||||
if (Path.DirectorySeparatorChar == '\\')
|
||||
{
|
||||
// Running in development mode on Windows, so accept any response
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return VerifyHostName (HttpUtility.UrlDecode (name)) && VerifyHostAddress (HttpUtility.UrlDecode (address));
|
||||
}
|
||||
|
||||
[WebMethod (true)]
|
||||
public static bool IsConfigurationFileWritable()
|
||||
{
|
||||
return SwarmDb.Configuration.TestConfigurationWritable();
|
||||
}
|
||||
|
||||
|
||||
private static bool RandomBool()
|
||||
{
|
||||
return (GetRandomNumber (0, 1) == 0);
|
||||
}
|
||||
|
||||
//Function to get random number
|
||||
|
||||
private static int GetRandomNumber (int min, int max)
|
||||
{
|
||||
lock (syncLock)
|
||||
{
|
||||
// synchronize
|
||||
return GetRandom.Next (min, max + 1);
|
||||
}
|
||||
}
|
||||
|
||||
[WebMethod (true)]
|
||||
public static void CreateFirstUser (string name, string mail, string password)
|
||||
{
|
||||
// Make sure that no first person exists already, as a security measure
|
||||
|
||||
Person personOne = null;
|
||||
bool personOneExists = false;
|
||||
|
||||
try
|
||||
{
|
||||
personOne = Person.FromIdentity (1);
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
if (personOne.CityName != "Duckville" || personOne.Mail != "noreply@example.com")
|
||||
// these values are returned in debug environments when no person is found
|
||||
{
|
||||
personOneExists = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
personOne = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
personOneExists = true;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// We expect this to throw.
|
||||
}
|
||||
|
||||
if (personOneExists || personOne != null)
|
||||
{
|
||||
throw new InvalidOperationException ("Cannot run initialization processes again when initialized.");
|
||||
}
|
||||
|
||||
Person newPerson = Person.Create (HttpUtility.UrlDecode (name),
|
||||
HttpUtility.UrlDecode (mail),
|
||||
HttpUtility.UrlDecode (password), string.Empty, string.Empty, string.Empty,
|
||||
string.Empty, string.Empty, DateTime.MinValue, PersonGender.Unknown);
|
||||
|
||||
newPerson.AddMembership (1, DateTime.MaxValue); // Add membership in Sandbox
|
||||
newPerson.AddRole (RoleType.SystemAdmin, 0, 0); // Add role System Admin
|
||||
}
|
||||
|
||||
|
||||
protected void ButtonLogin_Click (object sender, EventArgs args)
|
||||
{
|
||||
// Check the host names and addresses again as a security measure - after all, we can be called from outside our intended script
|
||||
|
||||
if (!(VerifyHostName (this.TextServerName.Text) && VerifyHostAddress (this.TextServerAddress.Text)))
|
||||
{
|
||||
if (!Debugger.IsAttached)
|
||||
{
|
||||
return; // Probable hack attempt - fail silently
|
||||
}
|
||||
}
|
||||
|
||||
Person expectedPersonOne = Authentication.Authenticate ("1",
|
||||
this.TextFirstUserPassword1.Text);
|
||||
|
||||
if (expectedPersonOne != null)
|
||||
{
|
||||
FormsAuthentication.RedirectFromLoginPage ("1,1", true);
|
||||
Response.Redirect ("/", true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class PermissionsAnalysis
|
||||
{
|
||||
public bool AllPermissionsOk { get; set; }
|
||||
public bool ReadCredentialsCanLogin { get; set; }
|
||||
public bool ReadCredentialsCanSelect { get; set; }
|
||||
public bool ReadCredentialsCanExecute { get; set; }
|
||||
public bool ReadCredentialsCanAdmin { get; set; }
|
||||
public bool WriteCredentialsCanLogin { get; set; }
|
||||
public bool WriteCredentialsCanSelect { get; set; }
|
||||
public bool WriteCredentialsCanExecute { get; set; }
|
||||
public bool WriteCredentialsCanAdmin { get; set; }
|
||||
public bool AdminCredentialsCanLogin { get; set; }
|
||||
public bool AdminCredentialsCanSelect { get; set; }
|
||||
public bool AdminCredentialsCanExecute { get; set; }
|
||||
public bool AdminCredentialsCanAdmin { get; set; }
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,789 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.Services;
|
||||
using System.Web.SessionState;
|
||||
using System.Web.UI;
|
||||
using Resources;
|
||||
using Swarmops.Common.Enums;
|
||||
using Swarmops.Database;
|
||||
using Swarmops.Logic.Cache;
|
||||
using Swarmops.Logic.Financial;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Support;
|
||||
using Swarmops.Logic.Swarm;
|
||||
using Swarmops.Logic.Automation;
|
||||
using City = Swarmops.Logic.Automation.City;
|
||||
using Country = Swarmops.Logic.Automation.Country;
|
||||
using Geography = Swarmops.Logic.Automation.Geography;
|
||||
using PostalCode = Swarmops.Logic.Automation.PostalCode;
|
||||
|
||||
namespace Swarmops.Frontend.Pages.v5.Public
|
||||
{
|
||||
public partial class Initialize : Page
|
||||
{
|
||||
private static SwarmDb.Credentials _testReadCredentials;
|
||||
private static SwarmDb.Credentials _testWriteCredentials;
|
||||
private static SwarmDb.Credentials _testAdminCredentials;
|
||||
private static int _initProgress;
|
||||
private static string _initMessage = "Initializing...";
|
||||
private static readonly Random GetRandom = new Random();
|
||||
private static readonly object syncLock = new object();
|
||||
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
this.ImageCultureIndicator.Style[HtmlTextWriterStyle.MarginTop] = "-3px";
|
||||
this.ImageCultureIndicator.Style[HtmlTextWriterStyle.MarginRight] = "3px";
|
||||
this.ImageCultureIndicator.Style[HtmlTextWriterStyle.Cursor] = "pointer";
|
||||
|
||||
this.TextCredentialsReadDatabase.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsReadServer.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsReadUser.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsReadPassword.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
|
||||
this.TextCredentialsWriteDatabase.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsWriteServer.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsWriteUser.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsWritePassword.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
|
||||
this.TextCredentialsAdminDatabase.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsAdminServer.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsAdminUser.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
this.TextCredentialsAdminPassword.Style[HtmlTextWriterStyle.Width] = "70px";
|
||||
|
||||
this.DropFavoriteColor.Style[HtmlTextWriterStyle.Width] = "155px";
|
||||
|
||||
// this.LanguageSelector.LanguageChanged += new EventHandler(LanguageSelector_LanguageChanged);
|
||||
|
||||
Localize();
|
||||
}
|
||||
|
||||
protected override void OnPreInit (EventArgs e)
|
||||
{
|
||||
// This OnPreInit is copied from master page base
|
||||
|
||||
// Localization
|
||||
|
||||
string preferredCulture = "en-US";
|
||||
|
||||
// ----------- SET CULTURE ------------
|
||||
|
||||
// Does the user have a culture preference?
|
||||
|
||||
if (Request.Cookies["PreferredCulture"] != null)
|
||||
{
|
||||
// Yes, set it
|
||||
preferredCulture = Request.Cookies["PreferredCulture"].Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No, determine from browser
|
||||
string browserPreference = "en-GB";
|
||||
if (Request.UserLanguages != null && Request.UserLanguages.Length > 0)
|
||||
{
|
||||
browserPreference = Request.UserLanguages[0];
|
||||
preferredCulture = browserPreference;
|
||||
}
|
||||
|
||||
if (preferredCulture == "en-US")
|
||||
{
|
||||
preferredCulture = "en-GB"; // Hack because of malfunctioning Telerik popup
|
||||
}
|
||||
|
||||
/*
|
||||
string[] languages = (string[])Application["Cultures"];
|
||||
for (int index = 0; index < languages.Length; index++)
|
||||
{
|
||||
if (languages[index].StartsWith(browserPreference))
|
||||
{
|
||||
preferredCulture = languages[index];
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
GregorianCalendar normalizedCalendar = new GregorianCalendar();
|
||||
normalizedCalendar.CalendarType = GregorianCalendarTypes.USEnglish;
|
||||
|
||||
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture (preferredCulture);
|
||||
Thread.CurrentThread.CurrentCulture.DateTimeFormat.Calendar = normalizedCalendar;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new Exception ("Could not set culture \"" + preferredCulture + "\"", exception);
|
||||
// Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
|
||||
}
|
||||
|
||||
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
|
||||
|
||||
base.OnPreInit (e);
|
||||
}
|
||||
|
||||
public event EventHandler LanguageChanged;
|
||||
|
||||
private void LanguageSelector_LanguageChanged (object sender, EventArgs e)
|
||||
{
|
||||
// Received event from control - refire
|
||||
|
||||
if (LanguageChanged != null)
|
||||
{
|
||||
LanguageChanged (this, new EventArgs());
|
||||
}
|
||||
|
||||
Localize();
|
||||
}
|
||||
|
||||
|
||||
private void Localize()
|
||||
{
|
||||
this.LabelCurrentUserName.Text = Resources.Pages.Init.Init_UserInfo_InstallingAdmin;
|
||||
this.LabelCurrentOrganizationName.Text = Resources.Pages.Init.Init_UserInfo_NoOrgsYet;
|
||||
this.LabelPreferences.Text = Global.CurrentUserInfo_Preferences;
|
||||
this.LabelSidebarInfoHeader.Text = Global.Sidebar_Information;
|
||||
this.LabelSidebarInfoContent.Text = Resources.Pages.Init.Init_SidebarInfo_Welcome;
|
||||
this.LabelSidebarActionsHeader.Text = Global.Sidebar_Actions;
|
||||
this.LabelSidebarActionsContent.Text = Resources.Pages.Init.Init_SidebarActions_None;
|
||||
this.LabelSidebarTodoHeader.Text = Global.Sidebar_Todo;
|
||||
this.LabelSidebarTodoConnectDatabase.Text = Resources.Pages.Init.Init_SidebarTodo_CompleteSetup;
|
||||
|
||||
this.DropFavoriteColor.Items.Clear();
|
||||
this.DropFavoriteColor.Items.Add (" -- Select one --");
|
||||
this.DropFavoriteColor.Items.Add ("Blue!");
|
||||
this.DropFavoriteColor.Items.Add ("No, wait, yellow!");
|
||||
|
||||
// SetupMenuItems();
|
||||
|
||||
string flagName = "uk";
|
||||
|
||||
string cultureString = Thread.CurrentThread.CurrentCulture.ToString();
|
||||
string cultureStringLower = cultureString.ToLowerInvariant();
|
||||
|
||||
if (cultureStringLower != "en-gb" && cultureString.Length > 3)
|
||||
{
|
||||
flagName = cultureStringLower.Substring (3);
|
||||
}
|
||||
this.ImageCultureIndicator.ImageUrl = "~/Images/Flags/" + flagName + "-24px.png";
|
||||
}
|
||||
|
||||
|
||||
[WebMethod]
|
||||
public static bool CreateDatabaseFromRoot (string mysqlHostName, string rootPassword, string serverName,
|
||||
string ipAddress)
|
||||
{
|
||||
if (!(VerifyHostName (serverName) && VerifyHostAddress (ipAddress)))
|
||||
{
|
||||
if (!Debugger.IsAttached)
|
||||
{
|
||||
return true; // Probable hack attempt - fail silently
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string random = Authentication.CreateRandomPassword (5);
|
||||
|
||||
SwarmDb.Credentials rootCredentials = new SwarmDb.Credentials ("mysql",
|
||||
new SwarmDb.ServerSet (mysqlHostName), "root", rootPassword);
|
||||
|
||||
string readPass = GenerateLongPassword();
|
||||
string writePass = GenerateLongPassword();
|
||||
string adminPass = GenerateLongPassword();
|
||||
|
||||
string[] initInstructions =
|
||||
DbCreateScript.Replace ("[random]", random)
|
||||
.Replace ("[readpass]", readPass)
|
||||
.Replace ("[writepass]", writePass)
|
||||
.Replace ("[adminpass]", adminPass).Split ('#');
|
||||
|
||||
SwarmDb.GetTestDatabase (rootCredentials).ExecuteAdminCommands (initInstructions);
|
||||
|
||||
PermissionsAnalysis permissionsResult = FirstCredentialsTest (
|
||||
"Swarmops-" + random, mysqlHostName, "Swarmops-R-" + random, readPass,
|
||||
"Swarmops-" + random, mysqlHostName, "Swarmops-W-" + random, writePass,
|
||||
"Swarmops-" + random, mysqlHostName, "Swarmops-A-" + random, adminPass,
|
||||
serverName, ipAddress);
|
||||
|
||||
if (!permissionsResult.AllPermissionsOk)
|
||||
{
|
||||
throw new InvalidOperationException ("waaaaaah");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private const string DbCreateScript =
|
||||
"CREATE DATABASE `Swarmops-[random]`#" +
|
||||
"CREATE USER `Swarmops-R-[random]` IDENTIFIED BY '[readpass]'#" +
|
||||
"CREATE USER `Swarmops-W-[random]` IDENTIFIED BY '[writepass]'#" +
|
||||
"CREATE USER `Swarmops-A-[random]` IDENTIFIED BY '[adminpass]'#" +
|
||||
"GRANT SELECT ON mysql.proc TO `Swarmops-W-[random]`#" +
|
||||
"GRANT SELECT ON mysql.proc TO `Swarmops-A-[random]`#" +
|
||||
"USE `Swarmops-[random]`#" +
|
||||
"GRANT ALL ON `Swarmops-[random]`.* TO `Swarmops-A-[random]`#" +
|
||||
"GRANT SELECT ON `Swarmops-[random]`.* TO `Swarmops-W-[random]`#" +
|
||||
"GRANT EXECUTE ON `Swarmops-[random]`.* TO `Swarmops-W-[random]`#" +
|
||||
"GRANT SELECT ON `Swarmops-[random]`.* TO `Swarmops-R-[random]`#" +
|
||||
"FLUSH PRIVILEGES";
|
||||
|
||||
|
||||
|
||||
private static string GenerateLongPassword()
|
||||
{
|
||||
return Guid.NewGuid().ToString ("N") + Guid.NewGuid().ToString ("N");
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public static PermissionsAnalysis FirstCredentialsTest
|
||||
(string readDatabase, string readServer, string readUser, string readPassword,
|
||||
string writeDatabase, string writeServer, string writeUser, string writePassword,
|
||||
string adminDatabase, string adminServer, string adminUser, string adminPassword,
|
||||
string serverName, string ipAddress)
|
||||
{
|
||||
if (!(VerifyHostName (serverName) && VerifyHostAddress (ipAddress)))
|
||||
{
|
||||
if (!Debugger.IsAttached)
|
||||
{
|
||||
return null; // Probable hack attempt - fail silently
|
||||
}
|
||||
}
|
||||
|
||||
_testReadCredentials = new SwarmDb.Credentials (
|
||||
readDatabase, new SwarmDb.ServerSet (readServer), readUser, readPassword);
|
||||
_testWriteCredentials = new SwarmDb.Credentials (
|
||||
writeDatabase, new SwarmDb.ServerSet (writeServer), writeUser, writePassword);
|
||||
_testAdminCredentials = new SwarmDb.Credentials (
|
||||
adminDatabase, new SwarmDb.ServerSet (adminServer), adminUser, adminPassword);
|
||||
|
||||
return RecheckDatabasePermissions(); // Subsequent tests only call this function
|
||||
}
|
||||
|
||||
|
||||
[WebMethod (true)]
|
||||
public static void ResetTestCredentials()
|
||||
{
|
||||
_testReadCredentials =
|
||||
_testWriteCredentials =
|
||||
_testAdminCredentials = null;
|
||||
}
|
||||
|
||||
|
||||
[WebMethod (true)]
|
||||
public static PermissionsAnalysis RecheckDatabasePermissions()
|
||||
{
|
||||
while (_testReadCredentials == null || _testWriteCredentials == null || _testAdminCredentials == null)
|
||||
{
|
||||
Thread.Sleep (100);
|
||||
// A couple of async race conditions happen as this is called, we need to wait for credentials
|
||||
}
|
||||
|
||||
PermissionsAnalysis result = new PermissionsAnalysis();
|
||||
|
||||
// First, test ADMIN
|
||||
|
||||
SwarmDb adminDb = SwarmDb.GetTestDatabase (_testAdminCredentials);
|
||||
|
||||
// Drop table, procedure first just in case there's garbage left behind. Ignore result.
|
||||
adminDb.TestDropTable();
|
||||
adminDb.TestDropProcedure();
|
||||
|
||||
// All these should pass.
|
||||
result.AdminCredentialsCanLogin = adminDb.TestLogin();
|
||||
result.AdminCredentialsCanAdmin = adminDb.TestCreateTable();
|
||||
result.AdminCredentialsCanAdmin &= adminDb.TestDropTable();
|
||||
result.AdminCredentialsCanAdmin &= adminDb.TestCreateTable();
|
||||
result.AdminCredentialsCanAdmin &= adminDb.TestAlterTable();
|
||||
result.AdminCredentialsCanAdmin &= adminDb.TestCreateProcedure(); // AND -- all must succeed
|
||||
result.AdminCredentialsCanAdmin &= adminDb.TestDropProcedure();
|
||||
// Test DROP before we mess up the state of the table, procedure
|
||||
result.AdminCredentialsCanAdmin &= adminDb.TestCreateProcedure(); // therefore, recreate it after the drop
|
||||
|
||||
if (result.AdminCredentialsCanAdmin) // if we have a created table and procedure, otherwise default fail
|
||||
{
|
||||
result.AdminCredentialsCanExecute = adminDb.TestExecute ("Admin Execute");
|
||||
result.AdminCredentialsCanSelect = adminDb.TestSelect();
|
||||
}
|
||||
|
||||
// Within the created table, test WRITE and READ accounts before testing them on excessive rights.
|
||||
|
||||
SwarmDb writeDb = SwarmDb.GetTestDatabase (_testWriteCredentials);
|
||||
|
||||
result.WriteCredentialsCanLogin = writeDb.TestLogin();
|
||||
|
||||
if (result.WriteCredentialsCanLogin && result.AdminCredentialsCanAdmin)
|
||||
{
|
||||
result.WriteCredentialsCanExecute = writeDb.TestExecute ("Write Execute");
|
||||
result.WriteCredentialsCanSelect = writeDb.TestSelect();
|
||||
}
|
||||
|
||||
SwarmDb readDb = SwarmDb.GetTestDatabase (_testReadCredentials);
|
||||
|
||||
result.ReadCredentialsCanLogin = readDb.TestLogin();
|
||||
|
||||
if (result.ReadCredentialsCanLogin && result.AdminCredentialsCanAdmin)
|
||||
{
|
||||
result.ReadCredentialsCanExecute = readDb.TestExecute ("Read Execute");
|
||||
result.ReadCredentialsCanSelect = readDb.TestSelect();
|
||||
}
|
||||
|
||||
// Finally, test the write and read accounts for admin rights. Note the "OR" here rather than "AND" -
|
||||
// any one of these rights present should return a true, because it's a fail.
|
||||
|
||||
if (result.ReadCredentialsCanLogin)
|
||||
{
|
||||
result.ReadCredentialsCanAdmin = readDb.TestDropProcedure();
|
||||
result.ReadCredentialsCanAdmin |= readDb.TestDropTable();
|
||||
result.ReadCredentialsCanAdmin |= readDb.TestCreateTable();
|
||||
result.ReadCredentialsCanAdmin |= readDb.TestCreateProcedure();
|
||||
}
|
||||
|
||||
if (result.WriteCredentialsCanLogin)
|
||||
{
|
||||
result.WriteCredentialsCanAdmin = writeDb.TestDropProcedure();
|
||||
result.WriteCredentialsCanAdmin |= writeDb.TestDropTable();
|
||||
result.WriteCredentialsCanAdmin |= writeDb.TestCreateTable();
|
||||
result.WriteCredentialsCanAdmin |= writeDb.TestCreateProcedure();
|
||||
}
|
||||
|
||||
// Clean up
|
||||
|
||||
adminDb.TestDropTable(); // ignore result
|
||||
adminDb.TestDropProcedure();
|
||||
|
||||
result.AllPermissionsOk =
|
||||
result.AdminCredentialsCanLogin &&
|
||||
result.AdminCredentialsCanSelect &&
|
||||
result.AdminCredentialsCanExecute &&
|
||||
result.AdminCredentialsCanAdmin &&
|
||||
result.WriteCredentialsCanLogin &&
|
||||
result.WriteCredentialsCanSelect &&
|
||||
result.WriteCredentialsCanExecute &&
|
||||
!result.WriteCredentialsCanAdmin && // not this
|
||||
result.ReadCredentialsCanLogin &&
|
||||
result.ReadCredentialsCanSelect &&
|
||||
!result.ReadCredentialsCanExecute && // not this
|
||||
!result.ReadCredentialsCanAdmin; // not this
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
[WebMethod (true)]
|
||||
public static void InitDatabase()
|
||||
{
|
||||
// Make sure we're uninitialized
|
||||
|
||||
bool organizationOneExists = false;
|
||||
Organization organizationOne = null;
|
||||
|
||||
try
|
||||
{
|
||||
organizationOne = Organization.FromIdentity (1);
|
||||
organizationOneExists = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// We expect this to throw
|
||||
}
|
||||
|
||||
if (organizationOneExists || organizationOne != null)
|
||||
{
|
||||
throw new InvalidOperationException ("Cannot re-initialize database");
|
||||
}
|
||||
|
||||
// Store database credentials
|
||||
|
||||
SwarmDb.Configuration.Set (
|
||||
new SwarmDb.Configuration (
|
||||
_testReadCredentials,
|
||||
_testWriteCredentials,
|
||||
_testAdminCredentials));
|
||||
|
||||
// SECURITY: Set machine token crypto keys to randomized values
|
||||
|
||||
if (!Debugger.IsAttached) // (but not while debugging in a non-live environment)
|
||||
{
|
||||
string machineKeyXml =
|
||||
"<?xml version=\"1.0\" ?>\n" +
|
||||
"<!--\n" +
|
||||
" The MachineKey is the key used to encrypt/decrypt the cookie containing\n" +
|
||||
" authentication information. When you have multiple front-end web servers\n" +
|
||||
" serving a single Swarmops installation, this key must be identical on\n" +
|
||||
" all front-end machines - otherwise, authentication won't follow from\n" +
|
||||
" one server to the next.\n\n" +
|
||||
" This particular MachineKey was randomized at the time of initial\n" +
|
||||
" installation of this Swarmops database, and is unique. If you have\n" +
|
||||
" multiple front-ends, you need to copy this file to /etc/swarmops\n" +
|
||||
" on each of them.\n" +
|
||||
"-->\n" +
|
||||
GetMachineKey() + "\n";
|
||||
|
||||
File.WriteAllText ("/etc/swarmops/machineKey.config", machineKeyXml, Encoding.GetEncoding (1252));
|
||||
}
|
||||
|
||||
// Start an async thread that does all the initialization work, then return
|
||||
|
||||
Thread initThread = new Thread (InitDatabaseThread);
|
||||
initThread.Start();
|
||||
}
|
||||
|
||||
|
||||
private static string GetMachineKey()
|
||||
{
|
||||
StringBuilder machineKey = new StringBuilder();
|
||||
machineKey.Append ("<machineKey \n");
|
||||
machineKey.Append ("validationKey=\"" + SupportFunctions.GenerateSecureRandomKey (64) + "\"\n");
|
||||
machineKey.Append ("decryptionKey=\"" + SupportFunctions.GenerateSecureRandomKey (32) + "\"\n");
|
||||
machineKey.Append ("validation=\"HMACSHA512\" decryption=\"AES\"\n");
|
||||
machineKey.Append ("/>\n");
|
||||
return machineKey.ToString();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This function copies the schemas and geography data off an existing Swarmops installation. Runs in its own thread.
|
||||
/// </summary>
|
||||
public static void InitDatabaseThread()
|
||||
{
|
||||
// Ignore the session object, that method of sharing data didn't work, but a static variable did.
|
||||
|
||||
_initProgress = 1;
|
||||
_initMessage = "Loading schema from Swarmops servers; creating tables and procs...";
|
||||
Thread.Sleep (100);
|
||||
|
||||
try
|
||||
{
|
||||
// Get the schema and initialize the database structures. Requires ADMIN access to database.
|
||||
|
||||
DatabaseMaintenance.FirstInitialization();
|
||||
|
||||
_initProgress = 3;
|
||||
_initMessage = "Applying all post-baseline database schema upgrades...";
|
||||
DatabaseMaintenance.UpgradeSchemata();
|
||||
Thread.Sleep (100);
|
||||
|
||||
_initProgress = 5;
|
||||
_initMessage = "Getting list of countries from Swarmops servers...";
|
||||
Thread.Sleep (100);
|
||||
|
||||
// Create translation lists
|
||||
|
||||
Dictionary<string, int> countryIdTranslation = new Dictionary<string, int>();
|
||||
|
||||
// Initialize the root geography (which becomes #1 if everything works)
|
||||
|
||||
int rootGeographyId = SwarmDb.GetDatabaseForWriting().CreateGeography ("[LOC]World", 0);
|
||||
|
||||
// Get the list of countries
|
||||
|
||||
GetGeographyData geoDataFetcher = new GetGeographyData();
|
||||
|
||||
Country[] countries = geoDataFetcher.GetCountries();
|
||||
|
||||
_initProgress = 7;
|
||||
_initMessage = "Creating all countries on local server...";
|
||||
Thread.Sleep (100);
|
||||
int count = 0;
|
||||
int total = countries.Length;
|
||||
|
||||
// Create all countries in our own database
|
||||
|
||||
foreach (Country country in countries)
|
||||
{
|
||||
countryIdTranslation[country.Code] = SwarmDb.GetDatabaseForWriting().CreateCountry (country.Name,
|
||||
country.Code,
|
||||
country.Culture,
|
||||
rootGeographyId, country.PostalCodeLength,
|
||||
string.Empty);
|
||||
|
||||
count++;
|
||||
_initMessage = String.Format ("Creating all countries on local server... ({0}%)", count*100/total);
|
||||
}
|
||||
|
||||
_initProgress = 10;
|
||||
|
||||
// Construct list of countries that have geographic data
|
||||
|
||||
List<string> initializableCountries = new List<string>();
|
||||
|
||||
foreach (Country country in countries)
|
||||
{
|
||||
if (country.GeographyId != 1)
|
||||
{
|
||||
initializableCountries.Add (country.Code);
|
||||
}
|
||||
}
|
||||
|
||||
float initStepPerCountry = 90f/initializableCountries.Count;
|
||||
int countryCount = 0;
|
||||
|
||||
// For each country...
|
||||
|
||||
foreach (string countryCode in initializableCountries)
|
||||
{
|
||||
// Get the geography layout
|
||||
|
||||
_initMessage = "Initializing geography for country " + countryCode + "... ";
|
||||
Thread.Sleep (100);
|
||||
|
||||
GeographyUpdate.PrimeCountry (countryCode);
|
||||
GuidCache.Set ("DbInitProgress", string.Empty);
|
||||
|
||||
countryCount++;
|
||||
|
||||
_initProgress = 10 + (int) (countryCount*initStepPerCountry);
|
||||
}
|
||||
|
||||
// Set Geography at baseline (TODO: Ask for what baseline we got)
|
||||
|
||||
Persistence.Key["LastGeographyUpdateId"] = "0";
|
||||
Persistence.Key["LastGeographyUpdate"] = "1900-01-01";
|
||||
|
||||
// Set an installation ID
|
||||
|
||||
Persistence.Key["SwarmopsInstallationId"] = Guid.NewGuid().ToString();
|
||||
|
||||
_initMessage = "Initializing currencies...";
|
||||
|
||||
// Create initial currencies (European et al)
|
||||
|
||||
Currency.Create ("EUR", "Euros", "€");
|
||||
Currency.Create ("USD", "US Dollars", "$");
|
||||
Currency.Create ("CAD", "Canadian Dollars", "CA$");
|
||||
Currency.Create ("SEK", "Swedish Krona", string.Empty);
|
||||
Currency.Create ("NOK", "Norwegian Krona", string.Empty);
|
||||
Currency.Create ("DKK", "Danish Krona", string.Empty);
|
||||
Currency.Create ("ISK", "Icelandic Krona", string.Empty);
|
||||
Currency.Create ("CHF", "Swiss Franc", string.Empty);
|
||||
Currency.Create ("GBP", "Pounds Sterling", "£");
|
||||
Currency.Create ("BTC", "Bitcoin", "฿");
|
||||
|
||||
// Fetch the first set of exchange rates, completing the currency collection
|
||||
|
||||
ExchangeRateSnapshot.Create();
|
||||
|
||||
// Create the sandbox
|
||||
|
||||
Organization.Create (0, "Sandbox", "Sandbox", "Sandbox", "swarmops.com", "Ops",
|
||||
rootGeographyId, true,
|
||||
true, 0).EnableEconomy (Currency.FromCode ("EUR"));
|
||||
|
||||
_initProgress = 100;
|
||||
_initMessage = "Complete.";
|
||||
}
|
||||
catch (Exception failedException)
|
||||
{
|
||||
// Use initMessage to push info about what went wrong to the user
|
||||
|
||||
_initMessage = failedException.ToString();
|
||||
}
|
||||
|
||||
Thread.Sleep (1000);
|
||||
// give some time for static var to stick and web interface to react before killing thread
|
||||
}
|
||||
|
||||
|
||||
[WebMethod]
|
||||
public static int GetInitProgress()
|
||||
{
|
||||
HttpSessionState state = HttpContext.Current.Session;
|
||||
object progressObject = state["PercentInitComplete"];
|
||||
|
||||
try
|
||||
{
|
||||
int progress = (int) HttpContext.Current.Session["PercentInitComplete"];
|
||||
|
||||
return progress;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return _initProgress;
|
||||
}
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public static string GetInitProgressMessage()
|
||||
{
|
||||
return _initMessage + GuidCache.Get ("DbInitProgress");
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public static bool VerifyHostName (string input)
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
return true; // Cannot read "/etc/hostname" in Windows environment
|
||||
}
|
||||
|
||||
// validate against /etc/hostname
|
||||
|
||||
string realHostName;
|
||||
|
||||
using (TextReader reader = new StreamReader ("/etc/hostname"))
|
||||
// This will throw in a Windows dev environment
|
||||
{
|
||||
realHostName = reader.ReadLine();
|
||||
}
|
||||
|
||||
if (String.Compare (input, realHostName, true, CultureInfo.InvariantCulture) == 0)
|
||||
// case-insensitive compare
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[WebMethod (true)]
|
||||
public static bool VerifyHostAddress (string input)
|
||||
{
|
||||
string localAddress = HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"];
|
||||
|
||||
if (input == localAddress)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[WebMethod (true)]
|
||||
public static bool VerifyHostNameAndAddress (string name, string address)
|
||||
{
|
||||
if (Path.DirectorySeparatorChar == '\\')
|
||||
{
|
||||
// Running in development mode on Windows, so accept any response
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return VerifyHostName (HttpUtility.UrlDecode (name)) && VerifyHostAddress (HttpUtility.UrlDecode (address));
|
||||
}
|
||||
|
||||
[WebMethod (true)]
|
||||
public static bool IsConfigurationFileWritable()
|
||||
{
|
||||
return SwarmDb.Configuration.TestConfigurationWritable();
|
||||
}
|
||||
|
||||
|
||||
private static bool RandomBool()
|
||||
{
|
||||
return (GetRandomNumber (0, 1) == 0);
|
||||
}
|
||||
|
||||
//Function to get random number
|
||||
|
||||
private static int GetRandomNumber (int min, int max)
|
||||
{
|
||||
lock (syncLock)
|
||||
{
|
||||
// synchronize
|
||||
return GetRandom.Next (min, max + 1);
|
||||
}
|
||||
}
|
||||
|
||||
[WebMethod (true)]
|
||||
public static void CreateFirstUser (string name, string mail, string password)
|
||||
{
|
||||
// Make sure that no first person exists already, as a security measure
|
||||
|
||||
Person personOne = null;
|
||||
bool personOneExists = false;
|
||||
|
||||
try
|
||||
{
|
||||
personOne = Person.FromIdentity (1);
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
if (personOne.CityName != "Duckville" || personOne.Mail != "noreply@example.com")
|
||||
// these values are returned in debug environments when no person is found
|
||||
{
|
||||
personOneExists = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
personOne = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
personOneExists = true;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// We expect this to throw.
|
||||
}
|
||||
|
||||
if (personOneExists || personOne != null)
|
||||
{
|
||||
throw new InvalidOperationException ("Cannot run initialization processes again when initialized.");
|
||||
}
|
||||
|
||||
Person newPerson = Person.Create (HttpUtility.UrlDecode (name),
|
||||
HttpUtility.UrlDecode (mail),
|
||||
HttpUtility.UrlDecode (password), string.Empty, string.Empty, string.Empty,
|
||||
string.Empty, string.Empty, DateTime.MinValue, PersonGender.Unknown);
|
||||
|
||||
newPerson.AddMembership (1, DateTime.MaxValue); // Add membership in Sandbox
|
||||
newPerson.AddRole (RoleType.SystemAdmin, 0, 0); // Add role System Admin
|
||||
}
|
||||
|
||||
|
||||
protected void ButtonLogin_Click (object sender, EventArgs args)
|
||||
{
|
||||
// Check the host names and addresses again as a security measure - after all, we can be called from outside our intended script
|
||||
|
||||
if (!(VerifyHostName (this.TextServerName.Text) && VerifyHostAddress (this.TextServerAddress.Text)))
|
||||
{
|
||||
if (!Debugger.IsAttached)
|
||||
{
|
||||
return; // Probable hack attempt - fail silently
|
||||
}
|
||||
}
|
||||
|
||||
Person expectedPersonOne = Authentication.Authenticate ("1",
|
||||
this.TextFirstUserPassword1.Text);
|
||||
|
||||
if (expectedPersonOne != null)
|
||||
{
|
||||
FormsAuthentication.RedirectFromLoginPage ("1,1", true);
|
||||
Response.Redirect ("/", true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class PermissionsAnalysis
|
||||
{
|
||||
public bool AllPermissionsOk { get; set; }
|
||||
public bool ReadCredentialsCanLogin { get; set; }
|
||||
public bool ReadCredentialsCanSelect { get; set; }
|
||||
public bool ReadCredentialsCanExecute { get; set; }
|
||||
public bool ReadCredentialsCanAdmin { get; set; }
|
||||
public bool WriteCredentialsCanLogin { get; set; }
|
||||
public bool WriteCredentialsCanSelect { get; set; }
|
||||
public bool WriteCredentialsCanExecute { get; set; }
|
||||
public bool WriteCredentialsCanAdmin { get; set; }
|
||||
public bool AdminCredentialsCanLogin { get; set; }
|
||||
public bool AdminCredentialsCanSelect { get; set; }
|
||||
public bool AdminCredentialsCanExecute { get; set; }
|
||||
public bool AdminCredentialsCanAdmin { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,750 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Signup.aspx.cs" Inherits="Swarmops.Frontend.Pages.Public.Signup" %>
|
||||
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head id="Head1" runat="server">
|
||||
|
||||
<!-- jQuery and plugins -->
|
||||
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" ></script>
|
||||
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="/Scripts/jquery.leanModal.min.js" ></script>
|
||||
<script language="javascript" type="text/javascript" src="/Scripts/jquery.smartWizard-2.0.min.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="/Scripts/jquery.json.min.js"></script>
|
||||
|
||||
<!-- fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Permanent+Marker' rel='stylesheet' type='text/css' />
|
||||
<link href='https://fonts.googleapis.com/css?family=Ubuntu:light,regular,500,bold' rel='stylesheet' type='text/css' />
|
||||
<link href='https://fonts.googleapis.com/css?family=Arimo:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css' />
|
||||
|
||||
<!-- page title -->
|
||||
<title>Swarmops - Signup</title>
|
||||
|
||||
<link href="/Style/style-v5.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../v5/Init/WizardStyle.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
<!-- initialize all modal popups -->
|
||||
<script language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
$("a[rel*=leanModal]").leanModal();
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- hide "previous" button -->
|
||||
|
||||
<style type="text/css">
|
||||
.swMain .buttonPrevious
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
.PermissionsErrorCredentials
|
||||
{
|
||||
font-weight: bold;
|
||||
}
|
||||
.PermissionsErrorResults
|
||||
{
|
||||
font-size: 200%;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<form id="form2" runat="server">
|
||||
<asp:ScriptManager runat="server" ID="ScriptManagerBlahblah" />
|
||||
<script type="text/javascript">
|
||||
|
||||
var databaseInitComplete = false;
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$('#<%=this.TextCredentialsReadDatabase.ClientID %>').focusout(function () {
|
||||
var dbValue = $('#<%=this.TextCredentialsReadDatabase.ClientID %>').val();
|
||||
$('#<%=this.TextCredentialsWriteDatabase.ClientID %>').val(dbValue);
|
||||
$('#<%=this.TextCredentialsAdminDatabase.ClientID %>').val(dbValue);
|
||||
});
|
||||
|
||||
$('#<%=this.TextCredentialsReadServer.ClientID %>').focusout(function () {
|
||||
var serverValue = $('#<%=this.TextCredentialsReadServer.ClientID %>').val();
|
||||
$('#<%=this.TextCredentialsWriteServer.ClientID %>').val(serverValue);
|
||||
$('#<%=this.TextCredentialsAdminServer.ClientID %>').val(serverValue);
|
||||
});
|
||||
|
||||
// Initialize Smart Wizard
|
||||
$('#wizard').smartWizard({
|
||||
transitionEffect: 'fade',
|
||||
keyNavigation: false,
|
||||
onLeaveStep: leaveAStepCallback,
|
||||
onFinish: onFinishCallback
|
||||
});
|
||||
|
||||
function leaveAStepCallback(obj) {
|
||||
if (disableNext) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var stepNum = obj.attr('rel');
|
||||
return validateStep(stepNum);
|
||||
}
|
||||
|
||||
function onFinishCallback(obj) {
|
||||
$('#<%=this.ButtonLogin.ClientID %>').click();
|
||||
}
|
||||
|
||||
function validateStep(stepNumber) {
|
||||
var isValid = false;
|
||||
var textBoxes;
|
||||
var loop;
|
||||
var fieldContents;
|
||||
var hostName = $('#<%=this.TextServerName.ClientID %>').val();
|
||||
var hostAddress = $('#<%=this.TextServerAddress.ClientID %>').val();
|
||||
|
||||
if (stepNumber == 1) {
|
||||
// Validate Hostname, Host Address
|
||||
|
||||
if (hostName && hostName.length > 0 && hostAddress && hostAddress.length > 0) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/VerifyHostNameAndAddress",
|
||||
data: "{'name': '" + escape(hostName) + "', 'address': '" + escape(hostAddress) + "'}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
async: false, // blocks until function returns - race conditions otherwise
|
||||
success: function (msg) {
|
||||
if (msg.d == true) {
|
||||
isValid = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (!isValid) {
|
||||
$('#<%=this.TextServerName.ClientID %>').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
|
||||
$('#<%=this.TextServerAddress.ClientID %>').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
|
||||
} else {
|
||||
$('#<%=this.TextServerName.ClientID %>').css('background-image', "none");
|
||||
$('#<%=this.TextServerAddress.ClientID %>').css('background-image', "none");
|
||||
}
|
||||
|
||||
if (isValid) { // Validate writability of config file
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/IsConfigurationFileWritable",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
async: false, // blocks until function returns - race conditions otherwise
|
||||
success: function (msg) {
|
||||
if (msg.d == true) {
|
||||
|
||||
// Yes, config is writable. Hide "unwritable" div, show "writable" div, all is nice
|
||||
$('#DivDatabaseUnwritable').css('display', 'none');
|
||||
$('#DivDatabaseRootConfig').css('display', 'inline');
|
||||
setTimeout('$("#TextMysqlServerHost").focus();', 250);
|
||||
//$('#<%=this.TextCredentialsReadDatabase.ClientID %>').focus();
|
||||
} else {
|
||||
// Config is NOT writable. Keep the error on-screen and keep re-checking every two seconds.
|
||||
|
||||
setTimeout('recheckConfigurationWritability();', 5000); // 5s until first re-check
|
||||
DisableNext();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
else if (stepNumber == 2) {
|
||||
isValid = true; // assume true, make false as we go
|
||||
|
||||
textBoxes = [];
|
||||
|
||||
if (autoConfigMode) {
|
||||
textBoxes = ["TextMysqlServerHost", "TextMysqlRootPassword"];
|
||||
} else {
|
||||
textBoxes = [
|
||||
"<%=this.TextCredentialsReadDatabase.ClientID %>", "<%=this.TextCredentialsReadServer.ClientID %>", "<%=this.TextCredentialsReadUser.ClientID %>", "<%=this.TextCredentialsReadPassword.ClientID %>",
|
||||
"<%=this.TextCredentialsWriteDatabase.ClientID %>", "<%=this.TextCredentialsWriteServer.ClientID %>", "<%=this.TextCredentialsWriteUser.ClientID %>", "<%=this.TextCredentialsWritePassword.ClientID %>",
|
||||
"<%=this.TextCredentialsAdminDatabase.ClientID %>", "<%=this.TextCredentialsAdminServer.ClientID %>", "<%=this.TextCredentialsAdminUser.ClientID %>", "<%=this.TextCredentialsAdminPassword.ClientID %>"
|
||||
];
|
||||
}
|
||||
|
||||
for (loop = 0; loop < textBoxes.length; loop++) {
|
||||
fieldContents = $('#' + textBoxes[loop]).val();
|
||||
|
||||
if (fieldContents && fieldContents.length > 0) {
|
||||
$('#' + textBoxes[loop]).css('background-image', "none");
|
||||
} else {
|
||||
$('#' + textBoxes[loop]).css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Verify database credentials are good and permissions correct
|
||||
|
||||
if (isValid) {
|
||||
DisableNext(); // block Next during synchro call - it may take a while
|
||||
// also, won't get re-enabled no matter the outcome
|
||||
|
||||
var jsonData = {};
|
||||
jsonData.serverName = hostName;
|
||||
jsonData.ipAddress = hostAddress;
|
||||
|
||||
if (autoConfigMode) {
|
||||
jsonData.mysqlHostName = $('#TextMysqlServerHost').val();
|
||||
jsonData.rootPassword = $('#TextMysqlRootPassword').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/CreateDatabaseFromRoot",
|
||||
data: $.toJSON(jsonData),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
async: false, // blocks until function returns - race conditions otherwise
|
||||
success: function (msg) {
|
||||
if (msg.d != true) {
|
||||
|
||||
// Credentials problem.
|
||||
$('#TextMysqlRootPassword, #TextMysqlServerHost').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
|
||||
EnableNext();
|
||||
isValid = false;
|
||||
} else {
|
||||
// re-enable Next only on exit of step 3
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
jsonData.readDatabase = $('#<%=this.TextCredentialsReadDatabase.ClientID %>').val();
|
||||
jsonData.readServer = $('#<%=this.TextCredentialsReadServer.ClientID %>').val();
|
||||
jsonData.readUser = $('#<%=this.TextCredentialsReadUser.ClientID %>').val();
|
||||
jsonData.readPassword = $('#<%=this.TextCredentialsReadPassword.ClientID %>').val();
|
||||
jsonData.writeDatabase = $('#<%=this.TextCredentialsWriteDatabase.ClientID %>').val();
|
||||
jsonData.writeServer = $('#<%=this.TextCredentialsWriteServer.ClientID %>').val();
|
||||
jsonData.writeUser = $('#<%=this.TextCredentialsWriteUser.ClientID %>').val();
|
||||
jsonData.writePassword = $('#<%=this.TextCredentialsWritePassword.ClientID %>').val();
|
||||
jsonData.adminDatabase = $('#<%=this.TextCredentialsAdminDatabase.ClientID %>').val();
|
||||
jsonData.adminServer = $('#<%=this.TextCredentialsAdminServer.ClientID %>').val();
|
||||
jsonData.adminUser = $('#<%=this.TextCredentialsAdminUser.ClientID %>').val();
|
||||
jsonData.adminPassword = $('#<%=this.TextCredentialsAdminPassword.ClientID %>').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/FirstCredentialsTest",
|
||||
data: $.toJSON(jsonData),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
async: false, // blocks until function returns - race conditions otherwise
|
||||
success: function (msg) {
|
||||
if (msg.d.AllPermissionsOk != true) {
|
||||
|
||||
// We have a permissions problem. Block further progress and display the problem.
|
||||
updatePermissionsAnalysisDisplay(msg.d);
|
||||
$('#DivDatabaseManualConfig').fadeOut(400, 'swing', function () { $('#DivDatabasePermissionProblem').fadeIn(200); });
|
||||
setTimeout('recheckDatabasePermissionsAnalysis();', 5000); // 5s until first re-check
|
||||
isValid = false;
|
||||
} else {
|
||||
// re-enable Next only on exit of step 3
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isValid) {
|
||||
$('#DivProgressDatabase').progressbar({ value: 0, max: 100 });
|
||||
setTimeout('updateInitProgressBar();', 1000);
|
||||
setTimeout('updateInitProgressMessage();', 1500);
|
||||
beginInitDatabase();
|
||||
DisableNext();
|
||||
}
|
||||
|
||||
}
|
||||
else if (stepNumber == 3) {
|
||||
isValid = databaseInitComplete;
|
||||
|
||||
if (isValid) {
|
||||
$('#<%=this.TextFirstUserName.ClientID %>').focus();
|
||||
}
|
||||
}
|
||||
else if (stepNumber == 4) {
|
||||
isValid = true; // assume true, make false as we go
|
||||
|
||||
// Check that all four boxes are filled in, and that Password1 and Password2 equal each other.
|
||||
|
||||
textBoxes = ["<%=this.TextFirstUserName.ClientID %>", "<%=this.TextFirstUserMail.ClientID %>", "<%=this.TextFirstUserPassword1.ClientID %>", "<%=this.TextFirstUserPassword2.ClientID %>"];
|
||||
|
||||
for (loop = 0; loop < textBoxes.length; loop++) {
|
||||
fieldContents = $('#' + textBoxes[loop]).val();
|
||||
|
||||
if (fieldContents && fieldContents.length > 0) {
|
||||
$('#' + textBoxes[loop]).css('background-image', "none");
|
||||
} else {
|
||||
$('#' + textBoxes[loop]).css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
// As we exit the zero-length check, fieldContents contains Password2.Text, so we can compare it to Password1.Text right away.
|
||||
|
||||
if (isValid) {
|
||||
if (fieldContents != $('#<%=this.TextFirstUserPassword1.ClientID %>').val()) {
|
||||
$('#<%=this.TextFirstUserPassword1.ClientID %>').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
|
||||
$('#<%=this.TextFirstUserPassword2.ClientID %>').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
// If all is valid, create the first user.
|
||||
|
||||
if (isValid) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/CreateFirstUser",
|
||||
data: "{'name': '" + escape($('#<%=this.TextFirstUserName.ClientID %>').val()) + "', 'mail': '" + escape($('#<%=this.TextFirstUserMail.ClientID %>').val()) + "', 'password': '" + escape($('#<%=this.TextFirstUserPassword1.ClientID %>').val()) + "'}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
// Don't care
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (stepNumber == 5) {
|
||||
// If we get here, we're always good
|
||||
|
||||
isValid = true;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
}); // end of document.ready
|
||||
|
||||
var disableNext = false;
|
||||
var stopRechecking = false;
|
||||
|
||||
function DisableNext() {
|
||||
$('a.buttonNext').addClass("buttonDisabled");
|
||||
disableNext = true;
|
||||
}
|
||||
|
||||
function EnableNext() {
|
||||
$('a.buttonNext').removeClass("buttonDisabled");
|
||||
disableNext = false;
|
||||
}
|
||||
|
||||
function ClickNext() {
|
||||
$('a.buttonNext').click();
|
||||
}
|
||||
|
||||
|
||||
function ReturnToCredentials() {
|
||||
stopRechecking = true;
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/ResetTestCredentials",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
$('#DivDatabasePermissionProblem').fadeOut(200, 'swing', function () { $('#DivDatabaseManualConfig').fadeIn(200); EnableNext(); });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function recheckConfigurationWritability() {
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/IsConfigurationFileWritable",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
if (msg.d == true) {
|
||||
|
||||
// Yes, config is writable. Hide "unwritable" div, show "config" div, all is nice
|
||||
$('#DivDatabaseUnwritable').css('display', 'none');
|
||||
$('#DivDatabaseManualConfig').fadeIn('slow');
|
||||
setTimeout('$("#TextMysqlServerHost").focus();', 250);
|
||||
EnableNext();
|
||||
} else {
|
||||
// Config is NOT writable. Keep the error on-screen and keep re-checking every two seconds.
|
||||
|
||||
setTimeout('recheckConfigurationWritability();', 2000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateInitProgressBar() {
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/GetInitProgress",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
if (msg.d > 99) {
|
||||
$("#DivProgressDatabase .ui-progressbar-value").animate(
|
||||
{
|
||||
width: "100%"
|
||||
}, { queue: false });
|
||||
databaseInitComplete = true;
|
||||
EnableNext(); // re-enable - it has been disabled throughout Init
|
||||
ClickNext();
|
||||
} else {
|
||||
// We're not done yet. Keep the progress bar on-screen and keep re-checking.
|
||||
|
||||
if (msg.d == 1) {
|
||||
$('#DivProgressDatabase').progressbar("value", msg.d);
|
||||
} else {
|
||||
$("#DivProgressDatabase .ui-progressbar-value").animate(
|
||||
{
|
||||
width: msg.d + "%"
|
||||
}, { queue: false });
|
||||
}
|
||||
|
||||
setTimeout('updateInitProgressBar();', 1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateInitProgressMessage() {
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/GetInitProgressMessage",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
$('#SpanInitProgressMessage').text(msg.d);
|
||||
|
||||
if (msg.d == 'Complete.') {
|
||||
|
||||
// We're done. Do nothing, the progress bar updater will do this step.
|
||||
|
||||
} else {
|
||||
|
||||
// We're not done yet. Keep the progress bar on-screen and keep re-checking.
|
||||
setTimeout('updateInitProgressMessage();', 500);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function recheckDatabasePermissionsAnalysis() {
|
||||
|
||||
if (stopRechecking) {
|
||||
stopRechecking = false;
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/RecheckDatabasePermissions",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
updatePermissionsAnalysisDisplay(msg.d);
|
||||
if (!msg.d.AllPermissionsOk) {
|
||||
setTimeout('recheckDatabasePermissionsAnalysis();', 2000);
|
||||
} else {
|
||||
EnableNext();
|
||||
ClickNext();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updatePermissionsAnalysisDisplay(testResults) {
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionReadCredentialCanLogin', testResults.ReadCredentialsCanLogin);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionReadCredentialCanSelect', testResults.ReadCredentialsCanSelect);
|
||||
updateOneDatabasePermissionExpectedFailure('CellPermissionReadCredentialCanExecute', testResults.ReadCredentialsCanExecute);
|
||||
updateOneDatabasePermissionExpectedFailure('CellPermissionReadCredentialCanAdmin', testResults.ReadCredentialsCanAdmin);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionWriteCredentialCanLogin', testResults.WriteCredentialsCanLogin);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionWriteCredentialCanSelect', testResults.WriteCredentialsCanSelect);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionWriteCredentialCanExecute', testResults.WriteCredentialsCanExecute);
|
||||
updateOneDatabasePermissionExpectedFailure('CellPermissionWriteCredentialCanAdmin', testResults.WriteCredentialsCanAdmin);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionAdminCredentialCanLogin', testResults.AdminCredentialsCanLogin);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionAdminCredentialCanSelect', testResults.AdminCredentialsCanSelect);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionAdminCredentialCanExecute', testResults.AdminCredentialsCanExecute);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionAdminCredentialCanAdmin', testResults.AdminCredentialsCanAdmin);
|
||||
}
|
||||
|
||||
function updateOneDatabasePermissionExpectedSuccess(cellName, result) {
|
||||
if (result) {
|
||||
$('#' + cellName).html('YES <img src="/Images/Icons/iconshock-greentick-16px.png" />');
|
||||
} else {
|
||||
$('#' + cellName).html('NO <img src="/Images/Icons/iconshock-redcross-16px.png" />');
|
||||
}
|
||||
}
|
||||
|
||||
function updateOneDatabasePermissionExpectedFailure(cellName, result) {
|
||||
if (result) {
|
||||
$('#' + cellName).html('YES <img src="/Images/Icons/iconshock-redcross-16px.png" />');
|
||||
} else {
|
||||
$('#' + cellName).html('NO <img src="/Images/Icons/iconshock-greentick-16px.png" />');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function beginInitDatabase() {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/InitDatabase",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function () {
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function goManualCredentials() {
|
||||
autoConfigMode = false;
|
||||
$('#DivDatabaseRootConfig').css('display', 'none');
|
||||
$('#DivDatabaseManualConfig').fadeIn('slow');
|
||||
setTimeout('$("#<%=this.TextCredentialsReadDatabase.ClientID %>").focus();', 250);
|
||||
}
|
||||
|
||||
var autoConfigMode = true;
|
||||
|
||||
</script>
|
||||
|
||||
<!-- Main menu, dynamically constructed -->
|
||||
|
||||
<div class="center980px">
|
||||
<div class="currentuserinfo"><div style="background-image:url('/Images/Icons/iconshock-user-16px.png');background-repeat:no-repeat;padding-left:16px;float:left"><asp:Label ID="LabelCurrentUserName" runat="server" /> | </div><div style="background-image:url('/Images/Icons/iconshock-workchair-16px.png');background-repeat:no-repeat;padding-left:17px;float:left"><asp:Label ID="LabelCurrentOrganizationName" runat="server" /> | </div><div style="background-image:url('/Images/Icons/iconshock-gamepad-16px.png');background-repeat:no-repeat;padding-left:20px;float:left"><asp:Label ID="LabelPreferences" runat="server" /> | </div><asp:Image ID="ImageCultureIndicator" runat="server" ImageUrl="~/Images/Flags/uk-24px.png" /></div>
|
||||
<div class="logoimage"><a href="/"><img style="border:none" src="/Images/Logo-Stock.png" alt="Swarmops Logo" /></a></div>
|
||||
<div class="break"></div>
|
||||
<div class="topmenu">
|
||||
<div class="searchbox"><asp:TextBox ID="SearchBox" runat="server" /></div>
|
||||
</div>
|
||||
|
||||
<div class="mainbar">
|
||||
<!--<div id="page-icon-encaps"><asp:Image ID="IconPage" runat="server" ImageUrl="~/Images/PageIcons/iconshock-ignitionkey-40px.png" /></div><h1><asp:Label ID="LabelPageTitle" Text="Installation" runat="server" /></h1>-->
|
||||
|
||||
<div class="box">
|
||||
<div class="content">
|
||||
|
||||
<div id="wizard" class="swMain">
|
||||
<ul>
|
||||
<li><a href="#step-1">
|
||||
<label class="stepNumber">1</label>
|
||||
<span class="stepDesc">
|
||||
Welcome!<br />
|
||||
<small>A short introduction</small>
|
||||
</span>
|
||||
</a></li>
|
||||
<li><a href="#step-2">
|
||||
<label class="stepNumber">2</label>
|
||||
<span class="stepDesc">
|
||||
About you<br />
|
||||
<small>Tell us a little about yourself</small>
|
||||
</span>
|
||||
</a></li>
|
||||
<li><a href="#step-3">
|
||||
<label class="stepNumber">3</label>
|
||||
<span class="stepDesc">
|
||||
Create logon<br />
|
||||
<small>Pick a password</small>
|
||||
</span>
|
||||
</a></li>
|
||||
<li><a href="#step-4">
|
||||
<label class="stepNumber">4</label>
|
||||
<span class="stepDesc">
|
||||
Activity<br />
|
||||
<small>How much do you wish to engage?</small>
|
||||
</span>
|
||||
</a></li>
|
||||
<li><a href="#step-5">
|
||||
<label class="stepNumber">5</label>
|
||||
<span class="stepDesc">
|
||||
Complete<br />
|
||||
<small>All done. Let's login!</small>
|
||||
</span>
|
||||
</a></li>
|
||||
</ul>
|
||||
<div id="step-1">
|
||||
<h2>Welcome to OrganizationName</h2>
|
||||
<p>This is the organization's custom welcome text. It is set in Admin / Org Settings.</p> <asp:Label runat="server" ID="LabelTest" />
|
||||
|
||||
<div class="entryLabelsAdmin" style="width:250px">
|
||||
What is this server's /etc/hostname?<br />
|
||||
What is this server's internal IP?<br />
|
||||
What is your favorite color?
|
||||
</div>
|
||||
<div class="entryFieldsAdmin">
|
||||
<asp:TextBox CssClass="textinput" ID="TextServerName" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextServerAddress" runat="server" /> <br />
|
||||
<asp:DropDownList ID="DropFavoriteColor" runat="server" /> <br />
|
||||
</div>
|
||||
</div>
|
||||
<div id="step-2">
|
||||
<div id="DivDatabaseUnwritable">
|
||||
<h2>Fix File Permissions</h2>
|
||||
<asp:Image ImageUrl="~/Images/Icons/iconshock-cross-96px.png" ID="FailWriteConfig" runat="server" ImageAlign="Left" /><p>The bad news is that we can't write to the configuration file. This is fairly normal for a new installation. The good news is that you can fix that, so we can continue installing. Please open a shell to the Swarmops server and execute the following commands:</p><br/>
|
||||
<p><strong>cd /etc/swarmops<br/>sudo chown www-data:www-data database.config</strong></p>
|
||||
<p>The installation will continue when it detects that these steps have been taken.</p>
|
||||
</div>
|
||||
<div id="DivDatabasePermissionProblem" style="display:none">
|
||||
<h2>Fix Database Permissions</h2>
|
||||
<asp:Image ImageUrl="~/Images/Icons/iconshock-cross-96px.png" ID="Image1" runat="server" ImageAlign="Left" /><p>There seems to be an error with the database credentials, or more likely, the permissions for those credentials. <strong>Edit the database permissions until you have green ticks in all boxes below.</strong> (If you made a mistake filling in the database credentials, you can <a href="javascript:ReturnToCredentials();">return to entering credentials</a>.)</p>
|
||||
<p>The installation will continue when it detects this has been corrected, and the table below will update continuously as you change database permissions.</p>
|
||||
<table>
|
||||
<thead><tr><th> </th><th>Can login?</th><th>Can SELECT?</th><th>Can EXECUTE?</th><th>Can alter schema?</th></tr></thead>
|
||||
<tr>
|
||||
<td class="PermissionsErrorCredentials">Read credentials</td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionReadCredentialCanLogin"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionReadCredentialCanSelect"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionReadCredentialCanExecute"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionReadCredentialCanAdmin"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="PermissionsErrorCredentials">Write credentials</td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionWriteCredentialCanLogin"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionWriteCredentialCanSelect"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionWriteCredentialCanExecute"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionWriteCredentialCanAdmin"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="PermissionsErrorCredentials">Admin credentials</td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionAdminCredentialCanLogin"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionAdminCredentialCanSelect"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionAdminCredentialCanExecute"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionAdminCredentialCanAdmin"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="DivDatabaseRootConfig" style="display:none">
|
||||
<h2>Create the database and users</h2>
|
||||
<p>The Swarmops install sequence can set up the database and users for you, if you provide a root password to the MySQL database server.</p>
|
||||
<p>(If you don't trust the Swarmops install to do that, that's fine, go to <a href="javascript:goManualCredentials();">manual account credentials</a>.)</p>
|
||||
<div class="entryLabelsAdmin" style="width:250px">Hostname of MySQL database server<br/>Root password for that MySQL server<br/> </div>
|
||||
<div class="entryFieldsAdmin"><input type="text" id="TextMysqlServerHost" value="localhost"/> <br/><input type="password" id="TextMysqlRootPassword"/> </div>
|
||||
</div>
|
||||
<div id="DivDatabaseManualConfig" style="display:none">
|
||||
<h2>Connect to existing database</h2>
|
||||
<p>Before you fill this in, you will need to have created a database on a MySQL server that this web server can access, and set up user accounts that can access it. For security reasons, we <strong>require</strong> having three separate accounts - one for reading (SELECT permissions only), one for writing (SELECT and EXECUTE), and one for admin. All three accounts also need SELECT permissions on the mysql database.</p>
|
||||
|
||||
<div class="entryLabelsAdmin" style="width:120px">
|
||||
<br/>
|
||||
Database<br />
|
||||
Server<br />
|
||||
User<br/>
|
||||
Password
|
||||
</div>
|
||||
<div class="entryFieldsAdmin" style="width:80px">
|
||||
<strong>Read access</strong><br/>
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsReadDatabase" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsReadServer" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsReadUser" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsReadPassword" TextMode="Password" runat="server" /> <br />
|
||||
</div>
|
||||
<div class="entryFieldsAdmin" style="width:80px;margin-left:10px">
|
||||
<strong>Write access</strong><br/>
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsWriteDatabase" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsWriteServer" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsWriteUser" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsWritePassword" TextMode="Password" runat="server" /> <br />
|
||||
</div>
|
||||
<div class="entryFieldsAdmin" style="width:80px;margin-left:10px">
|
||||
<strong>Admin access</strong><br/>
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminDatabase" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminServer" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminUser" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminPassword" TextMode="Password" runat="server" /> <br />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="step-3">
|
||||
<h2>Initializing database</h2>
|
||||
<div id="DivProgressDatabase"></div>
|
||||
<p>Please wait while the database is being initialized with schemas and geographic data from the Swarmops servers. This is going to take a <strong>significant</strong> amount of time; we're loading tons of geodata onto your new server.</p>
|
||||
<p><span id="SpanInitProgressMessage">Initializing...</span></p>
|
||||
</div>
|
||||
<div id="step-4">
|
||||
<h2>Creating the first user</h2>
|
||||
<p>Your new Swarmops server has been loaded with the geographic layout of the countries we're active in, and the first organization - the <em>Sandbox</em> - has been created. We are now going to create your user account, which will become the systems administrator account of this Swarmops installation.</p>
|
||||
|
||||
<p>(You can add other people to the <em>System Administrator</em> role later.)</p>
|
||||
|
||||
<div class="entryLabelsAdmin" style="width:250px">
|
||||
Your full name<br />
|
||||
Your email<br />
|
||||
Your password<br/>
|
||||
Repeat password
|
||||
</div>
|
||||
<div class="entryFieldsAdmin">
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserName" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserMail" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserPassword1" TextMode="Password" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserPassword2" TextMode="Password" runat="server" /> <br />
|
||||
</div>
|
||||
</div>
|
||||
<div id="step-5" style="display:none">
|
||||
<h2>All done - ready to login</h2>
|
||||
<p>Your Swarmops installation is ready! Press Finish to log in as your new user and start using it.</p>
|
||||
<div style="display:none"><asp:Button runat="server" ID="ButtonLogin" OnClick="ButtonLogin_Click" Text="This button is invisible."/></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<asp:Label ID="LabelDashboardTemporaryContent" runat="server" /> <a href="/Pages/v5/Governance/Vote.aspx"><asp:Label ID="LabelGoThere2" runat="server" /></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="sidebar">
|
||||
<h2 class="blue"><asp:Label ID="LabelSidebarInfoHeader" runat="server" /><span class="arrow"></span></h2>
|
||||
|
||||
<div class="box">
|
||||
<div class="content">
|
||||
<asp:Label ID="LabelSidebarInfoContent" runat="server" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="blue"><asp:Label ID="LabelSidebarActionsHeader" runat="server" /><span class="arrow"></span></h2>
|
||||
|
||||
<div class="box">
|
||||
<div class="content">
|
||||
<asp:Label ID="LabelSidebarActionsContent" runat="server" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="orange"><asp:Label ID="LabelSidebarTodoHeader" runat="server" /><span class="arrow"></span></h2>
|
||||
|
||||
<div class="box">
|
||||
<div class="content">
|
||||
<div class="link-row-encaps" onclick="return false;" >
|
||||
<div class="link-row-icon" style="background-image:url('/Images/Icons/iconshock-databaseconnect-16px.png')"></div>
|
||||
<asp:Label ID="LabelSidebarTodoConnectDatabase" runat="server" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace Swarmops.Frontend.Pages.Public
|
||||
{
|
||||
public partial class Signup : System.Web.UI.Page
|
||||
{
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,406 +1,406 @@
|
||||
/*
|
||||
SmartWizard 2.0 plugin
|
||||
jQuery Wizard control Plugin
|
||||
by Dipu
|
||||
|
||||
http://www.techlaboratory.net
|
||||
http://tech-laboratory.blogspot.com
|
||||
*/
|
||||
.swMain {
|
||||
position:relative;
|
||||
display:block;
|
||||
margin:0;
|
||||
padding:0;
|
||||
border: 0px solid #CCC;
|
||||
overflow:visible;
|
||||
/* float:left;
|
||||
width:980px; */
|
||||
}
|
||||
.swMain .stepContainer {
|
||||
display:block;
|
||||
position: relative;
|
||||
margin: 0;
|
||||
padding:0;
|
||||
border: 0px solid #CCC;
|
||||
overflow:hidden;
|
||||
clear:right;
|
||||
height:300px;
|
||||
}
|
||||
|
||||
.swMain .stepContainer div.content {
|
||||
float:left;
|
||||
margin: 0;
|
||||
padding:5px;
|
||||
padding-left: 15px;
|
||||
text-align:left;
|
||||
overflow:auto;
|
||||
z-index:88;
|
||||
clear:both;
|
||||
display:block;
|
||||
height: 300px;
|
||||
/*position: absolute;
|
||||
border-radius: 5px;
|
||||
width:470px;
|
||||
border: 1px solid #CCC;
|
||||
font: normal 12px Ubuntu, sans-serif;
|
||||
color:#5A5655;
|
||||
background-color:#F8F8F8;
|
||||
height:300px;*/
|
||||
}
|
||||
|
||||
.swMain div.actionBar {
|
||||
display:block;
|
||||
position: relative;
|
||||
clear:right;
|
||||
margin: 3px 0 0 0;
|
||||
/*border: 1px solid #CCC;*/
|
||||
padding: 0;
|
||||
color: #5A5655;
|
||||
/*background-color: #F8F8F8;*/
|
||||
height:40px;
|
||||
/* width:730px;
|
||||
float:right; */
|
||||
text-align:left;
|
||||
overflow:auto;
|
||||
z-index:88;
|
||||
/*border-radius: 5px;*/
|
||||
}
|
||||
|
||||
.swMain .stepContainer .StepTitle {
|
||||
display:block;
|
||||
position: relative;
|
||||
margin:0;
|
||||
border:1px solid #E0E0E0;
|
||||
padding:5px;
|
||||
font: bold 16px Ubuntu, sans-serif;
|
||||
color:#5A5655;
|
||||
background-color:#E0E0E0;
|
||||
clear:both;
|
||||
text-align:left;
|
||||
z-index:88;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.swMain ul.anchor {
|
||||
position: relative;
|
||||
display:block;
|
||||
float:left;
|
||||
list-style: none;
|
||||
padding: 0px;
|
||||
margin: 5px 10px 0 0;
|
||||
border: 0px solid #CCCCCC;
|
||||
background: transparent; /*#EEEEEE */
|
||||
}
|
||||
.swMain ul.anchor li{
|
||||
position: relative;
|
||||
display:block;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
padding-top:3px;
|
||||
padding-bottom: 3px;
|
||||
border: 0px solid #E0E0E0;
|
||||
float: left;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* Anchor Element Style */
|
||||
.swMain ul.anchor li a {
|
||||
display:block;
|
||||
position:relative;
|
||||
float:left;
|
||||
margin:0;
|
||||
padding:3px;
|
||||
height:55px;
|
||||
width:180px;
|
||||
text-decoration: none;
|
||||
outline-style:none;
|
||||
border-radius: 5px;
|
||||
z-index:99;
|
||||
}
|
||||
.swMain ul.anchor li a .stepNumber{
|
||||
position:relative;
|
||||
float:left;
|
||||
width:30px;
|
||||
text-align: center;
|
||||
padding:5px;
|
||||
padding-top:0;
|
||||
font: 300 45px Ubuntu, sans-serif;
|
||||
}
|
||||
.swMain ul.anchor li a .stepDesc{
|
||||
position:relative;
|
||||
display:block;
|
||||
float:left;
|
||||
text-align: left;
|
||||
padding:5px;
|
||||
width:70%;
|
||||
font: bold 15px Ubuntu, sans-serif;
|
||||
}
|
||||
.swMain ul.anchor li a .stepDesc small{
|
||||
font: normal 11px Ubuntu, sans-serif;
|
||||
line-height: 12px;
|
||||
}
|
||||
.swMain ul.anchor li a.selected{
|
||||
color:#7F5500;
|
||||
background: #EA8511; /* EA8511 */
|
||||
border: 1px solid #EA8511;
|
||||
cursor:text;
|
||||
box-shadow: 2px 2px 4px #7F5500;
|
||||
|
||||
background-color: #FFBC37;
|
||||
background: -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFC145', endColorstr='#F0AB22'); /* MSIE */
|
||||
background: -moz-linear-gradient(top, #FFC145, #F0AB22); /* Mozilla */
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#FFC145), to(#F0AB22)); /* Chrome, Safari */
|
||||
text-shadow: #FFEDC8 0px 0px 3px, #FFEDC8 0px 0px 3px;
|
||||
|
||||
border-color: #C78B15;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
left: -1px;
|
||||
}
|
||||
.swMain ul.anchor li a.selected:hover {
|
||||
/* color:#F8F8F8; */
|
||||
/* background: #EA8511; */
|
||||
}
|
||||
|
||||
.swMain ul.anchor li a.done {
|
||||
position:relative;
|
||||
color:#FFF;
|
||||
background: #8CC63F;
|
||||
border: 1px solid #8CC63F;
|
||||
z-index:99;
|
||||
background-color: #A2BEFF;
|
||||
background: -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#B0C8FF', endColorstr='#86A6F0'); /* MSIE */
|
||||
background: -moz-linear-gradient(top, #B0C8FF, #86A6F0); /* Mozilla */
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#B0C8FF), to(#86A6F0)); /* Chrome, Safari */
|
||||
text-shadow: #476EC7 0px 0px 3px, #476EC7 0px 0px 3px;
|
||||
|
||||
border-color: #476EC7;
|
||||
}
|
||||
.swMain ul.anchor li a.done:hover {
|
||||
/* background: #8CC63F; */
|
||||
text-shadow: #1C397E 0px 0px 3px, #1C397E 0px 0px 3px;
|
||||
border: 1px solid #1C397E;
|
||||
}
|
||||
.swMain ul.anchor li a.disabled {
|
||||
color:#CCCCCC;
|
||||
background: #F8F8F8;
|
||||
border: 1px solid #CCC;
|
||||
cursor:text;
|
||||
}
|
||||
.swMain ul.anchor li a.disabled:hover {
|
||||
color:#CCCCCC;
|
||||
background: #F8F8F8;
|
||||
}
|
||||
|
||||
.swMain ul.anchor li a.error {
|
||||
color:#6c6c6c !important;
|
||||
background: #f08f75 !important;
|
||||
border: 1px solid #fb3500 !important;
|
||||
}
|
||||
.swMain ul.anchor li a.error:hover {
|
||||
color:#000 !important;
|
||||
}
|
||||
|
||||
.swMain .buttonNext {
|
||||
display:block;
|
||||
float:right;
|
||||
margin:5px 3px 0 3px;
|
||||
padding:5px;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
font: bold 13px Ubuntu, sans-serif;
|
||||
width:100px;
|
||||
color:#FFF;
|
||||
outline-style:none;
|
||||
background-color: #5A5655;
|
||||
border: 1px solid #5A5655;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.swMain .buttonPrevious {
|
||||
display:block;
|
||||
float:right;
|
||||
margin:5px 3px 0 3px;
|
||||
padding:5px;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
font: bold 13px Ubuntu, sans-serif;
|
||||
width:100px;
|
||||
color:#FFF;
|
||||
outline-style:none;
|
||||
background-color: #5A5655;
|
||||
border: 1px solid #5A5655;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.swMain .buttonFinish {
|
||||
display:block;
|
||||
float:right;
|
||||
margin:5px 10px 0 3px;
|
||||
padding:5px;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
font: bold 13px Ubuntu, sans-serif;
|
||||
width:100px;
|
||||
color:#FFF;
|
||||
outline-style:none;
|
||||
background-color: #5A5655;
|
||||
border: 1px solid #5A5655;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.swMain .buttonPrevious {
|
||||
position: relative;
|
||||
color: white;
|
||||
background: #8CC63F;
|
||||
border: 1px solid #8CC63F;
|
||||
z-index: 99;
|
||||
box-shadow: 1px 1px 4px #476EC7;
|
||||
background: -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#B0C8FF', endColorstr='#86A6F0');
|
||||
background: -moz-linear-gradient(top, #B0C8FF, #86A6F0);
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#B0C8FF), to(#86A6F0));
|
||||
text-shadow: #476EC7 0px 0px 3px, #476EC7 0px 0px 3px;
|
||||
border-color: #476EC7;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
left: -1px;
|
||||
}
|
||||
|
||||
.swMain .buttonNext, .swMain .buttonFinish {
|
||||
color: #7F5500;
|
||||
background: #EA8511;
|
||||
border: 1px solid #EA8511;
|
||||
box-shadow: 1px 1px 4px #7F5500;
|
||||
background: -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFC145', endColorstr='#F0AB22');
|
||||
background: -moz-linear-gradient(top, #FFC145, #F0AB22);
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#FFC145), to(#F0AB22));
|
||||
text-shadow: #FFEDC8 0px 0px 3px, #FFEDC8 0px 0px 3px;
|
||||
border-color: #C78B15;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
left: -1px;
|
||||
}
|
||||
|
||||
|
||||
.swMain .buttonPrevious:hover
|
||||
{
|
||||
top: -2px;
|
||||
left: -2px;
|
||||
box-shadow: 2px 2px 4px #476EC7;
|
||||
}
|
||||
|
||||
.swMain .buttonPrevious:active
|
||||
{
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
box-shadow: 0px 0px 4px #476EC7;
|
||||
}
|
||||
|
||||
.swMain .buttonNext:hover, .swMain .buttonFinish:hover
|
||||
{
|
||||
top: -2px;
|
||||
left: -2px;
|
||||
box-shadow: 2px 2px 4px #7F5500;
|
||||
}
|
||||
|
||||
.swMain .buttonNext:active, .swMain .buttonFinish:active
|
||||
{
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
box-shadow: 0px 0px 4px #7F5500;
|
||||
}
|
||||
|
||||
|
||||
.swMain .buttonDisabled {
|
||||
color:#F8F8F8 !important;
|
||||
background-color: #CCCCCC !important;
|
||||
border: 1px solid #CCCCCC !important;
|
||||
background: -ms-filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#CCCCCC', endColorstr='#BBBBBB') !important;
|
||||
background: -moz-linear-gradient(top, #CCCCCC, #BBBBBB) !important;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#CCCCCC), to(#BBBBBB)) !important;
|
||||
cursor:text;
|
||||
top: 0px !important;
|
||||
left: 0px !important;
|
||||
box-shadow: none !important;
|
||||
text-shadow: none !important;
|
||||
}
|
||||
|
||||
|
||||
/* Form Styles */
|
||||
|
||||
.txtBox {
|
||||
border:1px solid #CCCCCC;
|
||||
color:#5A5655;
|
||||
font:13px Ubuntu,sans-serif;
|
||||
padding:2px;
|
||||
width:430px;
|
||||
}
|
||||
.txtBox:focus {
|
||||
border:1px solid #EA8511;
|
||||
}
|
||||
|
||||
.swMain .loader {
|
||||
position:relative;
|
||||
display:none;
|
||||
float:left;
|
||||
margin: 2px 0 0 2px;
|
||||
padding:8px 10px 8px 40px;
|
||||
border: 1px solid #FFD700;
|
||||
font: bold 13px Ubuntu, sans-serif;
|
||||
color:#5A5655;
|
||||
background: #FFF url(../images/loader.gif) no-repeat 5px;
|
||||
border-radius: 5px;
|
||||
z-index:998;
|
||||
}
|
||||
.swMain .msgBox {
|
||||
position:relative;
|
||||
display:none;
|
||||
float:left;
|
||||
margin: 4px 0 0 5px;
|
||||
padding:5px;
|
||||
border: 1px solid #FFD700;
|
||||
background-color: #FFFFDD;
|
||||
font: normal 12px Ubuntu, sans-serif;
|
||||
color:#5A5655;
|
||||
-moz-border-radius : 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
z-index:999;
|
||||
min-width:200px;
|
||||
}
|
||||
.swMain .msgBox .content {
|
||||
font: normal 12px Ubuntu,sans-serif;
|
||||
padding: 0px;
|
||||
float:left;
|
||||
}
|
||||
.swMain .msgBox .close {
|
||||
border: 1px solid #CCC;
|
||||
border-radius: 3px;
|
||||
color: #CCC;
|
||||
display: block;
|
||||
float: right;
|
||||
margin: 0 0 0 5px;
|
||||
outline-style: none;
|
||||
padding: 0 2px 0 2px;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
}
|
||||
.swMain .msgBox .close:hover{
|
||||
color: #EA8511;
|
||||
border: 1px solid #EA8511;
|
||||
}
|
||||
|
||||
.ui-progressbar-value {
|
||||
background-image: url('/Images/Abstract/swarmops-progressbar-animation.gif');
|
||||
height: 13px;
|
||||
border-radius: 3px;
|
||||
box-shadow: 1px 0px 5px 0px #7F5500;
|
||||
}
|
||||
|
||||
|
||||
.ui-progressbar {
|
||||
height: 13px;
|
||||
width: 100%;
|
||||
border: solid 1px #C78B15;
|
||||
border-radius: 3px;
|
||||
box-shadow: inset 0px 1px 10px 0px #C78B15;
|
||||
margin-bottom: 8px;
|
||||
/*
|
||||
SmartWizard 2.0 plugin
|
||||
jQuery Wizard control Plugin
|
||||
by Dipu
|
||||
|
||||
http://www.techlaboratory.net
|
||||
http://tech-laboratory.blogspot.com
|
||||
*/
|
||||
.swMain {
|
||||
position:relative;
|
||||
display:block;
|
||||
margin:0;
|
||||
padding:0;
|
||||
border: 0px solid #CCC;
|
||||
overflow:visible;
|
||||
/* float:left;
|
||||
width:980px; */
|
||||
}
|
||||
.swMain .stepContainer {
|
||||
display:block;
|
||||
position: relative;
|
||||
margin: 0;
|
||||
padding:0;
|
||||
border: 0px solid #CCC;
|
||||
overflow:hidden;
|
||||
clear:right;
|
||||
height:300px;
|
||||
}
|
||||
|
||||
.swMain .stepContainer div.content {
|
||||
float:left;
|
||||
margin: 0;
|
||||
padding:5px;
|
||||
padding-left: 15px;
|
||||
text-align:left;
|
||||
overflow:auto;
|
||||
z-index:88;
|
||||
clear:both;
|
||||
display:block;
|
||||
height: 300px;
|
||||
/*position: absolute;
|
||||
border-radius: 5px;
|
||||
width:470px;
|
||||
border: 1px solid #CCC;
|
||||
font: normal 12px Ubuntu, sans-serif;
|
||||
color:#5A5655;
|
||||
background-color:#F8F8F8;
|
||||
height:300px;*/
|
||||
}
|
||||
|
||||
.swMain div.actionBar {
|
||||
display:block;
|
||||
position: relative;
|
||||
clear:right;
|
||||
margin: 3px 0 0 0;
|
||||
/*border: 1px solid #CCC;*/
|
||||
padding: 0;
|
||||
color: #5A5655;
|
||||
/*background-color: #F8F8F8;*/
|
||||
height:40px;
|
||||
/* width:730px;
|
||||
float:right; */
|
||||
text-align:left;
|
||||
overflow:auto;
|
||||
z-index:88;
|
||||
/*border-radius: 5px;*/
|
||||
}
|
||||
|
||||
.swMain .stepContainer .StepTitle {
|
||||
display:block;
|
||||
position: relative;
|
||||
margin:0;
|
||||
border:1px solid #E0E0E0;
|
||||
padding:5px;
|
||||
font: bold 16px Ubuntu, sans-serif;
|
||||
color:#5A5655;
|
||||
background-color:#E0E0E0;
|
||||
clear:both;
|
||||
text-align:left;
|
||||
z-index:88;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.swMain ul.anchor {
|
||||
position: relative;
|
||||
display:block;
|
||||
float:left;
|
||||
list-style: none;
|
||||
padding: 0px;
|
||||
margin: 5px 10px 0 0;
|
||||
border: 0px solid #CCCCCC;
|
||||
background: transparent; /*#EEEEEE */
|
||||
}
|
||||
.swMain ul.anchor li{
|
||||
position: relative;
|
||||
display:block;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
padding-top:3px;
|
||||
padding-bottom: 3px;
|
||||
border: 0px solid #E0E0E0;
|
||||
float: left;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* Anchor Element Style */
|
||||
.swMain ul.anchor li a {
|
||||
display:block;
|
||||
position:relative;
|
||||
float:left;
|
||||
margin:0;
|
||||
padding:3px;
|
||||
height:55px;
|
||||
width:180px;
|
||||
text-decoration: none;
|
||||
outline-style:none;
|
||||
border-radius: 5px;
|
||||
z-index:99;
|
||||
}
|
||||
.swMain ul.anchor li a .stepNumber{
|
||||
position:relative;
|
||||
float:left;
|
||||
width:30px;
|
||||
text-align: center;
|
||||
padding:5px;
|
||||
padding-top:0;
|
||||
font: 300 45px Ubuntu, sans-serif;
|
||||
}
|
||||
.swMain ul.anchor li a .stepDesc{
|
||||
position:relative;
|
||||
display:block;
|
||||
float:left;
|
||||
text-align: left;
|
||||
padding:5px;
|
||||
width:70%;
|
||||
font: bold 15px Ubuntu, sans-serif;
|
||||
}
|
||||
.swMain ul.anchor li a .stepDesc small{
|
||||
font: normal 11px Ubuntu, sans-serif;
|
||||
line-height: 12px;
|
||||
}
|
||||
.swMain ul.anchor li a.selected{
|
||||
color:#7F5500;
|
||||
background: #EA8511; /* EA8511 */
|
||||
border: 1px solid #EA8511;
|
||||
cursor:text;
|
||||
box-shadow: 2px 2px 4px #7F5500;
|
||||
|
||||
background-color: #FFBC37;
|
||||
background: -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFC145', endColorstr='#F0AB22'); /* MSIE */
|
||||
background: -moz-linear-gradient(top, #FFC145, #F0AB22); /* Mozilla */
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#FFC145), to(#F0AB22)); /* Chrome, Safari */
|
||||
text-shadow: #FFEDC8 0px 0px 3px, #FFEDC8 0px 0px 3px;
|
||||
|
||||
border-color: #C78B15;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
left: -1px;
|
||||
}
|
||||
.swMain ul.anchor li a.selected:hover {
|
||||
/* color:#F8F8F8; */
|
||||
/* background: #EA8511; */
|
||||
}
|
||||
|
||||
.swMain ul.anchor li a.done {
|
||||
position:relative;
|
||||
color:#FFF;
|
||||
background: #8CC63F;
|
||||
border: 1px solid #8CC63F;
|
||||
z-index:99;
|
||||
background-color: #A2BEFF;
|
||||
background: -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#B0C8FF', endColorstr='#86A6F0'); /* MSIE */
|
||||
background: -moz-linear-gradient(top, #B0C8FF, #86A6F0); /* Mozilla */
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#B0C8FF), to(#86A6F0)); /* Chrome, Safari */
|
||||
text-shadow: #476EC7 0px 0px 3px, #476EC7 0px 0px 3px;
|
||||
|
||||
border-color: #476EC7;
|
||||
}
|
||||
.swMain ul.anchor li a.done:hover {
|
||||
/* background: #8CC63F; */
|
||||
text-shadow: #1C397E 0px 0px 3px, #1C397E 0px 0px 3px;
|
||||
border: 1px solid #1C397E;
|
||||
}
|
||||
.swMain ul.anchor li a.disabled {
|
||||
color:#CCCCCC;
|
||||
background: #F8F8F8;
|
||||
border: 1px solid #CCC;
|
||||
cursor:text;
|
||||
}
|
||||
.swMain ul.anchor li a.disabled:hover {
|
||||
color:#CCCCCC;
|
||||
background: #F8F8F8;
|
||||
}
|
||||
|
||||
.swMain ul.anchor li a.error {
|
||||
color:#6c6c6c !important;
|
||||
background: #f08f75 !important;
|
||||
border: 1px solid #fb3500 !important;
|
||||
}
|
||||
.swMain ul.anchor li a.error:hover {
|
||||
color:#000 !important;
|
||||
}
|
||||
|
||||
.swMain .buttonNext {
|
||||
display:block;
|
||||
float:right;
|
||||
margin:5px 3px 0 3px;
|
||||
padding:5px;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
font: bold 13px Ubuntu, sans-serif;
|
||||
width:100px;
|
||||
color:#FFF;
|
||||
outline-style:none;
|
||||
background-color: #5A5655;
|
||||
border: 1px solid #5A5655;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.swMain .buttonPrevious {
|
||||
display:block;
|
||||
float:right;
|
||||
margin:5px 3px 0 3px;
|
||||
padding:5px;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
font: bold 13px Ubuntu, sans-serif;
|
||||
width:100px;
|
||||
color:#FFF;
|
||||
outline-style:none;
|
||||
background-color: #5A5655;
|
||||
border: 1px solid #5A5655;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.swMain .buttonFinish {
|
||||
display:block;
|
||||
float:right;
|
||||
margin:5px 10px 0 3px;
|
||||
padding:5px;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
font: bold 13px Ubuntu, sans-serif;
|
||||
width:100px;
|
||||
color:#FFF;
|
||||
outline-style:none;
|
||||
background-color: #5A5655;
|
||||
border: 1px solid #5A5655;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.swMain .buttonPrevious {
|
||||
position: relative;
|
||||
color: white;
|
||||
background: #8CC63F;
|
||||
border: 1px solid #8CC63F;
|
||||
z-index: 99;
|
||||
box-shadow: 1px 1px 4px #476EC7;
|
||||
background: -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#B0C8FF', endColorstr='#86A6F0');
|
||||
background: -moz-linear-gradient(top, #B0C8FF, #86A6F0);
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#B0C8FF), to(#86A6F0));
|
||||
text-shadow: #476EC7 0px 0px 3px, #476EC7 0px 0px 3px;
|
||||
border-color: #476EC7;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
left: -1px;
|
||||
}
|
||||
|
||||
.swMain .buttonNext, .swMain .buttonFinish {
|
||||
color: #7F5500;
|
||||
background: #EA8511;
|
||||
border: 1px solid #EA8511;
|
||||
box-shadow: 1px 1px 4px #7F5500;
|
||||
background: -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFC145', endColorstr='#F0AB22');
|
||||
background: -moz-linear-gradient(top, #FFC145, #F0AB22);
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#FFC145), to(#F0AB22));
|
||||
text-shadow: #FFEDC8 0px 0px 3px, #FFEDC8 0px 0px 3px;
|
||||
border-color: #C78B15;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
left: -1px;
|
||||
}
|
||||
|
||||
|
||||
.swMain .buttonPrevious:hover
|
||||
{
|
||||
top: -2px;
|
||||
left: -2px;
|
||||
box-shadow: 2px 2px 4px #476EC7;
|
||||
}
|
||||
|
||||
.swMain .buttonPrevious:active
|
||||
{
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
box-shadow: 0px 0px 4px #476EC7;
|
||||
}
|
||||
|
||||
.swMain .buttonNext:hover, .swMain .buttonFinish:hover
|
||||
{
|
||||
top: -2px;
|
||||
left: -2px;
|
||||
box-shadow: 2px 2px 4px #7F5500;
|
||||
}
|
||||
|
||||
.swMain .buttonNext:active, .swMain .buttonFinish:active
|
||||
{
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
box-shadow: 0px 0px 4px #7F5500;
|
||||
}
|
||||
|
||||
|
||||
.swMain .buttonDisabled {
|
||||
color:#F8F8F8 !important;
|
||||
background-color: #CCCCCC !important;
|
||||
border: 1px solid #CCCCCC !important;
|
||||
background: -ms-filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#CCCCCC', endColorstr='#BBBBBB') !important;
|
||||
background: -moz-linear-gradient(top, #CCCCCC, #BBBBBB) !important;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#CCCCCC), to(#BBBBBB)) !important;
|
||||
cursor:text;
|
||||
top: 0px !important;
|
||||
left: 0px !important;
|
||||
box-shadow: none !important;
|
||||
text-shadow: none !important;
|
||||
}
|
||||
|
||||
|
||||
/* Form Styles */
|
||||
|
||||
.txtBox {
|
||||
border:1px solid #CCCCCC;
|
||||
color:#5A5655;
|
||||
font:13px Ubuntu,sans-serif;
|
||||
padding:2px;
|
||||
width:430px;
|
||||
}
|
||||
.txtBox:focus {
|
||||
border:1px solid #EA8511;
|
||||
}
|
||||
|
||||
.swMain .loader {
|
||||
position:relative;
|
||||
display:none;
|
||||
float:left;
|
||||
margin: 2px 0 0 2px;
|
||||
padding:8px 10px 8px 40px;
|
||||
border: 1px solid #FFD700;
|
||||
font: bold 13px Ubuntu, sans-serif;
|
||||
color:#5A5655;
|
||||
background: #FFF url(../images/loader.gif) no-repeat 5px;
|
||||
border-radius: 5px;
|
||||
z-index:998;
|
||||
}
|
||||
.swMain .msgBox {
|
||||
position:relative;
|
||||
display:none;
|
||||
float:left;
|
||||
margin: 4px 0 0 5px;
|
||||
padding:5px;
|
||||
border: 1px solid #FFD700;
|
||||
background-color: #FFFFDD;
|
||||
font: normal 12px Ubuntu, sans-serif;
|
||||
color:#5A5655;
|
||||
-moz-border-radius : 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
z-index:999;
|
||||
min-width:200px;
|
||||
}
|
||||
.swMain .msgBox .content {
|
||||
font: normal 12px Ubuntu,sans-serif;
|
||||
padding: 0px;
|
||||
float:left;
|
||||
}
|
||||
.swMain .msgBox .close {
|
||||
border: 1px solid #CCC;
|
||||
border-radius: 3px;
|
||||
color: #CCC;
|
||||
display: block;
|
||||
float: right;
|
||||
margin: 0 0 0 5px;
|
||||
outline-style: none;
|
||||
padding: 0 2px 0 2px;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
}
|
||||
.swMain .msgBox .close:hover{
|
||||
color: #EA8511;
|
||||
border: 1px solid #EA8511;
|
||||
}
|
||||
|
||||
.ui-progressbar-value {
|
||||
background-image: url('/Images/Abstract/swarmops-progressbar-animation.gif');
|
||||
height: 13px;
|
||||
border-radius: 3px;
|
||||
box-shadow: 1px 0px 5px 0px #7F5500;
|
||||
}
|
||||
|
||||
|
||||
.ui-progressbar {
|
||||
height: 13px;
|
||||
width: 100%;
|
||||
border: solid 1px #C78B15;
|
||||
border-radius: 3px;
|
||||
box-shadow: inset 0px 1px 10px 0px #C78B15;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
The only override for the Pages/Public, Style, Images, and Security folders is that no authentication is required.
|
||||
-->
|
||||
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
|
||||
<system.web>
|
||||
<authorization>
|
||||
<allow users="*" />
|
||||
</authorization>
|
||||
</system.web>
|
||||
</configuration>
|
||||
@@ -30,7 +30,7 @@ namespace Swarmops.Pages.Security
|
||||
|
||||
if (!SwarmDb.Configuration.IsConfigured())
|
||||
{
|
||||
Response.Redirect ("/Pages/v5/Init/", true);
|
||||
Response.Redirect ("/Initialize", true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user