本文整理汇总了PHP中file::read方法的典型用法代码示例。如果您正苦于以下问题:PHP file::read方法的具体用法?PHP file::read怎么用?PHP file::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
public function install($path)
{
$module = @(include path::decode($path . DS . 'module.php'));
if (is_array($module)) {
$module['path'] = $path;
$module['url'] = $path;
if (!isset($module['icon'])) {
if (file::exists($path . '/icon.png')) {
$module['icon'] = $module['url'] . '/icon.png';
}
}
$module['type'] = empty($module['type']) ? 'plugin' : $module['type'];
$module['status'] = 0;
$module['order'] = $this->max('order') + 1;
$module['installtime'] = TIME;
$module['updatetime'] = TIME;
$insert = $this->insert($module);
}
if ($insert) {
$driver = $this->db()->config('driver');
$sqls = file::read($path . DS . 'install' . DS . $driver . '.sql');
if ($sqls) {
$this->db()->run($sqls);
}
}
return true;
}
示例2: actionLicense
public function actionLicense($path)
{
$module = zotop::model('zotop.module');
$modules = $module->getUnInstalled();
if (empty($path) || !dir::exists($path)) {
msg::error(array('content' => zotop::t('模块不存在,请确认是否已经上传该模块?'), 'description' => zotop::t("路径:{$path}")));
}
$licenseFile = $path . DS . 'license.txt';
if (!file::exists($licenseFile)) {
zotop::redirect('zotop/module/install', array('path' => url::encode($path)));
exit;
}
$license = file::read($licenseFile);
$page = new dialog();
$page->set('title', '许可协议');
$page->set('license', html::decode($license));
$page->set('next', zotop::url('zotop/module/install', array('path' => url::encode($path))));
$page->display();
}
示例3: onEdit
public function onEdit($file)
{
if (form::isPostBack()) {
$content = request::post('source');
msg::success('保存测试', '测试,继续编辑或者返回' . zotop::dump($content, true), 'reload');
}
$source = file::read(ROOT . $file);
$page['title'] = '文件编辑器';
page::header($page);
page::top();
page::navbar($this->navbar());
form::header(array('class' => 'sourceEditor'));
form::field(array('type' => 'label', 'label' => zotop::t('文件名称'), 'name' => 'filename', 'value' => $file, 'valid' => '', 'description' => zotop::t('')));
form::field(array('type' => 'source', 'label' => zotop::t('文件内容'), 'name' => 'source', 'value' => $source, 'valid' => 'required:true', 'description' => zotop::t('')));
form::buttons(array('type' => 'submit', 'value' => '保存文件'), array('type' => 'back'));
form::footer();
page::bottom();
page::footer();
}
示例4: licenseAction
public function licenseAction($id)
{
$module = zotop::model('zotop.module');
$modules = $module->getUnInstalled();
if (empty($id) || !isset($modules[$id])) {
msg::error(zotop::t('ID为<b>{$id}</b>的模块不存在,请确认是否已经上传该模块?'));
}
$licenseFile = $modules[$id]['path'] . DS . 'license.txt';
if (!file::exists($licenseFile)) {
zotop::redirect('zotop/module/install', array('id' => $id));
exit;
}
$license = file::read($licenseFile);
$page = new dialog();
$page->set('title', '许可协议');
$page->set('license', html::decode($license));
$page->set('next', zotop::url('zotop/module/install', array('id' => $id)));
$page->display();
}
示例5: actionEditor
public function actionEditor($file = '')
{
$file = empty($file) ? zotop::get('file') : $file;
$file = trim(url::decode($file), '/');
$filepath = site::template($file);
if (form::isPostBack()) {
$filecontent = zotop::post('filecontent');
if (file::write($filepath, $filecontent)) {
msg::success('保存成功');
}
msg::error('保存失败');
}
$filecontent = file::read($filepath);
$page = new dialog();
$page->title = zotop::t('模板编辑器');
$page->set('file', $file);
$page->set('filepath', $filepath);
$page->set('filecontent', $filecontent);
$page->display();
}
示例6: family_name
static function family_name($real_name)
{
if (strlen($real_name) >= 6 && strlen($real_name) <= 15) {
if (regexp::match($real_name, 'chinese')) {
$first_name = substr($real_name, 0, 3);
$odd_family_name = file::read('family_name', 1);
$odd_data = str_split($odd_family_name[0], 3);
if (in_array($first_name, $odd_data)) {
return true;
}
$first_name = substr($real_name, 0, 6);
$even_family_name = file::read('family_name', 2);
$even_data = explode(',', $even_family_name);
if (in_array($first_name, $even_data)) {
return true;
}
}
}
return false;
}
示例7: actionEdit
public function actionEdit($file = '')
{
$file = empty($file) ? zotop::get('file') : $file;
$file = trim(url::decode($file), '/');
$filepath = ZOTOP_PATH_ROOT . DS . str_replace('/', DS, $file);
if (form::isPostBack()) {
$content = request::post('source');
$content = trim($content);
if (empty($content)) {
msg::error('内容为空,无法保存!');
}
file::write($filepath, trim($content));
msg::success('内容保存成功!');
}
$filecontent = file::read($filepath);
$page = new dialog();
$page->title = '文件编辑器';
$page->set('file', $file);
$page->set('filepath', $filepath);
$page->set('filecontent', $filecontent);
$page->display();
}
示例8: actionEdit
public function actionEdit($file)
{
$filepath = realpath(ZOTOP_PATH_ROOT . DS . trim($file, '/'));
if (empty($file)) {
return false;
}
if (form::isPostBack()) {
$content = request::post('source');
$content = trim($content);
if (empty($content)) {
msg::error('内容为空,无法保存!');
}
file::write($filepath, trim($content));
msg::success('内容保存成功!');
}
$content = file::read($filepath);
$page = new dialog();
$page->title = '文件编辑器';
$page->set('file', $file);
$page->set('filepath', $filepath);
$page->set('content', $content);
$page->display();
}
示例9: getBody
/**
* Get the body content
*
* @param string|null $headers Header to edit or null to add the header in the email
* @return string
*/
protected function getBody(&$headers = null)
{
$body = null;
//$text = $this->quotePrintable($this->cfg->text);
$text = $this->cfg->text;
if ($this->cfg->html) {
if (empty($this->cfg->text)) {
//$text = $this->quotePrintable(utils::html2Text($this->cfg->html));
$text = utils::html2Text($this->cfg->html);
}
$boundary = '------------' . $this->getBoundary();
if ($headers) {
$headers .= $this->headerLine('Content-Type', 'multipart/alternative;' . $this->cfg->crlf . ' boundary="' . $boundary . '"');
//$headers.= $this->textLine(' boundary="'.$boundary.'"');
} else {
$body .= $this->headerLine('Content-Type', 'multipart/alternative;' . $this->cfg->crlf . ' boundary="' . $boundary . '"');
//$body.= $this->textLine(' boundary="'.$boundary.'"');
$body .= $this->textLine('');
}
// Text part
$body .= $this->textLine('This is a multi-part message in MIME format.');
$body .= $this->textLine('--' . $boundary);
}
$body .= $this->headerLine('Content-Type', 'text/plain; charset=' . $this->cfg->charset);
//$body.= $this->textLine(' charset="'.$this->cfg->charset.'"');
$body .= $this->headerLine('Content-Transfer-Encoding', $this->cfg->encoding);
//$body.= $this->headerLine('Content-Disposition', 'inline');
$body .= $this->textLine(null);
$body .= $this->textLine($this->encode($this->wrapText($text)));
if ($this->cfg->html) {
// HTML part
$body .= $this->textLine('--' . $boundary);
$html = $this->cfg->html;
$inlineImages = false;
if ($this->cfg->htmlInlineImage) {
$rootUri = request::get('rootUri');
preg_match_all('@src="(' . $rootUri . '|/)(.+)"@siU', $html, $matches);
if (!empty($matches)) {
$images = array_unique($matches[2]);
$inlineImages = array();
$i = 1;
foreach ($images as $img) {
if (file::webExists($img)) {
$file = WEBROOT . str_replace('/', DS, $img);
$cid = 'part' . $i . '.' . $this->getBoundary(16) . '@' . $this->cfg->serverName;
$inlineImages[] = array('cid' => $cid, 'file' => $file, 'name' => file::name($file), 'type' => file::getType($file));
$i++;
$html = preg_replace('@src="(' . $rootUri . '|/)(' . $img . ')"@siU', 'src="cid:' . $cid . '"', $html);
}
}
}
}
if (!empty($inlineImages)) {
$boundaryRel = '------------' . $this->getBoundary();
$body .= $this->headerLine('Content-Type', 'multipart/related;' . $this->cfg->crlf . ' boundary="' . $boundaryRel . '"');
//$body.= $this->textLine(' boundary="'.$boundaryRel.'"');
$body .= $this->textLine(null);
$body .= $this->textLine(null);
$body .= $this->textLine('--' . $boundaryRel);
}
$body .= $this->headerLine('Content-Type', 'text/html; charset=' . $this->cfg->charset . '');
//$body.= $this->textLine(' charset="'.$this->cfg->charset.'"');
$body .= $this->headerLine('Content-Transfer-Encoding', $this->cfg->encoding);
//$body.= $this->headerLine('Content-Disposition', 'inline');
$body .= $this->textLine(null);
//$body.= $this->textLine($this->quotePrintable($html));
$body .= $this->textLine($this->encode($this->wrapText($html)));
if (!empty($inlineImages)) {
foreach ($inlineImages as $img) {
$body .= $this->textLine('--' . $boundaryRel);
$body .= $this->headerLine('Content-Type', $img['type']);
//.'; name="'.$img['name'].'"');
$body .= $this->headerLine('Content-Transfer-Encoding', $this->cfg->fileEncoding);
$body .= $this->headerLine('Content-ID', '<' . $img['cid'] . '>');
//$body.= $this->headerLine('Content-Disposition', 'inline; filename="'.$img['name'].'"');
$body .= $this->textLine(null);
$body .= $this->encode(file::read($img['file']), $this->cfg->fileEncoding);
}
$body .= $this->textLine('--' . $boundaryRel . '--');
$body .= $this->textLine(null);
}
$body .= '--' . $boundary . '--';
}
return $body;
}
示例10: start
/**
* Try to get an output cached. If not found, information will be stored
* and used with the next call from end.
* The cache id is made with 5 kinds :
* - the $id passed to the function
* - the get, post, session or cookie variable if set
* - the class and function name where the cache is call
* - the tags if set
* - 'cache' is added (to differenciate from variable caching)
*
* @param array $prm Parameter for the cached variable:
* - int ttl: Time to live, in minutes, 0 for eternal (default: 60)
* - string id: Cache id (required)
* - array tags: Optionnal tags for the id
* - array request: Array for build the request ID (@see cache::idRequest)
* @return bool True if cache found and content printed
* @see end
*/
public function start(array $prm)
{
if ($this->isEnabled() && config::initTab($prm, array('ttl' => $this->cfg->ttl, 'id' => null, 'tags' => $this->cfg->tags, 'request' => $this->cfg->request))) {
$prm['file'] = $this->file(array_merge($prm, array('callFrom' => debug::callFrom(2), 'type' => 'cache')));
if (file::exists($prm['file']) && ($prm['ttl'] == 0 || file::date($prm['file']) + $prm['ttl'] * 60 > time())) {
echo file::read($prm['file']);
return true;
} else {
$this->obSave = '';
/*
if (ob_get_length()) {
$this->obSave = ob_get_contents();
ob_end_clean();
}
// */
ob_start();
$this->prmOut = $prm;
}
}
return false;
}
示例11: compile
public static function compile($file)
{
$content = file::read($file);
$content = trim($content);
//strip <?php
$content = substr($content, 5);
//strip <?php
if (strtolower(substr($content, -2)) == '?>') {
$content = substr($content, 0, -2);
}
return $content;
}
示例12: showFile
/**
* Show a file to the client
*
* @param string $file File Path
*/
public function showFile($file) {
if (file::exists($file)) {
$type = file::getType($file);
if (strpos($type, 'audio') === 0 || strpos($type, 'video') === 0) {
$this->mediaDownload($file);
} else {
$this->cfg->compress = false;
$this->neverExpire();
$this->addHeader('Last-Modified', gmdate('D, j M Y H:i:s', filemtime($file)).' GMT', true);
$this->addHeader('Content-Type', $type, true);
$this->addHeader('Cache-Control', 'public', false);
$this->addHeader('Pragma', null, false);
$this->addHeader('Content-length', file::size($file), true);
$this->sendText(file::read($file));
}
}
}
示例13: add
/**
* Add an include file
*
* @param array $prm Same parameter as addCss or addJs, with adding:
* - string type File type (js or css) (required)
* @return bool True if addedor already added, False if not found
* @throws nExecption if type or file not provided
* @see addJs, addCss
*/
public function add(array $prm) {
if (config::initTab($prm, array(
'type'=>null,
'file'=>null,
'dir'=>'nyro',
'media'=>'screen',
'condIE'=>false,
'verifExists'=>true
))) {
$ret = false;
$firstFile = $prm['file'];
if (strpos($firstFile, 'jquery') === 0 && $firstFile != 'jquery')
$this->addJS('jquery');
foreach($this->getDepend($prm['file'], $prm['type']) as $d) {
if (is_array($d))
$this->add(array_merge($prm, $d));
else
$this->add(array_merge($prm, array('file'=>$d)));
}
foreach($this->cfg->getInArray($prm['type'], 'alias') as $k=>$a) {
if (strtolower($prm['file']) == strtolower($k))
$prm['file'] = $a;
}
$prmType = $this->cfg->get($prm['type']);
$locDir = $prm['dir'];
if (!array_key_exists($locDir, $this->incFiles[$prm['type']]))
$locDir = 'nyro';
$fileExt = $prm['file'].'.'.$prm['type'];
if ($prm['verifExists'])
$fileExists = $locDir == 'web'
? file::webExists($prmType['dirWeb'].DS.$fileExt)
: file::nyroExists(array(
'name'=>'module_'.nyro::getCfg()->compressModule.'_'.$prm['type'].'_'.$prm['file'],
'type'=>'tpl',
'tplExt'=>$prm['type']
));
else
$fileExists = true;
if ($fileExists) {
if (!isset($this->incFiles[$prm['type']][$locDir][$prm['media']]))
$this->incFiles[$prm['type']][$locDir][$prm['media']] = array();
$this->incFiles[$prm['type']][$locDir][$prm['media']][$prm['file']] = $prm;
if ($prm['type'] == 'css') {
$c = file::read($fileExists);
preg_match_all('`@import (url\()?"(.+).css"\)?;`', $c, $matches);
if (!empty($matches[2])) {
$prefix = substr($prm['file'], 0, strpos($prm['file'], '_')+1);
foreach($matches[2 ] as $m)
$this->add(array_merge($prm, array('file'=>$prefix.$m)));
}
}
$ret = true;
}
foreach($this->getDepend($firstFile, $prm['type'], true) as $d) {
if (is_array($d))
$this->add(array_merge($prm, $d));
else
$this->add(array_merge($prm, array('file'=>$d)));
}
return $ret;
} else
throw new nException('reponse::add: parameters file and/or type not provied');
}
示例14: file
<?php
require_once "inc/class.file.php";
require_once "inc/class.gabarito.php";
$gaboficial = new file("gabaritos/gabaritooficial-1-a.dat");
$gabstr = $gaboficial->read();
$gabaritooficial = new gabarito();
$gabaritooficial->getFromStr($gabstr);
$lines = file('gabaritos/cobaia.dat');
// Percorre o array, mostrando o fonte HTML com numeração de linhas.
foreach ($lines as $line_num => $line) {
$dados = substr($line, 0, 50);
$gab = substr($line, 50, strlen($line) - 50);
$gabarito = new gabarito();
$gabarito->setDados($dados);
$gabarito->getFromStr($gab);
$gabarito->comparaComOficial($gabaritooficial);
$html = $gabarito->getResultado();
echo $html . "<br>";
//echo "Linha #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br>\n";
/*
echo "$gab<br>\n";
echo "<pre>";
var_dump($gabarito);
echo "</pre>";
*/
}
示例15: file_data
function file_data($filename)
{
$file = new file($filename);
$data = $file->read();
return $data;
}