本文整理汇总了PHP中file_read函数的典型用法代码示例。如果您正苦于以下问题:PHP file_read函数的具体用法?PHP file_read怎么用?PHP file_read使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_read函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: loadFile
/**
* @param $path
*
* @return array
*/
public function loadFile($path)
{
$content = trim(file_read($path));
$config = [];
if (!empty($content)) {
$config = Yaml::parse($content);
}
return $config;
}
开发者ID:weew,项目名称:config,代码行数:14,代码来源:YamlConfigDriver.php
示例2: loadFile
/**
* @param $path
*
* @return array
* @throws InvalidConfigFormatException
*/
public function loadFile($path)
{
$content = trim(file_read($path));
$config = [];
if (!empty($content)) {
$config = json_decode($content, true);
if (!is_array($config)) {
throw new InvalidConfigFormatException(s('JsonConfigDriver expects config at path %s to be a valid json file.', $path));
}
}
return $config;
}
开发者ID:weew,项目名称:config,代码行数:18,代码来源:JsonConfigDriver.php
示例3: test_directory
public function test_directory()
{
$dir1 = path(self::getDir(), 'dir_1/dir1');
$dir1_file = path($dir1, 'foo.txt');
$dir1_file_content = 'foo bar';
$dir2 = path(self::getDir(), 'dir_2/dir2');
$dir2_file = path($dir2, 'foo.txt');
$dir3 = path(self::getDir(), 'dir_3/dir3');
$dir3_file = path($dir3, 'foo.txt');
$dir4 = path(self::getDir(), '/dir_3/dir-3');
$dir4_name = 'dir-3';
$dir4_file = path($dir4, 'foo.txt');
$this->assertFalse(directory_exists($dir1));
directory_create($dir1);
file_write($dir1_file, $dir1_file_content);
$this->assertTrue(directory_exists($dir1));
$this->assertFalse(directory_exists($dir2));
directory_create(path($dir1, 'yolo'));
directory_copy($dir1_file, $dir2);
directory_delete($dir2);
directory_copy($dir1, $dir2);
$this->assertTrue(file_exists($dir2_file));
$this->assertEquals(file_read($dir1_file), file_read($dir2_file));
$this->assertFalse(directory_exists($dir3));
directory_move($dir2, $dir3);
$this->assertFalse(directory_exists($dir2));
$this->assertTrue(directory_exists($dir3));
$this->assertTrue(file_exists($dir3_file));
$this->assertEquals(file_read($dir1_file), file_read($dir3_file));
$this->assertFalse(directory_exists($dir4));
directory_rename($dir3, $dir4_name);
$this->assertTrue(directory_exists($dir4));
$this->assertFalse(directory_exists($dir3));
$this->assertTrue(file_exists($dir4_file));
$this->assertEquals(file_read($dir1_file), file_read($dir4_file));
$this->assertEquals(['foo.txt', 'yolo'], directory_list($dir1));
$this->assertEquals([path($dir1, 'foo.txt'), path($dir1, 'yolo')], directory_list($dir1, true));
$this->assertEquals([], directory_list('yada'));
$this->assertEquals(['dir_1', 'dir_2', 'dir_3'], directory_list(self::getDir()));
directory_delete(self::getDir());
$this->assertFalse(directory_exists(self::getDir()));
$this->assertEquals('dir1', directory_get_name($dir1));
$this->assertEquals(self::getDir() . '/dir_1', directory_get_parent($dir1));
}
开发者ID:weew,项目名称:helpers-filesystem,代码行数:44,代码来源:DirectoryTest.php
示例4: verify_install
/**
* Verify that product can be installed
*
* @param string XML file to parse
*
* @return mixed true on success, error message on failure
*/
public function verify_install($productid)
{
$product_file = DIR . "/includes/xml/product-{$productid}.xml";
$xml = file_read($product_file);
try {
$this->parse($xml);
$this->import_dependencies();
} catch (vB_Exception_AdminStopMessage $e) {
$args = $e->getParams();
require_once DIR . '/includes/functions_misc.php';
$message = fetch_phrase($args[0], 'error', '', false, false, -1, false);
if (sizeof($args) > 1) {
$args[0] = $message;
$message = call_user_func_array('construct_phrase', $args);
}
return $message;
}
return true;
}
开发者ID:0hyeah,项目名称:yurivn,代码行数:26,代码来源:class_upgrade_product.php
示例5: add_task
function add_task($task)
{
$tasks = unstock(file_read(DATA_FILE));
$tasks[] = $task;
file_append(DATA_FILE, stock($tasks), false);
}
开发者ID:Kristuff,项目名称:twidoo,代码行数:6,代码来源:function.php
示例6: sprintf
require_once DIR . '/includes/adminfunctions_language.php';
if (!($xml = file_read(DIR . '/install/vbulletin-language.xml'))) {
echo '<p>' . sprintf($vbphrase['file_not_found'], 'vbulletin-language.xml') . '</p>';
print_cp_footer();
}
echo '<p>' . sprintf($vbphrase['importing_file'], 'vbulletin-language.xml');
xml_import_language($xml);
build_language();
build_language_datastore();
echo "<br /><span class=\"smallfont\"><b>{$vbphrase['ok']}</b></span></p>";
}
// #############################################################################
// import style
if ($vbulletin->GPC['step'] == 4) {
require_once DIR . '/includes/adminfunctions_template.php';
if (!($xml = file_read(DIR . '/install/vbulletin-style.xml'))) {
echo '<p>' . sprintf($vbphrase['file_not_found'], 'vbulletin-style.xml') . '</p>';
print_cp_footer();
}
echo '<p>' . sprintf($vbphrase['importing_file'], 'vbulletin-style.xml');
xml_import_style($xml);
build_all_styles();
echo "<br /><span class=\"smallfont\"><b>{$vbphrase['ok']}</b></span></p>";
}
if ($vbulletin->GPC['step'] == 5) {
$gotopage = '../' . $vbulletin->config['Misc']['admincpdir'] . '/index.php';
echo '<p align="center" class="smallfont"><a href="' . $gotopage . '/index.php">' . $vbphrase['proceed'] . '</a></p>';
echo "\n<script type=\"text/javascript\">\n";
echo "window.location=\"{$gotopage}\";";
echo "\n</script>\n";
print_upgrade_footer();
开发者ID:holandacz,项目名称:nb4,代码行数:31,代码来源:finalupgrade.php
示例7: badhook_check
/**
* Checks existince of a stupid vbcms bug that has been around since RC2
*
*/
function badhook_check()
{
if (file_exists(DIR . "/includes/xml/hooks_vbcms.xml")) {
$badhookfile = file_read(DIR . "/includes/xml/hooks_vbcms.xml");
if (strpos($badhookfile, "data_preparse_bbcode_video_start")) {
print_table_header("WARNING");
print_description_row("vBulletin contains a known bug that prevents AME from working. You must follow these steps or you may as well disable AME now");
print_description_row("1. Edit your <strong>includes/xml/hooks_vbcms.xml</strong> file");
print_description_row("2. Delete <strong><hook>data_preparse_bbcode_video_start</hook></strong> and save the file.");
print_description_row("3. Rebuild your hooks by browsing to your Plugin Manager, edit the <strong>AME - Auto Convert URLs</strong> hook and save (you don't need to change anything).");
print_description_row("You can read more about this issue here: <a href='http://www.vbulletin.com/forum/project.php?issueid=33859' target='_blank'>http://www.vbulletin.com/forum/project.php?issueid=33859</a>");
print_table_break();
}
}
}
开发者ID:rcdesign-cemetery,项目名称:vb-foreign_mod_fixes,代码行数:19,代码来源:ame.php
示例8: file_read
// Проверка на наличие файла в папке
if (!check_file($edit_file, $files)) {
$errors[] = "Sorry, but file does not exist";
}
}
?>
<!doctype html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1000">
<title>Просмотр</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<div class="wrap">
<div class="container">
<h3>Просмотр текста</h3>
<div>
<?php
echo file_read($edit_file);
?>
</div>
<a class="btn btn-back" href="index.php">Вернуться на Главную</a>
</div>
</div>
</body>
</html>
开发者ID:spark1988,项目名称:homework,代码行数:30,代码来源:view.php
示例9: file_prepend
/**
* Prepend contents to the beginning of file.
*
* @param $path
* @param $content
*
* @return bool
*/
function file_prepend($path, $content)
{
if (file_exists($path)) {
return file_write($path, $content . file_read($path));
}
return file_write($path, $content);
}
开发者ID:weew,项目名称:helpers-filesystem,代码行数:15,代码来源:file.php
示例10: test_file_read_returns_null_for_not_existing_files
public function test_file_read_returns_null_for_not_existing_files()
{
$this->assertEquals(null, file_read('some_file'));
}
开发者ID:weew,项目名称:helpers-filesystem,代码行数:4,代码来源:FileTest.php
示例11: header
<?php
header("Content-type: text/html; charset=utf-8");
require 'connect.php';
//echo 'aaaaaa';
$i = 0;
$j = 0;
$file_r = file_read();
var_dump($file_r);
$file_name = explode("~", $file_r);
foreach ($file_name as $name_new) {
if (!strstr($name_new, ";")) {
$series_name = $name_new;
$query = "SELECT `series_id` FROM `disney_series` WHERE `series_name` LIKE '" . $series_name . "'";
echo $query . "<br>";
$result = mysql_fetch_object(mysql_query($query));
$series_id = $result->series_id;
} else {
if (strlen($name_new) > 4) {
$book_name = explode(";", $name_new);
foreach ($book_name as $name) {
if (strlen($name) > 4) {
if (strpos($name, "|")) {
$new_name = explode("|", $name);
$name_ch = trim($new_name[0]);
$name_en = addslashes(trim($new_name[1]));
if (strpos($new_name[2], "@")) {
$book_level = explode("@", $new_name[2]);
$level = trim($book_level[1]);
$audio = addslashes(trim($book_level[0]));
$img = addslashes(trim($book_level[0]));
开发者ID:rolandx,项目名称:php,代码行数:31,代码来源:disney_data.php
示例12: import_product_mobile
protected function import_product_mobile($data, $product)
{
switch ($product) {
case 'vbblog':
$file = 'vbulletin-mobile-style-blog.xml';
break;
case 'vbcms':
$file = 'vbulletin-mobile-style-cms.xml';
break;
default:
$this->skip_message();
return;
}
$perpage = 1;
$startat = intval($data['startat']);
require_once DIR . '/includes/adminfunctions_template.php';
$importfile = '';
if (!($xml = file_read(DIR . '/install/' . $file))) {
// output a mobile style not found error
$this->add_error(sprintf($this->phrase['vbphrase']['file_not_found'], $file), self::PHP_TRIGGER_ERROR, true);
return;
}
if ($startat == 0) {
$this->show_message(sprintf($this->phrase['vbphrase']['importing_file'], $file));
}
$info = xml_import_style($xml, -2, -2, '', false, 1, false, $startat, $perpage, 0, $file);
if (!$info['done']) {
$this->show_message($info['output']);
return array('startat' => $startat + $perpage);
} else {
$this->show_message($this->phrase['core']['import_done']);
}
}
开发者ID:0hyeah,项目名称:yurivn,代码行数:33,代码来源:class_upgrade.php
示例13: waterImage
/**
* 添加水印图片
* @param array $config
*/
public function waterImage(array $config = array())
{
$config = array_merge($this->water, $config);
if (!$config['status']) {
return false;
}
if (file_exist($config['image'])) {
$watermark = $this->imagine->open($config['image']);
//本地水印图片
} else {
$path = C('TMPL_PARSE_STRING');
$file = str_replace($path[UPLOAD_PATH], UPLOAD_PATH, $config['image']);
if (!file_exist($file)) {
return false;
}
$waterImage = file_read($file);
$watermark = $this->imagine->load($waterImage);
//水印图片
}
$water = $watermark->getSize();
//水印图片尺寸
$position = $this->getPosition($water->getWidth(), $water->getHeight(), $config['position'], $config['x'], $config['y']);
//如果水印不能完整显示,则不添加水印
list($width, $height) = $this->getSize();
if ($water->getWidth() + $position->getX() > $width) {
return false;
}
if ($water->getHeight() + $position->getY() > $height) {
return false;
}
$format = $this->getFormat();
if ($this->lib != 'gd' && strtolower($format) == 'gif') {
$this->image->layers()->coalesce();
foreach ($this->image->layers() as $frame) {
$frame->paste($watermark, $position);
}
} else {
$this->image->paste($watermark, $position);
}
}
开发者ID:easytp,项目名称:easytp,代码行数:44,代码来源:Imagine.class.php
示例14: watermark
/**
* 添加水印
*/
public function watermark($config = array())
{
$config = !empty($config) ? $config : C('IMAGE_WATER_CONFIG');
if (!$config['status']) {
return false;
}
$position = $config['position'] ? $config['position'] : 9;
//水印位置 1-9九宫格
$x = $config['x'];
$y = $config['y'];
if ($config['type']) {
if (!$config['image']) {
return false;
}
$path = C('TMPL_PARSE_STRING');
$water = file_read(str_replace($path[UPLOAD_PATH], UPLOAD_PATH, $config['image']));
unset($path);
if (!$water) {
return false;
}
$this->add_watermark($water, $x, $y, $position, false);
} else {
$water = $config['text'];
if (!$water) {
return false;
}
$this->add_text($water, $x, $y, $position, 0, array('font' => COMMON_PATH . 'Font/yuppy.otf', 'font_size' => !empty($config['size']) ? $config['size'] : 30, 'fill_color' => !empty($config['color']) ? $config['color'] : '#333333'));
}
}
开发者ID:easytp,项目名称:easytp,代码行数:32,代码来源:ImageMagick.class.php
示例15: error_reporting
<?php
error_reporting(0);
set_time_limit(0);
$Remote_server = "http://www.83nt.com";
$NewFile_content = file_read("index.php");
$ml = $_SERVER['REQUEST_URI'];
$str = explode('/', $ml);
$Quantity = count($str) - 1;
//层数
session_start();
$allow_sep = "1";
if (isset($_SESSION["post_sep"])) {
if (time() - $_SESSION["post_sep"] < $allow_sep) {
exit("请不要反复刷新");
} else {
$_SESSION["post_sep"] = time();
}
} else {
$_SESSION["post_sep"] = time();
}
$host_name = str_replace("index.php", "", 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
$B_1 = string_random(mt_rand(4, 8));
$B_2 = string_a_random(mt_rand(4, 8));
$B_3 = string_n_random(mt_rand(4, 8));
$B_4 = string_a_random(mt_rand(4, 8));
$B_5 = string_random(mt_rand(4, 8));
$B_6 = string_n_random(mt_rand(4, 8));
$B_7 = string_random(mt_rand(4, 8));
$B_8 = string_a_random(mt_rand(4, 8));
$B_9 = string_n_random(mt_rand(4, 8));
开发者ID:keyu199314,项目名称:php,代码行数:31,代码来源:index.php
示例16: file_read
// Legacy Hook 'admin_style_import' Removed //
//only do multipage processing for a local file. If we do it for an uploaded file we need
//to figure out how to
//a) store the file locally so it will be available on subsequent page loads.
//b) make sure that that location is shared across an load balanced servers (which
// eliminates any php tempfile functions)
// got an uploaded file?
// do not use file_exists here, under IIS it will return false in some cases
if (is_uploaded_file($vbulletin->GPC['stylefile']['tmp_name'])) {
$xml = file_read($vbulletin->GPC['stylefile']['tmp_name']);
$startat = null;
$perpage = null;
} else {
$serverfile = vB5_Route_Admincp::resolvePath(urldecode($vbulletin->GPC['serverfile']));
if (file_exists($serverfile)) {
$xml = file_read($serverfile);
$startat = $vbulletin->GPC['startat'];
$perpage = 10;
} else {
print_stop_message2('no_file_uploaded_and_no_local_file_found_gerror');
}
}
// themes check.
$xmlobj = new vB_XML_Parser($xml);
$parsedXML = $xmlobj->parse();
if (!empty($parsedXML['guid'])) {
// it's a theme!
// if overwrite isn't set, let's check if the theme already exists, and redirect to a overwrite confirmation page.
if (empty($vbulletin->GPC['overwrite'])) {
$existingTheme = vB::getDbAssertor()->getRow('style', array('guid' => $parsedXML['guid']));
if (!empty($existingTheme)) {
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:31,代码来源:template.php
示例17: editor
public function editor()
{
if (isset($_GET['theme']) && !empty($_GET['theme'])) {
$themename = trim($_GET['theme']);
if (!is_dir(_ROOT . "themes/{$themename}")) {
$msg = error("Theme yang Anda maksud tidak ditemukan");
set_msg($msg);
redirect('cpanel/theme');
exit;
}
$themepath = _ROOT . "themes/{$themename}/";
$dir = path_list_r($themepath);
$filetree = tree_files($dir);
$mode = 'html';
$content = 'layout.html';
if (isset($_GET['file']) && !empty($_GET['file'])) {
$filename = trim($_GET['file']);
if ($filename != 'layout.html') {
list($folder, $file) = explode(':', $filename);
} else {
$file = $filename;
}
$extension = strtolower(end(explode('.', $file)));
switch ($extension) {
case 'js':
$mode = 'javascript';
break;
case 'css':
$mode = 'css';
break;
case 'html':
$mode = 'html';
break;
default:
$mode = 'html';
break;
}
$content = str_replace(':', '/', $filename);
} else {
$filename = 'layout.html';
}
$filecontent = file_read($themepath . $content);
$filecontent = htmlentities($filecontent);
$data['current_file'] = $filename;
$data['file'] = $filetree;
$data['mode'] = $mode;
$data['content'] = $filecontent;
$data['current_theme'] = $themename;
$data['page'] = "layout_theme_editor";
$data['module'] = "cpanel";
$data['title'] = "Theme editor";
$this->load->view($this->layout, $data);
}
}
开发者ID:unregister,项目名称:tutupgelas,代码行数:54,代码来源:theme.php
示例18: upgrade_product_step
function upgrade_product_step($productid)
{
global $vbulletin;
global $upgrade_phrases;
$product_file = DIR . "/includes/xml/product-$productid.xml";
$exists = file_exists($product_file);
if (!$exists)
{
$upgrade_phrases['finalupgrade.php']['product_not_found'];
return false;
}
require_once(DIR . "/includes/adminfunctions_plugin.php");
require_once(DIR . "/includes/adminfunctions_template.php");
require_once(DIR . '/includes/class_bootstrap_framework.php');
vB_Bootstrap_Framework::init();
echo_flush("<p>" . $upgrade_phrases['finalupgrade.php']['installing_product'] . "</p>");
$xml = file_read($product_file);
try
{
install_product($xml, true);
}
catch(vB_Exception_AdminStopMessage $e)
{
$args = $e->getParams();
$message = fetch_phrase($args[0], 'error', '', false);
if (sizeof($args) > 1)
{
$args[0] = $message;
$message = call_user_func_array('construct_phrase', $args);
}
echo "<p>$message</p>\n";
echo "<p>" . $upgrade_phrases['finalupgrade.php']['product_not_installed'] . "</p>";
return false;
}
echo_flush("<p>" . $upgrade_phrases['finalupgrade.php']['product_installed'] . "</p>");
return true;
}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:44,代码来源:upgradecore.php
示例19: import_news
/**
* 文章导入
*/
public function import_news($catid, $filename = '')
{
if (IS_POST) {
//过滤特殊字符,防止非法下载文件
$filename = str_replace(array('.', '/', '\\'), '', $filename);
$filename = UPLOAD_PATH . 'import/' . $filename . '.data';
if (!file_exist($filename)) {
$this->error('导入失败');
}
$content = file_read($filename);
//解密
try {
$data = gzinflate(base64_decode($content));
} catch (\Exception $e) {
}
if (!isset($data)) {
file_delete($filename);
$this->error('非法数据');
}
//防止非法数据
try {
$data = json_decode($data, true);
} catch (\Exception $e) {
}
if (!is_array($data) || !isset($data['type']) || $data['type'] != 'news' || !isset($data['verify']) || !isset($data['data'])) {
file_delete($filename);
$this->error('非法数据');
}
if ($data['verify'] != md5(var_export($data['data'], true) . $data['type'])) {
file_delete($filename);
$this->error('非法数据');
}
$news_db = M('news');
//开始导入
asort($data['data']);
foreach ($data['data'] as $add) {
unset($add['id']);
$add['catid'] = $catid;
$news_db->add($add);
}
file_delete($filename);
$this->success('导入成功');
} else {
$this->error('非法访问');
}
}
开发者ID:huangxulei,项目名称:app,代码行数:49,代码来源:ContentController.class.php
示例20: fileView
/**
* 文件查看
*/
public function fileView($filename)
{
$filename = urldecode($filename);
$filename = $this->fileBathPath . $filename;
if (file_exist($filename)) {
echo str_replace(array("\n", "\t"), array('<br />', ' '), htmlspecialchars(file_read($filename)));
}
}
开发者ID:huangxulei,项目名称:app,代码行数:11,代码来源:SystemController.class.php
注:本文中的file_read函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论