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


PHP get_extension函数代码示例

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


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

示例1: load

 function load()
 {
     if ($this->exists() == true) {
         $this->import();
     } else {
         require_once 'classes/class.geshi.php';
         $this->data = array();
         $source = 'classes/geshi/';
         $d = dir($source);
         while (false !== ($entry = $d->read())) {
             if (get_extension($entry) == 'php' && !is_dir($source . $entry)) {
                 include_once $source . $entry;
                 if (!isset($language_data['NO_INDEX'])) {
                     $short = str_replace('.php', '', $entry);
                     $this->data[$short]['file'] = $entry;
                     $this->data[$short]['name'] = $language_data['LANG_NAME'];
                     $this->data[$short]['short'] = $short;
                 }
             }
         }
         $d->close();
         asort($this->data);
         $this->export();
     }
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:25,代码来源:syntaxhighlight.inc.php

示例2: SaveHTTPFile

function SaveHTTPFile($fFileHTTPPath, $fFileSavePath, $fFileSaveName)
{
    //记录程序开始的时间
    $BeginTime = getmicrotime();
    //取得文件名
    $fFileSaveName = $fFileSavePath . "/" . $fFileSaveName;
    make_dir(dirname($fFileSaveName));
    //取得文件的内容
    ob_start();
    readfile($fFileHTTPPath);
    $img = ob_get_contents();
    ob_end_clean();
    //$size = strlen($img);
    //保存到本地
    $fp2 = @fopen($fFileSaveName, "a");
    fwrite($fp2, $img);
    fclose($fp2);
    /*加水印代码*/
    require_once ROOT_PATH . 'includes/cls_image.php';
    $ext = get_extension($fFileSaveName);
    $fFileSaveName = convert_GIF_to_JPG($fFileSaveName);
    if (CopyFiles($fFileSaveName)) {
        $image = new cls_image();
        $image->add_watermark($fFileSaveName, '', '../../../../' . $GLOBALS['waterMark']['watermark'], $GLOBALS['waterMark']['watermark_place'], $GLOBALS['waterMark']['watermark_alpha']);
    }
    if ($ext == 'gif' || $ext == '.gif') {
        back_JPG_to_GIF($fFileSaveName);
    }
    /*加水印代码--end*/
    //记录程序运行结束的时间
    $EndTime = getmicrotime();
    //返回运行时间
    return $EndTime - $BeginTime;
}
开发者ID:norain2050,项目名称:benhu,代码行数:34,代码来源:ServerXMLHTTP.php

示例3: export_template_list

function export_template_list($path, $d = 0)
{
    if (substr($path, strlen($path) - 1) != '/') {
        $path .= '/';
    }
    $dirlist = array();
    if ($handle = opendir($path)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != '.' && $file != '..') {
                $file = $path . $file;
                if (!is_dir($file)) {
                    $extension = get_extension($path);
                    if (stripos($extension, 'bak') === false) {
                        $dirlist[] = $file;
                    }
                } elseif ($d >= 0) {
                    $result = export_template_list($file . '/', $d + 1);
                    $dirlist = array_merge($dirlist, $result);
                }
            }
        }
        closedir($handle);
    }
    if ($d == 0) {
        natcasesort($dirlist);
    }
    return $dirlist;
}
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:28,代码来源:designs.php

示例4: upload

function upload()
{
    $msg = 9;
    $con = mysqli_connect('localhost', 'shibli', 'shibli');
    mysqli_select_db($con, 'piclib');
    $imaget = mysqli_real_escape_string($con, $_FILES["userfile"]["type"]);
    $f = substr($imaget, 0, 5);
    if ($f == "image") {
        if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
            header("location: http://localhost:63342/VideoLibraryApp/views/fun.php");
        }
        $imgData = addslashes(file_get_contents($_FILES['userfile']['tmp_name']));
        $ext = get_extension($_FILES['userfile']['name']);
        $query2 = " Select max(imageID) from imgdata;";
        $result2 = mysqli_query($con, $query2);
        $row2 = mysqli_fetch_row($result2);
        $r = $row2[0] + 1;
        $sql = "INSERT INTO imgdata values({$r},'{$ext}','{$_POST['imageName']}','{$_POST['user']}','{$imgData}')";
        mysqli_query($con, $sql) or die("Error in Query: " . mysqli_error($con));
        header("location: http://localhost:63342/VideoLibraryApp/views/displayLogged.php");
    } else {
        //$finfo = finfo_open(FILEINFO_MIME_TYPE);
        //finfo_file($finfo, $_FILES['userfile']['tmp_name']);
        header("location: http://localhost:63342/VideoLibraryApp/views/main.css");
    }
    return $msg;
}
开发者ID:shiblibaig,项目名称:Photo-Library,代码行数:27,代码来源:uploadPics.php

示例5: upload_data

function upload_data()
{
    $msg = "";
    $filename = $_FILES["file"]["name"];
    //文件名
    //echo get_extension($filename);exit;
    if (get_extension($filename) == "csv") {
        if ($_FILES["file"]["error"] > 0) {
            $msg = "上传错误: " . $_FILES["file"]["error"];
        } else {
            if (file_exists("data/" . $_FILES["file"]["name"])) {
                $msg = $_FILES["file"]["name"] . " 已经存在,请查看data文件下是否存在您的数据文件. ";
            } else {
                move_uploaded_file($_FILES["file"]["tmp_name"], "data/" . $_FILES["file"]["name"]);
                if (file_exists("data/" . $_FILES["file"]["name"])) {
                    $msg = "上传成功!文件已经保存在了 " . "data/" . $_FILES["file"]["name"] . "接下来您可以导入本次打卡记录了。";
                } else {
                    $msg = "上传失败,因为目录权限被拒绝,请手动上传。";
                }
            }
        }
    } else {
        $msg = "文件格式错误";
    }
    return $msg;
}
开发者ID:sdgdsffdsfff,项目名称:duty,代码行数:26,代码来源:upload.php

示例6: convert_data

 function convert_data($data)
 {
     global $db, $import_session, $mybb, $error_notice, $insert_data;
     static $field_info;
     if (!isset($field_info)) {
         // Get columns so we avoid any 'unknown column' errors
         $field_info = $db->show_fields_from("attachments");
     }
     $insert_data = array();
     foreach ($field_info as $key => $field) {
         if ($field['Extra'] == 'auto_increment') {
             if ($db->type != "sqlite") {
                 $insert_data[$field['Field']] = '';
             }
             continue;
         }
         if (isset($data[$field['Field']])) {
             $insert_data[$field['Field']] = $data[$field['Field']];
         }
     }
     // MyBB 1.6 values
     $insert_data['import_aid'] = $data['aid'];
     $insert_data['pid'] = $this->get_import->pid($data['pid']);
     $insert_data['uid'] = $this->get_import->uid($data['uid']);
     $attachname_array = explode('_', str_replace('.attach', '', $data['attachname']));
     $insert_data['attachname'] = 'post_' . $this->get_import->uid($attachname_array[1]) . '_' . $attachname_array[2] . '.attach';
     if ($data['thumbnail']) {
         $ext = get_extension($data['thumbnail']);
         $insert_data['thumbnail'] = str_replace(".attach", "_thumb.{$ext}", $insert_data['attachname']);
     }
     return $insert_data;
 }
开发者ID:dgrp,项目名称:merge-system,代码行数:32,代码来源:attachments.php

示例7: get_bak_file

/**
 * returns bak file for restore
 * @param string
 */
function get_bak_file($file)
{
    if (get_extension($file) == 'php') {
        return substr_replace($file, '.bak', strrpos($file, '.'), 0);
    } else {
        return $file . '.bak';
    }
}
开发者ID:HassenLin,项目名称:piwigo_utf8filename,代码行数:12,代码来源:functions.inc.php

示例8: data_uri

function data_uri($file)
{
    $type = get_extension($file);
    $mime = 'image/' . $type;
    $contents = file_get_contents($file);
    $base64 = base64_encode($contents);
    return 'data:' . $mime . ';base64,' . $base64;
}
开发者ID:Covert-Inferno,项目名称:callme,代码行数:8,代码来源:login.php

示例9: save_external_image

 public function save_external_image($url = '', $path = '')
 {
     if (empty($url)) {
         return;
     }
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
     $err = curl_error($ch);
     if (empty($err)) {
         $rawdata = curl_exec($ch);
     }
     curl_close($ch);
     if ($rawdata) {
         $ext = get_extension($path);
         $upload_path = './uploads/editor/';
         if (is_dir($upload_path) == false) {
             mkdir($upload_path, 0707);
             $file = $upload_path . 'index.php';
             $f = @fopen($file, 'w');
             @fwrite($f, '');
             @fclose($f);
             @chmod($file, 0644);
         }
         $upload_path .= cdate('Y') . '/';
         if (is_dir($upload_path) === false) {
             mkdir($upload_path, 0707);
             $file = $upload_path . 'index.php';
             $f = @fopen($file, 'w');
             @fwrite($f, '');
             @fclose($f);
             @chmod($file, 0644);
         }
         $upload_path .= cdate('m') . '/';
         if (is_dir($upload_path) === false) {
             mkdir($upload_path, 0707);
             $file = $upload_path . 'index.php';
             $f = @fopen($file, 'w');
             @fwrite($f, '');
             @fclose($f);
             @chmod($file, 0644);
         }
         list($usec, $sec) = explode(' ', microtime());
         $file_name = md5(uniqid(mt_rand())) . '_' . str_replace('.', '', $sec . $usec) . '.' . $ext;
         $save_dir = $upload_path . $file_name;
         $save_url = site_url('uploads/editor/' . cdate('Y') . '/' . cdate('m') . '/' . $file_name);
         $fp = fopen($save_dir, 'w');
         fwrite($fp, $rawdata);
         fclose($fp);
         if (file_exists($save_dir)) {
             return $save_url;
         }
     }
     return;
 }
开发者ID:smboy86,项目名称:zzing,代码行数:56,代码来源:Imagelib.php

示例10: __autoload

function __autoload($class)
{
    // $class = strtolower($class);
    // $class = str_replace('A\\',DIRECTORY_SEPARATOR,$class);
    $name = $class . '.class.php';
    // echo $name;
    get_extension($name);
    get_exist($name);
    require_once $name;
}
开发者ID:yyangzhou,项目名称:yangzhou,代码行数:10,代码来源:autoload.php

示例11: show_image

function show_image($image)
{
    header('Content-type: image/' . get_extension($image));
    $handle = fopen($image, "rb");
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
        echo $buffer;
    }
    fclose($handle);
}
开发者ID:shifter,项目名称:ospap,代码行数:10,代码来源:picture.php

示例12: getFileType

function getFileType($image_data)
{
    $f = finfo_open();
    $mime_type = finfo_buffer($f, $image_data, FILEINFO_MIME_TYPE);
    $ext = get_extension($mime_type);
    if ($ext === false) {
        error("Unsupported filetype: " . $mime_type);
    }
    return $ext;
}
开发者ID:shadowbeam,项目名称:img-srch,代码行数:10,代码来源:file-upload.php

示例13: verif_image

function verif_image($tabFile)
{
    $ret = _UPLOAD_NO_ERROR;
    $file_name = $tabFile["name"];
    $extension = get_extension($file_name);
    if (!in_array($extension, array(_UPLOAD_EXTENSION_JPG, _UPLOAD_EXTENSION_PNG, _UPLOAD_EXTENSION_GIF))) {
        $ret = _UPLOAD_TYPE_ERROR;
    }
    return $ret;
}
开发者ID:PetiLabo,项目名称:PetiLabo,代码行数:10,代码来源:upload_image.php

示例14: jet_Upload

/**
 * @param string $name
 * @param string $type
 * @return bool
 */
function jet_Upload($name = 'random', $type = 'image')
{
    if ($type and !file_exists(ROOT . '/uploads/' . $type)) {
        mkdir(ROOT . '/uploads/' . $type);
    }
    $f = array_keys($_FILES)[0];
    $ext = get_extension($_FILES[$f]['name']);
    $save_path = $type ? ROOT . '/uploads/' . $type . '/' : ROOT . 'uploads/';
    $save_name = $name ? $name . '.' . $ext : jetRandString(12) . '.' . $ext;
    return move_uploaded_file($_FILES[$f]["tmp_name"], $save_path . $save_name) || false;
}
开发者ID:Jaggle,项目名称:JetPHP,代码行数:16,代码来源:functions.php

示例15: deal_upload_image

function deal_upload_image($fileInfo, $allowExt = array("gif", "jpeg", "jpg", "png", "wbmp"), $maxSize = 1512000, $imgFlag = true)
{
    if ($fileInfo['error'] == 0) {
        //UPLOAD_ERR_OK
        $f_ext = get_extension($fileInfo['name']);
        if (!in_array($f_ext, $allowExt)) {
            return $mes = '非法文件类型';
        }
        if ($fileInfo['size'] > $maxSize) {
            return $mes = '文件大小超过上限';
        }
        if ($imgFlag) {
            $info = getimagesize($fileInfo['tmp_name']);
            if (!$info) {
                return $mes = '不是真实的图片类型';
            }
        }
        return true;
    } else {
        switch ($fileInfo['error']) {
            case 1:
                $mes = "超过了配置文件上传文件的大小";
                //UPLOAD_ERR_INI_SIZE
                break;
            case 2:
                $mes = "超过了表单设置上传文件的大小";
                //UPLOAD_ERR_FORM_SIZE
                break;
            case 3:
                $mes = "文件部分被上传";
                //UPLOAD_ERR_PARTIAL
                break;
            case 4:
                $mes = "没有文件被上传";
                //UPLOAD_ERR_NO_FILE
                break;
            case 6:
                $mes = "没有找到临时目录";
                //UPLOAD_ERR_NO_TMP_DIR
                break;
            case 7:
                $mes = "文件不可写";
                //UPLOAD_ERR_CANT_WRITE;
                break;
            case 8:
                $mes = "由于PHP的扩展程序中断了文件上传";
                //UPLOAD_ERR_EXTENSION
                break;
        }
        return $mes;
    }
}
开发者ID:rayshuai,项目名称:Myfunctions,代码行数:52,代码来源:deal_upload_image.php


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