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


PHP get_ext函数代码示例

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


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

示例1: upload

function upload($upload, $target = './', $exts = 'jpg,gif,torrent,zip,rar,7z,doc,docx,xls,xlsx,ppt,pptx,mp3,wma,swf,flv,txt', $size = 20, $rename = '')
{
    mk_dir($target);
    if (is_array($upload['name'])) {
        $return = array();
        foreach ($upload["name"] as $k => $v) {
            if (!empty($upload['name'][$k])) {
                $ext = get_ext($upload['name'][$k]);
                if (strpos($exts, $ext) !== false && $upload['size'][$k] < $size * 1024 * 1024) {
                    $name = empty($rename) ? upload_name($ext) : upload_rename($rename, $ext);
                    if (upload_move($upload['tmp_name'][$k], $target . $name)) {
                        $return[] = $name;
                    }
                }
            }
        }
        return $return;
    } else {
        $return = '';
        if (!empty($upload['name'])) {
            $ext = get_ext($upload['name']);
            if (strpos($exts, $ext) !== false && $upload['size'] < $size * 1024 * 1024) {
                $name = empty($rename) ? upload_name($ext) : upload_rename($rename, $ext);
                if (upload_move($upload['tmp_name'], $target . $name)) {
                    $return = $name;
                }
            }
        }
    }
    return $return;
}
开发者ID:q275957304,项目名称:huanshou,代码行数:31,代码来源:function.php

示例2: download

/**
 * 文件下载/或输出显示
 * @param $filepath 文件路径
 * @param $filename 文件名称
 */
function download($filepath, $filename = '', $output = 0)
{
    if (!$filename) {
        $filename = basename($filepath);
    }
    if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'msie ') !== false) {
        $filename = rawurlencode($filename);
    }
    $filetype = get_ext($filename);
    if (!file_exists($filepath)) {
        MSG('文件不存在');
    }
    $filesize = sprintf("%u", filesize($filepath));
    if (ob_get_length() !== false) {
        @ob_end_clean();
    }
    header('Pragma: public');
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Cache-Control: no-store, no-cache, must-revalidate');
    header('Cache-Control: pre-check=0, post-check=0, max-age=0');
    header('Content-Transfer-Encoding: binary');
    header('Content-Encoding: none');
    header('Content-type: ' . $filetype);
    if (!$output) {
        header('Content-Disposition: attachment; filename="' . $filename . '"');
    }
    header('Content-length: ' . $filesize);
    readfile($filepath);
    exit;
}
开发者ID:another3000,项目名称:wuzhicms,代码行数:35,代码来源:content.func.php

示例3: caching

function caching($comics_id, $zip_path, $image_ext)
{
    $comic = zip_open($zip_path);
    if (!is_resource($comic)) {
        die("[ERR]ZIP_OPEN : " . $zip_path);
    }
    $inzip_path = "";
    $count = 0;
    $files = null;
    $db = new SQLite3(DB);
    $db->exec("BEGIN DEFERRED;");
    while (($entry = zip_read($comic)) !== false) {
        $inzip_path = zip_entry_name($entry);
        $cache_name = md5($zip_path . "/" . $inzip_path) . '.' . get_ext($inzip_path);
        // 画像か否か
        if (!is_image($inzip_path, $image_ext)) {
            continue;
        }
        $data = zip_entry_read($entry, zip_entry_filesize($entry));
        $filepath = CACHE . '/' . $cache_name;
        file_put_contents($filepath, $data);
        $count++;
        query("INSERT INTO images (comics_id, page, filepath) VALUES (" . $comics_id . ", " . $count . ", '" . $filepath . "')", $db);
    }
    zip_close($comic);
    query("UPDATE comics SET pages = " . $count . " WHERE id = " . $comics_id, $db);
    $db->exec("COMMIT;");
}
开发者ID:undisputed-seraphim,项目名称:manga_server,代码行数:28,代码来源:view.php

示例4: code_preprocessor

function code_preprocessor($id, $file, $url_root)
{
    $ext = get_ext($file);
    $dir = REPOSITORY . DIRECTORY_SEPARATOR . $id . DIRECTORY_SEPARATOR;
    $relative_path = str_replace($dir, "", $file);
    $is_new = isset($_GET['t']);
    include V2_PLUGIN . "/code/preprocessor/{$ext}.php";
}
开发者ID:juijs,项目名称:store.jui.io,代码行数:8,代码来源:common.php

示例5: insert

 /**
  * 文件上传记录入库操作
  *
  * @author tuzwu
  * @createtime
  * @modifytime
  * @param	
  * @return
  */
 public function insert($insert)
 {
     $db = load_class('db');
     $insert['userkeys'] = get_cookie('userkeys');
     $ext = get_ext($insert['path']);
     if (in_array($ext, array('jpg', 'gif', 'bmp', 'png', 'jpeg'))) {
         $insert['isimage'] = 1;
     }
     return $id = $db->insert('attachment', $insert);
 }
开发者ID:another3000,项目名称:wuzhicms,代码行数:19,代码来源:attachment.class.php

示例6: loadArchiveImages

 /**
  * Загрузка изображений из архива
  * @param string $name
  * @return array
  */
 public function loadArchiveImages($name)
 {
     $data = array();
     $ext = get_ext($_FILES[$name]['name']);
     $filename = md5(microtime());
     if ($_FILES[$name]['type'] != 'application/zip' or $_FILES[$name]['type'] != 0) {
         return $data;
     }
     if (move_uploaded_file($_FILES[$name]['tmp_name'], DOC . 'userfiles/' . $filename . '.' . $ext)) {
         chmod(DOC . 'userfiles/' . $filename . '.' . $ext, 0644);
         $zip = new ZipArchive();
         $res = $zip->open(DOC . 'userfiles/' . $filename . '.' . $ext);
         if ($res === TRUE) {
             // Создаем временную папку
             if (!is_dir(DOC . 'userfiles/' . $filename)) {
                 mkdir(DOC . 'userfiles/' . $filename, 0777);
             }
             // выгружаем изображение во временную папкуж
             $zip->extractTo(DOC . 'userfiles/' . $filename);
             $zip->close();
             // Проверяем являются ли загруженные файлы изображениями и копируем в основную папку
             if ($dh = opendir(DOC . 'userfiles/' . $filename)) {
                 while ($d = readdir($dh)) {
                     // определение дочерней директории
                     if (is_file(DOC . 'userfiles/' . $filename . '/' . $d) && $d != '.' && $d != '..') {
                         $image = DOC . 'userfiles/' . $filename . '/' . $d;
                         if (getimagesize($image)) {
                             $copy_image = md5($filename . $d) . '.' . get_ext($image);
                             copy($image, DOC . 'userfiles/original/' . $copy_image);
                             $data[] = array('name' => $d, 'url' => $copy_image);
                         }
                     }
                 }
                 closedir($dh);
             }
         } else {
             echo 'failed, code:' . $res;
             exit;
         }
     }
     // Удаляем архив
     unlink(DOC . 'userfiles/' . $filename . '.' . $ext);
     // Удаляем временную папку
     $this->removeDir(DOC . 'userfiles/' . $filename);
     return $data;
 }
开发者ID:klimjr,项目名称:cms,代码行数:51,代码来源:class.gallery.php

示例7: validate_image

/**
 * Validate an image
 * @param $image
 * @return TRUE if the image is valid
 */
function validate_image($image)
{
    global $mime, $image_whitelist;
    // Get the info for the image
    $info = getimagesize($image['tmp_name']);
    // Is it invalid?
    if (empty($info)) {
        return FALSE;
    }
    // Verify the mimetype
    $mime_type = $info['mime'];
    if (!isset($mime[$mime_type])) {
        return FALSE;
    }
    // Get the file extension
    $ext = get_ext($image['name']);
    // Compare it to the whitelist
    if (!in_array($ext, $image_whitelist)) {
        return FALSE;
    }
    // It is good
    return TRUE;
}
开发者ID:YannickFricke,项目名称:puush-api,代码行数:28,代码来源:func.php

示例8: wp_get_files

 function wp_get_files($dir)
 {
     global $wp_get_files_list, $domain, $site_url, $home_path, $assets_dir;
     if (is_dir($dir)) {
         if ($dh = opendir($dir)) {
             $file_id = 1;
             while ($file = readdir($dh)) {
                 if ($file != '.' && $file != '..') {
                     if (is_dir($dir . $file)) {
                         wp_get_files($dir . $file . '/');
                     } else {
                         if (get_ext($file) == 'js' || get_ext($file) == 'css' || get_ext($file) == 'jpg' || get_ext($file) == 'jpeg' || get_ext($file) == 'gif' || get_ext($file) == 'png' || get_ext($file) == 'apng' || get_ext($file) == 'tiff' || get_ext($file) == 'svg' || get_ext($file) == 'pdf' || get_ext($file) == 'css' || get_ext($file) == 'bmp') {
                             $rand_code = rand(99, 999);
                             $wp_get_files_list['html_encode'][str_replace($home_path, $site_url, $dir . $file)] = $site_url . $assets_dir . $file_id . $rand_code . '.' . get_ext($file);
                             $wp_get_files_list['htacess_decode'][$file_id . $rand_code . '.' . get_ext($file)] = str_replace($domain, '', str_replace($home_path, $site_url, $dir . $file));
                         }
                     }
                 }
                 $file_id++;
             }
         }
         closedir($dh);
     }
 }
开发者ID:WebergeIndia,项目名称:wp-hide,代码行数:24,代码来源:wp-hide.php

示例9: unlink

if ($_GET['type'] === 'experiments') {
    // Check file id is owned by connected user
    $sql = "SELECT userid, real_name, long_name, item_id FROM uploads WHERE id = :id";
    $req = $bdd->prepare($sql);
    $req->execute(array('id' => $id));
    $data = $req->fetch();
    if ($data['userid'] == $_SESSION['userid']) {
        // Good to go -> DELETE FILE
        $sql = "DELETE FROM uploads WHERE id = " . $id;
        $reqdel = $bdd->prepare($sql);
        $reqdel->execute();
        $reqdel->closeCursor();
        $filepath = 'uploads/' . $data['long_name'];
        unlink($filepath);
        // remove thumbnail
        $ext = get_ext($data['real_name']);
        if (file_exists('uploads/' . $data['long_name'] . '_th.' . $ext)) {
            unlink('uploads/' . $data['long_name'] . '_th.' . $ext);
        }
        // Redirect to the viewXP
        $expid = $data['item_id'];
        $msg_arr = array();
        $msg_arr[] = 'File ' . $data['real_name'] . ' deleted successfully';
        $_SESSION['infos'] = $msg_arr;
        header("location: experiments.php?mode=edit&id={$expid}");
    } else {
        die;
    }
    // DATABASE ITEM
} elseif ($_GET['type'] === 'database') {
    // Get realname
开发者ID:studur,项目名称:elabchem,代码行数:31,代码来源:delete_file.php

示例10: time_format

    if (stripos($file, '.php') !== false) {
        continue;
    }
    ?>
    <li>
        <div class="task-title">
<span class="task-title-sp">
<?php 
    echo "<img src='" . R . "images/icon/file.png' class='pull-left'> ";
    echo "<span class='col-lg-2 col-sm-4'>" . $file . "</span>";
    echo "修改时间:" . time_format(filemtime(TPL_ROOT . $dir . '/' . $file));
    ?>
</span>
            <div class="pull-right hidden-phone">
                <?php 
    $extent = get_ext($file);
    if (in_array($extent, array('js', 'css'))) {
        ?>
                    <a href="?m=template&f=res&v=history&dir=<?php 
        echo $dir;
        ?>
&file=<?php 
        echo $file . $this->su();
        ?>
" class="btn btn-default btn-xs">历史版本</a>
                    <a href="?m=template&f=res&v=edit&dir=<?php 
        echo $dir;
        ?>
&file=<?php 
        echo $file . $this->su();
        ?>
开发者ID:another3000,项目名称:wuzhicms,代码行数:31,代码来源:res_listing.tpl.php

示例11: serialize

 if (isset($_POST['phconc'])) {
     if ($_POST['phconc'] == true) {
         if (is_array($_POST['concurs']) && count($_POST['concurs']) > 0) {
             $concurs = serialize($_POST['concurs']);
             $i = 0;
             foreach ($_POST['concurs'] as $con) {
                 if (count($con['img']) < 3) {
                     for ($a = 0; $a < count($con['img']); $a++) {
                         if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/img/uploads/news/fb/" . date('Y-m') . "/" . get_ext($con['img'][$a], '/'))) {
                             resizeCopy($_SERVER['DOCUMENT_ROOT'] . str_replace('http://funtime.ge:80', '', generate_unknown($con['img'][$a])), get_ext($con['img'][$a], '/'), 485, $_SERVER['DOCUMENT_ROOT'] . "/img/uploads/news/fb/" . date('Y-m'), false);
                         }
                     }
                 } else {
                     for ($a = 0; $a < count($con['img']); $a++) {
                         if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/img/uploads/news/fb/" . date('Y-m') . "/" . get_ext($con['img'][$a], '/'))) {
                             resizeCopy($_SERVER['DOCUMENT_ROOT'] . str_replace('http://funtime.ge:80', '', generate_unknown($con['img'][$a])), get_ext($con['img'][$a], '/'), 285, $_SERVER['DOCUMENT_ROOT'] . "/img/uploads/news/fb/" . date('Y-m'), 3);
                         }
                     }
                 }
                 $i++;
             }
             $check_concurs = $DB->getOne("SELECT id FROM #__news_gallery_com WHERE news_id=" . intval($_GET['edit']));
             if ($check_concurs > 0) {
                 $DB->execute("UPDATE #__news_gallery_com SET gallery='{$concurs}',updated_at='" . date('Y-m-d H:i:s') . "' WHERE news_id=" . intval($_GET['edit']));
             } else {
                 $DB->execute("INSERT INTO #__news_gallery_com (news_id,gallery,date,updated_at) VALUES ('" . intval($_GET['edit']) . "','" . $concurs . "','" . date('Y-m-d H:i:s') . "','" . date('Y-m-d H:i:s') . "')");
             }
         } else {
             $concurs = "";
             $check_concurs = $DB->getOne("SELECT id FROM #__news_gallery_com WHERE news_id=" . intval($_GET['edit']));
             if ($check_concurs > 0) {
开发者ID:Vatia13,项目名称:funtime,代码行数:31,代码来源:.model.php

示例12: die

     die('0');
     //返回命令  0 = 开始上传文件, 2 = 不上传文件,前台直接显示上传完成
 }
 if (getGet('access2008_cmd') == '3') {
     //提交文件信息进行验证
     getGet("access2008_File_name");
     // 	'文件名
     getGet("access2008_File_size");
     //	'文件大小,单位字节
     getGet("access2008_File_type");
     //	'文件类型 例如.gif .png
     die('0');
     //返回命令 0 = 开始上传文件,1 = 提交MD5验证后的文件信息进行验证, 2 = 不上传文件,前台直接显示上传完成
 }
 //---------------------------------------------------------------------------------------------
 $type = get_ext($_FILES["Filedata"]["name"]);
 $uploadfile = @iconv('UTF-8', 'GB2312//IGNORE', trim(urldecode($_REQUEST['path']), '/') . '/' . $_FILES["Filedata"]["name"]);
 if ((in_array('*', C('UPLOAD_CONF.UPLOAD_ALLOW_TYPE')) || in_array($type, C('UPLOAD_CONF.UPLOAD_ALLOW_TYPE'))) && $_FILES["Filedata"]["size"] < C('UPLOAD_CONF.UPLOAD_MAX_SIZE')) {
     if ($_FILES["Filedata"]["error"] > 0) {
         echo '<div class="notification attention png_bg"><div><span style="float:left;">上传失败: </span>' . $_FILES["Filedata"]["name"] . '!</div></div>';
         echo '<div class="notification error png_bg"><div><span style="float:left;">错误信息: </span>' . $_FILES["Filedata"]["error"] . '!</div></div>';
         exit;
     } else {
         $file = array();
         $file['msg_attention'] = '<div class="notification attention png_bg"><div><span style="float:left;">上传失败: </span>' . $_FILES["Filedata"]["name"] . '</div></div>';
         $file['msg_success_normal'] = '<div class="notification success png_bg"><div><span style="float:left;">上传成功: </span>' . $_FILES["Filedata"]["name"] . '</div></div>';
         $file['msg_success_cover'] = '<div class="notification attention png_bg"><div><span style="float:left;">上传成功: </span>' . $_FILES["Filedata"]["name"] . ' 已覆盖</div></div>';
         $file['file_type'] = '<span style="float:left;">文件类型: </span>' . $type . '<br />';
         $file['file_size'] = '<span style="float:left;">文件大小: </span>' . dealsize($_FILES["Filedata"]["size"]) . '<br />';
         $file['file_md5'] = '<span style="float:left;">MD5 校验 : </span>' . getGet("access2008_File_md5") . '<br />';
         $file['info'] = '<div class="notification information png_bg"><div>' . $file['file_type'] . $file['file_size'] . $file['file_md5'] . '</div></div>';
开发者ID:Wen1750686723,项目名称:webftp,代码行数:31,代码来源:upload.tpl.php

示例13: _remap

 /**
  * Load the current page
  * @return null
  */
 public function _remap()
 {
     try {
         // URI segment
         $uri = explode('.', implode('/', array_slice($this->uri->segments, 1)));
         $slug = $uri[0];
         $slug_first_segment = strpos($slug, '/') ? substr($slug, 0, strpos($slug, '/')) : $slug;
         if (empty($slug)) {
             header('Location: ' . $this->data['base_uri'] . $this->fallback_page);
             exit;
         }
         // Ajax login check
         if ('login_status' == $slug_first_segment) {
             return $this->login_status();
         }
         // Load page based on slug
         $page = $this->pages->get_by_slug($this->data['book']->book_id, $slug);
         if (!empty($page)) {
             // Protect
             if (!$page->is_live) {
                 $this->protect_book('Reader');
             }
             // Version being asked for
             $version_num = (int) get_version($this->uri->uri_string());
             $this->data['version_datetime'] = null;
             if (!empty($version_num)) {
                 $version = $this->versions->get_by_version_num($page->content_id, $version_num);
                 if (!empty($version)) {
                     $this->data['version_datetime'] = $version->created;
                 }
             }
             // Build (hierarchical) RDF object for the page's version(s)
             $settings = array('book' => $this->data['book'], 'content' => $page, 'base_uri' => $this->data['base_uri'], 'versions' => !empty($this->data['version_datetime']) ? $this->data['version_datetime'] : RDF_Object::VERSIONS_MOST_RECENT, 'ref' => RDF_Object::REFERENCES_ALL, 'prov' => RDF_Object::PROVENANCE_ALL, 'max_recurses' => $this->max_recursions);
             $index = $this->rdf_object->index($settings);
             if (!count($index)) {
                 throw new Exception('Problem getting page index');
             }
             $this->data['page'] = $index[0];
             unset($index);
             // Paywall
             if (isset($page->paywall) && $page->paywall) {
                 $this->paywall();
             }
             // If a media page, overwrite the views with the media_views if applicable
             if ('media' == $this->data['page']->type && !empty($this->data['media_views'])) {
                 $this->data['views'] = $this->data['media_views'];
             }
             // Set the view based on the page's default view
             $default_view = $this->data['page']->versions[$this->data['page']->version_index]->default_view;
             if (array_key_exists($default_view, $this->data['views'])) {
                 $this->data['view'] = $default_view;
             }
         } else {
             $this->data['slug'] = $slug;
         }
         // View and view-specific method (outside of the if/page context above, in case the page hasn't been created yet
         if (array_key_exists(get_ext($this->uri->uri_string()), $this->data['views'])) {
             $this->data['view'] = get_ext($this->uri->uri_string());
         }
         if (in_array($this->data['view'], $this->vis_views)) {
             $this->data['viz_view'] = $this->data['view'];
             // Keep a record of the specific viz view being asked for
             $this->data['view'] = $this->vis_views[0];
             // There's only one viz page (Javascript handles the specific viz types)
         }
         // View-specific method
         $method_name = $this->data['view'] . '_view';
         if (method_exists($this, $method_name)) {
             $this->{$method_name}();
         }
         // URI segment method
         if (method_exists($this, $slug_first_segment)) {
             $this->{$slug_first_segment}();
         }
     } catch (Exception $e) {
         header($e->getMessage());
         exit;
     }
     if ($this->template_has_rendered) {
         return;
     }
     // Template might be rendered in one of the methods below
     $this->template->set_template($this->config->item('arbor'));
     foreach ($this->template->template['regions'] as $region) {
         $this->template->write_view($region, 'melons/' . $this->data['melon'] . '/' . $region, $this->data);
     }
     $this->template->render();
 }
开发者ID:riseofthetigers,项目名称:scalar,代码行数:92,代码来源:book.php

示例14: is_image

function is_image($filename, $image_ext)
{
    $filename = trim($filename);
    $ext = get_ext($filename);
    return in_array($ext, $image_ext);
}
开发者ID:undisputed-seraphim,项目名称:manga_server,代码行数:6,代码来源:functions.php

示例15: DbMySqli

<?php

include_once $_SERVER['DOCUMENT_ROOT'] . "/common/lib/common.php";
$db = new DbMySqli();
$name = addslashes($_POST['name']);
$title = addslashes($_POST['title']);
$content = addslashes($_POST['content']);
//첨부파일 업로드
if (is_uploaded_file($_FILES["filename"]["tmp_name"])) {
    $filename = $_FILES["filename"]["name"];
    $filesize = $_FILES["filename"]["size"];
    $origin_filename = $filename;
    $ext = strtolower(get_ext($filename));
    new_check_ext($ext);
    //금지파일 체크
    $filename = get_filename($filepath1, $ext);
    move_uploaded_file($_FILES["filename"]["tmp_name"], get_real_filepath($filepath1) . "/" . $filename);
} else {
    $filesize = 0;
}
$userip = $_SERVER['REMOTE_ADDR'];
$sql = "select ifnull(max(idx), 0) + 1 from tbl_qna";
$result = $db->query($sql);
$rows = mysqli_fetch_row($result);
$f_idx = $rows[0];
$table = "tbl_qna";
$idx_field = "idx";
$db['f_idx'] = $f_idx;
$db['thread'] = "a";
$db['name'] = $name;
$db['title'] = $title;
开发者ID:kisstest,项目名称:snu_stress_manage,代码行数:31,代码来源:write_proc.php


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