本文整理汇总了PHP中discuz_upload::get_target_filename方法的典型用法代码示例。如果您正苦于以下问题:PHP discuz_upload::get_target_filename方法的具体用法?PHP discuz_upload::get_target_filename怎么用?PHP discuz_upload::get_target_filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类discuz_upload
的用法示例。
在下文中一共展示了discuz_upload::get_target_filename方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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;
}
示例3: 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;
$thumb = $width = 0;
示例4: forum_downremotefile
//.........这里部分代码省略.........
} 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;
$width = $image->imginfo['width'];