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


PHP Path::getBaseName方法代码示例

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


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

示例1: copyRecusive

function copyRecusive($source, $target, $chkPrint = false)
{
    if (Path::getBaseName($source) == "." || Path::getBaseName($source) == "..") {
        return;
    }
    if (!is_dir($source)) {
        copy($source, $target);
        return;
    }
    if (!file_exists($target) || !is_dir($target)) {
        mkdir($target);
        @chmod($target, 0777);
    }
    $d = dir($source);
    while ($entry = $d->read()) {
        copyRecusive("{$source}/{$entry}", "{$target}/{$entry}", $chkPrint);
    }
    $d->close();
}
开发者ID:ragi79,项目名称:Textcube,代码行数:19,代码来源:file.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: __construct

 function __construct($filename)
 {
     $context = Model_Context::getInstance();
     if (!($sval = file_get_contents($filename))) {
         Respond::ErrorPage("KeywordSkin");
     }
     $origPath = $context->getProperty('uri.service') . substr($filename, strlen(ROOT));
     $origPath = substr($origPath, 0, 0 - strlen(Path::getBaseName($origPath)));
     $sval = str_replace('./', $origPath, $sval);
     replaceSkinTag($sval, 'html');
     replaceSkinTag($sval, 'head');
     replaceSkinTag($sval, 'body');
     list($sval, $this->keylogItem) = $this->cutSkinTag($sval, 'blog_rep');
     list($sval, $this->keylog) = $this->cutSkinTag($sval, 'blog');
     $this->outter = $sval;
 }
开发者ID:webhacking,项目名称:Textcube,代码行数:16,代码来源:blogskin.php

示例4: catch

						if(isIE) 
							uploader = window.parent.document.getElementById("uploader");
						else 
							uploader = window.parent.document.getElementById("uploader2");
					} catch(e) {		
						uploader = null;	
					}
					
					if (uploader!=null) {
						uploader.SetVariable('/:openBroswer','true');
					}
				}
<?php 
if (count($_FILES) == 1) {
    $file = array_pop($_FILES);
    if (getAttachmentByLabel($blogid, $suri['id'], Path::getBaseName($file['name']))) {
        print 'alert("' . _t('동일한 이름을 가진 파일이 이미 첨부되었습니다.') . '");';
        ?>

				for( i=0; i<oSelect.options.length; i++) {
					if(oSelect.options[i].value == "<?php 
        echo escapeJSInCData($_POST['fileName']);
        ?>
") {
						oSelect.remove(i);
					}
				}
<?php 
    } else {
        if (($attachment = addAttachment($blogid, $suri['id'], $file)) === false) {
            print 'alert("' . _t('첨부하지 못했습니다.') . '");';
开发者ID:webhacking,项目名称:Textcube,代码行数:31,代码来源:index.php

示例5: KeylogSkin

 function KeylogSkin($filename)
 {
     global $service, $serviceURL;
     if (!($sval = file_get_contents($filename))) {
         Respond::ErrorPage("KeywordSkin");
     }
     $origPath = $serviceURL . substr($filename, strlen(ROOT));
     $origPath = substr($origPath, 0, 0 - strlen(Path::getBaseName($origPath)));
     $sval = str_replace('./', $origPath, $sval);
     replaceSkinTag($sval, 'html');
     replaceSkinTag($sval, 'head');
     replaceSkinTag($sval, 'body');
     list($sval, $this->keylogItem) = $this->cutSkinTag($sval, 'blog_rep');
     list($sval, $this->keylog) = $this->cutSkinTag($sval, 'blog');
     $this->outter = $sval;
 }
开发者ID:hinablue,项目名称:TextCube,代码行数:16,代码来源:blog.skin.php

示例6: setSkinSetting

function setSkinSetting($blogid, $setting)
{
    global $skinSetting;
    // Legacy global support. TODO: DELETE THIS LINE AFTER CHECK EVERY REFERENCES IN WHOLE SOURCE
    importlib('blogskin');
    $blogid = getBlogId();
    if (strncmp($context->getProperty('skin.skin'), 'customize/', 10) == 0) {
        if (strcmp($context->getProperty('skin.skin'), "customize/{$blogid}") != 0) {
            return false;
        }
    } else {
        $skinSetting['skin'] = Path::getBaseName($context->getProperty('skin.skin'));
        // Legacy global support. TODO: DELETE THIS LINE AFTER CHECK EVERY REFERENCES IN WHOLE SOURCE
        $context->setProperty('skin.skin', $skinSetting['skin']);
        if ($context->getProperty('skin.skin') === '.' || $context->getProperty('skin.skin') === '..') {
            return _t('실패 했습니다');
        }
    }
    $skinpath = getSkinPath($context->getProperty('skin.skin'));
    if (!is_dir($skinpath)) {
        return _t('실패 했습니다');
    }
    foreach ($setting as $key => $value) {
        Setting::setSkinSetting($key, $value, $blogid);
    }
    Setting::setSkinSetting('skin', $context->getProperty('skin.skin'), $blogid);
    Setting::setBlogSetting('useMicroformat', $setting['useMicroformat'], true);
    Setting::setBlogSetting('useAjaxComment', $setting['useAjaxComment'], true);
    Setting::setBlogSetting('useFOAF', $setting['useFOAF'] == 1 ? 1 : 0, true);
    Setting::setBlogSetting('entriesOnPage', $setting['entriesOnPage'], true);
    Setting::setBlogSetting('entriesOnList', $setting['entriesOnList'], true);
    CacheControl::flushCategory();
    CacheControl::flushTag();
    CacheControl::flushSkin();
    Setting::getSkinSettings($blogid, true);
    // refresh skin cache
    return true;
}
开发者ID:ni5am,项目名称:Textcube,代码行数:38,代码来源:skin.php

示例7: getAddAttachment

function getAddAttachment($file)
{
    global $database, $serviceURL;
    requireComponent('Textcube.Function.misc');
    requireComponent('Textcube.Data.Attachment');
    Attachment::confirmFolder();
    if (empty($file['name']) || $file['error'] != 0) {
        return false;
    }
    $attachment = array();
    $attachment['ext'] = Misc::getFileExtension(Path::getBaseName($file['name']));
    $path = __TEXTCUBE_ATTACH_DIR__ . "/" . getBlogId() . "/team";
    if (!is_dir($path)) {
        mkdir($path);
        if (!is_dir($path)) {
            return false;
        }
        @chmod($path, 0777);
    }
    do {
        $attachment['name'] = rand(1000000000, 9999999999.0) . "." . $attachment['ext'];
        $attachment['path'] = "{$path}/{$attachment['name']}";
    } while (file_exists($attachment['path']));
    if (!move_uploaded_file($file['tmp_name'], $attachment['path'])) {
        return false;
    }
    @chmod($attachment['path'], 0666);
    $tmpImage = POD::queryCell("SELECT image FROM {$database['prefix']}TeamUserSettings WHERE blogid=" . getBlogId() . " and userid=" . getUserId());
    if (!POD::execute("UPDATE {$database['prefix']}TeamUserSettings SET image='" . $attachment['name'] . "', updated=UNIX_TIMESTAMP() WHERE blogid=" . getBlogId() . " and userid=" . getUserId())) {
        @unlink($attachment['path']);
        $result = "{$serviceURL}/resources/image/spacer.gif";
    } else {
        $result = "{$serviceURL}/attach/" . getBlogId() . "/team/" . $attachment['name'];
    }
    if (!empty($tmpImage)) {
        @unlink($path . "/" . $tmpImage);
    }
    return $result;
}
开发者ID:ragi79,项目名称:Textcube,代码行数:39,代码来源:index.php

示例8: setSkinSetting

function setSkinSetting($blogid, $setting)
{
    global $database;
    global $skinSetting;
    requireLibrary('blog.skin');
    $blogid = getBlogId();
    if (strncmp($skinSetting['skin'], 'customize/', 10) == 0) {
        if (strcmp($skinSetting['skin'], "customize/{$blogid}") != 0) {
            return false;
        }
    } else {
        $skinSetting['skin'] = Path::getBaseName($skinSetting['skin']);
        if ($skinSetting['skin'] === '.' || $skinSetting['skin'] === '..') {
            return _t('실패 했습니다');
        }
    }
    $skinpath = ROOT . '/skin/blog/' . $skinSetting['skin'];
    if (!is_dir($skinpath)) {
        return _t('실패 했습니다');
    }
    foreach ($setting as $key => $value) {
        Setting::setSkinSetting($key, $value, $blogid);
    }
    Setting::setSkinSetting('skin', $skinSetting['skin'], $blogid);
    Setting::setBlogSetting('useMicroformat', $setting['useMicroformat'], true);
    Setting::setBlogSetting('useAjaxComment', $setting['useAjaxComment'], true);
    Setting::setBlogSetting('useFOAF', $setting['useFOAF'] == 1 ? 1 : 0, true);
    Setting::setBlogSetting('entriesOnPage', $setting['entriesOnPage'], true);
    Setting::setBlogSetting('entriesOnList', $setting['entriesOnList'], true);
    CacheControl::flushCategory();
    CacheControl::flushTag();
    CacheControl::flushSkin();
    Setting::getSkinSettings($blogid, true);
    // refresh skin cache
    return true;
}
开发者ID:hinablue,项目名称:TextCube,代码行数:36,代码来源:blog.skin.php

示例9: getAddAttachment

function getAddAttachment($file)
{
    $context = Model_Context::getInstance();
    $pool = DBModel::getInstance();
    Attachment::confirmFolder();
    if (empty($file['name']) || $file['error'] != 0) {
        return false;
    }
    $attachment = array();
    $attachment['ext'] = Utils_Misc::getFileExtension(Path::getBaseName($file['name']));
    $path = __TEXTCUBE_ATTACH_DIR__ . "/" . getBlogId() . "/team";
    if (!is_dir($path)) {
        mkdir($path);
        if (!is_dir($path)) {
            return false;
        }
        @chmod($path, 0777);
    }
    do {
        $attachment['name'] = rand(1000000000, 9999999999) . "." . $attachment['ext'];
        $attachment['path'] = "{$path}/{$attachment['name']}";
    } while (file_exists($attachment['path']));
    if (!move_uploaded_file($file['tmp_name'], $attachment['path'])) {
        return false;
    }
    @chmod($attachment['path'], 0666);
    $pool->reset("TeamUserSettings");
    $pool->setQualifier("blogid", "eq", getBlogId());
    $pool->setQualifier("userid", "eq", getUserId());
    $tmpImage = $pool->getCell("image");
    $pool->reset("TeamUserSettings");
    $pool->setAttribute("image", $attachment['name'], true);
    $pool->setAttribute("updated", Timestamp::getUNIXtime());
    $pool->setQualifier("blogid", "eq", getBlogId());
    $pool->setQualifier("userid", "eq", getUserId());
    if (!$pool->update()) {
        @unlink($attachment['path']);
        $result = $context->getProperty("uri.service") . "/resources/image/spacer.gif";
    } else {
        $result = $context->getProperty("uri.service") . "/attach/" . getBlogId() . "/team/" . $attachment['name'];
    }
    if (!empty($tmpImage)) {
        @unlink($path . "/" . $tmpImage);
    }
    return $result;
}
开发者ID:Avantians,项目名称:Textcube,代码行数:46,代码来源:index.php

示例10: addAttachment

function addAttachment($blogid, $parent, $file)
{
    $pool = DBModel::getInstance();
    if (empty($file['name']) || $file['error'] != 0) {
        return false;
    }
    $pool->reset('Attachments');
    $pool->setQualifier('blogid', 'equals', $blogid);
    $pool->setQualifier('parent', 'equals', $parent);
    $pool->setQualifier('label', 'equals', $file['name'], true);
    if ($pool->getCount() > 0) {
        return false;
    }
    $attachment = array();
    $attachment['parent'] = $parent ? $parent : 0;
    $attachment['label'] = Path::getBaseName($file['name']);
    $attachment['size'] = $file['size'];
    $extension = Utils_Misc::getFileExtension($attachment['label']);
    switch (strtolower($extension)) {
        case 'exe':
        case 'php':
        case 'sh':
        case 'com':
        case 'bat':
            $extension = 'xxx';
            break;
    }
    if (strlen($extension) > 6 || $extension == '') {
        $extension = 'xxx';
    }
    $path = __TEXTCUBE_ATTACH_DIR__ . "/{$blogid}";
    if (!is_dir($path)) {
        mkdir($path);
        if (!is_dir($path)) {
            return false;
        }
        @chmod($path, 0777);
    }
    do {
        $attachment['name'] = rand(1000000000, 9999999999) . ".{$extension}";
        $attachment['path'] = "{$path}/{$attachment['name']}";
    } while (file_exists($attachment['path']));
    if (!move_uploaded_file($file['tmp_name'], $attachment['path'])) {
        return false;
    }
    @chmod($attachment['path'], 0666);
    if ($imageAttributes = @getimagesize($attachment['path'])) {
        $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['label'] = Utils_Unicode::lessenAsEncoding($attachment['label'], 64);
    $attachment['mime'] = Utils_Unicode::lessenAsEncoding($attachment['mime'], 32);
    $pool->reset('Attachments');
    $pool->setAttribute('blogid', $blogid);
    $pool->setAttribute('parent', $attachment['parent']);
    $pool->setAttribute('name', $attachment['name'], true);
    $pool->setAttribute('label', $attachment['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,代码行数:76,代码来源:attachment.php

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