Discuz! x2 相册批量上传阐明

  首先我们进入Discuz相册批量上传页面,从地点栏可以阐明

home.php?mod=spacecp&ac=upload&op=flash&albumid=0

  会见的文件是 source\module\home\home_spacecp.php

  此文件底部

require_once libfile('spacecp/'.$ac, 'include');

  挪用source\include\spacecp\spacecp_upload.php文件,进入这部门:

if(!checkperm('allowupload')) {

showmessage('no_privilege_upload', '', array(), array('return' => true));

}

cknewuser();

$config = urlencode($_G['siteroot'].'home.php?mod=misc&ac=swfupload&op=config'.($_GET['op'] == 'cam'? '&cam=1' : ''));

$albums = getalbums($_G['uid']);

$actives = ($_GET['op'] == 'flash' || $_GET['op'] == 'cam')?array($_GET['op']=>' class="a"'):array('js'=>' class="a"');

$maxspacesize = checkperm('maxspacesize');

if(!empty($maxspacesize)) {

space_merge($space, 'count');

space_merge($space, 'field_home');

$maxspacesize = $maxspacesize + $space['addsize'] * 1024 * 1024;

$haveattachsize = ($maxspacesize < $space['attachsize'] ? '-':'').formatsize($maxspacesize - $space['attachsize']);

} else {

$haveattachsize = 0;

}

require_once libfile('function/friend');

$groups = friend_group_list();

loadcache('albumcategory');

$category = $_G['cache']['albumcategory'];

$categoryselect = '';

if($category) {

include_once libfile('function/portalcp');

$categoryselect = category_showselect('album', 'catid', !$_G['setting']['albumcategoryrequired'] ? true : false, $_GET['catid']);

}

}

  此处的代码中的

$config = urlencode($_G['siteroot'].'home.php?mod=misc&ac=swfupload&op=config'.($_GET['op'] == 'cam'? '&cam=1' : ''));

  是会见flash 处理惩罚文件的进口

include_once template("home/spacecp_upload");

  然后挪用模版文件,下面我们来查察模版相应的相册批量上传部门的代码:

<script type="text/javascript">
document.write(AC_FL_RunContent(
'width', '100%', 'height', '400',
'src', '{IMGDIR}/album_upload.swf?config=$config&albumid=$_GET[albumid]',
'quality', 'high', 'wmode', 'transparent'
));
</script>

  代码中的config来自 上面提到的$config 这部门代码,这部门代码用来显示flash,来自于static/js/common.js

  接下来,会见将进入flash处理惩罚的要害部门:source\include\misc\misc_swfupload.php,首次执行的是:

} elseif($op == 'config') {
$hash = md5($_G['uid'].UC_KEY);
$uploadurl = urlencode(getsiteurl().'home.php?mod=misc&ac=swfupload'.($iscamera ? '&op=screen' : ($isdoodle ? '&op=doodle&from=':'')));
.......中间代码省略
$albums = getalbums($_G['uid']);
//系统分类
loadcache('albumcategory');
$categorys = $_G['cache']['albumcategory'];
$categorystat = $_G['setting']['albumcategorystat'] ? intval($_G['setting']['albumcategorystat']) : 0;
$categoryrequired = $_G['setting']['albumcategoryrequired'] ? intval($_G['setting']['albumcategoryrequired']) : 0;

  这段代码中的

albums = getalbums($_G['uid']);//系统分类
loadcache('albumcategory');
$categorys = $_G['cache']['albumcategory'];

  用于获取用户的相册分类,这也是容易堕落的处所(当用户在靠山开启了相册分类,可是没有配置分类项,导致$categorys为空)

$categorystat = $_G['setting']['albumcategorystat'] ? intval($_G['setting']['albumcategorystat']) : 0;

  上面这段代码用于挪用返回给flash的相册分类xml文件(template\default\home\misc_swfupload.htm)

  当第一次会见完 misc_swfupload.php文件,将返回xml文件给flash 用于显示,主要处理惩罚在文件底部,假如返回的xml文件有错误将导致flash上显示不正确,可能终止继承运行,导致flash停滞。返回正常措施将通过用户提交上传图片将再次会见,该文件进入

elseif($_FILES && $_POST) {
if($_FILES["Filedata"]['error']) {
$uploadfiles = lang('spacecp', 'file_is_too_big');
} else {
$_FILES["Filedata"]['name'] = addslashes(diconv(urldecode($_FILES["Filedata"]['name']), 'UTF-8'));
$_POST['albumid'] = addslashes(diconv(urldecode($_POST['albumid']), 'UTF-8'));
$catid = $_POST['catid'] ? intval($_POST['catid']) : 0;
$uploadfiles = pic_save($_FILES["Filedata"], $_POST['albumid'], addslashes(diconv(urldecode($_POST['title']), 'UTF-8')), true, $catid);
}
$proid = $_POST['proid'];
$uploadResponse = true;
$albumid = 0;
if($uploadfiles && is_array($uploadfiles)) {
$status = "success";
$albumid = $uploadfiles['albumid'];
} else {
$status = "failure";
}
}

  个中以下这段代码:

$uploadfiles = pic_save($_FILES["Filedata"], $_POST['albumid'], addslashes(diconv(urldecode($_POST['title']), 'UTF-8')), true, $catid);

  浸染是生存图片(从姑且目次移动随处事器端,到达上传文件结果),函数来自source\function\function_spacecp.php。

  到此,相册批量上传图片已根基竣事。

Discuz 下载:

Discuz! X2 R20120628 简体GBK下载

Discuz! x2 相册批量上传阐发

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/10424.html