示例#1
0
文件: ftp.php 项目: noikiy/shopnc-2
/**
 * 通过FTP同步图片到远程服务器
 *
 * @param string $path 图片路径(upload/store/goods/4)
 * @param string $file 图片名称(含年月日2012/06/12/03f625d923bfb1ca84355007487ed68b.jpg)
 * @param boolean $ifdel 是否删除本地图片,目前淘宝导入的图片上传到远程时,不会删除本地图片
 * @return string 远程图片路径部分
 */
function remote_ftp($path, $file, $ifdel = true)
{
    $image_full_path = $path . '/' . $file;
    ftpcmd('upload', $image_full_path);
    $_ext = '.' . get_image_type($image_full_path);
    if (!ftpcmd('error')) {
        ftpcmd('upload', $image_full_path . '_max' . $_ext);
    }
    if (!ftpcmd('error')) {
        ftpcmd('upload', $image_full_path . '_mid' . $_ext);
    }
    if (!ftpcmd('error')) {
        ftpcmd('upload', $image_full_path . '_small' . $_ext);
    }
    if (!ftpcmd('error')) {
        ftpcmd('upload', $image_full_path . '_tiny' . $_ext);
    }
    if (!ftpcmd('error')) {
        ftpcmd('upload', $image_full_path . '_240x240' . $_ext);
    }
    if (!ftpcmd('error')) {
        if ($ifdel) {
            @unlink(BASE_PATH . '/' . $image_full_path);
            @unlink(BASE_PATH . '/' . $image_full_path . '_max' . $_ext);
            @unlink(BASE_PATH . '/' . $image_full_path . '_mid' . $_ext);
            @unlink(BASE_PATH . '/' . $image_full_path . '_small' . $_ext);
            @unlink(BASE_PATH . '/' . $image_full_path . '_tiny' . $_ext);
            @unlink(BASE_PATH . '/' . $image_full_path . '_240x240' . $_ext);
        }
        return C('ftp_access_url') . '/' . $path;
    }
    return false;
}
示例#2
0
文件: ftp.php 项目: my1977/shopnc
/**
 * 
 *
 * Framework ºËÐÄ¿ò¼Ü
 * 
 *
 * @copyright  Copyright (c) 2007-2013 ShopNC Inc. (http://www.shopnc.net)
 * @license    http://www.shopnc.net/
 * @link       http://www.shopnc.net/
 * @since      File available since Release v1.1
 */
function remote_ftp($path, $file, $ifdel = TRUE)
{
    $image_full_path = $path . "/" . $file;
    ftpcmd("upload", $image_full_path);
    $_ext = "." . get_image_type($image_full_path);
    if (!ftpcmd("error")) {
        ftpcmd("upload", $image_full_path . "_max" . $_ext);
    }
    if (!ftpcmd("error")) {
        ftpcmd("upload", $image_full_path . "_mid" . $_ext);
    }
    if (!ftpcmd("error")) {
        ftpcmd("upload", $image_full_path . "_small" . $_ext);
    }
    if (!ftpcmd("error")) {
        ftpcmd("upload", $image_full_path . "_tiny" . $_ext);
    }
    if (!ftpcmd("error")) {
        ftpcmd("upload", $image_full_path . "_240x240" . $_ext);
    }
    if (!ftpcmd("error")) {
        if ($ifdel) {
            @unlink(BasePath . "/" . $image_full_path);
            @unlink(BasePath . "/" . $image_full_path . "_max" . $_ext);
            @unlink(BasePath . "/" . $image_full_path . "_mid" . $_ext);
            @unlink(BasePath . "/" . $image_full_path . "_small" . $_ext);
            @unlink(BasePath . "/" . $image_full_path . "_tiny" . $_ext);
            @unlink(BasePath . "/" . $image_full_path . "_240x240" . $_ext);
        }
        return c("ftp_access_url") . "/" . $path;
    }
    return FALSE;
}
示例#3
0
function dunlink($attach, $havethumb = 0, $remote = 0)
{
    global $_G;
    $filename = $attach['attachment'];
    $havethumb = $attach['thumb'];
    $remote = $attach['remote'];
    $aid = $attach['aid'];
    if ($remote) {
        ftpcmd('delete', $filename);
        $havethumb && ftpcmd('delete', 'forum/' . $filename . '.thumb.jpg');
    } else {
        @unlink($_G['setting']['attachdir'] . '/' . $filename);
        $havethumb && @unlink($_G['setting']['attachdir'] . '/forum/' . $filename . '.thumb.jpg');
        @unlink(DISCUZ_ROOT . './data/attachment/image/' . $aid . '_140_140.jpg');
    }
}
示例#4
0
function dunlink($attach)
{
    global $_G;
    $filename = $attach['attachment'];
    $havethumb = $attach['thumb'];
    $remote = $attach['remote'];
    $aid = $attach['aid'];
    if ($remote) {
        ftpcmd('delete', $_G['setting']['ftp']['attachdir'] . '/forum/' . $filename);
        $havethumb && ftpcmd('delete', $_G['setting']['ftp']['attachdir'] . '/forum/' . $filename . '.thumb.jpg');
    } else {
        @unlink($_G['setting']['attachdir'] . '/forum/' . $filename);
        $havethumb && @unlink($_G['setting']['attachdir'] . '/forum/' . $filename . '.thumb.jpg');
    }
    @unlink($_G['setting']['attachdir'] . 'image/' . $aid . '_140_140.jpg');
}
示例#5
0
function dunlink($attach) {
	global $_G;
	$filename = $attach['attachment'];
	$havethumb = $attach['thumb'];
	$remote = $attach['remote'];
	if($remote) {
		ftpcmd('delete', 'forum/'.$filename);
		$havethumb && ftpcmd('delete', 'forum/'.getimgthumbname($filename));
	} else {
		@unlink($_G['setting']['attachdir'].'/forum/'.$filename);
		$havethumb && @unlink($_G['setting']['attachdir'].'/forum/'.getimgthumbname($filename));
	}
	if($attach['aid']) {
		@unlink($_G['setting']['attachdir'].'image/'.$attach['aid'].'_100_100.jpg');
	}
}
示例#6
0
文件: ftp.php 项目: noikiy/ejia
/**
 * 通过FTP同步图片到远程服务器
 *
 * @param string $path 图片路径(upload/store/goods/4)
 * @param string $file 图片名称(含年月日2012/06/12/03f625d923bfb1ca84355007487ed68b.jpg)
 * @param boolean $ifdel 是否删除本地图片,目前淘宝导入的图片上传到远程时,不会删除本地图片
 * @return string 远程图片路径部分
 */
function remote_ftp($path, $file, $ifdel = true){

	ftpcmd('upload', $path.'/'.$file);
	$img_ext = explode(',', GOODS_IMAGES_EXT);
	foreach ($img_ext as $val) {
        if(!ftpcmd('error')) ftpcmd('upload', $path.'/'.str_ireplace('.', $val . '.', $file));
	}

	if(!ftpcmd('error')) {
		if ($ifdel){
			@unlink(BASE_PATH.'/'.$path.'/'.$file);
			foreach ($img_ext as $val) {
                @unlink(BASE_PATH.'/'.$path.'/'.str_ireplace('.', $val . '.', $file));
			}
		}
		return C('ftp_access_url').'/'.$path;
	}
	return false;
}
示例#7
0
 /**
  * 删除图片
  *
  * @param string $id
  * @return bool
  */
 public function delPic($id)
 {
     $pic_list = $this->getPicList(array('in_apic_id' => $id), '', 'apic_cover');
     /**
      * 删除图片
      */
     foreach ($pic_list as $v) {
         @unlink(BasePath . DS . ATTACH_GOODS . DS . $_SESSION['store_id'] . DS . $v['apic_cover']);
         @unlink(BasePath . DS . ATTACH_GOODS . DS . $_SESSION['store_id'] . DS . $v['apic_cover'] . "_tiny." . get_image_type($v['apic_cover']));
         @unlink(BasePath . DS . ATTACH_GOODS . DS . $_SESSION['store_id'] . DS . $v['apic_cover'] . "_small." . get_image_type($v['apic_cover']));
         @unlink(BasePath . DS . ATTACH_GOODS . DS . $_SESSION['store_id'] . DS . $v['apic_cover'] . "_mid." . get_image_type($v['apic_cover']));
         @unlink(BasePath . DS . ATTACH_GOODS . DS . $_SESSION['store_id'] . DS . $v['apic_cover'] . "_max." . get_image_type($v['apic_cover']));
         @unlink(BasePath . DS . ATTACH_GOODS . DS . $_SESSION['store_id'] . DS . $v['apic_cover'] . "_240x240." . get_image_type($v['apic_cover']));
         if (C('ftp_open') && C('thumb.save_type') == 3) {
             import('function.ftp');
             $image_full_path = ATTACH_GOODS . DS . $_SESSION['store_id'] . DS . $v['apic_cover'];
             $_ext = '.' . get_image_type($image_full_path);
             if (!ftpcmd('error')) {
                 ftpcmd('delete', $image_full_path);
             }
             if (!ftpcmd('error')) {
                 ftpcmd('delete', $image_full_path . '_max' . $_ext);
             }
             if (!ftpcmd('error')) {
                 ftpcmd('delete', $image_full_path . '_mid' . $_ext);
             }
             if (!ftpcmd('error')) {
                 ftpcmd('delete', $image_full_path . '_small' . $_ext);
             }
             if (!ftpcmd('error')) {
                 ftpcmd('delete', $image_full_path . '_tiny' . $_ext);
             }
             if (!ftpcmd('error')) {
                 ftpcmd('delete', $image_full_path . '_240x240' . $_ext);
             }
         }
     }
     if (!empty($id)) {
         return Db::delete('album_pic', 'apic_id in(' . $id . ')');
     } else {
         return false;
     }
 }
function getremotefile($file)
{
    global $_G;
    @set_time_limit(0);
    if (!@readfile($_G['setting']['ftp']['attachurl'] . 'forum/' . $file)) {
        $ftp = ftpcmd('object');
        $tmpfile = @tempnam($_G['setting']['attachdir'], '');
        if ($ftp->ftp_get($tmpfile, 'forum/' . $file, FTP_BINARY)) {
            @readfile($tmpfile);
            @unlink($tmpfile);
        } else {
            @unlink($tmpfile);
            return FALSE;
        }
    }
    return TRUE;
}
示例#9
0
function setthreadcover($pid, $tid = 0, $aid = 0)
{
    global $_G;
    $cover = 0;
    if (empty($_G['uid']) || !intval($_G['setting']['forumpicstyle']['thumbwidth']) || !intval($_G['setting']['forumpicstyle']['thumbwidth'])) {
        return false;
    }
    if (($pid || $aid) && empty($tid)) {
        if ($aid) {
            $attachtable = getattachtablebyaid($aid);
            $wheresql = "aid='{$aid}' AND isimage IN ('1', '-1')";
        } else {
            $attachtable = getattachtablebypid($pid);
            $wheresql = "pid='{$pid}' AND isimage IN ('1', '-1') ORDER BY width DESC LIMIT 1";
        }
        $query = DB::query("SELECT * FROM " . DB::table($attachtable) . " WHERE {$wheresql}");
        if (!($attach = DB::fetch($query))) {
            return false;
        }
        if (empty($_G['forum']['ismoderator']) && $_G['uid'] != $attach['uid']) {
            return false;
        }
        $pid = empty($pid) ? $attach['pid'] : $pid;
        $tid = empty($tid) ? $attach['tid'] : $tid;
        $basedir = !$_G['setting']['attachdir'] ? DISCUZ_ROOT . './data/attachment/' : $_G['setting']['attachdir'];
        $coverdir = 'threadcover/' . substr(md5($tid), 0, 2) . '/' . substr(md5($tid), 2, 2) . '/';
        dmkdir($basedir . './forum/' . $coverdir);
        $picsource = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/' . $attach['attachment'];
        require_once libfile('class/image');
        $image = new image();
        if ($image->Thumb($picsource, 'forum/' . $coverdir . $tid . '.jpg', $_G['setting']['forumpicstyle']['thumbwidth'], $_G['setting']['forumpicstyle']['thumbheight'], 2)) {
            $remote = '';
            if (getglobal('setting/ftp/on')) {
                if (ftpcmd('upload', 'forum/' . $coverdir . $tid . '.jpg')) {
                    $remote = '-';
                }
            }
            $cover = DB::result_first("SELECT COUNT(*) FROM " . DB::table($attachtable) . " WHERE pid='{$pid}' AND isimage IN ('1', '-1')");
            $cover = $remote . $cover;
        } else {
            return false;
        }
    }
    if ($tid || $cover) {
        if (empty($cover)) {
            $oldcover = DB::result_first("SELECT cover FROM " . DB::table('forum_thread') . " WHERE tid='{$tid}'");
            $cover = DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($tid)) . " WHERE pid='{$pid}' AND isimage IN ('1', '-1')");
            $cover = $cover && $oldcover < 0 ? '-' . $cover : $cover;
        }
        DB::update('forum_thread', array('cover' => $cover), array('tid' => $tid));
    }
    return true;
}
示例#10
0
function setthreadcover($pid, $tid = 0, $aid = 0, $countimg = 0, $imgurl = '')
{
    global $_G;
    $cover = 0;
    if (empty($_G['uid']) || !intval($_G['setting']['forumpicstyle']['thumbheight']) || !intval($_G['setting']['forumpicstyle']['thumbwidth'])) {
        return false;
    }
    if (($pid || $aid) && empty($countimg)) {
        if (empty($imgurl)) {
            if ($aid) {
                $attachtable = 'aid:' . $aid;
                $attach = C::t('forum_attachment_n')->fetch('aid:' . $aid, $aid, array(1, -1));
            } else {
                $attachtable = 'pid:' . $pid;
                $attach = C::t('forum_attachment_n')->fetch_max_image('pid:' . $pid, 'pid', $pid);
            }
            if (!$attach) {
                return false;
            }
            if (empty($_G['forum']['ismoderator']) && $_G['uid'] != $attach['uid']) {
                return false;
            }
            $pid = empty($pid) ? $attach['pid'] : $pid;
            $tid = empty($tid) ? $attach['tid'] : $tid;
            $picsource = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/' . $attach['attachment'];
        } else {
            $attachtable = 'pid:' . $pid;
            $picsource = $imgurl;
        }
        $basedir = !$_G['setting']['attachdir'] ? DISCUZ_ROOT . './data/attachment/' : $_G['setting']['attachdir'];
        $coverdir = 'threadcover/' . substr(md5($tid), 0, 2) . '/' . substr(md5($tid), 2, 2) . '/';
        dmkdir($basedir . './forum/' . $coverdir);
        require_once libfile('class/image');
        $image = new image();
        if ($image->Thumb($picsource, 'forum/' . $coverdir . $tid . '.jpg', $_G['setting']['forumpicstyle']['thumbwidth'], $_G['setting']['forumpicstyle']['thumbheight'], 2)) {
            $remote = '';
            if (getglobal('setting/ftp/on')) {
                if (ftpcmd('upload', 'forum/' . $coverdir . $tid . '.jpg')) {
                    $remote = '-';
                }
            }
            $cover = C::t('forum_attachment_n')->count_image_by_id($attachtable, 'pid', $pid);
            if ($imgurl && empty($cover)) {
                $cover = 1;
            }
            $cover = $remote . $cover;
        } else {
            return false;
        }
    }
    if ($countimg) {
        if (empty($cover)) {
            $thread = C::t('forum_thread')->fetch($tid);
            $oldcover = $thread['cover'];
            $cover = C::t('forum_attachment_n')->count_image_by_id('tid:' . $tid, 'pid', $pid);
            if ($cover) {
                $cover = $oldcover < 0 ? '-' . $cover : $cover;
            }
        }
    }
    if ($cover) {
        C::t('forum_thread')->update($tid, array('cover' => $cover));
        return true;
    }
}
示例#11
0
function block_delete_pic($bid, $itemid = array())
{
    global $_G;
    if (!empty($bid)) {
        if (!is_array($bid)) {
            $bid = array($bid);
        }
        $where = ' bid IN (' . dimplode($bid) . ')';
        if ($itemid && !is_array($itemid)) {
            $itemid = array($itemid);
        }
        $where .= !empty($itemid) ? ' AND itemid IN (' . dimplode($itemid) . ')' : '';
        $picids = array();
        $query = DB::query('SELECT picid, pic, picflag FROM ' . DB::table('common_block_pic') . " WHERE {$where}");
        while ($value = DB::fetch($query)) {
            $picids[$value['picid']] = $value['picid'];
            if ($value['picflag']) {
                ftpcmd('delete', $value['pic']);
            } else {
                @unlink($_G['setting']['attachdir'] . '/' . $value['pic']);
            }
        }
        if (!empty($picids)) {
            DB::delete('common_block_pic', 'picid IN(' . dimplode($picids) . ')');
        }
    }
}
示例#12
0
 function DoAddADV()
 {
     $html = '';
     $location = jget('location', 'trim');
     $adid = jget('adid', 'int');
     if ($adid) {
         $sql = " select * from `" . TABLE_PREFIX . "ad` where `adid` = '{$adid}' ";
         $ad_info = DB::fetch_first($sql);
         $ad_info || $this->Messager("您要修改的广告不存在或已删除。", -1);
     }
     $location || $ad_info['location'] || $this->Messager("这个是哪里的广告位?", 'admin.php?mod=income');
     $title = jget('title', 'trim');
     if (!$title) {
         $this->Messager("请输入广告标题", -1);
     }
     $hcode = jget('hcode');
     if (count($hcode['page']) < 1) {
         $this->Messager("广告投放范围必须要有哦", -1);
     }
     $ftime = jget('ftime', 'trim');
     if ($ftime) {
         $ftime = strtotime($ftime);
     }
     $ttime = jget('ttime', 'trim');
     if ($ttime) {
         $ttime = strtotime($ttime);
     }
     $type = jget('type', 'int');
     switch ($type) {
         case 1:
             #代码
             if (!$hcode['html']) {
                 $this->Messager("广告HTML代码必须要有哦", -1);
             }
             $html = $hcode['html'];
             break;
         case 2:
             #文字
             if (!$hcode['word']) {
                 $this->Messager("文字内容必须要有哦", -1);
             }
             if (!$hcode['word_url']) {
                 $this->Messager("文字链接必须要有哦", -1);
             }
             if ($hcode['word_size']) {
                 $word_size = 'style="font-size:' . $hcode['word_size'] . 'px"';
             }
             $html = '<a href="' . $hcode['word_url'] . '" target="_blank"><span ' . $word_size . '>' . $hcode['word'] . '</span></a>';
             break;
         case 3:
             #图片
             if ($_FILES['image']['name']) {
                 $name = time() . MEMBER_ID;
                 $image_name = $name . ".jpg";
                 $image_path = RELATIVE_ROOT_PATH . 'images/ad/';
                 $image_file = $image_path . $image_name;
                 if (!is_dir($image_path)) {
                     jio()->MakeDir($image_path);
                 }
                 jupload()->init($image_path, 'image', true);
                 jupload()->setNewName($image_name);
                 $result = jupload()->doUpload();
                 if ($result) {
                     $result = is_image($image_file);
                 }
                 if (!$result) {
                     unlink($image_file);
                     $this->Messager("图片上传失败。", -1);
                 }
                 if ($this->Config['ftp_on']) {
                     $ftp_key = randgetftp();
                     $get_ftps = jconf::get('ftp');
                     $site_url = $get_ftps[$ftp_key]['attachurl'];
                     $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key);
                     if ($ftp_result > 0) {
                         jio()->DeleteFile($image_file);
                         $image_file = $site_url . '/' . str_replace('./', '', $image_file);
                     }
                 }
                 $hcode['image'] = $image_file;
             } else {
                 if (!$adid) {
                     $this->Messager("图片必须要有哦", -1);
                 } else {
                     $un_hcode = unserialize(base64_decode($ad_info['hcode']));
                     $hcode['image'] = $un_hcode['image'];
                 }
             }
             $hcode['pic_url'] || $this->Messager("图片链接必须要有哦", -1);
             $image_width_html = $hcode['pic_width'] ? ' width=' . $hcode['pic_width'] : '';
             $image_height_html = $hcode['pic_height'] ? ' height= ' . $hcode['pic_height'] : '';
             $html = '<a href="' . $hcode[pic_url] . '" target="_blank" title="' . $hcode['pic_title'] . '"><img src="' . $hcode['image'] . '" ' . $image_width_html . $image_height_html . '></a>';
             break;
         default:
             $this->Messager("展现方式必须要有哦", -1);
             break;
     }
     $ser_hcode = base64_encode(serialize($hcode));
     #保存到数据库
     $data = array('location' => $location, 'title' => $title, 'type' => $type, 'ftime' => $ftime, 'ttime' => $ttime, 'hcode' => $ser_hcode);
     if ($adid) {
         DB::update('ad', $data, " `adid` = '{$adid}' ");
     } else {
         $adid = DB::insert('ad', $data, true);
     }
     #保存到本地
     $ad = jconf::get('ad');
     if ($un_hcode['page']) {
         foreach ($un_hcode['page'] as $k => $v) {
             if (isset($ad['ad_list'][$v][$location][$adid]) && is_array($ad['ad_list'][$v][$location][$adid])) {
                 unset($ad['ad_list'][$v][$location][$adid]);
             }
         }
     }
     $AdLocationList = $this->AdLocationList();
     $ad_localtions = $AdLocationList[$location]['page'];
     if (isset($ad_localtions['width'])) {
         unset($ad_localtions['width']);
     }
     $unset_ad_pages = array_diff(array_keys($ad_localtions), $hcode['page']);
     if (is_array($unset_ad_pages) && count($unset_ad_pages) > 0) {
         foreach ($unset_ad_pages as $page) {
             if (isset($ad['ad_list'][$page]) && isset($ad['ad_list'][$page][$location]) && isset($ad['ad_list'][$page][$location][$adid]) && is_array($ad['ad_list'][$page][$location][$adid]) && $ad['ad_list'][$page][$location][$adid]) {
                 unset($ad['ad_list'][$page][$location][$adid]);
             }
             if ($ad['ad_list'][$page]) {
                 $ad['ad_list'][$page] = array_filter($ad['ad_list'][$page]);
             }
         }
         $ad['ad_list'] = array_filter($ad['ad_list']);
     }
     $ad['enable'] = 1;
     foreach ($hcode['page'] as $k => $v) {
         if (!is_array($ad['ad_list'][$v][$location])) {
             $ad['ad_list'][$v][$location] = array();
         }
         if (!is_array($ad['ad_list'][$v][$location][$adid])) {
             $ad['ad_list'][$v][$location][$adid] = array();
         }
         $ad['ad_list'][$v][$location][$adid]['html'] = $html;
         $ad['ad_list'][$v][$location][$adid]['ftime'] = $ftime;
         $ad['ad_list'][$v][$location][$adid]['ttime'] = $ttime;
     }
     jconf::set('ad', $ad);
     $this->Messager('设置成功', 'admin.php?mod=income&code=ad_list&op=' . $location);
 }
示例#13
0
 function onloadPic()
 {
     if (!$this->MemberHandler->HasPermission($this->Module, 'create')) {
         js_alert_showmsg($this->MemberHandler->GetError());
     }
     if ('admin' != MEMBER_ROLE_TYPE) {
         $is_allowed = jlogic('event')->allowedCreate(MEMBER_ID, $this->Member);
         if ($is_allowed) {
             js_alert_showmsg($is_allowed);
         }
     }
     if ($_FILES['pic']['name']) {
         $name = time() . MEMBER_ID;
         $image_name = $name . "_b.jpg";
         $image_path = RELATIVE_ROOT_PATH . 'images/event/';
         $image_file = $image_path . $image_name;
         $image_name_show = $name . "_s.jpg";
         $image_file_min = $image_path . $image_name_show;
         if (!is_dir($image_path)) {
             jio()->MakeDir($image_path);
         }
         jupload()->init($image_path, 'pic', true);
         jupload()->setNewName($image_name);
         $result = jupload()->doUpload();
         if ($result) {
             $result = is_image($image_file);
         }
         if (!$result) {
             unlink($image_file);
             unlink($image_file_min);
             echo "<script language='Javascript'>";
             echo "parent.document.getElementById('message').style.display='block';";
             echo "parent.document.getElementById('uploading').style.display='none';";
             if ($this->Post['top'] == 'top') {
                 echo "parent.document.getElementById('back1').style.display='block';";
                 echo "parent.document.getElementById('next3').style.display='block';";
             }
             echo "parent.document.getElementById('message').innerHTML='图片上载失败'";
             echo "</script>";
             exit;
         }
         makethumb($image_file, $image_file_min, 60, 60, 0, 0, 0, 0, 0, 0);
         image_thumb($image_file, $image_file, 100, 128, 1, 0, 0);
         if ($this->Config['watermark_enable']) {
             jlogic('image')->watermark($image_file);
         }
         if ($this->Config['ftp_on']) {
             $ftp_key = randgetftp();
             $get_ftps = jconf::get('ftp');
             $site_url = $get_ftps[$ftp_key]['attachurl'];
             $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key);
             if ($ftp_result > 0) {
                 ftpcmd('upload', $image_file_min, '', $ftp_key);
                 jio()->DeleteFile($image_file);
                 jio()->DeleteFile($image_file_min);
                 $image_file = $site_url . '/' . str_replace('./', '', $image_file);
             }
         }
         $hid_pic = $this->Post['hid_pic'];
         $eid = (int) $this->Post['id'];
         $this->doUnlink($hid_pic, $eid);
         echo "<script language='Javascript'>";
         echo "parent.document.getElementById('uploading').style.display='none';";
         if ($this->Post['top'] == 'top') {
             echo "parent.document.getElementById('back1').style.display='block';";
             echo "parent.document.getElementById('next3').style.display='block';";
         }
         echo "parent.document.getElementById('message').style.display='none';";
         echo "parent.document.getElementById('img').style.display='block';";
         echo "parent.document.getElementById('showimg').src='{$image_file}';";
         echo "parent.document.getElementById('hid_pic').value='{$image_file}';";
         echo "</script>";
         exit;
     }
 }
示例#14
0
 function Upload()
 {
     $image_id = 0;
     $field = 'topic';
     if (empty($_FILES) || !$_FILES[$field]['name']) {
         return 0;
     } else {
         $timestamp = time();
         $uid = $this->Post['touid'] ? $this->Post['touid'] : MEMBER_ID;
         $username = $this->Post['tousername'] ? $this->Post['tousername'] : MEMBER_NAME;
         $image_id = jlogic('image')->add($uid, $username);
         if ($image_id < 1) {
             return 0;
         }
         $sub_path = './images/' . $field . '/' . face_path($image_id);
         $image_path = RELATIVE_ROOT_PATH . $sub_path;
         $image_path_abs = ROOT_PATH . $sub_path;
         $image_path2 = './images/' . $field . '/' . face_path($image_id);
         $image_name = $image_id . "_o.jpg";
         $image_file = $image_path . $image_name;
         $image_file_abs = $image_path_abs . $image_name;
         $image_file2 = $image_path2 . $image_name;
         $image_file_small = $image_path . $image_id . "_s.jpg";
         $image_file_small_abs = $image_path_abs . $image_id . "_s.jpg";
         if (!is_dir($image_path_abs)) {
             jio()->MakeDir($image_path_abs);
         }
         jupload()->init($image_path_abs, $field, true);
         jupload()->setNewName($image_name);
         $result = jupload()->doUpload();
         if ($result) {
             $result = is_image($image_file_abs);
         }
         if (false == $result) {
             jio()->DeleteFile($image_file_abs);
             jlogic('image')->delete($image_id);
             $error_msg = implode(" ", (array) jupload()->getError());
         } else {
             $this->_removeTopicImage($image_id);
             list($image_width, $image_height, $image_type, $image_attr) = getimagesize($image_file_abs);
             $result = makethumb($image_file_abs, $image_file_small_abs, min($this->Config['thumbwidth'], $image_width), min($this->Config['thumbwidth'], $image_height), $this->Config['maxthumbwidth'], $this->Config['maxthumbheight']);
             if (!$result && !is_file($image_file_small_abs)) {
                 @copy($image_file_abs, $image_file_small_abs);
             }
             if ($this->Config['watermark_enable']) {
                 jlogic('image')->watermark($image_file_abs);
             }
             $image_size = filesize($image_file_abs);
             $name = addslashes($_FILES[$field]['name']);
             $site_url = '';
             if ($this->Config['ftp_on']) {
                 $ftp_key = randgetftp();
                 $get_ftps = jconf::get('ftp');
                 $site_url = $get_ftps[$ftp_key]['attachurl'];
                 $ftp_result = ftpcmd('upload', $image_file_abs, '', $ftp_key);
                 if ($ftp_result > 0) {
                     ftpcmd('upload', $image_file_small_abs, '', $ftp_key);
                     jio()->DeleteFile($image_file_abs);
                     jio()->DeleteFile($image_file_small_abs);
                     $image_file_small = $site_url . '/' . $image_file_small;
                 }
             }
             jlogic('image')->modify(array('id' => $image_id, 'site_url' => $site_url, 'photo' => $image_file2, 'name' => $name, 'filesize' => $image_size, 'width' => $image_width, 'height' => $image_height));
         }
     }
     return $image_id;
 }
示例#15
0
 function _parse_url_attach($data, $attach_url)
 {
     $__is_attach = false;
     $uid = $data['uid'];
     $username = $data['username'];
     $attach_id = jlogic('attach')->add($uid, $username);
     $p = array('id' => $attach_id, 'tid' => $data['tid'], 'file_url' => $attach_url);
     jlogic('attach')->modify($p);
     $attach_path = RELATIVE_ROOT_PATH . 'data/attachs/topic/' . face_path($attach_id) . '/';
     $attach_type = strtolower(end(explode('.', $attach_url)));
     $attach_name = $attach_id . '.' . $attach_type;
     $attach_file = $attach_path . $attach_name;
     if (!is_file($attach_file)) {
         if (!is_dir($attach_path)) {
             jio()->MakeDir($attach_path);
         }
         if (($temp_attach = dfopen($attach_url)) && jio()->WriteFile($attach_file, $temp_attach) && is_attach($attach_file)) {
             $attach_size = filesize($attach_file);
             $site_url = '';
             if ($GLOBALS['_J']['config']['ftp_on']) {
                 $ftp_key = randgetftp();
                 $get_ftps = jconf::get('ftp');
                 $site_url = $get_ftps[$ftp_key]['attachurl'];
                 $ftp_result = ftpcmd('upload', $attach_file, '', $ftp_key);
             }
             $p = array('id' => $attach_id, 'vtid' => $data['id'], 'site_url' => $site_url, 'file' => $attach_file, 'name' => basename($attach_url), 'filesize' => $attach_size, 'filetype' => $attach_type);
             jlogic('attach')->modify($p);
             $__is_attach = true;
         }
     }
     if (false === $__is_attach && $attach_id > 0) {
         jlogic('attach')->delete($attach_id);
         $attach_id = 0;
     }
     return $attach_id;
 }
示例#16
0
        $settingnew['ftp']['attachurl'] .= substr($settingnew['ftp']['attachurl'], -1, 1) != '/' ? '/' : '';
        $_G['setting']['ftp'] = $settingnew['ftp'];
        ftpcmd('upload', $testfile);
        $ftp = ftpcmd('object');
        if (ftpcmd('error')) {
            $alertmsg = cplang('setting_attach_remote_' . ftpcmd('error'));
        }
        if (!$alertmsg) {
            $str = getremotefile($_G['setting']['ftp']['attachurl'] . $testfile);
            if ($str !== $testcontent) {
                $alertmsg = cplang('setting_attach_remote_geterr');
            }
        }
        if (!$alertmsg) {
            ftpcmd('delete', $testfile);
            ftpcmd('delete', 'test/index.htm');
            $ftp->ftp_rmdir('test');
            $str = getremotefile($_G['setting']['ftp']['attachurl'] . $testfile);
            if ($str === $testcontent) {
                $alertmsg = cplang('setting_attach_remote_delerr');
            }
            @unlink($attach_dir . '/' . $testfile);
            @rmdir($attach_dir . 'test');
        }
    }
    if (!$alertmsg) {
        $alertmsg = cplang('setting_attach_remote_ok');
    }
    echo '<script language="javascript">alert(\'' . str_replace('\'', '\\\'', $alertmsg) . '\');parent.$(\'cpform\').action=\'' . ADMINSCRIPT . '?action=setting&edit=yes\';parent.$(\'cpform\').target=\'_self\'</script>';
} elseif ($operation == 'mailcheck') {
    $oldmail = dunserialize($_G['setting']['mail']);
示例#17
0
     $upload->save();
 }
 if ($upload->error()) {
     $errorcode = 4;
 }
 if (!$errorcode) {
     if ($attach['isimage'] && empty($_G['setting']['portalarticleimgthumbclosed'])) {
         require_once libfile('class/image');
         $image = new image();
         $thumbimgwidth = $_G['setting']['portalarticleimgthumbwidth'] ? $_G['setting']['portalarticleimgthumbwidth'] : 300;
         $thumbimgheight = $_G['setting']['portalarticleimgthumbheight'] ? $_G['setting']['portalarticleimgthumbheight'] : 300;
         $attach['thumb'] = $image->Thumb($attach['target'], '', $thumbimgwidth, $thumbimgheight, 2);
         $image->Watermark($attach['target'], '', 'portal');
     }
     if (getglobal('setting/ftp/on') && (!$_G['setting']['ftp']['allowedexts'] && !$_G['setting']['ftp']['disallowedexts'] || $_G['setting']['ftp']['allowedexts'] && in_array($attach['ext'], $_G['setting']['ftp']['allowedexts']) || $_G['setting']['ftp']['disallowedexts'] && !in_array($attach['ext'], $_G['setting']['ftp']['disallowedexts'])) && (!$_G['setting']['ftp']['minsize'] || $attach['size'] >= $_G['setting']['ftp']['minsize'] * 1024)) {
         if (ftpcmd('upload', 'portal/' . $attach['attachment']) && (!$attach['thumb'] || ftpcmd('upload', 'portal/' . getimgthumbname($attach['attachment'])))) {
             @unlink($_G['setting']['attachdir'] . '/portal/' . $attach['attachment']);
             @unlink($_G['setting']['attachdir'] . '/portal/' . getimgthumbname($attach['attachment']));
             $attach['remote'] = 1;
         } else {
             if (getglobal('setting/ftp/mirror')) {
                 @unlink($attach['target']);
                 @unlink(getimgthumbname($attach['target']));
                 $errorcode = 5;
             }
         }
     }
     $setarr = array('uid' => $_G['uid'], 'filename' => $attach['name'], 'attachment' => $attach['attachment'], 'filesize' => $attach['size'], 'isimage' => $attach['isimage'], 'thumb' => $attach['thumb'], 'remote' => $attach['remote'], 'filetype' => $attach['extension'], 'dateline' => $_G['timestamp'], 'aid' => $aid);
     $setarr['attachid'] = C::t('portal_attachment')->insert($setarr, true);
     if ($attach['isimage']) {
         require_once libfile('function/home');
示例#18
0
 function ModAttach()
 {
     if ($this->MemberHandler->HasPermission($this->Module, 'attach') == false) {
         $this->_mod_attach_error('您没有上传文件的权限,无法继续操作!');
     }
     $id = max(0, (int) $this->Post['id']);
     if ($id < 1) {
         $this->_mod_attach_error('附件ID 错误');
     }
     $attach_info = $this->AttachLogic->get_info($id);
     if (!$attach_info) {
         $this->_mod_attach_error('您要更新的附件已经不存在了');
     }
     if (MEMBER_ROLE_TYPE != 'admin') {
         if (MEMBER_ID != $attach_info['uid']) {
             $this->_mod_attach_error('您没有权限更新该附件');
         }
     }
     if (empty($_FILES) || !$_FILES['mafile']['name']) {
         $this->_mod_attach_error('没有文件上传');
     }
     $attach_size = min(is_numeric($this->Config['attach_size_limit']) ? $this->Config['attach_size_limit'] : 1024, 51200);
     $attach_path = str_replace($id . '.' . $attach_info['filetype'], '', $attach_info['file']);
     $attach_type = strtolower(end(explode('.', $_FILES['mafile']['name'])));
     $attach_name = $id . '.' . $attach_type;
     $attach_file = $attach_path . $attach_name;
     if (!is_dir($attach_path)) {
         jio()->MakeDir($attach_path);
     }
     jupload()->init($attach_path, 'mafile', false, true);
     jupload()->setMaxSize($attach_size);
     jupload()->setNewName($attach_name);
     $ret = jupload()->doUpload();
     if ($ret) {
         $ret = true;
     }
     if (!$ret) {
         jio()->DeleteFile($attach_file);
         $rets = jupload()->getError();
         $ret = $rets ? implode(" ", (array) $rets) : 'attach file is invalid';
         $this->_mod_attach_error($ret);
     }
     $site_url = '';
     if ($this->Config['ftp_on']) {
         $ftp_key = randgetftp();
         $get_ftps = jconf::get('ftp');
         $site_url = $get_ftps[$ftp_key]['attachurl'];
         $ftp_result = ftpcmd('upload', $attach_file, '', $ftp_key);
         if ($ftp_result > 0) {
             jio()->DeleteFile($attach_file);
         }
     }
     $attach_size = filesize($attach_file);
     $name = addslashes($_FILES['mafile']['name']);
     $p = array('id' => $id, 'site_url' => $site_url, 'file' => $attach_file, 'name' => $name, 'filetype' => $attach_type, 'filesize' => $attach_size);
     $this->AttachLogic->modify($p);
     $retval = array('src' => 'images/filetype/' . $attach_type . '.gif', 'name' => $name, 'size' => $attach_size > 1024 * 1024 ? round($attach_size / (1024 * 1024), 2) . 'MB' : ($attach_size == 0 ? '未知' : round($attach_size / 1024, 1) . 'KB'));
     echo "<script type='text/javascript'>window.parent.aupcomplete({$id},'{$retval['src']}','{$retval['name']}','{$retval['size']}');</script>";
 }
示例#19
0
function block_delete_pic($bid, $itemid = array())
{
    global $_G;
    if (!empty($bid)) {
        $picids = array();
        foreach (C::t('common_block_pic')->fetch_all_by_bid_itemid($bid, $itemid) as $value) {
            $picids[$value['picid']] = $value['picid'];
            if ($value['picflag']) {
                ftpcmd('delete', $value['pic']);
            } else {
                @unlink($_G['setting']['attachdir'] . '/' . $value['pic']);
            }
        }
        if (!empty($picids)) {
            C::t('common_block_pic')->delete($picids);
        }
    }
}
示例#20
0
 function upload($p)
 {
     $sys_config = jconf::get();
     if (!$_FILES[$p['field']] || !$_FILES[$p['field']]['name']) {
         return array('error' => 'attach is empty', 'code' => -1);
     }
     $itemid = is_numeric($p['itemid']) ? $p['itemid'] : 0;
     $item = '';
     if ($itemid > 0) {
         $item = $p['item'];
     }
     $uid = (int) ($p['uid'] ? $p['uid'] : MEMBER_ID);
     if ($uid < 1 || false == ($member_info = jsg_member_info($uid))) {
         return array('error' => 'uid is invalid', 'code' => -2);
     }
     $_FILES[$p['field']]['name'] = get_safe_code($_FILES[$p['field']]['name']);
     $att_id = $this->add($uid, $member_info['nickname'], $item, $itemid);
     if ($att_id < 1) {
         return array('error' => 'write database is invalid', 'code' => -3);
     }
     $filetype = end(explode('.', $_FILES[$p['field']]['name']));
     $att_name = $att_id . '.' . $filetype;
     $att_path = RELATIVE_ROOT_PATH . 'data/attachs/topic/' . face_path($att_id);
     $att_file = $att_path . $att_name;
     if (!is_dir($att_path)) {
         jio()->MakeDir($att_path);
     }
     jupload()->init($att_path, $p['field'], false, true);
     jupload()->setMaxSize($sys_config['attach_size_limit']);
     jupload()->setNewName($att_name);
     $ret = jupload()->doUpload();
     if (!$ret) {
         $this->delete($att_id);
         $rets = jupload()->getError();
         $ret = $rets ? implode(" ", (array) $rets) : 'image upload is invalid';
         return array('error' => $ret, 'code' => -5);
     }
     $site_url = '';
     if ($sys_config['ftp_on']) {
         $ftp_key = randgetftp();
         $get_ftps = jconf::get('ftp');
         $site_url = $get_ftps[$ftp_key]['attachurl'];
         $ftp_result = ftpcmd('upload', $att_file, '', $ftp_key);
         if ($ftp_result > 0) {
             jio()->DeleteFile($att_file);
             $att_file = $site_url . '/' . str_replace('./', '', $att_file);
         }
     }
     $att_size = filesize($att_file);
     $p = array('id' => $att_id, 'site_url' => $site_url, 'photo' => $att_file, 'name' => $_FILES[$p['field']]['name'], 'filesize' => $att_size, 'filetype' => $filetype, 'tid' => max(0, (int) $p['tid']), 'uid' => $uid, 'username' => $member_info['nickname'], 'dateline' => (int) time());
     $this->modify($p);
     return $p;
 }
示例#21
0
 /**
  * 删除图片文件
  * 
  */
 private function del_file($filename)
 {
     //取店铺ID
     if (preg_match('/^(\\d+_)/', $filename)) {
         $store_id = substr($filename, 0, strpos($filename, '_'));
     } else {
         $store_id = Model()->cls()->table('album_pic')->getfby_apic_cover($filename, 'store_id');
     }
     $path = BasePath . '/' . ATTACH_GOODS . '/' . $store_id . '/' . $filename;
     $ext = strrchr($path, '.');
     $type = array('_tiny', '_small', '_mid', '_max', '_240x240');
     foreach ($type as $v) {
         if (is_file($fpath = $path . $v . $ext)) {
             unlink($fpath);
         }
     }
     if (is_file($path)) {
         unlink($path);
     }
     if (C('ftp_open') && C('thumb.save_type') == 3) {
         import('function.ftp');
         $image_full_path = ATTACH_GOODS . '/' . $store_id . '/' . $filename;
         if (!ftpcmd('error')) {
             ftpcmd('delete', $image_full_path);
         }
         if (!ftpcmd('error')) {
             ftpcmd('delete', $image_full_path . '_max' . $ext);
         }
         if (!ftpcmd('error')) {
             ftpcmd('delete', $image_full_path . '_mid' . $ext);
         }
         if (!ftpcmd('error')) {
             ftpcmd('delete', $image_full_path . '_small' . $ext);
         }
         if (!ftpcmd('error')) {
             ftpcmd('delete', $image_full_path . '_tiny' . $ext);
         }
         if (!ftpcmd('error')) {
             ftpcmd('delete', $image_full_path . '_240x240' . $ext);
         }
     }
 }
示例#22
0
文件: setting.php 项目: noikiy/ecmall
 public function ftp_testOp()
 {
     /**
      * 读取语言包
      */
     $lang = Language::getLangContent();
     $message = '';
     $testcontent = md5('ShopNC' . MD5_KEY . time());
     $testfile = 'test/shopnc_test.txt';
     $attach_dir = BasePath . '/upload';
     @mkdir($attach_dir . '/test', 0777);
     if ($fp = @fopen($attach_dir . '/' . $testfile, 'w')) {
         fwrite($fp, $testcontent);
         fclose($fp);
     }
     import('function.ftp');
     if (!$message) {
         $GLOBALS['setting_config']['ftp_open'] = 1;
         $GLOBALS['setting_config']['ftp_server'] = $_POST['ftp_server'];
         $GLOBALS['setting_config']['ftp_ssl_state'] = $_POST['ftp_ssl_state'];
         $GLOBALS['setting_config']['ftp_port'] = $_POST['ftp_port'];
         $GLOBALS['setting_config']['ftp_username'] = $_POST['ftp_username'];
         $GLOBALS['setting_config']['ftp_password'] = $_POST['ftp_password'];
         $GLOBALS['setting_config']['ftp_pasv'] = $_POST['ftp_pasv'];
         $GLOBALS['setting_config']['ftp_attach_dir'] = $_POST['ftp_attach_dir'];
         $GLOBALS['setting_config']['ftp_access_url'] = $_POST['ftp_access_url'];
         $GLOBALS['setting_config']['ftp_timeout'] = $_POST['ftp_timeout'];
         ftpcmd('upload', 'upload/' . $testfile);
         $ftp = ftpcmd('object');
         if (ftpcmd('error')) {
             $message = $lang['ftp_error_' . ftpcmd('error')];
         }
         if (!$message) {
             $str = getremotefile(C('ftp_access_url') . '/upload/' . $testfile);
             if ($str !== $testcontent) {
                 $message = $lang['ftp_error_geterr'];
             }
         }
         if (!$message) {
             ftpcmd('delete', $testfile);
             ftpcmd('delete', 'test/index.html');
             $ftp->ftp_rmdir('test');
             $str = getremotefile(C('ftp_attach_dir') . '/' . $testfile);
             if ($str === $testcontent) {
                 $message = $lang['ftp_error_delerr'];
             }
             @unlink($attach_dir . '/' . $testfile);
             @rmdir($attach_dir . 'test');
         }
     }
     if (!$message) {
         $message = $lang['ftp_test_ok'];
     }
     if (strtoupper(CHARSET) == 'GBK') {
         $message = Language::getUTF8($message);
     }
     showMessage($message, '', 'json');
 }
示例#23
0
    $attach = $upload->attach;
    if (!$upload->error()) {
        $upload->save();
    }
    if ($upload->error()) {
        topic_upload_error($attach, $upload->error());
    } else {
        if ($attach['isimage']) {
            require_once libfile('class/image');
            $image = new image();
            $attach['thumb'] = $image->Thumb($attach['target'], '', '80', '50');
        }
        if (getglobal('setting/ftp/on')) {
            if (ftpcmd('upload', 'portal/' . $attach['attachment'])) {
                if ($attach['thumb']) {
                    ftpcmd('upload', 'portal/' . getimgthumbname($attach['attachment']));
                }
                $attach['remote'] = 1;
            } else {
                if (getglobal('setting/ftp/mirror')) {
                    @unlink($attach['target']);
                    @unlink(getimgthumbname($attach['target']));
                    topic_upload_error($attach, 'diy_remote_upload_failed');
                }
            }
        }
        $setarr = array('uid' => $_G['uid'], 'username' => $_G['username'], 'filename' => $attach['name'], 'filepath' => $attach['attachment'], 'size' => $attach['size'], 'thumb' => $attach['thumb'], 'remote' => $attach['remote'], 'dateline' => $_G['timestamp'], 'topicid' => $topicid);
        $setarr['picid'] = C::t('portal_topic_pic')->insert($setarr, true);
        topic_upload_show($topicid);
    }
} elseif (submitcheck('diysubmit')) {
示例#24
0
</table></center></form><?php 
}
$act = @$_GET['act'];
if ($act == 'add') {
    setcookie('ftpuser', $_POST['user']);
    setcookie('ftppass', $_POST['pass']);
    setcookie('ftpport', $_POST['port']);
    $dir = str_replace('\\', '/', $_POST['dir']);
    echo '<center><p></p><p></p><p></p><B>命令回显:</b><b>点击进入第二步执行命令<a href="?act=do"><font color="red">Go Execute</font></a></b><br /><textarea  cols="80" rows="15" readonly>' . "\r\n";
    up($_POST['port'], $_POST['user'], $_POST['pass'], $dir, $_POST['suser'], $_POST['spass'], $_POST['sport']);
    echo '</textarea><br/><b>点击进入第二步执行命令<a href="?act=do"><font color="red">Go Execute</font></a></b></center>';
}
if ($act == 'Execute') {
    $path = str_replace('\\', '/', $_POST['path']);
    echo '<center><p></p><p></p><p></p><B>命令回显:</b><br /><textarea  cols="80" rows="15" readonly>' . "\r\n";
    ftpcmd($_POST['port'], $_POST['user'], $_POST['pass'], $_POST['cmd'], $path);
    echo '</textarea></center>';
}
if ($_POST['subfile']) {
    $upfile = $_POST['p'] . $_FILES['file']['name'];
    if (is_uploaded_file($_FILES['file']['tmp_name'])) {
        if (!move_uploaded_file($_FILES['file']['tmp_name'], $upfile)) {
            echo '<center><font color="red">上传失败</font></center>';
        } else {
            setcookie('cmdpath', $upfile);
            echo '<center><font color="red">上传成功,路径为' . $upfile . '</font></center><br/><br/><br/><br/>';
        }
    }
}
if ($_POST['read']) {
    echo '<center><textarea  cols="80" rows="15" readonly>' . "\r\n";
示例#25
0
 function upload_icon($upload_data)
 {
     extract($upload_data);
     $u_setting = $this->upload_setting();
     $allow_exts = $u_setting['allow_exts'];
     $max_size = $u_setting['img_size'];
     $type = trim(strtolower(end(explode(".", $_FILES[$field]['name']))));
     if (!in_array($type, $allow_exts)) {
         return -1;
     }
     $image_name = substr(md5($_FILES[$field]['name']), -10) . ".{$type}";
     $image_path = $this->qun_avatar_path($upload_data['qid']);
     if (empty($image_path)) {
         return;
     }
     $image_file = $image_path . $image_name;
     if (!is_dir($image_path)) {
         jio()->MakeDir($image_path);
     }
     jupload()->init($image_path, $field, true);
     jupload()->setMaxSize($max_size);
     jupload()->setNewName($image_name);
     $result = jupload()->doUpload();
     if ($result) {
         $result = is_image($image_file);
     }
     if (!$result) {
         jio()->DeleteFile($image_file);
         return -2;
     }
     list($w, $h) = getimagesize($image_file);
     $dst_file = $image_path . $upload_data['qid'] . '_b.jpg';
     if (file_exists($dst_file)) {
         unlink($dst_file);
     }
     $make_result = image_thumb($image_file, $dst_file, 80, 80, 2);
     $lst_file = $image_path . $upload_data['qid'] . '_s.jpg';
     if (file_exists($lst_file)) {
         unlink($lst_file);
     }
     $make_result = image_thumb($image_file, $lst_file, 50, 50, 2);
     unlink($image_file);
     if ($GLOBALS['_J']['config']['ftp_on']) {
         $ftp_key = randgetftp();
         $get_ftps = jconf::get('ftp');
         $site_url = $get_ftps[$ftp_key]['attachurl'];
         $ftp_result = ftpcmd('upload', $lst_file, '', $ftp_key);
         if ($ftp_result > 0) {
             $ftp_result = ftpcmd('upload', $dst_file, '', $ftp_key);
             jio()->DeleteFile($lst_file);
             jio()->DeleteFile($dst_file);
             $lst_file = $site_url . '/' . str_replace('./', '', $lst_file);
         }
     }
     if (!empty($upload_data['qid'])) {
         DB::query("UPDATE " . DB::table('qun') . " SET icon='{$lst_file}' WHERE qid='{$upload_data['qid']}'");
     }
     return 1;
 }
示例#26
0
        }
        $settingnew['ftp']['password'] = authcode($settingnew['ftp']['password'], 'ENCODE', md5($_G['config']['security']['authkey']));
        $_G['setting']['ftp'] = $settingnew['ftp'];
        ftpcmd('upload', $testfile);
        $ftp = ftpcmd('object');
        if ($ftp->error()) {
            $alertmsg = cplang('setting_attach_remote_' . $ftp->error());
        }
        if (!$alertmsg) {
            $str = dfsockopen($_G['setting']['ftp']['attachurl'] . '/' . $testfile);
            if ($str !== $testcontent) {
                $alertmsg = cplang('setting_attach_remote_geterr');
            }
        }
        if (!$alertmsg) {
            ftpcmd('delete', $testfile);
            $ftp->ftp_rmdir('test');
            $str = dfsockopen($_G['setting']['ftp']['attachurl'] . '/' . $testfile);
            if ($str === $testcontent) {
                $alertmsg = cplang('setting_attach_remote_delerr');
            }
            @unlink($attach_dir . '/' . $testfile);
            @rmdir($attach_dir . 'test');
        }
    }
    if (!$alertmsg) {
        $alertmsg = cplang('setting_attach_remote_ok');
    }
    echo '<script language="javascript">alert(\'' . str_replace('\'', '\\\'', $alertmsg) . '\');parent.$(\'cpform\').action=\'' . ADMINSCRIPT . '?action=setting&edit=yes\';parent.$(\'cpform\').target=\'_self\'</script>';
} elseif ($operation == 'mailcheck') {
    $oldmail = unserialize($_G['setting']['mail']);
示例#27
0
function pic_save($FILE, $albumid, $title, $iswatermark = true)
{
    global $_G, $space;
    if ($albumid < 0) {
        $albumid = 0;
    }
    $allowpictype = array('jpg', 'jpeg', 'gif', 'png');
    require_once libfile('class/upload');
    $upload = new discuz_upload();
    $upload->init($FILE, 'album');
    if ($upload->error()) {
        return lang('spacecp', 'lack_of_access_to_upload_file_size');
    }
    if (!$upload->attach['isimage']) {
        return lang('spacecp', 'only_allows_upload_file_types');
    }
    if (empty($space)) {
        $_G['member'] = $space = getspace($_G['uid']);
        $_G['username'] = addslashes($space['username']);
    }
    if (!checkperm('allowupload')) {
        return lang('spacecp', 'not_allow_upload');
    }
    if (!ckrealname('album', 1)) {
        return lang('spacecp', 'not_allow_upload');
    }
    if (!ckvideophoto('album', array(), 1)) {
        return lang('spacecp', 'not_allow_upload');
    }
    if (!cknewuser(1)) {
        return lang('spacecp', 'not_allow_upload');
    }
    $maxspacesize = checkperm('maxspacesize');
    $maxspacesize = $maxspacesize * 1024 * 1024;
    if ($maxspacesize) {
        space_merge($space, 'count');
        space_merge($space, 'field_home');
        if ($space['attachsize'] + $upload->attach['size'] > $maxspacesize + $space['addsize']) {
            return lang('spacecp', 'inadequate_capacity_space');
        }
    }
    $showtip = true;
    $albumfriend = 0;
    if ($albumid) {
        $albumid = album_creat_by_id($albumid);
    } else {
        $albumid = 0;
        $showtip = false;
    }
    $upload->save();
    if ($upload->error()) {
        return lang('spacecp', 'mobile_picture_temporary_failure');
    }
    $new_name = $upload->attach['target'];
    require_once libfile('class/image');
    $image = new image();
    $result = $image->Thumb($new_name, '', 140, 140, 1);
    $thumb = empty($result) ? 0 : 1;
    if ($_G['setting']['maxthumbwidth'] && $_G['setting']['maxthumbheight']) {
        if ($_G['setting']['maxthumbwidth'] < 300) {
            $_G['setting']['maxthumbwidth'] = 300;
        }
        if ($_G['setting']['maxthumbheight'] < 300) {
            $_G['setting']['maxthumbheight'] = 300;
        }
        $image->Thumb($new_name, '', $_G['setting']['maxthumbwidth'], $_G['setting']['maxthumbheight'], 1, 1);
    }
    if ($iswatermark) {
        $image->Watermark($new_name);
    }
    $pic_remote = 0;
    $album_picflag = 1;
    if (getglobal('setting/ftp/on')) {
        $ftpresult_thumb = 0;
        $ftpresult = ftpcmd('upload', 'album/' . $upload->attach['attachment']);
        if ($ftpresult) {
            if ($thumb) {
                ftpcmd('upload', 'album/' . $upload->attach['attachment'] . '.thumb.jpg');
            }
            $pic_remote = 1;
            $album_picflag = 2;
        } else {
            if (getglobal('setting/ftp/mirror')) {
                @unlink($upload->attach['target']);
                @unlink($upload->attach['target'] . '.thumb.jpg');
                return lang('spacecp', 'ftp_upload_file_size');
            }
        }
    }
    $title = getstr($title, 200, 1, 1, 1);
    $setarr = array('albumid' => $albumid, 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $_G['timestamp'], 'filename' => addslashes($upload->attach['name']), 'postip' => $_G['clientip'], 'title' => $title, 'type' => addslashes($upload->attach['ext']), 'size' => $upload->attach['size'], 'filepath' => $upload->attach['attachment'], 'thumb' => $thumb, 'remote' => $pic_remote);
    $setarr['picid'] = DB::insert('home_pic', $setarr, 1);
    DB::query("UPDATE " . DB::table('common_member_count') . " SET attachsize=attachsize+{$upload->attach['size']} WHERE uid='{$_G['uid']}'");
    include_once libfile('function/stat');
    updatestat('pic');
    return $setarr;
}
示例#28
0
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;
}
示例#29
0
function pic_upload($FILES, $type = 'album', $thumb_width = 0, $thumb_height = 0, $thumb_type = 2)
{
    $upload = new discuz_upload();
    $result = array('pic' => '', 'thumb' => 0, 'remote' => 0);
    $upload->init($FILES, $type);
    if ($upload->error()) {
        return array();
    }
    $upload->save();
    if ($upload->error()) {
        return array();
    }
    $result['pic'] = $upload->attach['attachment'];
    if ($thumb_width && $thumb_height) {
        require_once libfile('class/image');
        $image = new image();
        if ($image->Thumb($upload->attach['target'], '', $thumb_width, $thumb_height, $thumb_type)) {
            $result['thumb'] = 1;
        }
    }
    if (getglobal('setting/ftp/on')) {
        if (ftpcmd('upload', $type . '/' . $upload->attach['attachment'])) {
            if ($result['thumb']) {
                ftpcmd('upload', $type . '/' . getimgthumbname($upload->attach['attachment']));
            }
            ftpcmd('close');
            $result['remote'] = 1;
        } else {
            if (getglobal('setting/ftp/mirror')) {
                @unlink($upload->attach['target']);
                @unlink(getimgthumbname($upload->attach['target']));
                return array();
            }
        }
    }
    return $result;
}
示例#30
0
function ftpupload($aids, $uid = 0)
{
    global $_G;
    $uid = $uid ? $uid : $_G['uid'];
    if (!$aids || !$_G['setting']['ftp']['on']) {
        return;
    }
    $query = DB::query("SELECT aid, thumb, attachment, filename, filesize FROM " . DB::table('forum_attachment') . " WHERE aid IN (" . dimplode($aids) . ") AND uid='{$_G['uid']}' AND remote='0'");
    $aids = array();
    while ($attach = DB::fetch($query)) {
        $attach['ext'] = fileext($attach['filename']);
        if ((!$_G['setting']['ftp']['allowedexts'] && !$_G['setting']['ftp']['disallowedexts'] || $_G['setting']['ftp']['allowedexts'] && in_array($attach['ext'], explode("\n", strtolower($_G['setting']['ftp']['allowedexts']))) || $_G['setting']['ftp']['disallowedexts'] && !in_array($attach['ext'], explode("\n", strtolower($_G['setting']['ftp']['disallowedexts'])))) && (!$_G['setting']['ftp']['minsize'] || $attach['filesize'] >= $_G['setting']['ftp']['minsize'] * 1024)) {
            if (ftpcmd('upload', 'forum/' . $attach['attachment']) && (!$attach['thumb'] || ftpcmd('upload', 'forum/' . $attach['attachment'] . '.thumb.jpg'))) {
                dunlink($attach);
                $aids[] = $attach['aid'];
            }
        }
    }
    if ($aids) {
        DB::update('forum_attachment', array('remote' => 1), "aid IN (" . dimplode($aids) . ")");
    }
}