• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP fileext函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ftpupload

function ftpupload($aids, $uid = 0)
{
    global $_G;
    $uid = $uid ? $uid : $_G['uid'];
    if (!$aids || !$_G['setting']['ftp']['on']) {
        return;
    }
    $query = DB::query("SELECT aid, thumb, attachment, filename, filesize FROM " . DB::table('forum_attachment') . " WHERE aid IN (" . dimplode($aids) . ") AND uid='{$_G['uid']}' AND remote='0'");
    $aids = array();
    while ($attach = DB::fetch($query)) {
        $attach['ext'] = fileext($attach['filename']);
        if ((!$_G['setting']['ftp']['allowedexts'] && !$_G['setting']['ftp']['disallowedexts'] || $_G['setting']['ftp']['allowedexts'] && in_array($attach['ext'], explode("\n", strtolower($_G['setting']['ftp']['allowedexts']))) || $_G['setting']['ftp']['disallowedexts'] && !in_array($attach['ext'], explode("\n", strtolower($_G['setting']['ftp']['disallowedexts'])))) && (!$_G['setting']['ftp']['minsize'] || $attach['filesize'] >= $_G['setting']['ftp']['minsize'] * 1024)) {
            if (ftpcmd('upload', 'forum/' . $attach['attachment']) && (!$attach['thumb'] || ftpcmd('upload', 'forum/' . $attach['attachment'] . '.thumb.jpg'))) {
                dunlink($attach);
                $aids[] = $attach['aid'];
            }
        }
    }
    if ($aids) {
        DB::update('forum_attachment', array('remote' => 1), "aid IN (" . dimplode($aids) . ")");
    }
}
开发者ID:Kingson4Wu,项目名称:php_demo,代码行数:22,代码来源:function_post.php


示例17: downloadfile

 function downloadfile($filename)
 {
     $this->setfilename($filename);
     if ($this->filecheck()) {
         if (empty($this->attach_filename)) {
             $fn = array_pop(explode('/', strtr($this->filename, '\\', '/')));
         } else {
             $fn = $this->attach_filename . fileext($this->filename);
         }
         header("Pragma: public");
         header("Expires: 0");
         // set expiration time
         header("Cache-Component: must-revalidate, post-check=0, pre-check=0");
         header("Content-type:application/java-archive");
         header("Content-Length: " . filesize($this->filename));
         header("Content-Disposition: attachment; filename=" . $fn);
         header('Content-Transfer-Encoding: binary');
         readfile($this->filename);
         return true;
     } else {
         return false;
     }
 }
开发者ID:vuong93st,项目名称:w-game,代码行数:23,代码来源:download.class.php


示例18: addAction

 public function addAction()
 {
     $dir = $this->get('dir') ? urldecode($this->get('dir')) : '';
     $dir = str_replace(array('..\\', '../', './', '.\\'), '', trim($dir));
     $dir = substr($dir, 0, 1) == '/' ? substr($dir, 1) : $dir;
     $dir = str_replace(array('\\', '//'), DIRECTORY_SEPARATOR, $dir);
     $filepath = $this->dir . $dir;
     $local = str_replace(XIAOCMS_PATH, '', $filepath);
     $filecontent = '';
     if ($this->post('submit')) {
         $filename = $this->post('file_name');
         if (file_exists($filepath . $filename)) {
             $this->show_message('该文件已经存在', 2, 1);
         }
         $ext = fileext($filename);
         if (!in_array($ext, array('html', 'css', 'js', 'txt'))) {
             $this->show_message('文件名后缀不对', 2, 1);
         }
         file_put_contents($filepath . $filename, $this->post('file_content'), LOCK_EX);
         $this->show_message('提交成功', 1, url('template', array('dir' => $dir)));
     }
     include $this->admin_tpl('template_add');
 }
开发者ID:43431655,项目名称:qizhongbao,代码行数:23,代码来源:template.php


示例19: parseforumattach

function parseforumattach(&$post, $aids)
{
    global $_G;
    if ($aids = array_unique($aids)) {
        require_once libfile('function/attachment');
        $finds = $replaces = array();
        foreach (C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $post['tid'], 'aid', $aids) as $attach) {
            $attach['url'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/';
            $attach['dateline'] = dgmdate($attach['dateline'], 'u');
            $extension = strtolower(fileext($attach['filename']));
            $attach['ext'] = $extension;
            $attach['imgalt'] = $attach['isimage'] ? strip_tags(str_replace('"', '\\"', $attach['description'] ? $attach['description'] : $attach['filename'])) : '';
            $attach['attachicon'] = attachtype($extension . "\t" . $attach['filetype']);
            $attach['attachsize'] = sizecount($attach['filesize']);
            $attach['refcheck'] = !$attach['remote'] && $_G['setting']['attachrefcheck'] || $attach['remote'] && ($_G['setting']['ftp']['hideurl'] || $attach['isimage'] && $_G['setting']['attachimgpost'] && strtolower(substr($_G['setting']['ftp']['attachurl'], 0, 3)) == 'ftp');
            $aidencode = packaids($attach);
            $widthcode = attachwidth($attach['width']);
            $is_archive = $_G['forum_thread']['is_archived'] ? "&fid=" . $_G['fid'] . "&archiveid=" . $_G['forum_thread']['archiveid'] : '';
            if ($attach['isimage']) {
                $attachthumb = getimgthumbname($attach['attachment']);
                if ($_G['setting']['thumbstatus'] && $attach['thumb']) {
                    $replaces[$attach['aid']] = "<a href=\"javascript:;\"><img id=\"_aimg_{$attach['aid']}\" aid=\"{$attach['aid']}\" onclick=\"zoom(this, this.getAttribute('zoomfile'), 0, 0, '{$_G[forum][showexif]}')\"\n\t\t\t\t\t\tzoomfile=\"" . ($attach['refcheck'] ? "forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes&nothumb=yes" : $attach['url'] . $attach['attachment']) . "\"\n\t\t\t\t\t\tsrc=\"" . ($attach['refcheck'] ? "forum.php?mod=attachment{$is_archive}&aid={$aidencode}" : $attach['url'] . $attachthumb) . "\" alt=\"{$attach['imgalt']}\" title=\"{$attach['imgalt']}\" w=\"{$attach['width']}\" /></a>";
                } else {
                    $replaces[$attach['aid']] = "<img id=\"_aimg_{$attach['aid']}\" aid=\"{$attach['aid']}\"\n\t\t\t\t\t\tzoomfile=\"" . ($attach['refcheck'] ? "forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes&nothumb=yes" : $attach['url'] . $attach['attachment']) . "\"\n\t\t\t\t\t\tsrc=\"" . ($attach['refcheck'] ? "forum.php?mod=attachment{$is_archive}&aid={$aidencode}&noupdate=yes " : $attach['url'] . $attach['attachment']) . "\" {$widthcode} alt=\"{$attach['imgalt']}\" title=\"{$attach['imgalt']}\" w=\"{$attach['width']}\" />";
                }
            } else {
                $replaces[$attach['aid']] = "{$attach['attachicon']}<a href=\"forum.php?mod=attachment{$is_archive}&aid={$aidencode}\" onmouseover=\"showMenu({'ctrlid':this.id,'pos':'12'})\" id=\"aid{$attach['aid']}\" target=\"_blank\">{$attach['filename']}</a>";
            }
            $finds[$attach['aid']] = '[attach]' . $attach['aid'] . '[/attach]';
        }
        if ($finds && $replaces) {
            $post['message'] = str_ireplace($finds, $replaces, $post['message']);
        }
    }
}
开发者ID:tang86,项目名称:discuz-utf8,代码行数:35,代码来源:portal_view.php


示例20: writetocsscache

function writetocsscache($data) {
	global $_G;
/*vot*/	$dir = DISCUZ_ROOT.'template/default/common/';
//DEBUG
//echo "writetocsscache: discuz_root=".DISCUZ_ROOT."<br>";
//echo "writetocsscache: dir=".$dir."<br>";
	$dh = opendir($dir);
	$data['staticurl'] = STATICURL;
	while(($entry = readdir($dh)) !== false) {
		if(fileext($entry) == 'css') {
/*vot*/			$cssfile = DISCUZ_ROOT.$data['tpldir'].'/common/'.$entry;
//DEBUG
//echo "writetocsscache: entry=".$entry."<br>";
//echo "writetocsscache: cssfile=".$cssfile."<br>";
			!file_exists($cssfile) && $cssfile = $dir.$entry;
			$cssdata = @implode('', file($cssfile));
//DEBUG
//echo "writetocsscache: check 1 for cssfile=".DISCUZ_ROOT.$data['tpldir'].'/common/extend_'.$entry."<br>";
			if(file_exists($cssfile = DISCUZ_ROOT.'./'.$data['tpldir'].'/common/extend_'.$entry)) {
				$cssdata .= @implode('', file($cssfile));
			}
			if(is_array($_G['setting']['plugins']['available']) && $_G['setting']['plugins']['available']) {
				foreach($_G['setting']['plugins']['available'] as $plugin) {
//DEBUG
//echo "writetocsscache: check 2 for cssfile=".DISCUZ_ROOT.'./source/plugin/'.$plugin.'/template/extend_'.$entry."<br>";
					if(file_exists($cssfile = DISCUZ_ROOT.'./source/plugin/'.$plugin.'/template/extend_'.$entry)) {
						$cssdata .= @implode('', file($cssfile));
					}
				}
			}
			$cssdata = preg_replace("/\{([A-Z0-9]+)\}/e", '\$data[strtolower(\'\1\')]', $cssdata);
			$cssdata = preg_replace("/<\?.+?\?>\s*/", '', $cssdata);
			$cssdata = !preg_match('/^http:\/\//i', $data['styleimgdir']) ? preg_replace("/url\(([\"'])?".preg_quote($data['styleimgdir'], '/')."/i", "url(\\1../../$data[styleimgdir]", $cssdata) : $cssdata;
			$cssdata = !preg_match('/^http:\/\//i', $data['imgdir']) ? preg_replace("/url\(([\"'])?".preg_quote($data['imgdir'], '/')."/i", "url(\\1../../$data[imgdir]", $cssdata) : $cssdata;
			$cssdata = !preg_match('/^http:\/\//i', $data['staticurl']) ? preg_replace("/url\(([\"'])?".preg_quote($data['staticurl'], '/')."/i", "url(\\1../../$data[staticurl]", $cssdata) : $cssdata;
/*vot*/			if($entry == 'module.css' || $entry == 'module_rtl.css') {
				$cssdata = preg_replace('/\/\*\*\s*(.+?)\s*\*\*\//', '[\\1]', $cssdata);
			}
			$cssdata = preg_replace(array('/\s*([,;:\{\}])\s*/', '/[\t\n\r]/', '/\/\*.+?\*\//'), array('\\1', '',''), $cssdata);
			if(@$fp = fopen(DISCUZ_ROOT.'./data/cache/style_'.$data['styleid'].'_'.$entry, 'w')) {
				fwrite($fp, $cssdata);
				fclose($fp);
			} else {
				exit('Can not write to cache files, please check directory ./data/ and ./data/cache/ .');
			}
		}
	}
}
开发者ID:xDiglett,项目名称:discuzx30,代码行数:48,代码来源:cache_styles.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP filegroup函数代码示例发布时间:2022-05-15
下一篇:
PHP filectime函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap