• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP set_file_buffer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中set_file_buffer函数的典型用法代码示例。如果您正苦于以下问题:PHP set_file_buffer函数的具体用法?PHP set_file_buffer怎么用?PHP set_file_buffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了set_file_buffer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: add

 public function add($csvRow)
 {
     $lock = fopen("../storage/waitlists/update.lock", "r");
     if (flock($lock, LOCK_SH)) {
         if (!file_exists($this->filePath)) {
             $entry = "Course,Section,First Name,Last Name,Email,Student ID,Reason" . $csvRow;
         } else {
             $entry = $csvRow;
         }
         $fp = fopen($this->filePath, 'a');
         chmod($this->filePath, 0600);
         // lock file for write
         if (flock($fp, LOCK_EX)) {
             // write entire line before releasing lock
             set_file_buffer($fp, 0);
             fwrite($fp, $entry);
             flock($fp, LOCK_UN);
         } else {
             error_log("could not obtain lock for " . $this->department . " file.");
         }
         fclose($fp);
     } else {
         error_log("Could not add to waitlists");
     }
     flock($lock, LOCK_UN);
     fclose($lock);
 }
开发者ID:ayejeyess,项目名称:scu-waitlist,代码行数:27,代码来源:Waitlist.php


示例2: plugin_counter_get_count

function plugin_counter_get_count($page)
{
    global $vars;
    static $counters = array();
    static $default;
    if (!isset($default)) {
        $default = array('total' => 0, 'date' => get_date('Y/m/d'), 'today' => 0, 'yesterday' => 0, 'ip' => '');
    }
    if (!is_page($page)) {
        return $default;
    }
    if (isset($counters[$page])) {
        return $counters[$page];
    }
    // Set default
    $counters[$page] = $default;
    $modify = FALSE;
    $file = COUNTER_DIR . encode($page) . PLUGIN_COUNTER_SUFFIX;
    $fp = fopen($file, file_exists($file) ? 'r+' : 'w+') or die('counter.inc.php: Cannot open COUTER_DIR/' . basename($file));
    set_file_buffer($fp, 0);
    flock($fp, LOCK_EX);
    rewind($fp);
    foreach ($default as $key => $val) {
        // Update
        $counters[$page][$key] = rtrim(fgets($fp, 256));
        if (feof($fp)) {
            break;
        }
    }
    if ($counters[$page]['date'] != $default['date']) {
        // New day
        $modify = TRUE;
        $is_yesterday = $counters[$page]['date'] == get_date('Y/m/d', strtotime('yesterday', UTIME));
        $counters[$page]['ip'] = $_SERVER['REMOTE_ADDR'];
        $counters[$page]['date'] = $default['date'];
        $counters[$page]['yesterday'] = $is_yesterday ? $counters[$page]['today'] : 0;
        $counters[$page]['today'] = 1;
        $counters[$page]['total']++;
    } else {
        if ($counters[$page]['ip'] != $_SERVER['REMOTE_ADDR']) {
            // Not the same host
            $modify = TRUE;
            $counters[$page]['ip'] = $_SERVER['REMOTE_ADDR'];
            $counters[$page]['today']++;
            $counters[$page]['total']++;
        }
    }
    // Modify
    if ($modify && $vars['cmd'] == 'read') {
        rewind($fp);
        ftruncate($fp, 0);
        foreach (array_keys($default) as $key) {
            fputs($fp, $counters[$page][$key] . "\n");
        }
    }
    flock($fp, LOCK_UN);
    fclose($fp);
    return $counters[$page];
}
开发者ID:geoemon2k,项目名称:source_wiki,代码行数:59,代码来源:counter.inc.php


示例3: ref_save

function ref_save($page)
{
    global $referer, $use_spam_check;
    // if (PKWK_READONLY || ! $referer || empty($_SERVER['HTTP_REFERER'])) return TRUE;
    // if (auth::check_role('readonly') || ! $referer || empty($_SERVER['HTTP_REFERER'])) return TRUE;
    if (!$referer || empty($_SERVER['HTTP_REFERER'])) {
        return TRUE;
    }
    $url = $_SERVER['HTTP_REFERER'];
    // Validate URI (Ignore own)
    $parse_url = parse_url($url);
    if ($parse_url === FALSE || !isset($parse_url['host']) || $parse_url['host'] == $_SERVER['HTTP_HOST']) {
        return TRUE;
    }
    // Blocking SPAM
    if ($use_spam_check['referer'] && SpamCheck($parse_url['host'])) {
        return TRUE;
    }
    if (!is_dir(REFERER_DIR)) {
        die('No such directory: REFERER_DIR');
    }
    if (!is_writable(REFERER_DIR)) {
        die('Permission denied to write: REFERER_DIR');
    }
    // Update referer data
    if (ereg("[,\"\n\r]", $url)) {
        $url = '"' . str_replace('"', '""', $url) . '"';
    }
    $data = ref_get_data($page, 3);
    $d_url = rawurldecode($url);
    if (!isset($data[$d_url])) {
        $data[$d_url] = array('', UTIME, 0, $url, 1);
    }
    $data[$d_url][0] = UTIME;
    $data[$d_url][2]++;
    $filename = ref_get_filename($page);
    $fp = fopen($filename, 'w');
    if ($fp === FALSE) {
        return FALSE;
    }
    set_file_buffer($fp, 0);
    @flock($fp, LOCK_EX);
    rewind($fp);
    foreach ($data as $line) {
        $str = trim(join(',', $line));
        if ($str != '') {
            fwrite($fp, $str . "\n");
        }
    }
    @flock($fp, LOCK_UN);
    fclose($fp);
    return TRUE;
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:53,代码来源:referer.php


示例4: nel_write_file

function nel_write_file($filename, $output, $chmod)
{
    $fp = fopen($filename, "w");
    if (!$fp) {
        echo 'Failed to open file for writing. Check permissions.';
        return FALSE;
    }
    set_file_buffer($fp, 0);
    rewind($fp);
    fputs($fp, $output);
    fclose($fp);
    chmod($filename, $chmod);
    return TRUE;
}
开发者ID:OtakuMegane,项目名称:Nelliel,代码行数:14,代码来源:file-handling.php


示例5: get_ticket

function get_ticket($newticket = FALSE)
{
    $file = CACHE_DIR . 'ticket.dat';
    if (file_exists($file) && $newticket !== TRUE) {
        $fp = fopen($file, 'r') or die_message('Cannot open ' . 'CACHE_DIR/' . 'ticket.dat');
        $ticket = trim(fread($fp, filesize($file)));
        fclose($fp);
    } else {
        $ticket = md5(mt_rand());
        pkwk_touch_file($file);
        $fp = fopen($file, 'r+') or die_message('Cannot open ' . 'CACHE_DIR/' . 'ticket.dat');
        set_file_buffer($fp, 0);
        @flock($fp, LOCK_EX);
        $last = ignore_user_abort(1);
        ftruncate($fp, 0);
        rewind($fp);
        fputs($fp, $ticket . "\n");
        ignore_user_abort($last);
        @flock($fp, LOCK_UN);
        fclose($fp);
    }
    return $ticket;
}
开发者ID:orangeal2o3,项目名称:pukiwiki-plugin,代码行数:23,代码来源:fileplus.php


示例6: plugin_tb_save

function plugin_tb_save($url, $tb_id)
{
    global $vars, $trackback, $use_spam_check;
    static $fields = array('url', 'title', 'excerpt', 'blog_name');
    $die = '';
    if (!$trackback) {
        $die .= 'TrackBack feature disabled. ';
    }
    if ($url == '') {
        $die .= 'URL parameter is not set. ';
    }
    if ($tb_id == '') {
        $die .= 'TrackBack Ping ID is not set. ';
    }
    if ($die != '') {
        plugin_tb_return(PLUGIN_TB_ERROR, $die);
    }
    if (!file_exists(TRACKBACK_DIR)) {
        plugin_tb_return(PLUGIN_TB_ERROR, 'No such directory: TRACKBACK_DIR');
    }
    if (!is_writable(TRACKBACK_DIR)) {
        plugin_tb_return(PLUGIN_TB_ERROR, 'Permission denied: TRACKBACK_DIR');
    }
    $page = tb_id2page($tb_id);
    if ($page === FALSE) {
        plugin_tb_return(PLUGIN_TB_ERROR, 'TrackBack ID is invalid.');
    }
    // URL validation (maybe worse of processing time limit)
    if (!is_url($url)) {
        plugin_tb_return(PLUGIN_TB_ERROR, 'URL is fictitious.');
    }
    if (PLUGIN_TB_SITE_CHECK === TRUE) {
        $result = http_request($url);
        if ($result['rc'] !== 200) {
            plugin_tb_return(PLUGIN_TB_ERROR, 'URL is fictitious.');
        }
        $urlbase = get_script_absuri();
        $matches = array();
        if (preg_match_all('#' . preg_quote($urlbase, '#') . '#i', $result['data'], $matches) == 0) {
            honeypot_write();
            if (PLUGIN_TB_HTTP_ERROR === TRUE && is_sapi_clicgi() === FALSE) {
                header('HTTP/1.0 403 Forbidden');
                exit;
            }
            plugin_tb_return(PLUGIN_TB_ERROR, 'Writing is prohibited.');
        }
    } else {
        $result = http_request($url, 'HEAD');
        if ($result['rc'] !== 200) {
            plugin_tb_return(PLUGIN_TB_ERROR, 'URL is fictitious.');
        }
    }
    // Update TrackBack Ping data
    $filename = tb_get_filename($page);
    $data = tb_get($filename);
    $matches = array();
    $items = array(UTIME);
    foreach ($fields as $key) {
        $value = isset($vars[$key]) ? $vars[$key] : '';
        if (preg_match('/[,"' . "\n\r" . ']/', $value)) {
            $value = '"' . str_replace('"', '""', $value) . '"';
        }
        $items[$key] = $value;
        // minimum checking from SPAM
        if (preg_match_all('/a\\s+href=/i', $items[$key], $matches) >= 1) {
            honeypot_write();
            if (PLUGIN_TB_HTTP_ERROR === TRUE && is_sapi_clicgi() === FALSE) {
                header('HTTP/1.0 400 Bad Request');
                exit;
            }
            plugin_tb_return(PLUGIN_TB_ERROR, 'Writing is prohibited.');
        }
    }
    // minimum checking from SPAM #2
    foreach (array('title', 'excerpt', 'blog_name') as $key) {
        if (preg_match_all('#http\\://#i', $items[$key], $matches) >= 1) {
            honeypot_write();
            if (PLUGIN_TB_HTTP_ERROR === TRUE && is_sapi_clicgi() === FALSE) {
                header('HTTP/1.0 400 Bad Request');
                exit;
            }
            plugin_tb_return(PLUGIN_TB_ERROR, 'Writing is prohibited.');
        }
    }
    // Blocking SPAM
    if ($use_spam_check['trackback'] && SpamCheck($items['url'])) {
        plugin_tb_return(1, 'Writing is prohibited.');
    }
    $data[rawurldecode($items['url'])] = $items;
    $fp = fopen($filename, 'w');
    set_file_buffer($fp, 0);
    flock($fp, LOCK_EX);
    rewind($fp);
    foreach ($data as $line) {
        $line = preg_replace('/[\\r\\n]/s', '', $line);
        // One line, one ping
        fwrite($fp, join(',', $line) . "\n");
    }
    flock($fp, LOCK_UN);
    fclose($fp);
//.........这里部分代码省略.........
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:101,代码来源:tb.inc.php


示例7: file_head

 /**
  * Reads heads of file into an array
  *
  * PHP API Extension
  *
  * @access public
  * @static
  * @param string  $file filename
  * @param int     $count number of executed fgets, usually equivalent to number of lines
  * @param boolean $lock use lock or not 
  * @param int     $buffer number of bytes to be read in one fgets
  * @return array
  * @version $Id: v 1.0 2008-06-05 11:14:46 sonots $
  */
 function file_head($file, $count = 1, $lock = true, $buffer = 8192)
 {
     $array = array();
     $fp = @fopen($file, 'r');
     if ($fp === false) {
         return false;
     }
     set_file_buffer($fp, 0);
     if ($lock) {
         @flock($fp, LOCK_SH);
     }
     rewind($fp);
     $index = 0;
     while (!feof($fp)) {
         $line = fgets($fp, $buffer);
         if ($line != false) {
             $array[] = $line;
         }
         if (++$index >= $count) {
             break;
         }
     }
     if ($lock) {
         @flock($fp, LOCK_UN);
     }
     if (!fclose($fp)) {
         return false;
     }
     return $array;
 }
开发者ID:orangeal2o3,项目名称:pukiwiki-plugin,代码行数:44,代码来源:sonots.class.php


示例8: fopen

            $domains[] = $parts[$i];
        }
    }
}
// Load previous results
$fp = fopen('testsuite.txt', 'rt');
if (!$fp) {
    $results = array();
} else {
    $results = unserialize(fgets($fp));
    fclose($fp);
}
// Test domains
include 'whois.main.php';
$whois = new Whois();
set_file_buffer(STDIN, 0);
foreach ($domains as $key => $domain) {
    echo "\nTesting {$domain} ---------------------------------\n";
    $result = $whois->Lookup($domain);
    unset($result['rawdata']);
    if (!isset($results[$domain])) {
        print_r($result);
        $res = get_answer("Add result for {$domain}");
        if ($res) {
            // Add as it is
            unset($result['regrinfo']['disclaimer']);
            $results[$domain] = $result;
        }
    } else {
        // Compare with previous result
        unset($result['regrinfo']['disclaimer']);
开发者ID:carriercomm,项目名称:NeoBill,代码行数:31,代码来源:testsuite.php


示例9: tb_get

function tb_get($file, $key = 1)
{
    if (!file_exists($file)) {
        return array();
    }
    $result = array();
    $fp = @fopen($file, 'r');
    set_file_buffer($fp, 0);
    @flock($fp, LOCK_EX);
    rewind($fp);
    while ($data = @fgets($fp, 8192)) {
        // $data[$key] = URL
        $data = csv_explode(',', $data);
        $result[rawurldecode($data[$key])] = $data;
    }
    @flock($fp, LOCK_UN);
    fclose($fp);
    return $result;
}
开发者ID:orangeal2o3,项目名称:pukiwiki-plugin,代码行数:19,代码来源:trackback.php


示例10: _plugin_code_write_cache

/**
 *  キャッシュに書き込む
 * 引数は添付ファイル名, HTML変換後のファイル
 */
function _plugin_code_write_cache($fname, $html)
{
    global $vars;
    // 添付ファイルのあるページ: defaultは現在のページ名
    $page = isset($vars['page']) ? $vars['page'] : '';
    // ファイル名にページ名(ページ参照パス)が合成されているか
    //   (Page_name/maybe-separated-with/slashes/ATTACHED_FILENAME)
    if (preg_match('#^(.+)/([^/]+)$#', $fname, $matches)) {
        if ($matches[1] == '.' || $matches[1] == '..') {
            $matches[1] .= '/';
        }
        // Restore relative paths
        $fname = $matches[2];
        $page = get_fullname(strip_bracket($matches[1]), $page);
        // strip is a compat
        $file = encode($page) . '_' . encode($fname);
    } else {
        // Simple single argument
        $file = encode($page) . '_' . encode($fname);
    }
    $fp = fopen(CACHE_DIR . 'code/' . $file . '.html', 'w') or die_message('Cannot write cache file ' . CACHE_DIR . 'code/' . $file . '.html' . '<br />Maybe permission is not writable or filename is too long');
    set_file_buffer($fp, 0);
    flock($fp, LOCK_EX);
    rewind($fp);
    fputs($fp, $html);
    flock($fp, LOCK_UN);
    fclose($fp);
}
开发者ID:aterai,项目名称:pukiwiki-plus-i18n,代码行数:32,代码来源:code.inc.php


示例11: updateLastDatabaseError

function updateLastDatabaseError()
{
    global $boarddir;
    // Find out this way if we can even write things on this filesystem.
    // In addition, store things first in the backup file
    $last_settings_change = @filemtime($boarddir . '/Settings.php');
    // Make sure the backup file is there...
    $file = $boarddir . '/Settings_bak.php';
    if ((!file_exists($file) || filesize($file) == 0) && !copy($boarddir . '/Settings.php', $file)) {
        return false;
    }
    // ...and writable!
    if (!is_writable($file)) {
        chmod($file, 0755);
        if (!is_writable($file)) {
            chmod($file, 0775);
            if (!is_writable($file)) {
                chmod($file, 0777);
                if (!is_writable($file)) {
                    return false;
                }
            }
        }
    }
    // Put the new timestamp.
    $data = file_get_contents($file);
    $data = preg_replace('~\\$db_last_error = \\d+;~', '$db_last_error = ' . time() . ';', $data);
    // Open the backup file for writing
    if ($fp = @fopen($file, 'w')) {
        // Reset the file buffer.
        set_file_buffer($fp, 0);
        // Update the file.
        $t = flock($fp, LOCK_EX);
        $bytes = fwrite($fp, $data);
        flock($fp, LOCK_UN);
        fclose($fp);
        // Was it a success?
        // ...only relevant if we're still dealing with the same good ole' settings file.
        clearstatcache();
        if ($bytes == strlen($data) && filemtime($boarddir . '/Settings.php') === $last_settings_change) {
            // This is our new Settings file...
            // At least this one is an atomic operation
            @copy($file, $boarddir . '/Settings.php');
            return true;
        } else {
            // Oops. Someone might have been faster
            // or we have no more disk space left, troubles, troubles...
            // Copy the file back and run for your life!
            @copy($boarddir . '/Settings.php', $file);
        }
    }
    return false;
}
开发者ID:valek0972,项目名称:hackits,代码行数:53,代码来源:Subs-Admin.php


示例12: lockr

 static function lockr($fp)
 {
     set_file_buffer($fp, 0);
     if (!flock($fp, LOCK_SH)) {
         HakoError::lockFail();
     }
     rewind($fp);
 }
开发者ID:hiro0218,项目名称:hakoniwa,代码行数:8,代码来源:hako-ally.php


示例13: putstatus

 function putstatus()
 {
     $this->status['count'] = join(',', $this->status['count']);
     $fp = fopen($this->logname, 'wb') or die_message('cannot write ' . $this->logname);
     set_file_buffer($fp, 0);
     flock($fp, LOCK_EX);
     rewind($fp);
     foreach ($this->status as $key => $value) {
         fwrite($fp, $value . "\n");
     }
     flock($fp, LOCK_UN);
     fclose($fp);
 }
开发者ID:geoemon2k,项目名称:source_wiki,代码行数:13,代码来源:attach.inc.php


示例14: init

function init()
{
    $err = "";
    $chkfile = array(LOGFILE, TREEFILE);
    if (!is_writable(realpath("./"))) {
        error("カレントディレクトリに書けません<br>");
    }
    foreach ($chkfile as $value) {
        if (!file_exists(realpath($value))) {
            $fp = fopen($value, "w");
            set_file_buffer($fp, 0);
            if ($value == LOGFILE) {
                fputs($fp, "1,2002/01/01(月) 00:00,名無し,,無題,本文なし,,,,,,,,\n");
            }
            if ($value == TREEFILE) {
                fputs($fp, "1\n");
            }
            fclose($fp);
            if (file_exists(realpath($value))) {
                @chmod($value, 0666);
            }
        }
        if (!is_writable(realpath($value))) {
            $err .= $value . "を書けません<br>";
        }
        if (!is_readable(realpath($value))) {
            $err .= $value . "を読めません<br>";
        }
    }
    @mkdir(IMG_DIR, 0777);
    @chmod(IMG_DIR, 0777);
    if (!is_dir(realpath(IMG_DIR))) {
        $err .= IMG_DIR . "がありません<br>";
    }
    if (!is_writable(realpath(IMG_DIR))) {
        $err .= IMG_DIR . "を書けません<br>";
    }
    if (!is_readable(realpath(IMG_DIR))) {
        $err .= IMG_DIR . "を読めません<br>";
    }
    if (USE_THUMB) {
        @mkdir(THUMB_DIR, 0777);
        @chmod(THUMB_DIR, 0777);
        if (!is_dir(realpath(IMG_DIR))) {
            $err .= THUMB_DIR . "がありません<br>";
        }
        if (!is_writable(realpath(THUMB_DIR))) {
            $err .= THUMB_DIR . "を書けません<br>";
        }
        if (!is_readable(realpath(THUMB_DIR))) {
            $err .= THUMB_DIR . "を読めません<br>";
        }
    }
    if ($err) {
        error($err);
    }
}
开发者ID:Phalacrocorax,项目名称:futaba,代码行数:57,代码来源:futaba.php


示例15: ref_save

function ref_save($page)
{
    global $referer;
    if (PKWK_READONLY || !$referer || empty($_SERVER['HTTP_REFERER'])) {
        return true;
    }
    $url = $_SERVER['HTTP_REFERER'];
    // Validate URI (Ignore own)
    $parse_url = parse_url($url);
    if (empty($parse_url['host']) || $parse_url['host'] == $_SERVER['HTTP_HOST']) {
        return true;
    }
    if (!is_dir(TRACKBACK_DIR)) {
        die('No such directory: TRACKBACK_DIR');
    }
    if (!is_writable(TRACKBACK_DIR)) {
        die('Permission denied to write: TRACKBACK_DIR');
    }
    // Update referer data
    if (ereg("[,\"\n\r]", $url)) {
        $url = '"' . str_replace('"', '""', $url) . '"';
    }
    $filename = tb_get_filename($page, '.ref');
    $data = tb_get($filename, 3);
    $d_url = rawurldecode($url);
    if (!isset($data[$d_url])) {
        $data[$d_url] = array('', UTIME, 0, $url, 1);
    }
    $data[$d_url][0] = UTIME;
    $data[$d_url][2]++;
    $fp = fopen($filename, 'w');
    if ($fp === false) {
        return false;
    }
    set_file_buffer($fp, 0);
    flock($fp, LOCK_EX);
    rewind($fp);
    foreach ($data as $line) {
        fwrite($fp, join(',', $line) . "\n");
    }
    flock($fp, LOCK_UN);
    fclose($fp);
    return true;
}
开发者ID:nsmr0604,项目名称:pukiwiki,代码行数:44,代码来源:trackback.php


示例16: _plugin_code_write_cache

 /**
  * キャッシュに書き込む
  * 引数は添付ファイル名, HTML変換後のファイル
  */
 function _plugin_code_write_cache($fname, $html, $option)
 {
     // 添付ファイルのあるページ: defaultは現在のページ名
     $page = isset($this->root->vars['page']) ? $this->root->vars['page'] : '';
     // ファイル名にページ名(ページ参照パス)が合成されているか
     //   (Page_name/maybe-separated-with/slashes/ATTACHED_FILENAME)
     if (preg_match('#^(.+)/([^/]+)$#', $fname, $matches)) {
         if ($matches[1] == '.' || $matches[1] == '..') {
             $matches[1] .= '/';
         }
         // Restore relative paths
         $fname = $matches[2];
         $page = $this->func->get_fullname($this->func->strip_bracket($matches[1]), $page);
         // strip is a compat
         //	$file = $this->func->encode($page) . '_' . $this->func->encode($fname);
         //} else {
         //	// Simple single argument
         //	$file =  $this->func->encode($page) . '_' . $this->func->encode($fname);
     }
     $file = $this->func->encode($page) . '_' . $this->func->encode($fname);
     // md5ハッシュ取得
     list(, , , , , , , , $md5) = array_pad(@file($this->cont['UPLOAD_DIR'] . $file . ".log"), 9, "");
     $md5 = trim($md5);
     $html = $this->func->strip_MyHostUrl($html);
     $data = serialize(array($html, $option, $md5));
     $fp = fopen($this->cont['CACHE_DIR'] . 'plugin/' . $file . ($this->cont['UA_PROFILE'] === 'keitai' ? '.k' : '') . '.code', 'wb') or $this->func->die_message('Cannot write cache file ' . $this->cont['CACHE_DIR'] . 'plugin/' . $file . '.code' . '<br />Maybe permission is not writable or filename is too long');
     set_file_buffer($fp, 0);
     flock($fp, LOCK_EX);
     rewind($fp);
     fputs($fp, $data);
     flock($fp, LOCK_UN);
     fclose($fp);
 }
开发者ID:nao-pon,项目名称:xpWiki,代码行数:37,代码来源:code.inc.php


示例17: tb_get

 function tb_get($file, $key = 1)
 {
     if (!is_file($file)) {
         return array();
     }
     $result = array();
     $fp = @fopen($file, 'r');
     set_file_buffer($fp, 0);
     flock($fp, LOCK_SH);
     rewind($fp);
     while ($data = @fgetcsv($fp, 8192, ',')) {
         // $data[$key] = URL
         $result[rawurldecode($data[$key])] = $data;
     }
     flock($fp, LOCK_UN);
     fclose($fp);
     return $result;
 }
开发者ID:nao-pon,项目名称:xpWiki,代码行数:18,代码来源:pukiwiki_func.php


示例18: put_lastmodified

function put_lastmodified()
{
    global $maxshow, $whatsnew, $autolink;
    if (PKWK_READONLY) {
        return;
    }
    // Do nothing
    // Get WHOLE page list
    $pages = get_existpages();
    // Check ALL filetime
    $recent_pages = array();
    foreach ($pages as $page) {
        if ($page != $whatsnew && !check_non_list($page)) {
            $recent_pages[$page] = get_filetime($page);
        }
    }
    // Sort decending order of last-modification date
    arsort($recent_pages, SORT_NUMERIC);
    // Cut unused lines
    // BugTrack2/179: array_splice() will break integer keys in hashtable
    $count = $maxshow + PKWK_MAXSHOW_ALLOWANCE;
    $_recent = array();
    foreach ($recent_pages as $key => $value) {
        unset($recent_pages[$key]);
        $_recent[$key] = $value;
        if (--$count < 1) {
            break;
        }
    }
    $recent_pages =& $_recent;
    // Re-create PKWK_MAXSHOW_CACHE
    $file = CACHE_DIR . PKWK_MAXSHOW_CACHE;
    pkwk_touch_file($file);
    $fp = fopen($file, 'r+') or die_message('Cannot open' . 'CACHE_DIR/' . PKWK_MAXSHOW_CACHE);
    set_file_buffer($fp, 0);
    flock($fp, LOCK_EX);
    ftruncate($fp, 0);
    rewind($fp);
    foreach ($recent_pages as $page => $time) {
        fputs($fp, $time . "\t" . $page . "\n");
    }
    flock($fp, LOCK_UN);
    fclose($fp);
    // Create RecentChanges
    $file = get_filename($whatsnew);
    pkwk_touch_file($file);
    $fp = fopen($file, 'r+') or die_message('Cannot open ' . htmlspecialchars($whatsnew));
    set_file_buffer($fp, 0);
    flock($fp, LOCK_EX);
    ftruncate($fp, 0);
    rewind($fp);
    foreach (array_keys($recent_pages) as $page) {
        $time = $recent_pages[$page];
        $s_lastmod = htmlspecialchars(format_date($time));
        $s_page = htmlspecialchars($page);
        fputs($fp, '-' . $s_lastmod . ' - [[' . $s_page . ']]' . "\n");
    }
    fputs($fp, '#norelated' . "\n");
    // :)
    flock($fp, LOCK_UN);
    fclose($fp);
    // For AutoLink
    if ($autolink) {
        list($pattern, $pattern_a, $forceignorelist) = get_autolink_pattern($pages);
        $file = CACHE_DIR . PKWK_AUTOLINK_REGEX_CACHE;
        pkwk_touch_file($file);
        $fp = fopen($file, 'r+') or die_message('Cannot open ' . 'CACHE_DIR/' . PKWK_AUTOLINK_REGEX_CACHE);
        set_file_buffer($fp, 0);
        flock($fp, LOCK_EX);
        ftruncate($fp, 0);
        rewind($fp);
        fputs($fp, $pattern . "\n");
        fputs($fp, $pattern_a . "\n");
        fputs($fp, join("\t", $forceignorelist) . "\n");
        flock($fp, LOCK_UN);
        fclose($fp);
    }
}
开发者ID:KimuraYoichi,项目名称:PukiWiki,代码行数:78,代码来源:file.php


示例19: write_eeprom_cfg_file

function write_eeprom_cfg_file()
{
    global $sernos, $nsernos, $bddb_cfgdir, $numerrs, $cfgerrs;
    global $date, $batch, $type_vals, $rev;
    global $sdram_vals, $sdram_nbits;
    global $flash_vals, $flash_nbits;
    global $zbt_vals, $zbt_nbits;
    global $xlxtyp_vals, $xlxspd_vals, $xlxtmp_vals, $xlxgrd_vals;
    global $cputyp, $cputyp_vals, $clk_vals;
    global $hstype, $hstype_vals, $hschin, $hschout;
    $numerrs = 0;
    $cfgerrs = array();
    for ($i = 0; $i < $nsernos; $i++) {
        $serno = sprintf("%010d", $sernos[$i]);
        $wfp = @fopen($bddb_cfgdir . "/{$serno}.cfg", "w");
        if (!$wfp) {
            $cfgerrs[$i] = 'file create fail';
            $numerrs++;
            continue;
        }
        set_file_buffer($wfp, 0);
        if (!fprintf($wfp, "serno=%d\n", $sernos[$i])) {
            $cfgerrs[$i] = 'cfg wr fail (serno)';
            fclose($wfp);
            $numerrs++;
            continue;
        }
        if (!fprintf($wfp, "date=%s\n", $date)) {
            $cfgerrs[$i] = 'cfg wr fail (date)';
            fclose($wfp);
            $numerrs++;
            continue;
        }
        if ($batch != '') {
            if (!fprintf($wfp, "batch=%s\n", $batch)) {
                $cfgerrs[$i] = 'cfg wr fail (batch)';
                fclose($wfp);
                $numerrs++;
                continue;
            }
        }
        $typei = enum_to_index("type", $type_vals);
        if (!fprintf($wfp, "type=%d\n", $typei)) {
            $cfgerrs[$i] = 'cfg wr fail (type)';
            fclose($wfp);
            $numerrs++;
            continue;
        }
        if (!fprintf($wfp, "rev=%d\n", $rev)) {
            $cfgerrs[$i] = 'cfg wr fail (rev)';
            fclose($wfp);
            $numerrs++;
            continue;
        }
        $s = gather_enum_multi_write("sdram", 4, $sdram_vals, $sdram_nbits);
        if ($s != '') {
            $b = fprintf($wfp, "sdram=%s\n", $s);
            if (!$b) {
                $cfgerrs[$i] = 'cfg wr fail (sdram)';
                fclose($wfp);
                $numerrs++;
                continue;
            }
        }
        $s = gather_enum_multi_write("flash", 4, $flash_vals, $flash_nbits);
        if ($s != '') {
            $b = fprintf($wfp, "flash=%s\n", $s);
            if (!$b) {
                $cfgerrs[$i] = 'cfg wr fail (flash)';
                fclose($wfp);
                $numerrs++;
                continue;
            }
        }
        $s = gather_enum_multi_write("zbt", 16, $zbt_vals, $zbt_nbits);
        if ($s != '') {
            $b = fprintf($wfp, "zbt=%s\n", $s);
            if (!$b) {
                $cfgerrs[$i] = 'cfg wr fail (zbt)';
                fclose($wfp);
                $numerrs++;
                continue;
            }
        }
        $s = gather_enum_multi_write("xlxtyp", 4, $xlxtyp_vals);
        if ($s != '') {
            $b = fprintf($wfp, "xlxtyp=%s\n", $s);
            if (!$b) {
                $cfgerrs[$i] = 'cfg wr fail (xlxtyp)';
                fclose($wfp);
                $numerrs++;
                continue;
            }
        }
        $s = gather_enum_multi_write("xlxspd", 4, $xlxspd_vals);
        if ($s != '') {
            $b = fprintf($wfp, "xlxspd=%s\n", $s);
            if (!$b) {
                $cfgerrs[$i] = 'cfg wr fail (xlxspd)';
                fclose($wfp);
//.........这里部分代码省略.........
开发者ID:yjhjstz,项目名称:pandorabox,代码行数:101,代码来源:defs.php


示例20: plugin_tb_save

 function plugin_tb_save($url, $tb_id)
 {
     //	global $vars, $trackback;
     //	static $fields = array( /* UTIME, */ 'url', 'title', 'excerpt', 'blog_name');
     static $fields = array();
     if (!isset($fields[$this->xpwiki->pid])) {
         $fields[$this->xpwiki->pid] = array('url', 'title', 'excerpt', 'blog_name');
     }
     $die = '';
     if (!$this->root->trackback) {
         $die .= 'TrackBack feature disabled. ';
     }
     if ($url == '') {
         $die .= 'URL parameter is not set. ';
     }
     if ($tb_id == '') {
         $die .= 'TrackBack Ping ID is not set. ';
     }
     if ($die != '') {
         return array($this->cont['PLUGIN_TB_ERROR'], $die);
     }
     if (!file_exists($this->cont['TRACKBACK_DIR'])) {
         return array($this->cont['PLUGIN_TB_ERROR'], 'No such directory: TRACKBACK_DIR');
     }
     if (!is_writable($this->cont['TRACKBACK_DIR'])) {
         return array($this->cont['PLUGIN_TB_ERROR'], 'Permission denied: TRACKBACK_DIR');
     }
     $page = $this->func->tb_id2page($tb_id);
     if ($page === FALSE) {
         return array($this->cont['PLUGIN_TB_ERROR'], 'TrackBack ID is invalid.');
     }
     // URL validation (maybe worse of processing time limit)
     $result = $this->func->http_request($url, 'HEAD');
     if ($result['rc'] !== 200) {
         return array($this->cont['PLUGIN_TB_ERROR'], 'URL is fictitious.');
     }
     // Update TrackBack Ping data
     $filename = $this->func->tb_get_filename($page);
     $data = $this->func->tb_get($filename);
     $items = array($this->cont['UTIME']);
     foreach ($fields[$this->xpwiki->pid] as $key) {
         $value = isset($this->root->vars[$key]) ? $this->root->vars[$key] : '';
         if (preg_match('/[,"' . "\n\r" . ']/', $value)) {
             $value = '"' . str_replace('"', '""', $value) . '"';
         }
         $items[$key] = $value;
     }
     $data[rawurldecode($items['url'])] = $items;
     $fp = fopen($filename, 'w');
     set_file_buffer($fp, 0);
     flock($fp, LOCK_EX);
     rewind($fp);
     foreach ($data as $line) {
         $line = preg_replace('/[\\r\\n]/s', '', $line);
         // One line, one ping
         fwrite($fp, join(',', $line) . "\n");
     }
     flock($fp, LOCK_UN);
     fclose($fp);
     return array($this->cont['PLUGIN_TB_NOERROR'], '');
 }
开发者ID:nouphet,项目名称:rata,代码行数:61,代码来源:tb.inc.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP set_filter函数代码示例发布时间:2022-05-15
下一篇:
PHP set_field_select函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap