Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data.SQLite;
- using System.Diagnostics;
- using System.Drawing;
- using System.Globalization;
- using System.IO;
- using System.IO.Pipes;
- using System.Linq;
- using System.Management;
- using System.Net;
- using System.Reflection;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Microsoft.VisualBasic;
- using Microsoft.VisualBasic.CompilerServices;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using SHDocVw;
- namespace Cold_Turkey
- {
- [DesignerGenerated]
- public class ColdTurkey : Form
- {
- [DllImport("wininet.dll", CharSet = CharSet.Auto)]
- private static extern bool InternetGetConnectedState(ref int Description, int ReservedValue);
- [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
- private static extern bool AttachConsole(int dwProcessId);
- [DllImport("gdi32.dll")]
- private static extern int GetDeviceCaps(IntPtr hdc, ColdTurkey.DeviceCap nIndex);
- private float GetScalingFactors()
- {
- IntPtr hdc = Graphics.FromHwnd(IntPtr.Zero).GetHdc();
- int deviceCaps = ColdTurkey.GetDeviceCaps(hdc, ColdTurkey.DeviceCap.VERTRES);
- int deviceCaps2 = ColdTurkey.GetDeviceCaps(hdc, ColdTurkey.DeviceCap.DESKTOPVERTRES);
- float deviceCaps3 = (float)ColdTurkey.GetDeviceCaps(hdc, ColdTurkey.DeviceCap.LOGPIXELSY);
- float num = (float)deviceCaps2 / (float)deviceCaps;
- float num2 = deviceCaps3 / 96f;
- float result;
- if (num != 1f)
- {
- result = num;
- }
- else
- {
- result = num2;
- }
- return result;
- }
- private void AdjustDPI()
- {
- try
- {
- float scalingFactors = this.GetScalingFactors();
- if (scalingFactors == 1f)
- {
- this.webBrowserScale = 100;
- }
- else if (scalingFactors == 1.25f)
- {
- this.webBrowserScale = 150;
- }
- else if (scalingFactors == 1.5f)
- {
- this.webBrowserScale = 200;
- }
- else if (scalingFactors == 1.75f)
- {
- this.webBrowserScale = 250;
- }
- else if (scalingFactors == 2f)
- {
- this.webBrowserScale = 300;
- }
- else if (scalingFactors == 2.25f)
- {
- this.webBrowserScale = 350;
- }
- else if (scalingFactors == 2.5f)
- {
- this.webBrowserScale = 400;
- }
- else
- {
- this.webBrowserScale = 100;
- }
- }
- catch (Exception ex)
- {
- }
- }
- private void ColdTurkey_Load(object sender, EventArgs e)
- {
- this.AdjustDPI();
- this.OpenDatabases();
- this.LoadSettings();
- this.HandleCommandLineArguments(Environment.GetCommandLineArgs(), false);
- this.SetAdditionalUpdate();
- this.SetAdditionalWin10();
- this.SetAdditionalUsers();
- this.SetWindowTitle();
- this.CalculateAllowances();
- this.calculateAllowancesTimer.Start();
- this.web.ScriptErrorsSuppressed = true;
- this.web.ObjectForScripting = this;
- this.web.Navigate(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\web\\index.html");
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public void OpenDatabases()
- {
- try
- {
- try
- {
- this.dbApp.Open();
- }
- catch (Exception ex)
- {
- if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Cold Turkey\\data-app.db"))
- {
- File.Create(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Cold Turkey\\data-app.db").Dispose();
- }
- this.dbApp.Open();
- }
- try
- {
- this.dbBrowser.Open();
- }
- catch (Exception ex2)
- {
- if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Cold Turkey\\data-browser.db"))
- {
- File.Create(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Cold Turkey\\data-browser.db").Dispose();
- }
- this.dbBrowser.Open();
- }
- try
- {
- this.dbHelper.Open();
- }
- catch (Exception ex3)
- {
- if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Cold Turkey\\data-helper.db"))
- {
- File.Create(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Cold Turkey\\data-helper.db").Dispose();
- }
- this.dbHelper.Open();
- }
- try
- {
- this.dbService.Open();
- }
- catch (Exception ex4)
- {
- if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Cold Turkey\\data-service.db"))
- {
- File.Create(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Cold Turkey\\data-service.db").Dispose();
- }
- this.dbService.Open();
- }
- }
- catch (Exception e)
- {
- this.WriteError(e);
- Interaction.MsgBox("The databases where your settings are stored are locked and can't be opened. Try opening Cold Turkey Blocker in a few seconds.", MsgBoxStyle.Exclamation, "Error Reading Database");
- ProjectData.EndApp();
- }
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public bool HandleCommandLineArguments(string[] args, bool secondInstance)
- {
- bool result = false;
- try
- {
- if (args.Count<string>() > 1)
- {
- bool flag = !secondInstance;
- ColdTurkey.AttachConsole(-1);
- Console.WriteLine("\r\n");
- string text = args[1];
- uint num = <PrivateImplementationDetails>.ComputeStringHash(text);
- if (num <= 1229256295U)
- {
- if (num != 474815838U)
- {
- if (num != 736341131U)
- {
- if (num != 1229256295U)
- {
- goto IL_9C3;
- }
- if (Operators.CompareString(text, "-show-extension-install", false) != 0)
- {
- goto IL_9C3;
- }
- if (secondInstance)
- {
- this.web.Document.InvokeScript("ForceExtensionInstall", new object[]
- {
- this.GetBrowserInstallList()
- });
- this.OpenWindow(false);
- }
- else
- {
- this.settings.Additional.ForceExtensionInstall = "true";
- }
- flag = false;
- result = true;
- goto IL_9CD;
- }
- else if (Operators.CompareString(text, "-help", false) != 0)
- {
- goto IL_9C3;
- }
- }
- else
- {
- if (Operators.CompareString(text, "-first-run", false) != 0)
- {
- goto IL_9C3;
- }
- this.firstRun = true;
- this.settings.Additional.ForceExtensionInstall = "true";
- flag = false;
- result = true;
- goto IL_9CD;
- }
- }
- else
- {
- if (num <= 3528909995U)
- {
- if (num != 2665476292U)
- {
- if (num != 3528909995U)
- {
- goto IL_9C3;
- }
- if (Operators.CompareString(text, "-add", false) != 0)
- {
- goto IL_9C3;
- }
- goto IL_732;
- }
- else if (Operators.CompareString(text, "-start", false) != 0)
- {
- goto IL_9C3;
- }
- }
- else
- {
- if (num != 3872925760U)
- {
- if (num != 4232490106U)
- {
- goto IL_9C3;
- }
- if (Operators.CompareString(text, "-pause", false) != 0)
- {
- goto IL_9C3;
- }
- }
- else
- {
- if (Operators.CompareString(text, "-stop", false) != 0)
- {
- goto IL_9C3;
- }
- try
- {
- if (Operators.CompareString(args[2], "ServiceHubHelperTimer", false) == 0)
- {
- string text2 = args[3];
- if (text2 != null)
- {
- if (this.settings.Blocks[text2] != null)
- {
- if (Operators.CompareString(this.settings.Blocks[text2].LockUnblock, "true", false) == 0 & this.settings.Blocks[text2].Lock.Contains(","))
- {
- this.settings.Blocks[text2].Enabled = "false";
- }
- else if (Operators.CompareString(text2, "Frozen Turkey", false) == 0)
- {
- this.settings.Blocks[text2].Enabled = "false";
- }
- this.settings.Blocks[text2].Lock = "none";
- this.settings.Blocks[text2].Timer = "";
- this.WriteSettingsToDatabase();
- this.PipeSettingsReloadMessage();
- if (secondInstance)
- {
- this.ForceSettingsReload();
- }
- }
- else
- {
- Console.WriteLine("Print available command line arguments using -help\r\n");
- }
- }
- else
- {
- Console.WriteLine("Print available command line arguments using -help\r\n");
- }
- }
- else if (Operators.CompareString(args[2], "ServiceHubHelperRestarted", false) == 0)
- {
- try
- {
- foreach (KeyValuePair<string, Block> keyValuePair in this.settings.Blocks)
- {
- if (Operators.CompareString(keyValuePair.Value.Lock, "restart", false) == 0)
- {
- if (Operators.CompareString(keyValuePair.Value.RestartUnblock, "true", false) == 0)
- {
- keyValuePair.Value.Enabled = "false";
- }
- keyValuePair.Value.Lock = "none";
- keyValuePair.Value.Timer = "";
- }
- }
- }
- finally
- {
- Dictionary<string, Block>.Enumerator enumerator;
- ((IDisposable)enumerator).Dispose();
- }
- this.WriteSettingsToDatabase();
- this.PipeSettingsReloadMessage();
- if (secondInstance)
- {
- this.ForceSettingsReload();
- }
- }
- else
- {
- Console.WriteLine("Print available command line arguments using -help\r\n");
- }
- goto IL_9CD;
- }
- catch (Exception ex)
- {
- Console.WriteLine("Print available command line arguments using -help\r\n");
- goto IL_9CD;
- }
- }
- try
- {
- if (Operators.CompareString(args[2], "ServiceHubHelper", false) == 0)
- {
- if (Operators.CompareString(args[3], "start", false) == 0)
- {
- if (Operators.CompareString(this.settings.Settings.BlockCharity, "true", false) != 0)
- {
- DateTime dateTime = DateAndTime.Now.AddMinutes(10.0);
- this.settings.Additional.Paused = string.Concat(new string[]
- {
- dateTime.Year.ToString(),
- ",",
- dateTime.Month.ToString(),
- ",",
- dateTime.Day.ToString(),
- ",",
- dateTime.Hour.ToString(),
- ",",
- dateTime.Minute.ToString(),
- ",",
- dateTime.Second.ToString()
- });
- this.WriteSettingsToDatabase();
- this.PipeSettingsReloadMessage();
- if (secondInstance)
- {
- this.ForceSettingsReload();
- }
- this.tray.BalloonTipTitle = "Your blocks are paused for 10 minutes!";
- this.tray.BalloonTipText = "Please do not log off to enjoy the full 10 minutes. Thanks for your donation!";
- this.tray.BalloonTipIcon = ToolTipIcon.Info;
- this.previousTrayVisibleState = this.tray.Visible;
- this.tray.Visible = true;
- this.tray.ShowBalloonTip(10000);
- }
- }
- else
- {
- this.settings.Additional.Paused = "false";
- this.WriteSettingsToDatabase();
- this.PipeSettingsReloadMessage();
- if (secondInstance)
- {
- this.ForceSettingsReload();
- }
- this.tray.BalloonTipTitle = "Your blocks have resumed!";
- this.tray.BalloonTipText = "Thanks for taking a pause for a cause!";
- this.tray.BalloonTipIcon = ToolTipIcon.Info;
- this.previousTrayVisibleState = this.tray.Visible;
- this.tray.Visible = true;
- this.tray.ShowBalloonTip(10000);
- }
- }
- else
- {
- Console.WriteLine("Print available command line arguments using -help\r\n");
- }
- goto IL_9CD;
- }
- catch (Exception ex2)
- {
- Console.WriteLine("Print available command line arguments using -help\r\n");
- goto IL_9CD;
- }
- }
- try
- {
- string text3 = args[2];
- if (text3 != null & Operators.CompareString(text3, "Frozen Turkey", false) != 0)
- {
- if (this.settings.Blocks[text3] != null)
- {
- if (Operators.CompareString(this.settings.Blocks[text3].Enabled, "true", false) != 0)
- {
- try
- {
- string left = args[3];
- string text4 = args[4];
- if ((((-(((Operators.CompareString(left, "-lock", false) == 0) > false) ? 1 : 0)) ? 1 : 0) & int.Parse(text4)) != 0)
- {
- this.QuickStart("command", text3, text4);
- this.PipeSettingsReloadMessage();
- if (secondInstance)
- {
- this.ForceSettingsReload();
- }
- }
- else
- {
- Console.WriteLine("Error: Lock parameters are invalid.\r\n");
- }
- goto IL_711;
- }
- catch (Exception ex3)
- {
- this.QuickStart("command", text3, "0");
- this.PipeSettingsReloadMessage();
- if (secondInstance)
- {
- this.ForceSettingsReload();
- }
- goto IL_711;
- }
- }
- Console.WriteLine("Error: Block is already started.\r\n");
- }
- else
- {
- Console.WriteLine("Error: Block name is invalid. No block named " + text3 + " was found.\r\n");
- }
- }
- else
- {
- Console.WriteLine("Error: Block name is invalid. Frozen Turkey can not be started via command line.\r\n");
- }
- IL_711:
- goto IL_9CD;
- }
- catch (Exception ex4)
- {
- Console.WriteLine("Error: Block name not specified.\r\n");
- goto IL_9CD;
- }
- IL_732:
- try
- {
- string text5 = args[2];
- if (text5 != null & Operators.CompareString(text5, "Frozen Turkey", false) != 0)
- {
- if (this.settings.Blocks[text5] != null)
- {
- try
- {
- string left2 = args[3];
- string text6 = args[4];
- if (text6.StartsWith("https://") | text6.StartsWith("http://") | text6.StartsWith("ftp://"))
- {
- if (text6.Contains("://"))
- {
- text6 = text6.Substring(checked(text6.IndexOf("://") + 3));
- }
- if (text6.StartsWith("www."))
- {
- text6 = text6.Substring(4);
- }
- }
- else if (!text6.StartsWith("file://"))
- {
- Console.WriteLine("Error: URL protocol is not supported.\r\n");
- }
- if (Operators.CompareString(left2, "-web", false) == 0)
- {
- if (!this.settings.Blocks[text5].Web.Contains(text6))
- {
- this.settings.Blocks[text5].Web.Add(text6);
- this.WriteSettingsToDatabase();
- this.PipeSettingsReloadMessage();
- if (secondInstance)
- {
- this.ForceSettingsReload();
- }
- }
- }
- else if (Operators.CompareString(left2, "-exception", false) == 0)
- {
- if (Operators.CompareString(this.settings.Blocks[text5].Lock, "none", false) != 0)
- {
- this.settings.Blocks[text5].Exceptions.Add(text6);
- this.WriteSettingsToDatabase();
- this.PipeSettingsReloadMessage();
- if (secondInstance)
- {
- this.ForceSettingsReload();
- }
- }
- else
- {
- Console.WriteLine("Error: Can not add exceptions to a locked block.\r\n");
- }
- }
- else
- {
- Console.WriteLine("Error: Invalid block tab specified.\r\n");
- }
- goto IL_918;
- }
- catch (Exception ex5)
- {
- Console.WriteLine("Error: Invalid number of parameters specified.\r\n");
- goto IL_918;
- }
- }
- Console.WriteLine("Error: Block name is invalid. No block named " + text5 + " was found.\r\n");
- }
- else
- {
- Console.WriteLine("Error: Block name is invalid. Can not add websites to Frozen Turkey.\r\n");
- }
- IL_918:
- goto IL_9CD;
- }
- catch (Exception ex6)
- {
- Console.WriteLine("Error: Block name not specified.\r\n");
- goto IL_9CD;
- }
- }
- Console.WriteLine("Cold Turkey Blocker [Version " + this.currentVersion.ToString("0.00") + "]\r\nCopyright (c) 2020. Cold Turkey Software Inc.\r\n");
- Console.WriteLine("Cold Turkey Blocker.exe [options]\r\n");
- Console.WriteLine(" Where [options] must be one of following formats:\r\n");
- Console.WriteLine(" [-start \"Block Name\"]");
- Console.WriteLine(" Starts an unlocked block with the specified name. The block must already exist and not be enabled.\r\n");
- Console.WriteLine(" [-start \"Block Name\" -lock X]");
- Console.WriteLine(" Starts a locked block for X number of minutes with the specified name. The block must already exist and not be enabled.\r\n");
- Console.WriteLine(" [-add \"Block Name\" -web \"URL\"]");
- Console.WriteLine(" Adds a URL to the website tab of a block with the specified name. The block must already exist.\r\n");
- Console.WriteLine(" [-add \"Block Name\" -exception \"URL\"]");
- Console.WriteLine(" Adds a URL to the exception tab of a block with the specified name. The block must already exist and not be locked.\r\n");
- goto IL_9CD;
- IL_9C3:
- Console.WriteLine("Invalid arguments. Show available command line arguments using -help\r\n");
- IL_9CD:
- if (flag)
- {
- SendKeys.SendWait("{ENTER}");
- this.DisposeOpenObjects();
- ProjectData.EndApp();
- }
- }
- else if (secondInstance)
- {
- this.OpenWindow(true);
- }
- }
- catch (Exception ex7)
- {
- this.DisposeOpenObjects();
- ProjectData.EndApp();
- }
- return result;
- }
- public void PipeSettingsReloadMessage()
- {
- NamedPipeClientStream namedPipeClientStream = new NamedPipeClientStream("CTBAppToService");
- StreamWriter streamWriter = new StreamWriter(namedPipeClientStream);
- NamedPipeClientStream namedPipeClientStream2 = new NamedPipeClientStream("CTBAppToHelper");
- StreamWriter streamWriter2 = new StreamWriter(namedPipeClientStream2);
- try
- {
- namedPipeClientStream.Connect(500);
- streamWriter.WriteLine("-reload-settings");
- streamWriter.Flush();
- streamWriter.Dispose();
- namedPipeClientStream.Dispose();
- }
- catch (Exception ex)
- {
- }
- try
- {
- namedPipeClientStream2.Connect(500);
- streamWriter2.WriteLine("-reload-settings");
- streamWriter2.Flush();
- streamWriter2.Dispose();
- streamWriter2.Dispose();
- }
- catch (Exception ex2)
- {
- }
- }
- public void ForceSettingsReload()
- {
- this.LoadSettings();
- this.web.Document.InvokeScript("ForceSettingsUpdate", new object[]
- {
- this.SendSettings()
- });
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- private void LoadSettings()
- {
- try
- {
- if (Conversions.ToInteger(new SQLiteCommand("PRAGMA user_version", this.dbHelper).ExecuteScalar()) < 4)
- {
- Interaction.MsgBox("The settings database has not been upgraded to the latest version yet. Try opening Cold Turkey Blocker in a few seconds.", MsgBoxStyle.Exclamation, "Error Reading Database");
- ProjectData.EndApp();
- }
- else
- {
- string text = new SQLiteCommand("SELECT value from settings where key = 'settings'", this.dbApp).ExecuteScalar() as string;
- if (text != null & Operators.CompareString(text, "", false) != 0)
- {
- this.settings = JsonConvert.DeserializeAnonymousType<Settings>(text, this.settings);
- }
- else
- {
- this.ResetSettings();
- }
- }
- }
- catch (Exception e)
- {
- this.WriteError(e);
- Interaction.MsgBox("The database where your settings are stored is locked and can't be read. Try opening Cold Turkey Blocker in a few seconds.", MsgBoxStyle.Exclamation, "Error Reading Database");
- ProjectData.EndApp();
- }
- }
- private void SetAdditionalUpdate()
- {
- try
- {
- if (this.CheckConnection() && double.Parse(Regex.Replace(this.GetHTML("https://getcoldturkey.com/version/windows/"), "\\\\s+", string.Empty), CultureInfo.InvariantCulture) > this.currentVersion)
- {
- this.settings.Additional.UpdateAvailable = "true";
- return;
- }
- }
- catch (Exception ex)
- {
- }
- this.settings.Additional.UpdateAvailable = "false";
- }
- private void SetAdditionalWin10()
- {
- List<string> list = new List<string>();
- try
- {
- SQLiteDataReader sqliteDataReader = new SQLiteCommand("Select * FROM apps", this.dbService).ExecuteReader();
- while (sqliteDataReader.Read())
- {
- list.Add(sqliteDataReader["file"].ToString().Substring(checked(sqliteDataReader["file"].ToString().LastIndexOf('\\') + 1)));
- }
- }
- catch (Exception ex)
- {
- }
- this.settings.Additional.Win10 = list;
- }
- private void SetAdditionalUsers()
- {
- List<string> list = new List<string>();
- try
- {
- SelectQuery query = new SelectQuery("Win32_UserAccount");
- ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher(query);
- try
- {
- foreach (ManagementBaseObject managementBaseObject in managementObjectSearcher.Get())
- {
- string text = ((ManagementObject)managementBaseObject)["Name"].ToString();
- if (Operators.CompareString(text, "WDAGUtilityAccount", false) != 0 & Operators.CompareString(text, "DefaultAccount", false) != 0 & Operators.CompareString(text, "defaultuser0", false) != 0)
- {
- list.Add(text);
- }
- }
- }
- finally
- {
- ManagementObjectCollection.ManagementObjectEnumerator enumerator;
- if (enumerator != null)
- {
- ((IDisposable)enumerator).Dispose();
- }
- }
- }
- catch (Exception ex)
- {
- }
- new Settings();
- this.settings.Additional.Users = list;
- }
- private void SetWindowTitle()
- {
- string proStatus = this.settings.Additional.ProStatus;
- if (Operators.CompareString(proStatus, "free", false) == 0)
- {
- this.Text = "Cold Turkey Blocker Free (v" + this.currentVersion.ToString("0.00") + ")";
- return;
- }
- if (Operators.CompareString(proStatus, "trial", false) == 0)
- {
- string[] array = this.settings.Additional.TrialEnd.Split(new string[]
- {
- ","
- });
- DateTime dateTime = new DateTime(Conversions.ToInteger(array[0]), Conversions.ToInteger(array[1]), Conversions.ToInteger(array[2]), Conversions.ToInteger(array[3]), Conversions.ToInteger(array[4]), 0);
- this.Text = string.Concat(new string[]
- {
- "Cold Turkey Blocker (Pro trial ends: ",
- dateTime.ToString("f", CultureInfo.CurrentCulture),
- ") (v",
- this.currentVersion.ToString("0.00"),
- ")"
- });
- return;
- }
- if (Operators.CompareString(proStatus, "trialed", false) == 0)
- {
- this.Text = "Cold Turkey Blocker Free (v" + this.currentVersion.ToString("0.00") + ")";
- return;
- }
- if (Operators.CompareString(proStatus, "pro", false) != 0)
- {
- return;
- }
- this.Text = "Cold Turkey Blocker Pro (v" + this.currentVersion.ToString("0.00") + ")";
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- private void ResetSettings()
- {
- try
- {
- string value = "{\"blocks\":{\"Frozen Turkey\":{\"enabled\":\"false\",\"type\":\"continuous\",\"timer\":\"\",\"startTime\":\"\",\"lock\":\"none\",\"lockUnblock\":\"true\",\"restartUnblock\":\"\",\"break\":\"none\",\"password\":\"\",\"randomTextLength\":\"30\",\"window\":\"lock@9,0@17,0\",\"users\":\"all\",\"web\":[],\"exceptions\":[],\"apps\":[],\"schedule\":[],\"customUsers\":[]},\"Distractions\":{\"enabled\":\"false\",\"type\":\"continuous\",\"timer\":\"\",\"startTime\":\"\",\"lock\":\"none\",\"lockUnblock\":\"true\",\"restartUnblock\":\"true\",\"break\":\"none\",\"password\":\"\",\"randomTextLength\":\"30\",\"window\":\"lock@9,0@17,0\",\"users\":\"all\",\"web\":[\"4chan.org\",\"9gag.com\",\"badoo.com\",\"buzzfeed.com\",\"facebook.com\",\"imgur.com\",\"instagram.com\",\"linkedin.com\",\"mashable.com\",\"myspace.com\",\"netflix.com\",\"pinterest.com\",\"qzone.qq.com\",\"reddit.com\",\"skype.com\",\"snapchat.com\",\"tagged.com\",\"tieba.baidu.com\",\"tumblr.com\",\"twitter.com\",\"vimeo.com\",\"vk.com\",\"weibo.com\",\"youtube.com\",\"yy.com\"],\"exceptions\":[],\"apps\":[],\"schedule\":[],\"customUsers\":[]}},\"settings\":{\"show24hour\":\"false\",\"weekStart\":\"sunday\",\"theme\":\"light\",\"openStartup\":\"false\",\"closeToTray\":\"true\",\"showExtensionWarning\":\"true\",\"notifyDone\":\"true\",\"notifyStart\":\"true\",\"notifyEnd\":\"true\",\"notifyBreak\":\"true\",\"notifyAllowance\":\"true\",\"notifyBlock\":\"true\",\"notifyWarning\":\"true\",\"notifyWarningPeriod\":\"2\",\"notifyWarningAllowance\":\"true\",\"notifyAllowancePeriod\":\"2\",\"blockMode\":\"exit\",\"frozenTurkeyMode\":\"lock\",\"blockCharity\":\"false\",\"blockUnsupported\":\"true\",\"blockInstaller\":\"false\",\"blockTaskManager\":\"false\",\"blockTaskManagerChrome\":\"false\",\"blockTimeChange\":\"false\",\"blockEmbedded\":\"false\",\"blockInactive\":\"false\",\"forceAllowFile\":\"false\",\"extensionGracePeriod\":\"60\",\"password\":\"\",\"passwordStrict\":\"false\",\"statsEnabled\":\"true\",\"statsEnabledIncognito\":\"true\",\"statsStrict\":\"false\"},\"additional\":{\"paused\":\"false\",\"proStatus\":\"free\",\"trialEnd\":\"\",\"updateAvailable\":\"false\",\"browserList\":\"\",\"forceExtensionInstall\":\"true\",\"win10\":[],\"users\":[]}}";
- new SQLiteCommand("INSERT OR REPLACE INTO settings (key, value) VALUES ('settings', @settings)", this.dbApp)
- {
- Parameters =
- {
- new SQLiteParameter("@settings", value)
- }
- }.ExecuteNonQuery();
- string text = new SQLiteCommand("SELECT value from settings where key = 'settings'", this.dbApp).ExecuteScalar() as string;
- if (text != null & Operators.CompareString(text, "", false) != 0)
- {
- this.settings = JsonConvert.DeserializeAnonymousType<Settings>(text, this.settings);
- }
- }
- catch (Exception e)
- {
- this.WriteError(e);
- Interaction.MsgBox("Your settings could not be reset. Try opening Cold Turkey Blocker in a few seconds.", MsgBoxStyle.Exclamation, "Error Resetting Settings");
- ProjectData.EndApp();
- }
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public string SendSettings()
- {
- string result;
- try
- {
- result = JsonConvert.SerializeObject(this.settings).Replace("\\\\'", "\\\\\\\\\\'");
- }
- catch (Exception e)
- {
- this.WriteError(e);
- Interaction.MsgBox("Your settings could not be sent to the web application. Try opening Cold Turkey Blocker in a few seconds.", MsgBoxStyle.Exclamation, "Error Sending Settings");
- ProjectData.EndApp();
- }
- return result;
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- public string SendAllowanceUpdate()
- {
- string result;
- try
- {
- result = JsonConvert.SerializeObject(this.allowances).Replace("\\\\'", "\\\\\\\\\\'");
- }
- catch (Exception e)
- {
- this.WriteError(e);
- Interaction.MsgBox("Your allowance data could not be sent to the web application. Try opening Cold Turkey Blocker in a few seconds.", MsgBoxStyle.Exclamation, "Error Sending Allowances");
- ProjectData.EndApp();
- }
- return result;
- }
- private void CalculateAllowances()
- {
- checked
- {
- try
- {
- if (this.settings != null)
- {
- this.allowances = new Dictionary<string, string>();
- try
- {
- foreach (KeyValuePair<string, Block> keyValuePair in this.settings.Blocks)
- {
- if ((Operators.CompareString(keyValuePair.Value.Users, "all", false) == 0 | keyValuePair.Value.CustomUsers.Contains(Environment.UserName)) && Operators.CompareString(keyValuePair.Value.Enabled, "true", false) == 0)
- {
- bool flag = false;
- string text = "none";
- DateTime dateTime;
- DateTime endTime;
- if (Operators.CompareString(keyValuePair.Value.Type, "continuous", false) == 0)
- {
- flag = true;
- text = keyValuePair.Value.Break;
- string[] array = keyValuePair.Value.StartTime.Split(new string[]
- {
- ","
- });
- dateTime = new DateTime(int.Parse(array[0]), int.Parse(array[1]), int.Parse(array[2]), int.Parse(array[3]), int.Parse(array[4]), 0, 0);
- if (DateTime.Compare(dateTime, new DateTime(DateAndTime.Now.Year, DateAndTime.Now.Month, DateAndTime.Now.Day, 0, 0, 0, 0)) < 0)
- {
- dateTime = new DateTime(DateAndTime.Now.Year, DateAndTime.Now.Month, DateAndTime.Now.Day, 0, 0, 0, 0);
- }
- endTime = new DateTime(DateAndTime.Now.Year, DateAndTime.Now.Month, DateAndTime.Now.Day, 0, 0, 0, 0);
- endTime = endTime.AddHours(24.0);
- }
- else
- {
- try
- {
- foreach (Schedule schedule in keyValuePair.Value.Schedule)
- {
- string[] array2 = schedule.StartTime.Split(new string[]
- {
- ","
- });
- string[] array3 = schedule.EndTime.Split(new string[]
- {
- ","
- });
- if (int.Parse(array2[0]) == (int)DateAndTime.Now.DayOfWeek)
- {
- DateTime dateTime2 = new DateTime(DateAndTime.Now.Year, DateAndTime.Now.Month, DateAndTime.Now.Day, int.Parse(array2[1]), int.Parse(array2[2]), 0, 0);
- DateTime dateTime3 = new DateTime(DateAndTime.Now.Year, DateAndTime.Now.Month, DateAndTime.Now.Day, int.Parse(array3[1]), int.Parse(array3[2]), 0, 0);
- if (DateTime.Compare(dateTime2, DateAndTime.Now) <= 0 & DateTime.Compare(DateAndTime.Now, dateTime3) < 0)
- {
- flag = true;
- text = schedule.Break;
- dateTime = dateTime2;
- endTime = dateTime3;
- }
- }
- }
- }
- finally
- {
- List<Schedule>.Enumerator enumerator2;
- ((IDisposable)enumerator2).Dispose();
- }
- }
- if (flag && (Operators.CompareString(text, "none", false) != 0 & !text.Contains(",")))
- {
- int num = int.Parse(text);
- if (Operators.CompareString(keyValuePair.Key, "Frozen Turkey", false) == 0)
- {
- int num2 = Convert.ToInt32(Math.Floor(new decimal(num * 60 - this.GetSecondsSpentOnAnything(dateTime, endTime))));
- if (num2 < 0)
- {
- num2 = 0;
- }
- this.allowances.Add(keyValuePair.Key, num2.ToString(CultureInfo.InvariantCulture));
- }
- else
- {
- int num3 = Convert.ToInt32(Math.Floor(new decimal(num * 60 - this.GetSecondsSpentOn(keyValuePair.Key, dateTime, endTime))));
- if (num3 < 0)
- {
- num3 = 0;
- }
- this.allowances.Add(keyValuePair.Key, num3.ToString(CultureInfo.InvariantCulture));
- }
- }
- }
- }
- }
- finally
- {
- Dictionary<string, Block>.Enumerator enumerator;
- ((IDisposable)enumerator).Dispose();
- }
- }
- }
- catch (Exception ex)
- {
- }
- }
- }
- private int GetSecondsSpentOn(string blockId, DateTime startTime, DateTime endTime)
- {
- string text = startTime.Subtract(new DateTime(1970, 1, 1)).TotalSeconds.ToString("F0");
- string text2 = endTime.Subtract(new DateTime(1970, 1, 1)).TotalSeconds.ToString("F0");
- List<string> list = new List<string>();
- string text3 = Environment.UserName.Replace("'", "''");
- foreach (string text4 in this.settings.Blocks[blockId].Web.Distinct<string>().ToArray<string>())
- {
- try
- {
- foreach (string text5 in this.settings.Blocks[blockId].Exceptions.Distinct<string>())
- {
- if (new Regex(text4.Replace("*", ".*")).IsMatch(text5.Replace("*", ".*")))
- {
- list.Add(text5);
- }
- }
- }
- finally
- {
- IEnumerator<string> enumerator;
- if (enumerator != null)
- {
- enumerator.Dispose();
- }
- }
- }
- int num = 0;
- checked
- {
- try
- {
- foreach (string text6 in this.settings.Blocks[blockId].Web.Distinct<string>())
- {
- int num2 = 0;
- string text7 = text6.Replace("%", "\\%").Replace("*", "%").Replace("'", "''");
- string text8;
- if (!text7.Contains("/"))
- {
- text8 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM stats WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND (domain = '",
- text7,
- "' OR domain LIKE '%.",
- text7,
- "' ESCAPE '\\' OR domain LIKE '",
- text7,
- "/%' ESCAPE '\\' OR domain LIKE '%.",
- text7,
- "/%' ESCAPE '\\')"
- });
- }
- else
- {
- text8 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM stats WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND (domain = '",
- text7,
- "' OR domain LIKE '%.",
- text7,
- "%' ESCAPE '\\')"
- });
- }
- if (text8 != null && int.TryParse(new SQLiteCommand(text8, this.dbBrowser).ExecuteScalar().ToString(), out num2))
- {
- num += num2;
- }
- }
- }
- finally
- {
- IEnumerator<string> enumerator2;
- if (enumerator2 != null)
- {
- enumerator2.Dispose();
- }
- }
- int num3 = 0;
- try
- {
- foreach (string text9 in this.settings.Blocks[blockId].Apps.Distinct<string>())
- {
- int num4 = 0;
- string text10 = text9.Replace("%", "\\%").Replace("*", "%").Replace("'", "''");
- string text11 = null;
- if (text10.StartsWith("file:"))
- {
- string text12 = text10.Substring(5).ToLowerInvariant();
- text11 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM statsApp WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND file = '",
- text12,
- "'"
- });
- }
- else if (text10.StartsWith("win10:"))
- {
- string text13 = text10.Substring(6).ToLowerInvariant();
- text11 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM statsApp WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND (file LIKE '%/windowsapps/%",
- text13,
- "' OR file LIKE '%/systemapps/%",
- text13,
- "')"
- });
- }
- else if (text10.StartsWith("folder:"))
- {
- string text14 = text10.Substring(7).ToLowerInvariant();
- text11 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM statsApp WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND file LIKE '",
- text14,
- "%' ESCAPE '\\'"
- });
- }
- else if (text10.StartsWith("title:"))
- {
- string text15 = text10.Substring(6).ToLowerInvariant();
- text11 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM statsTitle WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND title LIKE '",
- text15,
- "' ESCAPE '\\'"
- });
- }
- if (text11 != null && int.TryParse(new SQLiteCommand(text11, this.dbHelper).ExecuteScalar().ToString(), out num4))
- {
- num3 += num4;
- }
- }
- }
- finally
- {
- IEnumerator<string> enumerator3;
- if (enumerator3 != null)
- {
- enumerator3.Dispose();
- }
- }
- int num5 = 0;
- try
- {
- foreach (string text16 in list)
- {
- int num6 = 0;
- string text17 = text16.Replace("%", "\\%").Replace("*", "%").Replace("'", "''");
- string text18;
- if (!text17.Contains("/"))
- {
- text18 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM stats WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND (domain = '",
- text17,
- "' OR domain LIKE '%.",
- text17,
- "' ESCAPE '\\' OR domain LIKE '",
- text17,
- "/%' ESCAPE '\\' OR domain LIKE '%.",
- text17,
- "/%' ESCAPE '\\')"
- });
- }
- else
- {
- text18 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM stats WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND (domain = '",
- text17,
- "' OR domain LIKE '%.",
- text17,
- "%' ESCAPE '\\')"
- });
- }
- if (text18 != null && int.TryParse(new SQLiteCommand(text18, this.dbBrowser).ExecuteScalar().ToString(), out num6))
- {
- num5 += num6;
- }
- }
- }
- finally
- {
- List<string>.Enumerator enumerator4;
- ((IDisposable)enumerator4).Dispose();
- }
- int num7 = 0;
- int num8 = 0;
- int num9 = 0;
- if (Operators.CompareString(this.settings.Settings.StatsStrict, "true", false) == 0)
- {
- try
- {
- foreach (string text19 in this.settings.Blocks[blockId].Web.Distinct<string>())
- {
- int num10 = 0;
- string text20 = text19.Replace("%", "\\%").Replace("*", "%").Replace("'", "''");
- string text21;
- if (!text20.Contains("/"))
- {
- text21 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM statsStrict WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND (domain = '",
- text20,
- "' OR domain LIKE '%.",
- text20,
- "' ESCAPE '\\' OR domain LIKE '",
- text20,
- "/%' ESCAPE '\\' OR domain LIKE '%.",
- text20,
- "/%' ESCAPE '\\')"
- });
- }
- else
- {
- text21 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM statsStrict WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND (domain = '",
- text20,
- "' OR domain LIKE '%.",
- text20,
- "%' ESCAPE '\\')"
- });
- }
- if (text21 != null && int.TryParse(new SQLiteCommand(text21, this.dbBrowser).ExecuteScalar().ToString(), out num10))
- {
- num7 += num10;
- }
- }
- }
- finally
- {
- IEnumerator<string> enumerator5;
- if (enumerator5 != null)
- {
- enumerator5.Dispose();
- }
- }
- try
- {
- foreach (string text22 in this.settings.Blocks[blockId].Apps.Distinct<string>())
- {
- int num11 = 0;
- int num12 = 0;
- string text23 = text22.Replace("%", "\\%").Replace("*", "%").Replace("'", "''");
- string text24 = null;
- string text25 = null;
- if (text23.StartsWith("file:"))
- {
- string text26 = text23.Substring(5).ToLowerInvariant();
- text24 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM statsAppStrict WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND file = '",
- text26,
- "'"
- });
- }
- else if (text23.StartsWith("win10:"))
- {
- string text27 = text23.Substring(6).ToLowerInvariant();
- text24 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM statsAppStrict WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND (file LIKE '%/windowsapps/%",
- text27,
- "' OR file LIKE '%/systemapps/%",
- text27,
- "')"
- });
- }
- else if (text23.StartsWith("folder:"))
- {
- string text28 = text23.Substring(7).ToLowerInvariant();
- text24 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM statsAppStrict WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND file LIKE '",
- text28,
- "%' ESCAPE '\\'"
- });
- }
- else if (text23.StartsWith("title:"))
- {
- string text29 = text23.Substring(6).ToLowerInvariant();
- text24 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM statsTitleStrict WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND title LIKE '",
- text29,
- "' ESCAPE '\\'"
- });
- text25 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM statsTitleStrict WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND title LIKE '",
- text29,
- "' ESCAPE '\\'"
- });
- }
- if (text24 != null && int.TryParse(new SQLiteCommand(text24, this.dbHelper).ExecuteScalar().ToString(), out num11))
- {
- num8 += num11;
- }
- if (text25 != null && int.TryParse(new SQLiteCommand(text24, this.dbBrowser).ExecuteScalar().ToString(), out num12))
- {
- num8 += num12;
- }
- }
- }
- finally
- {
- IEnumerator<string> enumerator6;
- if (enumerator6 != null)
- {
- enumerator6.Dispose();
- }
- }
- try
- {
- foreach (string text30 in list)
- {
- int num13 = 0;
- string text31 = text30.Replace("%", "\\%").Replace("*", "%").Replace("'", "''");
- string text32;
- if (!text31.Contains("/"))
- {
- text32 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM statsStrict WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND (domain = '",
- text31,
- "' OR domain LIKE '%.",
- text31,
- "' ESCAPE '\\' OR domain LIKE '",
- text31,
- "/%' ESCAPE '\\' OR domain LIKE '%.",
- text31,
- "/%' ESCAPE '\\')"
- });
- }
- else
- {
- text32 = string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM statsStrict WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "' AND (domain = '",
- text31,
- "' OR domain LIKE '%.",
- text31,
- "%' ESCAPE '\\')"
- });
- }
- if (text32 != null && int.TryParse(new SQLiteCommand(text32, this.dbBrowser).ExecuteScalar().ToString(), out num13))
- {
- num9 += num13;
- }
- }
- }
- finally
- {
- List<string>.Enumerator enumerator7;
- ((IDisposable)enumerator7).Dispose();
- }
- }
- int num14 = num - num5 + num7 - num9;
- if (num14 < 0)
- {
- num14 = 0;
- }
- return num14 + num3 + num8;
- }
- }
- private int GetSecondsSpentOnAnything(DateTime startTime, DateTime endTime)
- {
- string text = startTime.Subtract(new DateTime(1970, 1, 1)).TotalSeconds.ToString("F0");
- string text2 = endTime.Subtract(new DateTime(1970, 1, 1)).TotalSeconds.ToString("F0");
- string text3 = Environment.UserName.Replace("'", "''");
- int result = 0;
- int.TryParse(new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT SUM(seconds) FROM statsApp WHERE (date >= ",
- text,
- " AND date < ",
- text2,
- ") AND user = '",
- text3,
- "'"
- }), this.dbHelper).ExecuteScalar().ToString(), out result);
- return result;
- }
- public void WriteSettingsToDatabase()
- {
- try
- {
- new SQLiteCommand("INSERT OR REPLACE INTO settings (key, value) VALUES ('settings', @settings)", this.dbApp)
- {
- Parameters =
- {
- new SQLiteParameter("@settings", JsonConvert.SerializeObject(this.settings))
- }
- }.ExecuteNonQuery();
- }
- catch (Exception e)
- {
- this.WriteError(e);
- Interaction.MsgBox("Your settings could not be saved. Try closing and reopening the Cold Turkey Blocker window.", MsgBoxStyle.Exclamation, "Error Saving Settings");
- }
- }
- private void SysTray_MouseClick(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Right)
- {
- this.trayMenu.Enabled = true;
- return;
- }
- if (e.Button == MouseButtons.Left)
- {
- this.OpenWindow(true);
- }
- }
- private void TrayAbout_Click(object sender, EventArgs e)
- {
- this.ShowInfo();
- }
- private void TrayOpen_Click(object sender, EventArgs e)
- {
- this.OpenWindow(true);
- }
- public void OpenWindow(bool refresh)
- {
- base.ShowInTaskbar = true;
- this.tray.Visible = false;
- base.Show();
- base.Activate();
- if (refresh)
- {
- this.web.Refresh();
- }
- }
- [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
- private void TrayExit_Click(object sender, EventArgs e)
- {
- this.DisposeOpenObjects();
- ProjectData.EndApp();
- }
- private void ColdTurkey_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (e.CloseReason == CloseReason.UserClosing & Operators.CompareString(this.settings.Settings.CloseToTray, "true", false) == 0)
- {
- base.ShowInTaskbar = false;
- base.Hide();
- this.tray.Visible = true;
- e.Cancel = true;
- return;
- }
- this.DisposeOpenObjects();
- }
- private void ShowInfo()
- {
- Interaction.MsgBox("Cold Turkey Blocker\r\nVersion " + this.currentVersion.ToString("0.00") + "\r\nhttps://getcoldturkey.com\r\n\r\nCold Turkey Blocker temporarily blocks websites and applications to help you get work done.\r\n\r\nCopyright (c) 2020. Cold Turkey Software Inc.", MsgBoxStyle.OkOnly, "About Cold Turkey Blocker");
- }
- public object SendStats(string chartId, string chartOptions, string chartUsers, double startDateIn, double endDateIn)
- {
- List<Series> list = new List<Series>();
- DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(startDateIn);
- double num = startDateIn + TimeZoneInfo.Local.GetUtcOffset(dateTime).TotalSeconds;
- DateTime dateTime2 = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(endDateIn);
- double num2 = endDateIn + TimeZoneInfo.Local.GetUtcOffset(dateTime2).TotalSeconds;
- string text = num.ToString("F0");
- string text2 = num2.ToString("F0");
- try
- {
- uint num3 = <PrivateImplementationDetails>.ComputeStringHash(chartId);
- if (num3 <= 1160245379U)
- {
- if (num3 <= 435774502U)
- {
- if (num3 != 164560180U)
- {
- if (num3 != 435774502U)
- {
- goto IL_1AD1;
- }
- if (Operators.CompareString(chartId, "web-top5", false) != 0)
- {
- goto IL_1AD1;
- }
- string text3 = "";
- string text4 = "";
- if (Operators.CompareString(chartUsers, "all", false) != 0)
- {
- text4 = " AND user = '" + chartUsers.Replace("'", "''") + "'";
- }
- if (Operators.CompareString(chartOptions, "all", false) != 0)
- {
- List<string> values = new List<string>(this.settings.Blocks[chartOptions].Web.Where((ColdTurkey._Closure$__.$I42-2 == null) ? (ColdTurkey._Closure$__.$I42-2 = ((string entry) => !(entry.Contains("*") | entry.Contains("/")))) : ColdTurkey._Closure$__.$I42-2).Select((ColdTurkey._Closure$__.$I42-3 == null) ? (ColdTurkey._Closure$__.$I42-3 = ((string entry) => entry.Replace("'", "''"))) : ColdTurkey._Closure$__.$I42-3));
- text3 = " AND fdomain IN ('" + string.Join("','", values) + "')";
- }
- List<string> list2 = new List<string>();
- SQLiteDataReader sqliteDataReader = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT SUBSTR(domain, 0, IFNULL(NULLIF(INSTR(domain, '/'),0),LENGTH(domain)+1)) as fdomain FROM stats WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text4,
- text3,
- " GROUP BY fdomain ORDER BY SUM(seconds) DESC LIMIT 5"
- }), this.dbBrowser).ExecuteReader();
- while (sqliteDataReader.Read())
- {
- list2.Add(sqliteDataReader["fdomain"].ToString());
- }
- try
- {
- foreach (string text5 in list2)
- {
- Series series = new Series();
- double num4 = num;
- double num5 = num2;
- for (double num6 = num4; num6 <= num5; num6 += 86400.0)
- {
- List<double[]> data = series.Data;
- double[] array = new double[2];
- array[0] = num6 * 1000.0;
- data.Add(array);
- }
- SQLiteDataReader sqliteDataReader2 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT date, SUM(seconds) AS fsum FROM stats WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text4,
- " AND SUBSTR(domain, 0, IFNULL(NULLIF(INSTR(domain, '/'),0),LENGTH(domain)+1)) = '",
- text5.Replace("'", "''"),
- "' GROUP BY strftime('%Y-%m-%d', date, 'unixepoch')"
- }), this.dbBrowser).ExecuteReader();
- while (sqliteDataReader2.Read())
- {
- ColdTurkey._Closure$__42-2 CS$<>8__locals1 = new ColdTurkey._Closure$__42-2(CS$<>8__locals1);
- CS$<>8__locals1.$VB$Local_midnight = Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader2["date"])) - Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader2["date"])) % 86400.0;
- int num7 = series.Data.FindIndex((double[] point) => point[0] == CS$<>8__locals1.$VB$Local_midnight * 1000.0);
- if (num7 >= 0)
- {
- series.Data[num7] = new double[]
- {
- CS$<>8__locals1.$VB$Local_midnight * 1000.0,
- Math.Round(Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader2["fsum"])) / 60.0, 2)
- };
- }
- }
- series.Label = text5;
- list.Add(series);
- }
- goto IL_1AD1;
- }
- finally
- {
- List<string>.Enumerator enumerator;
- ((IDisposable)enumerator).Dispose();
- }
- }
- else
- {
- if (Operators.CompareString(chartId, "app-search-title", false) != 0)
- {
- goto IL_1AD1;
- }
- goto IL_17D9;
- }
- }
- else if (num3 != 770011565U)
- {
- if (num3 != 1160245379U)
- {
- goto IL_1AD1;
- }
- if (Operators.CompareString(chartId, "app-top10", false) != 0)
- {
- goto IL_1AD1;
- }
- goto IL_11CA;
- }
- else
- {
- if (Operators.CompareString(chartId, "app-top5", false) != 0)
- {
- goto IL_1AD1;
- }
- goto IL_EB6;
- }
- }
- else if (num3 <= 1732731101U)
- {
- if (num3 != 1346409049U)
- {
- if (num3 != 1732731101U)
- {
- goto IL_1AD1;
- }
- if (Operators.CompareString(chartId, "app-blocked", false) != 0)
- {
- goto IL_1AD1;
- }
- Series series2 = new Series();
- double num8 = num;
- double num9 = num2;
- for (double num10 = num8; num10 <= num9; num10 += 86400.0)
- {
- List<double[]> data2 = series2.Data;
- double[] array2 = new double[2];
- array2[0] = num10 * 1000.0;
- data2.Add(array2);
- }
- SQLiteDataReader sqliteDataReader3 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT date, COUNT(*) FROM statsBlocked WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ") GROUP BY strftime('%Y-%m-%d', date, 'unixepoch')"
- }), this.dbHelper).ExecuteReader();
- while (sqliteDataReader3.Read())
- {
- ColdTurkey._Closure$__42-1 CS$<>8__locals2 = new ColdTurkey._Closure$__42-1(CS$<>8__locals2);
- CS$<>8__locals2.$VB$Local_midnight = Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader3["date"])) - Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader3["date"])) % 86400.0;
- int num11 = series2.Data.FindIndex((double[] point) => point[0] == CS$<>8__locals2.$VB$Local_midnight * 1000.0);
- if (num11 >= 0)
- {
- series2.Data[num11] = new double[]
- {
- CS$<>8__locals2.$VB$Local_midnight * 1000.0,
- Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader3["COUNT(*)"]))
- };
- }
- }
- series2.Label = "Applications Blocked";
- list.Add(series2);
- goto IL_1AD1;
- }
- else
- {
- if (Operators.CompareString(chartId, "app-search-name", false) != 0)
- {
- goto IL_1AD1;
- }
- goto IL_14DE;
- }
- }
- else if (num3 != 1794203764U)
- {
- if (num3 != 1906460134U)
- {
- if (num3 != 4155674659U)
- {
- goto IL_1AD1;
- }
- if (Operators.CompareString(chartId, "web-search-domain", false) != 0)
- {
- goto IL_1AD1;
- }
- goto IL_ACB;
- }
- else if (Operators.CompareString(chartId, "web-top10", false) != 0)
- {
- goto IL_1AD1;
- }
- }
- else
- {
- if (Operators.CompareString(chartId, "web-blocked", false) != 0)
- {
- goto IL_1AD1;
- }
- Series series3 = new Series();
- double num12 = num;
- double num13 = num2;
- for (double num14 = num12; num14 <= num13; num14 += 86400.0)
- {
- List<double[]> data3 = series3.Data;
- double[] array3 = new double[2];
- array3[0] = num14 * 1000.0;
- data3.Add(array3);
- }
- SQLiteDataReader sqliteDataReader4 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT date, COUNT(*) FROM statsBlocked WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ") GROUP BY strftime('%Y-%m-%d', date, 'unixepoch')"
- }), this.dbBrowser).ExecuteReader();
- while (sqliteDataReader4.Read())
- {
- ColdTurkey._Closure$__42-0 CS$<>8__locals3 = new ColdTurkey._Closure$__42-0(CS$<>8__locals3);
- CS$<>8__locals3.$VB$Local_midnight = Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader4["date"])) - Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader4["date"])) % 86400.0;
- int num15 = series3.Data.FindIndex((double[] point) => point[0] == CS$<>8__locals3.$VB$Local_midnight * 1000.0);
- if (num15 >= 0)
- {
- series3.Data[num15] = new double[]
- {
- CS$<>8__locals3.$VB$Local_midnight * 1000.0,
- Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader4["COUNT(*)"]))
- };
- }
- }
- series3.Label = "Websites Blocked";
- list.Add(series3);
- goto IL_1AD1;
- }
- string text6 = "";
- string text7 = "";
- if (Operators.CompareString(chartUsers, "all", false) != 0)
- {
- text7 = " AND user = '" + chartUsers.Replace("'", "''") + "'";
- }
- if (Operators.CompareString(chartOptions, "all", false) != 0)
- {
- List<string> values2 = new List<string>(this.settings.Blocks[chartOptions].Web.Where((ColdTurkey._Closure$__.$I42-5 == null) ? (ColdTurkey._Closure$__.$I42-5 = ((string entry) => !(entry.Contains("*") | entry.Contains("/")))) : ColdTurkey._Closure$__.$I42-5).Select((ColdTurkey._Closure$__.$I42-6 == null) ? (ColdTurkey._Closure$__.$I42-6 = ((string entry) => entry.Replace("'", "''"))) : ColdTurkey._Closure$__.$I42-6));
- text6 = " AND fdomain IN ('" + string.Join("','", values2) + "')";
- }
- List<string> list3 = new List<string>();
- SQLiteDataReader sqliteDataReader5 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT SUBSTR(domain, 0, IFNULL(NULLIF(INSTR(domain, '/'),0),LENGTH(domain)+1)) as fdomain FROM stats WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text7,
- text6,
- " GROUP BY fdomain ORDER BY SUM(seconds) DESC LIMIT 10"
- }), this.dbBrowser).ExecuteReader();
- while (sqliteDataReader5.Read())
- {
- list3.Add(sqliteDataReader5["fdomain"].ToString());
- }
- try
- {
- foreach (string text8 in list3)
- {
- Series series4 = new Series();
- double num16 = num;
- double num17 = num2;
- for (double num18 = num16; num18 <= num17; num18 += 86400.0)
- {
- List<double[]> data4 = series4.Data;
- double[] array4 = new double[2];
- array4[0] = num18 * 1000.0;
- data4.Add(array4);
- }
- SQLiteDataReader sqliteDataReader6 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT date, SUM(seconds) AS fsum FROM stats WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text7,
- " AND SUBSTR(domain, 0, IFNULL(NULLIF(INSTR(domain, '/'),0),LENGTH(domain)+1)) = '",
- text8.Replace("'", "''"),
- "' GROUP BY strftime('%Y-%m-%d', date, 'unixepoch')"
- }), this.dbBrowser).ExecuteReader();
- while (sqliteDataReader6.Read())
- {
- ColdTurkey._Closure$__42-3 CS$<>8__locals4 = new ColdTurkey._Closure$__42-3(CS$<>8__locals4);
- CS$<>8__locals4.$VB$Local_midnight = Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader6["date"])) - Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader6["date"])) % 86400.0;
- int num19 = series4.Data.FindIndex((double[] point) => point[0] == CS$<>8__locals4.$VB$Local_midnight * 1000.0);
- if (num19 >= 0)
- {
- series4.Data[num19] = new double[]
- {
- CS$<>8__locals4.$VB$Local_midnight * 1000.0,
- Math.Round(Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader6["fsum"])) / 60.0, 2)
- };
- }
- }
- series4.Label = text8;
- list.Add(series4);
- }
- goto IL_1AD1;
- }
- finally
- {
- List<string>.Enumerator enumerator2;
- ((IDisposable)enumerator2).Dispose();
- }
- IL_ACB:
- string text9 = "";
- if (Operators.CompareString(chartUsers, "all", false) != 0)
- {
- text9 = " AND user = '" + chartUsers.Replace("'", "''") + "'";
- }
- if (chartOptions == null | Operators.CompareString(chartOptions, "", false) == 0)
- {
- Series series5 = new Series();
- double num20 = num;
- double num21 = num2;
- for (double num22 = num20; num22 <= num21; num22 += 86400.0)
- {
- List<double[]> data5 = series5.Data;
- double[] array5 = new double[2];
- array5[0] = num22 * 1000.0;
- data5.Add(array5);
- }
- series5.Label = "";
- list.Add(series5);
- goto IL_1AD1;
- }
- List<string> list4 = new List<string>();
- SQLiteCommand sqliteCommand;
- if (chartOptions.StartsWith("file://"))
- {
- sqliteCommand = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT domain as fdomain FROM stats WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text9,
- " AND fdomain LIKE '%",
- chartOptions.Replace("'", "''"),
- "%' GROUP BY fdomain ORDER BY SUM(seconds) DESC LIMIT 10"
- }), this.dbBrowser);
- }
- else
- {
- sqliteCommand = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT SUBSTR(domain, 0, IFNULL(NULLIF(INSTR(domain, '/'),0),LENGTH(domain)+1)) as fdomain FROM stats WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text9,
- " AND fdomain LIKE '%",
- chartOptions.Replace("'", "''"),
- "%' GROUP BY fdomain ORDER BY SUM(seconds) DESC LIMIT 10"
- }), this.dbBrowser);
- }
- SQLiteDataReader sqliteDataReader7 = sqliteCommand.ExecuteReader();
- while (sqliteDataReader7.Read())
- {
- list4.Add(sqliteDataReader7["fdomain"].ToString());
- }
- try
- {
- foreach (string text10 in list4)
- {
- Series series6 = new Series();
- double num23 = num;
- double num24 = num2;
- for (double num25 = num23; num25 <= num24; num25 += 86400.0)
- {
- List<double[]> data6 = series6.Data;
- double[] array6 = new double[2];
- array6[0] = num25 * 1000.0;
- data6.Add(array6);
- }
- SQLiteCommand sqliteCommand2;
- if (chartOptions.StartsWith("file://"))
- {
- sqliteCommand2 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT date, SUM(seconds) AS fsum FROM stats WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text9,
- " AND domain = '",
- text10.Replace("'", "''"),
- "' GROUP BY strftime('%Y-%m-%d', date, 'unixepoch')"
- }), this.dbBrowser);
- }
- else
- {
- sqliteCommand2 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT date, SUM(seconds) AS fsum FROM stats WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text9,
- " AND SUBSTR(domain, 0, IFNULL(NULLIF(INSTR(domain, '/'),0),LENGTH(domain)+1)) = '",
- text10.Replace("'", "''"),
- "' GROUP BY strftime('%Y-%m-%d', date, 'unixepoch')"
- }), this.dbBrowser);
- }
- SQLiteDataReader sqliteDataReader8 = sqliteCommand2.ExecuteReader();
- while (sqliteDataReader8.Read())
- {
- ColdTurkey._Closure$__42-4 CS$<>8__locals5 = new ColdTurkey._Closure$__42-4(CS$<>8__locals5);
- CS$<>8__locals5.$VB$Local_midnight = Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader8["date"])) - Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader8["date"])) % 86400.0;
- int num26 = series6.Data.FindIndex((double[] point) => point[0] == CS$<>8__locals5.$VB$Local_midnight * 1000.0);
- if (num26 >= 0)
- {
- series6.Data[num26] = new double[]
- {
- CS$<>8__locals5.$VB$Local_midnight * 1000.0,
- Math.Round(Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader8["fsum"])) / 60.0, 2)
- };
- }
- }
- series6.Label = text10;
- list.Add(series6);
- }
- goto IL_1AD1;
- }
- finally
- {
- List<string>.Enumerator enumerator3;
- ((IDisposable)enumerator3).Dispose();
- }
- IL_EB6:
- string text11 = "";
- string text12 = "";
- if (Operators.CompareString(chartUsers, "all", false) != 0)
- {
- text12 = " AND user = '" + chartUsers.Replace("'", "''") + "'";
- }
- if (Operators.CompareString(chartOptions, "all", false) != 0)
- {
- List<string> values3 = new List<string>(this.settings.Blocks[chartOptions].Apps.Where((ColdTurkey._Closure$__.$I42-9 == null) ? (ColdTurkey._Closure$__.$I42-9 = ((string entry) => entry.StartsWith("file:") | entry.StartsWith("win10:"))) : ColdTurkey._Closure$__.$I42-9).Select((ColdTurkey._Closure$__.$I42-10 == null) ? (ColdTurkey._Closure$__.$I42-10 = ((string entry) => entry.Substring(checked(entry.LastIndexOf("/") + 1)))) : ColdTurkey._Closure$__.$I42-10));
- text11 = " AND ffile IN ('" + string.Join("','", values3) + "')";
- }
- List<string> list5 = new List<string>();
- SQLiteDataReader sqliteDataReader9 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT REPLACE(file, RTRIM(file, REPLACE(file, '/', '')), '') AS ffile FROM statsApp WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text12,
- text11,
- " GROUP BY ffile ORDER BY SUM(seconds) DESC LIMIT 5"
- }), this.dbHelper).ExecuteReader();
- while (sqliteDataReader9.Read())
- {
- list5.Add(sqliteDataReader9["ffile"].ToString());
- }
- try
- {
- foreach (string text13 in list5)
- {
- Series series7 = new Series();
- double num27 = num;
- double num28 = num2;
- for (double num29 = num27; num29 <= num28; num29 += 86400.0)
- {
- List<double[]> data7 = series7.Data;
- double[] array7 = new double[2];
- array7[0] = num29 * 1000.0;
- data7.Add(array7);
- }
- SQLiteDataReader sqliteDataReader10 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT date, SUM(seconds) AS fsum FROM statsApp WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text12,
- " AND REPLACE(file, RTRIM(file, REPLACE(file, '/', '')), '') = '",
- text13.Replace("'", "''"),
- "' GROUP BY strftime('%Y-%m-%d', date, 'unixepoch')"
- }), this.dbHelper).ExecuteReader();
- while (sqliteDataReader10.Read())
- {
- ColdTurkey._Closure$__42-5 CS$<>8__locals6 = new ColdTurkey._Closure$__42-5(CS$<>8__locals6);
- CS$<>8__locals6.$VB$Local_midnight = Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader10["date"])) - Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader10["date"])) % 86400.0;
- int num30 = series7.Data.FindIndex((double[] point) => point[0] == CS$<>8__locals6.$VB$Local_midnight * 1000.0);
- if (num30 >= 0)
- {
- series7.Data[num30] = new double[]
- {
- CS$<>8__locals6.$VB$Local_midnight * 1000.0,
- Math.Round(Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader10["fsum"])) / 60.0, 2)
- };
- }
- }
- series7.Label = text13;
- list.Add(series7);
- }
- goto IL_1AD1;
- }
- finally
- {
- List<string>.Enumerator enumerator4;
- ((IDisposable)enumerator4).Dispose();
- }
- IL_11CA:
- string text14 = "";
- string text15 = "";
- if (Operators.CompareString(chartUsers, "all", false) != 0)
- {
- text15 = " AND user = '" + chartUsers.Replace("'", "''") + "'";
- }
- if (Operators.CompareString(chartOptions, "all", false) != 0)
- {
- List<string> values4 = new List<string>(this.settings.Blocks[chartOptions].Apps.Where((ColdTurkey._Closure$__.$I42-12 == null) ? (ColdTurkey._Closure$__.$I42-12 = ((string entry) => entry.StartsWith("file:") | entry.StartsWith("win10:"))) : ColdTurkey._Closure$__.$I42-12).Select((ColdTurkey._Closure$__.$I42-13 == null) ? (ColdTurkey._Closure$__.$I42-13 = ((string entry) => entry.Substring(checked(entry.LastIndexOf("/") + 1)))) : ColdTurkey._Closure$__.$I42-13));
- text14 = " AND ffile IN ('" + string.Join("','", values4) + "')";
- }
- List<string> list6 = new List<string>();
- SQLiteDataReader sqliteDataReader11 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT REPLACE(file, RTRIM(file, REPLACE(file, '/', '')), '') AS ffile FROM statsApp WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text15,
- text14,
- " GROUP BY ffile ORDER BY SUM(seconds) DESC LIMIT 10"
- }), this.dbHelper).ExecuteReader();
- while (sqliteDataReader11.Read())
- {
- list6.Add(sqliteDataReader11["ffile"].ToString());
- }
- try
- {
- foreach (string text16 in list6)
- {
- Series series8 = new Series();
- double num31 = num;
- double num32 = num2;
- for (double num33 = num31; num33 <= num32; num33 += 86400.0)
- {
- List<double[]> data8 = series8.Data;
- double[] array8 = new double[2];
- array8[0] = num33 * 1000.0;
- data8.Add(array8);
- }
- SQLiteDataReader sqliteDataReader12 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT date, SUM(seconds) AS fsum FROM statsApp WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text15,
- " AND REPLACE(file, RTRIM(file, REPLACE(file, '/', '')), '') = '",
- text16.Replace("'", "''"),
- "' GROUP BY strftime('%Y-%m-%d', date, 'unixepoch')"
- }), this.dbHelper).ExecuteReader();
- while (sqliteDataReader12.Read())
- {
- ColdTurkey._Closure$__42-6 CS$<>8__locals7 = new ColdTurkey._Closure$__42-6(CS$<>8__locals7);
- CS$<>8__locals7.$VB$Local_midnight = Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader12["date"])) - Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader12["date"])) % 86400.0;
- int num34 = series8.Data.FindIndex((double[] point) => point[0] == CS$<>8__locals7.$VB$Local_midnight * 1000.0);
- if (num34 >= 0)
- {
- series8.Data[num34] = new double[]
- {
- CS$<>8__locals7.$VB$Local_midnight * 1000.0,
- Math.Round(Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader12["fsum"])) / 60.0, 2)
- };
- }
- }
- series8.Label = text16;
- list.Add(series8);
- }
- goto IL_1AD1;
- }
- finally
- {
- List<string>.Enumerator enumerator5;
- ((IDisposable)enumerator5).Dispose();
- }
- IL_14DE:
- string text17 = "";
- if (Operators.CompareString(chartUsers, "all", false) != 0)
- {
- text17 = " AND user = '" + chartUsers.Replace("'", "''") + "'";
- }
- if (chartOptions == null | Operators.CompareString(chartOptions, "", false) == 0)
- {
- Series series9 = new Series();
- double num35 = num;
- double num36 = num2;
- for (double num37 = num35; num37 <= num36; num37 += 86400.0)
- {
- List<double[]> data9 = series9.Data;
- double[] array9 = new double[2];
- array9[0] = num37 * 1000.0;
- data9.Add(array9);
- }
- series9.Label = "";
- list.Add(series9);
- goto IL_1AD1;
- }
- List<string> list7 = new List<string>();
- SQLiteDataReader sqliteDataReader13 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT REPLACE(file, RTRIM(file, REPLACE(file, '/', '')), '') AS ffile FROM statsApp WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text17,
- " AND ffile LIKE '%",
- chartOptions.Replace("'", "''"),
- "%' GROUP BY ffile ORDER BY SUM(seconds) DESC LIMIT 10"
- }), this.dbHelper).ExecuteReader();
- while (sqliteDataReader13.Read())
- {
- list7.Add(sqliteDataReader13["ffile"].ToString());
- }
- try
- {
- foreach (string text18 in list7)
- {
- Series series10 = new Series();
- double num38 = num;
- double num39 = num2;
- for (double num40 = num38; num40 <= num39; num40 += 86400.0)
- {
- List<double[]> data10 = series10.Data;
- double[] array10 = new double[2];
- array10[0] = num40 * 1000.0;
- data10.Add(array10);
- }
- SQLiteDataReader sqliteDataReader14 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT date, SUM(seconds) AS fsum FROM statsApp WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text17,
- " AND REPLACE(file, RTRIM(file, REPLACE(file, '/', '')), '') = '",
- text18.Replace("'", "''"),
- "' GROUP BY strftime('%Y-%m-%d', date, 'unixepoch')"
- }), this.dbHelper).ExecuteReader();
- while (sqliteDataReader14.Read())
- {
- ColdTurkey._Closure$__42-7 CS$<>8__locals8 = new ColdTurkey._Closure$__42-7(CS$<>8__locals8);
- CS$<>8__locals8.$VB$Local_midnight = Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader14["date"])) - Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader14["date"])) % 86400.0;
- int num41 = series10.Data.FindIndex((double[] point) => point[0] == CS$<>8__locals8.$VB$Local_midnight * 1000.0);
- if (num41 >= 0)
- {
- series10.Data[num41] = new double[]
- {
- CS$<>8__locals8.$VB$Local_midnight * 1000.0,
- Math.Round(Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader14["fsum"])) / 60.0, 2)
- };
- }
- }
- series10.Label = text18;
- list.Add(series10);
- }
- goto IL_1AD1;
- }
- finally
- {
- List<string>.Enumerator enumerator6;
- ((IDisposable)enumerator6).Dispose();
- }
- IL_17D9:
- string text19 = "";
- if (Operators.CompareString(chartUsers, "all", false) != 0)
- {
- text19 = " AND user = '" + chartUsers.Replace("'", "''") + "'";
- }
- if (chartOptions == null | Operators.CompareString(chartOptions, "", false) == 0)
- {
- Series series11 = new Series();
- double num42 = num;
- double num43 = num2;
- for (double num44 = num42; num44 <= num43; num44 += 86400.0)
- {
- List<double[]> data11 = series11.Data;
- double[] array11 = new double[2];
- array11[0] = num44 * 1000.0;
- data11.Add(array11);
- }
- series11.Label = "";
- list.Add(series11);
- }
- else
- {
- List<string> list8 = new List<string>();
- SQLiteDataReader sqliteDataReader15 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT title FROM statsTitle WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text19,
- " AND title LIKE '%",
- chartOptions.Replace("'", "''"),
- "%' GROUP BY title ORDER BY SUM(seconds) DESC LIMIT 10"
- }), this.dbHelper).ExecuteReader();
- while (sqliteDataReader15.Read())
- {
- list8.Add(sqliteDataReader15["title"].ToString());
- }
- try
- {
- foreach (string text20 in list8)
- {
- Series series12 = new Series();
- double num45 = num;
- double num46 = num2;
- for (double num47 = num45; num47 <= num46; num47 += 86400.0)
- {
- List<double[]> data12 = series12.Data;
- double[] array12 = new double[2];
- array12[0] = num47 * 1000.0;
- data12.Add(array12);
- }
- SQLiteDataReader sqliteDataReader16 = new SQLiteCommand(string.Concat(new string[]
- {
- "SELECT date, SUM(seconds) AS fsum FROM statsTitle WHERE (date >= ",
- text,
- " AND date <= ",
- text2,
- ")",
- text19,
- " AND title = '",
- text20.Replace("'", "''"),
- "' GROUP BY strftime('%Y-%m-%d', date, 'unixepoch')"
- }), this.dbHelper).ExecuteReader();
- while (sqliteDataReader16.Read())
- {
- ColdTurkey._Closure$__42-8 CS$<>8__locals9 = new ColdTurkey._Closure$__42-8(CS$<>8__locals9);
- CS$<>8__locals9.$VB$Local_midnight = Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader16["date"])) - Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader16["date"])) % 86400.0;
- int num48 = series12.Data.FindIndex((double[] point) => point[0] == CS$<>8__locals9.$VB$Local_midnight * 1000.0);
- if (num48 >= 0)
- {
- series12.Data[num48] = new double[]
- {
- CS$<>8__locals9.$VB$Local_midnight * 1000.0,
- Math.Round(Convert.ToDouble(RuntimeHelpers.GetObjectValue(sqliteDataReader16["fsum"])) / 60.0, 2)
- };
- }
- }
- series12.Label = text20;
- list.Add(series12);
- }
- }
- finally
- {
- List<string>.Enumerator enumerator7;
- ((IDisposable)enumerator7).Dispose();
- }
- }
- IL_1AD1:;
- }
- catch (Exception ex)
- {
- }
- return JsonConvert.SerializeObject(list);
- }
- private void WriteError(Exception e)
- {
- string text = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Cold Turkey\\logs";
- string text2 = text + "\\error.log";
- bool append = true;
- try
- {
- if (Directory.Exists(text))
- {
- if (File.Exists(text2) && new FileInfo(text2).Length > 1000000L)
- {
- append = false;
- }
- using (StreamWriter streamWriter = new StreamWriter(text2, append))
- {
- streamWriter.WriteLine(string.Concat(new string[]
- {
- "Cold Turkey Blocker v",
- this.currentVersion.ToString("0.00"),
- " [",
- DateAndTime.Now.ToString(),
- "]\r\n",
- e.ToString()
- }));
- goto IL_127;
- }
- }
- Directory.CreateDirectory(text);
- using (StreamWriter streamWriter2 = new StreamWriter(text2, append))
- {
- streamWriter2.WriteLine(string.Concat(new string[]
- {
- "Cold Turkey Blocker v",
- this.currentVersion.ToString("0.00"),
- " [",
- DateAndTime.Now.ToString(),
- "]\r\n",
- e.ToString()
- }));
- }
- IL_127:;
- }
- catch (Exception ex)
- {
- Console.WriteLine(string.Concat(new string[]
- {
- "Cold Turkey Blocker v",
- this.currentVersion.ToString("0.00"),
- " [",
- DateAndTime.Now.ToString(),
- "]\r\n",
- ex.ToString()
- }));
- }
- }
- public ColdTurkey()
- {
- base.Load += this.ColdTurkey_Load;
- base.FormClosing += this.ColdTurkey_FormClosing;
- this.settings = null;
- this.currentVersion = 4.0;
- this.firstRun = false;
- this.previousTrayVisibleState = false;
- this.lastMinuteChecked = -1;
- this.webBrowserScale = 100;
- this.allowances = new Dictionary<string, string>();
- this.dbApp = new SQLiteConnection("Data Source=" + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Cold Turkey\\data-app.db;Version=3;");
- this.dbBrowser = new SQLiteConnection("Data Source=" + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Cold Turkey\\data-browser.db;Version=3;");
- this.dbHelper = new SQLiteConnection("Data Source=" + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Cold Turkey\\data-helper.db;Version=3;");
- this.dbService = new SQLiteConnection("Data Source=" + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Cold Turkey\\data-service.db;Version=3;");
- this.InitializeComponent();
- }
- private void DisposeOpenObjects()
- {
- try
- {
- this.tray.Visible = false;
- this.dbApp.Cancel();
- this.dbBrowser.Cancel();
- this.dbHelper.Cancel();
- this.dbService.Cancel();
- this.dbApp.Close();
- this.dbBrowser.Close();
- this.dbHelper.Close();
- this.dbService.Close();
- }
- catch (Exception ex)
- {
- }
- }
- private void QuickStartParseFromMenu(object sender, EventArgs e)
- {
- try
- {
- ToolStripMenuItem toolStripMenuItem = (ToolStripMenuItem)sender;
- string text;
- if (Operators.CompareString(toolStripMenuItem.Name, "0", false) == 0)
- {
- text = toolStripMenuItem.OwnerItem.Text;
- }
- else
- {
- text = toolStripMenuItem.OwnerItem.OwnerItem.Text;
- }
- if (text.EndsWith("..."))
- {
- text = text.Substring(0, checked(text.Length - 3));
- }
- this.QuickStart("menu", text, toolStripMenuItem.Name);
- }
- catch (Exception e2)
- {
- this.WriteError(e2);
- }
- }
- private void QuickStart(string sender, string blockId, string lockDuration)
- {
- try
- {
- if (Operators.CompareString(this.settings.Blocks[blockId].Enabled, "false", false) == 0)
- {
- int num = int.Parse(lockDuration);
- DateTime dateTime = new DateTime(DateAndTime.Now.Year, DateAndTime.Now.Month, DateAndTime.Now.Day, DateAndTime.Now.Hour, DateAndTime.Now.Minute, 0);
- DateTime dateTime2 = dateTime.AddMinutes((double)num);
- this.settings.Blocks[blockId].Type = "continuous";
- this.settings.Blocks[blockId].Enabled = "true";
- this.settings.Blocks[blockId].StartTime = string.Concat(new string[]
- {
- dateTime.Year.ToString(),
- ",",
- dateTime.Month.ToString(),
- ",",
- dateTime.Day.ToString(),
- ",",
- dateTime.Hour.ToString(),
- ",",
- dateTime.Minute.ToString()
- });
- string balloonTipText;
- if (num == 0)
- {
- this.settings.Blocks[blockId].Lock = "none";
- balloonTipText = "\"" + blockId + "\" is now being blocked.";
- }
- else
- {
- this.settings.Blocks[blockId].Lock = string.Concat(new string[]
- {
- dateTime2.Year.ToString(),
- ",",
- dateTime2.Month.ToString(),
- ",",
- dateTime2.Day.ToString(),
- ",",
- dateTime2.Hour.ToString(),
- ",",
- dateTime2.Minute.ToString()
- });
- balloonTipText = string.Concat(new string[]
- {
- "\"",
- blockId,
- "\" is now being blocked for ",
- lockDuration,
- " minutes."
- });
- }
- this.WriteSettingsToDatabase();
- if (Operators.CompareString(sender, "menu", false) == 0)
- {
- this.web.Document.InvokeScript("ForceSettingsUpdate", new object[]
- {
- this.SendSettings()
- });
- this.tray.BalloonTipTitle = "Your block started!";
- this.tray.BalloonTipText = balloonTipText;
- this.tray.BalloonTipIcon = ToolTipIcon.Info;
- this.previousTrayVisibleState = this.tray.Visible;
- this.tray.Visible = true;
- this.tray.ShowBalloonTip(6000);
- }
- }
- }
- catch (Exception e)
- {
- this.WriteError(e);
- }
- }
- private void TrayMenu_Opening(object sender, CancelEventArgs e)
- {
- try
- {
- bool flag = false;
- List<ToolStripMenuItem> list = new List<ToolStripMenuItem>();
- if (Operators.CompareString(this.settings.Settings.Password, "", false) == 0 | Operators.CompareString(this.settings.Settings.PasswordStrict, "false", false) == 0)
- {
- try
- {
- foreach (KeyValuePair<string, Block> keyValuePair in this.settings.Blocks)
- {
- if (Operators.CompareString(keyValuePair.Key, "Frozen Turkey", false) != 0)
- {
- ToolStripMenuItem toolStripMenuItem = new ToolStripMenuItem(keyValuePair.Key + "...")
- {
- Enabled = false
- };
- flag = true;
- if (Operators.CompareString(keyValuePair.Value.Enabled, "false", false) == 0)
- {
- ToolStripMenuItem toolStripMenuItem2 = new ToolStripMenuItem("Start and lock for...");
- ToolStripMenuItem value = new ToolStripMenuItem("Start with no lock", null, new EventHandler(this.QuickStartParseFromMenu), "0");
- List<ToolStripMenuItem> list2 = new List<ToolStripMenuItem>();
- list2.Add(new ToolStripMenuItem("1 day", null, new EventHandler(this.QuickStartParseFromMenu), "1440"));
- list2.Add(new ToolStripMenuItem("12 hours", null, new EventHandler(this.QuickStartParseFromMenu), "720"));
- list2.Add(new ToolStripMenuItem("8 hours", null, new EventHandler(this.QuickStartParseFromMenu), "480"));
- list2.Add(new ToolStripMenuItem("7 hours", null, new EventHandler(this.QuickStartParseFromMenu), "420"));
- list2.Add(new ToolStripMenuItem("6 hours", null, new EventHandler(this.QuickStartParseFromMenu), "360"));
- list2.Add(new ToolStripMenuItem("5 hours", null, new EventHandler(this.QuickStartParseFromMenu), "300"));
- list2.Add(new ToolStripMenuItem("4 hours", null, new EventHandler(this.QuickStartParseFromMenu), "240"));
- list2.Add(new ToolStripMenuItem("3 hours", null, new EventHandler(this.QuickStartParseFromMenu), "180"));
- list2.Add(new ToolStripMenuItem("2 hours", null, new EventHandler(this.QuickStartParseFromMenu), "120"));
- list2.Add(new ToolStripMenuItem("1 hour", null, new EventHandler(this.QuickStartParseFromMenu), "60"));
- list2.Add(new ToolStripMenuItem("50 minutes", null, new EventHandler(this.QuickStartParseFromMenu), "50"));
- list2.Add(new ToolStripMenuItem("45 minutes", null, new EventHandler(this.QuickStartParseFromMenu), "45"));
- list2.Add(new ToolStripMenuItem("30 minutes", null, new EventHandler(this.QuickStartParseFromMenu), "30"));
- list2.Add(new ToolStripMenuItem("25 minutes", null, new EventHandler(this.QuickStartParseFromMenu), "25"));
- list2.Add(new ToolStripMenuItem("20 minutes", null, new EventHandler(this.QuickStartParseFromMenu), "20"));
- list2.Add(new ToolStripMenuItem("15 minutes", null, new EventHandler(this.QuickStartParseFromMenu), "15"));
- list2.Add(new ToolStripMenuItem("10 minutes", null, new EventHandler(this.QuickStartParseFromMenu), "10"));
- list2.Add(new ToolStripMenuItem("5 minutes", null, new EventHandler(this.QuickStartParseFromMenu), "5"));
- toolStripMenuItem2.DropDownItems.AddRange(list2.ToArray());
- toolStripMenuItem.Enabled = true;
- toolStripMenuItem.DropDownItems.Add(value);
- toolStripMenuItem.DropDownItems.Add(toolStripMenuItem2);
- }
- list.Add(toolStripMenuItem);
- }
- }
- }
- finally
- {
- Dictionary<string, Block>.Enumerator enumerator;
- ((IDisposable)enumerator).Dispose();
- }
- }
- this.startTimerList.DropDownItems.Clear();
- if (flag)
- {
- this.startTimerList.Enabled = true;
- this.startTimerList.DropDownItems.AddRange(list.ToArray());
- }
- else
- {
- this.startTimerList.Enabled = false;
- }
- }
- catch (Exception e2)
- {
- this.WriteError(e2);
- }
- }
- public void UpdateButton()
- {
- try
- {
- Process.Start("http://getcoldturkey.com/support/update/win/");
- }
- catch (Exception e)
- {
- this.WriteError(e);
- }
- }
- public void UpgradeButton()
- {
- try
- {
- Process.Start("https://getcoldturkey.com/support/upgrade/");
- }
- catch (Exception e)
- {
- this.WriteError(e);
- }
- }
- public void StoryButton()
- {
- try
- {
- Process.Start("https://getcoldturkey.com/support/story/");
- }
- catch (Exception e)
- {
- this.WriteError(e);
- }
- }
- public string AddApplication(string type)
- {
- string result;
- if (Operators.CompareString(type, "file", false) == 0)
- {
- List<string> list = new List<string>();
- OpenFileDialog openFileDialog = new OpenFileDialog
- {
- Multiselect = true,
- InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
- Filter = "Executable files (*.exe, *.bin, *.com)|*.exe;*.bin;*.com",
- FilterIndex = 1
- };
- if (openFileDialog.ShowDialog() == DialogResult.OK)
- {
- foreach (string input in openFileDialog.FileNames)
- {
- list.Add("file:" + Regex.Replace(input, "\\\\", "/"));
- }
- }
- result = string.Join("::", list);
- }
- else
- {
- FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog
- {
- RootFolder = Environment.SpecialFolder.MyComputer,
- SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
- ShowNewFolderButton = false
- };
- if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
- {
- result = "folder:" + Regex.Replace(folderBrowserDialog.SelectedPath, "\\\\", "/");
- }
- else
- {
- result = "";
- }
- }
- return result;
- }
- public string ImportUrlsFromFile()
- {
- string text = "[]";
- OpenFileDialog openFileDialog = new OpenFileDialog
- {
- Title = "Import URLs from file...",
- Multiselect = false,
- InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
- Filter = "Text file (*.txt)|*.txt",
- FilterIndex = 1
- };
- checked
- {
- if (openFileDialog.ShowDialog() == DialogResult.OK)
- {
- try
- {
- if (File.Exists(openFileDialog.FileName))
- {
- string[] array = new string[]
- {
- ""
- };
- List<string> list = new List<string>();
- string[] array2 = File.ReadAllLines(openFileDialog.FileName);
- if (array2.Count<string>() > 5000)
- {
- text = "[\"error:list-too-large\"]";
- }
- else
- {
- string[] array3 = array2;
- for (int i = 0; i < array3.Length; i++)
- {
- string text2 = Regex.Replace(array3[i], "[\\t\\r\\n\\\\]", "");
- if (Operators.CompareString(text2, "", false) != 0)
- {
- list.Add(text2);
- }
- }
- text = string.Join("\",\"", list);
- text = "[\"" + text + "\"]";
- }
- }
- }
- catch (Exception ex)
- {
- text = "[\"error:list-invalid\"]";
- }
- }
- return text;
- }
- }
- public string ImportApplicationsFromFile()
- {
- string text = "[]";
- OpenFileDialog openFileDialog = new OpenFileDialog
- {
- Title = "Import applications from file...",
- Multiselect = false,
- InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
- Filter = "Cold Turkey Blocker application list (*.ctbal)|*.ctbal",
- FilterIndex = 1
- };
- if (openFileDialog.ShowDialog() == DialogResult.OK)
- {
- try
- {
- if (File.Exists(openFileDialog.FileName))
- {
- string[] array = File.ReadAllLines(openFileDialog.FileName);
- List<string> list = new List<string>();
- if (array.Count<string>() > 5000)
- {
- text = "[\"error:list-too-large\"]";
- }
- else
- {
- foreach (string text2 in array)
- {
- if (Operators.CompareString(text2, "", false) != 0 & (text2.StartsWith("file:") | text2.StartsWith("folder:") | text2.StartsWith("win10:") | text2.StartsWith("title:")))
- {
- list.Add(text2);
- }
- }
- text = string.Join("\",\"", list);
- text = "[\"" + text + "\"]";
- }
- }
- }
- catch (Exception ex)
- {
- text = "[\"error:list-invalid\"]";
- }
- }
- return text;
- }
- public void ExportList(string listTab, string blockTitle, string data)
- {
- string str = new CultureInfo("en-US", false).TextInfo.ToTitleCase(blockTitle.ToLowerInvariant());
- SaveFileDialog saveFileDialog;
- if (Operators.CompareString(listTab, "apps", false) == 0)
- {
- saveFileDialog = new SaveFileDialog
- {
- Title = "Export applications to file...",
- InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
- Filter = "Cold Turkey Blocker application list (*.ctbal)|*.ctbal",
- FilterIndex = 1,
- FileName = str + " Applications List",
- DefaultExt = "ctbal"
- };
- }
- else
- {
- saveFileDialog = new SaveFileDialog
- {
- Title = "Export URLs to file...",
- InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
- Filter = "Text file (*.txt)|*.txt",
- FilterIndex = 1,
- FileName = str + " " + listTab,
- DefaultExt = "txt"
- };
- }
- if (saveFileDialog.ShowDialog() == DialogResult.OK)
- {
- try
- {
- File.WriteAllText(saveFileDialog.FileName, data);
- }
- catch (Exception ex)
- {
- Interaction.MsgBox("Error writing to the selected location. Please try saving somewhere else.", MsgBoxStyle.OkOnly, null);
- }
- }
- }
- public void ExportBlocks(string data)
- {
- SaveFileDialog saveFileDialog = new SaveFileDialog
- {
- Title = "Export all blocks to file...",
- InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
- Filter = "Cold Turkey Blocker block lists (*.ctbbl)|*.ctbbl",
- FilterIndex = 1,
- FileName = "Block Lists from " + Environment.MachineName,
- DefaultExt = "ctbbl"
- };
- if (saveFileDialog.ShowDialog() == DialogResult.OK)
- {
- try
- {
- File.WriteAllText(saveFileDialog.FileName, data);
- }
- catch (Exception ex)
- {
- Interaction.MsgBox("Error writing to the selected location. Please try saving somewhere else.", MsgBoxStyle.OkOnly, null);
- }
- }
- }
- public string ImportBlocks()
- {
- OpenFileDialog openFileDialog = new OpenFileDialog
- {
- Title = "Import blocks from file...",
- Multiselect = false,
- InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
- Filter = "Cold Turkey Blocker block lists (*.ctbbl)|*.ctbbl",
- FilterIndex = 1
- };
- if (openFileDialog.ShowDialog() == DialogResult.OK)
- {
- try
- {
- if (File.Exists(openFileDialog.FileName))
- {
- string text = File.ReadAllText(openFileDialog.FileName);
- if (text.StartsWith("{"))
- {
- return text;
- }
- }
- }
- catch (Exception ex)
- {
- return "error:blocks-invalid";
- }
- }
- return "error:blocks-invalid";
- }
- public void RefreshBrowser(string browser)
- {
- if (Interaction.MsgBox("Cold Turkey Blocker will close the selected browser if it's running. It will then reopen the browser so that you can finish installing the extension.", MsgBoxStyle.OkCancel, "Browser Restart Required") == MsgBoxResult.Ok)
- {
- try
- {
- Process.Start(new ProcessStartInfo
- {
- FileName = AppDomain.CurrentDomain.BaseDirectory + "\\CTHostInstaller.exe",
- Arguments = browser + " true"
- });
- }
- catch (Exception e)
- {
- Interaction.MsgBox("A required file: " + AppDomain.CurrentDomain.BaseDirectory + "\\CTHostInstaller.exe is missing. Please reinstall Cold Turkey Blocker.", MsgBoxStyle.OkOnly, null);
- this.WriteError(e);
- }
- }
- }
- public void InstallBrowserExt(string browser)
- {
- try
- {
- Process.Start(new ProcessStartInfo
- {
- FileName = AppDomain.CurrentDomain.BaseDirectory + "\\CTHostInstaller.exe",
- Arguments = browser + " false"
- });
- }
- catch (Exception e)
- {
- Interaction.MsgBox("A required file: " + AppDomain.CurrentDomain.BaseDirectory + "\\CTHostInstaller.exe is missing. Please reinstall Cold Turkey Blocker.", MsgBoxStyle.OkOnly, null);
- this.WriteError(e);
- }
- }
- public void InstallChrome()
- {
- try
- {
- Process.Start("https://www.google.com/chrome/");
- }
- catch (Exception e)
- {
- this.WriteError(e);
- }
- }
- public void InstallFirefox()
- {
- try
- {
- Process.Start("https://www.mozilla.org/firefox/");
- }
- catch (Exception e)
- {
- this.WriteError(e);
- }
- }
- public void GetSettings(string settingsInput)
- {
- this.settings = JsonConvert.DeserializeObject<Settings>(settingsInput);
- this.WriteSettingsToDatabase();
- this.PipeSettingsReloadMessage();
- this.CalculateAllowances();
- this.SetWindowTitle();
- }
- public void DeleteStats()
- {
- Process.Start(AppDomain.CurrentDomain.BaseDirectory + "\\ServiceHub.Helper.exe", "-delete-stats");
- }
- public void ExportStats(object data)
- {
- TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
- SaveFileDialog saveFileDialog = new SaveFileDialog
- {
- Title = "Export statistics to file...",
- InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
- Filter = "JSON file (*.json)|*.json",
- FilterIndex = 1,
- FileName = "Cold Turkey Blocker Statistics",
- DefaultExt = "json"
- };
- if (saveFileDialog.ShowDialog() == DialogResult.OK)
- {
- try
- {
- File.WriteAllText(saveFileDialog.FileName, Conversions.ToString(data));
- }
- catch (Exception ex)
- {
- Interaction.MsgBox("Error writing to the selected location. Please try saving somewhere else.", MsgBoxStyle.OkOnly, null);
- }
- }
- }
- public object CheckProductKey(string productKey)
- {
- if (productKey != null && (productKey.Length == 24 & this.IsAlphaNum(productKey.ToUpper())))
- {
- try
- {
- if (this.GetHTML("https://getcoldturkey.com/activate/activate.php?v=4&key=" + productKey.ToUpper()).Contains("true"))
- {
- return "pass";
- }
- }
- catch (Exception ex)
- {
- }
- }
- return "fail";
- }
- private bool IsAlphaNum(string code)
- {
- string text = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- checked
- {
- for (int i = 0; i < code.Length; i++)
- {
- string value = Conversions.ToString(code[i]);
- if (!text.Contains(value))
- {
- return false;
- }
- }
- return true;
- }
- }
- private string GetHTML(string strPage)
- {
- string result = "NULL";
- try
- {
- WebResponse response = WebRequest.Create(strPage).GetResponse();
- result = new StreamReader(response.GetResponseStream()).ReadToEnd();
- }
- catch (Exception ex)
- {
- }
- return result;
- }
- public void DisableShortcutsAfterShortDelay()
- {
- this.web.WebBrowserShortcutsEnabled = false;
- }
- private void WebPreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
- {
- Keys keyData = e.KeyData;
- if (keyData <= (Keys)131137)
- {
- if (keyData != Keys.Delete)
- {
- if (keyData != (Keys)131137)
- {
- return;
- }
- this.web.WebBrowserShortcutsEnabled = true;
- Task.Delay(50).ContinueWith(delegate(Task a0)
- {
- this._Lambda$__69-0();
- });
- return;
- }
- else
- {
- this.web.WebBrowserShortcutsEnabled = true;
- Task.Delay(50).ContinueWith(delegate(Task a0)
- {
- this._Lambda$__69-6();
- });
- }
- }
- else
- {
- if (keyData == (Keys)131139)
- {
- this.web.WebBrowserShortcutsEnabled = true;
- Task.Delay(50).ContinueWith(delegate(Task a0)
- {
- this._Lambda$__69-1();
- });
- return;
- }
- if (keyData == (Keys)131142)
- {
- this.web.WebBrowserShortcutsEnabled = true;
- Task.Delay(50).ContinueWith(delegate(Task a0)
- {
- this._Lambda$__69-2();
- });
- return;
- }
- switch (keyData)
- {
- case (Keys)131158:
- this.web.WebBrowserShortcutsEnabled = true;
- Task.Delay(50).ContinueWith(delegate(Task a0)
- {
- this._Lambda$__69-4();
- });
- return;
- case (Keys)131159:
- case (Keys)131161:
- break;
- case (Keys)131160:
- this.web.WebBrowserShortcutsEnabled = true;
- Task.Delay(50).ContinueWith(delegate(Task a0)
- {
- this._Lambda$__69-3();
- });
- return;
- case (Keys)131162:
- this.web.WebBrowserShortcutsEnabled = true;
- Task.Delay(50).ContinueWith(delegate(Task a0)
- {
- this._Lambda$__69-5();
- });
- return;
- default:
- return;
- }
- }
- }
- private bool CheckConnection()
- {
- int num;
- return ColdTurkey.InternetGetConnectedState(ref num, 0);
- }
- public string GetBrowserInstallList()
- {
- List<string> list = new List<string>();
- List<string> list2 = new List<string>();
- List<string> list3 = new List<string>();
- List<string> list4 = new List<string>();
- checked
- {
- string result;
- try
- {
- if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + "\\Google\\Chrome\\Application\\chrome.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Google\\Chrome\\Application\\chrome.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Google\\Chrome\\Application\\chrome.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Google\\Chrome\\Application\\chrome.exe"))
- {
- string text = null;
- if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Google\\Chrome\\User Data\\Local State"))
- {
- text = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
- }
- else if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Google\\Chrome\\User Data\\Local State"))
- {
- text = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
- }
- if (text != null)
- {
- JObject jobject = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text + "\\Google\\Chrome\\User Data\\Local State"));
- string text2 = null;
- if (jobject["profile"]["last_used"] != null)
- {
- string text3 = jobject["profile"]["last_used"].ToString();
- if (Operators.CompareString(text3, "", false) != 0)
- {
- text2 = text3;
- }
- }
- if (text2 == null && jobject["profile"]["last_active_profiles"].Count<JToken>() > 0 && jobject["profile"]["last_active_profiles"][0] != null)
- {
- string text4 = jobject["profile"]["last_active_profiles"][0].ToString();
- if (Operators.CompareString(text4, "", false) != 0)
- {
- text2 = text4;
- }
- }
- if (text2 == null)
- {
- text2 = "Default";
- }
- if (File.Exists(text + "\\Google\\Chrome\\User Data\\" + text2 + "\\Secure Preferences") & File.Exists(text + "\\Google\\Chrome\\User Data\\" + text2 + "\\Preferences"))
- {
- try
- {
- JObject jobject2 = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text + "\\Google\\Chrome\\User Data\\" + text2 + "\\Secure Preferences"));
- JObject jobject3 = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text + "\\Google\\Chrome\\User Data\\" + text2 + "\\Preferences"));
- bool flag = false;
- try
- {
- if (jobject2["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"] != null && (int)jobject2["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"]["state"] == 1 && !(bool)jobject2["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"]["withholding_permissions"])
- {
- flag = true;
- }
- }
- catch (Exception ex)
- {
- try
- {
- if (jobject3["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"] != null && (int)jobject3["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"]["state"] == 1)
- {
- flag = true;
- }
- }
- catch (Exception ex2)
- {
- }
- }
- if (flag)
- {
- if (this.firstRun)
- {
- bool flag2 = false;
- Process[] processesByName = Process.GetProcessesByName("chrome");
- int i = 0;
- while (i < processesByName.Length)
- {
- Process process = processesByName[i];
- string text5;
- try
- {
- text5 = process.MainModule.FileName.ToLowerInvariant();
- }
- catch (Exception ex3)
- {
- goto IL_38E;
- }
- goto IL_37B;
- IL_38E:
- i++;
- continue;
- IL_37B:
- if (text5.EndsWith("\\chrome\\application\\chrome.exe"))
- {
- flag2 = true;
- break;
- }
- goto IL_38E;
- }
- if (flag2)
- {
- list2.Add("chrome");
- }
- else
- {
- list3.Add("chrome");
- }
- }
- else
- {
- list3.Add("chrome");
- }
- }
- else
- {
- list.Add("chrome");
- }
- }
- catch (Exception e)
- {
- this.WriteError(e);
- }
- }
- }
- }
- if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + "\\Google\\Chrome Beta\\Application\\chrome.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Google\\Chrome Beta\\Application\\chrome.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Google\\Chrome Beta\\Application\\chrome.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Google\\Chrome Beta\\Application\\chrome.exe"))
- {
- string text6 = null;
- if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Google\\Chrome Beta\\User Data\\Local State"))
- {
- text6 = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
- }
- else if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Google\\Chrome Beta\\User Data\\Local State"))
- {
- text6 = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
- }
- if (text6 != null)
- {
- JObject jobject4 = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text6 + "\\Google\\Chrome Beta\\User Data\\Local State"));
- string text7 = null;
- if (jobject4["profile"]["last_used"] != null)
- {
- string text8 = jobject4["profile"]["last_used"].ToString();
- if (Operators.CompareString(text8, "", false) != 0)
- {
- text7 = text8;
- }
- }
- if (text7 == null && jobject4["profile"]["last_active_profiles"].Count<JToken>() > 0 && jobject4["profile"]["last_active_profiles"][0] != null)
- {
- string text9 = jobject4["profile"]["last_active_profiles"][0].ToString();
- if (Operators.CompareString(text9, "", false) != 0)
- {
- text7 = text9;
- }
- }
- if (text7 == null)
- {
- text7 = "Default";
- }
- if (File.Exists(text6 + "\\Google\\Chrome Beta\\User Data\\" + text7 + "\\Secure Preferences") & File.Exists(text6 + "\\Google\\Chrome Beta\\User Data\\" + text7 + "\\Preferences"))
- {
- try
- {
- JObject jobject5 = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text6 + "\\Google\\Chrome Beta\\User Data\\" + text7 + "\\Secure Preferences"));
- JObject jobject6 = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text6 + "\\Google\\Chrome Beta\\User Data\\" + text7 + "\\Preferences"));
- bool flag3 = false;
- try
- {
- if (jobject5["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"] != null && (int)jobject5["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"]["state"] == 1 && !(bool)jobject5["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"]["withholding_permissions"])
- {
- flag3 = true;
- }
- }
- catch (Exception ex4)
- {
- try
- {
- if (jobject6["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"] != null && (int)jobject6["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"]["state"] == 1)
- {
- flag3 = true;
- }
- }
- catch (Exception ex5)
- {
- }
- }
- if (flag3)
- {
- if (this.firstRun)
- {
- bool flag4 = false;
- Process[] processesByName2 = Process.GetProcessesByName("chrome");
- int j = 0;
- while (j < processesByName2.Length)
- {
- Process process2 = processesByName2[j];
- string text10;
- try
- {
- text10 = process2.MainModule.FileName.ToLowerInvariant();
- }
- catch (Exception ex6)
- {
- goto IL_760;
- }
- goto IL_74D;
- IL_760:
- j++;
- continue;
- IL_74D:
- if (text10.EndsWith("\\chrome beta\\application\\chrome.exe"))
- {
- flag4 = true;
- break;
- }
- goto IL_760;
- }
- if (flag4)
- {
- list2.Add("chromebeta");
- }
- else
- {
- list3.Add("chromebeta");
- }
- }
- else
- {
- list3.Add("chromebeta");
- }
- }
- else
- {
- list.Add("chromebeta");
- }
- }
- catch (Exception e2)
- {
- this.WriteError(e2);
- }
- }
- }
- }
- if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + "\\Google\\Chrome Dev\\Application\\chrome.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Google\\Chrome Dev\\Application\\chrome.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Google\\Chrome Dev\\Application\\chrome.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Google\\Chrome Dev\\Application\\chrome.exe"))
- {
- string text11 = null;
- if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Google\\Chrome Dev\\User Data\\Local State"))
- {
- text11 = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
- }
- else if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Google\\Chrome Dev\\User Data\\Local State"))
- {
- text11 = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
- }
- if (text11 != null)
- {
- JObject jobject7 = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text11 + "\\Google\\Chrome Dev\\User Data\\Local State"));
- string text12 = null;
- if (jobject7["profile"]["last_used"] != null)
- {
- string text13 = jobject7["profile"]["last_used"].ToString();
- if (Operators.CompareString(text13, "", false) != 0)
- {
- text12 = text13;
- }
- }
- if (text12 == null && jobject7["profile"]["last_active_profiles"].Count<JToken>() > 0 && jobject7["profile"]["last_active_profiles"][0] != null)
- {
- string text14 = jobject7["profile"]["last_active_profiles"][0].ToString();
- if (Operators.CompareString(text14, "", false) != 0)
- {
- text12 = text14;
- }
- }
- if (text12 == null)
- {
- text12 = "Default";
- }
- if (File.Exists(text11 + "\\Google\\Chrome Dev\\User Data\\" + text12 + "\\Secure Preferences"))
- {
- try
- {
- JObject jobject8 = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text11 + "\\Google\\Chrome Dev\\User Data\\" + text12 + "\\Secure Preferences"));
- JObject jobject9 = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text11 + "\\Google\\Chrome Dev\\User Data\\" + text12 + "\\Preferences"));
- bool flag5 = false;
- try
- {
- if (jobject8["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"] != null && (int)jobject8["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"]["state"] == 1 && !(bool)jobject8["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"]["withholding_permissions"])
- {
- flag5 = true;
- }
- }
- catch (Exception ex7)
- {
- try
- {
- if (jobject9["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"] != null && (int)jobject9["extensions"]["settings"]["pganeibhckoanndahmnfggfoeofncnii"]["state"] == 1)
- {
- flag5 = true;
- }
- }
- catch (Exception ex8)
- {
- }
- }
- if (flag5)
- {
- if (this.firstRun)
- {
- bool flag6 = false;
- Process[] processesByName3 = Process.GetProcessesByName("chrome");
- int k = 0;
- while (k < processesByName3.Length)
- {
- Process process3 = processesByName3[k];
- string text15;
- try
- {
- text15 = process3.MainModule.FileName.ToLowerInvariant();
- }
- catch (Exception ex9)
- {
- goto IL_B19;
- }
- goto IL_B06;
- IL_B19:
- k++;
- continue;
- IL_B06:
- if (text15.EndsWith("\\chrome dev\\application\\chrome.exe"))
- {
- flag6 = true;
- break;
- }
- goto IL_B19;
- }
- if (flag6)
- {
- list2.Add("chromedev");
- }
- else
- {
- list3.Add("chromedev");
- }
- }
- else
- {
- list3.Add("chromedev");
- }
- }
- else
- {
- list.Add("chromedev");
- }
- }
- catch (Exception e3)
- {
- this.WriteError(e3);
- }
- }
- }
- }
- if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + "\\Microsoft\\Edge\\Application\\msedge.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Microsoft\\Edge\\Application\\msedge.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Microsoft\\Edge\\Application\\msedge.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Microsoft\\Edge\\Application\\msedge.exe"))
- {
- string text16 = null;
- if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Microsoft\\Edge\\User Data\\Local State"))
- {
- text16 = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
- }
- else if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Microsoft\\Edge\\User Data\\Local State"))
- {
- text16 = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
- }
- if (text16 != null)
- {
- JObject jobject10 = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text16 + "\\Microsoft\\Edge\\User Data\\Local State"));
- string text17 = null;
- if (jobject10["profile"]["last_used"] != null)
- {
- string text18 = jobject10["profile"]["last_used"].ToString();
- if (Operators.CompareString(text18, "", false) != 0)
- {
- text17 = text18;
- }
- }
- if (text17 == null && jobject10["profile"]["last_active_profiles"].Count<JToken>() > 0 && jobject10["profile"]["last_active_profiles"][0] != null)
- {
- string text19 = jobject10["profile"]["last_active_profiles"][0].ToString();
- if (Operators.CompareString(text19, "", false) != 0)
- {
- text17 = text19;
- }
- }
- if (text17 == null)
- {
- text17 = "Default";
- }
- if (File.Exists(text16 + "\\Microsoft\\Edge\\User Data\\" + text17 + "\\Secure Preferences") & File.Exists(text16 + "\\Microsoft\\Edge\\User Data\\" + text17 + "\\Preferences"))
- {
- try
- {
- JObject jobject11 = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text16 + "\\Microsoft\\Edge\\User Data\\" + text17 + "\\Secure Preferences"));
- JObject jobject12 = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text16 + "\\Microsoft\\Edge\\User Data\\" + text17 + "\\Preferences"));
- bool flag7 = false;
- try
- {
- if (jobject11["extensions"]["settings"]["jfphahkinplobmabmgjmjgflbhjjddeb"] != null && (int)jobject11["extensions"]["settings"]["jfphahkinplobmabmgjmjgflbhjjddeb"]["state"] == 1 && !(bool)jobject11["extensions"]["settings"]["jfphahkinplobmabmgjmjgflbhjjddeb"]["withholding_permissions"])
- {
- flag7 = true;
- }
- }
- catch (Exception ex10)
- {
- try
- {
- if (jobject12["extensions"]["settings"]["jfphahkinplobmabmgjmjgflbhjjddeb"] != null && (int)jobject12["extensions"]["settings"]["jfphahkinplobmabmgjmjgflbhjjddeb"]["state"] == 1)
- {
- flag7 = true;
- }
- }
- catch (Exception ex11)
- {
- }
- }
- if (flag7)
- {
- if (this.firstRun)
- {
- bool flag8 = false;
- Process[] processesByName4 = Process.GetProcessesByName("msedge");
- int l = 0;
- while (l < processesByName4.Length)
- {
- Process process4 = processesByName4[l];
- string text20;
- try
- {
- text20 = process4.MainModule.FileName.ToLowerInvariant();
- }
- catch (Exception ex12)
- {
- goto IL_EEB;
- }
- goto IL_ED8;
- IL_EEB:
- l++;
- continue;
- IL_ED8:
- if (text20.EndsWith("\\edge\\application\\msedge.exe"))
- {
- flag8 = true;
- break;
- }
- goto IL_EEB;
- }
- if (flag8)
- {
- list2.Add("msedge");
- }
- else
- {
- list3.Add("msedge");
- }
- }
- else
- {
- list3.Add("msedge");
- }
- }
- else
- {
- list.Add("msedge");
- }
- }
- catch (Exception e4)
- {
- this.WriteError(e4);
- }
- }
- }
- }
- if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + "\\Microsoft\\Edge Beta\\Application\\msedge.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Microsoft\\Edge Beta\\Application\\msedge.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Microsoft\\Edge Beta\\Application\\msedge.exe") | File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Microsoft\\Edge Beta\\Application\\msedge.exe"))
- {
- string text21 = null;
- if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Microsoft\\Edge Beta\\User Data\\Local State"))
- {
- text21 = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
- }
- else if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Microsoft\\Edge Beta\\User Data\\Local State"))
- {
- text21 = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
- }
- if (text21 != null)
- {
- JObject jobject13 = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text21 + "\\Microsoft\\Edge Beta\\User Data\\Local State"));
- string text22 = null;
- if (jobject13["profile"]["last_used"] != null)
- {
- string text23 = jobject13["profile"]["last_used"].ToString();
- if (Operators.CompareString(text23, "", false) != 0)
- {
- text22 = text23;
- }
- }
- if (text22 == null && jobject13["profile"]["last_active_profiles"].Count<JToken>() > 0 && jobject13["profile"]["last_active_profiles"][0] != null)
- {
- string text24 = jobject13["profile"]["last_active_profiles"][0].ToString();
- if (Operators.CompareString(text24, "", false) != 0)
- {
- text22 = text24;
- }
- }
- if (text22 == null)
- {
- text22 = "Default";
- }
- if (File.Exists(text21 + "\\Microsoft\\Edge Beta\\User Data\\" + text22 + "\\Secure Preferences") & File.Exists(text21 + "\\Microsoft\\Edge Beta\\User Data\\" + text22 + "\\Preferences"))
- {
- try
- {
- JObject jobject14 = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text21 + "\\Microsoft\\Edge Beta\\User Data\\" + text22 + "\\Secure Preferences"));
- JObject jobject15 = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(text21 + "\\Microsoft\\Edge Beta\\User Data\\" + text22 + "\\Preferences"));
- bool flag9 = false;
- try
- {
- if (jobject14["extensions"]["settings"]["jfphahkinplobmabmgjmjgflbhjjddeb"] != null && (int)jobject14["extensions"]["settings"]["jfphahkinplobmabmgjmjgflbhjjddeb"]["state"] == 1 && !(bool)jobject14["extensions"]["settings"]["jfphahkinplobmabmgjmjgflbhjjddeb"]["withholding_permissions"])
- {
- flag9 = true;
- }
- }
- catch (Exception ex13)
- {
- try
- {
- if (jobject15["extensions"]["settings"]["jfphahkinplobmabmgjmjgflbhjjddeb"] != null && (int)jobject15["extensions"]["settings"]["jfphahkinplobmabmgjmjgflbhjjddeb"]["state"] == 1)
- {
- flag9 = true;
- }
- }
- catch (Exception ex14)
- {
- }
- }
- if (flag9)
- {
- if (this.firstRun)
- {
- bool flag10 = false;
- Process[] processesByName5 = Process.GetProcessesByName("msedge");
- int m = 0;
- while (m < processesByName5.Length)
- {
- Process process5 = processesByName5[m];
- string text25;
- try
- {
- text25 = process5.MainModule.FileName.ToLowerInvariant();
- }
- catch (Exception ex15)
- {
- goto IL_12BD;
- }
- goto IL_12AA;
- IL_12BD:
- m++;
- continue;
- IL_12AA:
- if (text25.EndsWith("\\edge beta\\application\\msedge.exe"))
- {
- flag10 = true;
- break;
- }
- goto IL_12BD;
- }
- if (flag10)
- {
- list2.Add("msedgebeta");
- }
- else
- &nb