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

PHP fseek函数代码示例

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

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



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

示例1: DeleteLyrics3

 function DeleteLyrics3()
 {
     // Initialize getID3 engine
     $getID3 = new getID3();
     $ThisFileInfo = $getID3->analyze($this->filename);
     if (isset($ThisFileInfo['lyrics3']['tag_offset_start']) && isset($ThisFileInfo['lyrics3']['tag_offset_end'])) {
         if (is_readable($this->filename) && is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'a+b'))) {
             flock($fp, LOCK_EX);
             $oldignoreuserabort = ignore_user_abort(true);
             fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_end'], SEEK_SET);
             $DataAfterLyrics3 = '';
             if ($ThisFileInfo['filesize'] > $ThisFileInfo['lyrics3']['tag_offset_end']) {
                 $DataAfterLyrics3 = fread($fp, $ThisFileInfo['filesize'] - $ThisFileInfo['lyrics3']['tag_offset_end']);
             }
             ftruncate($fp, $ThisFileInfo['lyrics3']['tag_offset_start']);
             if (!empty($DataAfterLyrics3)) {
                 fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_start'], SEEK_SET);
                 fwrite($fp, $DataAfterLyrics3, strlen($DataAfterLyrics3));
             }
             flock($fp, LOCK_UN);
             fclose($fp);
             ignore_user_abort($oldignoreuserabort);
             return true;
         } else {
             $this->errors[] = 'Cannot fopen(' . $this->filename . ', "a+b")';
             return false;
         }
     }
     // no Lyrics3 present
     return true;
 }
开发者ID:ricofreak,项目名称:omekaArchiveProject,代码行数:31,代码来源:write.lyrics3.php


示例2: mkdir

  */
 public function mkdir($savepath)
 {
     return true;
 }
 /**
  * 保存指定文件
  * @param  array   $file    保存的文件信息
  * @param  boolean $replace 同名文件是否覆盖
  * @return boolean          保存状态,true-成功,false-失败
  */
 public function save($file, $replace = true)
 {
     $header['Content-Type'] = $file['type'];
     $header['Content-MD5'] = $file['md5'];
     $header['Mkdir'] = 'true';
     $resource = fopen($file['tmp_name'], 'r');
     $save = $this->rootPath . $file['savepath'] . $file['savename'];
     $data = $this->request($save, 'PUT', $header, $resource);
     return false === $data ? false : true;
 }
 /**
  * 获取最后一次上传错误信息
  * @return string 错误信息
  */
 public function getError()
 {
     return $this->error;
 }
 /**
  * 请求又拍云服务器
  * @param  string   $path    请求的PATH
  * @param  string   $method  请求方法
  * @param  array    $headers 请求header
  * @param  resource $body    上传文件资源
  * @return boolean
  */
 private function request($path, $method, $headers = null, $body = null)
 {
     $uri = "/{$this->config['bucket']}/{$path}";
     $ch = curl_init($this->config['host'] . $uri);
     $_headers = array('Expect:');
     if (!is_null($headers) && is_array($headers)) {
         foreach ($headers as $k => $v) {
             array_push($_headers, "{$k}: {$v}");
         }
     }
     $length = 0;
     $date = gmdate('D, d M Y H:i:s \\G\\M\\T');
     if (!is_null($body)) {
         if (is_resource($body)) {
             fseek($body, 0, SEEK_END);
             $length = ftell($body);
             fseek($body, 0);
             array_push($_headers, "Content-Length: {$length}");
             curl_setopt($ch, CURLOPT_INFILE, $body);
             curl_setopt($ch, CURLOPT_INFILESIZE, $length);
         } else {
             $length = @strlen($body);
             array_push($_headers, "Content-Length: {$length}");
             curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
开发者ID:RqHe,项目名称:aunet1,代码行数:61,代码来源:Upyun.class.php


示例3: fsize

function fsize($file)
{
    // filesize will only return the lower 32 bits of
    // the file's size! Make it unsigned.
    $fmod = filesize($file);
    if ($fmod < 0) {
        $fmod += 2.0 * (PHP_INT_MAX + 1);
    }
    // find the upper 32 bits
    $i = 0;
    $myfile = fopen($file, "r");
    // feof has undefined behaviour for big files.
    // after we hit the eof with fseek,
    // fread may not be able to detect the eof,
    // but it also can't read bytes, so use it as an
    // indicator.
    while (strlen(fread($myfile, 1)) === 1) {
        fseek($myfile, PHP_INT_MAX, SEEK_CUR);
        $i++;
    }
    fclose($myfile);
    // $i is a multiplier for PHP_INT_MAX byte blocks.
    // return to the last multiple of 4, as filesize has modulo of 4 GB (lower 32 bits)
    if ($i % 2 == 1) {
        $i--;
    }
    // add the lower 32 bit to our PHP_INT_MAX multiplier
    return (double) $i * (PHP_INT_MAX + 1) + $fmod;
}
开发者ID:netor27,项目名称:UnovaPrivado,代码行数:29,代码来源:funcionesParaArchivos.php


示例4: analyze

 /**
  * @return bool
  */
 public function analyze()
 {
     $info =& $this->getid3->info;
     fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
     $EXEheader = fread($this->getid3->fp, 28);
     $magic = 'MZ';
     if (substr($EXEheader, 0, 2) != $magic) {
         $info['error'][] = 'Expecting "' . Helper::PrintHexBytes($magic) . '" at offset ' . $info['avdataoffset'] . ', found "' . Helper::PrintHexBytes(substr($EXEheader, 0, 2)) . '"';
         return false;
     }
     $info['fileformat'] = 'exe';
     $info['exe']['mz']['magic'] = 'MZ';
     $info['exe']['mz']['raw']['last_page_size'] = Helper::LittleEndian2Int(substr($EXEheader, 2, 2));
     $info['exe']['mz']['raw']['page_count'] = Helper::LittleEndian2Int(substr($EXEheader, 4, 2));
     $info['exe']['mz']['raw']['relocation_count'] = Helper::LittleEndian2Int(substr($EXEheader, 6, 2));
     $info['exe']['mz']['raw']['header_paragraphs'] = Helper::LittleEndian2Int(substr($EXEheader, 8, 2));
     $info['exe']['mz']['raw']['min_memory_paragraphs'] = Helper::LittleEndian2Int(substr($EXEheader, 10, 2));
     $info['exe']['mz']['raw']['max_memory_paragraphs'] = Helper::LittleEndian2Int(substr($EXEheader, 12, 2));
     $info['exe']['mz']['raw']['initial_ss'] = Helper::LittleEndian2Int(substr($EXEheader, 14, 2));
     $info['exe']['mz']['raw']['initial_sp'] = Helper::LittleEndian2Int(substr($EXEheader, 16, 2));
     $info['exe']['mz']['raw']['checksum'] = Helper::LittleEndian2Int(substr($EXEheader, 18, 2));
     $info['exe']['mz']['raw']['cs_ip'] = Helper::LittleEndian2Int(substr($EXEheader, 20, 4));
     $info['exe']['mz']['raw']['relocation_table_offset'] = Helper::LittleEndian2Int(substr($EXEheader, 24, 2));
     $info['exe']['mz']['raw']['overlay_number'] = Helper::LittleEndian2Int(substr($EXEheader, 26, 2));
     $info['exe']['mz']['byte_size'] = ($info['exe']['mz']['raw']['page_count'] - 1) * 512 + $info['exe']['mz']['raw']['last_page_size'];
     $info['exe']['mz']['header_size'] = $info['exe']['mz']['raw']['header_paragraphs'] * 16;
     $info['exe']['mz']['memory_minimum'] = $info['exe']['mz']['raw']['min_memory_paragraphs'] * 16;
     $info['exe']['mz']['memory_recommended'] = $info['exe']['mz']['raw']['max_memory_paragraphs'] * 16;
     $info['error'][] = 'EXE parsing not enabled in this version of GetId3Core() [' . $this->getid3->version() . ']';
     return false;
 }
开发者ID:Nattpyre,项目名称:rocketfiles,代码行数:34,代码来源:Exe.php


示例5: _fstrpos

function _fstrpos($resource, $str, $direction = 1)
{
    $pos = ftell($resource);
    $buff = fgets($resource);
    fseek($resource, $pos);
    return $pos + ($direction == 1 ? strpos($buff, $str) : strrpos($buff, $str));
}
开发者ID:neel,项目名称:bong,代码行数:7,代码来源:common.php


示例6: executeTask

 /**
  * Executes the task
  *
  * @param array              $uParameters  parameters
  * @param FormatterInterface $uFormatter   formatter class
  *
  * @return int exit code
  */
 public function executeTask(array $uParameters, FormatterInterface $uFormatter)
 {
     if (!isset($uParameters[0])) {
         $uFormatter->writeColor("red", "parameter needed: database name.");
         return 1;
     }
     $tDatabase = $uParameters[0];
     // set up server class
     $tServer = new Server($this->services);
     $tServer->connect();
     // set output
     $tHandle = tmpfile();
     // start dumping database to a local file
     $uFormatter->writeColor("green", "reading sql dump from the server for database '{$tDatabase}'...");
     $tServer->dump($tDatabase, $tHandle);
     // seek to the beginning
     fseek($tHandle, 0);
     // set up client class
     $tClient = new Client($this->services);
     $uFormatter->writeColor("green", "writing dump to the client...");
     // execute sql at the client
     $tClient->connect();
     $tClient->dropAndCreateDatabase($tDatabase);
     $tClient->executeStream($tHandle);
     // close and destroy the file
     fclose($tHandle);
     $uFormatter->writeColor("yellow", "done.");
     return 0;
 }
开发者ID:eserozvataf,项目名称:sqlsync,代码行数:37,代码来源:TransferTask.php


示例7: read_history

function read_history($history_file, $history_pos, $repo_path)
{
    $fp = fopen($history_file, "r") or die("Unable to open file!");
    $pos = -2;
    // Skip final new line character (Set to -1 if not present)
    $lines = array();
    $currentLine = '';
    while (-1 !== fseek($fp, $pos, SEEK_END)) {
        $char = fgetc($fp);
        if (PHP_EOL == $char) {
            $lines[] = $currentLine;
            $currentLine = '';
        } else {
            $currentLine = $char . $currentLine;
        }
        $pos--;
    }
    list($result, $build_id, $branch, $commit_id, $ci_pipeline_time) = split('[|]', $lines[$history_pos]);
    list($dummy, $result) = split('[:]', $result);
    $result = trim($result);
    list($dummy, $build_id) = split('[:]', $build_id);
    $build_id = trim($build_id);
    list($dummy, $branch) = split('[:]', $branch);
    $branch = trim($branch);
    list($dummy, $commit_id) = split('[:]', $commit_id);
    $commit_id = substr(trim($commit_id), -10);
    list($dummy, $ci_pipeline_time) = split('[:]', $ci_pipeline_time);
    $ci_pipeline_time = substr(trim($ci_pipeline_time), -10);
    $history = array("result" => $result, "build_id" => $build_id, "branch" => $branch, "commit_id" => $commit_id, "artifact_path" => "{$repo_path}/ci_fuel_opnfv/artifact/{$branch}/{$build_id}", "log" => "{$repo_path}/ci_fuel_opnfv/artifact/{$branch}/{$build_id}/ci.log", "iso" => "{$repo_path}/ci_fuel_opnfv/artifact/{$branch}/{$build_id}/opnfv-{$build_id}.iso", "ci_pipeline_time" => $ci_pipeline_time);
    return $history;
}
开发者ID:jonasbjurel,项目名称:OPNFV-Playground,代码行数:31,代码来源:history.php


示例8: export

 public function export(\Contao\DC_Table $dc)
 {
     $database = \Contao\Database::getInstance();
     $stage_id = $database->query("SELECT s.id FROM tl_beachcup_stage AS s WHERE s.start_date >= UNIX_TIMESTAMP() ORDER BY s.start_date ASC LIMIT 1")->fetchAssoc()["id"];
     $data = $database->query("select tl_beachcup_registration.id as ANMELDUNG_ID, tl_beachcup_tournament.name_de AS TURNIER, DATE_FORMAT(from_unixtime(tl_beachcup_registration.tstamp), '%d.%m.%Y') as DATUM_ANMELDUNG,\n                                    p1.surname as NACHNAME_1, p1.name as VORNAME_1, p1.tax_number as STEUER_NR_1, DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL p1.birth_date SECOND), '%d.%m.%Y') as GEB_DATUM_1, p1.birth_place as GEB_ORT_1, p1.gender as GESCHLECHT_1, p1.address as ADRESSE_1, p1.zip_code as PLZ_1, p1.city as ORT_1, p1.country as LAND_1, p1.email as EMAIL_1, p1.phone_number as TEL_1, p1.shirt_size as SHIRT_1, p1.has_shirt as SHIRT_ERHALTEN_1, p1.is_fipav as FIPAV_1, p1level.description_de as SPIELER_LEVEL_1, p1.has_medical_certificate as AERZTL_ZEUGNIS_1, p1.is_confirmed as EIGENERKLAERUNG_1,\n                                    p2.surname as NACHNAME_2, p2.name as VORNAME_2, p2.tax_number as STEUER_NR_2, DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL p2.birth_date SECOND), '%d.%m.%Y') as GEB_DATUM_2, p2.birth_place as GEB_ORT_2, p2.gender as GESCHLECHT_2, p2.address as ADRESSE_2, p2.zip_code as PLZ_2, p2.city as ORT_2, p2.country as LAND_2, p2.email as EMAIL_2, p2.phone_number as TEL_2, p2.shirt_size as SHIRT_2, p2.has_shirt as SHIRT_ERHALTEN_2, p2.is_fipav as FIPAV_2, p2level.description_de as SPIELER_LEVEL_2, p2.has_medical_certificate as AERZTL_ZEUGNIS_2, p2.is_confirmed as EIGENERKLAERUNG_2,\n                                    tl_beachcup_registration_state.code as STATUS_ANMELDUNG\n                                    from tl_beachcup_registration\n                                    join tl_beachcup_team on tl_beachcup_team.id = tl_beachcup_registration.team_id\n                                    join tl_beachcup_player p1 on p1.id =  tl_beachcup_team.player_1\n                                    join tl_beachcup_player_level p1level on p1level.id = p1.player_level\n                                    join tl_beachcup_player p2 on p2.id =  tl_beachcup_team.player_2\n                                    join tl_beachcup_player_level p2level on p2level.id = p2.player_level\n                                    join tl_beachcup_tournament on tl_beachcup_tournament.id = tl_beachcup_registration.tournament_id\n                                    join tl_beachcup_registration_state on tl_beachcup_registration_state.id = tl_beachcup_registration.state_id\n                                    join tl_beachcup_stage on tl_beachcup_stage.id = tl_beachcup_tournament.stage_id\n                                    where tl_beachcup_stage.id = {$stage_id} and tl_beachcup_registration_state.code != 'REJECTED'\n                                    order by tl_beachcup_tournament.date, tl_beachcup_tournament.name_de, tl_beachcup_registration.tstamp;")->fetchAllAssoc();
     if (count($data) > 0) {
         $headers = array();
         foreach ($data[0] as $key => $value) {
             $headers[] = $key;
         }
         $file = fopen("php://memory", "w");
         fputcsv($file, $headers, ";");
         foreach ($data as $record) {
             fputcsv($file, $record, ";");
         }
         fseek($file, 0);
         header('Content-Encoding: iso-8859-1');
         header('Content-Type: application/csv; charset=iso-8859-1');
         header('Content-Disposition: attachement; filename="Anmeldungen.csv";');
         echo "";
         fpassthru($file);
         exit;
     }
     \Contao\Controller::redirect('contao/main.php?do=registration');
 }
开发者ID:Jobu,项目名称:core,代码行数:25,代码来源:RegistrationExport.php


示例9: load

 public function load()
 {
     /**
      * Trick: open in append mode to read,
      * place pointer to begin
      * create if not exists
      */
     $f = fopen($this->_configFile, "a+");
     fseek($f, 0, SEEK_SET);
     $size = filesize($this->_configFile);
     if (!$size) {
         $this->store();
         return;
     }
     $headerLen = strlen(self::HEADER);
     $contents = fread($f, $headerLen);
     if (self::HEADER != $contents) {
         $this->store();
         return;
     }
     $size -= $headerLen;
     $contents = fread($f, $size);
     $data = @unserialize($contents);
     if ($data === unserialize(false)) {
         $this->store();
         return;
     }
     foreach ($data as $k => $v) {
         $this->{$k} = $v;
     }
     fclose($f);
 }
开发者ID:natxetee,项目名称:magento2,代码行数:32,代码来源:Config.php


示例10: SaveSession

 function SaveSession($session)
 {
     $name = $this->file['name'];
     if (!$this->opened_file) {
         if (!($this->opened_file = fopen($name, 'c+'))) {
             return $this->SetPHPError('could not open the token file ' . $name, $php_error_message);
         }
     }
     if (!flock($this->opened_file, LOCK_EX)) {
         return $this->SetPHPError('could not lock the token file ' . $name . ' for writing', $php_error_message);
     }
     if (fseek($this->opened_file, 0)) {
         return $this->SetPHPError('could not rewind the token file ' . $name . ' for writing', $php_error_message);
     }
     if (!ftruncate($this->opened_file, 0)) {
         return $this->SetPHPError('could not truncate the token file ' . $name . ' for writing', $php_error_message);
     }
     if (!fwrite($this->opened_file, json_encode($session))) {
         return $this->SetPHPError('could not write to the token file ' . $name, $php_error_message);
     }
     if (!fclose($this->opened_file)) {
         return $this->SetPHPError('could not close to the token file ' . $name, $php_error_message);
     }
     $this->opened_file = false;
     return true;
 }
开发者ID:olivercieliszak,项目名称:orw,代码行数:26,代码来源:file_oauth_client.php


示例11: seek

 /**
  * {@inheritdoc}
  *
  * @see \Contrib\Component\File\SeekableFileInterface::seek()
  */
 public function seek($offset, $whence = SEEK_SET)
 {
     if (isset($this->handle) && is_resource($this->handle)) {
         return fseek($this->handle, $offset, $whence) === 0;
     }
     throw new \RuntimeException('File handle is not set.');
 }
开发者ID:ngangchill,项目名称:FileClient,代码行数:12,代码来源:AbstractFileHandler.php


示例12: connect

 function connect($filename, $encode = "EUC-JP")
 {
     $allData = array();
     //一時ファイルを使い、一気に文字コード変換
     if (!file_exists($filename)) {
         return false;
     }
     if (!($fileData = file_get_contents($filename))) {
         return false;
     }
     $fileData = mb_convert_encoding($fileData, "UTF-8", $encode);
     // 一時ファイルに書き込み
     $handle = tmpfile();
     $size = fwrite($handle, $fileData);
     fseek($handle, 0);
     while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) {
         $line = array();
         foreach ($data as $val) {
             echo $val;
             $line[] = trim($val);
         }
         $allData[] = $line;
     }
     fclose($handle);
     if ($this->allData = $allData) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:aim-web-projects,项目名称:ann-cosme,代码行数:30,代码来源:DB_CSV.class.php


示例13: getid3_exe

 function getid3_exe(&$fd, &$ThisFileInfo)
 {
     fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
     $EXEheader = fread($fd, 28);
     if (substr($EXEheader, 0, 2) != 'MZ') {
         $ThisFileInfo['error'][] = 'Expecting "MZ" at offset ' . $ThisFileInfo['avdataoffset'] . ', found "' . substr($EXEheader, 0, 2) . '" instead.';
         return false;
     }
     $ThisFileInfo['fileformat'] = 'exe';
     $ThisFileInfo['exe']['mz']['magic'] = 'MZ';
     $ThisFileInfo['exe']['mz']['raw']['last_page_size'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 2, 2));
     $ThisFileInfo['exe']['mz']['raw']['page_count'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 4, 2));
     $ThisFileInfo['exe']['mz']['raw']['relocation_count'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 6, 2));
     $ThisFileInfo['exe']['mz']['raw']['header_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 8, 2));
     $ThisFileInfo['exe']['mz']['raw']['min_memory_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 10, 2));
     $ThisFileInfo['exe']['mz']['raw']['max_memory_paragraphs'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 12, 2));
     $ThisFileInfo['exe']['mz']['raw']['initial_ss'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 14, 2));
     $ThisFileInfo['exe']['mz']['raw']['initial_sp'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 16, 2));
     $ThisFileInfo['exe']['mz']['raw']['checksum'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 18, 2));
     $ThisFileInfo['exe']['mz']['raw']['cs_ip'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 20, 4));
     $ThisFileInfo['exe']['mz']['raw']['relocation_table_offset'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 24, 2));
     $ThisFileInfo['exe']['mz']['raw']['overlay_number'] = getid3_lib::LittleEndian2Int(substr($EXEheader, 26, 2));
     $ThisFileInfo['exe']['mz']['byte_size'] = ($ThisFileInfo['exe']['mz']['raw']['page_count'] - 1) * 512 + $ThisFileInfo['exe']['mz']['raw']['last_page_size'];
     $ThisFileInfo['exe']['mz']['header_size'] = $ThisFileInfo['exe']['mz']['raw']['header_paragraphs'] * 16;
     $ThisFileInfo['exe']['mz']['memory_minimum'] = $ThisFileInfo['exe']['mz']['raw']['min_memory_paragraphs'] * 16;
     $ThisFileInfo['exe']['mz']['memory_recommended'] = $ThisFileInfo['exe']['mz']['raw']['max_memory_paragraphs'] * 16;
     $ThisFileInfo['error'][] = 'EXE parsing not enabled in this version of getID3()';
     return false;
 }
开发者ID:ninthlink,项目名称:m2m,代码行数:29,代码来源:module.misc.exe.php


示例14: logAction

 public function logAction()
 {
     $pageSize = 4096;
     $overlapSize = 128;
     $dir = APPLICATION_PATH . '/../data/logs/';
     $file = $this->_getParam('file', null);
     $this->view->page = $this->_getParam('page', 0);
     if ($file === null) {
         $file = sprintf('%s_application.log', Zend_Date::now()->toString('yyyy.MM.dd'));
     }
     $fp = fopen($dir . $file, 'r');
     fseek($fp, -$pageSize * ($this->view->page + 1) + $overlapSize, SEEK_END);
     $this->view->errorLog = fread($fp, $pageSize + $overlapSize * 2);
     fclose($fp);
     $iterator = new DirectoryIterator($dir);
     while ($iterator->valid()) {
         if (!$iterator->isDot()) {
             if ($iterator->isFile()) {
                 $files[$iterator->getFilename()] = $iterator->getPathName();
             }
         }
         $iterator->next();
     }
     $this->view->itemCountPerPage = $pageSize;
     $this->view->totalItemCount = filesize($dir . $file);
     $this->view->files = $files;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:27,代码来源:IndexController.php


示例15: find

 public static function find($ip)
 {
     if (empty($ip) === TRUE) {
         return 'N/A';
     }
     $nip = gethostbyname($ip);
     $ipdot = explode('.', $nip);
     if ($ipdot[0] < 0 || $ipdot[0] > 255 || count($ipdot) !== 4) {
         return 'N/A';
     }
     if (self::$fp === NULL) {
         self::init();
     }
     $nip2 = pack('N', ip2long($nip));
     $tmp_offset = (int) $ipdot[0] * 4;
     $start = unpack('Vlen', self::$index[$tmp_offset] . self::$index[$tmp_offset + 1] . self::$index[$tmp_offset + 2] . self::$index[$tmp_offset + 3]);
     $index_offset = $index_length = NULL;
     $max_comp_len = self::$offset['len'] - 1024 - 4;
     for ($start = $start['len'] * 8 + 1024; $start < $max_comp_len; $start += 8) {
         if (self::$index[$start] . self::$index[$start + 1] . self::$index[$start + 2] . self::$index[$start + 3] >= $nip2) {
             $index_offset = unpack('Vlen', self::$index[$start + 4] . self::$index[$start + 5] . self::$index[$start + 6] . "");
             $index_length = unpack('Clen', self::$index[$start + 7]);
             break;
         }
     }
     if ($index_offset === NULL) {
         return 'N/A';
     }
     fseek(self::$fp, self::$offset['len'] + $index_offset['len'] - 1024);
     $ret_arr = explode("\t", fread(self::$fp, $index_length['len']));
     return array('country' => $ret_arr[0], 'province' => $ret_arr[1], 'city' => $ret_arr[2]);
 }
开发者ID:haohaizihcc,项目名称:commonswoole,代码行数:32,代码来源:ip.php


示例16: _goto

 /** @todo docblock */
 private function _goto($id)
 {
     fseek($this->_fh, $id == 0 ? 0 : $this->_positions[$id - 1]);
     fgets($this->_fh);
     // consume first line (mbox marker)
     return $this->_positions[$id];
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:8,代码来源:Mbox.php


示例17: read

 /**
  * Read the contents of a file
  *
  * @param string $filename The full file path
  * @param boolean $incpath Use include path
  * @param int $amount Amount of file to read
  * @param int $chunksize Size of chunks to read
  * @param int $offset Offset of the file
  * @return mixed Returns file contents or boolean False if failed
  * @since 1.5
  */
 function read($filename, $incpath = false, $amount = 0, $chunksize = 8192, $offset = 0)
 {
     // Initialize variables
     $data = null;
     if ($amount && $chunksize > $amount) {
         $chunksize = $amount;
     }
     if (false === ($fh = fopen($filename, 'rb', $incpath))) {
         JError::raiseWarning(21, 'extFile::read: ' . JText::_('Unable to open file') . ": '{$filename}'");
         return false;
     }
     clearstatcache();
     if ($offset) {
         fseek($fh, $offset);
     }
     if ($fsize = @filesize($filename)) {
         if ($amount && $fsize > $amount) {
             $data = fread($fh, $amount);
         } else {
             $data = fread($fh, $fsize);
         }
     } else {
         $data = '';
         $x = 0;
         // While its:
         // 1: Not the end of the file AND
         // 2a: No Max Amount set OR
         // 2b: The length of the data is less than the max amount we want
         while (!feof($fh) && (!$amount || strlen($data) < $amount)) {
             $data .= fread($fh, $chunksize);
         }
     }
     fclose($fh);
     return $data;
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:46,代码来源:file.php


示例18: phpfiwa_check

function phpfiwa_check($engine_properties)
{
    $dir = $engine_properties['dir'];
    $files = scandir($dir);
    $feeds = array();
    for ($i = 2; $i < count($files); $i++) {
        $filename_parts = explode(".", $files[$i]);
        $feedid = (int) $filename_parts[0];
        if ($feedid > 0 && !in_array($feedid, $feeds)) {
            $feeds[] = $feedid;
        }
    }
    $error_count = 0;
    $n = 0;
    foreach ($feeds as $id) {
        $error = false;
        $errormsg = "";
        // 1) Analyse meta file
        $feedname = "{$id}.meta";
        // CHECK 1: META FILE EXISTS
        if (!file_exists($dir . $feedname)) {
            print "[Meta file does not exist: {$id}]\n";
            $error = true;
        } else {
            $meta = new stdClass();
            $metafile = fopen($dir . $feedname, 'rb');
            fseek($metafile, 4);
            $tmp = unpack("I", fread($metafile, 4));
            $meta->start_time = $tmp[1];
            $tmp = unpack("I", fread($metafile, 4));
            $meta->nlayers = $tmp[1];
            for ($i = 0; $i < $meta->nlayers; $i++) {
                $tmp = unpack("I", fread($metafile, 4));
            }
            $meta->interval = array();
            for ($i = 0; $i < $meta->nlayers; $i++) {
                $tmp = unpack("I", fread($metafile, 4));
                $meta->interval[$i] = $tmp[1];
            }
            fclose($metafile);
            if ($meta->nlayers < 1 || $meta->nlayers > 4) {
                $errormsg .= "[nlayers out of range: " . $meta->nlayers . "]";
                $error = true;
            }
            if ($meta->start_time > 0 && filesize($dir . $id . "_0.dat") == 0) {
                $errormsg .= "[Start time set but datafile is empty]";
                $error = true;
            }
            if ($error) {
                print "Feed {$id} " . $errormsg . " [" . date("d:m:Y G:i", filemtime($dir . $feedname)) . "]\n";
            }
        }
        if ($error) {
            $error_count++;
        }
        $n++;
    }
    print "Error count: " . $error_count . "\n";
    print "Number of feeds: {$n}\n";
}
开发者ID:AndaDB,项目名称:usefulscripts,代码行数:60,代码来源:phpfiwa.php


示例19: getStream

 protected function getStream($string)
 {
     $stream = fopen('php://temp', 'r+');
     fwrite($stream, $string);
     fseek($stream, 0);
     return $stream;
 }
开发者ID:0x17de,项目名称:core,代码行数:7,代码来源:requesttest.php


示例20: download

 public function download($file, $name = '', $size = 0, $reload = false)
 {
     if ($name == '') {
         $name = basename($file);
     }
     $fp = fopen($file, 'rb');
     if (!$size) {
         $size = filesize($file);
     }
     $ranges = $this->getRange($size);
     if ($reload && $ranges != null) {
         header('HTTP/1.1 206 Partial Content');
         header('Accept-Ranges:bytes');
         header(sprintf('content-length:%u', $ranges['end'] - $ranges['start']));
         header(sprintf('content-range:bytes %s-%s/%s', $ranges['start'], $ranges['end'], $size));
         fseek($fp, sprintf('%u', $ranges['start']));
     } else {
         header('HTTP/1.1 200 OK');
         header('content-length:' . $size);
     }
     while (!feof($fp)) {
         echo fread($fp, round($this->_speed * 1024, 0));
         ob_flush();
         flush();
         //sleep(1);
     }
     $fp != null && fclose($fp);
 }
开发者ID:xpchg,项目名称:iBarn,代码行数:28,代码来源:FileDownload.class.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP fsocketopen函数代码示例发布时间:2022-05-15
下一篇:
PHP fscanf函数代码示例发布时间: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