本文整理汇总了PHP中MainWP_Utility::downloadToFile方法的典型用法代码示例。如果您正苦于以下问题:PHP MainWP_Utility::downloadToFile方法的具体用法?PHP MainWP_Utility::downloadToFile怎么用?PHP MainWP_Utility::downloadToFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainWP_Utility
的用法示例。
在下文中一共展示了MainWP_Utility::downloadToFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: backupDownloadFile
public static function backupDownloadFile($pSiteId, $pType, $pUrl, $pFile)
{
$dir = dirname($pFile) . '/';
@mkdir($dir, 0777, true);
if (!file_exists($dir . 'index.php')) {
@touch($dir . 'index.php');
}
//Clean old backups from our system
$maxBackups = get_option('mainwp_backupsOnServer');
if ($maxBackups === false) {
$maxBackups = 1;
}
$dbBackups = array();
$fullBackups = array();
if (file_exists($dir) && ($dh = opendir($dir))) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..') {
$theFile = $dir . $file;
if ($pType == 'db' && MainWP_Utility::isSQLFile($file)) {
$dbBackups[filemtime($theFile) . $file] = $theFile;
}
if ($pType == 'full' && MainWP_Utility::isArchive($file) && !MainWP_Utility::isSQLArchive($file)) {
$fullBackups[filemtime($theFile) . $file] = $theFile;
}
}
}
closedir($dh);
}
krsort($dbBackups);
krsort($fullBackups);
$cnt = 0;
foreach ($dbBackups as $key => $dbBackup) {
$cnt++;
if ($cnt >= $maxBackups) {
@unlink($dbBackup);
}
}
$cnt = 0;
foreach ($fullBackups as $key => $fullBackup) {
$cnt++;
if ($cnt >= $maxBackups) {
@unlink($fullBackup);
}
}
$website = MainWP_DB::Instance()->getWebsiteById($pSiteId);
MainWP_Utility::endSession();
$what = null;
if ($pType == 'db') {
MainWP_Utility::downloadToFile(MainWP_Utility::getGetDataAuthed($website, $pUrl, 'fdl'), $pFile, false, $website->http_user, $website->http_pass);
}
if ($pType == 'full') {
MainWP_Utility::downloadToFile(MainWP_Utility::getGetDataAuthed($website, $pUrl, 'fdl'), $pFile, false, $website->http_user, $website->http_pass);
}
return true;
}