/** Preparse and move all files and subfolders within path * * @return bool */ protected function _preparse() { global $Config; // get new path $path_new = $this->_getPath(false, false); // free path if ($this->path == $path_new) { // move $path_old = $this->path . '__moved_by_preparser_' . rand(1, 1000); ts_FileHandler::copyFolder($this->path, $path_old); $this->path = $path_old; } elseif (is_dir($path_new)) { ts_BackupHandler::backupModule($path_new, 'invalid_name'); } ts_FileHandler::deleteFolder($path_new); // load PreParser-object $PreParser = new ts_PreParser($this); // parse if ($PreParser->parse($this->path, $path_new, $Config->get('dir_data'))) { // success // delete old source ts_FileHandler::deleteFolder($this->path); $this->path = $path_new; return true; } // failure ts_FileHandler::deleteFolder($path_new); return false; }
/** Delete module * * @return bool */ public function deleteModule() { global $Database; // is source available? if (is_dir($this->path)) { // backup if (!ts_BackupHandler::backupModule($this->path)) { return false; } } if (!ts_FileHandler::deleteFolder($this->path)) { return false; } // delete entry in database $sql = "DELETE FROM #__modules\n\t WHERE id__module = '" . $this->id . "';"; if (!$Database->doDelete($sql)) { return false; } return true; }
/** Backup runtime folder * @param bool $includeDatabase * Backup database, too? * * @return array */ public function backupRuntime($includeDatabase = false) { global $Config, $Database; // create paths $path = $Config->get('dir_runtime'); $path_new = $Config->get('dir_data') . '/backup/runtime/' . date('Y_m_d__H_i_s'); // move folder to backup-directory if (!ts_FileHandler::copyFolder($path, $path_new)) { return false; } // backup database //TODO - skip database-backup (creates too big sql-file!) if ($includeDatabase) { // get path for sql-backup $path_sql = $path_new . '/backup_database.sql'; // backup database // if (!self::backupDatabase($path_sql)) return false; } // get number of backups $path = $Config->get('dir_data') . '/backup/runtime'; $backups = ts_FileHandler::getSubFolders($path); rsort($backups); $counter = 0; foreach ($backups as $index => $value) { $counter++; if ($counter >= 10) { // delete backup ts_FileHandler::deleteFolder($path . '/' . $value); } } return true; }