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


PHP Path::getExtension方法代码示例

本文整理汇总了PHP中Path::getExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::getExtension方法的具体用法?PHP Path::getExtension怎么用?PHP Path::getExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Path的用法示例。


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

示例1: open

 public static function open(\Path $path)
 {
     $ext = $path->getExtension();
     switch ($ext) {
         case 'zip':
         case 'cbz':
             return new ZipArchive($path);
         case 'rar':
         case 'cbr':
             return new RarArchive($path);
         default:
             throw new \Exception('Invalid file type: ' . $ext);
     }
 }
开发者ID:Lord-Simon,项目名称:MangaIndex,代码行数:14,代码来源:Factory.php

示例2: api_addAttachment

function api_addAttachment($blogid, $parent, $file)
{
    $pool = DBModel::getInstance();
    $attachment = array();
    $attachment['parent'] = $parent ? $parent : 0;
    $attachment['label'] = Path::getBaseName($file['name']);
    $label = Utils_Unicode::lessenAsEncoding($attachment['label'], 64);
    $attachment['size'] = $file['size'];
    $extension = Path::getExtension($attachment['label']);
    switch (strtolower($extension)) {
        case '.exe':
        case '.php':
        case '.sh':
        case '.com':
        case '.bat':
            $extension = '.xxx';
            break;
    }
    /* Create directory for owner */
    $path = __TEXTCUBE_ATTACH_DIR__ . "/{$blogid}";
    if (!is_dir($path)) {
        mkdir($path);
        if (!is_dir($path)) {
            return false;
        }
        @chmod($path, 0777);
    }
    $pool->reset('Attachments');
    $pool->setQualifier('blogid', 'eq', $blogid);
    $pool->setQualifier('parent', 'eq', $parent);
    $pool->setQualifier('label', 'eq', $label, true);
    $oldFile = $pool->getCell('name');
    if ($oldFile !== null) {
        $attachment['name'] = $oldFile;
    } else {
        $attachment['name'] = rand(1000000000, 9999999999) . $extension;
        while (Attachment::doesExist($attachment['name'])) {
            $attachment['name'] = rand(1000000000, 9999999999) . $extension;
        }
    }
    $attachment['path'] = "{$path}/{$attachment['name']}";
    deleteAttachment($blogid, -1, $attachment['name']);
    if ($file['content']) {
        $f = fopen($attachment['path'], "w");
        if (!$f) {
            return false;
        }
        $attachment['size'] = fwrite($f, $file['content']);
        fclose($f);
        $file['tmp_name'] = $attachment['path'];
    }
    if ($imageAttributes = @getimagesize($file['tmp_name'])) {
        $attachment['mime'] = $imageAttributes['mime'];
        $attachment['width'] = $imageAttributes[0];
        $attachment['height'] = $imageAttributes[1];
    } else {
        $attachment['mime'] = Utils_Misc::getMIMEType($extension);
        $attachment['width'] = 0;
        $attachment['height'] = 0;
    }
    $attachment['mime'] = Utils_Unicode::lessenAsEncoding($attachment['mime'], 32);
    @chmod($attachment['path'], 0666);
    $pool->reset('Attachments');
    $pool->setAttribute('blogid', $blogid);
    $pool->setAttribute('parent', $attachment['parent']);
    $pool->setAttribute('name', $attachment['name'], true);
    $pool->setAttribute('label', $label, true);
    $pool->setAttribute('mime', $attachment['mime'], true);
    $pool->setAttribute('size', $attachment['size'], true);
    $pool->setAttribute('width', $attachment['width']);
    $pool->setAttribute('height', $attachment['height']);
    $pool->setAttribute('attached', Timestamp::getUNIXtime());
    $pool->setAttribute('downloads', 0);
    $pool->setAttribute('enclosure', 0);
    $result = $pool->insert();
    if (!$result) {
        @unlink($attachment['path']);
        return false;
    }
    return $attachment;
}
开发者ID:Avantians,项目名称:Textcube,代码行数:81,代码来源:api.php

示例3: array_push

        array_push($errorText, _t('파비콘을 변경하지 못했습니다.'));
    } else {
        Attachment::confirmFolder();
        if (move_uploaded_file($_FILES['favicon']['tmp_name'], __TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/favicon.ico")) {
            @chmod(__TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/favicon.ico", 0666);
            array_push($errorText, _t('파비콘을 변경하였습니다.'));
        }
    }
}
// 블로그 아이콘 처리.
if ($_POST['deleteBlogIcon'] == "yes") {
    unlink(__TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/index.gif");
    array_push($errorText, _t('블로그 아이콘을 초기화 하였습니다.'));
}
if (!empty($_FILES['blogIcon']['tmp_name'])) {
    $fileExt = Path::getExtension($_FILES['blogIcon']['name']);
    if (!in_array($fileExt, array('.gif', '.jpg', '.jpeg', '.png'))) {
        array_push($errorText, _t('블로그 아이콘을 변경하지 못했습니다.'));
    } else {
        Attachment::confirmFolder();
        if (move_uploaded_file($_FILES['blogIcon']['tmp_name'], __TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/index.gif")) {
            @chmod(__TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/index.gif", 0666);
            array_push($errorText, _t('블로그 아이콘을 변경하였습니다.'));
        } else {
        }
    }
}
Setting::setBlogSettingGlobal('useBlogIconAsIphoneShortcut', $_POST['useBlogIconAsIphoneShortcut']);
if (!empty($errorText)) {
    $errorText = urlencode(implode('<br />', $errorText));
} else {
开发者ID:Avantians,项目名称:Textcube,代码行数:31,代码来源:index.php

示例4: getExtension

 public function getExtension()
 {
     return Path::getExtension($this->path);
 }
开发者ID:ASDAFF,项目名称:open_bx,代码行数:4,代码来源:fileentry.php

示例5: getImageFileUpload

function getImageFileUpload($target)
{
    global $database;
    if (doesHaveOwnership() && doesHaveMembership()) {
        $type = $_POST['type'];
        $file = $_FILES['teamImageFile'];
        $errcode = 0;
        if ($type == "upload") {
            $fileExt = Path::getExtension($file['name']);
            if ($fileExt != '.gif' && $fileExt != '.jpg' && $fileExt != '.png') {
                $errmsg = _t('잘못된 파일 형식입니다. 다시 시도하세요');
                $errcode = 1;
            } else {
                $result = getAddAttachment($file);
                $errmsg = _t('새로운 프로필 사진을 저장 했습니다.');
            }
        } else {
            if ($type == "delete") {
                $tmpImage = POD::queryCell("SELECT image FROM {$database['prefix']}TeamUserSettings WHERE blogid=" . getBlogId() . " and userid=" . getUserId());
                if ($tmpImage) {
                    $result = getDeleteAttachment();
                    $errmsg = _t('등록된 프로필 사진을 삭제 하였습니다.');
                } else {
                    $errmsg = _t('삭제할 파일이 없습니다. 다시 시도하세요');
                    $errcode = 1;
                }
            }
        }
    }
    $script = '<script type="text/javascript">//<![CDATA' . CRLF;
    if ($errcode != 1) {
        $script .= '	window.parent.top.document.getElementById("teamImage").src = "' . $result . '";';
    }
    $script .= '	window.parent.top.PM.showMessage("' . $errmsg . '", "center", "bottom");';
    $script .= '//]]></script>';
    echo $script;
    exit;
}
开发者ID:ragi79,项目名称:Textcube,代码行数:38,代码来源:index.php

示例6: splitSite

 function splitSite($url)
 {
     $pos = strpos($url, '/', 8);
     if ($pos === false) {
         $ext = Path::getExtension($url);
         if (!in_array($ext, $this->extensions)) {
             return array($url, "");
         }
         die("{$url} not a valid url");
     }
     $site = substr($url, 0, $pos);
     $filename = substr($url, $pos + 1);
     return array($site, $filename);
 }
开发者ID:shamblett,项目名称:janitor,代码行数:14,代码来源:linche.php

示例7: resample

 function resample($width, $height)
 {
     if (empty($width) && empty($height)) {
         return false;
     }
     if (empty($this->imageFile) || !file_exists($this->imageFile)) {
         return false;
     }
     // create an image device as image format.
     switch ($this->getImageType($this->imageFile)) {
         case "gif":
             if (imagetypes() & IMG_GIF) {
                 $originImageDevice = imagecreatefromgif($this->imageFile);
             } else {
                 return false;
             }
             break;
         case "jpg":
             if (imagetypes() & IMG_JPG) {
                 $originImageDevice = imagecreatefromjpeg($this->imageFile);
             } else {
                 return false;
             }
             break;
         case "png":
             if (imagetypes() & IMG_PNG && function_exists('imagecreatefrompng')) {
                 $originImageDevice = imagecreatefrompng($this->imageFile);
             } else {
                 return false;
             }
             break;
         case "wbmp":
             if (imagetypes() & IMG_WBMP) {
                 $originImageDevice = imagecreatefromwbmp($this->imageFile);
             } else {
                 return false;
             }
             break;
         case "xpm":
             if (imagetypes() & IMG_XPM) {
                 $originImageDevice = imagecreatefromxpm($this->imageFile);
             } else {
                 return false;
             }
             break;
         default:
             return false;
             break;
     }
     // 리샘플링은 최종단계에서 리샘플링만을 하는 기능임. 시스템을 예로 들면 OS의 기능에 해당함.
     // 이미지 프로세스는 어플리케이션의 기능으로 볼 수 있고, 따라서 이미지 리샘플링 중에는 이벤트가 끼어들면 안 됨.
     //$originImageDevice = fireEvent('BeforeResizeImage', $originImageDevice, $this);
     if (Path::getExtension($this->imageFile) == ".gif") {
         $this->resultImageDevice = imagecreate($width, $height);
     } else {
         $this->resultImageDevice = imagecreatetruecolor($width, $height);
     }
     $temp = imagecolorallocate($this->resultImageDevice, $this->bgColorBy16['R'], $this->bgColorBy16['G'], $this->bgColorBy16['B']);
     imagefilledrectangle($this->resultImageDevice, 0, 0, $width, $height, $temp);
     imagecopyresampled($this->resultImageDevice, $originImageDevice, 0, 0, 0, 0, $width, $height, imagesx($originImageDevice), imagesy($originImageDevice));
     imagedestroy($originImageDevice);
     //$this->resultImageDevice = fireEvent('AfterResizeImage', $this->resultImageDevice, $this);
     return true;
 }
开发者ID:webhacking,项目名称:Textcube,代码行数:64,代码来源:Image.php

示例8: _generateName

 function _generateName()
 {
     $blogid = getBlogId();
     if (isset($this->name)) {
         if (!Validator::filename($this->name)) {
             return $this->_error('name');
         }
         switch (Path::getExtension($this->name)) {
             case '.php':
             case '.exe':
             case '.com':
             case '.sh':
             case '.bat':
                 $ext = '.xxx';
                 $this->name = rand(1000000000, 9999999999.0) . $ext;
                 break;
             default:
                 $ext = Path::getExtension2($this->name);
                 break;
         }
     } else {
         $ext = '';
     }
     $this->confirmFolder();
     while (Attachment::doesExist($this->name)) {
         $this->name = rand(1000000000, 9999999999.0) . $ext;
     }
     return true;
 }
开发者ID:ragi79,项目名称:Textcube,代码行数:29,代码来源:Textcube.Data.Attachment.php

示例9: storeImage

function storeImage($image)
{
    echo "+----------------------------------------------------------------------------+<br>";
    include './sharedkeys.php';
    echo "Start Storing [{$image}]<br>";
    include_once './Path.php';
    $file_name = Path::getFileNameWithoutExtension($_FILES[$image]['name']);
    echo "The Sent File Name [{$file_name}]<br>";
    $name = $file_name;
    include_once './Path.php';
    $extension = Path::getExtension($_FILES[$image]['name']);
    echo "The File Extension [{$extension}]<br>";
    $index = 0;
    echo "Checking File Existance<br>";
    while (file_exists(IMAGES_LOCATION . $name . "." . $extension)) {
        $name = $file_name . "_" . $index;
        $index++;
    }
    $file_name = str_replace(' ', '_', $name . "." . $extension);
    echo "The Aproved File Name [{$file_name}]<br>";
    $picture = IMAGES_LOCATION . $file_name;
    echo "Move From Upload [" . $_FILES[$image]["tmp_name"] . "] To [{$picture}]<br>";
    move_uploaded_file($_FILES[$image]["tmp_name"], $picture);
    $thum = createThum(IMAGES_LOCATION, $file_name, 100, 100);
    echo "A Thum Created At [{$thum}]<br>";
    echo "Save The Info<br>";
    $result = array(IMAGES_LOCATION_R . $file_name, IMAGES_LOCATION_R . "thum_" . $file_name);
    echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><br>";
    return $result;
}
开发者ID:Yazany6b,项目名称:php-repo,代码行数:30,代码来源:send_message.php

示例10: api_addAttachment

function api_addAttachment($blogid, $parent, $file)
{
    global $database;
    $attachment = array();
    $attachment['parent'] = $parent ? $parent : 0;
    $attachment['label'] = Path::getBaseName($file['name']);
    $label = POD::escapeString(UTF8::lessenAsEncoding($attachment['label'], 64));
    $attachment['size'] = $file['size'];
    $extension = Path::getExtension($attachment['label']);
    switch (strtolower($extension)) {
        case '.exe':
        case '.php':
        case '.sh':
        case '.com':
        case '.bat':
            $extension = '.xxx';
            break;
    }
    /* Create directory for owner */
    $path = ROOT . "/attach/{$blogid}";
    if (!is_dir($path)) {
        mkdir($path);
        if (!is_dir($path)) {
            return false;
        }
        @chmod($path, 0777);
    }
    $oldFile = POD::queryCell("SELECT name FROM {$database['prefix']}Attachments WHERE blogid={$blogid} AND parent={$parent} AND label = '{$label}'");
    if ($oldFile !== null) {
        $attachment['name'] = $oldFile;
    } else {
        $attachment['name'] = rand(1000000000, 9999999999) . $extension;
        while (Attachment::doesExist($attachment['name'])) {
            $attachment['name'] = rand(1000000000, 9999999999) . $extension;
        }
    }
    $attachment['path'] = "{$path}/{$attachment['name']}";
    deleteAttachment($blogid, -1, $attachment['name']);
    if ($file['content']) {
        $f = fopen($attachment['path'], "w");
        if (!$f) {
            return false;
        }
        $attachment['size'] = fwrite($f, $file['content']);
        fclose($f);
        $file['tmp_name'] = $attachment['path'];
    }
    if ($imageAttributes = @getimagesize($file['tmp_name'])) {
        $attachment['mime'] = $imageAttributes['mime'];
        $attachment['width'] = $imageAttributes[0];
        $attachment['height'] = $imageAttributes[1];
    } else {
        $attachment['mime'] = Misc::getMIMEType($extension);
        $attachment['width'] = 0;
        $attachment['height'] = 0;
    }
    $attachment['mime'] = UTF8::lessenAsEncoding($attachment['mime'], 32);
    @chmod($attachment['path'], 0666);
    $result = POD::query("insert into {$database['prefix']}Attachments values ({$blogid}, {$attachment['parent']}, '{$attachment['name']}', '{$label}', '{$attachment['mime']}', {$attachment['size']}, {$attachment['width']}, {$attachment['height']}, UNIX_TIMESTAMP(), 0,0)");
    if (!$result) {
        @unlink($attachment['path']);
        return false;
    }
    return $attachment;
}
开发者ID:hinablue,项目名称:TextCube,代码行数:65,代码来源:blog.api.php


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