本文整理汇总了PHP中makethumb函数的典型用法代码示例。如果您正苦于以下问题:PHP makethumb函数的具体用法?PHP makethumb怎么用?PHP makethumb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makethumb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _uploadImage
function _uploadImage()
{
$field = 'author';
$type = trim(strtolower(end(explode(".", $_FILES[$field]['name']))));
if ($type != 'gif' && $type != 'jpg' && $type != 'png') {
Mobile::error('Illegal Strings', 350);
}
$image_name = substr(md5($_FILES[$field]['name']), -10) . ".{$type}";
$sub_path = './cache/temp_images/' . $image_name[0] . '/';
$image_path = RELATIVE_ROOT_PATH . $sub_path;
$image_path_abs = ROOT_PATH . $sub_path;
$image_file = $image_path . $image_name;
$image_file_abs = $image_path_abs . $image_name;
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 (!$result) {
jio()->RemoveDir($image_path_abs);
Mobile::error('Illegal Strings', 352);
}
list($w, $h) = getimagesize($image_file_abs);
if ($w > 601) {
$tow = 599;
$toh = round($tow * ($h / $w));
$result = makethumb($image_file_abs, $image_file_abs, $tow, $toh);
if (!$result) {
jio()->RemoveDir($image_path_abs);
Mobile::error('Illegal Strings', 351);
}
}
$up_image_path = addslashes($image_file_abs);
$src_file = $image_file_abs;
$image_path = RELATIVE_ROOT_PATH . 'images/face/' . face_path(MEMBER_ID);
$image_path_abs = ROOT_PATH . './images/face/' . face_path(MEMBER_ID);
if (!is_dir($image_path_abs)) {
jio()->MakeDir($image_path_abs);
}
$image_file = $dst_file = $image_path . MEMBER_ID . '_b.jpg';
$image_file_abs = $dst_file_abs = $image_path_abs . MEMBER_ID . '_b.jpg';
$make_result = image_thumb($src_file, $dst_file_abs, 128, 128, 2);
$image_file_small = $dst_file = $image_path . MEMBER_ID . '_s.jpg';
$image_file_small_abs = $dst_file_abs = $image_path_abs . MEMBER_ID . '_s.jpg';
$make_result = image_thumb($src_file, $dst_file_abs, 50, 50, 2);
$face_url = '';
if ($this->Config['ftp_on']) {
$ftp_key = randgetftp();
$get_ftps = jconf::get('ftp');
$face_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);
}
}
$sql = "update `" . TABLE_PREFIX . "members` set `face_url`='{$face_url}', `face`='{$dst_file}' where `uid`='" . MEMBER_ID . "'";
$this->DatabaseHandler->Query($sql);
jio()->DeleteFile($src_file);
if ($this->Config['extcredits_enable'] && MEMBER_ID > 0) {
update_credits_by_action('face', MEMBER_ID);
}
Mobile::success("Success");
}
示例2: saveremotefile
function saveremotefile($url, $thumbarr = array(100, 100), $mkthumb = 1, $maxsize = 0)
{
global $_SCONFIG, $_SGLOBAL;
$patharr = $blank = array('file' => '', 'thumb' => '', 'name' => '', 'type' => '', 'size' => 0);
$ext = fileext($url);
$patharr['type'] = $ext;
if (in_array($ext, array('jpg', 'jpeg', 'gif', 'png'))) {
$isimage = 1;
} else {
$isimage = 0;
$ext = 'attach';
}
//debug 文件名
if (empty($_SGLOBAL['_num'])) {
$_SGLOBAL['_num'] = 0;
}
$_SGLOBAL['_num'] = intval($_SGLOBAL['_num']);
$_SGLOBAL['_num']++;
$filemain = $_SGLOBAL['supe_uid'] . '_' . sgmdate($_SGLOBAL['timestamp'], 'YmdHis') . $_SGLOBAL['_num'] . random(4);
$patharr['name'] = $filemain . '.' . $ext;
//debug 得到存储目录
$dirpath = getattachdir();
if (!empty($dirpath)) {
$dirpath .= '/';
}
$patharr['file'] = $dirpath . $filemain . '.' . $ext;
//debug 上传
$content = sreadfile($url, 'rb', 1, $maxsize);
if (empty($content)) {
return $blank;
}
writefile(A_DIR . '/' . $patharr['file'], $content, 'text', 'wb', 0);
if (!file_exists(A_DIR . '/' . $patharr['file'])) {
return $blank;
}
$imageinfo = @getimagesize(A_DIR . '/' . $patharr['file']);
list($width, $height, $type) = !empty($imageinfo) ? $imageinfo : array('', '', '');
if (!in_array($type, array(1, 2, 3, 6, 13))) {
@unlink(A_DIR . '/' . $patharr['file']);
return $blank;
}
$patharr['size'] = filesize(A_DIR . '/' . $patharr['file']);
//debug 缩略图水印
if ($isimage) {
if ($mkthumb && $ext != 'gif') {
//debug 缩略图
$patharr['thumb'] = makethumb($patharr['file'], $thumbarr);
//debug 加水印
if (!empty($patharr['thumb'])) {
makewatermark($patharr['file']);
}
}
if (empty($patharr['thumb'])) {
$patharr['thumb'] = $patharr['file'];
}
}
return $patharr;
}
示例3: COUNT
$count = $_SGLOBAL['db']->result($_SGLOBAL['db']->query("SELECT COUNT(*) FROM " . tname('jifen_lp') . " where lbid=" . intval($_POST['lbid']) . " group by lbid"), 0);
updatetable('jifen_lb', array('nums' => $count), array('id' => intval($_POST['lbid'])));
// 更新缓存
include_once S_ROOT . "source/function_cache.php";
jifen_lb_cache();
}
// 上传海报
if (!empty($_FILES['pic']['tmp_name'])) {
include_once S_ROOT . './source/function_image.php';
$tmp_name = S_ROOT . './data/temp/eventpic.tmp';
move_uploaded_file($_FILES['pic']['tmp_name'], $tmp_name);
// 临时改变缩略图设置
include_once S_ROOT . './data/data_setting.php';
$tmpsetting = $_SGLOBAL['setting'];
$_SGLOBAL['setting'] = array('thumbwidth' => 200, 'thumbheight' => 200, 'maxthumbwidth' => 200, 'maxthumbheight' => 200);
$thumbpath = makethumb($tmp_name);
$_SGLOBAL['setting'] = $tmpsetting;
if (empty($thumbpath)) {
//未生成缩略图
if (fileext($_FILES['pic']['name']) != 'jpg') {
cpmessage('poster_only_jpg_allowed');
}
$thumbpath = $tmp_name;
} else {
//成功生成缩略图
@unlink($tmp_name);
}
if (!is_dir(S_ROOT . './jifen/uploads/image')) {
@mkdir(S_ROOT . './jifen/uploads/image');
}
if (is_file(S_ROOT . './jifen/uploads/image/' . $id . '.jpg')) {
示例4: 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;
}
}
示例5: class_upload
<?php
include_once "../includes/config.inc.php";
include_once "../includes/class-upload.php";
$customer_id = $_WGT['m_customer_id'];
if (method_is('post')) {
$upload = new class_upload();
$upload->upload_form_field = 'imgfile';
$upload->out_file_dir = '../data/image_c/' . $customer_id . '/' . date("Ymd");
$upload->max_file_size = 1024 * 1024 * 6;
//6M
$upload->make_script_safe = 1;
$upload->allowed_file_ext = array('gif', 'jpg', 'jpeg', 'png');
$upload->upload_process();
if ($upload->error_no) {
ajax_feedback(0, $upload->error_no);
}
//等比缩放
makethumb($upload->saved_upload_name, $upload->saved_upload_name, 800, 800, 1);
$save_path = str_replace('../data/image_c/', '', $upload->saved_upload_name);
ajax_feedback(1, array('path' => $save_path));
}
示例6: intval
$setarr["scategory"] = $scategory_arr[1];
$setarr["category_cn"] = $scategory_arr[2];
$setarr["shop_stock"] = $_POST["shop_stock"] ? intval($_POST["shop_stock"]) : adminmsg("请输入商品库存");
$setarr["shop_customer"] = intval($_POST["shop_customer"]);
$setarr["shop_points"] = $_POST["shop_points"] ? intval($_POST["shop_points"]) : adminmsg("请输入商品兑换所需积分");
$setarr["content"] = $_POST["content"] ? trim($_POST["content"]) : adminmsg("请输入商品描述");
$setarr["recommend"] = intval($_POST["recommend"]);
if ($_FILES['shop_img']['name']) {
require_once QISHI_ROOT_PATH . 'include/upload.php';
$upfiles_dir = "../data/shop/" . date("Y/m/d/");
make_dir($upfiles_dir);
$shop_img = _asUpFiles($upfiles_dir, "shop_img", 1024 * 2, 'jpg/gif/png', true);
$makefile = $upfiles_dir . $shop_img;
$thumb_dir = "../data/shop/thumb/" . date("Y/m/d/");
make_dir($thumb_dir);
makethumb($makefile, $thumb_dir, 288, 288, 1);
$setarr['shop_img'] = date("Y/m/d/") . $shop_img;
}
if ($id > 0) {
write_log("后台修改商品信息", $_SESSION['admin_name'], 3);
!$db->updatetable(table("shop_goods"), $setarr, array("id" => $id)) ? adminmsg("修改失败!") : adminmsg("修改成功!", 2);
} else {
$setarr['addtime'] = time();
$setarr['shop_number'] = time() . rand(1000, 9999);
write_log("后台添加商品信息", $_SESSION['admin_name'], 3);
!$db->inserttable(table("shop_goods"), $setarr) ? adminmsg("添加失败!") : adminmsg("添加成功!", 2);
}
} elseif ($act == "shop_del") {
$id = !empty($_REQUEST['id']) ? $_REQUEST['id'] : adminmsg("你没有选择商品!", 1);
$num = del_shop($id);
if ($num > 0) {
示例7: 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;
}
示例8: elseif
}
} elseif ($act == 'avatars_save') {
require_once QISHI_ROOT_PATH . 'include/cut_upload.php';
require_once QISHI_ROOT_PATH . 'include/imageresize.class.php';
$imgresize = new ImageResize();
$userinfomation = get_user_info($_SESSION['uid']);
if ($userinfomation['avatars']) {
$up_dir_original = "../../data/avatar/original/";
$up_dir_100 = "../../data/avatar/100/";
$up_dir_48 = "../../data/avatar/48/";
$up_dir_thumb = "../../data/avatar/thumb/";
$imgresize->load($up_dir_thumb . $userinfomation['avatars']);
$imgresize->cut(intval($_POST['w']), intval($_POST['h']), intval($_POST['x']), intval($_POST['y']));
$imgresize->save($up_dir_thumb . $userinfomation['avatars']);
makethumb($up_dir_thumb . $userinfomation['avatars'], $up_dir_100 . date("Y/m/d/"), 100, 100);
makethumb($up_dir_thumb . $userinfomation['avatars'], $up_dir_48 . date("Y/m/d/"), 48, 48);
@unlink($up_dir_original . $userinfomation['avatars']);
@unlink($up_dir_thumb . $userinfomation['avatars']);
$wheresql = " uid='" . $_SESSION['uid'] . "'";
write_memberslog($_SESSION['uid'], 2, 1006, $_SESSION['username'], "修改了个人头像");
showmsg('保存成功!', 2);
} else {
showmsg('请上传图片!', 1);
}
} elseif ($act == 'password_edit') {
$uid = intval($_SESSION['uid']);
$smarty->assign('total', $db->get_total("SELECT COUNT(*) AS num FROM " . table('pms') . " WHERE (msgfromuid='{$uid}' OR msgtouid='{$uid}') AND `new`='1'"));
$smarty->assign('title', '修改密码 - 个人会员中心 - ' . $_CFG['site_name']);
$smarty->display('member_personal/personal_password.htm');
} elseif ($act == 'save_password') {
require_once QISHI_ROOT_PATH . 'include/fun_user.php';
示例9: resize_image
function resize_image($file_path,$thumb_file_path,$width,$height,$cut=false)
{
return makethumb($file_path,$thumb_file_path,$width,$height);
}
示例10: array
$pictypes['png'] = array('imagecreatefrompng', 'imagepng');
$pictypes['jpeg'] = array('imagecreatefromjpeg', 'imagejpeg');
$pictypes['jpg'] = array('imagecreatefromjpeg', 'imagejpeg');
$contenttypes = array();
$contenttypes['gif'] = 'image/gif';
$contenttypes['png'] = 'image/png';
$contenttypes['jpeg'] = 'image/jpg';
$contenttypes['jpg'] = 'image/jpg';
$width = $_POST['rdx'] - $_POST['ldx'];
$height = $_POST['rdy'] - $_POST['ruy'];
$image = @imagecreatetruecolor($width, $height);
$imagesrc = @$pictypes[$picfiletype][0]($_POST['imagepath']);
@imagecopy($image, $imagesrc, 0, 0, $_POST['ldx'], $_POST['luy'], $width, $height);
$swapfile = S_ROOT . 'data/temp/swappic_' . $_SGLOBAL['supe_uid'] . '.' . $picfiletype;
@$pictypes[$picfiletype][1]($image, $swapfile);
$makethumb = makethumb($swapfile, array($_POST['imagewidth'], $_POST['imageheight']), A_DIR . '/' . $_POST['thumbimg']);
@unlink($swapfile);
$charset = $_SC['charset'];
print <<<END
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
<title>{$blang['thumb_image_ok']}</title>
</head>
<script language="JavaScript">
<!--
function refreshParentImage(iamgeid) {
\tvar imagereload = opener.document.getElementById(iamgeid)
\timagereload.src = imagereload.src
\twindow.close();
示例11: class_DBOperation
<?php
require 'Class_DBOperation.php';
require 'global.php';
require 'inc_thumb.php';
$dbOperation = new class_DBOperation(DBHOST, DBUSER, DBPWD, DBNAME, DBCHARSET);
$email = $_POST['email'];
$target = "upload/";
$FileID = date("Ymd-His") . '-' . rand(100, 999);
$thumb = $target . 'thumb_' . $FileID . basename($_FILES['uploaded']['name']);
$target = $target . $FileID . basename($_FILES['uploaded']['name']);
if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {
makethumb($target, $thumb, "75", "75");
$sql = "select * from lbs_member where email='{$email}' ";
$checkResult = $dbOperation->query($sql);
$resultObj = $dbOperation->fetch_obj($checkResult);
if ($resultObj) {
$userid = $resultObj->userid;
$sql = "insert into lbs_photo(userid,x_pic,d_pic) values('{$userid}','{$thumb}','{$target}') ";
$dbOperation->query($sql);
}
$sql = "update lbs_member set pic='{$thumb}',update_time=now() where email='{$email}' and pic='upload/no.jpg' ";
$dbOperation->query($sql);
$resultJson = json_encode(array('regTag' => 1));
echo $resultJson;
} else {
$resultJson = json_encode(array('regTag' => -1));
echo $resultJson;
}
?>
示例12: upload
function upload($p = array())
{
$sys_config = jconf::get();
if ($sys_config['image_uploadify_queue_size_limit'] > 0 && $this->upload_count >= $sys_config['image_uploadify_queue_size_limit']) {
return array('error' => 'image upload limit', 'code' => 0);
}
$pic_url = $p['pic_url'] && false !== strpos($p['pic_url'], ':/' . '/') ? $p['pic_url'] : '';
$p['pic_field'] = $p['pic_field'] ? $p['pic_field'] : 'topic';
$pic_field = $p['pic_field'] && $_FILES[$p['pic_field']] ? $p['pic_field'] : '';
if (!$pic_url && !$pic_field) {
return array('error' => 'pic is empty', 'code' => -1);
}
$itemid = is_numeric($p['itemid']) ? $p['itemid'] : 0;
$albumid = is_numeric($p['albumid']) ? $p['albumid'] : 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);
}
$image_id = $this->add($uid, $member_info['nickname'], $item, $itemid, $albumid);
if ($image_id < 1) {
return array('error' => 'write database is invalid', 'code' => -3);
}
$image_path = RELATIVE_ROOT_PATH . 'images/topic/' . face_path($image_id);
$image_name = $image_id . "_o.jpg";
$image_file = $image_path . $image_name;
$image_file_small = $image_path . $image_id . "_s.jpg";
$image_file_middle = $image_path . $image_id . "_m.jpg";
$image_file_photo = $image_path . $image_id . "_p.jpg";
$image_file_temp = $image_path . $image_id . "_t.jpg";
if (!is_dir($image_path)) {
jio()->MakeDir($image_path);
}
if ($pic_field) {
if (empty($_FILES) || !$_FILES[$pic_field]['name']) {
return array('error' => 'FILES is empty', 'code' => -4);
}
$_FILES[$pic_field]['name'] = get_safe_code($_FILES[$pic_field]['name']);
jupload()->init($image_path, $pic_field, true, false);
jupload()->setMaxSize($sys_config['image_size']);
jupload()->setNewName($image_name);
$ret = jupload()->doUpload();
if (!$ret) {
$this->delete($image_id);
$rets = jupload()->getError();
$ret = $rets ? implode(" ", (array) $rets) : 'image upload is invalid';
return array('error' => $ret, 'code' => -5);
}
} elseif ($pic_url) {
$temp_image = dfopen($pic_url);
if ($temp_image) {
jio()->WriteFile($image_file, $temp_image);
} else {
return array('error' => 'image download is invalid', 'code' => -6);
}
}
if (!is_image($image_file)) {
jio()->DeleteFile($image_file);
return array('error' => 'image file is invalid', 'code' => -7);
}
@copy($image_file, $image_file_temp);
list($image_width, $image_height, $image_type, $image_attr) = getimagesize($image_file);
$thumbwidth = min($sys_config['thumbwidth'], $image_width);
$thumbheight = min($sys_config['thumbheight'], $image_width);
$maxw = $sys_config['maxthumbwidth'];
$maxh = $sys_config['maxthumbheight'];
$result = makethumb($image_file, $image_file_small, $thumbwidth, $thumbheight, $maxw, $maxh, 0, 0, 0, 0, $sys_config['thumb_cut_type'], $sys_config['image_thumb_quality']);
clearstatcache();
if (!is_file($image_file)) {
@copy($image_file_temp, $image_file);
}
$iw = $image_width;
$ih = $image_height;
if (!$sys_config['thumb_cut_type']) {
if ($image_width != $image_height) {
if ($maxw > 300 && $maxh > 300 && ($iw > $maxw || $ih > $maxh)) {
list($iw, $ih) = getimagesize($image_file);
}
$src_x = $src_y = 0;
$src_w = $src_h = min($iw, $ih);
if ($iw > $ih) {
$src_x = round(($iw - $ih) / 2);
} else {
$src_y = round(($ih - $iw) / 2);
}
$result = makethumb($image_file, $image_file_small, $thumbwidth, $thumbheight, 0, 0, $src_x, $src_y, $src_w, $src_h, 0, $sys_config['image_thumb_quality']);
}
clearstatcache();
if (!$result && !is_file($image_file_small)) {
@copy($image_file_temp, $image_file_small);
}
}
$image_width_p = (int) $sys_config['image_width_p'];
if ($image_width_p < 1) {
$image_width_p = 280;
}
if ($iw > $image_width_p) {
//.........这里部分代码省略.........
示例13: DoModifyFace
function DoModifyFace()
{
if (MEMBER_ID < 1) {
$this->Messager("请先<a href='index.php?mod=login'>点此登录</a>或者<a href='index.php?mod=member'>点此注册</a>一个帐号", 'index.php?mod=login');
}
$field = 'face';
$src_x = 0;
$src_y = 0;
$src_w = 200;
$src_h = 200;
if (!empty($_FILES[$field]['name'])) {
$type = trim(strtolower(end(explode(".", $_FILES[$field]['name']))));
if ($type != 'gif' && $type != 'jpg' && $type != 'png' && $type != 'jpeg') {
$this->Messager("图片格式不对", 'index.php?mod=settings&code=face');
}
$image_path = ROOT_PATH . 'images/' . $field . '/' . face_path(MEMBER_ID);
$image_name = MEMBER_ID . "_b.jpg";
$src_file = $image_path . $image_name;
if (!is_dir($image_path)) {
jio()->MakeDir($image_path);
}
jupload()->init($image_path, $field, true, false);
jupload()->setNewName($image_name);
$result = jupload()->doUpload();
$image_file_small = $dst_file = $image_path . MEMBER_ID . '_s.jpg';
$make_result = makethumb($src_file, $dst_file, 50, 50, 0, 0, $src_x, $src_y, $src_w, $src_h);
$image_file = $dst_file = $image_path . $image_name;
$make_result = makethumb($src_file, $dst_file, max(50, min(128, $src_w)), max(50, min(128, $src_w)), 0, 0, $src_x, $src_y, $src_w, $src_h);
if ($result) {
$result = is_image($image_file);
}
if (!$result) {
jio()->DeleteFile($image_file);
$this->Messager("图片上载失败", 'index.php?mod=settings&code=face');
}
$sql = "update `" . TABLE_PREFIX . "members` set `face`='{$image_file}' where `uid`='" . MEMBER_ID . "'";
$this->DatabaseHandler->Query($sql);
}
$this->Messager("头像设置成功", 'index.php?mod=settings&code=base&uid=' . MEMBER_ID);
}
示例14: class_upload
<?php
include_once "../includes/config.inc.php";
include_once "../includes/class-upload.php";
$customer_id = $_WGT['m_customer_id'];
if (method_is('post')) {
$upload = new class_upload();
$upload->upload_form_field = 'imgfile';
$upload->out_file_dir = '../data/image_c/' . $customer_id . '/' . date("Ymd");
$upload->max_file_size = 1024 * 1024 * 6;
//6M
$upload->make_script_safe = 1;
$upload->allowed_file_ext = array('gif', 'jpg', 'jpeg', 'png');
$upload->upload_process();
if ($upload->error_no) {
ajax_feedback(0, $upload->error_no);
}
$save_path = str_replace('../data/image_c/', '', $upload->saved_upload_name);
makethumb($upload->saved_upload_name, $upload->saved_upload_name, 200, 200);
//更新到数据库
$model = new Model_Subtable('sub_user');
$model->query("update sub_user set head_pic='{$save_path}' where id=" . $_POST['id']);
ajax_feedback(1, array('path' => $save_path));
}
示例15: stream_save
function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name = '', $title = '', $delsize = 0)
{
global $_SGLOBAL, $space, $_SCONFIG, $_SC;
$setarr = array();
$filepath = getfilepath($fileext, true);
$newfilename = $_SC['attachdir'] . './' . $filepath;
if ($handle = fopen($newfilename, 'wb')) {
if (fwrite($handle, $strdata) !== FALSE) {
fclose($handle);
$size = filesize($newfilename);
//检查空间大小
if (empty($space)) {
$query = $_SGLOBAL['db']->query("SELECT username, credit, groupid, attachsize, addsize FROM " . tname('space') . " WHERE uid='{$_SGLOBAL['supe_uid']}'");
$space = $_SGLOBAL['db']->fetch_array($query);
$_SGLOBAL['supe_username'] = addslashes($space['username']);
}
$_SGLOBAL['member'] = $space;
$maxattachsize = intval(checkperm('maxattachsize'));
//单位MB
if ($maxattachsize) {
//0为不限制
if ($space['attachsize'] + $size - $delsize > $maxattachsize + $space['addsize']) {
@unlink($newfilename);
return -1;
}
}
//检查是否图片
if (function_exists('getimagesize') && !@getimagesize($newfilename)) {
@unlink($newfilename);
return -2;
}
//缩略图
include_once S_ROOT . './source/function_image.php';
$thumbpath = makethumb($newfilename);
$thumb = empty($thumbpath) ? 0 : 1;
//大头帖不添加水印
if ($_SCONFIG['allowwatermark']) {
makewatermark($newfilename);
}
//入库
$filename = addslashes($name ? $name : substr(strrchr($filepath, '/'), 1));
$title = $title;
if ($albumid) {
preg_match("/^new\\:(.+)\$/i", $albumid, $matchs);
if (!empty($matchs[1])) {
$albumname = shtmlspecialchars(trim($matchs[1]));
if (empty($albumname)) {
$albumname = sgmdate('Ymd');
}
$albumid = album_creat(array('albumname' => $albumname));
} else {
$albumid = intval($albumid);
if ($albumid) {
$query = $_SGLOBAL['db']->query("SELECT albumname,friend FROM " . tname('album') . " WHERE albumid='{$albumid}' AND uid='{$_SGLOBAL['supe_uid']}'");
if ($value = $_SGLOBAL['db']->fetch_array($query)) {
$albumname = addslashes($value['albumname']);
$albumfriend = $value['friend'];
} else {
$albumname = sgmdate('Ymd');
$albumid = album_creat(array('albumname' => $albumname));
}
}
}
} else {
$albumname = sgmdate('Ymd');
$albumid = album_creat(array('albumname' => $albumname));
}
$setarr = array('albumid' => $albumid, 'uid' => $_SGLOBAL['supe_uid'], 'dateline' => $_SGLOBAL['timestamp'], 'filename' => $filename, 'postip' => getonlineip(), 'title' => $title, 'type' => $fileext, 'size' => $size, 'filepath' => $filepath, 'thumb' => $thumb);
$setarr['picid'] = inserttable('pic', $setarr, 1);
//更新附件大小
//积分
$setsql = '';
if ($pic_credit = creditrule('get', 'pic')) {
$setsql = ",credit=credit+{$pic_credit}";
}
$_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET attachsize=attachsize+'{$size}', updatetime='{$_SGLOBAL['timestamp']}' {$setsql} WHERE uid='{$_SGLOBAL['supe_uid']}'");
//相册更新
if ($albumid) {
$file = $filepath . ($thumb ? '.thumb.jpg' : '');
$_SGLOBAL['db']->query("UPDATE " . tname('album') . "\r\n\t\t\t\t\tSET picnum=picnum+1, updatetime='{$_SGLOBAL['timestamp']}', pic='{$file}', picflag='1'\r\n\t\t\t\t\tWHERE albumid='{$albumid}'");
}
//最后进行ftp上传,防止垃圾产生
if ($_SCONFIG['allowftp']) {
include_once S_ROOT . './source/function_ftp.php';
if (ftpupload($newfilename, $filepath)) {
$setarr['remote'] = 1;
updatetable('pic', array('remote' => $setarr['remote']), array('picid' => $setarr['picid']));
if ($albumid) {
updatetable('album', array('picflag' => 2), array('albumid' => $albumid));
}
}
}
$siteurl = '';
if (empty($setarr['remote'])) {
$uri = $_SERVER['REQUEST_URI'] ? $_SERVER['REQUEST_URI'] : ($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);
$siteurl = 'http://' . $_SERVER['HTTP_HOST'] . substr($uri, 0, strexists($uri, '/api') ? strrpos($uri, '/') - 3 : strrpos($uri, '/') + 1);
}
$setarr['filepathall'] = $siteurl . mkpicurl($setarr, 0);
return $setarr;
} else {
//.........这里部分代码省略.........