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


PHP FileSystem::touch方法代码示例

本文整理汇总了PHP中Cx\Lib\FileSystem\FileSystem::touch方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::touch方法的具体用法?PHP FileSystem::touch怎么用?PHP FileSystem::touch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cx\Lib\FileSystem\FileSystem的用法示例。


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

示例1: _createSettingsFile

 /**
  * Write all settings into the config-file
  *
  */
 function _createSettingsFile()
 {
     global $_ARRLANG;
     $objDb = $this->_getDbObject($statusMsg);
     if ($objDb === false) {
         return $statusMsg;
     } else {
         $strSettingsFile = $_SESSION['installer']['config']['documentRoot'] . $_SESSION['installer']['config']['offsetPath'] . '/config/settings.php';
         if (!\Cx\Lib\FileSystem\FileSystem::touch($strSettingsFile) || !\Cx\Lib\FileSystem\FileSystem::makeWritable($strSettingsFile)) {
             return sprintf($_ARRLANG['TXT_SETTINGS_ERROR_WRITABLE'], $strSettingsFile);
         }
         //Header & Footer
         $strHeader = "<?php\n";
         $strHeader .= "/**\n";
         $strHeader .= "* This file is generated by the \"settings\"-menu in your CMS.\n";
         $strHeader .= "* Do not try to edit it manually!\n";
         $strHeader .= "*/\n\n";
         $strFooter = "\n";
         //Get module-names
         $objResult = $objDb->Execute("SELECT id, name FROM `" . $_SESSION['installer']['config']['dbTablePrefix'] . "modules`");
         if ($objResult->RecordCount() > 0) {
             while (!$objResult->EOF) {
                 $arrModules[$objResult->fields['id']] = $objResult->fields['name'];
                 $objResult->MoveNext();
             }
         }
         //Get values
         $objResult = $objDb->Execute("SELECT setname, setmodule, setvalue FROM `" . $_SESSION['installer']['config']['dbTablePrefix'] . "settings` ORDER BY    setmodule ASC, setname ASC");
         $intMaxLen = 0;
         if ($objResult->RecordCount() > 0) {
             while (!$objResult->EOF) {
                 $intMaxLen = strlen($objResult->fields['setname']) > $intMaxLen ? strlen($objResult->fields['setname']) : $intMaxLen;
                 $arrValues[$objResult->fields['setmodule']][$objResult->fields['setname']] = $objResult->fields['setvalue'];
                 $objResult->MoveNext();
             }
         }
         $intMaxLen += strlen('$_CONFIG[\'\']') + 1;
         //needed for formatted output
         //Write values
         $data = $strHeader;
         $strBody = '';
         foreach ($arrValues as $intModule => $arrInner) {
             $strBody .= "/**\n";
             $strBody .= "* -------------------------------------------------------------------------\n";
             $strBody .= "* " . ucfirst(isset($arrModules[$intModule]) ? $arrModules[$intModule] : '') . "\n";
             $strBody .= "* -------------------------------------------------------------------------\n";
             $strBody .= "*/\n";
             foreach ($arrInner as $strName => $strValue) {
                 $strBody .= sprintf("%-" . $intMaxLen . "s", '$_CONFIG[\'' . $strName . '\']');
                 $strBody .= "= ";
                 $strBody .= (is_numeric($strValue) ? $strValue : '"' . str_replace('"', '\\"', $strValue) . '"') . ";\n";
             }
             $strBody .= "\n";
         }
         $data .= $strBody;
         $data .= $strFooter;
         try {
             $objFile = new \Cx\Lib\FileSystem\File($strSettingsFile);
             $objFile->write($data);
             return true;
         } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
             DBG::msg($e->getMessage());
         }
         return false;
     }
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:70,代码来源:common.class.php

示例2: prepareFileAccess

 /**
  * Prepare file access
  *
  * Creates the file specified by $path if it doesn't exist
  * and removes the write-protection mode on the file if there's one.
  *
  * @param string $path
  * @return boolean  Returns TRUE if the specified file exists and has no write-protection on it at the end. Returns FALSE if something fails.
  */
 private function prepareFileAccess($path)
 {
     $file = $this->document_root . $path;
     return (file_exists($file) || \Cx\Lib\FileSystem\FileSystem::touch($file)) && \Cx\Lib\FileSystem\FileSystem::makeWritable($file);
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:14,代码来源:FWHtAccess.class.php

示例3: newWithin

 /**
  * create new file or folder
  * 
  * @param array $params supplied arguments from JsonData-request
  * @return string
  */
 public function newWithin($params)
 {
     global $_ARRAYLANG, $objInit;
     $_ARRAYLANG = $objInit->loadLanguageData('ViewManager');
     if (empty($params['post']['theme']) || empty($params['post']['name'])) {
         return array('status' => 'error', 'message' => $_ARRAYLANG['TXT_THEME_OPERATION_FAILED_FOR_EMPTY_NAME']);
     }
     if ($params['post']['isFolder'] && preg_match('/^\\./', trim($params['post']['name']))) {
         // folder name should not start with dot(.)
         return array('status' => 'error', 'reload' => false, 'message' => sprintf($_ARRAYLANG['TXT_THEME_FOLDER_NAME_NOT_ALLOWED'], contrexx_input2xhtml($params['post']['name'])));
     }
     $matches = null;
     preg_match('@{([0-9A-Za-z._-]+)(:([_a-zA-Z][A-Za-z_0-9]*))?}@sm', $params['post']['name'], $matches);
     if (!empty($matches)) {
         return array('status' => 'error', 'reload' => false, 'message' => sprintf($_ARRAYLANG['TXT_THEME_NAME_NOT_ALLOWED'], contrexx_input2xhtml($params['post']['newName'])));
     }
     // Cannot rename the virtual directory
     $virtualDirs = array('/' . \Cx\Core\Core\Model\Entity\SystemComponent::TYPE_CORE_MODULE, '/' . \Cx\Core\Core\Model\Entity\SystemComponent::TYPE_MODULE, '/' . \Cx\Core\Core\Model\Entity\SystemComponent::TYPE_CORE);
     $currentThemeFolderDirPath = \Env::get('cx')->getWebsiteThemesPath() . '/' . $params['post']['theme'] . '/';
     // Create the theme folder, if it does not exist
     if (!\Cx\Lib\FileSystem\FileSystem::exists($currentThemeFolderDirPath)) {
         if (!\Cx\Lib\FileSystem\FileSystem::make_folder($currentThemeFolderDirPath)) {
             return array('status' => 'error', 'reload' => false, 'message' => $_ARRAYLANG['TXT_THEME_NEWFILE_FAILED']);
         }
     }
     $newFileName = \Cx\Lib\FileSystem\FileSystem::replaceCharacters($params['post']['name']);
     if (!\FWValidator::is_file_ending_harmless($newFileName)) {
         return array('status' => 'error', 'reload' => false, 'message' => sprintf($_ARRAYLANG['TXT_THEME_FILE_EXTENSION_NOT_ALLOWED'], contrexx_input2xhtml($newFileName)));
     }
     if (in_array('/' . $newFileName, $virtualDirs)) {
         return array('status' => 'error', 'reload' => false, 'message' => $_ARRAYLANG['TXT_THEME_OPERATION_FAILED_FOR_VIRTUAL_FOLDER']);
     }
     if (!\Cx\Lib\FileSystem\FileSystem::exists($currentThemeFolderDirPath . $newFileName)) {
         if ($params['post']['isFolder']) {
             $status = \Cx\Lib\FileSystem\FileSystem::make_folder($currentThemeFolderDirPath . $newFileName);
             $succesMessage = sprintf($_ARRAYLANG['TXT_THEME_FOLDER_CREATE_SUCCESS'], contrexx_input2xhtml($newFileName));
         } else {
             $status = \Cx\Lib\FileSystem\FileSystem::touch($currentThemeFolderDirPath . $newFileName);
             $succesMessage = sprintf($_ARRAYLANG['TXT_THEME_FILE_CREATE_SUCCESS'], contrexx_input2xhtml($newFileName));
         }
         if (!$status) {
             return array('status' => 'error', 'message' => $_ARRAYLANG['TXT_THEME_NEWFILE_FAILED']);
         }
         return array('status' => 'success', 'reload' => true, 'message' => $succesMessage, 'path' => '/' . $newFileName);
     }
     return array('status' => 'error', 'message' => sprintf($_ARRAYLANG['TXT_THEME_OPERATION_FAILED_FOR_FILE_ALREADY_EXITS'], contrexx_input2xhtml($newFileName)));
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:53,代码来源:JsonViewManager.class.php


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