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

PHP get_ext函数代码示例

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

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



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


示例16: file_upload

 function file_upload($field = '', $file_type = '', $dest_dir = '')
 {
     $uploadtempdir = $_ENV["TEMP"] . "\\";
     ini_set('upload_tmp_dir', $uploadtempdir);
     $tmp_name = $_FILES[$field]["tmp_name"];
     $file_name = $_FILES[$field]["name"];
     $file_type = $_FILES[$field]["type"];
     $file_size = $_FILES[$field]["size"];
     $file_ext = get_ext($file_name);
     $file_name_orig = $file_name;
     $file_name_base = substr($file_name, 0, strlen($file_name) - (strlen($file_ext) + 1));
     //$dest_dir = '/tmp';
     if ($file_size == 0) {
         return;
     }
     if (!is_dir($dest_dir)) {
         echo "dest_dir not found<br />\n";
         return;
     }
     //check if allowed file type
     if ($file_type == "img") {
         switch (strtolower($file_ext)) {
             case "jpg":
                 break;
             case "png":
                 break;
             case "gif":
                 break;
             case "bmp":
                 break;
             case "psd":
                 break;
             case "tif":
                 break;
             default:
                 return false;
         }
     }
     if ($file_type == "file") {
         switch (strtolower($file_ext)) {
             case "doc":
                 break;
             case "pdf":
                 break;
             case "ppt":
                 break;
             case "xls":
                 break;
             case "zip":
                 break;
             case "exe":
                 break;
             default:
                 return false;
         }
     }
     //find unique filename: check if file exists if it does then increment the filename
     $i = 1;
     while (file_exists($dest_dir . '/' . $file_name)) {
         if (strlen($file_ext) > 0) {
             $file_name = $file_name_base . $i . '.' . $file_ext;
         } else {
             $file_name = $file_name_orig . $i;
         }
         $i++;
     }
     //echo "file_type: ".$file_type."<br />\n";
     //echo "tmp_name: ".$tmp_name."<br />\n";
     //echo "file_name: ".$file_name."<br />\n";
     //echo "file_ext: ".$file_ext."<br />\n";
     //echo "file_name_orig: ".$file_name_orig."<br />\n";
     //echo "file_name_base: ".$file_name_base."<br />\n";
     //echo "dest_dir: ".$dest_dir."<br />\n";
     //move the file to upload directory
     //bool move_uploaded_file  ( string $filename, string $destination  )
     if (move_uploaded_file($tmp_name, $dest_dir . '/' . $file_name)) {
         return $file_name;
     } else {
         echo "File upload failed!  Here's some debugging info:\n";
         return false;
     }
     exit;
 }
开发者ID:rdissauer,项目名称:fusionpbx,代码行数:83,代码来源:functions.php


示例17: get_ext

<?php

include 'data/function.php';
//$a = array('1','2','3');
//$b = array('odin','dva','tri');
//$c = str_replace($a, $b, '1234');
//print_r($c);
//echo generate_page_fname('buy viagra online');
//$d = preg_replace("/\[noan\]/","TAGG",'asjasasnas[noan]mkmkmk');
//echo $d;
//$patterns = array ("/(19|20)(\d{2})-(\d{1,2})-(\d{1,2})/","/^\s*{(\w+)}\s*=/");
//$replace = array ("\\3/\\4/\\1\\2", "$\\1 =");
//echo preg_replace($patterns, $replace, "{startDate} = 1999-5-27");
//$string = "The quick brown fox jumped over the lazy dog.";
//$patterns[0] = "/quick/";
//$patterns[1] = "/brown/";
//$patterns[2] = "/fox/";
//$replacements[2] = "bear";
//$replacements[1] = "black";
//$replacements[0] = "slow";
//echo preg_replace($patterns, $replacements, $string);
print get_ext('asasa.txt');
开发者ID:ivrm,项目名称:mbgdorgen,代码行数:22,代码来源:test.php


示例18: __construct

 /**
  * URL information and load the current book
  */
 public function __construct()
 {
     parent::__construct();
     $this->load->model('book_model', 'books');
     $this->load->model('page_model', 'pages');
     $this->load->model('version_model', 'versions');
     $this->load->model('reference_model', 'references');
     $this->load->model('annotation_model', 'annotations');
     $this->load->model('path_model', 'paths');
     $this->load->model('tag_model', 'tags');
     $this->load->model('reply_model', 'replies');
     $this->load->library('RDF_Object', 'rdf_object');
     $this->load->library('statusCodes');
     $this->load->helper('inflector');
     $this->models = $this->config->item('rel');
     // Determine the current book being asked for (if applicable)
     $this->scope = strtolower(get_class($this)) == strtolower($this->uri->segment('1')) ? null : strtolower($this->uri->segment('1'));
     // Load book beind asked for (if applicable)
     $this->data['book'] = !empty($this->scope) ? $this->books->get_by_slug($this->scope) : null;
     if (empty($this->data['book'])) {
         // Book couldn't be found
         $this->data['base_uri'] = confirm_slash(base_url());
     } else {
         // Book was found
         $this->data['base_uri'] = confirm_slash(base_url()) . confirm_slash($this->data['book']->slug);
         // Protect book; TODO: provide api_key authentication like api.php
         $this->set_user_book_perms();
         if (!$this->data['book']->url_is_public && !$this->login_is_book_admin('reader')) {
             header(StatusCodes::httpHeaderFor(StatusCodes::HTTP_NOT_FOUND));
             exit;
         }
     }
     // Format (e.g., 'xml', 'json')
     $allowable_formats = array('xml' => 'xml', 'json' => 'json', 'rdfxml' => 'xml', 'rdfjson' => 'json', 'turtle' => 'turtle');
     $this->data['format'] = isset($_REQUEST['format']) && array_key_exists($_REQUEST['format'], $allowable_formats) ? $allowable_formats[$_REQUEST['format']] : $allowable_formats[key($allowable_formats)];
     $ext = get_ext($this->uri->uri_string());
     $this->data['format'] = !empty($ext) && array_key_exists($ext, $allowable_formats) ? $allowable_formats[$ext] : $this->data['format'];
     // Recursion level
     $this->data['recursion'] = isset($_REQUEST['rec']) && is_numeric($_REQUEST['rec']) ? (int) $_REQUEST['rec'] : 0;
     // Display references?
     $this->data['references'] = isset($_REQUEST['ref']) && $_REQUEST['ref'] ? true : false;
     // Restrict relationships to a certain relationship or set of relationships (seperated by a comma)?
     $this->data['restrict'] = array();
     $restrict = isset($_REQUEST['res']) && !empty($_REQUEST['res']) ? explode(',', $_REQUEST['res']) : array();
     foreach ($restrict as $res) {
         if (!in_array(plural(strtolower($res)), $this->models)) {
             continue;
         }
         $this->data['restrict'][] = (string) plural(strtolower($res));
     }
     // Display all versions?
     $this->data['versions'] = isset($_REQUEST['versions']) && $_REQUEST['versions'] ? true : false;
     // Search terms
     $this->data['sq'] = isset($_REQUEST['sq']) && !empty($_REQUEST['sq']) ? search_split_terms($_REQUEST['sq']) : null;
     // Provenance
     $this->data['provenance'] = isset($_REQUEST['prov']) && !empty($_REQUEST['prov']) ? 1 : null;
     // Show hidden content
     $this->data['hidden'] = isset($_REQUEST['hidden']) && !empty($_REQUEST['hidden']) ? (int) $_REQUEST['hidden'] : 0;
     $this->set_user_book_perms();
     if (!$this->data['login'] || !$this->login_is_book_admin()) {
         $this->data['hidden'] = 0;
     }
     // Pagination
     $start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : null;
     $results = isset($_REQUEST['results']) && !empty($_REQUEST['results']) ? (int) $_REQUEST['results'] : null;
     if (empty($results)) {
         $start = $results = null;
     }
     $this->data['pagination'] = array();
     if (!empty($start) || $start === 0) {
         $this->data['pagination']['start'] = $start;
     }
     if (!empty($results)) {
         $this->data['pagination']['results'] = $results;
     }
 }
开发者ID:austinvernsonger,项目名称:scalar,代码行数:79,代码来源:rdf.php


示例19: while

 $sql = "DELETE FROM items WHERE id = :id";
 $req = $pdo->prepare($sql);
 $result[] = $req->execute(array('id' => $id));
 // delete associated tags
 $sql = "DELETE FROM items_tags WHERE item_id = :id";
 $req = $pdo->prepare($sql);
 $result[] = $req->execute(array('id' => $id));
 // delete associated files
 $sql = "SELECT real_name, long_name FROM uploads WHERE item_id = :id AND type = :type";
 $req = $pdo->prepare($sql);
 $req->execute(array('id' => $id, 'type' => 'items'));
 while ($uploads = $req->fetch()) {
     $filepath = ELAB_ROOT . 'uploads/' . $uploads['long_name'];
     unlink($filepath);
     // remove thumbnail
     $ext = get_ext($uploads['real_name']);
     if (file_exists(ELAB_ROOT . 'uploads/' . $uploads['long_name'] . '_th.' . $ext)) {
         unlink(ELAB_ROOT . 'uploads/' . $uploads['long_name'] . '_th.' . $ext);
     }
 }
 // now remove them from the database
 $sql = "DELETE FROM uploads WHERE item_id = :id AND type = :type";
 $req = $pdo->prepare($sql);
 $result[] = $req->execute(array('id' => $id, 'type' => 'items'));
 // delete links of this item in experiments with this item linked
 // get all experiments with that item linked
 $sql = "SELECT id FROM experiments_links WHERE link_id = :link_id";
 $req = $pdo->prepare($sql);
 $result[] = $req->execute(array('link_id' => $id));
 while ($links = $req->fetch()) {
     $delete_sql = "DELETE FROM experiments_links WHERE id=" . $links['id'];
开发者ID:jcapellman,项目名称:elabftw,代码行数:31,代码来源:delete.php


示例20: while

        $count = 1;
        while (($entry = zip_read($comic)) !== false) {
            $file_name = zip_entry_name($entry);
            $file_name = mb_convert_encoding($file_name, "UTF-8", $enc);
            // もう走査しなくていい
            if ($count > FORCOVER) {
                break;
            }
            // 画像か否か
            if (!is_image($file_name, $image_ext)) {
                continue;
            }
            // サムネイルを作るべき画像か
            if ($count == FORCOVER) {
                $data = zip_entry_read($entry, zip_entry_filesize($entry));
                $ext = get_ext($file_name);
                $thumb = array("id" => $i + 1, "zip" => $zip_file, "filepath" => CACHE . "/thumb." . $ext, "ext" => $ext);
                file_put_contents($thumb["filepath"], $data);
                $r = make_thumbnail($thumb);
                if ($r) {
                    save_thumbnail($thumb);
                }
            }
            $count++;
        }
    } else {
        //die("[ERR]ZIP_OPEN : ".$zip_file);
        // ここに代替画像
    }
    zip_close($comic);
}
开发者ID:undisputed-seraphim,项目名称:manga_server,代码行数:31,代码来源:make_thumbnail.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP get_extended函数代码示例发布时间:2022-05-15
下一篇:
PHP get_exists_page_number函数代码示例发布时间: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