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


PHP fileext函数代码示例

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


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

示例1: page_admin_images

function page_admin_images($act = "", $id = "")
{
    requires_admin();
    use_template("admin");
    if ($act == "add") {
        if (form_file_uploaded("file")) {
            $fname = $_FILES["file"]['name'];
            db_query("INSERT INTO images (link) VALUES ('')");
            $id = db_last_id();
            $fname = $id . "." . fileext($fname);
            form_file_uploaded_move("file", "img/" . $fname);
            db_query("UPDATE images SET link='img/{$fname}' WHERE id=%d", $id);
            redir("admin/images");
        }
        form_start("", "post", " enctype='multipart/form-data' ");
        form_file("Файл", "file");
        form_submit("Загрузить", "submit");
        form_end();
        $o = form();
        return $o;
    }
    if ($act == "del") {
        $im = db_object_get("images", $id);
        @unlink("../{$im->link}");
    }
    $o = table_edit("images", "admin/images", $act, $id, "", "", "", "image_func");
    return $o;
}
开发者ID:NazarK,项目名称:timedesk,代码行数:28,代码来源:images.php

示例2: build_cache_postimg

function build_cache_postimg()
{
    $imgextarray = array('jpg', 'gif', 'png');
    $imgdir = array('hrline', 'postbg');
    $postimgjs = 'var postimg_type = new Array();';
    foreach ($imgdir as $perdir) {
        $count = 0;
        $pdir = DISCUZ_ROOT . './static/image/' . $perdir;
        $postimgdir = dir($pdir);
        $postimgjs .= 'postimg_type["' . $perdir . '"]=[';
        while ($entry = $postimgdir->read()) {
            if (in_array(strtolower(fileext($entry)), $imgextarray) && preg_match("/^[\\w\\-\\.\\[\\]\\(\\)\\<\\> &]+\$/", substr($entry, 0, strrpos($entry, '.'))) && strlen($entry) < 30 && is_file($pdir . '/' . $entry)) {
                $postimg[$perdir][] = array('url' => $entry);
                $postimgjs .= ($count ? ',' : '') . '"' . $entry . '"';
                $count++;
            }
        }
        $postimgjs .= '];';
        $postimgdir->close();
    }
    savecache('postimg', $postimg);
    $cachedir = 'saekv://data/cache/';
    if (@($fp = fopen($cachedir . 'common_postimg.js', 'w'))) {
        fwrite($fp, $postimgjs);
        fclose($fp);
    } else {
        exit('Can not write to cache files, please check directory ./data/ and ./data/cache/ .');
    }
}
开发者ID:wait121000,项目名称:discuz3.0forsae,代码行数:29,代码来源:cache_postimg.php

示例3: poll_upload

 function poll_upload()
 {
     global $_G;
     $this->uid = intval($_G['gp_uid']);
     $swfhash = md5(substr(md5($_G['config']['security']['authkey']), 8) . $this->uid);
     if (!$_FILES['Filedata']['error'] && $_G['gp_hash'] == $swfhash && $this->uid) {
         $this->aid = 0;
         $this->simple = 0;
         $this->user = getuserbyuid($this->uid);
         if (empty($this->user['adminid'])) {
             $this->uploadmsg(9);
         }
         $_G['uid'] = $this->uid;
         $this->pollid = !empty($_G['gp_pollid']) ? intval($_G['gp_pollid']) : 0;
         if ($this->pollid <= 0 || !intval(DB::result_first("SELECT contenttype FROM " . DB::table('poll_item') . " WHERE itemid='{$this->pollid}'"))) {
             $this->uploadmsg(9);
         }
         $attach = upload_images($_FILES['Filedata'], 'poll', 176, 176);
         $caption = dhtmlspecialchars(trim($attach['name']));
         $caption = substr($caption, 0, -(strlen(fileext($caption)) + 1));
         $data = array('itemid' => $this->pollid, 'caption' => $caption, 'displayorder' => 0, 'imageurl' => $attach['attachment'], 'aid' => $attach['aid']);
         DB::insert('poll_choice', $data);
         $this->aid = $this->pollid;
         $this->uploadmsg(0);
     }
 }
开发者ID:pan289091315,项目名称:Discuz,代码行数:26,代码来源:class_pollupload.php

示例4: parseattach

function parseattach($attachpids, $attachtags, &$postlist, $showimages = 1, $skipaids = array())
{
    global $db, $tablepre, $discuz_uid, $skipaidlist, $readaccess, $attachlist, $attachimgpost, $maxchargespan, $timestamp, $forum, $ftp, $attachurl, $dateformat, $timeformat, $timeoffset, $hideattach, $thread, $tradesaids, $trades, $exthtml, $tagstatus, $sid, $authkey, $exempt;
    $query = $db->query("SELECT a.*, af.description, ap.aid AS payed FROM {$tablepre}attachments a LEFT JOIN {$tablepre}attachmentfields af ON a.aid=af.aid LEFT JOIN {$tablepre}attachpaymentlog ap ON ap.aid=a.aid AND ap.uid='{$discuz_uid}' WHERE a.pid IN ({$attachpids})");
    $attachexists = FALSE;
    while ($attach = $db->fetch_array($query)) {
        $attachexists = TRUE;
        $exthtml = '';
        if ($skipaids && in_array($attach['aid'], $skipaids)) {
            continue;
        }
        $attached = 0;
        $extension = strtolower(fileext($attach['filename']));
        $attach['ext'] = $extension;
        $attach['attachicon'] = attachtype($extension . "\t" . $attach['filetype']);
        $attach['attachsize'] = sizecount($attach['filesize']);
        $attach['attachimg'] = $showimages && $attachimgpost && $attach['isimage'] && (!$attach['readperm'] || $readaccess >= $attach['readperm']) ? 1 : 0;
        if ($attach['price']) {
            if ($maxchargespan && $timestamp - $attach['dateline'] >= $maxchargespan * 3600) {
                $db->query("UPDATE {$tablepre}attachments SET price='0' WHERE aid='{$attach['aid']}'");
                $attach['price'] = 0;
            } else {
                if (!$discuz_uid || !$forum['ismoderator'] && $attach['uid'] != $discuz_uid && !$attach['payed']) {
                    $attach['unpayed'] = 1;
                }
            }
        }
        $exemptattachpay = $exempt & 8 ? 1 : 0;
        $attach['payed'] = $attach['payed'] || $forum['ismoderator'] || $attach['uid'] == $discuz_uid ? 1 : 0;
        $attach['url'] = $attach['remote'] ? $ftp['attachurl'] : $attachurl;
        $attach['dateline'] = dgmdate("{$dateformat} {$timeformat}", $attach['dateline'] + $timeoffset * 3600);
        $postlist[$attach['pid']]['attachments'][$attach['aid']] = $attach;
        if (is_array($attachtags[$attach['pid']]) && in_array($attach['aid'], $attachtags[$attach['pid']])) {
            $findattach[$attach['pid']][] = "/\\[attach\\]{$attach['aid']}\\[\\/attach\\]/i";
            $replaceattach[$attach['pid']][] = $hideattach[$attach['pid']] ? '[attach]***[/attach]' : attachtag($attach['pid'], $attach['aid'], $postlist);
            $attached = 1;
        }
        if (!$attached || $attach['unpayed']) {
            if ($attach['isimage']) {
                $postlist[$attach['pid']]['imagelist'] .= attachlist($attach);
            } else {
                if (!$skipaidlist || !in_array($attach['aid'], $skipaidlist)) {
                    $postlist[$attach['pid']]['attachlist'] .= attachlist($attach);
                }
            }
        }
    }
    if ($attachexists) {
        foreach ($attachtags as $pid => $aids) {
            if ($findattach[$pid]) {
                $postlist[$pid]['message'] = preg_replace($findattach[$pid], $replaceattach[$pid], $postlist[$pid]['message'], 1);
                $postlist[$pid]['message'] = preg_replace($findattach[$pid], '', $postlist[$pid]['message']);
            }
        }
    } else {
        $db->query("UPDATE {$tablepre}posts SET attachment='0' WHERE pid IN ({$attachpids})", 'UNBUFFERED');
    }
}
开发者ID:lilhorse,项目名称:cocoa,代码行数:58,代码来源:attachment.func.php

示例5: parseattach

function parseattach($attachpids, $attachtags, &$postlist, $skipaids = array())
{
    global $_G;
    $query = DB::query("SELECT a.*, af.description, l.relatedid AS payed\n\t\tFROM " . DB::table('forum_attachment') . " a\n\t\tLEFT JOIN " . DB::table('forum_attachmentfield') . " af ON a.aid=af.aid\n\t\tLEFT JOIN " . DB::table('common_credit_log') . " l ON l.relatedid=a.aid AND l.uid='{$_G['uid']}' AND l.operation='BAC'\n\t\tWHERE a.pid IN ({$attachpids})");
    $attachexists = FALSE;
    while ($attach = DB::fetch($query)) {
        $attachexists = TRUE;
        if ($skipaids && in_array($attach['aid'], $skipaids)) {
            continue;
        }
        $attached = 0;
        $extension = strtolower(fileext($attach['filename']));
        $attach['ext'] = $extension;
        $attach['attachicon'] = attachtype($extension . "\t" . $attach['filetype']);
        $attach['attachsize'] = sizecount($attach['filesize']);
        $attach['attachimg'] = $_G['setting']['attachimgpost'] && $attach['isimage'] && (!$attach['readperm'] || $_G['group']['readaccess'] >= $attach['readperm']) ? 1 : 0;
        if ($attach['price']) {
            if ($_G['setting']['maxchargespan'] && TIMESTAMP - $attach['dateline'] >= $_G['setting']['maxchargespan'] * 3600) {
                DB::query("UPDATE " . DB::table('forum_attachment') . " SET price='0' WHERE aid='{$attach['aid']}'");
                $attach['price'] = 0;
            } else {
                if (!$_G['uid'] || !$_G['forum']['ismoderator'] && $attach['uid'] != $_G['uid'] && !$attach['payed']) {
                    $attach['unpayed'] = 1;
                }
            }
        }
        $exemptattachpay = $_G['group']['exempt'] & 8 ? 1 : 0;
        $attach['payed'] = $attach['payed'] || $_G['forum']['ismoderator'] || $attach['uid'] == $_G['uid'] ? 1 : 0;
        $attach['url'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] . '/' : $_G['setting']['attachurl']) . 'forum/';
        $attach['dateline'] = dgmdate($attach['dateline'], 'u');
        $postlist[$attach['pid']]['attachments'][$attach['aid']] = $attach;
        if (!empty($attachtags[$attach['pid']]) && is_array($attachtags[$attach['pid']]) && in_array($attach['aid'], $attachtags[$attach['pid']])) {
            $findattach[$attach['pid']][] = "/\\[attach\\]{$attach['aid']}\\[\\/attach\\]/i";
            $replaceattach[$attach['pid']][] = attachtag($attach['pid'], $attach['aid'], $postlist);
            $attached = 1;
        }
        if (!$attached) {
            if ($attach['isimage']) {
                $postlist[$attach['pid']]['imagelist'] .= attachlist($attach);
            } else {
                if (!$_G['forum_skipaidlist'] || !in_array($attach['aid'], $_G['forum_skipaidlist'])) {
                    $postlist[$attach['pid']]['attachlist'] .= attachlist($attach);
                }
            }
        }
    }
    if ($attachexists) {
        foreach ($attachtags as $pid => $aids) {
            if ($findattach[$pid]) {
                $postlist[$pid]['message'] = preg_replace($findattach[$pid], $replaceattach[$pid], $postlist[$pid]['message'], 1);
                $postlist[$pid]['message'] = preg_replace($findattach[$pid], '', $postlist[$pid]['message']);
            }
        }
    } else {
        updatepost(array('attachment' => '0'), "pid IN ({$attachpids})", true);
    }
}
开发者ID:Kingson4Wu,项目名称:php_demo,代码行数:57,代码来源:function_attachment.php

示例6: import_styles

function import_styles($ignoreversion = 1, $dir = '')
{
    global $db, $tablepre, $version, $importtxt, $stylearray;
    if (!isset($dir)) {
        $stylearrays = array(getimportdata('Discuz! Style'));
    } else {
        $dir = str_replace(array('/', '\\'), '', $dir);
        $templatedir = DISCUZ_ROOT . './templates/' . $dir;
        $searchdir = dir($templatedir);
        $stylearrays = array();
        while ($searchentry = $searchdir->read()) {
            if (substr($searchentry, 0, 13) == 'discuz_style_' && fileext($searchentry) == 'xml') {
                $importfile = $templatedir . '/' . $searchentry;
                $importtxt = implode('', file($importfile));
                $stylearrays[] = getimportdata('Discuz! Style');
            }
        }
    }
    foreach ($stylearrays as $stylearray) {
        if (empty($ignoreversion) && strip_tags($stylearray['version']) != strip_tags($version)) {
            cpmsg('styles_import_version_invalid', '', 'error');
        }
        $renamed = 0;
        if ($stylearray['templateid'] != 1) {
            $templatedir = DISCUZ_ROOT . './' . $stylearray['directory'];
            if (!is_dir($templatedir)) {
                if (!@mkdir($templatedir, 0777)) {
                    $basedir = dirname($stylearray['directory']);
                    cpmsg('styles_import_directory_invalid', '', 'error');
                }
            }
            if (!($templateid = $db->result_first("SELECT templateid FROM {$tablepre}templates WHERE name='{$stylearray['tplname']}'"))) {
                $db->query("INSERT INTO {$tablepre}templates (name, directory, copyright)\r\n\t\t\t\t\tVALUES ('{$stylearray['tplname']}', '{$stylearray['directory']}', '{$stylearray['copyright']}')");
                $templateid = $db->insert_id();
            }
        } else {
            $templateid = 1;
        }
        if ($db->result_first("SELECT COUNT(*) FROM {$tablepre}styles WHERE name='{$stylearray['name']}'")) {
            $stylearray['name'] .= '_' . random(4);
            $renamed = 1;
        }
        $db->query("INSERT INTO {$tablepre}styles (name, templateid)\r\n\t\t\tVALUES ('{$stylearray['name']}', '{$templateid}')");
        $styleidnew = $db->insert_id();
        foreach ($stylearray['style'] as $variable => $substitute) {
            $substitute = @htmlspecialchars($substitute);
            $db->query("INSERT INTO {$tablepre}stylevars (styleid, variable, substitute)\r\n\t\t\t\tVALUES ('{$styleidnew}', '{$variable}', '{$substitute}')");
        }
    }
    updatecache('styles');
    updatecache('settings');
    return $renamed;
}
开发者ID:BGCX262,项目名称:zyyhong-svn-to-git,代码行数:53,代码来源:importdata.func.php

示例7: _assignImage

 /**
  * Copy and assign the images
  * @return array of struct_corecatalog_cat_images - or array() (with count==0 elements, or empty)
  */
 protected function _assignImage($data_name, $filePathForSave)
 {
     if (!empty($_FILES[$data_name])) {
         $orig_name = $_FILES[$data_name]['name'];
         if (!$_FILES[$data_name]['error'] and (int) $_FILES[$data_name]['size']) {
             $currentUser = $this->getController()->getCurrentUser();
             $image = new struct_corecatalog_cat_images();
             $image->img_filename = 't_' . $currentUser->u_id . md5(time() . $currentUser->u_id . $orig_name) . '.' . strtolower(fileext($orig_name));
             move_uploaded_file($_FILES[$data_name]['tmp_name'], $filePathForSave . $image->img_filename);
             return $image->img_filename;
         }
     }
 }
开发者ID:ValenokPC,项目名称:tabernacms,代码行数:17,代码来源:fileuploader.php

示例8: getReader

 public function getReader($filename)
 {
     //获取reader对象
     $Reader = NULL;
     $ext = fileext($filename);
     //取得文件扩展名
     if ($ext == 'xls') {
         $Reader = new PHPExcel_Reader_Excel5();
     } elseif ($ext == 'xlsx') {
         $Reader = new PHPExcel_Reader_Excel2007();
     }
     //excel 2007
     return $Reader;
 }
开发者ID:zhouzhouxs,项目名称:Progect,代码行数:14,代码来源:excel.class.php

示例9: addPostFix

function addPostFix($fileName)
{
    if (file_exists($fileName)) {
        $LpostFix = fileext($fileName);
        $length = strrpos($fileName, '.');
        $name = substr($fileName, 0, $length);
        $fix = randChar();
        $name = $name . $fix;
        $fileName = $name . "." . $LpostFix;
        if (file_exists($fileName)) {
            addPostFix($fileName);
        }
    }
    return $fileName;
}
开发者ID:xiaohong1633,项目名称:eshop,代码行数:15,代码来源:upload.php

示例10: file_down

function file_down($file)
{
    global $lang_setdbNotExist;
    !file_exists($file) && okinfox('database.php?action=import', $lang_setdbNotExist);
    $filename = $filename ? $filename : basename($file);
    $filetype = fileext($filename);
    $filesize = filesize($file);
    header('Cache-control: max-age=31536000');
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
    header('Content-Encoding: none');
    header('Content-Length: ' . $filesize);
    header('Content-Disposition: attachment; filename=' . $filename);
    header('Content-Type: ' . $filetype);
    readfile($file);
    exit;
}
开发者ID:nanfs,项目名称:lt,代码行数:16,代码来源:global.func.php

示例11: page_admin_images

function page_admin_images($act = "", $id = "")
{
    requires_admin();
    use_layout("admin");
    form_start("", "post", " enctype='multipart/form-data' ");
    form_file("Файл", "file");
    $caption = "Загрузить картинку";
    if ($act == "edit") {
        $caption = "Изменить картинку";
    }
    form_submit($caption, "submit");
    form_end();
    $upload = form();
    if (form_file_uploaded("file")) {
        $fname = $_FILES["file"]['name'];
        $ext = strtolower(fileext($fname));
        if (!($ext == "swf" || $ext == "jpg" || $ext == "gif" || $ext == "png" || $ext == "bmp" || $ext == "jpeg" || $ext == "pdf")) {
            $o = "Данный тип файла не является картинкой";
            return $o;
        } else {
            if ($act == "add") {
                db_query("INSERT INTO images (link) VALUES ('')");
                $id = db_last_id();
            } else {
                @unlink(db_result(db_query("SELECT link FROM images WHERE id=%d", $id)));
            }
            $fname = $id . "." . fileext($fname);
            form_file_uploaded_move("file", "img/" . $fname);
            db_query("UPDATE images SET link='img/{$fname}' WHERE id=%d", $id);
            redir("admin/images/edit/{$id}");
        }
    }
    if ($act == "add") {
        $o = $upload;
        return $o;
    }
    if ($act == "del") {
        $im = db_object_get("images", $id);
        @unlink("{$im->link}");
    }
    $o = table_edit("images", "admin/images", $act, $id, "", "", "", "image_func");
    if ($act == 'edit') {
        $im = db_object_get("images", $id);
        $o .= "<img width=100px src={$im->link}><br>{$upload}";
    }
    return $o;
}
开发者ID:NazarK,项目名称:sqp,代码行数:47,代码来源:images.php

示例12: thumb

/**
 * 缩略图片
 */
function thumb($img, $width = 200, $height = 200)
{
    if (empty($img) || strlen($img) < 4) {
        return SITE_PATH . 'data/upload/nopic.gif';
    }
    if (file_exists(XIAOCMS_PATH . $img)) {
        $ext = fileext($img);
        $thumb = $img . '.thumb.' . $width . 'x' . $height . '.' . $ext;
        if (!file_exists(XIAOCMS_PATH . $thumb)) {
            $image = xiaocms::load_class('image');
            $image->thumb(XIAOCMS_PATH . $img, XIAOCMS_PATH . $thumb, $width, $height);
            // 生成图像缩略图
        }
        return $thumb;
    }
    return $img;
}
开发者ID:43431655,项目名称:qizhongbao,代码行数:20,代码来源:global.function.php

示例13: checkfilename

function checkfilename($filename)
{
    global $tpldir;
    $isedit = false;
    if (!empty($filename)) {
        $filename = str_replace(array('..', '/', '\\'), array('', '', ''), $filename);
        if (!empty($filename) && fileext($filename) == 'htm') {
            if (is_writeable($tpldir . $filename)) {
                $isedit = true;
            }
        }
    }
    if (!$isedit) {
        cpmessage('template_files_editing_failure_check_directory_competence');
    }
    return $filename;
}
开发者ID:shiyake,项目名称:php-ihome,代码行数:17,代码来源:admincp_template.php

示例14: dreaddir

function dreaddir($dir, $extarr = array())
{
    $dirs = array();
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if (!empty($extarr) && is_array($extarr)) {
                if (in_array(strtolower(fileext($file)), $extarr)) {
                    $dirs[] = $file;
                }
            } else {
                if ($file != '.' && $file != '..') {
                    $dirs[] = $file;
                }
            }
        }
        closedir($dh);
    }
    return $dirs;
}
开发者ID:upyun,项目名称:discuz-plugin,代码行数:19,代码来源:function_home.php

示例15: download

 public function download($field, $value, $watermark = '0', $ext = 'gif|jpg|jpeg|bmp|png', $absurl = '', $basehref = '')
 {
     $dir = date('Y-m-d/');
     $upload_url = '/Uploads/';
     $uploadpath = $upload_url . $dir;
     $uploaddir = './Uploads/' . $dir;
     $string = stripslashes($value);
     //判断是否需要下载
     if (!preg_match_all("/(href|src)=([\"|']?)([^ \"'>]+\\.({$ext}))\\2/i", $string, $matches)) {
         return $value;
     }
     //取出下载的图片
     $remotefileurls = array();
     foreach ($matches[3] as $matche) {
         //如果是本地图片, 则跳过
         if (strpos($matche, '://') === false) {
             continue;
         }
         $remotefileurls[] = $matche;
     }
     unset($matches, $string);
     $remotefileurls = array_unique($remotefileurls);
     $oldpath = $newpath = array();
     //开始下载
     //import("Org.Net.Http");
     foreach ($remotefileurls as $k => $file) {
         //判断是否是本地图片
         if (strpos($file, '://') === false || strpos($file, $upload_url) !== false) {
             continue;
         }
         //获取文件扩展名
         $filename = fileext($file);
         //$file_name = basename($file);
         $filename = $this->getname($filename);
         $newfile = $uploaddir . $filename;
         \Org\Net\Http::curlDownload($file, $newfile);
         //var_dump($newfile);exit;
     }
     //替换下载后的地址
 }
开发者ID:shenyangchong,项目名称:bjui_php,代码行数:40,代码来源:AttachmentModel.class.php


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