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 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>"; }
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; }
function DoEditTheme() { $id = $this->Post['id']; if (!$id) { $this->Messager("主题不存在", "admin.php?mod=show&code=modify_theme"); } $theme_arr = jconf::get('theme'); $theme_arr['theme_list'][$id]['theme_bg_color'] = $this->Post['theme_bg_color'] ? $this->Post['theme_bg_color'] : "#2F97CA"; $theme_arr['theme_list'][$id]['theme_link_color'] = $this->Post['theme_link_color'] ? $this->Post['theme_link_color'] : "#0073B2"; $theme_arr['theme_list'][$id]['theme_text_color'] = $this->Post['theme_text_color'] ? $this->Post['theme_text_color'] : "#333333"; $theme_arr['theme_list'][$id]['theme_bg_image_type'] = $this->Post['theme_bg_image_type'] ? $this->Post['theme_bg_image_type'] : "center"; jconf::set('theme', $theme_arr); $config = array(); if ($this->Post['set_system_theme'] == 1) { $config['theme_bg_color'] = $this->Post['theme_bg_color'] ? $this->Post['theme_bg_color'] : '#2F97CA'; $config['theme_bg_image_type'] = $this->Post['theme_bg_image_type'] ? $this->Post['theme_bg_image_type'] : 'center'; $config['theme_id'] = $id; $config['theme_link_color'] = $this->Post['theme_link_color'] ? $this->Post['theme_link_color'] : '#0073B2'; $config['theme_text_color'] = $this->Post['theme_text_color'] ? $this->Post['theme_text_color'] : '#333333'; jconf::update($config); } if ($_FILES['changePic']['name']) { $type = trim(strtolower(end(explode(".", $_FILES['changePic']['name'])))); $themebg = "themebg"; $image_name = $themebg . ".jpg"; $image_path = RELATIVE_ROOT_PATH . './theme/' . $id . '/images/'; $image_file = $image_path . $image_name; if (!is_dir($image_path)) { jio()->MakeDir($image_path); } jupload()->init($image_path, 'changePic', true); jupload()->setMaxSize(5120); jupload()->setNewName($image_name); $result = jupload()->doUpload(); $themebg_preview = "themebg_preview"; $themebg_preview_name = $themebg_preview . ".jpg"; $themebg_preview_path = RELATIVE_ROOT_PATH . './theme/' . $id . "/"; $image_file_min = $themebg_preview_path . $themebg_preview_name; image_thumb($image_file, $image_file_min, 76, 76); if ($result) { $result = is_image($image_file); } if (!$result) { unlink($image_file); unlink($image_file_min); $this->Messager("上传失败", -1); } } $this->Messager("设置成功", "admin.php?mod=show&code=modify_theme"); }
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); }
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 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 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 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); }
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 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 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"); }
function upload_pic($id) { $image_name = $id . ".png"; $image_path = RELATIVE_ROOT_PATH . 'images/talk/' . 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 { DB::update('talk', array('image' => $image_file), array('lid' => $id)); } return true; }
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'); }
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 DoModify() { $field = 'theme'; $image_id = MEMBER_ID; $theme_bg_image = str_replace($this->Config['site_url'] . '/', '', $this->Post['theme_bg_image']); $image_path = RELATIVE_ROOT_PATH . 'images/' . $field . '/' . face_path($image_id); $image_name = $image_id . "_o.jpg"; $image_file = $image_path . $image_name; if ($_FILES && $_FILES[$field]['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) { jio()->DeleteFile($image_file); $this->Messager("[图片上载失败]" . implode(" ", (array) jupload()->getError()), null); } else { $theme_bg_image = $image_file; } } else { if ($theme_bg_image != $image_file) { } } $theme_id = $this->Post['theme_id']; $theme_bg_color = $this->Post['theme_bg_color']; $theme_text_color = $this->Post['theme_text_color']; $theme_link_color = $this->Post['theme_link_color']; $theme_bg_image_type = $this->Post['theme_bg_image_type']; $theme_bg_repeat = $this->Post['theme_bg_repeat'] ? 1 : 0; $theme_bg_fixed = $this->Post['theme_bg_fixed'] ? 1 : 0; $sql = "update " . TABLE_PREFIX . "members set\r\n\t\t\t`theme_bg_image`='{$theme_bg_image}', `theme_bg_color`='{$theme_bg_color}', `theme_text_color`='{$theme_text_color}',\r\n\t\t\t`theme_link_color`='{$theme_link_color}' , theme_id='{$theme_id}' , theme_bg_image_type='{$theme_bg_image_type}' ,\r\n\t\t\t`theme_bg_repeat`='{$theme_bg_repeat}' , `theme_bg_fixed`='{$theme_bg_fixed}'\r\n\t\t\twhere `uid`='" . MEMBER_ID . "'"; $this->DatabaseHandler->Query($sql); if ('admin' == MEMBER_ROLE_TYPE && $this->Post['set_default']) { $config = array(); $config['theme_id'] = $theme_id; $config['theme_bg_image'] = $theme_bg_image; $config['theme_bg_color'] = $theme_bg_color; $config['theme_text_color'] = $theme_text_color; $config['theme_link_color'] = $theme_link_color; $config['theme_bg_image_type'] = $theme_bg_image_type; $config['theme_bg_repeat'] = $theme_bg_repeat; $config['theme_bg_fixed'] = $theme_bg_fixed; jconf::update($config); } $query = $this->DatabaseHandler->Query("select * from " . TABLE_PREFIX . "members where `uid`='" . MEMBER_ID . "'"); $this->_initTheme($query->GetRow()); $this->Messager("设置成功", 'index.php?mod=topic&code=myhome'); }
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'); }
public function doProfileImage() { $member = $this->_member(); if (!$member) { $this->Messager('您需要登录后才能继续操作', null); } $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 ($_FILES && $_FILES['image']['name']) { $temp_img_size = intval($_FILES['image']['size'] / 1024); if ($temp_img_size >= 2048) { if ($this->Get['home']) { echo '<script>parent.show_message("图片文件过大,2MB以内");parent.closeDialog("showuploadform");</script>'; exit; } else { $this->Messager('图片文件过大,2MB以内'); } } $_ts = explode(".", $_FILES['image']['name']); $type = trim(strtolower(end($_ts))); if ($type != 'gif' && $type != 'jpg' && $type != 'png' && $type != 'jpeg') { if ($this->Get['home']) { echo '<script>parent.show_message("图片格式不对");parent.closeDialog("showuploadform");</script>'; exit; } else { $this->Messager('图片格式不对'); } } 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) { jio()->DeleteFile($image_file); if ($this->Get['home']) { echo '<script>parent.show_message("图片上传失败");parent.closeDialog("showuploadform");</script>'; exit; } else { $this->Messager("[图片上载失败]" . implode(" ", (array) jupload()->getError()), null); } } else { list($w, $h) = getimagesize($image_file); if ($w > 960) { $tow = 960; $toh = round($tow * ($h / $w)); $result = makethumb($image_file, $image_file, $tow, $toh); if (!$result) { jio()->DeleteFile($image_file); if ($this->Get['home']) { echo '<script>parent.show_message("缩略图片失败");parent.closeDialog("showuploadform");</script>'; exit; } else { $this->Messager("缩略图片失败" . implode(" ", (array) jupload()->getError()), null); } } } $image_file_src = $this->Config['site_url'] . ltrim($image_file, "."); $tpl = 'setting/profile_image'; if ($this->Get['home']) { $is_home = TRUE; $tpl = 'setting/profile_image_home'; } include template($tpl); exit; } } else { if ($this->Get['home']) { echo 'parent.show_message("请上传图片!");parent.closeDialog("showuploadform");</script>'; exit; } else { $this->Messager("请上传图片!" . implode(" ", (array) jupload()->getError()), null); } } }
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; }
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("设置成功!"); } }