本文整理匯總了PHP中MailSo\Base\Utils::CopyDir方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::CopyDir方法的具體用法?PHP Utils::CopyDir怎麽用?PHP Utils::CopyDir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::CopyDir方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: CopyDir
/**
* @param string $sSource
* @param string $sDestination
*/
public static function CopyDir($sSource, $sDestination)
{
if (\is_dir($sSource)) {
if (!\is_dir($sDestination)) {
\mkdir($sDestination);
}
$oDirectory = \dir($sSource);
if ($oDirectory) {
while (false !== ($sRead = $oDirectory->read())) {
if ('.' === $sRead || '..' === $sRead) {
continue;
}
$sPathDir = $sSource . '/' . $sRead;
if (\is_dir($sPathDir)) {
\MailSo\Base\Utils::CopyDir($sPathDir, $sDestination . '/' . $sRead);
continue;
}
\copy($sPathDir, $sDestination . '/' . $sRead);
}
$oDirectory->close();
}
}
}
示例2: DoAdminUpdateCoreData
/**
* @return array
*/
public function DoAdminUpdateCoreData()
{
$this->IsAdminLoggined();
$bReal = false;
$sNewVersion = '';
$bRainLoopUpdatable = $this->rainLoopUpdatable();
$bRainLoopAccess = $this->rainLoopCoreAccess();
$aData = array();
if ($bRainLoopUpdatable && $bRainLoopAccess) {
$aData = $this->getCoreData($bReal);
}
$bResult = false;
if ($bReal && !empty($aData['file'])) {
$sTmp = $this->downloadRemotePackageByUrl($aData['file']);
if (!empty($sTmp)) {
include_once APP_VERSION_ROOT_PATH . 'app/libraries/pclzip/pclzip.lib.php';
$oArchive = new \PclZip($sTmp);
$sTmpFolder = APP_PRIVATE_DATA . \md5($sTmp);
\mkdir($sTmpFolder);
if (\is_dir($sTmpFolder)) {
$bResult = 0 !== $oArchive->extract(PCLZIP_OPT_PATH, $sTmpFolder);
if (!$bResult) {
$this->Logger()->Write('Cannot extract package files: ' . $oArchive->errorInfo(), \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
}
if ($bResult && \file_exists($sTmpFolder . '/index.php') && \is_writable(APP_INDEX_ROOT_PATH . 'rainloop/') && \is_writable(APP_INDEX_ROOT_PATH . 'index.php') && \is_dir($sTmpFolder . '/rainloop/')) {
$aMatch = array();
$sIndexFile = \file_get_contents($sTmpFolder . '/index.php');
if (\preg_match('/\'APP_VERSION\', \'([^\']+)\'/', $sIndexFile, $aMatch) && !empty($aMatch[1])) {
$sNewVersion = \trim($aMatch[1]);
}
if (empty($sNewVersion)) {
$this->Logger()->Write('Unknown version', \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
} else {
if (!\is_dir(APP_INDEX_ROOT_PATH . 'rainloop/v/' . $sNewVersion)) {
\MailSo\Base\Utils::CopyDir($sTmpFolder . '/rainloop/', APP_INDEX_ROOT_PATH . 'rainloop/');
if (\is_dir(APP_INDEX_ROOT_PATH . 'rainloop/v/' . $sNewVersion) && \is_file(APP_INDEX_ROOT_PATH . 'rainloop/v/' . $sNewVersion . '/index.php')) {
$bResult = \copy($sTmpFolder . '/index.php', APP_INDEX_ROOT_PATH . 'index.php');
if ($bResult) {
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('opcache_invalidate')) {
@\opcache_invalidate(APP_INDEX_ROOT_PATH . 'index.php', true);
}
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('apc_delete_file')) {
@\apc_delete_file(APP_INDEX_ROOT_PATH . 'index.php');
}
}
} else {
$this->Logger()->Write('Cannot copy new package files', \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
$this->Logger()->Write($sTmpFolder . '/rainloop/ -> ' . APP_INDEX_ROOT_PATH . 'rainloop/', \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
}
} else {
if (!empty($sNewVersion)) {
$this->Logger()->Write('"' . $sNewVersion . '" version already installed', \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
}
}
}
} else {
if ($bResult) {
$this->Logger()->Write('Cannot validate package files', \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
}
}
\MailSo\Base\Utils::RecRmDir($sTmpFolder);
} else {
$this->Logger()->Write('Cannot create tmp folder: ' . $sTmpFolder, \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
}
@\unlink($sTmp);
}
}
return $this->DefaultResponse(__FUNCTION__, $bResult);
}