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


PHP discuz_upload::get_target_dir方法代码示例

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


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

示例1: stream_save

function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name = '', $title = '', $delsize = 0, $from = false)
{
    global $_G, $space;
    if ($albumid < 0) {
        $albumid = 0;
    }
    $setarr = array();
    require_once libfile('class/upload');
    $upload = new discuz_upload();
    $filepath = $upload->get_target_dir('album') . $upload->get_target_filename('album') . '.' . $fileext;
    $newfilename = $_G['setting']['attachdir'] . './album/' . $filepath;
    if ($handle = fopen($newfilename, 'wb')) {
        if (fwrite($handle, $strdata) !== FALSE) {
            fclose($handle);
            $size = filesize($newfilename);
            if (empty($space)) {
                $_G['member'] = $space = getspace($_G['uid']);
                $_G['username'] = addslashes($space['username']);
            }
            $_G['member'] = $space;
            $maxspacesize = checkperm('maxspacesize');
            $maxspacesize = $maxspacesize * 1024 * 1024;
            if ($maxspacesize) {
                space_merge($space, 'common_member_count');
                space_merge($space, 'common_member_field_home');
                if ($space['attachsize'] + $size - $delsize > $maxspacesize + $space['addsize']) {
                    @unlink($newfilename);
                    return -1;
                }
            }
            if (!$upload->get_image_info($newfilename)) {
                @unlink($newfilename);
                return -2;
            }
            require_once libfile('class/image');
            $image = new image();
            $result = $image->Thumb($newfilename, NULL, 140, 140, 1);
            $thumb = empty($result) ? 0 : 1;
            $image->Watermark($newfilename);
            $pic_remote = 0;
            $album_picflag = 1;
            if (getglobal('setting/ftp/on')) {
                $ftpresult_thumb = 0;
                $ftpresult = ftpupload('album/' . $filepath);
                if ($ftpresult) {
                    if ($thumb) {
                        ftpupload('album/' . $filepath . '.thumb.jpg');
                    }
                    $pic_remote = 1;
                    $album_picflag = 2;
                } else {
                    if (getglobal('setting/ftp/mirror')) {
                        @unlink($newfilename);
                        @unlink($newfilename . '.thumb.jpg');
                        return -3;
                    }
                }
            }
            $filename = addslashes($name ? $name : substr(strrchr($filepath, '/'), 1));
            $title = getstr($title, 200, 1, 1, 1);
            if ($albumid) {
                $albumid = album_creat_by_id($albumid);
            } else {
                $albumid = 0;
            }
            $setarr = array('albumid' => $albumid, 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $_G['timestamp'], 'filename' => $filename, 'postip' => $_G['clientip'], 'title' => $title, 'type' => $fileext, 'size' => $size, 'filepath' => $filepath, 'thumb' => $thumb, 'remote' => $pic_remote);
            $setarr['picid'] = DB::insert('home_pic', $setarr, 1);
            DB::query("UPDATE " . DB::table('common_member_count') . " SET attachsize=attachsize+{$size} WHERE uid='{$_G['uid']}'");
            include_once libfile('function/stat');
            updatestat('pic');
            return $setarr;
        } else {
            fclose($handle);
        }
    }
    return -3;
}
开发者ID:Kingson4Wu,项目名称:php_demo,代码行数:77,代码来源:function_spacecp.php

示例2: dfsockopen

 }
 $content = '';
 if (preg_match('/^(http:\\/\\/|\\.)/i', $imageurl)) {
     $content = dfsockopen($imageurl);
 } elseif (preg_match('/^(' . preg_quote(getglobal('setting/attachurl'), '/') . ')/i', $imageurl)) {
     $imagereplace['newimageurl'][] = $value[0];
 }
 if (empty($content)) {
     continue;
 }
 $patharr = explode('/', $imageurl);
 $attach['name'] = trim($patharr[count($patharr) - 1]);
 $attach['thumb'] = '';
 $attach['isimage'] = $upload->is_image_ext($attach['ext']);
 $attach['extension'] = $upload->get_target_extension($attach['ext']);
 $attach['attachdir'] = $upload->get_target_dir('forum');
 $attach['attachment'] = $attach['attachdir'] . $upload->get_target_filename('forum') . '.' . $attach['extension'];
 $attach['target'] = getglobal('setting/attachdir') . './forum/' . $attach['attachment'];
 if (!@($fp = fopen($attach['target'], 'wb'))) {
     continue;
 } else {
     flock($fp, 2);
     fwrite($fp, $content);
     fclose($fp);
 }
 if (!$upload->get_image_info($attach['target'])) {
     @unlink($attach['target']);
     continue;
 }
 $attach['size'] = filesize($attach['target']);
 $upload->attach = $attach;
开发者ID:vanloswang,项目名称:DiscuzX,代码行数:31,代码来源:forum_ajax.php

示例3: stream_save

function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name = '', $title = '', $delsize = 0, $from = false)
{
    global $_G, $space;
    if ($albumid < 0) {
        $albumid = 0;
    }
    $allowPicType = array('jpg', 'jpeg', 'gif', 'png');
    if (!in_array($fileext, $allowPicType)) {
        return -3;
    }
    $setarr = array();
    $upload = new discuz_upload();
    $filepath = $upload->get_target_dir('album') . $upload->get_target_filename('album') . '.' . $fileext;
    $newfilename = $_G['setting']['attachdir'] . './album/' . $filepath;
    if ($handle = fopen($newfilename, 'wb')) {
        if (fwrite($handle, $strdata) !== FALSE) {
            fclose($handle);
            $size = filesize($newfilename);
            if (empty($space)) {
                $_G['member'] = $space = getuserbyuid($_G['uid']);
                $_G['username'] = $space['username'];
            }
            $_G['member'] = $space;
            loadcache('usergroup_' . $space['groupid']);
            $_G['group'] = $_G['cache']['usergroup_' . $space['groupid']];
            $maxspacesize = checkperm('maxspacesize');
            if ($maxspacesize) {
                space_merge($space, 'count');
                space_merge($space, 'field_home');
                if ($space['attachsize'] + $size - $delsize > $maxspacesize + $space['addsize'] * 1024 * 1024) {
                    @unlink($newfilename);
                    return -1;
                }
            }
            if (!$upload->get_image_info($newfilename)) {
                @unlink($newfilename);
                return -2;
            }
            require_once libfile('class/image');
            $image = new image();
            $result = $image->Thumb($newfilename, NULL, 140, 140, 1);
            $thumb = empty($result) ? 0 : 1;
            $image->Watermark($newfilename);
            $pic_remote = 0;
            $album_picflag = 1;
            if (getglobal('setting/ftp/on')) {
                $ftpresult_thumb = 0;
                $ftpresult = ftpcmd('upload', 'album/' . $filepath);
                if ($ftpresult) {
                    @unlink($_G['setting']['attachdir'] . 'album/' . $filepath);
                    if ($thumb) {
                        $thumbpath = getimgthumbname($filepath);
                        ftpcmd('upload', 'album/' . $thumbpath);
                        @unlink($_G['setting']['attachdir'] . 'album/' . $thumbpath);
                    }
                    $pic_remote = 1;
                    $album_picflag = 2;
                } else {
                    if (getglobal('setting/ftp/mirror')) {
                        @unlink($newfilename);
                        @unlink(getimgthumbname($newfilename));
                        return -3;
                    }
                }
            }
            $filename = $name ? $name : substr(strrchr($filepath, '/'), 1);
            $title = getstr($title, 200);
            $title = censor($title);
            if (censormod($title) || $_G['group']['allowuploadmod']) {
                $pic_status = 1;
            } else {
                $pic_status = 0;
            }
            if ($albumid) {
                $albumid = album_creat_by_id($albumid);
            } else {
                $albumid = 0;
            }
            $setarr = array('albumid' => $albumid, 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $_G['timestamp'], 'filename' => $filename, 'postip' => $_G['clientip'], 'title' => $title, 'type' => $fileext, 'size' => $size, 'filepath' => $filepath, 'thumb' => $thumb, 'remote' => $pic_remote, 'status' => $pic_status);
            $setarr['picid'] = C::t('home_pic')->insert($setarr, 1);
            C::t('common_member_count')->increase($_G['uid'], array('attachsize' => $size));
            include_once libfile('function/stat');
            updatestat('pic');
            return $setarr;
        } else {
            fclose($handle);
        }
    }
    return -3;
}
开发者ID:tianyunchong,项目名称:php,代码行数:90,代码来源:function_spacecp.php

示例4: elseif

 } elseif (checkperm('allowdownlocalimg')) {
     if (preg_match('/^data\\/(.*?)\\.thumb\\.jpg$/i', $imageurl)) {
         $content = file_get_contents(substr($imageurl, 0, strrpos($imageurl, '.') - 6));
     } elseif (preg_match('/^data\\/(.*?)\\.(jpg|jpeg|gif|png)$/i', $imageurl)) {
         $content = file_get_contents($imageurl);
     }
 }
 if (empty($content)) {
     continue;
 }
 $temp = explode('/', $imageurl);
 $attach['name'] = trim($temp[count($temp) - 1]);
 $attach['thumb'] = '';
 $attach['isimage'] = $upload->is_image_ext($attach['ext']);
 $attach['extension'] = $upload->get_target_extension($attach['ext']);
 $attach['attachdir'] = $upload->get_target_dir('portal');
 $attach['attachment'] = $attach['attachdir'] . $upload->get_target_filename('portal') . '.' . $attach['extension'];
 $attach['target'] = getglobal('setting/attachdir') . './portal/' . $attach['attachment'];
 if (!@($fp = fopen($attach['target'], 'wb'))) {
     continue;
 } else {
     flock($fp, 2);
     fwrite($fp, $content);
     fclose($fp);
 }
 if (!$upload->get_image_info($attach['target'])) {
     @unlink($attach['target']);
     continue;
 }
 $attach['size'] = filesize($attach['target']);
 $attachs[] = daddslashes($attach);
开发者ID:MCHacker,项目名称:discuz-docker,代码行数:31,代码来源:portalcp_upload.php

示例5: forum_downremotefile


//.........这里部分代码省略.........
                        $content_md5_arr[] = md5($content);
                    } elseif (preg_match('/^(' . preg_quote(getglobal('setting/attachurl'), '/') . ')/i', $imageurl)) {
                        $imagereplace['newimageurl'][] = $value[0];
                    }
                    if (empty($content)) {
                        if ($value[4] == 1) {
                            if ($del_a == 1) {
                                $imagereplace['newimageurl'][] = $value[2];
                            } else {
                                unset($imagereplace['oldimageurl'][$key]);
                            }
                        } else {
                            $imagereplace['newimageurl'][] = '';
                        }
                        continue;
                    }
                    if (!$attach['name']) {
                        $patharr = explode('/', $imageurl);
                        $attach['name'] = trim($patharr[count($patharr) - 1]);
                    }
                    $patharr = explode('/', $imageurl);
                    if (!$attach['name']) {
                        $attach['name'] = trim($patharr[count($patharr) - 1]);
                    }
                    $attach['thumb'] = '';
                    $attach['ext'] = trim($attach['ext']);
                    //不加这个有些还真不行
                    $attach['isimage'] = $upload->is_image_ext($attach['ext']);
                    if ($attach['isimage'] == 1 && $arr['is_download_img'] != 1) {
                        $imagereplace['newimageurl'][] = $value[0];
                        continue;
                    }
                    $attach['extension'] = $upload->get_target_extension($attach['ext']);
                    $attach['attachdir'] = $upload->get_target_dir('forum');
                    $attach['attachment'] = $attach['attachdir'] . $upload->get_target_filename('forum') . '.' . $attach['extension'];
                    $attach['target'] = getglobal('setting/attachdir') . './forum/' . $attach['attachment'];
                    if (!in_array($attach['ext'], $get_file_ext_arr) && $get_file_ext_arr && $attach['isimage'] == 0) {
                        if ($value[4] == 1) {
                            if ($del_a == 1) {
                                $imagereplace['newimageurl'][] = $value[2];
                            } else {
                                unset($imagereplace['oldimageurl'][$key]);
                            }
                        } else {
                            $imagereplace['newimageurl'][] = '';
                        }
                        continue;
                    }
                    if (!@($fp = fopen($attach['target'], 'wb'))) {
                        continue;
                    } else {
                        flock($fp, 2);
                        fwrite($fp, $content);
                        fclose($fp);
                    }
                    if (!$upload->get_image_info($attach['target']) && $attach['isimage'] == 1) {
                        @unlink($attach['target']);
                        continue;
                    }
                    $attach['size'] = filesize($attach['target']);
                    $upload->attach = $attach;
                    $thumb = $width = 0;
                    if ($upload->attach['isimage']) {
                        if ($_G['setting']['thumbstatus']) {
                            $image = new image();
                            $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], $_G['setting']['thumbsource']) ? 1 : 0;
开发者ID:edmundwong,项目名称:V604,代码行数:67,代码来源:function.article.php

示例6: array

 * 目前支持GD库和imagick
 * @author zhengtao
 * @param 2015 05 07
 */
$allow_pic_array = array("20_20" => array(20, 20), "30_30" => array(30, 30), "40_40" => array(40, 40), "60_60" => array(60, 60), "80_80" => array(80, 80), "88_88" => array(88, 88), "96_96" => array(96, 96), "100_100" => array(100, 100), "200_200" => array(200, 200), "300_300" => array(300, 300), "400_400" => array(400, 400), "500_500" => array(500, 500), "600_600" => array(600, 600), "700_700" => array(700, 700), "750_342" => array(750, 342), "800_800" => array(800, 800), "900_900" => array(900, 900), "1000_1000" => array(1000, 1000), "1024_1024" => array(1024, 1024), "1242_2208" => array(1242, 2208));
$hashlevel = 3;
//保存的图片的层级
$thisdir = dirname(__FILE__);
$default_pic = $thisdir . "/Image/default.png";
//默认图片的地址
$pic_url = isset($_GET['url']) ? $_GET['url'] : "";
$raw_pic_url = $pic_url;
$pic_size = isset($_GET['size']) ? $_GET['size'] : "";
$log_file = $thisdir . '/' . date("Y-m-d") . ".log";
$dzUp = new discuz_upload();
$dir2 = $dzUp->get_target_dir('common', strlen($pic_url));
$url_pathinfo = pathinfo($pic_url);
if (empty($url_pathinfo['extension'])) {
    $url_pathinfo['extension'] = 'png';
}
//判断是否是非法后缀,非法后缀则直接跳转
if (!isValidExt($pic_url)) {
    runlog('bigapp', 'invalid postfix, reject to optmize, just redirect [ url: ' . $pic_url . ' ]');
    redirect($pic_url);
}
$dir = getglobal('setting/attachdir') . './common/' . $dir2 . 'bigapp/';
//图片存储的目录
if ($pic_url != "" && array_key_exists($pic_size, $allow_pic_array)) {
    $size = $pic_size;
    $url_md5 = md5($pic_url);
    for ($i = 0; $i < $hashlevel; $i++) {
开发者ID:Mushan3420,项目名称:BigApp-PHP7,代码行数:31,代码来源:cut_pic.php


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