정의 위치
- ./classes/file/FileHandler.class.php
정의 내용
/** * Returns the content of the file * * @param string $filename Path of target file * @return string The content of the file. If target file does not exist, this function returns nothing. */ function readFile($filename) { if(($filename = self::exists($filename)) === FALSE || filesize($filename) < 1) { return; } return @file_get_contents($filename); }
파라메터
- string $filename : 내용을 읽고자 하는 파일의 경로.
용도
- 파일 내용을 반환한다. 파일이 존재하지 않을 경우 NULL.
예제
- ./addons/captcha/captcha.addon.php 내용 중 createCaptchaAudio()
-
function createCaptchaAudio($string) { $data = ''; $_audio = './addons/captcha/audio/F_%s.mp3'; for($i = 0, $c = strlen($string); $i < $c; $i++) { $_data = FileHandler::readFile(sprintf($_audio, $string{$i})); $start = rand(5, 68); // Random start in 4-byte header and 64 byte data $datalen = strlen($_data) - $start - 256; // Last unchanged 256 bytes for($j = $start; $j < $datalen; $j+=64) { $ch = ord($_data{$j}); if($ch < 9 || $ch > 119) { continue; } $_data{$j} = chr($ch + rand(-8, 8)); } $data .= $_data; } return $data; }
-