当前位置: 首页>>代码示例>>PHP>>正文


PHP IsWritable函数代码示例

本文整理汇总了PHP中IsWritable函数的典型用法代码示例。如果您正苦于以下问题:PHP IsWritable函数的具体用法?PHP IsWritable怎么用?PHP IsWritable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了IsWritable函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isRemovable

 /**
  * Is the application/plugin/theme removable?
  *
  * @param string $Type self::TYPE_APPLICATION or self::TYPE_PLUGIN or self::TYPE_THEME
  * @param string $Name
  * @return boolean
  */
 public static function isRemovable($Type, $Name)
 {
     switch ($Type) {
         case self::TYPE_APPLICATION:
             $ApplicationManager = Gdn::Factory('ApplicationManager');
             if ($IsRemovable = !array_key_exists($Name, $ApplicationManager->EnabledApplications())) {
                 $ApplicationInfo = arrayValue($Name, $ApplicationManager->AvailableApplications(), array());
                 $ApplicationFolder = arrayValue('Folder', $ApplicationInfo, '');
                 $IsRemovable = IsWritable(PATH_APPLICATIONS . DS . $ApplicationFolder);
             }
             break;
         case self::TYPE_PLUGIN:
             if ($IsRemovable = !array_key_exists($Name, Gdn::pluginManager()->EnabledPlugins())) {
                 $PluginInfo = arrayValue($Name, Gdn::pluginManager()->AvailablePlugins(), false);
                 $PluginFolder = arrayValue('Folder', $PluginInfo, false);
                 $IsRemovable = IsWritable(PATH_PLUGINS . DS . $PluginFolder);
             }
             break;
         case self::TYPE_THEME:
             // TODO
             $IsRemovable = false;
             break;
     }
     return $IsRemovable;
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:32,代码来源:class.settingsmodule.php

示例2: CanUpload

	public static function CanUpload($UploadPath=NULL) {
		if (is_null($UploadPath))
			$UploadPath = PATH_LOCAL_UPLOADS;

		if (ini_get('file_uploads') != 1)
			return FALSE;

		if (!is_dir($UploadPath))
			@mkdir($UploadPath);
		if (!is_dir($UploadPath))
			return FALSE;

      if (!IsWritable($UploadPath) || !is_readable($UploadPath)) 
			return FALSE;

		return TRUE;
	}
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:17,代码来源:class.upload.php

示例3: IsWritable

 /**
  * PHP's native is_writable() function fails to correctly determine write
  * capabilities on some systems (Windows), and in our tests it returned TRUE
  * despite not being able to create subfolders within the folder being
  * checked. Our version truly verifies permissions by performing file-write
  * tests.
  */
 function IsWritable($Path)
 {
     if ($Path[strlen($Path) - 1] == DS) {
         // Recursively return a temporary file path
         return IsWritable($Path . uniqid(mt_rand()) . '.tmp');
     } elseif (is_dir($Path)) {
         return IsWritable($Path . '/' . uniqid(mt_rand()) . '.tmp');
     }
     // Check tmp file for read/write capabilities
     $KeepPath = file_exists($Path);
     $File = @fopen($Path, 'a');
     if ($File === FALSE) {
         return FALSE;
     }
     fclose($File);
     if (!$KeepPath) {
         unlink($Path);
     }
     return TRUE;
 }
开发者ID:remobjects,项目名称:Garden,代码行数:27,代码来源:functions.general.php

示例4: _CheckPrerequisites

 /**
  * Check minimum requirements for Garden.
  *
  * @since 2.0.0
  * @access private
  * @return bool Whether platform passes requirement check.
  */
 private function _CheckPrerequisites()
 {
     // Make sure we are running at least PHP 5.1
     if (version_compare(phpversion(), ENVIRONMENT_PHP_VERSION) < 0) {
         $this->Form->AddError(sprintf(T('You are running PHP version %1$s. Vanilla requires PHP %2$s or greater. You must upgrade PHP before you can continue.'), phpversion(), ENVIRONMENT_PHP_VERSION));
     }
     // Make sure PDO is available
     if (!class_exists('PDO')) {
         $this->Form->AddError(T('You must have the PDO module enabled in PHP in order for Vanilla to connect to your database.'));
     }
     if (!defined('PDO::MYSQL_ATTR_USE_BUFFERED_QUERY')) {
         $this->Form->AddError(T('You must have the MySQL driver for PDO enabled in order for Vanilla to connect to your database.'));
     }
     // Make sure that the correct filesystem permissions are in place
     $PermissionProblem = FALSE;
     // Make sure the appropriate folders are writeable.
     $ProblemDirectories = array();
     if (!is_readable(PATH_LOCAL_CONF) || !IsWritable(PATH_LOCAL_CONF)) {
         $ProblemDirectories[] = PATH_LOCAL_CONF;
     }
     if (!is_readable(PATH_LOCAL_UPLOADS) || !IsWritable(PATH_LOCAL_UPLOADS)) {
         $ProblemDirectories[] = PATH_LOCAL_UPLOADS;
     }
     if (!is_readable(PATH_LOCAL_CACHE) || !IsWritable(PATH_LOCAL_CACHE)) {
         $ProblemDirectories[] = PATH_LOCAL_CACHE;
     }
     if (count($ProblemDirectories) > 0) {
         $PermissionProblem = TRUE;
         $PermissionError = T('Some folders don\'t have correct permissions.', '<p>Some of your folders do not have the correct permissions.</p><p>Using your ftp client, or via command line, make sure that the following permissions are set for your vanilla installation:</p>');
         $PermissionHelp = '<pre>chmod -R 777 ' . implode("\nchmod -R 777 ", $ProblemDirectories) . '</pre>';
         $this->Form->AddError($PermissionError . $PermissionHelp);
     }
     // Make sure the config folder is writeable
     if (!$PermissionProblem) {
         $ConfigFile = PATH_LOCAL_CONF . DS . 'config.php';
         if (!file_exists($ConfigFile)) {
             file_put_contents($ConfigFile, '');
         }
         // Make sure the config file is writeable
         if (!is_readable($ConfigFile) || !IsWritable($ConfigFile)) {
             $this->Form->AddError(sprintf(T('Your configuration file does not have the correct permissions. PHP needs to be able to read and write to this file: <code>%s</code>'), $ConfigFile));
             $PermissionProblem = TRUE;
         }
     }
     // Make sure the cache folder is writeable
     if (!$PermissionProblem) {
         if (!file_exists(PATH_LOCAL_CACHE . DS . 'Smarty')) {
             mkdir(PATH_LOCAL_CACHE . DS . 'Smarty');
         }
         if (!file_exists(PATH_LOCAL_CACHE . DS . 'Smarty' . DS . 'cache')) {
             mkdir(PATH_LOCAL_CACHE . DS . 'Smarty' . DS . 'cache');
         }
         if (!file_exists(PATH_LOCAL_CACHE . DS . 'Smarty' . DS . 'compile')) {
             mkdir(PATH_LOCAL_CACHE . DS . 'Smarty' . DS . 'compile');
         }
     }
     return $this->Form->ErrorCount() == 0 ? TRUE : FALSE;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:65,代码来源:class.setupcontroller.php

示例5: IsWritable

 function IsWritable($pathfile)
 {
     $isDir = substr($pathfile, -1) == '/' ? true : false;
     if ($isDir) {
         if (is_dir($pathfile)) {
             mt_srand((double) microtime() * 1000000);
             $pathfile = $pathfile . 'dede_' . uniqid(mt_rand()) . '.tmp';
         } elseif (@mkdir($pathfile)) {
             return IsWritable($pathfile);
         } else {
             return false;
         }
     }
     @chmod($pathfile, 0777);
     $fp = @fopen($pathfile, 'ab');
     if ($fp === false) {
         return false;
     }
     fclose($fp);
     $isDir && @unlink($pathfile);
     return true;
 }
开发者ID:hensonvip,项目名称:ymroad,代码行数:22,代码来源:index_testenv.php

示例6: CheckFilesystem

function CheckFilesystem()
{
    ShowCheck('{docroot}/tmp writable', IsWritable('tmp'));
    ShowCheck('{docroot}/dat writable', IsWritable('dat'));
    ShowCheck('{docroot}/results writable', IsWritable('results'));
    ShowCheck('{docroot}/work/jobs writable', IsWritable('work/jobs'));
    ShowCheck('{docroot}/logs writable', IsWritable('logs'));
    if ('Linux' == PHP_OS) {
        ShowCheck('{docroot}/tmp on tmpfs', IsWPTTmpOnTmpfs(), false);
    }
}
开发者ID:lucasRolff,项目名称:webpagetest,代码行数:11,代码来源:index.php

示例7: _CheckPrerequisites

    private function _CheckPrerequisites()
    {
        // Make sure we are running at least PHP 5.1
        if (version_compare(phpversion(), ENVIRONMENT_PHP_VERSION) < 0) {
            $this->Form->AddError(sprintf(T('You are running PHP version %1$s. Vanilla requires PHP %2$s or greater. You must upgrade PHP before you can continue.'), phpversion(), ENVIRONMENT_PHP_VERSION));
        }
        // Make sure PDO is available
        if (!class_exists('PDO')) {
            $this->Form->AddError(T('You must have the PDO module enabled in PHP in order for Vanilla to connect to your database.'));
        }
        if (!defined('PDO::MYSQL_ATTR_USE_BUFFERED_QUERY')) {
            $this->Form->AddError(T('You must have the MySQL driver for PDO enabled in order for Vanilla to connect to your database.'));
        }
        // Make sure that the correct filesystem permissions are in place
        $PermissionProblem = FALSE;
        $PermissionHelp = ' <p>Using your ftp client, or via command line, make sure that the following permissions are set for your vanilla installation:</p>
<pre>chmod -R 777 ' . CombinePaths(array(PATH_ROOT, 'conf')) . '
chmod -R 777 ' . CombinePaths(array(PATH_ROOT, 'cache')) . '
chmod -R 777 ' . CombinePaths(array(PATH_ROOT, 'uploads')) . '</pre>';
        // Make sure the config folder is writeable
        if (!is_readable(PATH_CONF) || !IsWritable(PATH_CONF)) {
            $this->Form->AddError(T('Your configuration folder does not have the correct permissions. PHP needs to be able to read and write to this folder.'));
            $PermissionProblem = TRUE;
        } else {
            $ConfigFile = PATH_CONF . DS . 'config.php';
            if (!file_exists($ConfigFile)) {
                file_put_contents($ConfigFile, '');
            }
            // Make sure the config file is writeable
            if (!is_readable($ConfigFile) || !IsWritable($ConfigFile)) {
                $this->Form->AddError(sprintf(T('Your configuration file does not have the correct permissions. PHP needs to be able to read and write to this file: <code>%s</code>'), $ConfigFile));
                $PermissionProblem = TRUE;
            }
        }
        $UploadsFolder = PATH_ROOT . DS . 'uploads';
        if (!is_readable($UploadsFolder) || !IsWritable($UploadsFolder)) {
            $this->Form->AddError(sprintf(T('Your uploads folder does not have the correct permissions. PHP needs to be able to read and write to this folder: <code>%s</code>'), $UploadsFolder));
            $PermissionProblem = TRUE;
        }
        // Make sure the cache folder is writeable
        if (!is_readable(PATH_CACHE) || !IsWritable(PATH_CACHE)) {
            $this->Form->AddError(sprintf(T('Your cache folder does not have the correct permissions. PHP needs to be able to read and write to this folder and all the files within: <code>%s</code>'), PATH_CACHE));
            $PermissionProblem = TRUE;
        } else {
            if (!file_exists(PATH_CACHE . DS . 'HtmlPurifier')) {
                mkdir(PATH_CACHE . DS . 'HtmlPurifier');
            }
            if (!file_exists(PATH_CACHE . DS . 'Smarty')) {
                mkdir(PATH_CACHE . DS . 'Smarty');
            }
            if (!file_exists(PATH_CACHE . DS . 'Smarty' . DS . 'cache')) {
                mkdir(PATH_CACHE . DS . 'Smarty' . DS . 'cache');
            }
            if (!file_exists(PATH_CACHE . DS . 'Smarty' . DS . 'compile')) {
                mkdir(PATH_CACHE . DS . 'Smarty' . DS . 'compile');
            }
        }
        if ($PermissionProblem) {
            $this->Form->AddError($PermissionHelp);
        }
        return $this->Form->ErrorCount() == 0 ? TRUE : FALSE;
    }
开发者ID:sipp11,项目名称:Garden,代码行数:62,代码来源:class.setupcontroller.php

示例8: clearstatcache

        // Wenn Verzeichnisse erstellt wurden - direkt weitermachen
        if ($iw[0] && $iw[1] && $iw[2] && $iw[3]) {
            echo '<script language="javascript">';
            echo 'self.location.href=\'install.php?language=' . $language . '&phase=4&connstr=' . $connstr . '\'';
            echo '</script>';
        }
        echo '</table>';
        break;
    case 10:
        //safe_mode FTP
        $config['ftp_useSSL'] = 0;
        clearstatcache();
        $iw[0] = IsWritable("work");
        $iw[1] = IsWritable("work/config");
        $iw[2] = IsWritable("work/log");
        $iw[3] = IsWritable("work/backup");
        if (!isset($install_ftp_port) || $install_ftp_port < 1) {
            $install_ftp_port = 21;
        }
        echo '<h6>' . $lang['L_FTPMODE'] . '</h6>';
        echo '<p align="left" style="padding-left:100px; padding-right:100px;">' . $lang['L_SAFEMODEDESC'] . '</p>';
        echo '<form action="install.php?language=' . $language . '&phase=10" method="post"><input type="hidden" name="connstr" value="' . $connstr . '">
		<table width="80%"><tr><td width="50%" valign="top"><table>';
        echo '<tr><td class="hd2" colspan="2">' . $lang['L_IDOMANUAL'] . '</td></tr>';
        echo '<tr><td colspan="2">' . $lang['L_DOFROM'] . '<br><div class="small">' . Realpfad('./') . '</div></td></tr>';
        echo '<tr><td><strong>work</strong></td><td>' . ($iw[0] ? $img_ok : $img_failed) . '</td></tr>';
        echo '<tr><td><strong>work/config</strong></td><td>' . ($iw[1] ? $img_ok : $img_failed) . '</td></tr>';
        echo '<tr><td><strong>work/log</strong></td><td>' . ($iw[2] ? $img_ok : $img_failed) . '</td></tr>';
        echo '<tr><td><strong>work/backup</strong></td><td>' . ($iw[3] ? $img_ok : $img_failed) . '</td></tr>';
        echo '<tr><td colspan="3" align="right"><input type="submit" name="dir_check" value=" ' . $lang['L_CHECK_DIRS'] . ' " class="Formbutton"></td></tr>';
        if ($iw[0] && $iw[1] && $iw[2] && $iw[3]) {
开发者ID:robmat,项目名称:samplebator,代码行数:31,代码来源:install.php

示例9: saveFile

 /**
  * Saves the specified file with the provided file contents.
  *
  * @param string $FileName The full path and name of the file to be saved.
  * @param string $FileContents The contents of the file being saved.
  */
 public static function saveFile($FileName, $FileContents, $Flags = VANILLA_FILE_PUT_FLAGS)
 {
     // Check that the folder exists and is writable
     $DirName = dirname($FileName);
     $FileBaseName = basename($FileName);
     if (!is_dir($DirName)) {
         throw new Exception(sprintf('Requested save operation [%1$s] could not be completed because target folder [%2$s] does not exist.', $FileBaseName, $DirName));
     }
     if (!IsWritable($DirName)) {
         throw new Exception(sprintf('Requested save operation [%1$s] could not be completed because target folder [%2$s] is not writable.', $FileBaseName, $DirName));
     }
     if (file_put_contents($FileName, $FileContents, $Flags) === false) {
         throw new Exception(sprintf('Requested save operation [%1$s] could not be completed!', $FileBaseName));
     }
     return true;
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:22,代码来源:class.filesystem.php

示例10: SaveFile

 /**
  * Saves the specified file with the provided file contents.
  *
  * @param string $FileName The full path and name of the file to be saved.
  * @param string $FileContents The contents of the file being saved.
  */
 public static function SaveFile($FileName, $FileContents, $Flags = LOCK_EX)
 {
     // Check that the folder exists and is writable
     $DirName = dirname($FileName);
     $FileBaseName = basename($FileName);
     if (!is_dir($DirName)) {
         throw new Exception(sprintf('Requested save operation [%1$s] could not be completed because target folder [%2$s] does not exist.', $FileBaseName, $DirName));
     }
     if (!IsWritable($DirName)) {
         throw new Exception(sprintf('Requested save operation [%1$s] could not be completed because target folder [%2$s] is not writable.', $FileBaseName, $DirName));
     }
     file_put_contents($FileName, $FileContents, $Flags);
     return TRUE;
 }
开发者ID:kennyma,项目名称:Garden,代码行数:20,代码来源:class.filesystem.php

示例11: clearstatcache

        if ($iw[0] && $iw[1] && $iw[2] && $iw[3] && $iw[4]) {
            echo '<script language="javascript">';
            echo 'self.location.href=\'install.php?language=' . $language . '&phase=4&connstr=' . $connstr . '\'';
            echo '</script>';
        }
        echo '</table>';
        break;
    case 10:
        //safe_mode FTP
        $config['ftp_useSSL'] = 0;
        clearstatcache();
        $iw[0] = IsWritable("work");
        $iw[1] = IsWritable("work/config");
        $iw[2] = IsWritable("work/log");
        $iw[3] = IsWritable("work/backup");
        $iw[4] = IsWritable("work/structure");
        if (!isset($install_ftp_port) || $install_ftp_port < 1) {
            $install_ftp_port = 21;
        }
        echo '<h6>' . $lang['ftpmode'] . '</h6>';
        echo '<p align="left" style="padding-left:100px; padding-right:100px;">' . $lang['safemodedesc'] . '</p>';
        echo '<form action="install.php?language=' . $language . '&phase=10" method="post"><input type="hidden" name="connstr" value="' . $connstr . '">
		<table width="80%"><tr><td width="50%" valign="top"><table>';
        echo '<tr><td class="hd2" colspan="2">' . $lang['idomanual'] . '</td></tr>';
        echo '<tr><td colspan="2">' . $lang['dofrom'] . '<br><div class="small">' . Realpfad('./') . '</div></td></tr>';
        echo '<tr><td><strong>work</strong></td><td>' . ($iw[0] ? $img_ok : $img_failed) . '</td></tr>';
        echo '<tr><td><strong>work/config</strong></td><td>' . ($iw[1] ? $img_ok : $img_failed) . '</td></tr>';
        echo '<tr><td><strong>work/log</strong></td><td>' . ($iw[2] ? $img_ok : $img_failed) . '</td></tr>';
        echo '<tr><td><strong>work/backup</strong></td><td>' . ($iw[3] ? $img_ok : $img_failed) . '</td></tr>';
        echo '<tr><td><strong>work/structure</strong></td><td>' . ($iw[4] ? $img_ok : $img_failed) . '</td></tr>';
        echo '<tr><td colspan="3" align="right"><input type="submit" name="dir_check" value=" ' . $lang['check'] . ' " class="Formbutton"></td></tr>';
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:31,代码来源:install.php

示例12: SetupCron

 public function SetupCron()
 {
     $CronFolder = PATH_PLUGINS . DS . 'SphinxSearchLite' . DS . 'cron';
     $InstallWizard = new SphinxSearchInstallWizard(null, null);
     //bad practice @todo fix this
     $Search = array('{path_to_indexer}' => $this->Settings['Install']->IndexerPath, '{path_to_php}' => $InstallWizard->RunTypeCommand('', 'php'), '{path_to_config}' => $this->Settings['Install']->ConfPath, '{path_to_cron}' => $CronFolder, '{DS}' => DS, '{index_prefix}' => $this->Settings['Install']->Prefix);
     $MainTemplate = file_get_contents(PATH_PLUGINS . DS . 'SphinxSearchLite' . DS . 'assests' . DS . 'cron.reindex.main.php.tpl');
     $DeltaTemplate = file_get_contents(PATH_PLUGINS . DS . 'SphinxSearchLite' . DS . 'assests' . DS . 'cron.reindex.delta.php.tpl');
     $StatsTemplate = file_get_contents(PATH_PLUGINS . DS . 'SphinxSearchLite' . DS . 'assests' . DS . 'cron.reindex.stats.php.tpl');
     $ReWritedMain = str_replace(array_keys($Search), $Search, $MainTemplate);
     $ReWritedDelta = str_replace(array_keys($Search), $Search, $DeltaTemplate);
     $ReWritedStats = str_replace(array_keys($Search), $Search, $StatsTemplate);
     //check if cron folder is good to go
     if (!file_exists($CronFolder)) {
         parent::Update(SS_FATAL_ERROR, FALSE, FALSE, "Cron folder not found at: {$CronFolder}");
     }
     if (!IsWritable($CronFolder)) {
         parent::Update(SS_FATAL_ERROR, FALSE, FALSE, "This location is not writable: {$CronFolder}");
     }
     try {
         if (!file_put_contents($CronFolder . DS . 'cron.reindex.main.php', $ReWritedMain)) {
             parent::Update(SS_FATAL_ERROR, FALSE, FALSE, "(Permissions) Error writing cron file: {$MainTemplate}");
         }
         if (!file_put_contents($CronFolder . DS . 'cron.reindex.delta.php', $ReWritedDelta)) {
             parent::Update(SS_FATAL_ERROR, FALSE, FALSE, "(Permissions) Error writing cron file: {$DeltaTemplate}");
         }
         if (!file_put_contents($CronFolder . DS . 'cron.reindex.stats.php', $ReWritedStats)) {
             parent::Update(SS_FATAL_ERROR, FALSE, FALSE, "(Permissions) Error writing cron file: {$StatsTemplate}");
         }
     } catch (Exception $e) {
         //get just the exception error
         $ErrorLen = strpos($e, 'Stack trace:', 0);
         $Error = substr($e, 0, $ErrorLen);
         parent::Update(SS_FATAL_ERROR, FALSE, FALSE, $Error);
     }
 }
开发者ID:Nordic-T,项目名称:vanilla-plugins,代码行数:36,代码来源:class.sphinxsearchinstall.php


注:本文中的IsWritable函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。