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


PHP io_readFile函数代码示例

本文整理汇总了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;
 }
开发者ID:samwilson,项目名称:dokuwiki-plugin-feedaggregator,代码行数:37,代码来源:syntax.php

示例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;
 }
开发者ID:stretchyboy,项目名称:plugin-blogtng,代码行数:12,代码来源:new.php

示例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();
     }
 }
开发者ID:jasongrout,项目名称:dokuwiki-newpagetemplate,代码行数:25,代码来源:action.php

示例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);
        }
    }
}
开发者ID:ngharaibeh,项目名称:Methodikos,代码行数:38,代码来源:infoutils.php

示例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;
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:63,代码来源:convert.php

示例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));
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:35,代码来源:syntax.php

示例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;
 }
开发者ID:NikolausL,项目名称:plugin-discussion,代码行数:34,代码来源:comments.php

示例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);
        }
    }
}
开发者ID:pyfun,项目名称:dokuwiki,代码行数:36,代码来源:infoutils.php

示例9: _fail

function _fail()
{
    header("HTTP/1.0 404 Not Found");
    header('Content-Type: image/png');
    echo io_readFile('broken.png', false);
    exit;
}
开发者ID:neutrinog,项目名称:Door43,代码行数:7,代码来源:img.php

示例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'));
 }
开发者ID:kbuildsyourdotcom,项目名称:Door43,代码行数:11,代码来源:io_readfile.test.php

示例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));
 }
开发者ID:richmahn,项目名称:Door43,代码行数:8,代码来源:io_savefile.test.php

示例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();
     }
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:8,代码来源:helper.php

示例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();
     }
 }
开发者ID:ZeusWPI,项目名称:dokuwiki-plugin-oauth,代码行数:15,代码来源:oAuthStorage.php

示例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);
 }
开发者ID:hefanbo,项目名称:edittable,代码行数:10,代码来源:renderer_plugin_edittable_inverse.test.php

示例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));
 }
开发者ID:richmahn,项目名称:Door43,代码行数:10,代码来源:io_deletefromfile.test.php


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