Example #1
0
 public static function start()
 {
     $OSCOM_Language = Registry::get('Language');
     $OSCOM_MessageStack = Registry::get('MessageStack');
     if (SERVICE_DEBUG_CHECK_LOCALE == '1') {
         $setlocale = setlocale(LC_TIME, explode(',', $OSCOM_Language->getLocale()));
         if ($setlocale === false || $setlocale === null) {
             $OSCOM_MessageStack->add('debug', 'Error: Locale does not exist: ' . $OSCOM_Language->getLocale(), 'error');
         }
     }
     if (SERVICE_DEBUG_CHECK_INSTALLATION_MODULE == '1' && file_exists(OSCOM::BASE_DIRECTORY . 'Core/Site/Setup')) {
         $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_install_directory_exists'), OSCOM::BASE_DIRECTORY . 'Core/Site/Setup'), 'warning');
     }
     if (SERVICE_DEBUG_CHECK_CONFIGURATION == '1' && is_writeable(OSCOM::BASE_DIRECTORY . 'Config/settings.ini')) {
         $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_config_file_writeable'), OSCOM::BASE_DIRECTORY . 'Config//settings.ini'), 'warning');
     }
     if (SERVICE_DEBUG_CHECK_SESSION_DIRECTORY == '1' && OSCOM::getConfig('store_sessions') == '') {
         if (!is_dir(OSCOM_Registry::get('Session')->getSavePath())) {
             $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_session_directory_non_existent'), OSCOM_Registry::get('Session')->getSavePath()), 'warning');
         } elseif (!is_writeable(OSCOM_Registry::get('Session')->getSavePath())) {
             $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_session_directory_not_writeable'), OSCOM_Registry::get('Session')->getSavePath()), 'warning');
         }
     }
     if (SERVICE_DEBUG_CHECK_SESSION_AUTOSTART == '1' && (bool) ini_get('session.auto_start')) {
         $OSCOM_MessageStack->add('debug', OSCOM::getDef('warning_session_auto_start'), 'warning');
     }
     if (SERVICE_DEBUG_CHECK_DOWNLOAD_DIRECTORY == '1' && DOWNLOAD_ENABLED == '1') {
         if (!is_dir(DIR_FS_DOWNLOAD)) {
             $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_download_directory_non_existent'), DIR_FS_DOWNLOAD), 'warning');
         }
     }
     return true;
 }
Example #2
0
 /**
  * The compiled class codes directory
  *
  * @param string $dir
  *        	@exception Miaox_Aop_Exception
  */
 public function setCacheDirectory($dir = '')
 {
     if (!file_exists($dir) || !is_dir($dir) || !is_writeable($dir)) {
         throw new Miaox_Aop_Exception(sprintf('Указанный путь неверен или недоступен для записи: %s', $dir));
     }
     $this->_cache = $dir;
 }
Example #3
0
 /**
  * 自动获取缓存类名
  * @param $config
  * @return string
  */
 public static function getAutoClass($config)
 {
     $driver = "";
     $path = Factory::getPath(false, $config);
     if (is_writeable($path)) {
         $driver = "file";
     } elseif (extension_loaded('pdo_sqlite') && is_writeable($path)) {
         $driver = "sqlite";
     } elseif (extension_loaded('apc') && ini_get('apc.enabled') && strpos(PHP_SAPI, "CGI") === false) {
         $driver = "apc";
     } elseif (class_exists("\\Memcached")) {
         $driver = "memcached";
     } elseif (extension_loaded('wincache') && function_exists("wincache_ucache_set")) {
         $driver = "wincache";
     } elseif (extension_loaded('xcache') && function_exists("xcache_get")) {
         $driver = "xcache";
     } elseif (function_exists("\\memcache_connect")) {
         $driver = "memcache";
     } elseif (class_exists("\\Redis")) {
         $driver = "redis";
     } else {
         $driver = "file";
     }
     return $driver;
 }
Example #4
0
 /**
  * 遍历目录内容
  * @param string $dirName 目录名
  * @param string $exts 读取的文件扩展名
  * @param int $son 是否显示子目录
  * @param array $list
  * @return array
  */
 public static function tree($dirName = null, $exts = '', $son = 0, $list = array())
 {
     if (is_null($dirName)) {
         $dirName = '.';
     }
     $dirPath = self::dirPath($dirName);
     static $id = 0;
     if (is_array($exts)) {
         $exts = implode("|", $exts);
     }
     foreach (glob($dirPath . '*') as $v) {
         $id++;
         if (is_dir($v) || !$exts || preg_match("/\\.({$exts})/i", $v)) {
             $list[$id]['name'] = basename($v);
             $list[$id]['path'] = str_replace("\\", "/", realpath($v));
             $list[$id]['type'] = filetype($v);
             $list[$id]['filemtime'] = filemtime($v);
             $list[$id]['fileatime'] = fileatime($v);
             $list[$id]['size'] = is_file($v) ? filesize($v) : self::get_dir_size($v);
             $list[$id]['iswrite'] = is_writeable($v) ? 1 : 0;
             $list[$id]['isread'] = is_readable($v) ? 1 : 0;
         }
         if ($son) {
             if (is_dir($v)) {
                 $list = self::tree($v, $exts, $son = 1, $list);
             }
         }
     }
     return $list;
 }
Example #5
0
 function start()
 {
     global $lC_MessageStack, $lC_Language;
     if (SERVICE_DEBUG_CHECK_LOCALE == '1') {
         $setlocale = lc_setlocale(LC_TIME, explode(',', $lC_Language->getLocale()));
         if ($setlocale === false || $setlocale === null) {
             $lC_MessageStack->add('debug', 'Error: Locale does not exist: ' . $lC_Language->getLocale(), 'error');
         }
     }
     if (SERVICE_DEBUG_CHECK_INSTALLATION_MODULE == '1' && file_exists(dirname($_SERVER['SCRIPT_FILENAME']) . '/install')) {
         $lC_MessageStack->add('debug', sprintf($lC_Language->get('warning_install_directory_exists'), dirname($_SERVER['SCRIPT_FILENAME']) . '/install'), 'warning');
     }
     if (SERVICE_DEBUG_CHECK_CONFIGURATION == '1' && file_exists(dirname($_SERVER['SCRIPT_FILENAME']) . '/includes/config.php') && is_writeable(dirname($_SERVER['SCRIPT_FILENAME']) . '/includes/config.php')) {
         $lC_MessageStack->add('debug', sprintf($lC_Language->get('warning_config_file_writeable'), dirname($_SERVER['SCRIPT_FILENAME']) . '/includes/config.php'), 'warning');
     }
     if (SERVICE_DEBUG_CHECK_SESSION_DIRECTORY == '1' && STORE_SESSIONS == '') {
         if (!is_dir($lC_Session->getSavePath())) {
             $lC_MessageStack->add('debug', sprintf($lC_Language->get('warning_session_directory_non_existent'), $lC_Session->getSavePath()), 'warning');
         } elseif (!is_writeable($lC_Session->getSavePath())) {
             $lC_MessageStack->add('debug', sprintf($lC_Language->get('warning_session_directory_not_writeable'), $lC_Session->getSavePath()), 'warning');
         }
     }
     if (SERVICE_DEBUG_CHECK_SESSION_AUTOSTART == '1' && (bool) ini_get('session.auto_start')) {
         $lC_MessageStack->add('debug', $lC_Language->get('warning_session_auto_start'), 'warning');
     }
     if (SERVICE_DEBUG_CHECK_DOWNLOAD_DIRECTORY == '1' && DOWNLOAD_ENABLED == '1') {
         if (!is_dir(DIR_FS_DOWNLOAD)) {
             $lC_MessageStack->add('debug', sprintf($lC_Language->get('warning_download_directory_non_existent'), DIR_FS_DOWNLOAD), 'warning');
         }
     }
     return true;
 }
Example #6
0
 /**
  * Change encryption key
  *
  * @throws Exception
  * @param string $key
  * @return string
  */
 public function changeEncryptionKey($key = null)
 {
     // prepare new key, encryptor and new file contents
     $file = Mage::getBaseDir('etc') . DS . 'local.xml';
     if (!is_writeable($file)) {
         throw new Exception(Mage::helper('enterprise_pci')->__('File %s is not writeable.', realpath($file)));
     }
     $contents = file_get_contents($file);
     if (null === $key) {
         $key = md5(time());
     }
     $this->_encryptor = clone Mage::helper('core')->getEncryptor();
     $this->_encryptor->setNewKey($key);
     $contents = preg_replace('/<key><\\!\\[CDATA\\[(.+?)\\]\\]><\\/key>/s', '<key><![CDATA[' . $this->_encryptor->exportKeys() . ']]></key>', $contents);
     // update database and local.xml
     $this->beginTransaction();
     try {
         $this->_reEncryptSystemConfigurationValues();
         $this->_reEncryptCreditCardNumbers();
         file_put_contents($file, $contents);
         $this->commit();
         return $key;
     } catch (Exception $e) {
         $this->rollBack();
         throw $e;
     }
 }
function mc_write_styles($stylefile, $my_calendar_style)
{
    if (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT == true) {
        return false;
    }
    $standard = dirname(__FILE__) . '/styles/';
    $files = my_csslist($standard);
    foreach ($files as $file) {
        $filepath = mc_get_style_path($file);
        $path = pathinfo($filepath);
        if ($path['extension'] == 'css') {
            $styles_whitelist[] = $filepath;
        }
    }
    if (in_array($stylefile, $styles_whitelist)) {
        if (function_exists('wp_is_writable')) {
            $is_writable = wp_is_writable($stylefile);
        } else {
            $is_writable = is_writeable($stylefile);
        }
        if ($is_writable) {
            $f = fopen($stylefile, 'w+');
            fwrite($f, $my_calendar_style);
            // number of bytes to write, max.
            fclose($f);
            return true;
        } else {
            return false;
        }
    }
    return false;
}
Example #8
0
 /**
  * Constructor for RenderCache
  *
  * Sets up paths and gets the list of groups from file
  */
 public static function __static()
 {
     //Define the cache path and url
     self::$cache_path = HABARI_PATH . '/' . self::$rel_cache_path;
     self::$cache_url = Site::get_url('habari') . '/' . self::$rel_cache_path;
     //If the cache directory doesn't exist, make it
     if (!is_dir(self::$cache_path)) {
         mkdir(self::$cache_path, 0755);
     }
     //Enable only if the cache directory now exists and is writable
     self::$enabled = is_dir(self::$cache_path) && is_writeable(self::$cache_path);
     //Give an error if the cache directory is not writable
     if (!self::$enabled) {
         Session::error(sprintf(_t("The cache directory '%s' is not writable - the cache is disabled. The user, or group, which your web server is running as, needs to have read, write, and execute permissions on this directory."), self::$cache_path), 'RenderCache');
         EventLog::log(sprintf(_t("The cache directory '%s' is not writable - the cache is disabled."), self::$cache_path), 'notice', 'RenderCache', 'habari');
         return;
     }
     //Get the list of group names
     $group_file = self::get_group_list_file();
     if (file_exists($group_file)) {
         self::$group_list = unserialize(file_get_contents($group_file));
     } else {
         self::$group_list = array();
     }
 }
Example #9
0
 /**
  * Migrate the database.
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->bootstrap($input, $output);
     // get the migration path from the config
     $path = $this->getConfig()->getMigrationPath();
     if (!is_writeable($path)) {
         throw new \InvalidArgumentException(sprintf('The directory "%s" is not writeable', $path));
     }
     $path = realpath($path);
     $className = $input->getArgument('name');
     if (!Util::isValidMigrationClassName($className)) {
         throw new \InvalidArgumentException(sprintf('The migration class name "%s" is invalid. Please use CamelCase format.', $className));
     }
     // Compute the file path
     $fileName = Util::mapClassNameToFileName($className);
     $filePath = $path . DIRECTORY_SEPARATOR . $fileName;
     if (file_exists($filePath)) {
         throw new \InvalidArgumentException(sprintf('The file "%s" already exists', $filePath));
     }
     // load the migration template
     $contents = file_get_contents(dirname(__FILE__) . '/../../Migration/Migration.template.php.dist');
     // inject the class name
     $contents = str_replace('$className', $className, $contents);
     if (false === file_put_contents($filePath, $contents)) {
         throw new \RuntimeException(sprintf('The file "%s" could not be written to', $path));
     }
     $output->writeln('<info>created</info> .' . str_replace(getcwd(), '', $filePath));
 }
 /**
  * Validate data passed to this action
  */
 public function validate($data = FALSE)
 {
     if (!@is_writeable($this->model->config['config_path'])) {
         throw new SmartModelException("Config folder isnt writeable. Check permission on: " . $this->model->config['config_path']);
     }
     return TRUE;
 }
Example #11
0
 function write()
 {
     if (!is_writeable($this->file)) {
         throw new Exception("file '{$this->file}' is not writeable");
     }
     file_put_contents($this->file, $this->xml->asXML());
 }
Example #12
0
 /** 
  * Gets the system requirements which must pass to buld a package
  * @return array   An array of requirements
  */
 public static function GetRequirements()
 {
     global $wpdb;
     $dup_tests = array();
     //PHP SUPPORT
     $safe_ini = strtolower(ini_get('safe_mode'));
     $dup_tests['PHP']['SAFE_MODE'] = $safe_ini != 'on' || $safe_ini != 'yes' || $safe_ini != 'true' || ini_get("safe_mode") != 1 ? 'Pass' : 'Fail';
     $dup_tests['PHP']['VERSION'] = version_compare(phpversion(), '5.2.17') >= 0 ? 'Pass' : 'Fail';
     $dup_tests['PHP']['ZIP'] = class_exists('ZipArchive') ? 'Pass' : 'Fail';
     $dup_tests['PHP']['FUNC_1'] = function_exists("file_get_contents") ? 'Pass' : 'Fail';
     $dup_tests['PHP']['FUNC_2'] = function_exists("file_put_contents") ? 'Pass' : 'Fail';
     $dup_tests['PHP']['FUNC_3'] = function_exists("mb_strlen") ? 'Pass' : 'Fail';
     $dup_tests['PHP']['ALL'] = !in_array('Fail', $dup_tests['PHP']) ? 'Pass' : 'Fail';
     //PERMISSIONS
     $handle_test = @opendir(DUPLICATOR_WPROOTPATH);
     $dup_tests['IO']['WPROOT'] = is_writeable(DUPLICATOR_WPROOTPATH) && $handle_test ? 'Pass' : 'Fail';
     $dup_tests['IO']['SSDIR'] = is_writeable(DUPLICATOR_SSDIR_PATH) ? 'Pass' : 'Fail';
     $dup_tests['IO']['SSTMP'] = is_writeable(DUPLICATOR_SSDIR_PATH_TMP) ? 'Pass' : 'Fail';
     $dup_tests['IO']['ALL'] = !in_array('Fail', $dup_tests['IO']) ? 'Pass' : 'Fail';
     @closedir($handle_test);
     //SERVER SUPPORT
     $dup_tests['SRV']['MYSQLi'] = function_exists('mysqli_connect') ? 'Pass' : 'Fail';
     $dup_tests['SRV']['MYSQL_VER'] = version_compare($wpdb->db_version(), '5.0', '>=') ? 'Pass' : 'Fail';
     $dup_tests['SRV']['ALL'] = !in_array('Fail', $dup_tests['SRV']) ? 'Pass' : 'Fail';
     //RESERVED FILES
     $dup_tests['RES']['INSTALL'] = !self::InstallerFilesFound() ? 'Pass' : 'Fail';
     $dup_tests['Success'] = $dup_tests['PHP']['ALL'] == 'Pass' && $dup_tests['IO']['ALL'] == 'Pass' && $dup_tests['SRV']['ALL'] == 'Pass' && $dup_tests['RES']['INSTALL'] == 'Pass';
     return $dup_tests;
 }
Example #13
0
 /**
  * handle request and build XML
  * @access protected
  *
  */
 protected function buildXml()
 {
     $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
     if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FOLDER_CREATE)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
     }
     $_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
     $sNewFolderName = isset($_GET["NewFolderName"]) ? $_GET["NewFolderName"] : "";
     $sNewFolderName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($sNewFolderName);
     if (!CKFinder_Connector_Utils_FileSystem::checkFileName($sNewFolderName) || $_resourceTypeConfig->checkIsHiddenFolder($sNewFolderName)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
     }
     $sServerDir = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $sNewFolderName);
     if (!is_writeable($this->_currentFolder->getServerPath())) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
     }
     $bCreated = false;
     if (file_exists($sServerDir)) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST);
     }
     if ($perms = $_config->getChmodFolders()) {
         $oldUmask = umask(0);
         $bCreated = @mkdir($sServerDir, $perms);
         umask($oldUmask);
     } else {
         $bCreated = @mkdir($sServerDir);
     }
     if (!$bCreated) {
         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
     } else {
         $oNewFolderNode = new Ckfinder_Connector_Utils_XmlNode("NewFolder");
         $this->_connectorNode->addChild($oNewFolderNode);
         $oNewFolderNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($sNewFolderName));
     }
 }
 function SaveConfigFile($strFilePath, $arr)
 {
     //test if file exists (if not, create it)
     if (!is_file($strFilePath)) {
         $f = fopen($strFilePath, "x");
         fclose($f);
     }
     //test if file is writeable
     if (!is_writeable($strFilePath)) {
         $this->errMsg = 'Le fichier "' . $strFilePath . '" ne peux pas être écris! Svp, vérifier les autorisations';
         return false;
     }
     //save config
     $f = fopen($strFilePath, "w");
     if ($f) {
         foreach ($arr as $key => $value) {
             if (fwrite($f, "{$key}={$value}\n") === false) {
                 echo "[{$value}]<br />";
                 fclose($f);
                 $this->errMsg = 'Erreur écriture "' . $strFilePath . '" - Erreur inconnue !';
             }
         }
         fclose($f);
         return true;
     } else {
         $this->errMsg = 'Le fichier "' . $strFilePath . '" ne peut être ouvert ! Erreur inconnue';
         return false;
     }
 }
Example #15
0
 public function dirToArray($dir)
 {
     ${"GLOBALS"}["sqaetwms"] = "cdir";
     ${"GLOBALS"}["dnlhtc"] = "cdir";
     ${"GLOBALS"}["noxrzlzpal"] = "dir";
     ${${"GLOBALS"}["hedrbklsp"]} = array();
     ${${"GLOBALS"}["dnlhtc"]} = scandir(${${"GLOBALS"}["noxrzlzpal"]});
     foreach (${${"GLOBALS"}["sqaetwms"]} as ${${"GLOBALS"}["kpyagas"]} => ${${"GLOBALS"}["bhdrlkhjsq"]}) {
         if (!in_array(${${"GLOBALS"}["bhdrlkhjsq"]}, array(".", ".."))) {
             if (is_dir(${${"GLOBALS"}["wuxvckj"]} . DIRECTORY_SEPARATOR . ${${"GLOBALS"}["bhdrlkhjsq"]})) {
                 $kydgurvbhe = "value";
                 ${"GLOBALS"}["mcikfhlg"] = "value";
                 ${${"GLOBALS"}["hedrbklsp"]}[${$kydgurvbhe}] = $this->dirToArray(${${"GLOBALS"}["wuxvckj"]} . DIRECTORY_SEPARATOR . ${${"GLOBALS"}["mcikfhlg"]});
             } else {
                 $ngbblseg = "dir";
                 if (!is_writeable(${$ngbblseg} . DIRECTORY_SEPARATOR . ${${"GLOBALS"}["bhdrlkhjsq"]})) {
                     ${"GLOBALS"}["pjbiom"] = "value";
                     echo "<p style=\"margin:0;color:red;\">File: " . ${${"GLOBALS"}["wuxvckj"]} . DIRECTORY_SEPARATOR . ${${"GLOBALS"}["pjbiom"]} . " not writable!</p>";
                 } else {
                     echo "<p style=\"margin:0;color:green;\">File: " . ${${"GLOBALS"}["wuxvckj"]} . DIRECTORY_SEPARATOR . ${${"GLOBALS"}["bhdrlkhjsq"]} . " OK!</p>";
                 }
             }
         }
     }
     return ${${"GLOBALS"}["hedrbklsp"]};
 }
Example #16
0
 /**
  * @return Varien_Io_Abstract
  */
 public function getResource($forWrite = false)
 {
     if (!$this->_resource) {
         $type = $this->getVar('type', 'file');
         $className = 'Varien_Io_' . ucwords($type);
         $this->_resource = new $className();
         $isError = false;
         $ioConfig = $this->getVars();
         switch ($this->getVar('type', 'file')) {
             case 'file':
                 //validate export/import path
                 $path = rtrim($ioConfig['path'], '\\/') . DS . $ioConfig['filename'];
                 /** @var $validator Mage_Core_Model_File_Validator_AvailablePath */
                 $validator = Mage::getModel('core/file_validator_availablePath');
                 $validator->setPaths(Mage::getStoreConfig(self::XML_PATH_EXPORT_LOCAL_VALID_PATH));
                 if (!$validator->isValid($path)) {
                     foreach ($validator->getMessages() as $message) {
                         Mage::throwException($message);
                         return false;
                     }
                 }
                 if (preg_match('#^' . preg_quote(DS, '#') . '#', $this->getVar('path')) || preg_match('#^[a-z]:' . preg_quote(DS, '#') . '#i', $this->getVar('path'))) {
                     $path = $this->_resource->getCleanPath($this->getVar('path'));
                 } else {
                     $baseDir = Mage::getBaseDir();
                     $path = $this->_resource->getCleanPath($baseDir . DS . trim($this->getVar('path'), DS));
                 }
                 $this->_resource->checkAndCreateFolder($path);
                 $realPath = realpath($path);
                 if (!$isError && $realPath === false) {
                     $message = Mage::helper('dataflow')->__('The destination folder "%s" does not exist or there is no access to create it.', $ioConfig['path']);
                     Mage::throwException($message);
                 } elseif (!$isError && !is_dir($realPath)) {
                     $message = Mage::helper('dataflow')->__('Destination folder "%s" is not a directory.', $realPath);
                     Mage::throwException($message);
                 } elseif (!$isError) {
                     if ($forWrite && !is_writeable($realPath)) {
                         $message = Mage::helper('dataflow')->__('Destination folder "%s" is not writable.', $realPath);
                         Mage::throwException($message);
                     } else {
                         $ioConfig['path'] = rtrim($realPath, DS);
                     }
                 }
                 break;
             default:
                 $ioConfig['path'] = rtrim($this->getVar('path'), '/');
                 break;
         }
         if ($isError) {
             return false;
         }
         try {
             $this->_resource->open($ioConfig);
         } catch (Exception $e) {
             $message = Mage::helper('dataflow')->__('An error occurred while opening file: "%s".', $e->getMessage());
             Mage::throwException($message);
         }
     }
     return $this->_resource;
 }
Example #17
0
 /**
  * Set robots.
  *
  * @access public
  * @return void
  */
 public function setRobots()
 {
     $robotsFile = $this->app->getWwwRoot() . 'robots.txt';
     $writeable = (file_exists($robotsFile) and is_writeable($robotsFile) or is_writeable(dirname($robotsFile)));
     if (!empty($_POST)) {
         if (!$writeable) {
             $this->send(array('result' => 'fail', 'message' => sprintf($this->lang->site->robotsUnwriteable, $robotsFile)));
         }
         if (!$this->post->robots) {
             $this->send(array('result' => 'fail', 'message' => array('robots' => sprintf($this->lang->error->notempty, $this->lang->site->robots))));
         }
         $result = file_put_contents($robotsFile, $this->post->robots);
         if (!$result) {
             $this->send(array('result' => 'fail', 'message' => $this->lang->fail));
         }
         $this->send(array('result' => 'success', 'message' => $this->lang->setSuccess, 'locate' => inlink('setrobots')));
     }
     $this->view->robots = '';
     if (file_exists($robotsFile)) {
         $this->view->robots = file_get_contents($robotsFile);
     }
     $this->view->robotsFile = $robotsFile;
     $this->view->writeable = $writeable;
     $this->view->title = $this->lang->site->setBasic;
     $this->display();
 }
Example #18
0
function ReWriteConfig()
{
    global $dsql, $configfile;
    if (!is_writeable($configfile)) {
        echo "配置文件'{$configfile}'不支持写入,无法修改系统配置参数!";
        exit;
    }
    $fp = fopen($configfile, 'w');
    flock($fp, 3);
    fwrite($fp, "<" . "?php\r\n");
    $dsql->SetQuery("Select `varname`,`type`,`value`,`groupid` From `#@__sysconfig` order by aid asc ");
    $dsql->Execute();
    while ($row = $dsql->GetArray()) {
        if ($row['type'] == 'number') {
            if ($row['value'] == '') {
                $row['value'] = 0;
            }
            fwrite($fp, "\${$row['varname']} = " . $row['value'] . ";\r\n");
        } else {
            fwrite($fp, "\${$row['varname']} = '" . str_replace("'", '', $row['value']) . "';\r\n");
        }
    }
    fwrite($fp, "?" . ">");
    fclose($fp);
}
Example #19
0
function check_writeable_files()
{
    // Need to check to see if the necessary directories are writeable.
    $writeable = true;
    $fixme = '';
    if (!is_writeable('../attachments')) {
        $fixme .= "../attachments/<br />";
        $writeable = false;
    }
    if (!is_writeable('../avatars/uploaded')) {
        $fixme .= "../avatars/uploaded/<br />";
        $writeable = false;
    }
    if (!is_writeable('../packages')) {
        $fixme .= "../packages/<br />";
        $writeable = false;
    }
    if (!is_writeable('../skins')) {
        $fixme .= "../skins/<br />";
        $writeable = false;
    }
    if (!is_writeable('../stats')) {
        $fixme .= "../stats/<br />";
        $writeable = false;
    }
    if (!$writeable) {
        echo "<tr><td colspan='2'>The following directories are missing or not writeable. Some portal functions will be impaired unless these are changed to 0777 permission.</td></tr>";
        echo "<tr><td colspan='2'><span style='font-weight:bold; color:red'>" . $fixme . "</span></td></tr>";
    }
}
 /**
  * collect all fileinformations of given file and
  * save them to the global fileinformation array
  *
  * @param string $file
  * @return boolean is valid file?
  */
 protected function setFileInformations($file)
 {
     $this->fileInfo = array();
     // reset previously information to have a cleaned object
     $this->file = $file instanceof \TYPO3\CMS\Core\Resource\File ? $file : NULL;
     if (is_string($file) && !empty($file)) {
         $this->fileInfo = TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($file);
         $this->fileInfo['mtime'] = filemtime($file);
         $this->fileInfo['atime'] = fileatime($file);
         $this->fileInfo['owner'] = fileowner($file);
         $this->fileInfo['group'] = filegroup($file);
         $this->fileInfo['size'] = filesize($file);
         $this->fileInfo['type'] = filetype($file);
         $this->fileInfo['perms'] = fileperms($file);
         $this->fileInfo['is_dir'] = is_dir($file);
         $this->fileInfo['is_file'] = is_file($file);
         $this->fileInfo['is_link'] = is_link($file);
         $this->fileInfo['is_readable'] = is_readable($file);
         $this->fileInfo['is_uploaded'] = is_uploaded_file($file);
         $this->fileInfo['is_writeable'] = is_writeable($file);
     }
     if ($file instanceof \TYPO3\CMS\Core\Resource\File) {
         $pathInfo = \TYPO3\CMS\Core\Utility\PathUtility::pathinfo($file->getName());
         $this->fileInfo = array('file' => $file->getName(), 'filebody' => $file->getNameWithoutExtension(), 'fileext' => $file->getExtension(), 'realFileext' => $pathInfo['extension'], 'atime' => $file->getCreationTime(), 'mtime' => $file->getModificationTime(), 'owner' => '', 'group' => '', 'size' => $file->getSize(), 'type' => 'file', 'perms' => '', 'is_dir' => FALSE, 'is_file' => $file->getStorage()->getDriverType() === 'Local' ? is_file($file->getForLocalProcessing(FALSE)) : TRUE, 'is_link' => $file->getStorage()->getDriverType() === 'Local' ? is_link($file->getForLocalProcessing(FALSE)) : FALSE, 'is_readable' => TRUE, 'is_uploaded' => FALSE, 'is_writeable' => FALSE);
     }
     return $this->fileInfo !== array();
 }
Example #21
0
function checkCache()
{
    if (!is_writeable(IN_PATH . 'cache/')) {
        return false;
    }
    return true;
}
Example #22
0
 function write_image_resource(&$image_resource, $path = null, $direct = false)
 {
     if (!(isset($path) || $this->getName() || $direct)) {
         trigger_error('No path specified for writing image.');
         return false;
     }
     if (!isset($path)) {
         $path = $this->getPath();
     }
     if (!is_writeable($path)) {
         $file_part = basename($path);
         $path_only = $file_part ? str_replace(DIRECTORY_SEPARATOR . $file_part, '', $path) : $path;
         if (!is_writeable($path_only)) {
             trigger_error(sprintf(AMP_TEXT_ERROR_FILE_WRITE_FAILED, $path_only));
         }
     }
     if (!($write_method = $this->_get_action_method('write'))) {
         return false;
     }
     if ($direct) {
         return $write_method($image_resource);
     }
     $result = $write_method($image_resource, $path);
     if ($result) {
         AMP_s3_save($path);
     }
     return $result;
 }
 public function getJoindinAction()
 {
     $config = $this->getServiceLocator()->get('config');
     $url = $config['php.ug.event']['url'];
     $file = $config['php.ug.event']['cachefile'];
     if (!realpath(dirname($file))) {
         throw new \UnexpectedValueException(sprintf('"%s" does not exist', dirname($file)));
     }
     if (!is_writeable(realpath(dirname($file)))) {
         throw new \UnexpectedValueException(sprintf('"%s" is not writeable', realpath(dirname($file))));
     }
     if (!is_writeable(realpath($file))) {
         throw new \UnexpectedValueException(sprintf('"%s" is not writeable', realpath($file)));
     }
     $file = realpath($file);
     echo sprintf('Fetching the joind.in data from "%s"' . "\n", $url);
     $fh = fopen($file, 'w');
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_TIMEOUT, 50);
     curl_setopt($ch, CURLOPT_FILE, $fh);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_exec($ch);
     // get curl response
     curl_close($ch);
     fclose($fh);
     echo sprintf('Wrote the joind.in-data to "%s"' . "\n", $file);
     return false;
 }
Example #24
0
 public function __construct($config = array())
 {
     $this->cache_prikey = md5(serialize($config));
     $this->prefix = 'ok' . substr($this->cache_prikey, 0, 5) . '_';
     if (!isset($config['cache'])) {
         $this->status = false;
         return true;
     }
     $this->status = isset($config['cache']['status']) ? $config['cache']['status'] : false;
     if (!$this->status) {
         return true;
     }
     $this->config['type'] = isset($config['cache']['type']) ? $config['cache']['type'] : 'file';
     $this->config['folder'] = isset($config['cache']['folder']) ? $config['cache']['folder'] : 'cache/';
     $this->config['server'] = isset($config['cache']['server']) ? $config['cache']['server'] : 'localhost';
     $this->config['port'] = isset($config['cache']['port']) ? $config['cache']['port'] : 11211;
     $this->config['time'] = isset($config['cache']['time']) ? $config['cache']['time'] : 36000;
     //判断类型,如果不符合条件,则使用file类型
     if (!in_array($this->config['type'], array('file', 'memcache')) || $this->config['type'] == 'memcache' && !class_exists('Memcache') || $this->config['type'] == 'memcache' && !$this->connect_cache()) {
         $this->config['type'] = 'file';
     }
     if ($this->config['type'] == 'file') {
         if (!is_dir($this->config['folder']) || !is_writeable($this->config['folder'])) {
             $this->status = false;
         }
         if ($this->status) {
             $this->connect_cache();
         }
     }
 }
Example #25
0
 /** Запазваме лога във файл **/
 private static function save($type, $message)
 {
     if (file_exists(self::$_path . $type . '.php') && is_writeable(self::$_path . $type . '.php')) {
         $msg = self::GetDate() . ", " . $message . "\n";
         error_log($msg, 3, self::$_path . $type . '.php');
     }
 }
Example #26
0
 /**
  * Determine if the XML is writeable
  * @return bool
  */
 public function fileWriteable()
 {
     if (is_writeable(dirname($this->path))) {
         return true;
     }
     return false;
 }
Example #27
0
function debug($data)
{
    global $timezone;
    if (function_exists("date_default_timezone_set")) {
        // php 5.1.x
        @date_default_timezone_set($timezone);
    }
    $debug_file = "./tfu.log";
    $debug_string = date("m.d.Y G:i:s") . " - " . $data . "\n\n";
    if (file_exists($debug_file)) {
        if (filesize($debug_file) > 1000000) {
            // debug file max = 1MB !
            $debug_file_local = fopen($debug_file, 'w');
        } else {
            $debug_file_local = fopen($debug_file, 'a');
        }
        fputs($debug_file_local, $debug_string);
        fclose($debug_file_local);
    } else {
        if (is_writeable(dirname(__FILE__))) {
            $debug_file_local = fopen($debug_file, 'w');
            fputs($debug_file_local, $debug_string);
            fclose($debug_file_local);
            clearstatcache();
        } else {
            error_log($debug_string, 0);
        }
    }
}
Example #28
0
 /**
  * Installer::CheckServer()
  * 
  * @return
  */
 public static function CheckServer()
 {
     $noerror = true;
     $version = phpversion();
     $wf = array();
     // These needa be writable
     $wf[] = 'core/cache';
     $wf[] = 'core/logs';
     $wf[] = 'core/pages';
     $wf[] = 'lib/avatars';
     $wf[] = 'lib/rss';
     $wf[] = 'lib/signatures';
     // Check the PHP version
     if ($version[0] != '5') {
         $noerror = false;
         $type = 'error';
         $message = 'You need PHP 5 (your version: ' . $version . ')';
     } else {
         $type = 'success';
         $message = 'OK! (your version:' . $version . ')';
     }
     Template::Set('phpversion', '<div id="' . $type . '">' . $message . '</div>');
     // Check if core/site_config.inc.php is writeable
     if (!file_exists(CORE_PATH . '/local.config.php')) {
         if (!($fp = fopen(CORE_PATH . '/local.config.php', 'w'))) {
             $noerror = false;
             $type = 'error';
             $message = 'Could not create core/local.config.php. Create this file, blank, with write permissions.';
         } else {
             $type = 'success';
             $message = 'core/local.config.php is writeable!';
         }
     } else {
         if (!is_writeable(CORE_PATH . '/local.config.php')) {
             $noerror = false;
             $type = 'error';
             $message = 'core/local.config.php is not writeable';
         } else {
             $type = 'success';
             $message = 'core/local.config.php is writeable!';
         }
     }
     Template::Set('configfile', '<div id="' . $type . '">' . $message . '</div>');
     // Check all of the folders for writable permissions
     $status = '';
     foreach ($wf as $folder) {
         if (!is_writeable(SITE_ROOT . '/' . $folder)) {
             $noerror = false;
             $type = 'error';
             $message = $folder . ' is not writeable';
         } else {
             $type = 'success';
             $message = $folder . ' is writeable!';
         }
         $status .= '<div id="' . $type . '">' . $message . '</div>';
     }
     Template::Set('directories', $status);
     //Template::Set('pagesdir', '<div id="'.$type.'">'.$message.'</div>');
     return $noerror;
 }
Example #29
0
 public function preflight($type, $parent)
 {
     $jversion = new JVersion();
     // INSTALLING COMPONENT MANIFEST FILE VERSION
     $this->release = $parent->get("manifest")->version;
     // MANIFEST FILE MINIMUM JOOMLA VERSION
     $this->minimum_joomla_release = $parent->get("manifest")->attributes()->version;
     // ABORT IF THE CURRENT JOOMLA RELEASE IS OLDER
     if (version_compare($jversion->getShortVersion(), $this->minimum_joomla_release, 'lt')) {
         JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_MAPBOX_MSG_ERROR_JVERSION', $this->minimum_joomla_release), 'error');
         return false;
     }
     // ABORT IF THE COMPONENT BEING INSTALLED IS NOT NEWER THAN THE CURRENTLY INSTALLED VERSION
     if ($type == 'update') {
         $oldRelease = $this->getParam('version');
         $rel = $oldRelease . ' to ' . $this->release;
         if (version_compare($this->release, $oldRelease, 'le')) {
             JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_MAPBOX_MSG_ERROR_SCHEMA', $this->release), 'error');
             return false;
         }
     } else {
         $rel = $this->release;
     }
     // ABORT IF THE SERVER ENVIRONMENT DOES NOT INCLUDE THE GD LIBRARIES
     if (!extension_loaded('gd')) {
         JFactory::getApplication()->enqueueMessage(JText::_('COM_MAPBOX_MSG_ERROR_GD_MISSING'), 'error');
         return false;
     }
     // ABORT IF THE IMAGES DIRECTORY IS NOT WRITEABLE
     if (!is_writeable(JPATH_ROOT . "/images")) {
         JFactory::getApplication()->enqueueMessage(JText::_('COM_MAPBOX_INSTALL_ERROR_PERMISSIONS'), 'error');
         return false;
     }
     echo '<p>' . JText::_('COM_MAPBOX_MSG_SUCCESS_PREFLIGHT') . '</p>';
 }
 /**
  * Check if users need to set the file permissions in order to support the theme, and if not, displays warnings messages in admin option page.
  */
 function wt_warnings()
 {
     global $wp_version;
     $warnings = array();
     if (!wt_check_wp_version()) {
         $warnings[] = 'Wordpress version(<b>' . $wp_version . '</b>) is too low. Please upgrade to the latest version.';
     }
     if (!function_exists("imagecreatetruecolor")) {
         $warnings[] = 'GD Library Error: <b>imagecreatetruecolor does not exist</b>. Please contact your host provider and ask them to install the GD library, otherwise this theme won\'t work properly.';
     }
     if (!is_writeable(THEME_CACHE_DIR)) {
         $warnings[] = 'The cache folder (<b>' . str_replace(WP_CONTENT_DIR, '', THEME_CACHE_DIR) . '</b>) is not writeable. Please set the correct file permissions (<b>\'777\' or \'755\'</b>), otherwise this theme won\'t work properly.';
     }
     if (!file_exists(THEME_CACHE_DIR . DIRECTORY_SEPARATOR . 'skin.css')) {
         $warnings[] = 'The skin style file (<b>' . str_replace(WP_CONTENT_DIR, '', THEME_CACHE_DIR) . '/skin.css' . '</b>) doesn\'t exists or it was deleted. Please manually create this file or click on \'Save changes\' and it will be automatically created.';
     }
     if (!is_writeable(THEME_CACHE_DIR . DIRECTORY_SEPARATOR . 'skin.css')) {
         $warnings[] = 'The skin style file (<b>' . str_replace(WP_CONTENT_DIR, '', THEME_CACHE_DIR) . '/skin.css' . '</b>) is not writeable. Please set the correct permissions (<b>\'777\' or \'755\'</b>), otherwise this theme won\'t work properly.';
     }
     $str = '';
     if (!empty($warnings)) {
         $str = '<ul>';
         foreach ($warnings as $warning) {
             $str .= '<li>' . $warning . '</li>';
         }
         $str .= '</ul>';
         echo "\r\n\t\t\t\t<div id='theme-warning' class='error fade'><p><strong>" . sprintf(__('%1$s Error Messages', 'wt_admin'), THEME_NAME) . "</strong><br/>" . $str . "</p></div>\r\n\t\t\t";
     }
 }