DupLiteBackupDir = DUP_Settings::getSsdirPath(); } /** * Apply patch code to all installer files */ public function ApplyInstallerPatch_0001() { $backupDir = $this->DupLiteBackupDir; foreach (glob("{$backupDir}/*_installer.php") as $file) { if (strstr($file, '_installer.php')) { $content = "\n"; $this->fwritePrepend($file, $content); } } } /** * Prepends data to an existing file * * @param string $file The full file path to the file * @param string $content The content to prepend to the file * * @return TRUE on success or if file does not exist. FALSE on failure */ private function fwritePrepend($file, $prepend) { if (!file_exists($file) || !is_writable($file)) { return false; } $handle = fopen($file, "r+"); $len = strlen($prepend); $final_len = filesize($file) + $len; $cache_old = fread($handle, $len); rewind($handle); $i = 1; while (ftell($handle) < $final_len) { fwrite($handle, $prepend); $prepend = $cache_old; $cache_old = fread($handle, $len); fseek($handle, $i * $len); $i++; } } }