本文整理汇总了PHP中io_readFile函数的典型用法代码示例。如果您正苦于以下问题:PHP io_readFile函数的具体用法?PHP io_readFile怎么用?PHP io_readFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了io_readFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle matches of the <feedaggregator> tag, storing the list of feeds in
* a file in the ~/data/tmp/feedaggregator directory.
*
* @param string $match The match of the syntax
* @param int $state The state of the handler
* @param int $pos The position in the document
* @param Doku_Handler $handler The handler
* @return array Data for the renderer
*/
public function handle($match, $state, $pos, Doku_Handler $handler)
{
global $conf;
$data = array();
// Are we to handle this match? If not, don't.
if ($state !== DOKU_LEXER_UNMATCHED) {
return $data;
}
// Get the feed URLs.
$matchedFeeds = preg_split('/[\\n\\r]+/', $match, -1, PREG_SPLIT_NO_EMPTY);
$feeds = array();
foreach ($matchedFeeds as $feed) {
if (filter_var($feed, FILTER_VALIDATE_URL) === false) {
msg("Feed URL not valid: <code>{$feed}</code>", 2);
continue;
}
$feeds[] = $feed;
}
$feedList = array_unique($feeds);
// Save the feeds to a temporary CSV. It'll be ready by the action script.
$file = fullpath($conf['tmpdir'] . '/feedaggregator.csv');
file_put_contents($file, join("\n", $feedList));
// Get the most-recently generated HTML feed aggregation. This won't be
// up to date with the above feeds yet, but that's okay.
$data['html'] = io_readFile(fullpath($conf['cachedir'] . '/feedaggregator/output.html'));
return $data;
}
示例2: _prepare_template
/**
* Loads the template for a new blog post and does some text replacements
*
* @author Gina Haeussge <osd@foosel.net>
*/
function _prepare_template($id, $title)
{
$tpl = io_readFile(DOKU_PLUGIN . 'blogtng/tpl/newentry.txt');
$replace = array('@TITLE@' => $title);
$tpl = str_replace(array_keys($replace), array_values($replace), $tpl);
return $tpl;
}
示例3: pagefromtemplate
function pagefromtemplate(&$event, $param)
{
if (strlen(trim($_REQUEST['newpagetemplate'])) > 0) {
global $conf;
global $INFO;
global $ID;
$tpl = io_readFile(wikiFN($_REQUEST['newpagetemplate']));
if ($this->getConf('userreplace')) {
$stringvars = array_map(create_function('$v', 'return explode(",",$v,2);'), explode(';', $_REQUEST['newpagevars']));
foreach ($stringvars as $value) {
$tpl = str_replace(trim($value[0]), trim($value[1]), $tpl);
}
}
if ($this->getConf('standardreplace')) {
// replace placeholders
$file = noNS($ID);
$page = strtr($file, '_', ' ');
$tpl = str_replace(array('@ID@', '@NS@', '@FILE@', '@!FILE@', '@!FILE!@', '@PAGE@', '@!PAGE@', '@!!PAGE@', '@!PAGE!@', '@USER@', '@NAME@', '@MAIL@', '@DATE@'), array($ID, getNS($ID), $file, utf8_ucfirst($file), utf8_strtoupper($file), $page, utf8_ucfirst($page), utf8_ucwords($page), utf8_strtoupper($page), $_SERVER['REMOTE_USER'], $INFO['userinfo']['name'], $INFO['userinfo']['mail'], $conf['dformat']), $tpl);
// we need the callback to work around strftime's char limit
$tpl = preg_replace_callback('/%./', create_function('$m', 'return strftime($m[0]);'), $tpl);
}
$event->result = $tpl;
$event->preventDefault();
}
}
示例4: checkUpdateMessages
/**
* Check for new messages from upstream
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function checkUpdateMessages()
{
global $conf;
global $INFO;
global $updateVersion;
if (!$conf['updatecheck']) {
return;
}
if ($conf['useacl'] && !$INFO['ismanager']) {
return;
}
$cf = $conf['cachedir'] . '/messages.txt';
$lm = @filemtime($cf);
// check if new messages needs to be fetched
if ($lm < time() - 60 * 60 * 24 || $lm < @filemtime(DOKU_INC . DOKU_SCRIPT)) {
@touch($cf);
dbglog("checkUpdatesMessages(): downloading messages.txt");
$http = new DokuHTTPClient();
$http->timeout = 12;
$data = $http->get(DOKU_MESSAGEURL . $updateVersion);
io_saveFile($cf, $data);
} else {
dbglog("checkUpdatesMessages(): messages.txt up to date");
$data = io_readFile($cf);
}
// show messages through the usual message mechanism
$msgs = explode("\n%\n", $data);
foreach ($msgs as $msg) {
if ($msg) {
msg($msg, 2);
}
}
}
示例5: convertDiscussionPage
/**
* this converts individual discussion pages to .comment meta files
*/
function convertDiscussionPage($file)
{
// read the old file
$data = io_readFile($file['old'], false);
// handle file with no comments yet
if (trim($data) == '') {
io_saveFile($file['new'], serialize(array('status' => 1, 'number' => 0)));
@unlink($file['old']);
return true;
}
// break it up into pieces
$old = explode('----', $data);
// merge with possibly already existing (newer) comments
$comments = array();
if (@file_exists($file['new'])) {
$comments = unserialize(io_readFile($file['old'], false));
}
// set general info
if (!isset($comments['status'])) {
$comments['status'] = 1;
}
$comments['number'] += count($old);
foreach ($old as $comment) {
// prepare comment data
if (strpos($comment, '<sub>') !== false) {
$in = '<sub>';
$out = ':</sub>';
} else {
$in = '//';
$out = ': //';
}
list($meta, $raw) = explode($out, $comment, 2);
$raw = trim($raw);
// skip empty comments
if (!$raw) {
$comments['number']--;
continue;
}
list($mail, $meta) = explode($in, $meta, 2);
list($name, $strd) = explode(', ', $meta, 2);
$date = strtotime($strd);
if ($date == -1) {
$date = time();
}
if ($mail) {
list($mail) = explode(' |', $mail, 2);
$mail = substr(strrchr($mail, '>'), 1);
}
$cid = md5($name . $date);
// render comment
$xhtml = p_render('xhtml', p_get_instructions($raw), $info);
// fill in the converted comment
$comments['comments'][$cid] = array('user' => array('name' => hsc($name), 'mail' => hsc($mail)), 'date' => array('created' => $date), 'show' => true, 'raw' => $raw, 'xhtml' => $xhtml, 'replies' => array());
}
// save the new file
io_saveFile($file['new'], serialize($comments));
// remove the old file
@unlink($file['old']);
return true;
}
示例6: handle
/**
* Handle the match
*/
function handle($match, $state, $pos, &$handler)
{
global $ID;
global $ACT;
// don't show linkback section on blog mainpages
if (defined('IS_BLOG_MAINPAGE')) {
return false;
}
// don't allow usage of syntax in comments
if (isset($_REQUEST['comment'])) {
return false;
}
// get linkback meta file name
$file = metaFN($ID, '.linkbacks');
$data = array('send' => false, 'receive' => false, 'display' => false, 'sentpings' => array(), 'receivedpings' => array(), 'number' => 0);
if (@file_exists($file)) {
$data = unserialize(io_readFile($file, false));
}
if ($match == '~~LINKBACK~~') {
$data['receive'] = true;
$data['display'] = true;
} else {
if ($match == '~~LINKBACK:off~~') {
$data['receive'] = false;
$data['display'] = false;
} else {
$data['receive'] = false;
$data['display'] = true;
}
}
io_saveFile($file, serialize($data));
}
示例7: handle
/**
* Handle the match
*/
function handle($match, $state, $pos, &$handler)
{
global $ID, $ACT;
// strip markup
$match = substr($match, 12, -2);
// split title (if there is one)
list($match, $title) = explode('|', $match, 2);
// assign discussion state
if ($match == ':off') {
$status = 0;
} else {
if ($match == ':closed') {
$status = 2;
} else {
$status = 1;
}
}
if ($ACT == 'preview') {
return;
}
// get discussion meta file name
$file = metaFN($ID, '.comments');
$data = array();
if (@file_exists($file)) {
$data = unserialize(io_readFile($file, false));
}
$data['title'] = $title;
$data['status'] = $status;
io_saveFile($file, serialize($data));
return $status;
}
示例8: checkUpdateMessages
/**
* Check for new messages from upstream
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function checkUpdateMessages()
{
global $conf;
global $INFO;
if (!$conf['updatecheck']) {
return;
}
if ($conf['useacl'] && !$INFO['ismanager']) {
return;
}
$cf = $conf['cachedir'] . '/messages.txt';
$lm = @filemtime($cf);
// check if new messages needs to be fetched
if ($lm < time() - 60 * 60 * 24 || $lm < @filemtime(DOKU_CONF . 'msg')) {
$num = @file(DOKU_CONF . 'msg');
$num = is_array($num) ? (int) $num[0] : 0;
$http = new DokuHTTPClient();
$http->timeout = 8;
$data = $http->get(DOKU_MESSAGEURL . $num);
io_saveFile($cf, $data);
} else {
$data = io_readFile($cf);
}
// show messages through the usual message mechanism
$msgs = explode("\n%\n", $data);
foreach ($msgs as $msg) {
if ($msg) {
msg($msg, 2);
}
}
}
示例9: _fail
function _fail()
{
header("HTTP/1.0 404 Not Found");
header('Content-Type: image/png');
echo io_readFile('broken.png', false);
exit;
}
示例10: test_bzfiles
/**
* @depends test_ext_bz2
*/
function test_bzfiles()
{
$this->assertEquals("The\nTest\n", io_readFile(__DIR__ . '/io_readfile/test.txt.bz2'));
$this->assertEquals("The\r\nTest\r\n", io_readFile(__DIR__ . '/io_readfile/test.txt.bz2', false));
$this->assertEquals(false, io_readFile(__DIR__ . '/io_readfile/nope.txt.bz2'));
// this test hangs
//$this->assertEquals(false, io_readFile(__DIR__.'/io_readfile/corrupt.txt.bz2'));
}
示例11: _write
function _write($file)
{
$contents = "The\nWrite\nTest\n";
$this->assertTrue(io_saveFile($file, $contents));
$this->assertEquals($contents, io_readFile($file));
$this->assertTrue(io_saveFile($file, $contents, true));
$this->assertEquals($contents . $contents, io_readFile($file));
}
示例12: __construct
function __construct()
{
$this->script_file = metaFN('epub:cache', '.ser');
$this->cache = unserialize(io_readFile($this->script_file, false));
if (!$this->cache) {
$this->cache = array();
}
}
示例13: loadServiceFile
/**
* Load the data from disk
*
* @param string $service
* @return array
*/
protected function loadServiceFile($service)
{
$file = $this->getServiceFile($service);
if (file_exists($file)) {
return unserialize(io_readFile($file, false));
} else {
return array();
}
}
示例14: test_fullsyntax
function test_fullsyntax()
{
$input = io_readFile(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.txt');
$this->assertTrue(strlen($input) > 1000);
// make sure we got what we want
$output = $this->render($input);
$input = $this->noWS($input);
$output = $this->noWS($output);
$this->assertEquals($input, $output);
}
示例15: test_delete
function test_delete()
{
$file = TMP_DIR . '/test.txt';
$contents = "The\nDelete\nDelete01\nDelete02\nDelete\nDeleteX\nTest\n";
io_saveFile($file, $contents);
$this->assertTrue(io_deleteFromFile($file, "Delete\n"));
$this->assertEquals("The\nDelete01\nDelete02\nDeleteX\nTest\n", io_readFile($file));
$this->assertTrue(io_deleteFromFile($file, "#Delete\\d+\n#", true));
$this->assertEquals("The\nDeleteX\nTest\n", io_readFile($file));
}