/** * function for removing all files in htdocs/files/*, htdocs/logo/* * when doing an install * * @return int value from exec command */ function cos_rm_files() { common::needRoot(); $files_path = conf::pathFiles() . "/*"; $command = "rm -Rf {$files_path}"; common::execCommand($command); }
/** * function for removing all files in htdocs/files/*, htdocs/logo/* * when doing an install * * @return int value from exec command */ function cos_rm_files() { common::needRoot(); $files_path = conf::pathBase() . '/htdocs/files/* '; $command = "rm -Rf {$files_path}"; common::execCommand($command); }
/** * Method that disable an apache2 site * * @param array $options only options is $options[sitename] */ public static function disableSite($options) { common::needRoot(); $hostname = trim($options['hostname']); $apache2_conf_file = "/etc/apache2/sites-available/{$hostname}"; $ret = common::execCommand("a2dissite {$hostname}"); if ($ret) { return false; } $version = self::getVersion(); $version = version::getSemanticAry($version); if ($version['minor'] >= 4) { $apache2_conf_file .= ".conf"; } $ret = common::execCommand("rm -f {$apache2_conf_file}"); // create new hosts file and reload server $host_file_str = ''; $hosts_file_str = file("/etc/hosts"); $host_search = "127.0.0.1\t{$hostname}\n"; $str = ""; foreach ($hosts_file_str as $key => $val) { if (strstr($val, $host_search)) { continue; } else { $host_file_str .= $val; } } file_put_contents("tmp/hosts", $host_file_str); common::execCommand("cp -f tmp/hosts /etc/hosts"); common::execCommand("/etc/init.d/apache2 reload"); }
/** * CLI command. Function for restoring tar archive * All file settings are restored (if user is the owner of all files) * * @param array options to parser, e.g. * <code>array('File' => '/backup/full/latest.tar')</code> This will restore * the tar achive /backup/full/latest.tar * * Leave options empty if you * want to restore latest archive with highest timestamp, .e.g * backup/full/1264168904.tar * @return int the executed commands shell status 0 on success. */ function backup_files_restore($options) { // in order to easily preserve ownership we use need to run as root if (!isset($options['File'])) { $latest = backup_get_latest_backup('files'); if ($latest == 0) { die("Yet no backups\n"); } $backup_file = $latest = "backup/files/" . $latest . ".tar.gz"; } else { $backup_file = $options['File']; } common::needRoot("In order to restore: {$backup_file}. We need root"); $command = "tar -Pxzf {$backup_file} -v ./htdocs/files "; $ret = common::execCommand($command); }
function cos_check_root($options = null) { common::needRoot(); }