/** * Compiles a template and writes it to a cache file, which is used for inclusion. * * @param string $file The full path to the template that will be compiled. * @param array $options Options for compilation include: * - `path`: Path where the compiled template should be written. * - `fallback`: Boolean indicating that if the compilation failed for some * reason (e.g. `path` is not writable), that the compiled template * should still be returned and no exception be thrown. * @return string The compiled template. */ public static function template($file, array $options = array()) { $cachePath = Libraries::get(true, 'resources') . '/tmp/cache/templates'; $defaults = array('path' => $cachePath, 'fallback' => false); $options += $defaults; $stats = stat($file); $oname = basename(dirname($file)) . '_' . basename($file, '.php'); $oname .= '_' . ($stats['ino'] ?: hash('md5', $file)); $template = "template_{$oname}_{$stats['mtime']}_{$stats['size']}.php"; $template = "{$options['path']}/{$template}"; if (file_exists($template)) { return $template; } $compiled = static::compile(file_get_contents($file)); if (is_writable($cachePath) && file_put_contents($template, $compiled) !== false) { foreach (glob("{$options['path']}/template_{$oname}_*.php", GLOB_NOSORT) as $expired) { if ($expired !== $template) { unlink($expired); } } return $template; } if ($options['fallback']) { return $file; } throw new TemplateException("Could not write compiled template `{$template}` to cache."); }
/** * {@inheritdoc} */ public function run() { if (is_null($this->dst) || "" === $this->dst) { return Result::error($this, 'You must specify a destination file with to() method.'); } if (!$this->checkResources($this->files, 'file')) { return Result::error($this, 'Source files are missing!'); } if (file_exists($this->dst) && !is_writable($this->dst)) { return Result::error($this, 'Destination already exists and cannot be overwritten.'); } $dump = ''; foreach ($this->files as $path) { foreach (glob($path) as $file) { $dump .= file_get_contents($file) . "\n"; } } $this->printTaskInfo('Writing {destination}', ['destination' => $this->dst]); $dst = $this->dst . '.part'; $write_result = file_put_contents($dst, $dump); if (false === $write_result) { @unlink($dst); return Result::error($this, 'File write failed.'); } // Cannot be cross-volume; should always succeed. @rename($dst, $this->dst); return Result::success($this); }
/** * Tests that the storage location is a directory and is writable. */ public function __construct($filename) { // Get the directory name $directory = str_replace('\\', '/', realpath(pathinfo($filename, PATHINFO_DIRNAME))) . '/'; // Set the filename from the real directory path $filename = $directory . basename($filename); // Make sure the cache directory is writable if (!is_dir($directory) or !is_writable($directory)) { throw new KoException('Cache: Directory :name is unwritable.', array(':name' => $directory)); } // Make sure the cache database is writable if (is_file($filename) and !is_writable($filename)) { throw new KoException('Cache: File :name is unwritable.', array(':name' => $filename)); } // Open up an instance of the database $this->db = new SQLiteDatabase($filename, '0666', $error); // Throw an exception if there's an error if (!empty($error)) { throw new KoException('Cache: Driver error - ' . sqlite_error_string($error)); } $query = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'caches'"; $tables = $this->db->query($query, SQLITE_BOTH, $error); // Throw an exception if there's an error if (!empty($error)) { throw new KoException('Cache: Driver error - ' . sqlite_error_string($error)); } if ($tables->numRows() == 0) { // Issue a CREATE TABLE command $this->db->unbufferedQuery('CREATE TABLE caches(id VARCHAR(127) PRIMARY KEY, expiration INTEGER, cache TEXT);'); } }
/** * {@inheritDoc} */ public function initialize() { if (Filesystem::isLocalPath($this->url)) { $this->repoDir = $this->url; } else { $cacheDir = $this->config->get('cache-vcs-dir'); $this->repoDir = $cacheDir . '/' . preg_replace('{[^a-z0-9]}i', '-', $this->url) . '/'; $fs = new Filesystem(); $fs->ensureDirectoryExists($cacheDir); if (!is_writable(dirname($this->repoDir))) { throw new \RuntimeException('Can not clone ' . $this->url . ' to access package information. The "' . $cacheDir . '" directory is not writable by the current user.'); } // update the repo if it is a valid hg repository if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) { if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) { $this->io->write('<error>Failed to update ' . $this->url . ', package information from this repository may be outdated (' . $this->process->getErrorOutput() . ')</error>'); } } else { // clean up directory and do a fresh clone into it $fs->removeDirectory($this->repoDir); if (0 !== $this->process->execute(sprintf('hg clone --noupdate %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoDir)), $output, $cacheDir)) { $output = $this->process->getErrorOutput(); if (0 !== $this->process->execute('hg --version', $ignoredOutput)) { throw new \RuntimeException('Failed to clone ' . $this->url . ', hg was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput()); } throw new \RuntimeException('Failed to clone ' . $this->url . ', could not read packages from it' . "\n\n" . $output); } } } $this->getTags(); $this->getBranches(); }
public static function prepare_dir($prefix) { $config = midcom_baseclasses_components_configuration::get('midcom.helper.filesync', 'config'); $path = $config->get('filesync_path'); if (!file_exists($path)) { $parent = dirname($path); if (!is_writable($parent)) { throw new midcom_error("Directory {$parent} is not writable"); } if (!mkdir($path)) { throw new midcom_error("Failed to create directory {$path}. Reason: " . $php_errormsg); } } if (substr($path, -1) != '/') { $path .= '/'; } $module_dir = "{$path}{$prefix}"; if (!file_exists($module_dir)) { if (!is_writable($path)) { throw new midcom_error("Directory {$path} is not writable"); } if (!mkdir($module_dir)) { throw new midcom_error("Failed to create directory {$module_dir}. Reason: " . $php_errormsg); } } return "{$module_dir}/"; }
/** * Initializes this logger. * * Available options: * * - file: The file path or a php wrapper to log messages * You can use any support php wrapper. To write logs to the Apache error log, use php://stderr * - format: The log line format (default to %time% %type% [%priority%] %message%%EOL%) * - time_format: The log time strftime format (default to %b %d %H:%M:%S) * - dir_mode: The mode to use when creating a directory (default to 0777) * - file_mode: The mode to use when creating a file (default to 0666) * * @param sfEventDispatcher $dispatcher A sfEventDispatcher instance * @param array $options An array of options. * * @return Boolean true, if initialization completes successfully, otherwise false. */ public function initialize(sfEventDispatcher $dispatcher, $options = array()) { if (!isset($options['file'])) { throw new sfConfigurationException('You must provide a "file" parameter for this logger.'); } if (isset($options['format'])) { $this->format = $options['format']; } if (isset($options['time_format'])) { $this->timeFormat = $options['time_format']; } if (isset($options['type'])) { $this->type = $options['type']; } $dir = dirname($options['file']); if (!is_dir($dir)) { mkdir($dir, isset($options['dir_mode']) ? $options['dir_mode'] : 0777, true); } $fileExists = file_exists($options['file']); if (!is_writable($dir) || $fileExists && !is_writable($options['file'])) { throw new sfFileException(sprintf('Unable to open the log file "%s" for writing.', $options['file'])); } $this->fp = fopen($options['file'], 'a'); if (!$fileExists) { chmod($options['file'], isset($options['file_mode']) ? $options['file_mode'] : 0666); } return parent::initialize($dispatcher, $options); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir'); $oldCacheDir = $realCacheDir . '_old'; $filesystem = $this->getContainer()->get('filesystem'); if (!is_writable($realCacheDir)) { throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir)); } if ($filesystem->exists($oldCacheDir)) { $filesystem->remove($oldCacheDir); } $kernel = $this->getContainer()->get('kernel'); $output->writeln(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true))); $this->getContainer()->get('cache_clearer')->clear($realCacheDir); if ($input->getOption('no-warmup')) { $filesystem->rename($realCacheDir, $oldCacheDir); } else { // the warmup cache dir name must have the same length than the real one // to avoid the many problems in serialized resources files $warmupDir = substr($realCacheDir, 0, -1) . '_'; if ($filesystem->exists($warmupDir)) { $filesystem->remove($warmupDir); } $this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers')); $filesystem->rename($realCacheDir, $oldCacheDir); if (defined('PHP_WINDOWS_VERSION_BUILD')) { sleep(1); // workaround for windows php rename bug } $filesystem->rename($warmupDir, $realCacheDir); } $filesystem->remove($oldCacheDir); }
/** * Creates extra folders. * * @return bool cache folder exists and is writeable */ function create_folders($version) { if (is_dir(STARRATING_XTRA_PATH)) { if (is_writable(STARRATING_XTRA_PATH)) { if (!is_dir(STARRATING_CACHE_PATH)) { mkdir(STARRATING_CACHE_PATH, 0755); } if (!is_dir(STARRATING_XTRA_PATH . "stars/")) { mkdir(STARRATING_XTRA_PATH . "stars/", 0755); } if (!is_dir(STARRATING_XTRA_PATH . "trends/")) { mkdir(STARRATING_XTRA_PATH . "trends/", 0755); } if (!is_dir(STARRATING_XTRA_PATH . "css/")) { mkdir(STARRATING_XTRA_PATH . "css/", 0755); } if (!file_exists(STARRATING_XTRA_PATH . "css/rating.css")) { copy(STARRATING_PATH . "css/rating.css", STARRATING_XTRA_PATH . "css/rating.css"); } } } else { $path = WP_CONTENT_DIR; if (is_writable($path)) { mkdir(STARRATING_XTRA_PATH, 0755); GDSRHelper::create_folders($version); } else { return false; } } return is_dir(STARRATING_CACHE_PATH) && is_writable(STARRATING_CACHE_PATH); }
public function folders() { global $mf_domain; $dir_list = ""; $dir_list2 = ""; wp_mkdir_p(MF_FILES_DIR); wp_mkdir_p(MF_CACHE_DIR); if (!is_dir(MF_CACHE_DIR)) { $dir_list2 .= "<li>" . MF_CACHE_DIR . "</li>"; } elseif (!is_writable(MF_CACHE_DIR)) { $dir_list .= "<li>" . MF_CACHE_DIR . "</li>"; } if (!is_dir(MF_FILES_DIR)) { $dir_list2 .= "<li>" . MF_FILES_DIR . "</li>"; } elseif (!is_writable(MF_FILES_DIR)) { $dir_list .= "<li>" . MF_FILES_DIR . "</li>"; } if ($dir_list2 != "") { echo "<div id='magic-fields-install-error-message' class='error'><p><strong>" . __('Magic Fields is not ready yet.', $mf_domain) . "</strong> " . __('must create the following folders (and must chmod 777):', $mf_domain) . "</p><ul>"; echo $dir_list2; echo "</ul></div>"; } if ($dir_list != "") { echo "<div id='magic-fields-install-error-message-2' class='error'><p><strong>" . __('Magic Fields is not ready yet.', $mf_domain) . "</strong> " . __('The following folders must be writable (usually chmod 777 is neccesary):', $mf_domain) . "</p><ul>"; echo $dir_list; echo "</ul></div>"; } }
/** * Constructor. * Requires a path to an existing and writable file. * * @param string $outputPath path to file to write schema changes to. */ public function __construct($outputPath) { if (!file_exists($outputPath) || !is_writable($outputPath)) { throw new RedBean_Exception_Security('Cannot write to file: ' . $outputPath); } $this->file = $outputPath; }
public function getStep2() { $this->layout->step = 2; $data['req']['php_version'] = PHP_VERSION_ID >= 50400; $data['req']['mcrypt'] = extension_loaded('mcrypt'); $data['req']['pdo'] = extension_loaded('pdo_mysql'); if (function_exists('apache_get_modules')) { $data['req']['rewrite'] = in_array('mod_rewrite', apache_get_modules()); } $dirs = array($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/storage/', $_SERVER['DOCUMENT_ROOT'] . '/apps/backend/storage/', $_SERVER['DOCUMENT_ROOT'] . '/upload/', $_SERVER['DOCUMENT_ROOT'] . '/install/', $_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/config/', $_SERVER['DOCUMENT_ROOT'] . '/apps/backend/config/'); foreach ($dirs as $path) { $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $item) { @chmod($item, 0777); } } $data['req']['wr_fr_storage'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/storage/'); $data['req']['wr_bk_storage'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/apps/backend/storage/'); $data['req']['wr_upload'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/upload/'); $data['req']['wr_install'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/install/'); $data['req']['wr_fr_db'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/config/'); $data['req']['wr_bk_db'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/apps/backend/config/'); $data['valid_step'] = true; foreach ($data['req'] as $valid) { $data['valid_step'] = $data['valid_step'] && $valid; } Session::put('step2', $data['valid_step']); $this->layout->content = View::make('install::step2', $data); return $this->layout; }
/** * Storing entity by ORM table * * @access public * @return boolean */ public function storeEntity($buffer = null) { try { // Data posted required, otherwise avoid write anything if (!$buffer) { throw new JMapException(JText::_('COM_JMAP_HTACCESS_NO_DATA'), 'error'); } $targetHtaccess = null; // Find htaccess file if (JFile::exists(JPATH_ROOT . '/.htaccess')) { $targetHtaccess = JPATH_ROOT . '/.htaccess'; } elseif (JFile::exists(JPATH_ROOT . '/htaccess.txt')) { // Fallback on txt dummy version $targetHtaccess = JPATH_ROOT . '/htaccess.txt'; $this->setState('htaccess_version', 'textual'); } else { throw new JMapException(JText::_('COM_JMAP_HTACCESS_NOTFOUND'), 'error'); } // If file permissions ko on rewrite updated contents if (!is_writable($targetHtaccess)) { @chmod($targetHtaccess, 0777); } if (@(!JFile::write($targetHtaccess, $buffer))) { throw new JMapException(JText::_('COM_JMAP_ERROR_WRITING_HTACCESS'), 'error'); } } catch (JMapException $e) { $this->setError($e); return false; } catch (Exception $e) { $jmapException = new JMapException($e->getMessage(), 'error'); $this->setError($jmapException); return false; } return true; }
function dowork() { $canIhaveAccess = 0; $canIhaveAccess = $canIhaveAccess + checklevel('admin'); if ($canIhaveAccess == 1) { if (is_writable('settings.php') == 0) { die("Error: settings.php is not writeable."); } if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } else { $action = "view"; } if ($action == "view") { $config = new pliggconfig(); if (isset($_REQUEST['page'])) { $config->var_page = $_REQUEST['page']; $config->showpage(); } } if ($action == "save") { $config = new pliggconfig(); $config->var_id = substr($_REQUEST['var_id'], 6, 10); $config->var_value = $_REQUEST['var_value']; $config->store(); } } }
public static function save_future_list($list, $save_type = FILE_APPEND) { $file = self::get_parent_dir() . self::$future_list_file; $data_to_write = ''; $errors = array(); if (!file_exists($file)) { $f = fopen($file, 'w'); if ($f === false) { $errors['error'] = "Cannot crete future list file <code>" . $file . "</code>"; } else { fclose($f); } } foreach ($list as $el) { $data_to_write .= trim($el['name']) . " ::: " . $el['link'] . "\n"; } if (is_writable($file)) { if (file_put_contents($file, $data_to_write, $save_type) == false) { $errors['error'] = 'Cannot write to file <code>' . $file . "</code>"; } } else { $errors['error'] = 'File is not writable <code>' . $file . "</code>"; } return $errors; }
function listDir($dir){ if(is_dir($dir)){ if ($dh = opendir($dir)) { while (($file= readdir($dh)) !== false){ if((is_dir($dir."/".$file)) && $file!="." && $file!="..") { if(is_writable($dir."/".$file)&&is_readable($dir."/".$file)) { echo "<b><font color='red'>文件名:</font></b>".$dir.$file."<font color='red'> 可写</font><font color='Blue'> 可读</font>"."<br><hr>"; }else{ if(is_writable($dir."/".$file)) { echo "<b><font color='red'>文件名:</font></b>".$dir.$file."<font color='red'> 可写</font>"."<br><hr>"; }else { echo "<b><font color='red'>文件名:</font></b>".$dir.$file."<font color='red'> 可读</font><font color='Blue'> 不可写</font>"."<br><hr>"; } } listDir($dir."/".$file."/"); } } } closedir($dh); } }
public function check() { if (phpversion() < '5.0.0') { return Response::json(FAIL, array('您的php版本过低,不能安装本软件,请升级到5.0.0或更高版本再安装,谢谢!')); } if (!extension_loaded('PDO')) { return Response::json(FAIL, array('请加载PHP的PDO模块,谢谢!')); } if (!function_exists('session_start')) { return Response::json(FAIL, array('请开启session,谢谢!')); } if (!is_writable(ROOT_PATH)) { return Response::json(FAIL, array('请保证代码目录有写权限,谢谢!')); } $config = (require CONFIG_PATH . 'mysql.php'); try { $mysql = new PDO('mysql:host=' . $config['master']['host'] . ';port=' . $config['master']['port'], $config['master']['user'], $config['master']['pwd']); } catch (Exception $e) { return Response::json(FAIL, array('请正确输入信息连接mysql,保证启动mysql,谢谢!')); } $mysql->exec('CREATE DATABASE ' . $config['master']['dbname']); $mysql = null; unset($config); return Response::json(SUCC, array('检测通过')); }
function is_really_writable($file) { // If we're on a Unix server with safe_mode off we call is_writable if (DIRECTORY_SEPARATOR == '/' AND @ini_get("safe_mode") == FALSE) { return is_writable($file); } // For windows servers and safe_mode "on" installations we'll actually // write a file then read it. Bah... if (is_dir($file)) { $file = rtrim($file, '/').'/'.md5(mt_rand(1,100).mt_rand(1,100)); if (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE) { return FALSE; } fclose($fp); @chmod($file, DIR_WRITE_MODE); @unlink($file); return TRUE; } elseif ( ! is_file($file) OR ($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE) { return FALSE; } fclose($fp); return TRUE; }
function isWritable($sFile, $sPrePath = '/../../') { clearstatcache(); $aPathInfo = pathinfo(__FILE__); $sFile = $aPathInfo['dirname'] . '/../../' . $sFile; return is_readable($sFile) && is_writable($sFile); }
/** * @see Console\Command\Command */ protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) { $dm = $this->getHelper('documentManager')->getDocumentManager(); $metadatas = $dm->getMetadataFactory()->getAllMetadata(); $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter')); // Process destination directory if (($destPath = $input->getArgument('dest-path')) === null) { $destPath = $dm->getConfiguration()->getProxyDir(); } if (!is_dir($destPath)) { mkdir($destPath, 0775, true); } $destPath = realpath($destPath); if (!file_exists($destPath)) { throw new \InvalidArgumentException(sprintf("Proxies destination directory '<info>%s</info>' does not exist.", $destPath)); } elseif (!is_writable($destPath)) { throw new \InvalidArgumentException(sprintf("Proxies destination directory '<info>%s</info>' does not have write permissions.", $destPath)); } if (count($metadatas)) { foreach ($metadatas as $metadata) { $output->write(sprintf('Processing document "<info>%s</info>"', $metadata->name) . PHP_EOL); } // Generating Proxies $dm->getProxyFactory()->generateProxyClasses($metadatas, $destPath); // Outputting information message $output->write(PHP_EOL . sprintf('Proxy classes generated to "<info>%s</INFO>"', $destPath) . PHP_EOL); } else { $output->write('No Metadata Classes to process.' . PHP_EOL); } }
function isWritable($path) { if (is_writable($path) || self::isOwner($path)) { return true; } return false; }
/** * Validate form values. */ function at_generator_validate_generator(&$form, &$form_state) { $build_info = $form_state->getBuildInfo(); $values = $form_state->getValues(); $theme = $build_info['args'][0]; // Validate Theme Generator. if (!empty($values['generate']['generate_machine_name']) && $theme == 'at_core') { $machine_name = $values['generate']['generate_machine_name']; $path = drupal_get_path('theme', 'at_core'); $target = $path . '/../../' . $machine_name; $subtheme_type = $values['generate']['generate_type']; $skin_base_theme = $values['generate']['generate_skin_base']; $clone_source = $values['generate']['generate_clone_source']; if ($subtheme_type == 'at_standard' || $subtheme_type == 'at_minimal' || $subtheme_type == 'at_skin') { $source = $path . '/../at_starterkits/' . $subtheme_type; } else if ($subtheme_type == 'at_clone') { $clone_source_theme = drupal_get_path('theme', $clone_source); $source = $clone_source_theme; } // Check if directories and files exist and are readable/writable etc. if (!file_exists($source) && !is_readable($source)) { $form_state->setErrorByName('', t('The Starterkit or base theme (if you are generating a Skin) can not be found or is not readable - check permissions or perhaps you moved things around?')); } if (!is_writable(dirname($target))) { $form_state->setErrorByName('', t('The target directory is not writable, please check permissions on the <code>/themes/</code> directory where Adaptivetheme is located.')); } } }
private static function addIndexFile($path) { if (file_exists($path) || !is_writable($path)) { return; } file_put_contents($path . 'index.php', '<?php header("location: ../index.php"); die;'); }
/** * Returns a stream resource for the current file being written/enqueued to * * @return resource */ private function getStream() { // If we have a valid stream, return it if (is_resource($this->statusStream)) { return $this->statusStream; } // If it's not a valid resource, we need to create one if (!is_dir($this->queueDir) || !is_writable($this->queueDir)) { throw new Exception('Unable to write to queueDir: ' . $this->queueDir); } // Construct stream file name, log and open $this->streamFile = $this->queueDir . '/' . self::QUEUE_FILE_ACTIVE; $this->log('Opening new active status stream: ' . $this->streamFile); $this->statusStream = fopen($this->streamFile, 'a'); // Append if present (crash recovery) // Ok? if (!is_resource($this->statusStream)) { throw new Exception('Unable to open stream file for writing: ' . $this->streamFile); } // If we don't have a last rotated time, it's effectively now if ($this->lastRotated == NULL) { $this->lastRotated = time(); } // Looking good, return the resource return $this->statusStream; }
public static function start(){ //PHP self::$params["safe_mode"] = (int) ini_get("safe_mode"); self::$params["safe_mode_gid"] = (int) ini_get("safe_mode_gid"); self::$params["upload_max_size"] = ini_get("upload_max_filesize"); self::$params["post_max_size"] = ini_get("post_max_size"); self::$params["memory_limit"] = ((ini_get("memory_limit")!="")?ini_get("memory_limit"):get_cfg_var("memory_limit")); self::$params["max_execution_time"] = ini_get("max_execution_time"); $uploadTmpDir = ini_get("upload_tmp_dir"); $uploadTmpDir = $uploadTmpDir ? $uploadTmpDir : realpath(sys_get_temp_dir()); self::$params["upload_tmp_dir"] = $uploadTmpDir; self::$params["upload_tmp_dir_writable"] = @is_writable($uploadTmpDir); self::$params["output_buffering"] = (int) !! ini_get('output_buffering'); //ZLIB self::$params["zlib"] = (int) function_exists('gzopen'); //For future or commercial versions self::$params["xml_parser_create"] = (int) function_exists("xml_parser_create"); //GD self::$params['gd'] = (int) (function_exists("gd_info") && function_exists("imagecopyresized") && function_exists("imagecopyresampled")) ; self::liveTests(); }
/** * @return Zend_Log */ public function init() { $bootstrap = $this->getBootstrap(); $bootstrap->bootstrap('Config'); $config = $bootstrap->getResource('Config'); if (!$config->log->errors && !$config->log->sql) { return; } $logFile = LOGS_DIR . '/' . 'errors.log'; if (!is_writable($logFile)) { throw new RuntimeException('Error log file cannot be written to. Please give this file read/write permissions for the web server.'); } $writer = new Zend_Log_Writer_Stream($logFile); $logger = new Zend_Log($writer); if (isset($config->log->priority)) { $priority = $config->log->priority; if (defined($priority)) { $writer->addFilter(constant($priority)); } } if (!empty($config->debug->email)) { $bootstrap->bootstrap('Mail'); $this->_addMailWriter($logger, (string) $config->debug->email, $config->debug->emailLogPriority); } return $logger; }
/** * Returns true if $wurflConfig specifies a Logger * @param WURFL_Configuration_Config $wurflConfig * @return bool */ private static function isLoggingConfigured($wurflConfig) { if (is_null($wurflConfig)) { return false; } return !is_null($wurflConfig->logDir) && is_writable($wurflConfig->logDir); }
/** * Entry point for the script * * @return void * * @since 1.0 */ public function doExecute() { jimport('joomla.filesystem.file'); if (file_exists(JPATH_BASE . '/configuration.php') || file_exists(JPATH_BASE . '/config.php')) { $configfile = file_exists(JPATH_BASE . 'configuration.php') ? JPATH_BASE . '/config.php' : JPATH_BASE . '/configuration.php'; if (is_writable($configfile)) { $config = file_get_contents($configfile); //Do a simple replace for the CMS and old school applications $newconfig = str_replace('public $offline = \'0\'', 'public $offline = \'1\'', $config); // Newer applications generally use JSON instead. if (!$newconfig) { $newconfig = str_replace('"public $offline":"0"', '"public $offline":"1"', $config); } if (!$newconfig) { $this->out('This application does not have an offline configuration setting.'); } else { JFile::Write($configfile, &$newconfig); $this->out('Site is offline'); } } else { $this->out('The file is not writable, you need to change the file permissions first.'); $this->out(); } } else { $this->out('This application does not have a configuration file'); } $this->out(); }
function CreateFolder($resourceType, $currentFolder) { $sErrorNumber = '0'; $sErrorMsg = ''; if (isset($_GET['NewFolderName'])) { $sNewFolderName = $_GET['NewFolderName']; // Map the virtual path to the local server path of the current folder. $sServerDir = ServerMapFolder($resourceType, $currentFolder); if (is_writable($sServerDir)) { $sServerDir .= $sNewFolderName; $sErrorMsg = CreateServerFolder($sServerDir); switch ($sErrorMsg) { case '': $sErrorNumber = '0'; break; case 'Invalid argument': case 'No such file or directory': $sErrorNumber = '102'; // Path too long. break; default: $sErrorNumber = '110'; break; } } else { $sErrorNumber = '103'; } } else { $sErrorNumber = '102'; } // Create the "Error" node. echo '<Error number="' . $sErrorNumber . '" originalDescription="' . ConvertToXmlAttribute($sErrorMsg) . '" />'; }
/** * Defined by Zend_Filter_Interface * * Decrypts the file $value with the defined settings * * @param string $value Full path of file to change * @return string The filename which has been set, or false when there were errors */ public function filter($value) { if (!file_exists($value)) { //require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception("File '{$value}' not found"); } if (!isset($this->_filename)) { $this->_filename = $value; } if (file_exists($this->_filename) and !is_writable($this->_filename)) { //require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception("File '{$this->_filename}' is not writable"); } $content = file_get_contents($value); if (!$content) { //require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception("Problem while reading file '{$value}'"); } $decrypted = parent::filter($content); $result = file_put_contents($this->_filename, $decrypted); if (!$result) { //require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception("Problem while writing file '{$this->_filename}'"); } return $this->_filename; }
/** * @param string $value directory for storing log files. * @throws CException if the path is invalid */ public function setLogPath($value) { $this->_logPath = realpath($value); if ($this->_logPath === false || !is_dir($this->_logPath) || !is_writable($this->_logPath)) { throw new CException(Yii::t('yii', 'CFileLogRoute.logPath "{path}" does not point to a valid directory. Make sure the directory exists and is writable by the Web server process.', array('{path}' => $value))); } }