public void BindData()
        {
            List <UpdateItem> updateItems = AutoUpdateManager.GetFilesInUpdatePackage(Target).OrderBy(p => p.RelativeDirectory).ThenBy(p => p.Name).ToList();

            foreach (UpdateItem updateItem in updateItems)
            {
                updateItem.RelativeDirectory = updateItem.RelativeDirectory.Replace("\\", "\\\\");
            }

            gvPackageFiles.Visible = updateItems.Count() > 0;

            if (ShowDelete == false)
            {
                foreach (DataControlField c in gvPackageFiles.Columns)
                {
                    if (c.HeaderText == "Delete")
                    {
                        c.Visible = false;
                    }
                }
            }

            gvPackageFiles.DataSource = updateItems;
            gvPackageFiles.DataBind();
        }
示例#2
0
        protected bool CommitChanges()
        {
            List <UpdateItem> updateItems = AutoUpdateManager.GetFilesInUpdatePackage(this.Target);

            string workingDirectory = Server.MapPath("~/TempFiles/" + this.Target);

            if (FindAllLauncherInstancesForDirectory(workingDirectory) > 1)
            {
                lblErrorMessage.Text = "Multiple launcher.exe instances found. Only one launcher.exe may be specified.";
                return(false);
            }

            CommitItems(updateItems, workingDirectory, workingDirectory);

            CleanUpPackageDirectories(updateItems, workingDirectory, workingDirectory);

            return(true);
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.PageHeader = "CSS - File Manager";

            if (this.IsPostBack == false)
            {
                List <UpdateItem> updateItems = AutoUpdateManager.GetFilesInUpdatePackage(this.Target);

                string workingDirectory = Server.MapPath("~/TempFiles/" + this.Target);

                if (Directory.Exists(workingDirectory) == true)
                {
                    Directory.Delete(workingDirectory, true);
                }

                Directory.CreateDirectory(workingDirectory);

                foreach (UpdateItem updateItem in updateItems)
                {
                    string targetDirectory = Path.Combine(workingDirectory, updateItem.RelativeDirectory);
                    if (Directory.Exists(targetDirectory) == false)
                    {
                        Directory.CreateDirectory(targetDirectory);
                    }

                    string destinationFile = Path.Combine(targetDirectory, updateItem.Name);
                    File.Copy(updateItem.FileInfo.FullName, destinationFile, true);
                }

                //FileInfo packageInfo = AutoUpdateManager.GetPackageInfo(this.Target);
                //CopyItemsToTempDirectory(packageInfo.FullName, workingDirectory);

                wcFileManager.RootDirectories.Add(new IZ.WebFileManager.RootDirectory()
                {
                    DirectoryPath = "~/TempFiles/" + this.Target,
                    Text          = this.Target,
                    ShowRootIndex = false
                });
            }
        }
示例#4
0
        private void CheckPackageForUpdatedLauncher()
        {
            List <UpdateItem> filesInPackage = AutoUpdateManager.GetFilesInUpdatePackage(txtPackageName.Text);

            UpdateItem launcherInstance = filesInPackage.FirstOrDefault(p => p.Name.ToLower() == "launcher.exe");

            if (launcherInstance != null)
            {
                // Create new launcher hash.
                using (SHA256Managed sha = new SHA256Managed())
                    using (FileStream fs = File.Open(launcherInstance.FileInfo.FullName, FileMode.Open, FileAccess.Read))
                    {
                        byte[] hash;

                        if (Settings.Default.UseDebugBlackBox == true)
                        {
                            hash = new byte[] { 0x37, 0x61, 0xA7, 0x4B, 0x7E, 0x31, 0xC8, 0x5E, 0xD1, 0xC0, 0xF7, 0xB3,
                                                0x95, 0xD4, 0x7E, 0x64, 0xB9, 0xC3, 0x22, 0xED, 0x2F, 0x6F, 0xF8, 0xEB,
                                                0x4D, 0xA1, 0x00, 0x9A, 0x35, 0xE5, 0x10, 0x19 };
                        }
                        else
                        {
                            hash = sha.ComputeHash(fs);
                        }

                        File.WriteAllBytes(Settings.Default.KnownHashLocation, hash);
                    }

                // Invalidate all existing blackboxes to force regeneration of key tokens.
                using (CSSDataContext db = new CSSDataContext())
                {
                    // TODO: Is there a LINQ native way to do this?
                    db.ExecuteCommand("UPDATE ActiveKey SET IsValid = 0");
                    db.SubmitChanges();
                }
            }
        }
示例#5
0
        private bool ValidateCombinedPackageAndZipFileContainOnlyOneLauncher(string targetPackage, string tempDirectory)
        {
            List <string>     launcherInstancesInZipFile    = GetLauncherInstancesInDirectory(tempDirectory);
            List <string>     launcherIntancesInPackageFile = new List <string>();
            List <UpdateItem> updateItems = AutoUpdateManager.GetFilesInUpdatePackage(targetPackage);

            //string packagePath = Path.Combine(AutoUpdateManager.PackageRoot, targetPackage);

            int matchedItemCounter = 0;

            foreach (UpdateItem updateItem in updateItems)
            {
                if (updateItem.Name.Equals("launcher.exe", StringComparison.InvariantCultureIgnoreCase) == true)
                {
                    string updateItemRelativeFilename = Path.Combine(updateItem.RelativeDirectory, updateItem.Name);
                    launcherIntancesInPackageFile.Add(updateItemRelativeFilename);

                    foreach (string zipFileLauncherInstance in launcherInstancesInZipFile)
                    {
                        string relativePath = zipFileLauncherInstance.Substring(tempDirectory.Length + 1);

                        if (relativePath.Equals(updateItemRelativeFilename, StringComparison.InvariantCultureIgnoreCase) == true)
                        {
                            matchedItemCounter++;
                            break;
                        }
                    }
                }
            }

            if (launcherInstancesInZipFile.Count + launcherIntancesInPackageFile.Count - matchedItemCounter > 1)
            {
                return(false);
            }

            return(true);
        }
示例#6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string backupName        = Request.Params["backup"];
            string itemType          = Request.Params["type"];
            string container         = Request.Params["container"];
            string relativeDirectory = Request.Params["rel"];
            string filename          = Request.Params["file"];

            string rootDirectory = String.Empty;

            string filepath = AutoUpdateManager.GetFilePath(itemType, container, relativeDirectory, filename);

            UpdateItem itemToDownload = null;

            if (String.IsNullOrEmpty(backupName) == false)             // Download the file from a backup.
            {
                if (AutoUpdateManager.IsFilenameOrDirectorySafe(backupName) == false)
                {
                    throw new Exception("backup name is invalid.");
                }

                BackupItems backupItems = AutoUpdateManager.GetFilesInBackup(backupName);

                if (itemType == "Packages")
                {
                    itemToDownload = backupItems.PackageFiles.FirstOrDefault(p => p.Name == filename && p.PackageName == container && p.RelativeDirectory == relativeDirectory);
                }
                else
                {
                    throw new Exception("Unsupported itemType: " + itemType);
                }
            }
            else             // Download the file from a package.
            {
                if (itemType == "Packages")
                {
                    List <UpdateItem> itemsInPackage = AutoUpdateManager.GetFilesInUpdatePackage(container);
                    itemToDownload = itemsInPackage.FirstOrDefault(p => p.Name == filename && p.PackageName == container && p.RelativeDirectory == relativeDirectory);
                }
                else
                {
                    throw new Exception("Unsupported itemType: " + itemType);
                }
            }

            if (itemToDownload == null)
            {
                Response.StatusCode = 404;
                Response.End();
            }

            string mimeType = Utility.GetMimeType(Path.GetExtension(itemToDownload.Name));

            byte[] outputBytes = File.ReadAllBytes(itemToDownload.FileInfo.FullName);

            Response.ContentType = mimeType;
            Response.AddHeader("Content-Disposition", "attachment; filename=" + itemToDownload.Name);
            Response.AddHeader("ContentLength", outputBytes.Length.ToString());

            Response.BinaryWrite(outputBytes);
        }