本文整理汇总了PHP中fs_director::SlashesToWin方法的典型用法代码示例。如果您正苦于以下问题:PHP fs_director::SlashesToWin方法的具体用法?PHP fs_director::SlashesToWin怎么用?PHP fs_director::SlashesToWin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fs_director
的用法示例。
在下文中一共展示了fs_director::SlashesToWin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ExecuteBackup
function ExecuteBackup($userid, $username, $download = 0)
{
include '../../../cnf/db.php';
try {
$zdbh = new db_driver("mysql:host=" . $host . ";dbname=" . $dbname . "", $user, $pass);
} catch (PDOException $e) {
exit;
}
$basedir = ctrl_options::GetSystemOption('temp_dir');
if (!is_dir($basedir)) {
fs_director::CreateDirectory($basedir);
}
$basedir = ctrl_options::GetSystemOption('sentora_root') . "etc/tmp/";
if (!is_dir($basedir)) {
fs_director::CreateDirectory($basedir);
}
$temp_dir = ctrl_options::GetSystemOption('sentora_root') . "etc/tmp/";
// Lets grab and archive the user's web data....
$homedir = ctrl_options::GetSystemOption('hosted_dir') . $username;
$backupname = $username . "_" . date("M-d-Y_hms", time());
$dbstamp = date("dmy_Gi", time());
// We now see what the OS is before we work out what compression command to use..
if (sys_versions::ShowOSPlatformVersion() == "Windows") {
$resault = exec(fs_director::SlashesToWin(ctrl_options::GetSystemOption('zip_exe') . " a -tzip -y-r " . $temp_dir . $backupname . ".zip " . $homedir . "/public_html"));
} else {
//cd /var/sentora/hostdata/zadmin/; zip -r backups/backup.zip public_html/
$resault = exec("cd " . $homedir . "/ && " . ctrl_options::GetSystemOption('zip_exe') . " -r9 " . $temp_dir . $backupname . " public_html/*");
@chmod($temp_dir . $backupname . ".zip", 0777);
}
// Now lets backup all MySQL datbases for the user and add them to the archive...
$sql = "SELECT COUNT(*) FROM x_mysql_databases WHERE my_acc_fk=:userid AND my_deleted_ts IS NULL";
$numrows = $zdbh->prepare($sql);
$numrows->bindParam(':userid', $userid);
$numrows->execute();
if ($numrows) {
if ($numrows->fetchColumn() != 0) {
$sql = $zdbh->prepare("SELECT * FROM x_mysql_databases WHERE my_acc_fk=:userid AND my_deleted_ts IS NULL");
$sql->bindParam(':userid', $userid);
$sql->execute();
while ($row_mysql = $sql->fetch()) {
$bkcommand = ctrl_options::GetSystemOption('mysqldump_exe') . " -h " . $host . " -u " . $user . " -p" . $pass . " --no-create-db " . $row_mysql['my_name_vc'] . " > " . $temp_dir . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql";
passthru($bkcommand);
// Add it to the ZIP archive...
if (sys_versions::ShowOSPlatformVersion() == "Windows") {
$resault = exec(fs_director::SlashesToWin(ctrl_options::GetSystemOption('zip_exe') . " u " . $temp_dir . $backupname . ".zip " . $temp_dir . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql"));
} else {
$resault = exec("cd " . $temp_dir . "/ && " . ctrl_options::GetSystemOption('zip_exe') . " " . $temp_dir . $backupname . " " . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql");
}
unlink($temp_dir . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql");
}
}
}
// We have the backup now lets output it to disk or download
if (file_exists($temp_dir . $backupname . ".zip")) {
// If Disk based backups are allowed in backup config
if (strtolower(ctrl_options::GetSystemOption('disk_bu')) == "true") {
// Copy Backup to user home directory...
$backupdir = $homedir . "/backups/";
if (!is_dir($backupdir)) {
fs_director::CreateDirectory($backupdir);
@chmod($backupdir, 0777);
}
copy($temp_dir . $backupname . ".zip", $backupdir . $backupname . ".zip");
fs_director::SetFileSystemPermissions($backupdir . $backupname . ".zip", 0777);
} else {
$backupdir = $temp_dir;
}
// If Client has checked to download file
if ($download != 0) {
/* Ajax not supporting headers - changed to link in temp dir.
if (sys_versions::ShowOSPlatformVersion() == "Windows") {
# Now we send the output (Windows)...
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename=' . $backupname . '.zip');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($backupdir . $backupname . '.zip ') . '');
readfile($backupdir . $backupname . ".zip ");
} else {
# Now we send the output (POSIX)...
$file = $backupdir . $backupname . ".zip";
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Description: File Transfer');
header('Content-Transfer-Encoding: binary');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename=' . $backupname . '.zip');
readfile_chunked($file);
}
*/
fs_director::SetFileSystemPermissions($backupdir . $backupname . ".zip", 0777);
return $temp_dir . $backupname . ".zip";
}
//.........这里部分代码省略.........
示例2: exec
$resault = exec("cd " . $homedir . "/ && " . ctrl_options::GetSystemOption('zip_exe') . " -r9 " . ctrl_options::GetSystemOption('temp_dir') . $backupname . " public_html/*");
@chmod(ctrl_options::GetSystemOption('temp_dir') . $backupname . ".zip", 0777);
}
// Now lets backup all MySQL datbases for the user and add them to the archive...
$sql = "SELECT COUNT(*) FROM x_mysql_databases WHERE my_acc_fk=" . $userid . " AND my_deleted_ts IS NULL";
if ($numrows = $zdbh->query($sql)) {
if ($numrows->fetchColumn() != 0) {
$sql = $zdbh->prepare("SELECT * FROM x_mysql_databases WHERE my_acc_fk=:userid AND my_deleted_ts IS NULL");
$sql->bindParam(':userid', $userid);
$sql->execute();
while ($row_mysql = $sql->fetch()) {
$bkcommand = ctrl_options::GetSystemOption('mysqldump_exe') . " -h " . $host . " -u " . $user . " -p" . $pass . " --no-create-db " . $row_mysql['my_name_vc'] . " > " . ctrl_options::GetSystemOption('temp_dir') . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql";
passthru($bkcommand);
// Add it to the ZIP archive...
if (sys_versions::ShowOSPlatformVersion() == "Windows") {
$resault = exec(fs_director::SlashesToWin(ctrl_options::GetSystemOption('zip_exe') . " u " . ctrl_options::GetSystemOption('temp_dir') . $backupname . ".zip " . ctrl_options::GetSystemOption('temp_dir') . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql"));
} else {
$resault = exec("cd " . ctrl_options::GetSystemOption('temp_dir') . "/ && " . ctrl_options::GetSystemOption('zip_exe') . " " . ctrl_options::GetSystemOption('temp_dir') . $backupname . " " . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql");
}
unlink(ctrl_options::GetSystemOption('temp_dir') . $row_mysql['my_name_vc'] . "_" . $dbstamp . ".sql");
}
}
}
// We have the backup now lets output it to disk or download
if (file_exists(ctrl_options::GetSystemOption('temp_dir') . $backupname . ".zip")) {
// Copy Backup to user home directory...
$backupdir = $homedir . "/backups/";
if (!is_dir($backupdir)) {
mkdir($backupdir, 0777, TRUE);
}
copy(ctrl_options::GetSystemOption('temp_dir') . $backupname . ".zip", $backupdir . $backupname . ".zip");