本文整理汇总了PHP中gzgets函数的典型用法代码示例。如果您正苦于以下问题:PHP gzgets函数的具体用法?PHP gzgets怎么用?PHP gzgets使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gzgets函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fgets
function fgets($fp, $len = 8192)
{
if ($this->has_gzip()) {
return gzgets($fp, $len);
}
return fgets($fp, $len);
}
示例2: fgetcsvWrapper
function fgetcsvWrapper($fp)
{
global $gzipEnabled;
if ($gzipEnabled) {
// FIXME エスケープが必要なデータが来ると壊れるよーー
$r = gzgets($fp, 4000);
// $r = "";
// $r = "";
// do {
// $r .= gzgets($fp, 4000);
// } while(mb_substr_count($r,'"') % 2 == 1);
if ($r !== FALSE) {
// 行末の\r\nは消してから分割
$r = mb_ereg_replace("\r?\n\$", "", $r);
return explode("\t", $r);
} else {
return FALSE;
}
} else {
// return fgetcsv($fp, 4000, "\t", '"');
$r = fgets($fp, 4000);
if ($r !== FALSE) {
// 行末の\r\nは消してから分割
$r = mb_ereg_replace("\r?\n\$", "", $r);
return explode("\t", $r);
} else {
return FALSE;
}
}
}
示例3: LoadBackUp
function LoadBackUp()
{
global $SAMSConf;
global $USERConf;
$DB = new SAMSDB();
$lang = "./lang/lang.{$SAMSConf->LANG}";
require $lang;
if ($USERConf->ToWebInterfaceAccess("C") != 1) {
exit;
}
PageTop("reark_48.jpg", "{$backupbuttom_2_loadbase_LoadBackUp_1}");
if (($finp = gzopen($_FILES['userfile']['tmp_name'], "r")) != NULL) {
while (gzeof($finp) == 0) {
$string = gzgets($finp, 10000);
$QUERY = strtok($string, ";");
if (strstr($QUERY, "#") == FALSE) {
echo "{$QUERY}<BR>";
$num_rows = $DB->samsdb_query($QUERY . ";");
}
$count++;
}
}
print "<SCRIPT>\n";
print " parent.lframe.location.href=\"lframe.php\"; \n";
print "</SCRIPT> \n";
}
示例4: import
public function import()
{
// It might not look like it, but it is actually compatible to
// uncompressed files.
$gzFileHandler = gzopen($this->file, 'r');
Model\DownloadIntent::delete_all();
Model\DownloadIntentClean::delete_all();
$batchSize = 1000;
$batch = array();
while (!gzeof($gzFileHandler)) {
$line = gzgets($gzFileHandler);
list($id, $user_agent_id, $media_file_id, $request_id, $accessed_at, $source, $context, $geo_area_id, $lat, $lng) = explode(",", $line);
$batch[] = array($user_agent_id, $media_file_id, $request_id, $accessed_at, $source, $context, $geo_area_id, $lat, $lng);
if (count($batch) >= $batchSize) {
self::save_batch_to_db($batch);
$batch = [];
}
}
gzclose($gzFileHandler);
// save last batch to db
self::save_batch_to_db($batch);
\Podlove\Analytics\DownloadIntentCleanup::cleanup_download_intents();
\Podlove\Cache\TemplateCache::get_instance()->setup_purge();
wp_redirect(admin_url('admin.php?page=podlove_imexport_migration_handle&status=success'));
exit;
}
示例5: gets
/**
* Read a line
*
* This function is identical to readLine except that trailing CR and LF characters
* will be included in its return value
*
* @param int bytes default 4096 Max. ammount of bytes to be read
* @return string Data read
* @throws io.IOException in case of an error
*/
public function gets($bytes = 4096)
{
if (FALSE === ($result = gzgets($this->_fd, $bytes))) {
throw new IOException('gets() cannot read ' . $bytes . ' bytes from ' . $this->uri);
}
return $result;
}
示例6: import_sql
function import_sql($filename)
{
$handle = @gzopen($filename, "r");
// can open normal files, too.
$query = "";
$queries = 0;
while ($handle && !feof($handle)) {
$line = gzgets($handle, 1024);
// keep string manipulations sane
if ($line != "" && substr($line, 0, 2) != "--") {
// line doesnt start with comment
$query .= $line;
if (substr(trim($line), -1, 1) == ";") {
if (!mysql_query($query)) {
if (defined("DEBUG")) {
echo "MYSQL Error: " . mysql_error() . "<Br><br>in query: {$query}";
} else {
echo "MYSQL Error: " . mysql_error();
}
}
$query = "";
$queries++;
}
}
}
return true;
}
示例7: restoreAction
function restoreAction()
{
$backupFile = new UploadedFile("backupFile");
if (!$backupFile->wasUploaded()) {
return;
}
$gzipMode = $this->request->fileType == "gzip";
$fileName = $backupFile->getTempName();
$fp = $gzipMode ? gzopen($fileName, "r") : fopen($fileName, "r");
$inString = false;
$query = "";
while (!feof($fp)) {
$line = $gzipMode ? gzgets($fp) : fgets($fp);
if (!$inString) {
$isCommentLine = false;
foreach (array("#", "--") as $commentTag) {
if (strpos($line, $commentTag) === 0) {
$isCommentLine = true;
}
}
if ($isCommentLine || trim($line) == "") {
continue;
}
}
$deslashedLine = str_replace('\\', '', $line);
if ((substr_count($deslashedLine, "'") - substr_count($deslashedLine, "\\'")) % 2) {
$inString = !$inString;
}
$query .= $line;
if (substr_compare(rtrim($line), ";", -1) == 0 && !$inString) {
$this->database->sqlQuery($query);
$query = "";
}
}
}
示例8: _Open
/**
* Open the file containing the backup data
* @return String a String containing the DB Dump
* @access private
*/
function _Open()
{
$fp = gzopen($this->filename, "rb") or die("Error. No se pudo abrir el archivo {$this->filename}");
while (!gzeof($fp)) {
$line = gzgets($fp, 1024);
$SQL .= "{$line}";
}
gzclose($fp);
return $SQL;
}
示例9: __getline
function __getline()
{
switch ($this->type) {
case 'gz':
$this->line = trim(gzgets($this->handle));
break;
case 'file':
$this->line = trim(fgets($this->handle));
break;
}
}
示例10: process
public function process($dumpFile)
{
$handle = gzopen($dumpFile, "r");
while ($line = gzgets($handle, 100000000)) {
$data = json_decode(rtrim($line, ",\n"), true);
if ($data !== null) {
$entity = $this->entityDeserializer->deserialize($data);
$this->entityHandler->handleEntity($entity);
}
}
gzclose($handle);
}
示例11: readLine
/**
* Reads a line from a stream. If the optional argument is provided,
* the method terminates reading on raching the specified length.
*
* @throws Opl_Stream_Exception
* @param integer $length The maximum line length to read.
* @return string The returned string.
*/
public function readLine($length = null)
{
if (!is_resource($this->_stream)) {
throw new Opl_Stream_Exception('Input stream is not opened.');
}
$content = gzgets($this->_stream, (int) $length, "\r\n");
if ($content === false) {
throw new Opl_Stream_Exception('Unable to read a line from an input stream.');
}
$this->_readingPtr += strlen($content);
return $content;
}
示例12: gzgetcont
function gzgetcont($f)
{
$d = "";
$fo = gzopen($f, 'r');
if ($fo) {
while (!gzeof($fo)) {
$d .= gzgets($fo);
}
}
gzclose($fo);
return $d;
}
示例13: uncompress
/**
* Uncompress a map file.
*
* @param string $path
*
* @return string
*/
private static function uncompress($path)
{
if (!file_exists($path)) {
throw new InvalidArgumentException('File does not exist');
}
$data = '';
$gzo = gzopen($path, 'r');
while ($line = gzgets($gzo, 1024)) {
$data .= $line;
}
gzclose($gzo);
return $data;
}
示例14: import_sql
function import_sql($filename)
{
global $mysql;
$handle = @gzopen($filename, "r");
// can open normal files, too.
$query = "";
$queries = 0;
while ($handle && !feof($handle)) {
$line = gzgets($handle, 4096);
// keep string manipulations sane
if ($line != "" && substr($line, 0, 2) != "--") {
// line doesnt start with comment
$query .= $line;
if (substr(trim($line), -2, 2) == ");") {
$query = str_replace("NOT EXISTS `", "NOT EXISTS `" . DB_PREFIX, $query);
$query = str_replace("IF EXISTS `", "IF EXISTS `" . DB_PREFIX, $query);
$query = str_replace("TABLE `", "TABLE `" . DB_PREFIX, $query);
$query = str_replace("INTO `", "INTO `" . DB_PREFIX, $query);
$query = str_replace("TABLES `", "TABLES `" . DB_PREFIX, $query);
if (!$mysql->query($query)) {
if (defined("DEBUG")) {
die("MYSQL Error: " . $mysql->error . "<Br><br>in query: <textarea>{$query}</textarea><br>");
} else {
die("MYSQL Error: " . $mysql->error . "<br>");
}
}
$query = "";
$queries++;
} elseif (substr(trim($line), -1, 1) == ";") {
$query = str_replace("NOT EXISTS `", "NOT EXISTS `" . DB_PREFIX, $query);
$query = str_replace("IF EXISTS `", "IF EXISTS `" . DB_PREFIX, $query);
$query = str_replace("TABLE `", "TABLE `" . DB_PREFIX, $query);
$query = str_replace("INTO `", "INTO `" . DB_PREFIX, $query);
$query = str_replace("TABLES `", "TABLES `" . DB_PREFIX, $query);
if (!$mysql->query($query)) {
if (defined("DEBUG")) {
die("MYSQL Error: " . $mysql->error . "<Br><br>in query: <textarea>{$query}</textarea><br>");
} else {
die("MYSQL Error: " . $mysql->error . "<br>");
}
}
$query = "";
$queries++;
}
}
}
if ($queries == 0) {
die("NO QUERIES RUN<br>");
}
return true;
}
示例15: peekLine
public function peekLine()
{
$line = false;
if ($this->tResource !== false) {
if ($this->tLine === false) {
$this->tLine = gzgets($this->tResource, FileDecoder::BUFLEN);
}
if ($this->tLine !== false) {
$line = $this->tLine;
} else {
bzclose($this->tResource);
$this->tResource = false;
}
}
return $line;
}