Changeset 18168 for trunk/FACT++/www/showlog/index.php
- Timestamp:
- 04/14/15 17:00:49 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/www/showlog/index.php
r17928 r18168 335 335 336 336 $size = filesize($filename); 337 if ($size>30000000) // 30MB 338 { 339 header('HTTP/1.1 403 File too large.'); 340 print("File too large.\n"); 341 return; 342 } 343 344 // FIXME: Reading the file line by line avoids any danger that 345 // something yields a problem if files grow too large 346 $file = file($filename); 347 if ($file===false) 337 338 $file=array(); 339 $fp = fopen($filename, "r"); 340 341 if ($fp===false) 348 342 { 349 343 header('HTTP/1.1 403 Access forbidden.'); … … 352 346 } 353 347 354 $max = 10000; 355 $pos = 500; 356 $n = count($file); 357 if ($n>$max) 358 { 359 $file[$pos] = "\n<b>[...]</b>\n\n"; 360 array_splice($file, $pos+1, $n-$max); 361 } 348 fseek($fp, -min(10000000, $size), SEEK_END); 349 fgets($fp); 350 while(!feof($fp)) 351 { 352 $line = fgets($fp); 353 array_push($file, $line); 354 } 355 fclose($fp); 356 362 357 363 358 $dir = basename(dirname($filename));
Note:
See TracChangeset
for help on using the changeset viewer.