本文整理汇总了PHP中is_dir_writeable函数的典型用法代码示例。如果您正苦于以下问题:PHP is_dir_writeable函数的具体用法?PHP is_dir_writeable怎么用?PHP is_dir_writeable使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_dir_writeable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _checkPath
/**
* Check file system path
*
* @param string $path
* @param bool $recursive
* @param bool $existence
* @param string $mode
* @return bool
*/
protected function _checkPath($path, $recursive, $existence, $mode)
{
$res = true;
$fullPath = dirname(Mage::getRoot()) . $path;
if ($mode == self::MODE_WRITE) {
$setError = false;
if ($existence) {
if (is_dir($fullPath) && !is_dir_writeable($fullPath) || !is_writable($fullPath)) {
$setError = true;
}
} else {
if (file_exists($fullPath) && !is_writable($fullPath)) {
$setError = true;
}
}
if ($setError) {
$this->_getInstaller()->getDataModel()->addError(Mage::helper('install')->__('Path "%s" must be writable.', $fullPath));
$res = false;
}
}
if ($recursive && is_dir($fullPath)) {
foreach (new DirectoryIterator($fullPath) as $file) {
if (!$file->isDot() && $file->getFilename() != '.svn' && $file->getFilename() != '.htaccess') {
$res = $res && $this->_checkPath($path . DS . $file->getFilename(), $recursive, $existence, $mode);
}
}
}
return $res;
}
示例2: getImportPath
public function getImportPath()
{
$path = Mage::getBaseDir('var') . DS . 'import' . DS . 'enhancedcms' . DS;
if (is_dir_writeable($path) != true) {
mkdir($path, '0744', $recursive = true);
}
// end
return $path;
}
示例3: _initAction
protected function _initAction()
{
$testDirs = array(Mage::getConfig()->getVarDir(), Mage::getBaseDir());
foreach ($testDirs as $dir) {
if (!is_dir_writeable($dir)) {
$this->_getSession()->addError($this->__('%s is not writeable by web server, please fix it.', $dir));
}
}
}
示例4: _getStorageDirectory
/**
* Get directory to store files; create if necessary and test if it is writable.
*
* @return string
* @throws Mage_Core_Exception
*/
protected function _getStorageDirectory()
{
$directoryPath = Mage::getStoreConfig(self::DIRECTORY_CONFIG_PATH);
if (!is_dir($directoryPath)) {
if (!mkdir($directoryPath, 0777, true)) {
Mage::throwException(Mage::helper('contentsync')->__('Directory "%s" could not be created.', $directoryPath));
}
}
if (!is_dir_writeable($directoryPath)) {
Mage::throwException(Mage::helper('contentsync')->__('Directory "%s" is not writable.', $directoryPath));
}
if (!in_array(substr($directoryPath, -1, 1), array('/', '\\'))) {
$directoryPath .= DS;
}
return $directoryPath;
}
示例5: getImportPath
public function getImportPath($theme = "")
{
$path = Mage::getBaseDir('var') . DS . 'cache' . DS;
if (is_dir_writeable($path) != true) {
mkdir($path, '0744', $recursive = true);
}
// end
return $path;
}
示例6: _checkFullPath
/**
* Check file system full path
*
* @param string $fullPath
* @param bool $recursive
* @param bool $existence
* @return bool
*/
protected function _checkFullPath($fullPath, $recursive, $existence)
{
$res = true;
$setError = $existence && (is_dir($fullPath) && !is_dir_writeable($fullPath) || !is_writable($fullPath)) || !$existence && file_exists($fullPath) && !is_writable($fullPath);
if ($setError) {
$this->_getInstaller()->getDataModel()->addError(Mage::helper('install')->__('Path "%s" must be writable.', $fullPath));
$res = false;
}
if ($recursive && is_dir($fullPath)) {
$skipFileNames = array('.svn', '.htaccess');
foreach (new DirectoryIterator($fullPath) as $file) {
$fileName = $file->getFilename();
if (!$file->isDot() && !in_array($fileName, $skipFileNames)) {
$res = $this->_checkFullPath($fullPath . DS . $fileName, $recursive, $existence) && $res;
}
}
}
return $res;
}
示例7: getUpdatedCustomerFromFile
public function getUpdatedCustomerFromFile($lastUpdatedTime)
{
$customerIds = array();
$dir = Mage::getBaseDir('media') . DS . 'webpos';
$customer_updatedfile = $dir . DS . 'customer_updated.txt';
if (!is_dir_writeable($dir)) {
$file = new Varien_Io_File();
$file->checkAndCreateFolder($dir);
}
$fileContent = file_get_contents($customer_updatedfile);
$fileContent = Zend_Json::decode($fileContent);
if (count($fileContent) > 0) {
foreach ($fileContent as $customerId => $updated_time) {
if ($lastUpdatedTime < $updated_time) {
$customerIds[] = $customerId;
}
}
}
return $customerIds;
}
示例8: __destruct
/**
* Class destructor
*/
public function __destruct()
{
if (self::$_numberOfFilesAddedToCache > 0) {
if (self::isApcUsed()) {
if (PHP_SAPI != 'cli') {
apc_store(self::getCacheKey(), self::$_cache, 0);
}
} elseif (is_dir_writeable(dirname(self::getCacheFilePath()))) {
$fileContent = serialize(self::$_cache);
$tmpFile = tempnam(sys_get_temp_dir(), 'aoe_classpathcache');
if (file_put_contents($tmpFile, $fileContent)) {
if (@rename($tmpFile, self::getCacheFilePath())) {
@chmod(self::getCacheFilePath(), 0664);
} else {
@unlink($tmpFile);
}
}
}
}
}
示例9: _verifyMinification
protected function _verifyMinification()
{
$stepOk = true;
try {
$varPath = Mage::getConfig()->getVarDir('minifycache');
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'skin/frontend/default' . '/default/css/print.css';
$client = new Zend_Http_Client($url);
/* HHVM fix for "Invalid chunk size" */
if ($this->_is_hhvm()) {
$client->setConfig(array('httpversion' => Zend_Http_Client::HTTP_0));
}
/* eof fix */
$response = $client->request();
$originalLength = strlen($response->getRawBody());
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'lib/minify/m.php?f=/skin/frontend/default' . '/default/css/print.css';
$client->setUri($url);
$response = $client->request();
$minifiedLength = strlen($response->getRawBody());
if ($minifiedLength >= $originalLength) {
$this->messages[] = 'Verify Minification ERROR: minification does not work (Step 3)';
$this->errorOccurred = true;
$stepOk = false;
}
if (!is_dir($varPath)) {
$this->messages[] = 'Verify Minification ERROR: "' . $varPath . '" does not exist (Step 3)';
$this->errorOccurred = true;
$stepOk = false;
}
if (!is_dir_writeable($varPath)) {
$this->messages[] = 'Verify Minification ERROR: "' . $varPath . '" is not writeable (Step 3)';
$this->errorOccurred = true;
$stepOk = false;
}
clearstatcache();
if ($handle = opendir($varPath)) {
$filesOK = false;
while (false !== ($entry = readdir($handle))) {
if (strpos($entry, 'minify_') !== false) {
$filesOK = true;
break;
}
}
closedir($handle);
if (!$filesOK) {
$this->messages[] = 'Verify Minification ERROR: there are no files starting with "minify_" in "' . $varPath . '" (Step 3)';
$this->errorOccurred = true;
$stepOk = false;
}
} else {
$this->messages[] = 'Verify Minification ERROR: can\'t open "' . $varPath . '" for reading (Step 3)';
$this->errorOccurred = true;
$stepOk = false;
}
} catch (Exception $e) {
$this->errorOccurred = true;
$stepOk = false;
$this->messages[] = $e->getMessage();
}
if ($stepOk) {
$this->messages[] = 'Step 3 - OK';
}
}
示例10: customerSaveAfter
public function customerSaveAfter($observer)
{
$customer = $observer->getCustomer();
$customerId = $customer->getId();
$dir = Mage::getBaseDir('media') . DS . 'webpos';
$customer_updatedfile = $dir . DS . 'customer_updated.txt';
if (!is_dir_writeable($dir)) {
$file = new Varien_Io_File();
$file->checkAndCreateFolder($dir);
}
$date = getdate();
$updated_time = $date[0];
$fileContent = file_get_contents($customer_updatedfile);
$fileContent = Zend_Json::decode($fileContent);
$fileContent[$customerId] = $updated_time;
$fileContent = Zend_Json::encode($fileContent);
file_put_contents($customer_updatedfile, $fileContent);
}
示例11: getUnWritableDirectories
public function getUnWritableDirectories()
{
$itemsToCheck = $this->getFoldersAndFiles();
$unWritableDirs = array();
foreach ($itemsToCheck as $item) {
$item = Mage::getBaseDir() . '/' . $item;
$items = glob($item);
if (preg_match('/\\*$/', $item)) {
$item = preg_replace('/\\*$/', '', $item);
$items = array_merge($items, $this->getDirectories($item));
}
foreach ($items as $path) {
if (is_file($path)) {
$path = explode('/', $path);
array_pop($path);
$path = implode('/', $path);
}
$path = rtrim($path, '/');
!is_dir_writeable($path) && ($unWritableDirs[] = $path);
}
}
return array_values(array_unique($unWritableDirs));
}
示例12: touch
<a href="#" class="floatright close-message"> <i class="fa fa-close"></i></a>
</div>
<?php
$config_file = 'log/log.log';
touch($config_file);
chmod($config_file, 0644);
$config_file_handle = fopen($config_file, 'a') or die('Cannot open file: ' . $config_file);
$config_data = '' . date(now) . ' | Base URL Path is not set' . PHP_EOL . '';
fwrite($config_file_handle, $config_data);
}
?>
<!-- Check if config set permissions -->
<?php
clearstatcache();
$configPath = '' . $BaseUrl . 'config/app/config.php';
$setError = is_dir($configPath) && !is_dir_writeable($configPath) || !is_writable($configPath) || file_exists($configPath) && !is_writable($configPath) && !is_readable($configPath);
if ($setError) {
} else {
?>
<div class="alert alert-danger message-item animated bounce m-t-10 " role="alert">
<strong><i class="fa fa-exclamation-triangle"></i> </strong> <?php
echo $configPath;
?>
is writable. Please CHMOD to 644 for security.
<a href="#" class="floatright close-message"> <i class="fa fa-close"></i></a>
</div>
<?php
}
?>
示例13: _verifyMinification
protected function _verifyMinification()
{
$stepOk = true;
try {
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'skin/frontend/default' . '/default/css/print.css';
$client = new Zend_Http_Client($url);
$response = $client->request();
$originalLength = $response->getHeader('Content-Length');
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'lib/minify/m.php?f=/skin/frontend/default' . '/default/css/print.css';
$client->setUri($url);
$response = $client->request();
$minifiedLength = $response->getHeader('Content-Length');
if ($minifiedLength >= $originalLength) {
$this->messages[] = 'Verify Minification ERROR: minification does not work (Step 3)';
$this->errorOccurred = true;
$stepOk = false;
}
$varPath = Mage::getBaseDir() . DS . 'var' . DS . 'minifycache';
if (!is_dir($varPath)) {
$this->messages[] = 'Verify Minification ERROR: "' . $varPath . '" does not exist (Step 3)';
$this->errorOccurred = true;
$stepOk = false;
}
if (!is_dir_writeable($varPath)) {
$this->messages[] = 'Verify Minification ERROR: "' . $varPath . '" is not writeable (Step 3)';
$this->errorOccurred = true;
$stepOk = false;
}
if ($handle = opendir($varPath)) {
$filesOK = false;
while (false !== ($entry = readdir($handle))) {
if (strpos($entry, 'minify_') !== false) {
$filesOK = true;
break;
}
}
closedir($handle);
if (!$filesOK) {
$this->messages[] = 'Verify Minification ERROR: there are no files starting with "minify_" in "' . $varPath . '" (Step 3)';
$this->errorOccurred = true;
$stepOk = false;
}
} else {
$this->messages[] = 'Verify Minification ERROR: can\'t open "' . $varPath . '" for reading (Step 3)';
$this->errorOccurred = true;
$stepOk = false;
}
} catch (Exception $e) {
$this->errorOccurred = true;
$stepOk = false;
$this->messages[] = $e->getMessage();
}
if ($stepOk) {
$this->messages[] = 'Step 3 - OK';
}
}
示例14: createDirIfNotExists
public function createDirIfNotExists($dir)
{
if (!empty($this->_dirExists[$dir])) {
return true;
}
if (file_exists($dir)) {
if (!is_dir($dir)) {
return false;
}
if (!is_dir_writeable($dir)) {
return false;
}
} else {
$oldUmask = umask(0);
if (!@mkdir($dir, 0777, true)) {
return false;
}
umask($oldUmask);
}
$this->_dirExists[$dir] = true;
return true;
}
示例15: getUnWritableDirectories
public function getUnWritableDirectories()
{
$directoriesForCheck = array();
foreach ($this->getFoldersAndFiles() as $item) {
$fullDirPath = Mage::getBaseDir() . DS . $item;
if (preg_match('/\\*$/', $item)) {
$fullDirPath = preg_replace('/\\*$/', '', $fullDirPath);
$directoriesForCheck = array_merge($directoriesForCheck, $this->getDirectories($fullDirPath));
}
$directoriesForCheck[] = dirname($fullDirPath);
is_dir($fullDirPath) && ($directoriesForCheck[] = rtrim($fullDirPath, '/\\'));
}
$directoriesForCheck = array_unique($directoriesForCheck);
$unWritableDirs = array();
foreach ($directoriesForCheck as $directory) {
!is_dir_writeable($directory) && ($unWritableDirs[] = $directory);
}
return $unWritableDirs;
}