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


PHP fileSize函数代码示例

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


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

示例1: conv_ringtone

 function conv_ringtone($infile, $outbase)
 {
     /*
     $outfile = $outbase .'.wav';
     */
     $outfile = $outbase . '.mp3';
     if (strToLower(subStr($infile, -4, 4)) === '.mp3') {
         if (fileSize($infile) <= 1000000) {
             # 1 MB
             if (!@copy($infile, $outfile)) {
                 return false;
             }
             return $outfile;
         }
     }
     /*
     if     (is_executable( '/usr/local/bin/mpg123' ))
     	$mpg123 = '/usr/local/bin/mpg123';
     elseif (is_executable( '/usr/bin/mpg123' ))
     	$mpg123 = '/usr/bin/mpg123';
     elseif (is_executable( '/bin/mpg123' ))
     	$mpg123 = '/bin/mpg123';
     else
     	$mpg123 = 'mpg123';
     
     if (strToLower(subStr($infile, -4, 4)) === '.mp3') {
     	# convert mp3 to wav first
     	$wavfile = $infile .'.wav';
     	$cmd = $mpg123 .' -m -w - -n 1000 -q '. qsa($infile) .' > '. qsa($wavfile) .' 2>>/dev/null';
     	# cuts file after 1000 frames (around 2.3 MB, depending on the rate)
     	# don't use -r 8000 as that doesn't really work for VBR encoded MP3s
     	@exec($cmd, $out, $err);
     	if ($err != 0) {
     		if (is_file($wavfile)) @unlink( $wavfile );
     		return false;
     	}
     	$infile = $wavfile;
     	$rm_tmp = $wavfile;
     } else
     	$rm_tmp = false;
     
     $cmd = 'sox '. qsa($infile) .' -r 8000 -c 1 -w '. qsa($outfile) .' trim 0 125000s 2>>/dev/null';
     # WAV, PCM, 8 kHz, 16 bit, mono
     # "The time for loading the file should not be longer then 3 seconds.
     # Size < 250 KByte."
     # cuts file after 125000 samples (around 245 kB, 15 secs)
     @exec($cmd, $out, $err);
     if ($err != 0) {
     	# $err == 2 would be unknown format
     	if (is_file($outfile)) @unlink( $outfile );
     	if ($rm_tmp && is_file($rm_tmp)) @unlink($rm_tmp);
     	return false;
     }
     return $outfile;
     */
     //return false;
     return null;
     # not implemented
 }
开发者ID:philipp-kempgen,项目名称:amooma-gemeinschaft-pbx,代码行数:59,代码来源:capability.php

示例2: drawScores

function drawScores()
{
    $scoresFile = fopen("highscores.txt", "r") or die("Unable to open file!");
    $lines = explode("\n", fread($scoresFile, fileSize("highscores.txt")));
    fclose($scoresFile);
    echo "<ol style='color:white;'>";
    foreach ($lines as $line) {
        echo "<li>";
        echo $line;
        echo "</li>";
    }
    echo "</ol>";
}
开发者ID:jdsutton,项目名称:BlackDragonProductions,代码行数:13,代码来源:highscores.php

示例3: uploadCreate

 private function uploadCreate($file_name)
 {
     $fileSize = fileSize($file_name);
     $url = 'http://' . $this->upload_server_ip . '/gupload/create_file';
     $param = array('upload_token' => $this->upload_token, 'file_size' => $fileSize, 'slice_length' => 1024, 'ext' => $this->getFileExt($file_name));
     try {
         $result = json_decode(Http::post($url, $param));
         if (isset($result->error)) {
             $error = $result->error;
             throw new UploadException($error->description, $error->code);
         }
     } catch (UploadException $e) {
         echo $e->getError();
         exit;
     }
     return $result;
 }
开发者ID:newlifes01,项目名称:youkuupload-php-sdk,代码行数:17,代码来源:YoukuUploader.class.php

示例4: addScore

function addScore($score, $name)
{
    $maxScores = 10;
    // Open the scores file for reading
    $scoresFile = fopen("highscores.txt", "r") or die("Unable to open file!");
    // Read in the scores
    $lines = explode("\n", fread($scoresFile, fileSize("highscores.txt")));
    // Close the file
    fclose($scoresFile);
    // Sort the scores
    $scores = array($name => intval($score));
    //array_push($scores, intval($score));
    foreach ($lines as $line) {
        $data = explode(" ", $line);
        $name = $data[0];
        $score = intval($data[1]);
        if (empty($scores[$name]) || $score > $scores[$name]) {
            $scores[$name] = $score;
        }
    }
    arsort($scores);
    // Remove excess scores
    while (count($scores) > $maxScores) {
        array_pop($scores);
    }
    // Open the scores file for reading
    $scoresFile = fopen("highscores.txt", "w") or die("Unable to open file!");
    // Write the scores
    $i;
    $len = count($scores);
    foreach ($scores as $name => $score) {
        fwrite($scoresFile, $name . " " . strval($score));
        if ($i < $len - 1) {
            fwrite($scoresFile, "\n");
        }
        $i += 1;
    }
    // Close the file
    fclose($scoresFile);
}
开发者ID:jdsutton,项目名称:HighscoreBoard,代码行数:40,代码来源:addScore.php

示例5: __construct

 public function __construct($path, $name = null)
 {
     // Make sure error logs are ready.
     if ($this->logging === TRUE) {
         $this->prepareLogs();
     }
     // See what kind of file we should be working with
     // If path is simply a pointer to directory we will look to create a new file with name
     // Otherwise if it is pointing to file, let's open that file.
     if (is_dir($path) && $name) {
         // Create a file with that name in this path
         $this->file = fopen($path . $name, 'w');
         $this->path = $path . $name;
     } else {
         if (is_file($path) && is_writable($path)) {
             // Then let's go ahead and read it.
             $this->file = fopen($path, 'a+');
             $this->path = $path;
         }
     }
     // If by this point no file is set, error out.
     if (!$this->file) {
         return $this->processError($this->error[100]);
         die;
     }
     // Set some member variables.
     $this->isOpen = TRUE;
     $this->fileSize = fileSize($path) . ' bytes';
     $this->type = substr(strrchr($path, '.'), 1);
     $this->contentString = file_get_contents($path);
 }
开发者ID:schneidermankyle,项目名称:file.IO,代码行数:31,代码来源:file.class.php

示例6: getSize

function getSize($a)
{
    if (file_exists($a)) {
        return fileSize($a);
    }
}
开发者ID:jyyy410team,项目名称:hts,代码行数:6,代码来源:loaddir-old.php

示例7: downloadFile

 /**
  * Download file
  *
  * @param int $id
  *
  * @return Response
  */
 public function downloadFile($id)
 {
     $file = FmFile::where('status', Constants::$COMMON_STATUSES['public'])->find($id);
     if (empty($file)) {
         App::abort('404');
     }
     $filePath = Utilities::getFileUploadPath() . $file->name;
     $content = file_get_contents($filePath);
     $contentLength = fileSize($filePath);
     $headers = array('Content-Length' => $contentLength, 'Content-disposition' => 'attachment; filename=' . $file->original_name);
     $finfo = new \finfo(FILEINFO_MIME_TYPE);
     $contentType = $finfo->buffer($content);
     if ($contentType == 'audio/mpeg') {
         $headers['Content-Type'] = 'application/octet-stream';
     }
     $response = Response::make($content);
     foreach ($headers as $headerName => $headerValue) {
         $response->header($headerName, $headerValue);
     }
     return $response;
 }
开发者ID:hungdo89,项目名称:file-manager,代码行数:28,代码来源:FrontendController.php

示例8: file

<!DOCTYPE html>
<html>
<head>
    <title>Course list</title>
    <meta charset="utf-8" />
    <link href="courses.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="header">
    <h1>Courses at CSE</h1>
<!-- Ex. 1: File of Courses -->
    <p>
    <?php 
$courses = file("courses.tsv");
$fileSize = fileSize("courses.tsv");
?>
        Course list has <?php 
echo count($courses);
?>
 total courses
        and
        size of <?php 
echo $fileSize;
?>
 bytes.
    </p>
</div>
<div class="article">
    <div class="section">
        <h2>Today's Courses</h2>
<!-- Ex. 2: Today’s Courses & Ex 6: Query Parameters -->
开发者ID:heojae91,项目名称:webLab00,代码行数:31,代码来源:courses.php

示例9: fopen

<?php

echo "Hold on, opening files...\n";
$fh = fopen("version.txt", "r");
$version = fread($fh, fileSize("version.txt"));
fclose($fh);
echo "Calculating stuffs...";
$version = $version++;
echo "You are committing version r{$version}.";
$fh = fopen("version.txt", "w");
fwrite($fh, $version);
fclose($fh);
// loop through each element in the $argv array
$i = 0;
foreach ($argv as $value) {
    if (!$i == 0) {
        $commitdata = $commitdata . $value;
    }
    $i++;
}
system("git commit -a -m 'r{$version} - {$commitdata}'");
echo "Done! Run git push to see it on GitHub.";
开发者ID:TDLive,项目名称:pre2013,代码行数:22,代码来源:commit.php

示例10: sleep

        return;
    }
    sleep(4);
    clearStatCache();
}
# download in progress?
#
if (file_exists('/tmp/gpbx-downloading-upgrade.pid') || (int) @shell_exec('sudo ps ax 2>>/dev/null | grep gpbx-upgrade-download | grep -v grep | wc -l') > 0) {
    echo '<br /><p>', 'Momentan wird ein Upgrade heruntergeladen.', '</p>', "\n";
    $upgrade_info = @gs_file_get_contents($gpbx_userdata . 'upgrades/upgrade-info');
    //$upgrade_info = ' gpbx_upgrade_size = 250420000 ';
    if (preg_match('/^\\s*gpbx_upgrade_size\\s*=\\s*([^\\s]*)/m', $upgrade_info, $m)) {
        $upgrade_size = (int) _upgrade_info_decode_val($m[1]);
        if ($upgrade_size > 50) {
            if (file_exists($gpbx_userdata . 'upgrades/dl/download')) {
                $download_size = @fileSize($gpbx_userdata . 'upgrades/dl/download');
                //$download_size = 210420000;
                if ($download_size !== false) {
                    echo '<p>', 'Fortschritt', ': &nbsp; <b>', number_format($download_size / $upgrade_size * 100, 1, ',', ''), ' %</b>';
                    if ($upgrade_size > 1000000) {
                        $factor = 1000000;
                        $units = 'MB';
                    } elseif ($upgrade_size > 1000) {
                        $factor = 1000;
                        $units = 'kB';
                    } else {
                        $factor = 1;
                        $units = 'B';
                    }
                    echo ' &nbsp; (', round($download_size / $factor), ' / ', round($upgrade_size / $factor), ' ', $units, ')</p>', "\n";
                    echo '<pre>';
开发者ID:rkania,项目名称:GS3,代码行数:31,代码来源:system_gpbx-upgrade.php

示例11: fopen

<html>
    <head>
        <title>Candace's Phonebook</title>
        <link href="css/bootstrap.min.css"
              rel="stylesheet"
              type="text/css" />
        <link href="css/indexStylesheet.css"
              rel="stylesheet"
              type="text/css" />
    </head>
    <body>
        <div id="contactList" class="container">
            <?php 
//This will generate the list of phonebook entries on this page
$phonesFile = fopen("phones.dat", "r") or die("Unable to open file");
if (fileSize("phones.dat") > 0) {
    $allEntries = fread($phonesFile, filesize("phones.dat"));
    $entries = explode("\r\n", $allEntries);
    foreach ($entries as $entry) {
        if ($entry != $entries[count($entries) - 1]) {
            echo '<a href="' . "update.php?entry={$entry}" . '">' . $entry . '</a> (<a href="' . "delete.php?entry={$entry}" . '">x</a>)<br />';
        }
    }
} else {
    $allEntries = "No entries";
    echo $allEntries . "\r\n";
}
?>

            <br /><button id="addButton">Add a Phone Number</button>
        </div>
开发者ID:Candace-Williford,项目名称:ProjectsFromSchool,代码行数:31,代码来源:index.php

示例12: Test_of_binary_data_on_database

 public function Test_of_binary_data_on_database()
 {
     $ar_path = AK_FRAMEWORK_DIR . DS . 'active_record' . DS . 'base.php';
     $long_string = file_get_contents($ar_path);
     $_tmp_file = fopen($ar_path, "rb");
     $binary_data = fread($_tmp_file, fileSize($ar_path));
     $i = 1;
     $details = array('varchar_field' => "{$i} string ", 'longtext_field' => $long_string, 'text_field' => "{$i} text", 'logblob_field' => $binary_data, 'date_field' => "2005/05/{$i}", 'datetime_field' => "2005/05/{$i}", 'tinyint_field' => $i, 'integer_field' => $i, 'smallint_field' => $i, 'bigint_field' => $i, 'double_field' => "{$i}.{$i}", 'numeric_field' => $i, 'bytea_field' => $binary_data, 'timestamp_field' => "2005/05/{$i} {$i}:{$i}:{$i}", 'boolean_field' => !($i % 2), 'int2_field' => "{$i}", 'int4_field' => $i, 'int8_field' => $i, 'foat_field' => "{$i}.{$i}", 'varchar4000_field' => "{$i} text", 'clob_field' => "{$i} text", 'nvarchar2000_field' => "{$i} text", 'blob_field' => $binary_data, 'nvarchar_field' => "{$i}", 'decimal1_field' => "{$i}", 'decimal3_field' => $i, 'decimal5_field' => $i, 'decimal10_field' => "{$i}", 'decimal20_field' => $i, 'decimal_field' => $i);
     $AkTestField = new AkTestField($details);
     $this->assertEqual($long_string, $binary_data);
     $this->assertTrue($AkTestField->save());
     $AkTestField = new AkTestField($AkTestField->getId());
     $this->assertEqual($AkTestField->longtext_field, $long_string);
     $this->assertEqual($AkTestField->bytea_field, $binary_data);
     $this->assertEqual($AkTestField->blob_field, $binary_data);
     $this->assertEqual($AkTestField->logblob_field, $binary_data);
 }
开发者ID:bermi,项目名称:akelos,代码行数:17,代码来源:legacy_tests_3.php

示例13: isVaild

   	private function isVaild($file ,$validate)
	{
		
		if($validate === []) return true ; 
		if(array_key_exists("isVaildSize" , $validate))
		{
			$size = strtolower($validate["isVaildSize"]);
			$sizes = [
				"b"=> 1,
				"kb" => 1024 ,
				"mb" => 1024*1024 ,
				"gb" => 1024*1024*1024,
				"tb" => 1024*1024*1024*1024,
			];
			
			if(preg_match("/kb|mb|gb|tb|byte/" , $validate["isVaildSize"] , $output))
			{
				if(preg_match("/[\>\<\:\=]{1,2}/" ,$validate["isVaildSize"] , $x))
				{
					$validate["isVaildSize"] = str_replace($x[0] , "" , $validate["isVaildSize"]) ;
				}
				$size = (int) str_replace($output[0] , "" ,$validate["isVaildSize"]) ;
				$size*=$sizes[$output[0]] ;
				if(!$this->isVaildRange(fileSize($file) , $x[0].$size))
				{
					$this->latestValidateError = "inVaildSize" ;
					return false ; 
				}
			}
		} 
		
		if(in_array("isVaildImage" , $validate) || array_key_exists("isVaildDim" , $validate))
		{
			if($d = getimagesize($file))
			{
				if(array_key_exists("isVaildDim" , $validate))
				{
					$dims = explode("x" , strtolower($validate["isVaildDim"]));
					if(isset($dims[0]))
					{
						if(!$this->isVaildRange($d[0] , $dims[0]))
						{
							$this->latestValidateError = "notVaildWidth" ;
							return false ; 
						}
					}
					if(isset($dims[1]))
					{
						if(!$this->isVaildRange($d[1] , $dims[1]))
						{
							$this->latestValidateError = "notVaildHeight" ;
							return false ; 
						}
					}
					
				}
			}
			else
			{
				
				$this->latestValidateError = "notVaildImage" ;
				return false ;
				
			}
			
		}
		return true ; 
	}
开发者ID:ahmadmarafa,项目名称:Snippets,代码行数:68,代码来源:uploader.php

示例14: imagecreatefromblp

function imagecreatefromblp($fileName, $imgId = 0)
{
    if (!CLISetup::fileExists($fileName)) {
        CLISetup::log('file ' . $fileName . ' could not be found', CLISetup::LOG_ERROR);
        return;
    }
    $file = fopen($fileName, 'rb');
    if (!$file) {
        CLISetup::log('could not open file ' . $fileName, CLISetup::LOG_ERROR);
        return;
    }
    $fileSize = fileSize($fileName);
    if ($fileSize < 16) {
        CLISetup::log('file ' . $fileName . ' is too small for a BLP file', CLISetup::LOG_ERROR);
        return;
    }
    $data = fread($file, $fileSize);
    fclose($file);
    // predict replacement patch files
    // ref: http://www.zezula.net/en/mpq/patchfiles.html
    if (substr($data, 0x0, 0x4) == "PTCH") {
        // strip patch header
        if (substr($data, 0x40, 0x43) == "COPY") {
            $data = substr($data, 0x44);
        } else {
            CLISetup::log('file ' . $fileName . ' is an incremental patch file and cannot be used by this script.', CLISetup::LOG_ERROR);
            return;
        }
    }
    if (substr($data, 0, 4) != "BLP2") {
        CLISetup::log('file ' . $fileName . ' has incorrect/unsupported magic bytes', CLISetup::LOG_ERROR);
        return;
    }
    $header = unpack("Vformat/Ctype/CalphaBits/CalphaType/Cmips/Vwidth/Vheight", substr($data, 4, 16));
    $header['mipsOffs'] = unpack("V16", substr($data, 20, 64));
    $header['mipsSize'] = unpack("V16", substr($data, 84, 64));
    $debugStr = ' header = ' . print_r($header, true);
    if ($header['format'] != 1) {
        CLISetup::log('file ' . $fileName . ' has unsupported format' . $debugStr, CLISetup::LOG_ERROR);
        return;
    }
    $offs = $header['mipsOffs'][$imgId + 1];
    $size = $header['mipsSize'][$imgId + 1];
    while ($imgId > 0) {
        $header['width'] /= 2;
        $header['height'] /= 2;
        $imgId--;
    }
    if ($size == 0) {
        CLISetup::log('file ' . $fileName . ' contains zeroes in a mips table' . $debugStr, CLISetup::LOG_ERROR);
        return;
    }
    if ($offs + $size > $fileSize) {
        CLISetup::log('file ' . $fileName . ' is corrupted/incomplete' . $debugStr, CLISetup::LOG_ERROR);
        return;
    }
    if ($header['type'] == 1) {
        $img = icfb1($header['width'], $header['height'], substr($data, 148, 1024), substr($data, $offs, $size));
    } else {
        if ($header['type'] == 2) {
            $img = icfb2($header['width'], $header['height'], substr($data, $offs, $size), $header['alphaBits'], $header['alphaType']);
        } else {
            if ($header['type'] == 3) {
                $img = icfb3($header['width'], $header['height'], substr($data, $offs, $size));
            } else {
                CLISetup::log('file ' . $fileName . ' has unsupported type' . $debugStr, CLISetup::LOG_ERROR);
                return;
            }
        }
    }
    return $img;
}
开发者ID:saqar,项目名称:aowow,代码行数:72,代码来源:imagecreatefromblp.func.php

示例15: tAdventure


//.........这里部分代码省略.........
            }
        }
    }
    $cmd = cmd();
    if (!@isset($cmd) || $cmd == "") {
        tadventure($start, $pts, $items, true, $name);
    } elseif ($cmd == 'quit') {
        if (file_exists(".shocked.tmp")) {
            unlink(".shocked.tmp");
        }
        if (file_exists(".torch.tmp")) {
            unlink(".torch.tmp");
        }
        echo "Thanks for playing!\n";
        exit;
    } elseif ($cmd == 'save') {
        echo "Saving...\n";
        $fh = fopen("tadventure_save.txt", 'w') or tAdventure($start, $pts, $items, true, $name);
        fwrite($fh, "{$start}/{$pts}");
        foreach ($items as $value) {
            fwrite($fh, "/{$value}");
        }
        echo "Game saved!\n";
        tAdventure($start, $pts, $items, true, $name);
    } elseif ($cmd == "update") {
        system("wget --version > /dev/null", $wgetv);
        if (!$wgetv == 0) {
            echo "Error! wget is not installed!\n";
            tAdventure($start, $pts, $items, true);
        }
        echo "Checking the version...\n";
        system("wget -q https://raw.github.com/TDLive/tAdventure/master/version.txt -O version.txt");
        $fh = fopen("version.txt", "r");
        $version = fread($fh, fileSize("version.txt"));
        fclose($fh);
        if ($version == VERSION || $version < VERSION) {
            echo "Your version is too new/the latest!\n";
            tAdventure($start, $pts, $items, true, $name);
        } else {
            echo "Getting tAdventure...\n";
            system("wget -q https://raw.github.com/TDLive/tAdventure/master/adventure.php -O adventure.php");
            echo "Starting tAdventure...\n\n";
            system("php adventure.php", $exitcode);
            exit($exitcode);
        }
    } elseif ($cmd == "room") {
        echo "\n";
        tAdventure($start, $pts, $items);
    } elseif ($cmd == "left") {
        if ($rdat["connectsLeft"]) {
            foreach ($darkrooms as $value) {
                if ($rdat["connectsLeftId"] == $value) {
                    if (!file_exists(".torch.tmp")) {
                        echo "It's too dark to go down this way!\n";
                        tAdventure($start, $pts, $items, true, $name);
                    }
                }
            }
            tAdventure($rdat["connectsLeftId"], $pts, $items, false, $name);
        } else {
            echo "You can't go left.\n";
            tAdventure($start, $pts, $items, true, $name);
        }
    } elseif ($cmd == "right") {
        if ($rdat["connectsRight"]) {
            foreach ($darkrooms as $value) {
开发者ID:TDLive,项目名称:pre2013,代码行数:67,代码来源:adventure.php


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