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"); }
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; }
$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')) {
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; } }
<?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)); }
$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) {
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; }
} } 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';
function resize_image($file_path,$thumb_file_path,$width,$height,$cut=false) { return makethumb($file_path,$thumb_file_path,$width,$height); }
$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();
<?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; } ?>
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) { $p_width = $image_width_p; $p_height = round($ih * $image_width_p / $iw); $result = makethumb($image_file, $image_file_photo, $p_width, $p_height, 0, 0, 0, 0, 0, 0, 0, $sys_config['image_thumb_quality']); } clearstatcache(); if ($iw <= $image_width_p || !$result && !is_file($image_file_photo)) { @copy($image_file_temp, $image_file_photo); } if ($sys_config['watermark_enable']) { $this->watermark($image_file, array('member_info' => $member_info, 'image_thumb_quality' => $sys_config['image_thumb_quality'])); clearstatcache(); if (!is_file($image_file)) { @copy($image_file_temp, $image_file); } } $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', $image_file, '', $ftp_key); if ($ftp_result > 0) { ftpcmd('upload', $image_file_small, '', $ftp_key); ftpcmd('upload', $image_file_photo, '', $ftp_key); jio()->DeleteFile($image_file); jio()->DeleteFile($image_file_small); jio()->DeleteFile($image_file_photo); $image_file_small = $site_url . '/' . str_replace('./', '', $image_file_small); } } $image_size = filesize($image_file); $name = addslashes(basename($_FILES[$pic_field]['name'])); $p = array('id' => $image_id, 'site_url' => $site_url, 'photo' => $image_file, 'name' => $name, 'filesize' => $image_size, 'width' => $image_width, 'height' => $image_height, 'tid' => max(0, (int) $p['tid']), 'image_url' => $pic_url); $this->modify($p); jio()->DeleteFile($image_file_temp); $p['src'] = $image_file_small; $this->upload_count += 1; return $p; }
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); }
<?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)); }
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 { fclose($handle); } } return -3; }
function VipIntro() { if (MEMBER_ID < 1) { $this->Messager("请先<a href='index.php?mod=login'>点此登录</a>或者<a href='index.php?mod=member'>点此注册</a>一个帐号", 'index.php?mod=member&code-login', 3); } $member = jsg_member_info(MEMBER_ID); $notUpToStandardVipConditions = $this->CheckVipCpnditions(); if (!$notUpToStandardVipConditions) { Load::logic('validate_category'); $this->ValidateLogic = new ValidateLogic($this); $is_card_pic = $this->Config['card_pic_enable']['is_card_pic']; if ($this->Post['postFlag']) { $validate_info = $this->Post['validate_remark']; $validate_info = trim(strip_tags((string) $validate_info)); if (empty($validate_info)) { $this->Messager('认证说明不能为空', -1); } $f_rets = filter($validate_info); if ($f_rets && $f_rets['error']) { $this->Messager($f_rets['msg'], -1); } $category_fid = $this->Post['category_fid']; $category_id = $this->Post['category_id']; if (empty($category_fid) || empty($category_id)) { $this->Messager('认证类别不能为空', -1); } $city = (int) $this->Post['city']; if ($city < 1) { $this->Messager('请填写所在区域', -1); } $validate_true_name = strip_tags(jpost('validate_true_name', 'txt')); if (empty($validate_true_name)) { $this->Messager('真实姓名不能为空', -1); } $validate_card_type = jpost('validate_card_type', 'txt'); if (empty($validate_card_type)) { $this->Messager('证件类型不能为空', -1); } $validate_card_id = strip_tags(jpost('validate_card_id', 'txt')); if (empty($validate_card_id)) { $this->Messager('证件号码不能为空', -1); } if ($is_card_pic) { $field = 'card_pic'; if (empty($_FILES) || !$_FILES[$field]['name']) { $this->Messager("请上传证件图片", -1); } } $data = array('uid' => MEMBER_ID, 'category_fid' => (int) $this->Post['category_fid'], 'category_id' => (int) $this->Post['category_id'], 'province' => jpost('province', 'txt'), 'city' => jpost('city', 'txt'), 'is_audit' => 0, 'dateline' => TIMESTAMP); $return_info = $this->ValidateLogic->Member_Validate_Add($data); if ($return_info['ids']) { if ($is_card_pic) { $image_id = $return_info['ids']; if (empty($_FILES) || !$_FILES[$field]['name']) { $this->Messager("请上传证件图片", -1); } $image_path = RELATIVE_ROOT_PATH . 'images/' . $field . '/' . $image_id . '/'; $image_name = $image_id . "_o.jpg"; $image_file = $image_path . $image_name; $image_file_small = $image_path . $image_id . "_s.jpg"; if (!is_dir($image_path)) { jio()->MakeDir($image_path); } jupload()->init($image_path, $field, true); jupload()->setNewName($image_name); $result = jupload()->doUpload(); if ($result) { $result = is_image($image_file); } if (!$result) { $this->Messager("上传图片失败", -1); } list($w, $h) = getimagesize($image_file); if ($w > 601) { $tow = 599; $toh = round($tow * ($h / $w)); $result = makethumb($image_file, $image_file, $tow, $toh); if (!$result) { jio()->DeleteFile($image_file); js_alert_output('大图片缩略失败'); } } $image_file = addslashes($image_file); $validate_card_pic = " `validate_card_pic` = '{$image_file}' ,"; } $sql = "update " . TABLE_PREFIX . "memberfields\r\n\t\t\t\t\t\tset {$validate_card_pic}\r\n\t\t\t\t\t\t\t`validate_remark` = '" . jpost('validate_remark', 'txt') . "' ,\r\n\t\t\t\t\t\t\t`validate_true_name`='" . jpost('validate_true_name', 'txt') . "' ,\r\n\t\t\t\t\t\t\t`validate_card_id` = '" . jpost('validate_card_id', 'txt') . "' ,\r\n\t\t\t\t\t\t\t`validate_card_type` = '" . jpost('validate_card_type', 'txt') . "'\r\n\t\t\t\t\t\twhere `uid`='" . MEMBER_ID . "'"; $this->DatabaseHandler->Query($sql); if ($notice_to_admin = $this->Config['notice_to_admin']) { $message = "用户" . MEMBER_NICKNAME . "申请了身份认证,<a href='admin.php?mod=vipintro&code=vipintro_manage' target='_blank'>点击</a>进入审核。"; $pm_post = array('message' => $message, 'to_user' => str_replace('|', ',', $notice_to_admin)); $admin_info = DB::fetch_first('select `uid`,`username`,`nickname` from `' . TABLE_PREFIX . 'members` where `uid` = 1'); load::logic('pm'); $PmLogic = new PmLogic(); $PmLogic->pmSend($pm_post, $admin_info['uid'], $admin_info['username'], $admin_info['nickname']); } } if ($return_info['msg_info']) { $this->Messager($return_info['msg_info']); } } $sql = "select * from `" . TABLE_PREFIX . "validate_category_fields` where `uid`='" . MEMBER_ID . "' "; $query = $this->DatabaseHandler->Query($sql); $validate_info = $query->GetRow(); $sql = "select * from `" . TABLE_PREFIX . "memberfields` where `uid`='" . MEMBER_ID . "'"; $query = $this->DatabaseHandler->Query($sql); $memberfields = $query->GetRow(); $memberfields['validate_card_type'] = $memberfields['validate_card_type'] ? $memberfields['validate_card_type'] : '未知'; $dateline = date('Y-m-d', $validate_info['dateline']); if (empty($validate_info['uid']) || $validate_info['is_audit'] == -1) { if (!$memberfields) { $memberfields = array(); $memberfields['uid'] = $member['uid']; $sql = "insert into `" . TABLE_PREFIX . "memberfields` (`uid`) values ('{$member['uid']}')"; $this->DatabaseHandler->Query($sql); } $_options = array('0' => array('name' => '请选择', 'value' => '0'), '身份证' => array('name' => '身份证', 'value' => '身份证'), '学生证' => array('name' => '学生证', 'value' => '学生证'), '军官证' => array('name' => '军官证', 'value' => '军官证'), '护照' => array('name' => '护照', 'value' => '护照'), '营业执照' => array('name' => '营业执照', 'value' => '营业执照'), '官方公函' => array('name' => '官方公函', 'value' => '官方公函'), '其他' => array('name' => '其他', 'value' => '其他')); $select_value = $memberfields['validate_card_type'] ? $memberfields['validate_card_type'] : "身份证"; $validate_card_type_select = jform()->Select('validate_card_type', $_options, $select_value); $query = $this->DatabaseHandler->Query("select * from " . TABLE_PREFIX . "common_district where `upid` = '0' order by list"); while ($rsdb = $query->GetRow()) { $province[$rsdb['id']]['value'] = $rsdb['id']; $province[$rsdb['id']]['name'] = $rsdb['name']; if ($member['province'] == $rsdb['name']) { $province_id = $rsdb['id']; } } $province_list = jform()->Select("province", $province, $province_id, "onchange=\"changeProvince();\""); $member_city = DB::fetch_first("SELECT * FROM " . DB::table('common_district') . " WHERE `name`='{$member['city']}'"); } $where_list = " `category_id` = '' "; $query = DB::query("SELECT *\r\n\t\t\t\t\t\t\tFROM " . DB::table('validate_category') . "\r\n\t\t\t\t\t\t\twhere {$where_list} ORDER BY id ASC"); $category_list = array(); while ($value = DB::fetch($query)) { $category_list[] = $value; } if ($this->Post['category_fid']) { $sub_category_list = $this->ValidateLogic->Small_CategoryList($this->Post['category_fid']); } } $this->Title = "{$this->Config['site_name']}身份验证"; include template('other/topic_vip'); }
require_once './image_conver.php'; if (!empty($_FILES)) { $dirid = isset($_POST["dirid"]) ? $_POST["dirid"] : ""; $kind = isset($_POST["kind"]) ? $_POST["kind"] : ""; $tempFile = $_FILES['Filedata']['tmp_name']; //$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'.$mbid. '/'; $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . DIRECTORY_SEPARATOR; $small_targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . DIRECTORY_SEPARATOR; $middle_targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . DIRECTORY_SEPARATOR; $lv1_targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . DIRECTORY_SEPARATOR; $lv2_targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . DIRECTORY_SEPARATOR; $lv3_targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . DIRECTORY_SEPARATOR; //檔案別名 //$real_filename = md5(uniqid()); //$file_ext = substr($_FILES['Filedata']['name'],strpos($_FILES['Filedata']['name'],".")); //$targetFiletmp = str_replace('//','/',$targetPath) . 'lvX_'.$real_filename.''.$file_ext; //$targetFile = str_replace('//','/',$targetPath) . $real_filename.$file_ext; $targetFiletmp = str_replace('//', '/', $targetPath) . 'lvX_' . $_FILES['Filedata']['name']; $targetFile = str_replace('//', '/', $targetPath) . $_FILES['Filedata']['name']; move_uploaded_file($tempFile, $targetFile); //縮圖處理 if ('product' == $kind) { //商品管理 makethumb($targetFile, str_replace('//', '/', $lv1_targetPath) . 'lv1_' . $_FILES['Filedata']['name'], '60', '45', false); makethumb($targetFile, str_replace('//', '/', $lv2_targetPath) . 'lv2_' . $_FILES['Filedata']['name'], '100', '75', false); makethumb($targetFile, str_replace('//', '/', $lv3_targetPath) . 'lv3_' . $_FILES['Filedata']['name'], '300', '230', false); makethumb($targetFile, str_replace('//', '/', $lv4_targetPath) . 'lv4_' . $_FILES['Filedata']['name'], '600', '460', false); makethumb($targetFile, $targetFile, 0, 0, true); } echo "1"; }
public function cutProfile() { $w = (int) $this->Post['w']; $h = (int) $this->Post['h']; $x = (int) $this->Post['x']; $y = (int) $this->Post['y']; $image_path = RELATIVE_ROOT_PATH . 'images/temp/profile/' . face_path(MEMBER_ID); $image_name = MEMBER_ID . "_o.jpg"; $image_file = $image_path . $image_name; if (!$image_file) { if ($this->Get['home']) { echo '<script>parent.show_message("剪切错误!请重新上传图片");parent.closeDialog("showuploadform");</script>'; exit; } else { $this->Messager("剪切错误!请重新上传图片"); } } $member = $this->_member(); $image_thumb_file = RELATIVE_ROOT_PATH . 'images/profile/' . face_path($member['uid']) . "_o.jpg"; if (!is_dir($image_thumb_dir = dirname($image_thumb_file))) { jmkdir($image_thumb_dir); } list($w_src, $h_src) = getimagesize($image_file); if (!$w_src) { if ($this->Get['home']) { echo '<script>parent.show_message("剪切图片已不存在!");parent.closeDialog("showuploadform");</script>'; exit; } else { $this->Messager("剪切图片已不存在", jurl('index.php?mod=settings&code=profile')); } } if (!$w || !$h) { if ($w_src < 750) { $w = $w_src; $h = (int) ($w * (5 / 16)); } else { $w = 750; $h = (int) ($w * (5 / 16)); } } if ($w_src > 750) { $bili = $w_src / 750; round($w * $bili); $result = makethumb($image_file, $image_thumb_file, round($w * $bili), round($h * $bili), 0, 0, round($x * $bili), round($y * $bili), round($w * $bili), round($h * $bili)); if ($result) { jio()->DeleteFile($image_file); } } else { $result = makethumb($image_file, $image_thumb_file, $w, $h, 0, 0, $x, $y, $w, $h); if ($result) { jio()->DeleteFile($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_thumb_file, '', $ftp_key); if ($ftp_result > 0) { jio()->DeleteFile($image_thumb_file); $image_thumb_file = $site_url . '/' . str_replace('./', '', $image_thumb_file); } } if ($result) { $sql = "update `" . TABLE_PREFIX . "members` set profile_image='" . $image_thumb_file . "' where `uid`='" . MEMBER_ID . "'"; $this->DatabaseHandler->Query($sql); if ($this->Get['home']) { echo '<script>parent.show_message("已保存!");parent.location.replace(parent.location.href);parent.closeDialog("showuploadform");</script>'; exit; } else { $this->Messager("已保存", jurl('index.php?mod=settings&code=profile')); } } else { if ($this->Get['home']) { echo '<script>parent.show_message("保存失败!");parent.closeDialog("showuploadform");</script>'; exit; } else { $this->Messager("保存失败", jurl('index.php?mod=settings&code=profile')); } } }
function Face() { if (MEMBER_ID < 1) { js_alert_output("请先登录或者注册一个帐号", 'alert'); } $uid = jget('uid', 'int', 'G'); $uid = $uid ? $uid : MEMBER_ID; $member = jsg_member_info($uid); if ('admin' != MEMBER_ROLE_TYPE) { if (!$this->Config['edit_face_enable'] && $member['__face__']) { js_alert_output('本站不允许用户修改头像。', 'alert'); } if ($uid != MEMBER_ID) { js_alert_output('您没有权限修改此头像'); } } $field = 'face'; $temp_img_size = intval($_FILES[$field]['size'] / 1024); if ($temp_img_size >= 2048) { js_alert_output('图片文件过大,2MB以内', 'alert'); } $type = trim(strtolower(end(explode(".", $_FILES[$field]['name'])))); if ($type != 'gif' && $type != 'jpg' && $type != 'png' && $type != 'jpeg') { js_alert_output('图片格式不对', 'alert'); } $image_name = substr(md5($_FILES[$field]['name']), -10) . ".{$type}"; $image_path = RELATIVE_ROOT_PATH . 'images/temp/face_images/' . $image_name[0] . '/'; $image_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(); if ($result) { $result = is_image($image_file); } if (!$result) { js_alert_output('图片上载失败', 'alert'); } list($w, $h) = getimagesize($image_file); if ($w > 601) { $tow = 599; $toh = round($tow * ($h / $w)); $result = makethumb($image_file, $image_file, $tow, $toh); if (!$result) { jio()->DeleteFile($image_file); js_alert_output('大图片缩略失败', 'alert'); } } $up_image_path = addslashes($image_file); echo "<script language='Javascript'>"; if ($this->Post['temp_face']) { echo "window.parent.location.href='{$this->Config[site_url]}/index.php?mod=settings&code=face&temp_face={$up_image_path}'"; } else { echo "parent.document.getElementById('cropbox').src='{$up_image_path}';"; echo "parent.document.getElementById('img_path').value='{$up_image_path}';"; echo "parent.document.getElementById('temp_face').value='{$up_image_path}';"; echo "parent.document.getElementById('jcrop_init_id').onclick();"; echo "parent.document.getElementById('cropbox_img1').value='{$up_image_path}';"; } echo "</script>"; }
$setsqlarr['tit_b'] = intval($_POST['tit_b']); $setsqlarr['author'] = trim($_POST['author']); $setsqlarr['source'] = trim($_POST['source']); $setsqlarr['focos'] = intval($_POST['focos']); $setsqlarr['is_display'] = intval($_POST['is_display']); $setsqlarr['is_url'] = trim($_POST['is_url']); $setsqlarr['seo_keywords'] = $_POST['seo_keywords']; $setsqlarr['seo_description'] = $_POST['seo_description']; $setsqlarr['article_order'] = intval($_POST['article_order']); if ($_FILES['Small_img']['name']) { $upfiles_dir .= date("Y/m/d/"); make_dir($upfiles_dir); $Small_img = _asUpFiles($upfiles_dir, "Small_img", 1024 * 2, 'jpg/gif/png', true); $makefile = $upfiles_dir . $Small_img; make_dir($thumb_dir . date("Y/m/d/")); makethumb($makefile, $thumb_dir . date("Y/m/d/"), $thumbwidth, $thumbheight); $setsqlarr['Small_img'] = date("Y/m/d/") . $Small_img; } $setsqlarr['parentid'] = get_article_parentid($setsqlarr['type_id']); $setsqlarr['subsite_id'] = intval($_POST['subsite_id']); $link[0]['text'] = "返回文章列表"; $link[0]['href'] = '?act=newslist'; $link[1]['text'] = "查看已修改文章"; $link[1]['href'] = "?act=article_edit&id=" . $id; write_log("修改id为" . $id . "的文章信息", $_SESSION['admin_name'], 3); !$db->updatetable(table('article'), $setsqlarr, " id=" . $id . "") ? adminmsg("修改失败!", 0) : adminmsg("修改成功!", 2, $link); } elseif ($act == 'del_img') { check_token(); $id = intval($_GET['id']); $img = $_GET['img']; $img = str_replace("../", "***", $img);
$setsqlarr['img'] = _asUpFiles($up_dir, "img", 800, 'gif/jpg/bmp/png/jpeg', true); if ($setsqlarr['img']) { // 新增打水印 if (extension_loaded('gd')) { include_once QISHI_ROOT_PATH . 'include/watermark.php'; $font_dir = QISHI_ROOT_PATH . "data/contactimgfont/cn.ttc"; if (file_exists($font_dir)) { $tpl = new watermark(); $tpl->img($up_dir . $setsqlarr['img'], gbk_to_utf8($_CFG['site_name']), $font_dir, 13, 0); } } $img_src = $up_dir . $setsqlarr['img']; $thumb_dir = "../../data/companyimg/thumb/" . $datedir; make_dir($thumb_dir); makethumb($img_src, $up_dir, 600, 600); makethumb($img_src, $thumb_dir, 295, 165); $setsqlarr['uid'] = intval($_SESSION['uid']); $setsqlarr['company_id'] = $company_profile['id']; $setsqlarr['addtime'] = time(); $setsqlarr['title'] = trim($_POST['title']); $setsqlarr['img'] = $datedir . $setsqlarr['img']; if ($company_profile['audit'] == "1") { $setsqlarr['audit'] = intval($_CFG['audit_verifycom_addimg']); } else { $setsqlarr['audit'] = intval($_CFG['audit_unexaminedcom_addimg']); } $img_id = $db->inserttable(table('company_img'), $setsqlarr, true); if ($img_id > 0) { // 上传企业风采 获得积分 $rule = get_cache('points_rule'); if ($rule['company_img_points']['value'] > 0) {
function get_photo_list($param) { $sql_where = ''; $uid = max(0, (int) $param['uid']); $cache_key = "{$uid}-get_photo_list-" . md5(serialize($param)); if (false === ($info = cache_db('get', $cache_key))) { if ($uid > 0) { $uids = get_buddyids($uid, $GLOBALS['_J']['config']['topic_myhome_time_limit']); if ($uids) { $sql_where = " AND t.uid in(" . jimplode($uids) . ") "; } else { return array(); } } $total_photo = (int) $param['count']; if ($total_photo < 1) { if ($param['vip']) { $total_photo = DB::result_first("select count(1) as `total` from " . DB::table('topic_image') . " t left join " . DB::table('members') . " m on m.uid=t.uid where t.tid>0 and m.validate='1'" . $sql_where); } else { $total_photo = DB::result_first("SELECT COUNT(*) FROM " . DB::table('topic_image') . " AS t WHERE t.tid > 0 " . $sql_where); } } $info = false; $limit_sql = ''; $photo_i = 0; $topic_list = array(); $user_lists = array(); if ($total_photo > 0) { if ($param['perpage']) { $page_arr = page($total_photo, $param['perpage'], $param['page_url'], array('return' => 'array')); $limit_sql = $page_arr['limit']; } else { if ($param['limit']) { $limit_sql = ' LIMIT ' . $param['limit']; } elseif ($param['count']) { $limit_sql = ' LIMIT ' . $param['count']; } } if ($param['vip']) { $query = DB::query("SELECT t.id,t.tid,t.uid,t.name,t.width,t.height,t.dateline,tr.content,tr.content2,tr.forwards,tr.replys,tr.digcounts\r\n\t\t\t\t\t\t\t\t\tFROM " . DB::table('topic_image') . " AS t\r\n\t\t\t\t\t\t\t\t\tLEFT JOIN " . DB::table('topic') . " AS tr\r\n\t\t\t\t\t\t\t\t\tON t.tid = tr.tid\r\n\t\t\t\t\t\t\t\t\tleft join " . DB::table('members') . " as m\r\n\t\t\t\t\t\t\t\t\ton m.uid=t.uid\r\n\t\t\t\t\t\t\t\t\tWHERE t.tid > 0 and m.validate='1' " . $sql_where . "\r\n\t\t\t\t\t\t\t\t\tORDER BY t.id DESC\r\n\t\t\t\t\t\t\t\t\t{$limit_sql} "); } else { $query = DB::query("SELECT t.id,t.tid,t.uid,t.name,t.width,t.height,t.dateline,tr.content,tr.content2,tr.forwards,tr.replys,tr.digcounts\r\n\t\t\t\t\t\t\t\t\tFROM " . DB::table('topic_image') . " AS t\r\n\t\t\t\t\t\t\t\t\tLEFT JOIN " . DB::table('topic') . " AS tr\r\n\t\t\t\t\t\t\t\t\tON t.tid = tr.tid\r\n\t\t\t\t\t\t\t\t\tWHERE t.tid > 0 " . $sql_where . "\r\n\t\t\t\t\t\t\t\t\tORDER BY t.id DESC\r\n\t\t\t\t\t\t\t\t\t{$limit_sql} "); } while ($value = DB::fetch($query)) { $value['content'] .= $value['content2']; $value['content'] = jhtmlspecialchars(strip_tags($value['content'])); if (!is_file(topic_image($value['id'], 'photo', 1))) { $image_file = RELATIVE_ROOT_PATH . 'images/topic/' . face_path($value['id']) . $value['id'] . "_o.jpg"; $image_file_photo = RELATIVE_ROOT_PATH . 'images/topic/' . face_path($value['id']) . $value['id'] . "_p.jpg"; if ($value['width'] > 280) { $p_width = 280; $p_height = round($value['height'] * 280 / $value['width']); $result = makethumb($image_file, $image_file_photo, $p_width, $p_height); } if ($value['width'] <= 280 || !$result && !is_file($image_file_photo)) { @copy($image_file, $image_file_photo); } } $value['photo'] = topic_image($value['id'], 'photo', 0); $value['height'] = $value['width'] > 280 ? round($value['height'] * 280 / $value['width']) : $value['height']; $value['width'] = $value['width'] > 280 ? 280 : $value['width']; $value['dateline'] = my_date_format2($value['dateline']); if (false != strpos($value['content'], '</U>')) { $value['content'] = preg_replace('#\\<U(.*?)\\>(.*?)\\</U\\>#', '<a href="\\2" target="_blank">Click Here</a>', $value['content']); } if (false !== strpos($value['content'], 'http:/' . '/')) { $value['content'] = preg_replace('~(http:/' . '/[a-z0-9-\\.\\?\\=&;_@/%#]+?)\\s+~i', '<a href="\\1" target="_blank">Click Here</a> ', $value['content']); $value['content'] = preg_replace("|\\s*http:/" . "/[a-z0-9-\\.\\?\\=&;_@/%#]*\$|sim", "", $value['content']); } $topic_list[] = $value; } if ($topic_list) { $topic_list_count = count($topic_list); $topic_list = $this->TopicLogic->MakeAll($topic_list, 0); $info = array('list' => $topic_list, 'count' => $param['count'] ? $topic_list_count : $total_photo, 'page' => $page_arr); } } cache_db('set', $cache_key, $info, $uid > 0 ? 3600 : 600); } if ($info['count'] > 0 && $info['list']) { if ($GLOBALS['_J']['config']['is_topic_user_follow'] && !$GLOBALS['_J']['disable_user_follow']) { $info['list'] = buddy_follow_html($info['list'], 'uid', 'follow_html2'); } $pi = 0; $list = array(); foreach ($info['list'] as $v) { $list[$pi++ % 3][] = $v; } $info['list'] = $list; } return $info; }
function DoModify() { $medal_id = jget('medal_id', 'int'); $sql = "SELECT * FROM " . TABLE_PREFIX . 'medal' . " WHERE id='{$medal_id}'"; $query = $this->DatabaseHandler->Query($sql); $medal_info = $query->GetRow(); $error_msg = ''; $field = 'medal'; $datetime = time(); $medal_name = $this->Post['medal_name']; $medal_depict = $this->Post['medal_depict']; $checkvalue = array('type' => $this->Post['type'], 'day' => $this->Post['day'], 'endday' => $this->Post['endday'], 'tagname' => $this->Post['tagname'], 'invite' => $this->Post['invite'], 'fans' => $this->Post['fans'], 'sign' => $this->Post['sign']); $checkvalue = serialize($checkvalue); $medal_name = $this->Post['medal_name']; $medal_depict = $this->Post['medal_depict']; if (empty($_FILES) || !$_FILES[$field]['name']) { $image_file = $medal_info['medal_img']; $image_file_small = $medal_info['medal_img2']; } else { jio()->DeleteFile($medal_info['medal_img']); jio()->DeleteFile($medal_info['medal_img2']); $image_path = RELATIVE_ROOT_PATH . 'images/' . $field . '/' . $datetime . '/'; $image_name = $medal_info['id'] . "_o.jpg"; $image_file = $image_path . $image_name; $image_file_small = $image_path . $medal_info['id'] . "_s.jpg"; if (!is_dir($image_path)) { jio()->MakeDir($image_path); } jupload()->init($image_path, $field, true); jupload()->setNewName($image_name); $result = jupload()->doUpload(); if ($result) { $result = is_image($image_file); } if (!$result) { $this->Messager("上传图片失败", "admin.php?mod=medal"); } makethumb($image_file, $image_file_small, 60, 60, 0, 0, 0, 0, 0, 0); image_thumb($image_file, $image_file, 60, 60); image_thumb($image_file_small, $image_file_small, 60, 60); $image_file = addslashes($image_file); $image_file_small = addslashes($image_file_small); $img = grayJpeg($image_file_small); imagejpeg($img, $image_file_small, 100); imagedestroy($img); } $sql = "update `" . TABLE_PREFIX . "medal` set `medal_img`='{$image_file}' ,`medal_img2` = '{$image_file_small}', `medal_name`='{$medal_name}' ,`medal_depict` = '{$medal_depict}' , `conditions` = '{$checkvalue}' where `id`='" . (int) $this->Post['medal_id'] . "'"; $this->DatabaseHandler->Query($sql); if ($error_msg) { $this->Messager($error_msg); } $this->Messager("编辑成功", 'admin.php?mod=medal'); }
function face($p = array(), $modify = 1) { global $_J; $pic_file = $p['pic_file'] && is_image($p['pic_file']) ? $p['pic_file'] : ''; $pic_url = $p['pic_url'] && false !== strpos($p['pic_url'], ':/' . '/') ? $p['pic_url'] : ''; $p['pic_field'] = $p['pic_field'] ? $p['pic_field'] : 'face'; $pic_field = $p['pic_field'] && $_FILES[$p['pic_field']] ? $p['pic_field'] : ''; if (!$pic_file && !$pic_url && !$pic_field) { return jerror('pic is empty', 0); } $uid = $p['uid'] ? (int) $p['uid'] : MEMBER_ID; if ($uid < 1) { return jerror('请指定一个用户ID', -1); } $member = jsg_member_info($uid); if (!$member) { return jerror('用户已经不存在了', -2); } if (!$_J['config']['edit_face_enable'] && $member['__face__'] && 'admin' != MEMBER_ROLE_TYPE) { return jerror('不允许用户修改头像', -3); } $src_x = max(0, (int) $p['x']); $src_y = max(0, (int) $p['y']); $src_w = max(0, (int) $p['w']); $src_h = max(0, (int) $p['h']); $image_path = RELATIVE_ROOT_PATH . 'images/' . ($_J['config']['face_verify'] ? 'face_verify' : 'face') . '/' . face_path($uid); $image_name = $uid . '_b.jpg'; $image_file = $image_path . $image_name; $image_file_small = $image_path . $uid . '_s.jpg'; $image_file_temp = $image_path . $uid . '_t.jpg'; if (!is_dir($image_path)) { jmkdir($image_path); } if (!$modify && is_image($image_file)) { return jerror('头像已经存在了', -4); } if ($pic_file) { $src_file = $pic_file; } elseif ($pic_url) { $image_data = dfopen($pic_url, 99999999, '', '', true, 3, $_SERVER['HTTP_USER_AGENT']); if ($image_data) { jio()->WriteFile($image_file, $image_data); if (is_image($image_file)) { $src_file = $image_file; } } } elseif ($pic_field) { jupload()->init($image_path, $pic_field, true, false); jupload()->setNewName($image_name); $result = jupload()->doUpload(); if ($result && is_image($image_file)) { $src_file = $image_file; } } if (!is_image($src_file)) { return jerror('源头像不存在了,请上传正确的图片文件', -5); } $w = max(50, min(128, $src_w > 50 ? $src_w : 200)); $make_result = makethumb($src_file, $image_file, $w, $w, 0, 0, $src_x, $src_y, $src_w, $src_h); $make_result = makethumb($src_file, $image_file_small, 50, 50, 0, 0, $src_x, $src_y, $src_w, $src_h); $face_url = ''; if ($_J['config']['ftp_on']) { $ftp_key = randgetftp(); $get_ftps = jconf::get('ftp'); $face_url = $get_ftps[$ftp_key]['attachurl']; $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key); if ($ftp_result > 0) { ftpcmd('upload', $image_file_small, '', $ftp_key); jio()->DeleteFile($image_file); jio()->DeleteFile($image_file_small); } } if ($_J['config']['face_verify']) { $count = DB::result_first("SELECT COUNT(1) FROM " . DB::table('members_verify') . " WHERE `uid`='{$uid}'"); if ($count) { $sql = "update `" . TABLE_PREFIX . "members_verify` set `face_url`='{$face_url}', `face`='{$image_file_small}' where `uid`='{$uid}'"; } else { $sql = "insert into `" . TABLE_PREFIX . "members_verify` (`uid`,`nickname`,`face_url`,`face`) values('{$uid}','{$member['nickname']}','{$face_url}','{$image_file_small}')"; } DB::query($sql); if ($_J['config']['notice_to_admin']) { $pm_post = array('message' => $member['nickname'] . " 修改了头像进入审核,<a href='admin.php?mod=verify&code=fs_verify' target='_blank'>点击</a>进入审核。", 'to_user' => str_replace('|', ',', $_J['config']['notice_to_admin'])); $admin_info = jsg_member_info(1); jlogic('pm')->pmSend($pm_post, $admin_info['uid'], $admin_info['username'], $admin_info['nickname']); } } else { $sql = "update `" . TABLE_PREFIX . "members` set `face_url`='{$face_url}', `face`='{$image_file_small}' where `uid`='{$uid}'"; DB::query($sql); if ($_J['config']['extcredits_enable'] && $uid > 0) { update_credits_by_action('face', $uid); } } return true; }
$datedir = date("Y/m/d/"); $up_dir = "../../data/photo/" . $datedir; make_dir($up_dir); $setsqlarr['img'] = _asUpFiles($up_dir, "resume_img", 800, 'gif/jpg/bmp/png/jpeg', true); if ($setsqlarr['img']) { // 新增打水印 if (extension_loaded('gd')) { include_once QISHI_ROOT_PATH . 'include/watermark.php'; $font_dir = QISHI_ROOT_PATH . "data/contactimgfont/cn.ttc"; if (file_exists($font_dir)) { $tpl = new watermark(); $tpl->img($up_dir . $setsqlarr['img'], gbk_to_utf8($_CFG['site_name']), $font_dir, 13, 0); } } $img_src = $up_dir . $setsqlarr['resume_img']; makethumb($img_src, $up_dir, 600, 600); $setsqlarr['uid'] = $uid; $setsqlarr['resume_id'] = $pid; $setsqlarr['addtime'] = time(); $setsqlarr['img'] = $datedir . $setsqlarr['img']; $img_id = $db->inserttable(table('resume_img'), $setsqlarr, true); if ($img_id > 0) { perfect_resume($_SESSION['uid'], $_SESSION['username'], $pid, 1); $data['save_url'] = $setsqlarr['img']; $data['url'] = $setsqlarr['img']; $data['title'] = $setsqlarr['title']; $data['addtime'] = date('Y-m-d', $setsqlarr['addtime']); $data['id'] = $img_id; $json_encode = json_encode($data); exit($json_encode); } else {
exit; /* --// some extra images */ /* yellow folder */ // $img = 'R0lGODlhEgAQAOfRAAAAAAAAAAAAAAAAAP//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMzMzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJmZmQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///wAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////yH5BAEKAP8ALAAAAAASABAAAAhhAP8JHEiwYMEqCBEaNFhFBQGHKqosHNjwocWICRVSjMaxo0eOVaxtvEjSYciNEEs+PCmwSjSVKVn+c5my5kqRLV/ajIlzZrSdF2W6hGlRaMajGXv+s8a0qVOnE6NKnfovIAA7'; /* binary image */ // $img = 'R0lGODlhEAAQAOMAAISGhMbHxgAAAP///wAAhAD//wAA////AP///////////////////////////////yH5BAEKAAgALAAAAAAQABAAAARcEMkJqq0zg8B7AEKGAENpfqBIEiyLhtpAFEb9SlhF1HYVkgMggGe4kTY+z0cAGFkCgqg06huVBATmBRnaGbACk6nqJUBBh6ixtNFWOClrEDqVUtgwwCE+mUr8GREAOw=='; /* blank document */ // $img = 'R0lGODlhEgAQAMIDAMbDxoSChAAAAP///////////////////yH5BAEKAAQALAAAAAASABAAAAM6SLHc9PCFQSsFIcJpKxiZxnWDYAoiaQFoNKpsql7tNtPyHLv3sNu3n6QnVBBrwyBSAWg6n8WTdIpMAAA7'; /* //-- */ } function url_encode($url) { return eregi_replace('[+]', '%20', urlencode($url)); } switch ($_GET['p']) { case "source": showsource($_GET['file']); break; case "thumb": makethumb(base64_decode($_GET['file']), $GLOBALS['CONFIG']['THUMB_HEIGHT'], $GLOBALS['CONFIG']['THUMB_WIDTH']); break; case "mime": getmimefile($_GET['type']); break; case "logo": getmimefile('logo'); break; default: listdir($dir); break; }
$smarty->display('member_personal/personal_avatars.htm'); } elseif ($act == 'avatars_ready') { require_once QISHI_ROOT_PATH . 'include/cut_upload.php'; !$_FILES['avatars']['name'] ? showmsg('请上传图片!', 1) : ""; $up_dir_original = "../../data/avatar/original/"; $up_dir_100 = "../../data/avatar/100/"; $up_dir_48 = "../../data/avatar/48/"; $up_dir_thumb = "../../data/avatar/thumb/"; make_dir($up_dir_original . date("Y/m/d/")); make_dir($up_dir_100 . date("Y/m/d/")); make_dir($up_dir_48 . date("Y/m/d/")); make_dir($up_dir_thumb . date("Y/m/d/")); $setsqlarr['avatars'] = _asUpFiles($up_dir_original . date("Y/m/d/"), "avatars", 500, 'gif/jpg/bmp/png', true); $setsqlarr['avatars'] = date("Y/m/d/") . $setsqlarr['avatars']; if ($setsqlarr['avatars']) { makethumb($up_dir_original . $setsqlarr['avatars'], $up_dir_thumb . date("Y/m/d/"), 445, 300); // makethumb($up_dir_original.$setsqlarr['avatars'],$up_dir_100.date("Y/m/d/"),100,100); // makethumb($up_dir_original.$setsqlarr['avatars'],$up_dir_48.date("Y/m/d/"),48,48); $wheresql = " uid='" . $_SESSION['uid'] . "'"; write_memberslog($_SESSION['uid'], 2, 1006, $_SESSION['username'], "修改了个人头像"); $db->updatetable(table('members'), $setsqlarr, $wheresql) ? exit($setsqlarr['avatars']) : showmsg('保存失败!', 1); } else { showmsg('保存失败!', 1); } } elseif ($act == 'avatars_save') { $savePath = "../../data/avatar/100/"; //图片存储路径 $savePathThumb = "../../data/avatar/48/"; //图片存储路径 $savePicName = time(); //图片存储名称
} $smarty->assign('title', '企业LOGO - 企业会员中心 - ' . $_CFG['site_name']); $smarty->assign('company_profile', $company_profile); $smarty->assign('rand', rand(1, 100)); $smarty->display('member_company/company_logo.htm'); } elseif ($act == 'company_logo_save') { require_once QISHI_ROOT_PATH . 'include/upload.php'; !$_FILES['logo']['name'] ? showmsg('请上传图片!', 1) : ""; $uplogo_dir = "../../data/logo/" . date("Y/m/d/"); make_dir($uplogo_dir); $setsqlarr['logo'] = _asUpFiles($uplogo_dir, "logo", $_CFG['logo_max_size'], 'gif/jpg/bmp/png', $_SESSION['uid']); if ($setsqlarr['logo']) { $setsqlarr['logo'] = date("Y/m/d/") . $setsqlarr['logo']; $logo_src = "../../data/logo/" . $setsqlarr['logo']; $thumb_dir = $uplogo_dir; makethumb($logo_src, $thumb_dir, 300, 110); //生成缩略图 $wheresql = "uid='" . $_SESSION['uid'] . "'"; if (updatetable(table('company_profile'), $setsqlarr, $wheresql)) { $link[0]['text'] = "查看LOGO"; $link[0]['href'] = '?act=company_logo'; write_memberslog($_SESSION['uid'], 1, 8003, $_SESSION['username'], "上传了企业LOGO"); showmsg('上传成功!', 2, $link); } else { showmsg('保存失败!', 1); } } else { showmsg('保存失败!', 1); } } elseif ($act == 'company_logo_del') { $uplogo_dir = "../../data/logo/";
function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name='', $title='', $delsize=0, $from = false) { global $_SGLOBAL, $space, $_SCONFIG, $_SC; if($albumid<0) $albumid = 0; $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)) { $space = getspace($_SGLOBAL['supe_uid']); $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('space')." WHERE uid='$_SGLOBAL[supe_uid]'"); $space = $_SGLOBAL['db']->fetch_array($query); $_SGLOBAL['supe_username'] = addslashes($space['username']); } $_SGLOBAL['member'] = $space; $maxattachsize = checkperm('maxattachsize');//单位MB if($maxattachsize) {//0为不限制 if($space['attachsize'] + $size - $delsize > $maxattachsize + $space['addsize']) { @unlink($newfilename); return -1; } } //检查是否图片 if(function_exists('getimagesize')) { $tmp_imagesize = @getimagesize($newfilename); list($tmp_width, $tmp_height, $tmp_type) = (array)$tmp_imagesize; $tmp_size = $tmp_width * $tmp_height; if($tmp_size > 16777216 || $tmp_size < 4 || empty($tmp_type) || strpos($tmp_imagesize['mime'], 'flash') > 0) { @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 = getstr($title, 200, 1, 1, 1); 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 { $albumid = 0; } $setarr = array( 'albumid' => $albumid, 'uid' => $_SGLOBAL['supe_uid'], 'username' => $_SGLOBAL['supe_username'], '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($from) { $reward = getreward($from, 0); if($reward['credit']) { $setsql = ",credit=credit+$reward[credit]"; } if($reward['experience']) { $setsql .= ",experience=experience+$reward[experience]"; } } $_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')." SET picnum=picnum+1, updatetime='$_SGLOBAL[timestamp]', pic='$file', picflag='1' WHERE 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)); } else { return -4; } } //统计 updatestat('pic'); return $setarr; } else { fclose($handle); } } return -3; }
function uploadPic($field, $category_pic_id) { $image_path = RELATIVE_ROOT_PATH . 'images/' . $field . '/' . face_path($category_pic_id); $image_name = $category_pic_id . "_o.gif"; $image_file = $image_path . $image_name; if (!is_dir($image_path)) { jio()->MakeDir($image_path); } jupload()->init($image_path, $field, true); jupload()->setNewName($image_name); $result = jupload()->doUpload(); if ($result) { $result = is_image($image_file); } if (!$result) { return array('err' => '图片上传失败'); } makethumb($image_file, 16, 16, 0, 0, 0, 0, 0, 0); image_thumb($image_file, $image_file, 16, 16); $image_file = addslashes($image_file); return $image_file; }