本文整理汇总了PHP中ftpcmd函数的典型用法代码示例。如果您正苦于以下问题:PHP ftpcmd函数的具体用法?PHP ftpcmd怎么用?PHP ftpcmd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftpcmd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remote_ftp
/**
* 通过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: remote_ftp
/**
*
*
* 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: dunlink
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: dunlink
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: dunlink
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: remote_ftp
/**
* 通过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: delPic
/**
* 删除图片
*
* @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;
}
}
示例8: getremotefile
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: setthreadcover
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: setthreadcover
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: block_delete_pic
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: DoAddADV
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);
//.........这里部分代码省略.........
示例13: onloadPic
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: Upload
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: _parse_url_attach
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;
}