本文整理汇总了PHP中Bitrix\Main\IO\File类的典型用法代码示例。如果您正苦于以下问题:PHP File类的具体用法?PHP File怎么用?PHP File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了File类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showTab
public static function showTab($div, $iblockElementInfo)
{
$engineList = array();
if (Option::get('main', 'vendor', '') == '1c_bitrix') {
$engineList[] = array("DIV" => "yandex_direct", "TAB" => Loc::getMessage("SEO_ADV_YANDEX_DIRECT"), "TITLE" => Loc::getMessage("SEO_ADV_YANDEX_DIRECT_TITLE"), "HANDLER" => IO\Path::combine(Application::getDocumentRoot(), BX_ROOT, "/modules/seo/admin/tab/seo_search_yandex_direct.php"));
}
if (count($engineList) > 0) {
$engineTabControl = new \CAdminViewTabControl("engineTabControl", $engineList);
?>
<tr>
<td colspan="2">
<?php
$engineTabControl->begin();
foreach ($engineList as $engineTab) {
$engineTabControl->beginNextTab();
$file = new IO\File($engineTab["HANDLER"]);
if ($file->isExists()) {
require $file->getPath();
}
}
$engineTabControl->end();
?>
</td>
</tr>
<?php
}
}
示例2: seoSitemapGetFilesData
function seoSitemapGetFilesData($PID, $arSitemap, $arCurrentDir, $sitemapFile)
{
global $NS;
$arDirList = array();
if ($arCurrentDir['ACTIVE'] == SitemapRuntimeTable::ACTIVE) {
$list = \CSeoUtils::getDirStructure($arSitemap['SETTINGS']['logical'] == 'Y', $arSitemap['SITE_ID'], $arCurrentDir['ITEM_PATH']);
foreach ($list as $dir) {
$dirKey = "/" . ltrim($dir['DATA']['ABS_PATH'], "/");
if ($dir['TYPE'] == 'F') {
if (!isset($arSitemap['SETTINGS']['FILE'][$dirKey]) || $arSitemap['SETTINGS']['FILE'][$dirKey] == 'Y') {
if (preg_match($arSitemap['SETTINGS']['FILE_MASK_REGEXP'], $dir['FILE'])) {
$f = new IO\File($dir['DATA']['PATH'], $arSitemap['SITE_ID']);
$sitemapFile->addFileEntry($f);
$NS['files_count']++;
}
}
} else {
if (!isset($arSitemap['SETTINGS']['DIR'][$dirKey]) || $arSitemap['SETTINGS']['DIR'][$dirKey] == 'Y') {
$arDirList[] = $dirKey;
}
}
}
} else {
$len = strlen($arCurrentDir['ITEM_PATH']);
if (!empty($arSitemap['SETTINGS']['DIR'])) {
foreach ($arSitemap['SETTINGS']['DIR'] as $dirKey => $checked) {
if ($checked == 'Y') {
if (strncmp($arCurrentDir['ITEM_PATH'], $dirKey, $len) === 0) {
$arDirList[] = $dirKey;
}
}
}
}
if (!empty($arSitemap['SETTINGS']['FILE'])) {
foreach ($arSitemap['SETTINGS']['FILE'] as $dirKey => $checked) {
if ($checked == 'Y') {
if (strncmp($arCurrentDir['ITEM_PATH'], $dirKey, $len) === 0) {
$fileName = IO\Path::combine(SiteTable::getDocumentRoot($arSitemap['SITE_ID']), $dirKey);
if (!is_dir($fileName)) {
$f = new IO\File($fileName, $arSitemap['SITE_ID']);
if ($f->isExists() && !$f->isSystem() && preg_match($arSitemap['SETTINGS']['FILE_MASK_REGEXP'], $f->getName())) {
$sitemapFile->addFileEntry($f);
$NS['files_count']++;
}
}
}
}
}
}
}
if (count($arDirList) > 0) {
foreach ($arDirList as $dirKey) {
$arRuntimeData = array('PID' => $PID, 'ITEM_PATH' => $dirKey, 'PROCESSED' => SitemapRuntimeTable::UNPROCESSED, 'ACTIVE' => SitemapRuntimeTable::ACTIVE, 'ITEM_TYPE' => SitemapRuntimeTable::ITEM_TYPE_DIR);
SitemapRuntimeTable::add($arRuntimeData);
}
}
SitemapRuntimeTable::update($arCurrentDir['ID'], array('PROCESSED' => SitemapRuntimeTable::PROCESSED));
}
示例3: getRewriteRules
/**
* Returns urlrewrite array
*
* @param string $site Site ID.
* @return array
*/
private static function getRewriteRules($site)
{
$docRoot = rtrim(\Bitrix\Main\SiteTable::getDocumentRoot($site), '/');
$rewriteRules = array();
$arUrlRewrite =& $rewriteRules;
$rewriteFile = new IO\File($docRoot . '/urlrewrite.php');
if ($rewriteFile->isExists()) {
include $rewriteFile->getPath();
}
return $rewriteRules;
}
示例4: __construct
/**
* FileAccessManager constructor.
*
* @param string $path Full path to file .access.php
*
* @throws InvalidPathException Invalid path to file.
*/
public function __construct($path)
{
if (empty($path)) {
throw new InvalidPathException($path);
}
$this->path = $path;
$file = new File($path);
if ($file->getName() === '.access.php') {
$this->isFileAccess = true;
}
}
示例5: finish
public function finish()
{
foreach ($this->partList as $key => $partName) {
$f = new File(Path::combine($this->getDirectoryName(), $partName));
$f->rename(str_replace($this->getPrefix(), '', $f->getPath()));
$this->partList[$key] = $f->getName();
}
if ($this->isCurrentPartNotEmpty()) {
$this->addFooter();
$this->rename(str_replace($this->getPrefix(), '', $this->getPath()));
}
}
示例6: prepareDataToInsertFromFileArray
protected static function prepareDataToInsertFromFileArray(array $fileData, array $data, ErrorCollection $errorCollection)
{
list($relativePath, $absolutePath) = self::generatePath();
$file = new IO\File($fileData['tmp_name']);
if (!$file->isExists()) {
$errorCollection->addOne(new Error('Could not find file', self::ERROR_EXISTS_FILE));
return null;
}
if (!$file->rename($absolutePath)) {
$errorCollection->addOne(new Error('Could not move file', self::ERROR_MOVE_FILE));
return null;
}
//now you can set CREATED_BY
$data = array_intersect_key($data, array('CREATED_BY' => true));
return array_merge(array('TOKEN' => bx_basename($relativePath), 'FILENAME' => $fileData['name'], 'PATH' => $relativePath, 'BUCKET_ID' => '', 'SIZE' => '', 'IS_CLOUD' => '', 'WIDTH' => empty($fileData['width']) ? '' : $fileData['width'], 'HEIGHT' => empty($fileData['height']) ? '' : $fileData['height']), $data);
}
示例7: isRequestedUriExists
private function isRequestedUriExists()
{
/** @var $request HttpRequest */
$request = $this->getContext()->getRequest();
$absUrl = IO\Path::convertRelativeToAbsolute($request->getRequestedPage());
return IO\File::isFileExists($absUrl);
}
示例8: writeStatistic
/**
* Updates cache usage statistics.
* Each of parameters is added to appropriate existing stats.
*
* @param int $hit
* @param int $miss
* @param int $quota
* @param int $posts
* @param float $files
* @return void
*/
public function writeStatistic($hit = 0, $miss = 0, $quota = 0, $posts = 0, $files = 0.0)
{
$fileValues = $this->readStatistic();
if ($fileValues) {
$newValues = array(intval($fileValues["HITS"]) + $hit, intval($fileValues["MISSES"]) + $miss, intval($fileValues["QUOTA"]) + $quota, intval($fileValues["POSTS"]) + $posts, $files === false ? 0 : doubleval($fileValues["FILE_SIZE"]) + doubleval($files));
$this->statFile->putContents(implode(",", $newValues));
}
}
示例9: createMap
private function createMap()
{
$mapFilePath = Application::getDocumentRoot() . "/bitrix/modules/mobileapp/maps/config.php";
$file = new File($mapFilePath);
if (!$file->isExists()) {
throw new SystemException("The map file '" . $mapFilePath . "' doesn't exists!", 100);
}
$map = (include $mapFilePath);
if (!is_array($map)) {
throw new SystemException("The map file does exist but has some broken structure.", 101);
}
self::$configMap = $map;
self::$configMap["groups"] = array();
$groupTypes = array(ParameterType::GROUP, ParameterType::GROUP_BACKGROUND, ParameterType::GROUP_BACKGROUND_LIGHT);
foreach ($map["types"] as $paramName => $intType) {
if (in_array($intType, $groupTypes)) {
self::$configMap["groups"][] = $paramName;
}
}
}
示例10: __construct
public function __construct($type)
{
parent::__construct();
$type = trim(strtolower($type), '.');
if (!$this->issetType($type)) {
throw new SystemException("Could not find type '{$type}' in BlankFile");
}
$typeData = $this->getType($type);
$this->name = $typeData['newFileName'] . $typeData['ext'];
$this->mimeType = TypeFile::getMimeTypeByFilename($this->name);
$this->src = $typeData['src'];
$this->size = IO\File::isFileExists($typeData['src']) ? filesize($typeData['src']) : 0;
}
示例11: saveRules
private static function saveRules($siteId, array $arUrlRewrite)
{
$site = SiteTable::getRow(array("filter" => array("LID" => $siteId)));
$docRoot = $site["DOC_ROOT"];
if (!empty($docRoot)) {
$docRoot = IO\Path::normalize($docRoot);
} else {
$docRoot = Application::getDocumentRoot();
}
$data = var_export($arUrlRewrite, true);
IO\File::putFileContents($docRoot . "/urlrewrite.php", "<" . "?php\n\$arUrlRewrite=" . $data . ";\n");
Application::resetAccelerator();
}
示例12: renderExceptionMessage
function renderExceptionMessage(\Exception $exception, $debug = false)
{
if ($debug) {
echo ExceptionHandlerFormatter::format($exception, true);
} else {
$p = Main\IO\Path::convertRelativeToAbsolute("/error.php");
if (Main\IO\File::isFileExists($p)) {
include $p;
} else {
$context = Main\Application::getInstance();
if ($context) {
echo Main\Localization\Loc::getMessage("eho_render_exception_message");
} else {
echo "A error occurred during execution of this script. You can turn on extended error reporting in .settings.php file.";
}
}
}
}
示例13: initScripts
/**
* Sets viewport-metadata
*/
public static function initScripts()
{
global $APPLICATION;
\CJSCore::Init();
$APPLICATION->AddHeadString("<script type=\"text/javascript\">var mobileSiteDir=\"" . SITE_DIR . "\"; var appVersion = " . self::$apiVersion . ";var platform = \"" . self::$platform . "\";</script>", false, true);
if (self::$platform == "android") {
/**
* This is workaround for android
* We use console.log() to tell the application about successful loading of this page
*/
$APPLICATION->AddHeadString("<script type=\"text/javascript\">console.log(\"bxdata://success\")</script>", false, true);
}
if (self::getInstance()->getBXScriptSupported()) {
/**
* If the application tells us bxscript-feature is available
* it means that device can load cordova-scripts (including plugins) itself.
*/
$pgJsFile = "/bitrix/js/mobileapp/__deviceload__/cordova.js";
$APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . $pgJsFile . "\"></script>", false, true);
} else {
$pgJsFile = "/bitrix/js/mobileapp/" . self::$platform . "-cordova-" . self::$pgVersion . ".js";
if (!File::isFileExists(Application::getDocumentRoot() . $pgJsFile)) {
$pgJsFile = self::$remoteScriptPath . self::$platform . "-cordova-" . self::$pgVersion . ".js";
}
$APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . \CUtil::GetAdditionalFileURL($pgJsFile) . "\"></script>", false, true);
}
$APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . \CUtil::GetAdditionalFileURL("/bitrix/js/mobileapp/bitrix_mobile.js") . "\"></script>", false, true);
$APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . \CUtil::GetAdditionalFileURL("/bitrix/js/mobileapp/mobile_lib.js") . "\"></script>", false, true);
if (self::$platform == "android") {
$APPLICATION->AddHeadString("<script type=\"text/javascript\">app.bindloadPageBlank();</script>", false, false);
}
$APPLICATION->AddHeadString(Mobile::getInstance()->getViewPort());
}
示例14: download
/**
* Downloads and saves a file.
*
* @param string $url URI to download
* @param string $filePath Absolute file path
* @return bool
*/
public function download($url, $filePath)
{
$dir = IO\Path::getDirectory($filePath);
IO\Directory::createDirectory($dir);
$file = new IO\File($filePath);
$handler = $file->open("w+");
if ($handler !== false) {
$this->setOutputStream($handler);
$res = $this->query(self::HTTP_GET, $url);
fclose($handler);
return $res;
}
return false;
}
示例15: isset
<?php
/** Bitrix Framework
* Bitrix vars
* @global CUser $USER
* @global CMain $APPLICATION
*/
use Bitrix\Main\IO\File;
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
if ($USER->IsAdmin()) {
$server = isset($_REQUEST['SERVER']) ? trim($_REQUEST['SERVER']) : false;
$param = isset($_REQUEST['PARAM']) ? trim($_REQUEST['PARAM']) : false;
$period = isset($_REQUEST['PERIOD']) ? trim($_REQUEST['PERIOD']) : false;
if ($server && $period && $param) {
$pathToImages = "/var/lib/munin";
$path = $pathToImages . '/' . $server . '/' . $server . '/' . $param . '-' . $period . '.png';
$f = new File($path);
if ($f->isExists()) {
header("Content-type: image/png");
echo $f->getContents();
}
}
}
die;