本文整理汇总了PHP中filetype函数的典型用法代码示例。如果您正苦于以下问题:PHP filetype函数的具体用法?PHP filetype怎么用?PHP filetype使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filetype函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setPath
/**
* @param string $path
* @throws \Exception
*/
public function setPath($path)
{
if (!(filter_var($path, FILTER_VALIDATE_IP) || filter_var($path, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)) && (!file_exists($path) || filetype($path) !== 'socket')) {
throw new \Exception('Ruta o archivo no válido');
}
$this->path = $path;
}
示例2: files_identical
public static function files_identical($fn1, $fn2, array $exclude = [])
{
if (filetype($fn1) !== filetype($fn2)) {
return FALSE;
}
/* if (filesize($fn1) !== filesize($fn2))
return FALSE; */
if (!($fp1 = @fopen($fn1, 'r'))) {
return FALSE;
}
if (!($fp2 = @fopen($fn2, 'r'))) {
fclose($fp1);
return FALSE;
}
$same = TRUE;
$count = 1;
while (($bufer1 = fgets($fp1, 4096)) !== false && ($bufer2 = fgets($fp2, 4096)) !== false) {
if (!in_array($count, $exclude)) {
if ($bufer1 !== $bufer2) {
$same = FALSE;
break;
}
}
$count++;
}
fclose($fp1);
fclose($fp2);
return $same;
}
示例3: transfer_templates
function transfer_templates($dir, $root_dir, $level = 0)
{
if (!$dh = @opendir($dir))
die("ERROR! Unable to open directory " . $dir . ".\n");
while ($file = readdir($dh)) {
if ($file == "." || $file == "..")
continue;
$full_path = $dir . "/" . $file;
$filetype = filetype($full_path);
if ($filetype == "dir") {
transfer_templates($full_path, $root_dir, $level + 1);
continue;
}
if ($filetype != "file") // ignore special files and links
continue;
$ending = substr($file, strlen($file) - 4);
if ($ending != ".tpl") // ignore files that are not templates (end in .tpl)
continue;
$rel_path = substr($full_path, strlen($root_dir) + 1);
$sql = "INSERT IGNORE INTO Templates (Name, Level) values('"
. $rel_path . "', " . $level . ")";
if (!mysql_query($sql))
die("Unable to insert template " . $rel_path . ".\n");
}
}
示例4: dircrawl
function dircrawl($dir, $hash_array, $extension_exclusions)
{
$dir = rtrim($dir, "\\/");
$return = "";
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file != "." and $file != "..") {
if (filetype($dir . "\\" . $file) == "dir") {
$return .= dircrawl($dir . "\\" . $file, $hash_array, $extension_exclusions);
} else {
if (filetype($dir . "\\" . $file) == "file") {
if (!in_array(pathinfo($dir . "\\" . $file, PATHINFO_EXTENSION), $extension_exclusions)) {
$hash_output = "";
foreach ($hash_array as $hash_type) {
$hash_output .= ",\"" . hash_file($hash_type, $dir . "\\" . $file) . "\"";
}
$return .= "\"" . dirname($dir . "\\" . $file) . "\",\"" . basename($dir . "\\" . $file) . "\",\"" . filesize($dir . "\\" . $file) . "\"" . $hash_output . "\n";
}
}
}
}
}
}
return $return;
}
示例5: drawAdminTools_Tools
function drawAdminTools_Tools($domain)
{
global $adm_login;
global $adm_pass;
global $addrlink;
global $lang;
global $htaccess_edit_flag_selected_subdomain;
$out = "";
$out .= subdomainSelector($domain);
if ($htaccess_edit_flag_selected_subdomain == "yes") {
if (isset($_REQUEST["edit_folder"]) && $_REQUEST["edit_folder"] == "/") {
$link1 = "";
$link2 = "";
} else {
$link1 = "<a href=\"" . $_SERVER["PHP_SELF"] . "?adm_login={$adm_login}&adm_pass={$adm_pass}&addrlink={$addrlink}&edit_subdomain=" . $domain["subdomains"][$i]["name"] . "&edit_folder=/\">";
$link2 = "</a>";
}
$out .= "{$link1} / {$link2}";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
$out .= "fichier : {$file} : type : " . filetype($dir . $file);
}
closedir($dh);
}
}
}
return $out;
}
示例6: fetch_data
function fetch_data()
{
global $msg;
global $PMBuserid;
$this->error = "";
$this->info = array();
$i = 0;
if (!is_dir($this->path)) {
$this->error = $msg["admin_files_gestion_error_is_no_path"] . $this->path;
$this->path = "";
return;
}
if (($objects = @scandir($this->path)) !== false) {
foreach ($objects as $object) {
if ($object != '.' && $object != '..') {
if (filetype($this->path . "/" . $object) != "dir") {
$this->info[$i]['name'] = $object;
$this->info[$i]['path'] = $this->path;
$this->info[$i]['type'] = filetype($this->path . $object);
$i++;
}
}
}
}
}
示例7: loadRanksets
function loadRanksets()
{
global $ranksetData, $ranksetNames;
if (isset($ranksetNames)) {
return;
}
$ranksetData = array();
$ranksetNames = array();
$dir = "ranksets/";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (filetype($dir . $file) != "dir") {
continue;
}
if ($file == ".." || $file == ".") {
continue;
}
$infofile = $dir . $file . "/rankset.php";
if (file_exists($infofile)) {
include $infofile;
}
}
closedir($dh);
}
}
}
示例8: DealFP
/**
* 遍历指定的目录以及子目录,将符合条件的文件加入XML
* $p 指定的目录
*/
function DealFP($p){
$FilterDir = $GLOBALS["FilterDir"];
$IndexFileExt = $GLOBALS["IndexFileExt"];
$handle=opendir($p);
if ($p==".") $path = "";
else $path = $p."/";
while ($file = readdir($handle))
{
$d = filetype($path.$file);
if ((($d=='file')||($d=='dir'))&&($file!='.')&&($file!='..'))
{
$pf = $path.$file;
//echo "[".$d."]".$pf."<br>";
if ($d=='dir')
{
if (!(strpos($FilterDir, "|".$pf."|")))
{
DealFP($pf);
}
}else{
$ext = "|".strtolower(substr($file, strrpos($file, ".")+1))."|";
if (strpos($IndexFileExt, $ext))
{
$d = filemtime($pf);
$dt = date("Y-m-d",$d)."T".date("H:i:s",$d)."+00:00";
addToXML($pf, $dt);
}
}
}
}
closedir($handle);
}
示例9: getFiles
function getFiles($path, $filter = '*', $recursive = false)
{
//Ajusta os filtros
$filter = strtolower($filter);
//Ajusta o nome da pasta
if (substr($path, -1, 1) != '/') {
$path .= '/';
}
//Se o caminho informado nao for um diretorio, pula fora
if (!is_dir($path)) {
return array();
}
$files = array();
$dir = opendir($path);
while (($file = readdir($dir)) !== false) {
if ($file != '.' && $file != '..' && strtolower($file) != '.ds_store') {
//Se for um diretorio e estiver ativo a recursividade
if (is_dir($path . $file) && $recursive) {
//Busca os arquivos de dentro do diretorio
$files[] = array('file' => $file, 'path' => $path, 'full' => $path . $file . '/', 'type' => filetype($path . $file), 'ext' => '');
$files = array_merge($files, $this->getFiles($path . $file, $filter, true));
} else {
//Adiciona um arquivo na lista
$ext = explode('.', $file);
$ext = strtolower(end($ext));
if ($filter == '*' || strpos('|' . $filter, $ext)) {
$files[] = array('file' => utf8_encode($file), 'name' => substr($file, 0, strlen($file) - 1 - strlen($ext)), 'path' => utf8_encode($path), 'full' => utf8_encode($path . $file), 'type' => filetype($path . $file), 'ext' => $ext);
}
}
}
}
return $files;
}
示例10: getFileList
/**
* @param $dir
*
* @return array
*/
private function getFileList($dir)
{
// array to hold return value
$retval = array();
// add trailing slash if missing
if (substr($dir, -1) != '/') {
$dir .= '/';
}
// open pointer to directory and read list of files
$d = @dir($dir) or die("getFileList: Failed opening directory {$dir} for reading");
while (false !== ($entry = $d->read())) {
$info = pathinfo($entry);
$ext = $info['extension'];
// skip hidden files
if ($entry[0] == '.') {
continue;
}
if (is_dir("{$dir}{$entry}")) {
$retval[] = array('name' => "{$entry}", 'fullpath' => "{$dir}/{$entry}", 'type' => filetype("{$dir}{$entry}"), 'size' => 0, 'lastmod' => filemtime("{$dir}{$entry}"), 'ext' => $ext);
} elseif (is_readable("{$dir}{$entry}")) {
$retval[] = array('name' => "{$entry}", 'fullpath' => "{$dir}/{$entry}", 'type' => mime_content_type("{$dir}{$entry}"), 'size' => filesize("{$dir}{$entry}"), 'lastmod' => filemtime("{$dir}{$entry}"), 'ext' => $ext);
}
}
$d->close();
return $this->aasort($retval, 'name');
}
示例11: mailPdf
function mailPdf($from, $to, $subject, $files)
{
$_boundary = md5(uniqid(microtime(), TRUE));
$_headers = 'From: ' . $from . "\r\n";
$_headers .= 'Mime-Version: 1.0' . "\r\n" . 'Content-type: multipart/mixed; boundary=' . $_boundary . "\r\n";
$_to = $to;
$_subject = $subject;
//message html
$_message = '--' . $_boundary . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
$_message .= 'Voici le rapport de supervision de la semaine dernière.';
$_message .= "\r\n";
foreach ($files as $key => $file) {
if (file_exists($file["url"])) {
$_fileType = filetype($file["url"]);
$_fileContent = file_get_contents($file["url"]);
if (!$_fileContent) {
die('Impossible de lire le fichier ' . $file["url"]);
}
$_fileContent = chunk_split(base64_encode($_fileContent));
$_message .= '--' . $_boundary . "\r\n" . 'Content-type: application/pdf' . '; name=' . $key . "\r\n" . 'Content-transfer-encoding: base64' . "\r\n";
$_message .= $_fileContent . "\r\n";
}
$_message .= '--' . $_boundary . "\r\n";
}
mail($_to, $_subject, $_message, $_headers);
}
示例12: copy_directory
function copy_directory($directory, $destination)
{
$destination = $destination . basename($directory);
# The directory will be created
if (!file_exists($destination)) {
if (!mkdir($destination)) {
return false;
}
}
$directory_list = @scandir($directory);
# Directory scanning
if (!$directory_list) {
return false;
}
foreach ($directory_list as $item_name) {
$item = $directory . DIRECTORY_SEPARATOR . $item_name;
if ($item_name == '.' || $item_name == '..') {
continue;
}
if (filetype($item) == 'dir') {
copy_directory($item, $destination . DIRECTORY_SEPARATOR);
} else {
var_dump($item);
var_dump($destination . DIRECTORY_SEPARATOR . $item_name);
if (!copy($item, $destination . DIRECTORY_SEPARATOR . $item_name)) {
return false;
}
}
}
return true;
}
示例13: __construct
public function __construct($cache_path = '', $plugin_dir = '')
{
if ($cache_path) {
$this->cache_path = $cache_path;
} else {
$this->cache_path = CACHE_PATH;
}
if ($plugin_dir) {
$this->plugin_dir = $plugin_dir;
} else {
$this->plugin_dir = PLUGIN_PATH . 'lezaz/plugin/';
}
// include all plugin
if ($dh = opendir($this->plugin_dir)) {
while (($file = readdir($dh)) !== false) {
$ext = explode('.', $file);
if ($file != '.' && $file != '..' && filetype($this->plugin_dir . $file) != 'dir' && $ext[1] == 'php') {
$this->element[] = $ext[0];
include $this->plugin_dir . $file;
}
}
closedir($dh);
}
$this->translate['all'] = array('{{lng}}', '{{lnguage}}', '{{ltr}}');
$this->translate['ar'] = array('ar', 'arabic', 'rtl');
$this->translate['en'] = array('en', 'english', 'ltr');
}
示例14: get_ftpdir
/**
* getftpdir - ftp konyvtar beolvasasa
*
* @param string az ftp konyvtar eleresi utja
* @param string a vizsgalt file-ok tipusa (picture vagy video lehet)
* @access public
* @return string
*/
function get_ftpdir($ftpdir, $type)
{
$ret = array();
if (!is_dir($ftpdir)) {
return $ret;
}
if (($dir = opendir($ftpdir)) === FALSE) {
return $ret;
}
$i = 0;
while (($file = readdir($dir)) !== FALSE) {
if ($type == "picture") {
if (preg_match("/\\.(jpe?g|gif|png)\$/i", $file) && filetype($ftpdir . $file) == 'file') {
$ret[$i] = $file;
$i++;
}
}
if ($type == "video") {
if (preg_match("/\\.(mpe?g|avi|wmv)\$/i", $file) && filetype($ftpdir . $file) == 'file') {
$ret[$i] = $file;
$i++;
}
}
}
closedir($dir);
return $ret;
}
示例15: stat
function stat($file, $md5 = true, $sha1 = true)
{
$rval = array();
foreach (stat($file) as $i => $v) {
if (is_numeric($i)) {
continue;
}
$rval[$i] = $v;
}
$rval['type'] = filetype($file);
if ($rval['type'] == 'file') {
if ($md5) {
$rval['md5'] = md5_file($file);
}
if ($sha1) {
$rval['sha1'] = sha1_file($file);
}
}
$dir = $this->dir;
if (0 !== strpos($file, $dir) && 'wp-config.php' == basename($file)) {
$dir = explode(DIRECTORY_SEPARATOR, $dir);
array_pop($dir);
$dir = implode(DIRECTORY_SEPARATOR, $dir);
}
$rval['path'] = str_replace($dir, '', $file);
return $rval;
}