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; }
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; } }
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; }
function _parse_url_attach($data, $attach_url) { $__is_attach = false; $uid = $data['uid']; $username = $data['username']; $attach_id = jlogic('attach')->add($uid, $username); $p = array('id' => $attach_id, 'tid' => $data['tid'], 'file_url' => $attach_url); jlogic('attach')->modify($p); $attach_path = RELATIVE_ROOT_PATH . 'data/attachs/topic/' . face_path($attach_id) . '/'; $attach_type = strtolower(end(explode('.', $attach_url))); $attach_name = $attach_id . '.' . $attach_type; $attach_file = $attach_path . $attach_name; if (!is_file($attach_file)) { if (!is_dir($attach_path)) { jio()->MakeDir($attach_path); } if (($temp_attach = dfopen($attach_url)) && jio()->WriteFile($attach_file, $temp_attach) && is_attach($attach_file)) { $attach_size = filesize($attach_file); $site_url = ''; if ($GLOBALS['_J']['config']['ftp_on']) { $ftp_key = randgetftp(); $get_ftps = jconf::get('ftp'); $site_url = $get_ftps[$ftp_key]['attachurl']; $ftp_result = ftpcmd('upload', $attach_file, '', $ftp_key); } $p = array('id' => $attach_id, 'vtid' => $data['id'], 'site_url' => $site_url, 'file' => $attach_file, 'name' => basename($attach_url), 'filesize' => $attach_size, 'filetype' => $attach_type); jlogic('attach')->modify($p); $__is_attach = true; } } if (false === $__is_attach && $attach_id > 0) { jlogic('attach')->delete($attach_id); $attach_id = 0; } return $attach_id; }
public function do_setting() { $wechat = $this->Post['wechat']; $diy_key = $this->Post['diy_key']; $diy_reply = $this->Post['diy_reply']; $delete = $this->Post['delete']; $wechat_conf = jconf::get("wechat"); if ($_FILES['qrcode']['name']) { $image_name = "my_wechat_qrcode.jpg"; $image_path = RELATIVE_ROOT_PATH . 'images/'; $image_file = $image_path . $image_name; jupload()->init($image_path, 'qrcode', true); jupload()->setMaxSize(512); jupload()->setNewName($image_name); $result = jupload()->doUpload(); if ($result) { $result = is_image($image_file); } if (!$result) { unlink($image_file); } image_thumb($image_file, $image_file, 150, 150); if ($this->Config['ftp_on']) { $ftp_key = randgetftp(); $get_ftps = jconf::get('ftp'); $site_url = $get_ftps[$ftp_key]['attachurl']; $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key); if ($ftp_result > 0) { jio()->DeleteFile($image_file); $image_file = $site_url . '/' . str_replace('./', '', $image_file); } } $wechat['my_qrcode'] = $image_file; } else { $wechat['my_qrcode'] = $wechat_conf['my_qrcode']; } $wechat['help_key'] = explode('|', $wechat['help_key']); $wechat['bind_key'] = explode('|', $wechat['bind_key']); $wechat['3g_key'] = explode('|', $wechat['3g_key']); $wechat['wap_key'] = explode('|', $wechat['wap_key']); if ($diy_key && $diy_reply) { $wechat['diy_reply']['diy_key'][] = $diy_key; $temp_key = array_search($diy_key, $wechat['diy_reply']['diy_key']); $wechat['diy_reply']['diy_reply'][$temp_key] = $diy_reply; } if (is_array($delete)) { foreach ($delete as $diy_key_del) { if ($wechat['diy_reply']['diy_key'][$diy_key_del]) { unset($wechat['diy_reply']['diy_key'][$diy_key_del]); } if ($wechat['diy_reply']['diy_reply'][$diy_key_del]) { unset($wechat['diy_reply']['diy_reply'][$diy_key_del]); } } } if ($wechat['on'] && !$wechat['token']) { $this->Messager("开启微信必须设置Token"); } else { $r = jconf::update("wechat_enable", $wechat['on']); $r = jconf::update("wechat_qrcode", $wechat['my_qrcode']); $r = jconf::update("my_wechat", $wechat['mywechat']); $r = jconf::set("wechat", $wechat); $this->Messager("设置成功!"); } }
function qmd_img_list($pic_path = '', $qmd_data) { if (!$pic_path || !$qmd_data) { return ''; } $topic_content1 = cutstr($qmd_data['content'], 43); $topic_content2 = substr($qmd_data['content'], strlen($topic_content1)); $content1 = $this->_entities($topic_content1); $content2 = $this->_entities($topic_content2); $topic_url = $GLOBALS['_J']['config']['site_url']; $topic_date = $this->_entities($qmd_data['dateline']); $nickname = $this->_entities($qmd_data['nickname']); $bg = imagecreatefromjpeg($pic_path); $content_white = imagecolorallocate($bg, 80, 80, 80); $font_white = imagecolorallocate($bg, 125, 125, 125); $url_white = imagecolorallocate($bg, 75, 167, 213); imagettftext($bg, 10, 0, 108, 23, $url_white, $GLOBALS['_J']['config']['qmd_fonts_url'], $nickname); imagettftext($bg, 9, 0, 108, 43, $content_white, $GLOBALS['_J']['config']['qmd_fonts_url'], $content1); if ($content2) { imagettftext($bg, 9, 0, 108, 64, $content_white, $GLOBALS['_J']['config']['qmd_fonts_url'], $content2); } imagettftext($bg, 9, 0, 288, 80, $font_white, $GLOBALS['_J']['config']['qmd_fonts_url'], $topic_date); imagettftext($bg, 9, 0, 108, 94, $url_white, $GLOBALS['_J']['config']['qmd_fonts_url'], $topic_url); $user_src = $qmd_data['face']; if (!is_image($user_src)) { return ''; } list($width, $height, $image_type) = getimagesize($user_src); $user_src_im = null; if (1 == $image_type) { $user_src_im = imagecreatefromgif($user_src); } elseif (3 == $image_type) { $user_src_im = imagecreatefrompng($user_src); } else { $user_src_im = imagecreatefromjpeg($user_src); } if (true === UCENTER_FACE && true === UCENTER) { if ($height <= 60) { $new_face_width = 75; $new_face_height = 75; } else { $new_face_width = round($width / 1.5); $new_face_height = round($height / 1.5); } } else { $new_face_width = 75; $new_face_height = 75; } $thumb = imagecreatetruecolor($new_face_width, $new_face_height); imagecopyresampled($thumb, $user_src_im, 0, 0, 0, 0, $new_face_width, $new_face_height, $width, $height); $box = imagecreatefrompng('./images/kuang.png'); imagecopyresampled($thumb, $box, 0, 0, 0, 0, $new_face_width, $new_face_height, 80, 80); $dst_x = 20; $dst_y = 12; $src_x = 0; $src_y = 0; $alpha = 100; imagecopymerge($bg, $thumb, $dst_x, $dst_y, $src_x, $src_y, $new_face_width, $new_face_height, $alpha); $qmd_file_url = $GLOBALS['_J']['config']['qmd_file_url']; $image_path = $qmd_file_url . face_path($qmd_data['uid']); $image_file = $image_path . $qmd_data['uid'] . '_o.gif'; if (!is_dir($image_path)) { jio()->MakeDir($image_path); } if (function_exists('imagegif')) { imagegif($bg, $image_file); } elseif (function_exists('imagepng')) { imagepng($bg, $image_file); } elseif (function_exists('imagejpeg')) { imagejpeg($bg, $image_file); } else { return ''; } imagedestroy($bg); imagedestroy($thumb); imagedestroy($box); if ($v) { imagedestroy($v); } imagedestroy($user_src_im); jio()->DeleteFile($user_src); $site_url = ''; if ($GLOBALS['_J']['config']['ftp_on']) { $ftp_key = randgetftp(); $get_ftps = jconf::get('ftp'); $site_url = $get_ftps[$ftp_key]['attachurl']; $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key); if ($ftp_result > 0) { jio()->DeleteFile($image_file); $image_file = $site_url . '/' . $image_file; } } $sql = "update `" . TABLE_PREFIX . "members` set `qmd_url`='{$image_file}' where `uid`='" . $qmd_data['uid'] . "' "; DB::query($sql); return $image_file; }
function upload_pic($id) { $image_name = $id . ".png"; $image_path = RELATIVE_ROOT_PATH . 'images/channel/' . face_path($id); $image_file = $image_path . $image_name; if (!is_dir($image_path)) { jio()->MakeDir($image_path); } jupload()->init($image_path, 'image', true); jupload()->setMaxSize(1000); jupload()->setNewName($image_name); $result = jupload()->doUpload(); if ($result) { $result = is_image($image_file); } if (!$result) { unlink($image_file); return false; } else { if ($GLOBALS['_J']['config']['ftp_on']) { $ftp_key = randgetftp(); $get_ftps = jconf::get('ftp'); $site_url = $get_ftps[$ftp_key]['attachurl']; $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key); if ($ftp_result > 0) { jio()->DeleteFile($image_file); $image_file = $site_url . '/' . str_replace('./', '', $image_file); } } DB::update('channel', array('picture' => $image_file), array('ch_id' => $id)); } return true; }
function upload($p) { $sys_config = jconf::get(); if (!$_FILES[$p['field']] || !$_FILES[$p['field']]['name']) { return array('error' => 'attach is empty', 'code' => -1); } $itemid = is_numeric($p['itemid']) ? $p['itemid'] : 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); } $_FILES[$p['field']]['name'] = get_safe_code($_FILES[$p['field']]['name']); $att_id = $this->add($uid, $member_info['nickname'], $item, $itemid); if ($att_id < 1) { return array('error' => 'write database is invalid', 'code' => -3); } $filetype = end(explode('.', $_FILES[$p['field']]['name'])); $att_name = $att_id . '.' . $filetype; $att_path = RELATIVE_ROOT_PATH . 'data/attachs/topic/' . face_path($att_id); $att_file = $att_path . $att_name; if (!is_dir($att_path)) { jio()->MakeDir($att_path); } jupload()->init($att_path, $p['field'], false, true); jupload()->setMaxSize($sys_config['attach_size_limit']); jupload()->setNewName($att_name); $ret = jupload()->doUpload(); if (!$ret) { $this->delete($att_id); $rets = jupload()->getError(); $ret = $rets ? implode(" ", (array) $rets) : 'image upload is invalid'; return array('error' => $ret, 'code' => -5); } $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', $att_file, '', $ftp_key); if ($ftp_result > 0) { jio()->DeleteFile($att_file); $att_file = $site_url . '/' . str_replace('./', '', $att_file); } } $att_size = filesize($att_file); $p = array('id' => $att_id, 'site_url' => $site_url, 'photo' => $att_file, 'name' => $_FILES[$p['field']]['name'], 'filesize' => $att_size, 'filetype' => $filetype, 'tid' => max(0, (int) $p['tid']), 'uid' => $uid, 'username' => $member_info['nickname'], 'dateline' => (int) time()); $this->modify($p); return $p; }
function addPrize() { $id = (int) $this->Get['id']; $file = 'image_' . $id; if ($_FILES[$file]['name']) { $name = time(); $image_name = $name . MEMBER_ID . ".jpg"; $image_path = RELATIVE_ROOT_PATH . 'images/reward/' . face_path(MEMBER_ID); $image_file = $image_path . $image_name; if (!is_dir($image_path)) { jio()->MakeDir($image_path); } jupload()->init($image_path, $file, true); jupload()->setNewName($image_name); $result = jupload()->doUpload(); if ($result) { $result = is_image($image_file); } if (!$result) { unlink($image_file); echo "<script type='text/javascript'>"; echo "parent.document.getElementById('message').style.display='none';"; echo "</script>"; $this->_image_error(jupload()->_error); exit; } image_thumb($image_file, $image_file, 100, 100); if ($this->Config['ftp_on']) { $ftp_key = randgetftp(); $get_ftps = jconf::get('ftp'); $site_url = $get_ftps[$ftp_key]['attachurl']; $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key); if ($ftp_result > 0) { jio()->DeleteFile($image_file); $image_file = $site_url . '/' . str_replace('./', '', $image_file); } } DB::query("insert into `" . TABLE_PREFIX . "reward_image` set `uid` = '" . MEMBER_ID . "',`image` = '{$image_file}' "); $image_id = DB::insert_id(); } else { echo "<script type='text/javascript'>"; echo "alert('没有图片');"; echo "</script>"; exit; } echo "<script type='text/javascript'>"; echo "parent.document.getElementById('message').style.display='none';"; echo "parent.document.getElementById('show_image_{$id}').src='{$image_file}';"; echo "parent.document.getElementById('show_image_{$id}').style.display='block';"; echo "parent.document.getElementById('hid_image_{$id}').value='{$image_id}';"; echo "</script>"; exit; }
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 onLoadPic() { if (!$this->MemberHandler->HasPermission($this->Module, 'create')) { js_alert_output($this->MemberHandler->GetError()); } $id = jget('id', 'int'); $file_name = 'pic' . $id; if (MEMBER_ROLE_TYPE != 'admin' && !$is_allowed) { load::logic('vote'); $VoteLogic = new VoteLogic(); $is_allowed = $VoteLogic->allowedCreate(MEMBER_ID); } if ($is_allowed) { js_alert_output($is_allowed); } if ($_FILES[$file_name]['name']) { $name = time() . MEMBER_ID; $image_name = $name . "_b.jpg"; $image_path = RELATIVE_ROOT_PATH . 'images/vote/'; $image_file = $image_path . $image_name; $image_th_file = $image_path . $name . "_th.jpg"; if (!is_dir($image_path)) { jio()->MakeDir($image_path); } jupload()->init($image_path, $file_name, true); jupload()->setNewName($image_name); $result = jupload()->doUpload(); if ($result) { $result = is_image($image_file); } if (!$result) { unlink($image_file); echo "<script language='Javascript'>"; echo "parent.document.getElementById('message').style.display='block';"; echo "parent.document.getElementById('uploading').style.display='none';"; echo "parent.document.getElementById('message').innerHTML='图片上载失败'"; echo "</script>"; exit; } image_thumb($image_file, $image_th_file, 100, 100, 1, 0, 0); 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, '', $ftp_key); if ($ftp_result > 0) { jio()->DeleteFile($image_file); $image_file = $face_url . '/' . str_replace('./', '', $image_file); } $ftp_result = ftpcmd('upload', $image_th_file, '', $ftp_key); if ($ftp_result > 0) { jio()->DeleteFile($image_th_file); $image_th_file = $face_url . '/' . str_replace('./', '', $image_th_file); } } #插入数据库 $image_id = $this->VoteLogic->insert_vote_img(MEMBER_ID, $image_th_file, $image_file); echo "<script language='Javascript'>"; echo "parent.document.getElementById('pic_show_{$id}').src='{$image_th_file}';"; echo "parent.document.getElementById('pic_id_{$id}').value='{$image_id}';"; echo "</script>"; exit; } }
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"); }
$file_ext = array_pop($temp_arr); $file_ext = trim($file_ext); $file_ext = strtolower($file_ext); if (in_array($file_ext, $ext_arr) === false) { alert("上传文件扩展名是不允许的扩展名。"); } $new_file_name = date("YmdHis") . '_' . rand(10000, 99999) . '.' . $file_ext; $file_path = $save_path . $new_file_name; if (move_uploaded_file($tmp_name, $file_path) === false) { alert("上传文件失败。"); } if (!is_image($file_path)) { alert("请上传正确的图片格式。"); } @chmod($file_path, 0644); $file_url = $save_url . $new_file_name; if ($_J['ftp_on']) { $ftp_key = randgetftp(); $get_ftps = jconf::get('ftp'); $site_url = $get_ftps[$ftp_key]['attachurl']; $ftp_result = ftpcmd('upload', $file_path, '', $ftp_key); if ($ftp_result > 0) { jio()->DeleteFile($file_path); $file_url = $site_url . 'images/kind/' . $new_file_name; } } @header('Content-type: text/html; charset=UTF-8'); $json = new Services_JSON(); echo $json->encode(array('error' => 0, 'url' => $file_url)); exit; }
function DoAddADV() { $html = ''; $location = jget('location', 'trim'); $adid = jget('adid', 'int'); if ($adid) { $sql = " select * from `" . TABLE_PREFIX . "ad` where `adid` = '{$adid}' "; $ad_info = DB::fetch_first($sql); $ad_info || $this->Messager("您要修改的广告不存在或已删除。", -1); } $location || $ad_info['location'] || $this->Messager("这个是哪里的广告位?", 'admin.php?mod=income'); $title = jget('title', 'trim'); if (!$title) { $this->Messager("请输入广告标题", -1); } $hcode = jget('hcode'); if (count($hcode['page']) < 1) { $this->Messager("广告投放范围必须要有哦", -1); } $ftime = jget('ftime', 'trim'); if ($ftime) { $ftime = strtotime($ftime); } $ttime = jget('ttime', 'trim'); if ($ttime) { $ttime = strtotime($ttime); } $type = jget('type', 'int'); switch ($type) { case 1: #代码 if (!$hcode['html']) { $this->Messager("广告HTML代码必须要有哦", -1); } $html = $hcode['html']; break; case 2: #文字 if (!$hcode['word']) { $this->Messager("文字内容必须要有哦", -1); } if (!$hcode['word_url']) { $this->Messager("文字链接必须要有哦", -1); } if ($hcode['word_size']) { $word_size = 'style="font-size:' . $hcode['word_size'] . 'px"'; } $html = '<a href="' . $hcode['word_url'] . '" target="_blank"><span ' . $word_size . '>' . $hcode['word'] . '</span></a>'; break; case 3: #图片 if ($_FILES['image']['name']) { $name = time() . MEMBER_ID; $image_name = $name . ".jpg"; $image_path = RELATIVE_ROOT_PATH . 'images/ad/'; $image_file = $image_path . $image_name; if (!is_dir($image_path)) { jio()->MakeDir($image_path); } jupload()->init($image_path, 'image', true); jupload()->setNewName($image_name); $result = jupload()->doUpload(); if ($result) { $result = is_image($image_file); } if (!$result) { unlink($image_file); $this->Messager("图片上传失败。", -1); } if ($this->Config['ftp_on']) { $ftp_key = randgetftp(); $get_ftps = jconf::get('ftp'); $site_url = $get_ftps[$ftp_key]['attachurl']; $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key); if ($ftp_result > 0) { jio()->DeleteFile($image_file); $image_file = $site_url . '/' . str_replace('./', '', $image_file); } } $hcode['image'] = $image_file; } else { if (!$adid) { $this->Messager("图片必须要有哦", -1); } else { $un_hcode = unserialize(base64_decode($ad_info['hcode'])); $hcode['image'] = $un_hcode['image']; } } $hcode['pic_url'] || $this->Messager("图片链接必须要有哦", -1); $image_width_html = $hcode['pic_width'] ? ' width=' . $hcode['pic_width'] : ''; $image_height_html = $hcode['pic_height'] ? ' height= ' . $hcode['pic_height'] : ''; $html = '<a href="' . $hcode[pic_url] . '" target="_blank" title="' . $hcode['pic_title'] . '"><img src="' . $hcode['image'] . '" ' . $image_width_html . $image_height_html . '></a>'; break; default: $this->Messager("展现方式必须要有哦", -1); break; } $ser_hcode = base64_encode(serialize($hcode)); #保存到数据库 $data = array('location' => $location, 'title' => $title, 'type' => $type, 'ftime' => $ftime, 'ttime' => $ttime, 'hcode' => $ser_hcode); if ($adid) { DB::update('ad', $data, " `adid` = '{$adid}' "); } else { $adid = DB::insert('ad', $data, true); } #保存到本地 $ad = jconf::get('ad'); if ($un_hcode['page']) { foreach ($un_hcode['page'] as $k => $v) { if (isset($ad['ad_list'][$v][$location][$adid]) && is_array($ad['ad_list'][$v][$location][$adid])) { unset($ad['ad_list'][$v][$location][$adid]); } } } $AdLocationList = $this->AdLocationList(); $ad_localtions = $AdLocationList[$location]['page']; if (isset($ad_localtions['width'])) { unset($ad_localtions['width']); } $unset_ad_pages = array_diff(array_keys($ad_localtions), $hcode['page']); if (is_array($unset_ad_pages) && count($unset_ad_pages) > 0) { foreach ($unset_ad_pages as $page) { if (isset($ad['ad_list'][$page]) && isset($ad['ad_list'][$page][$location]) && isset($ad['ad_list'][$page][$location][$adid]) && is_array($ad['ad_list'][$page][$location][$adid]) && $ad['ad_list'][$page][$location][$adid]) { unset($ad['ad_list'][$page][$location][$adid]); } if ($ad['ad_list'][$page]) { $ad['ad_list'][$page] = array_filter($ad['ad_list'][$page]); } } $ad['ad_list'] = array_filter($ad['ad_list']); } $ad['enable'] = 1; foreach ($hcode['page'] as $k => $v) { if (!is_array($ad['ad_list'][$v][$location])) { $ad['ad_list'][$v][$location] = array(); } if (!is_array($ad['ad_list'][$v][$location][$adid])) { $ad['ad_list'][$v][$location][$adid] = array(); } $ad['ad_list'][$v][$location][$adid]['html'] = $html; $ad['ad_list'][$v][$location][$adid]['ftime'] = $ftime; $ad['ad_list'][$v][$location][$adid]['ttime'] = $ttime; } jconf::set('ad', $ad); $this->Messager('设置成功', 'admin.php?mod=income&code=ad_list&op=' . $location); }
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 ModAttach() { if ($this->MemberHandler->HasPermission($this->Module, 'attach') == false) { $this->_mod_attach_error('您没有上传文件的权限,无法继续操作!'); } $id = max(0, (int) $this->Post['id']); if ($id < 1) { $this->_mod_attach_error('附件ID 错误'); } $attach_info = $this->AttachLogic->get_info($id); if (!$attach_info) { $this->_mod_attach_error('您要更新的附件已经不存在了'); } if (MEMBER_ROLE_TYPE != 'admin') { if (MEMBER_ID != $attach_info['uid']) { $this->_mod_attach_error('您没有权限更新该附件'); } } if (empty($_FILES) || !$_FILES['mafile']['name']) { $this->_mod_attach_error('没有文件上传'); } $attach_size = min(is_numeric($this->Config['attach_size_limit']) ? $this->Config['attach_size_limit'] : 1024, 51200); $attach_path = str_replace($id . '.' . $attach_info['filetype'], '', $attach_info['file']); $attach_type = strtolower(end(explode('.', $_FILES['mafile']['name']))); $attach_name = $id . '.' . $attach_type; $attach_file = $attach_path . $attach_name; if (!is_dir($attach_path)) { jio()->MakeDir($attach_path); } jupload()->init($attach_path, 'mafile', false, true); jupload()->setMaxSize($attach_size); jupload()->setNewName($attach_name); $ret = jupload()->doUpload(); if ($ret) { $ret = true; } if (!$ret) { jio()->DeleteFile($attach_file); $rets = jupload()->getError(); $ret = $rets ? implode(" ", (array) $rets) : 'attach file is invalid'; $this->_mod_attach_error($ret); } $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', $attach_file, '', $ftp_key); if ($ftp_result > 0) { jio()->DeleteFile($attach_file); } } $attach_size = filesize($attach_file); $name = addslashes($_FILES['mafile']['name']); $p = array('id' => $id, 'site_url' => $site_url, 'file' => $attach_file, 'name' => $name, 'filetype' => $attach_type, 'filesize' => $attach_size); $this->AttachLogic->modify($p); $retval = array('src' => 'images/filetype/' . $attach_type . '.gif', 'name' => $name, 'size' => $attach_size > 1024 * 1024 ? round($attach_size / (1024 * 1024), 2) . 'MB' : ($attach_size == 0 ? '未知' : round($attach_size / 1024, 1) . 'KB')); echo "<script type='text/javascript'>window.parent.aupcomplete({$id},'{$retval['src']}','{$retval['name']}','{$retval['size']}');</script>"; }
public function modify_left_icon() { $key = $this->Get['key']; $group = $this->Get['group']; $name = $this->Get['name']; $file = $key; $slide = $this->Post['slide']; if ($_FILES[$file]['name']) { $image_name = dir_safe($key) . ".jpg"; $image_path = RELATIVE_ROOT_PATH . 'images/lefticon/'; $image_file = $image_path . $image_name; if (!is_dir($image_path)) { jio()->MakeDir($image_path); } jupload()->init($image_path, $file, true); jupload()->setMaxSize(512); jupload()->setNewName($image_name); $result = jupload()->doUpload(); if ($result) { $result = is_image($image_file); } if (!$result) { $this->_js_output('alert("图片上传失败");'); } image_thumb($image_file, $image_file, 100, 100); if ($this->Config['ftp_on']) { $ftp_key = randgetftp(); $get_ftps = jconf::get('ftp'); $site_url = $get_ftps[$ftp_key]['attachurl']; $ftp_result = ftpcmd('upload', $image_file, '', $ftp_key); if ($ftp_result > 0) { jio()->DeleteFile($image_file); $image_file = $site_url . '/' . str_replace('./', '', $image_file); } } } else { echo "<script type='text/javascript'>"; echo "alert('没有图片');"; echo "</script>"; exit; } $slide_config = jconf::get('left_navigation'); foreach ($slide_config[$group] as &$v) { if ($v['code'] == $name) { $v['icon'] = $image_file; } } jconf::set('left_navigation', $slide_config); echo "<script type='text/javascript'>"; echo "parent.document.getElementById('show_image_{$key}').src='{$image_file}';"; echo "parent.document.getElementById('show_image_{$key}').style.display='block';"; echo "parent.document.getElementById('show_image_{$key}_value').value='{$image_file}';"; echo "parent.document.location.reload();"; echo "</script>"; exit; }
function upload_icon($upload_data) { extract($upload_data); $u_setting = $this->upload_setting(); $allow_exts = $u_setting['allow_exts']; $max_size = $u_setting['img_size']; $type = trim(strtolower(end(explode(".", $_FILES[$field]['name'])))); if (!in_array($type, $allow_exts)) { return -1; } $image_name = substr(md5($_FILES[$field]['name']), -10) . ".{$type}"; $image_path = $this->qun_avatar_path($upload_data['qid']); if (empty($image_path)) { return; } $image_file = $image_path . $image_name; if (!is_dir($image_path)) { jio()->MakeDir($image_path); } jupload()->init($image_path, $field, true); jupload()->setMaxSize($max_size); jupload()->setNewName($image_name); $result = jupload()->doUpload(); if ($result) { $result = is_image($image_file); } if (!$result) { jio()->DeleteFile($image_file); return -2; } list($w, $h) = getimagesize($image_file); $dst_file = $image_path . $upload_data['qid'] . '_b.jpg'; if (file_exists($dst_file)) { unlink($dst_file); } $make_result = image_thumb($image_file, $dst_file, 80, 80, 2); $lst_file = $image_path . $upload_data['qid'] . '_s.jpg'; if (file_exists($lst_file)) { unlink($lst_file); } $make_result = image_thumb($image_file, $lst_file, 50, 50, 2); unlink($image_file); if ($GLOBALS['_J']['config']['ftp_on']) { $ftp_key = randgetftp(); $get_ftps = jconf::get('ftp'); $site_url = $get_ftps[$ftp_key]['attachurl']; $ftp_result = ftpcmd('upload', $lst_file, '', $ftp_key); if ($ftp_result > 0) { $ftp_result = ftpcmd('upload', $dst_file, '', $ftp_key); jio()->DeleteFile($lst_file); jio()->DeleteFile($dst_file); $lst_file = $site_url . '/' . str_replace('./', '', $lst_file); } } if (!empty($upload_data['qid'])) { DB::query("UPDATE " . DB::table('qun') . " SET icon='{$lst_file}' WHERE qid='{$upload_data['qid']}'"); } return 1; }
/** * 同步头像到指定的DZ uid(同步到DZ)。 * 适用于没有安装UC的DZ。普通站长一般是DZ6.0.0 * * @param integer $uid DZ uid * @return integer 同步结果。正常为0,否则: * -1到-10:此错误码预留给_getFaceAndCreateTemp方法,请自行参阅该方法的注释 * * -20:要复制的中等头像不存在 * -21:论坛设置不允许该用户所在用户组上传头像 * -22:复制头像到指定论坛头像目录失败 */ function syncToNoUC($uid) { $step1result = $this->_getFaceAndCreateTemp($uid); if ($step1result < 0) { return $step1result; } $db = XWB_plugin::getDB(); //由于中等头像经大头像创建,而大头像已经经过安全检测,因此在这里只需要检测中等头像是否存在即可。 if (!file_exists($this->faceTempPath[3])) { $this->_delTempFace(); return -20; } $_destPrefix = './images/face/' . jsg_face_path($this->uid) . $this->uid; $image_file_small = $destPath = $_destPrefix . '_s.jpg'; $image_file = $_destPrefix . '_b.jpg'; $destRealPath = XWB_S_ROOT . $destPath; if (!is_dir(dirname($destPath))) { jmkdir(dirname($destPath)); } copy($this->faceTempPath[2], XWB_S_ROOT . $image_file); $copyresult = copy($this->faceTempPath[3], $destRealPath); $this->_delTempFace(); if (false == $copyresult) { return -22; } else { $face_url = ''; if ($GLOBALS['_J']['config']['ftp_enable']) { $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); @unlink($image_file); @unlink($image_file_small); } } $destPath = mysql_real_escape_string($destPath); $db->result_first("UPDATE " . XWB_S_TBPRE . "members SET `face_url`='{$face_url}', `face`= '" . $destPath . "' WHERE uid = '" . $this->uid . "' LIMIT 1"); return 0; } }