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 get_photo_list($param) { $sql_where = ''; $uid = max(0, (int) $param['uid']); $cache_key = "{$uid}-get_photo_list-" . md5(serialize($param)); if (false === ($info = cache_db('get', $cache_key))) { if ($uid > 0) { $uids = get_buddyids($uid, $GLOBALS['_J']['config']['topic_myhome_time_limit']); if ($uids) { $sql_where = " AND t.uid in(" . jimplode($uids) . ") "; } else { return array(); } } $total_photo = (int) $param['count']; if ($total_photo < 1) { if ($param['vip']) { $total_photo = DB::result_first("select count(1) as `total` from " . DB::table('topic_image') . " t left join " . DB::table('members') . " m on m.uid=t.uid where t.tid>0 and m.validate='1'" . $sql_where); } else { $total_photo = DB::result_first("SELECT COUNT(*) FROM " . DB::table('topic_image') . " AS t WHERE t.tid > 0 " . $sql_where); } } $info = false; $limit_sql = ''; $photo_i = 0; $topic_list = array(); $user_lists = array(); if ($total_photo > 0) { if ($param['perpage']) { $page_arr = page($total_photo, $param['perpage'], $param['page_url'], array('return' => 'array')); $limit_sql = $page_arr['limit']; } else { if ($param['limit']) { $limit_sql = ' LIMIT ' . $param['limit']; } elseif ($param['count']) { $limit_sql = ' LIMIT ' . $param['count']; } } if ($param['vip']) { $query = DB::query("SELECT t.id,t.tid,t.uid,t.name,t.width,t.height,t.dateline,tr.content,tr.content2,tr.forwards,tr.replys,tr.digcounts\r\n\t\t\t\t\t\t\t\t\tFROM " . DB::table('topic_image') . " AS t\r\n\t\t\t\t\t\t\t\t\tLEFT JOIN " . DB::table('topic') . " AS tr\r\n\t\t\t\t\t\t\t\t\tON t.tid = tr.tid\r\n\t\t\t\t\t\t\t\t\tleft join " . DB::table('members') . " as m\r\n\t\t\t\t\t\t\t\t\ton m.uid=t.uid\r\n\t\t\t\t\t\t\t\t\tWHERE t.tid > 0 and m.validate='1' " . $sql_where . "\r\n\t\t\t\t\t\t\t\t\tORDER BY t.id DESC\r\n\t\t\t\t\t\t\t\t\t{$limit_sql} "); } else { $query = DB::query("SELECT t.id,t.tid,t.uid,t.name,t.width,t.height,t.dateline,tr.content,tr.content2,tr.forwards,tr.replys,tr.digcounts\r\n\t\t\t\t\t\t\t\t\tFROM " . DB::table('topic_image') . " AS t\r\n\t\t\t\t\t\t\t\t\tLEFT JOIN " . DB::table('topic') . " AS tr\r\n\t\t\t\t\t\t\t\t\tON t.tid = tr.tid\r\n\t\t\t\t\t\t\t\t\tWHERE t.tid > 0 " . $sql_where . "\r\n\t\t\t\t\t\t\t\t\tORDER BY t.id DESC\r\n\t\t\t\t\t\t\t\t\t{$limit_sql} "); } while ($value = DB::fetch($query)) { $value['content'] .= $value['content2']; $value['content'] = jhtmlspecialchars(strip_tags($value['content'])); if (!is_file(topic_image($value['id'], 'photo', 1))) { $image_file = RELATIVE_ROOT_PATH . 'images/topic/' . face_path($value['id']) . $value['id'] . "_o.jpg"; $image_file_photo = RELATIVE_ROOT_PATH . 'images/topic/' . face_path($value['id']) . $value['id'] . "_p.jpg"; if ($value['width'] > 280) { $p_width = 280; $p_height = round($value['height'] * 280 / $value['width']); $result = makethumb($image_file, $image_file_photo, $p_width, $p_height); } if ($value['width'] <= 280 || !$result && !is_file($image_file_photo)) { @copy($image_file, $image_file_photo); } } $value['photo'] = topic_image($value['id'], 'photo', 0); $value['height'] = $value['width'] > 280 ? round($value['height'] * 280 / $value['width']) : $value['height']; $value['width'] = $value['width'] > 280 ? 280 : $value['width']; $value['dateline'] = my_date_format2($value['dateline']); if (false != strpos($value['content'], '</U>')) { $value['content'] = preg_replace('#\\<U(.*?)\\>(.*?)\\</U\\>#', '<a href="\\2" target="_blank">Click Here</a>', $value['content']); } if (false !== strpos($value['content'], 'http:/' . '/')) { $value['content'] = preg_replace('~(http:/' . '/[a-z0-9-\\.\\?\\=&;_@/%#]+?)\\s+~i', '<a href="\\1" target="_blank">Click Here</a> ', $value['content']); $value['content'] = preg_replace("|\\s*http:/" . "/[a-z0-9-\\.\\?\\=&;_@/%#]*\$|sim", "", $value['content']); } $topic_list[] = $value; } if ($topic_list) { $topic_list_count = count($topic_list); $topic_list = $this->TopicLogic->MakeAll($topic_list, 0); $info = array('list' => $topic_list, 'count' => $param['count'] ? $topic_list_count : $total_photo, 'page' => $page_arr); } } cache_db('set', $cache_key, $info, $uid > 0 ? 3600 : 600); } if ($info['count'] > 0 && $info['list']) { if ($GLOBALS['_J']['config']['is_topic_user_follow'] && !$GLOBALS['_J']['disable_user_follow']) { $info['list'] = buddy_follow_html($info['list'], 'uid', 'follow_html2'); } $pi = 0; $list = array(); foreach ($info['list'] as $v) { $list[$pi++ % 3][] = $v; } $info['list'] = $list; } return $info; }
function doVerify() { $act = $this->Get['act']; $uids = array(); $uid = (int) $this->Get['uid']; $uids = $this->Post['uids']; if ($uid) { $uids[$uid] = $uid; } $msg = jget('msg'); if ($act == 'yes') { if ($uids) { foreach ($uids as $uid) { if ($uid < 1) { continue; } $message = ''; $nickname = DB::result_first(" select `nickname` from `" . TABLE_PREFIX . "members` where `uid` = '{$uid}'"); $query = $this->DatabaseHandler->Query("select * from " . TABLE_PREFIX . "members_verify where `uid` = '{$uid}'"); $member_verify = $query->GetRow(); if ($member_verify) { if ($member_verify['face'] || $member_verify['face_url']) { $image_path = RELATIVE_ROOT_PATH . 'images/face/' . face_path($uid); if (!is_dir($image_path)) { jio()->MakeDir($image_path); } $image_file_b = $dst_file = $image_path . $uid . '_b.jpg'; $image_file_s = $dst_file = $image_path . $uid . '_s.jpg'; $image_verify_path = RELATIVE_ROOT_PATH . 'images/face_verify/' . face_path($uid); $image_verify_file_b = $dst_file = $image_verify_path . $uid . '_b.jpg'; $image_verify_file_s = $dst_file = $image_verify_path . $uid . '_s.jpg'; if ($member_verify['face_url']) { $ftp_key = getftpkey($member_verify['face_url']); if ($ftp_key < 0) { $this->Messager('请检查FTP是否可用'); } ftpcmd('get', $image_file_b, $image_verify_file_b, $ftp_key); ftpcmd('get', $image_file_s, $image_verify_file_s, $ftp_key); $ftp_result = ftpcmd('upload', $image_file_b, '', $ftp_key); $ftp_result = ftpcmd('upload', $image_file_s, '', $ftp_key); $sql = "update `" . TABLE_PREFIX . "members` set `face`='{$image_file_s}', `face_url`='{$member_verify['face_url']}' where `uid`='" . $uid . "'"; $this->DatabaseHandler->Query($sql); } else { if ($member_verify['face']) { @copy($image_verify_file_b, $image_file_b); @copy($image_verify_file_s, $image_file_s); $sql = "update `" . TABLE_PREFIX . "members` set `face`='{$image_file_s}' where `uid`='" . $uid . "'"; $this->DatabaseHandler->Query($sql); } } if ($this->Config['extcredits_enable'] && $member_verify['uid'] > 0) { update_credits_by_action('face', $member_verify['uid']); } $message .= '你更新的头像已经通过审核,可以通过ctrl+f5强制刷新来查看新头像;'; } if ($member_verify["signature"]) { $sql = "update " . TABLE_PREFIX . "members set signature = '{$member_verify['signature']}',signtime = '" . time() . "' where uid = '{$uid}' "; $this->DatabaseHandler->Query($sql); $message .= '你更新的签名已经更过审核;'; } $this->DatabaseHandler->Query("delete from " . TABLE_PREFIX . "members_verify where uid = '{$uid}'"); $pm_post = array('message' => $message, 'to_user' => $nickname); jlogic('pm')->pmSend($pm_post); } } } } else { if ($msg) { $to_user = DB::result_first("select `nickname` from `" . TABLE_PREFIX . "members` where `uid` = '{$uid}'"); if ($to_user) { $pm_post = array('message' => $msg, 'to_user' => $to_user); jlogic('pm')->pmSend($pm_post); } } $this->DatabaseHandler->Query("delete from `" . TABLE_PREFIX . "members_verify` where `uid` = '{$uid}'"); } $this->Messager("操作成功"); }
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 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 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($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 _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; }
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 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 UploadImage() { LogMessage("UploadImage"); $this->GotoLogin(); $imgId = $this->ImgLogic->AddNewImage(); $this->Logger->Write($imgId); if (!$imgId || $imgId <= 0) { echo "0"; return; } $uid = $this->User['uid']; $this->Logger->Write($uid); $this->User = $this->UserLogic->GetUser($uid); $IoHandler = new IoHandler(); $item = $this->Post['item'] ? $this->Post['item'] : $this->Get['item']; $itemId = $this->Post['itemId'] ? $this->Post['itemId'] : $this->Get['itemId']; $imgtype = $this->Post['imgtype'] ? $this->Post['imgtype'] : $this->Get['imgtype']; $name = $_FILES['Filedata']['name']; $this->Logger->Write($name); $id = $imgId; $subfolder = 'topic'; if ($item != '') { $subfolder = $item; } else { } $rpath = 'images/' . $subfolder . '/' . face_path($id); $image_path = __WEB_ROOT . '/' . $rpath; $image_name = $id . '_o.jpg'; $image_file = $rpath . $image_name; $image_file_s = $rpath . $id . '_s.jpg'; $image_file_t = $rpath . $id . '_t.jpg'; $image_file_p = $rpath . $id . '_p.jpg'; $image_file_tp = $rpath . $id . '_tp.jpg'; $image_file_avt = ''; $pic_field = 'Filedata'; $UploadHandler = new UploadHandler($_FILES, $image_path, $pic_field, true, false); $UploadHandler->setMaxSize(3072); $UploadHandler->setNewName($image_name); $ret = $UploadHandler->doUpload(); if (!$ret) { $rets = $UploadHandler->getError(); $ret = $rets ? implode(" ", (array) $rets) : 'image upload is invalid'; $r = array('error' => $ret, 'code' => -5); if ($r['code'] < 0 && $r['error']) { $this->ImgLogic->DeleteImage($imgId); $error = $UploadHandler->getError(); $result = array(); $result['status'] = "failed"; $result['message'] = urlencode($error); echo urldecode(json_encode($result)); exit; } } $image_type = $info['type']; list($image_width, $image_height, $image_type, $image_attr) = getimagesize($image_file); //this file used for topic list $Images = new ImagesHandler('Filedata'); $Images->item_type = $item; $w = 120; $h = 120; if ($item == 'event') { $h = 105; } //if($image_width>1500){ // LogMessage('resize to 1500 size'); // resizeimage($image_file, $image_file_tp,1500,0,true); // LogMessage('resize to 1500 size done'); // $image_file=$image_file_tp; // list($image_width,$image_height,$image_type,$image_attr) = getimagesize($image_file_tp); //} LogMessage("uploaed completed,going to resize image"); if ($image_width == $image_height) { LogMessage("Width is equal to height"); $resize = $Images->thumb($image_file, false, 1, $rpath . $id, 0, 0, $image_width, $image_height, $w, $h, 'jpg'); } else { if ($image_height > $image_width) { LogMessage("Width is less than height"); $resize = $Images->thumb($image_file, false, 1, $rpath . $id, 0, 0, $image_width, $image_width, $w, $h, 'jpg'); } else { if ($image_height < $image_width) { LogMessage("Width is larger than height"); $resize = $Images->thumb($image_file, false, 1, $rpath . $id, 0, 0, $image_height, $image_height, $w, $h, 'jpg'); } } } if (!$resize) { $result['status'] = "failed"; $result['message'] = "图片上传失败"; $this->ImgLogic->DeleteImage($imgId); $IoHandler->DeleteFile($image_file); echo json_encode($result); exit; } if ($this->CallType != 'open') { //reduce the photo quality, but keep photo original width and height resizeimage($image_file, $image_file_t, 1024, 0, true); } else { copy($image_file, $image_file_t); } if ($image_file_avt && $image_file_avt != '') { resizeimage($image_file, $image_file_avt, 50, 50, false); } //this file used for photo list resizeimage($image_file, $image_file_p, 200, 0, true); //update image table $datalist = array(); $datalist['name'] = $name; $datalist['photo'] = $image_file_s; list($tWidth, $tHeight, $tType, $tAttr) = getimagesize($image_file_t); $datalist['width'] = $tWidth; $datalist['height'] = $tHeight; if ($item != '' && $itemId != '') { $datalist['item'] = $item; $datalist['itemid'] = $itemId; } $this->ImgLogic->UpdateImage($datalist, $imgId); $result = array(); $result['status'] = "ok"; $result['message'] = "图片上传成功"; $item = array(); $item['item_id'] = $imgId; $item['item_type'] = 'image'; $item['item_src'] = $image_file_s; $item['item_name'] = $name; $item['item_width'] = $tWidth; $item['item_height'] = $tHeight; $result['item'] = $item; $IoHandler->DeleteFile($image_file); echo json_encode($result); }
function WaitForValidation() { $sql = " select count(*) from `" . TABLE_PREFIX . "members` where role_id = 5 "; $count = DB::result_first($sql); $page_num = 20; $query_link = "admin.php?mod=member&code=waitvalidate"; $pages = page($count, $page_num, $query_link, array('return' => 'array')); $limit = $pages['limit']; $sql = " select m.uid,m.username,m.nickname,m.regip,m.regdate,m.email,m.invite_uid,m2.nickname as invite_name\r\n\t\t\t\t from `" . TABLE_PREFIX . "members` m\r\n\t\t\t\t left join `" . TABLE_PREFIX . "members` m2 on m2.uid = m.invite_uid\r\n\t\t\t\t where m.role_id = 5 order by m.uid desc {$limit} "; $query = DB::query($sql); while ($rs = DB::fetch($query)) { $rs['face'] = face_path($rs['uid']); $members[$rs['uid']] = $rs; } include template('admin/member_wait_validate'); }
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 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 topic_image($id, $type = 'small', $relative = true) { $type = 'photo' == $type ? 'p' : ('small' == $type ? 's' : 'o'); $file = 'images/topic/' . face_path($id) . $id . "_{$type}.jpg"; if ($relative) { $file = RELATIVE_ROOT_PATH . $file; } else { static $sys_config = null; if (is_null($sys_config)) { $sys_config = jconf::get(); } if ($sys_config['ftp_on']) { if (!($site_url = $GLOBALS['ftp_site_urls'][$id])) { $site_url = jlogic('image')->get_site_url($id); $GLOBALS['ftp_site_urls'][$id] = $site_url; } } if (!$site_url) { $site_url = $sys_config['site_url']; } $file = $site_url . '/' . $file; } return $file; }
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 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_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 face_get($uid,$type='small') { $type = 'small' == $type ? 's' : 'b'; $file = IMAGE_PATH . 'face/' . face_path($uid) . $uid . "_{$type}.jpg"; if(!is_file($file)) $file = IMAGE_PATH . 'no.gif'; return $file; }
function Attach() { $item = $this->Get['aitem']; $itemid = max(0, (int) $this->Get['aitemid']); $this->_init_auth(); $field = 'topic'; if (empty($_FILES) || !$_FILES[$field]['name']) { $this->_attach_error('FILES is empty'); } $_FILES[$field]['name'] = get_safe_code($_FILES[$field]['name']); $_FILES[$field]['name'] = jaddslashes($_FILES[$field]['name']); $uid = jget('topic_uid', 'int') > 0 ? jget('topic_uid', 'int') : MEMBER_ID; $username = jget('topic_uid', 'int') > 0 ? '' : MEMBER_NICKNAME; $category = ''; if (jget('attch_category') > 0) { $category = jlogic('attach_category')->get_attacht_cat(jget('attch_category')); } $attach_id = $this->AttachLogic->add($uid, $username, $item, $itemid, $category); if (jget('attch_category') > 0) { $this->auto_add_weibo($attach_id, $_FILES[$field]['name']); } if ($attach_id < 1) { $this->_attach_error('write database is invalid'); } $this->AttachLogic->clear_invalid(); $attach_size = min(is_numeric($this->Config['attach_size_limit']) ? $this->Config['attach_size_limit'] : 1024, 51200); $attach_path = RELATIVE_ROOT_PATH . 'data/attachs/' . $field . '/' . face_path($attach_id); $attach_type = strtolower(end(explode('.', $_FILES[$field]['name']))); $attach_name = $attach_id . '.' . $attach_type; $attach_file = $attach_path . $attach_name; if (!is_dir($attach_path)) { jio()->MakeDir($attach_path); } jupload()->init($attach_path, $field, false, true); jupload()->setMaxSize($attach_size); jupload()->setNewName($attach_name); $ret = jupload()->doUpload(); if ($ret) { $ret = true; } if (!$ret) { jio()->DeleteFile($attach_file); $this->DatabaseHandler->Query("delete from " . TABLE_PREFIX . "topic_attach where `id`='{$attach_id}'"); $rets = jupload()->getError(); $ret = $rets ? implode(" ", (array) $rets) : 'attach file is invalid'; $this->_attach_error($ret); } $attach_size = filesize($attach_file); $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); } } $name = addslashes($_FILES[$field]['name']); $p = array('id' => $attach_id, 'site_url' => $site_url, 'file' => $attach_file, 'name' => $name, 'filetype' => $attach_type, 'filesize' => $attach_size); $this->AttachLogic->modify($p); update_credits_by_action('attach_add', $uid); $retval = array('id' => $attach_id, 'src' => 'images/filetype/' . $attach_type . '.gif', 'name' => $name); $this->_attach_result('ok', $retval); }
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 UploadImage() { //$this->GotoLogin(); $name = $_FILES['Filedata']['name']; $id = rand(10, 10000000); $rpath = 'images/building/face/' . face_path($id); $image_path = __WEB_ROOT . '/' . $rpath; $image_name = $id . '_o.jpg'; $image_file = $rpath . $image_name; $image_file_s = $rpath . $id . '_s.jpg'; $image_file_t = $rpath . $id . '_t.jpg'; $image_file_p = $rpath . $id . '_p.jpg'; $pic_field = 'Filedata'; $UploadHandler = new UploadHandler($_FILES, $image_path, $pic_field, true, false); $UploadHandler->setMaxSize(2048); $UploadHandler->setNewName($image_name); $ret = $UploadHandler->doUpload(); if (!$ret) { $rets = $UploadHandler->getError(); $ret = $rets ? implode(" ", (array) $rets) : 'image upload is invalid'; $r = array('error' => $ret, 'code' => -5); if ($r['code'] < 0 && $r['error']) { $this->_image_error($rets['error']); } } list($image_width, $image_height, $image_type, $image_attr) = getimagesize($image_file); if ($image_width >= 120 && $image_height <= 120) { resizeimage($image_file, $image_file_s, 120, 0, true); } if ($image_height >= 120 && $image_height <= 120) { resizeimage($image_file, $image_file_s, 0, 120, true); } if ($image_height > 120 && $image_width > 120 && $image_width > $image_height) { resizeimage($image_file, $image_file_s, 120, 0, true); } if ($image_height > 120 && $image_width > 120 && $image_width < $image_height) { resizeimage($image_file, $image_file_s, 0, 120, true); } resizeimage($image_file, $image_file_t, 600, 0, true); resizeimage($image_file, $image_file_p, 180, 180, false); $result = array(); $result['status'] = "ok"; $result['image'] = $image_file; echo json_encode($result); }
function UploadAvatorFromApp() { $this->NoLoginAjaxReturn(); $rpath = './images/temp'; $IoHandler = new IoHandler(); $Images = new ImagesHandler('Filedata'); $Images->saveDir = $rpath; $path = $Images->move_uploaded(); if (!file_exists($path)) { $result['status'] = "failed"; $result['message'] = urlencode('头像裁剪失败,图片传输过程中丢失'); echo urldecode(json_encode($result)); exit; } $userInfo = $this->UserLogic->GetUser($this->User['uid']); $old_facePath = $userInfo["face_url"]; $imgId = $this->ImgLogic->AddNewImage(); $path1 = 'images/user/' . face_path($imgId); if (!file_exists($path1)) { $IoHandler->MakeDir($path1); } $prefix = $path1 . $imgId; resizeimage($path, $prefix . '_p.jpg', 180, 180, true); resizeimage($path, $prefix . '_s.jpg', 50, 50, true); //$IoHandler->CopyFile($path, $prefix.'_t.jpg'); if (file_exists($prefix . '_s.jpg')) { $userdata = array(); $userdata['face_url'] = $prefix . '_s.jpg'; $ret = $this->UserLogic->UpdateUser2($userdata, $this->User['uid']); if ($old_facePath && $old_facePath != "" && file_exists($old_facePath)) { $IoHandler->DeleteFile($old_facePath); $ps = explode("_", $old_facePath); $old2 = $ps[0] . "_p.jpg"; if (file_exists($old2)) { $IoHandler->DeleteFile($old2); } } } else { $result['status'] = "failed"; $result['message'] = urlencode('头像缩放出错'); $result['item'] = $prefix . '_s.jpg'; echo urldecode(json_encode($result)); exit; } $this->ImgLogic->DeleteImage($imgId, ""); $IoHandler->DeleteFile($path); $result['status'] = "ok"; $result['face_url'] = $prefix . '_s.jpg'; $result['message'] = urlencode('头像保存成功'); echo urldecode(json_encode($result)); }
function _qmd_img_list($pic_path = '', $user_uid = 0, $user_face = '', $topic_content = '', $topic_dateline) { header("Content-type: image/png"); $bg = imagecreatefromjpeg($pic_path); $white = imagecolorallocate($bg, 00, 00, 00); $content = str_split($topic_content, 40); $content = array_iconv($this->Config['charset'], 'utf-8', $content); $topic_url = $this->Config['site_url']; $topic_date = array_iconv($this->Config['charset'], 'utf-8', $topic_dateline . ' | ' . '记事狗微博'); imagettftext($bg, 9, 0, 130, 25, $white, "images/simsun.ttc", $content[0]); imagettftext($bg, 9, 0, 130, 45, $white, "images/simsun.ttc", $content[1]); imagettftext($bg, 9, 0, 130, 70, $white, "images/simsun.ttc", $topic_date); imagettftext($bg, 9, 0, 218, 90, $white, "images/simsun.ttc", $topic_url); $dst_im = imagecreatefromjpeg($bg); $dst_info = getimagesize($bg); $src = $user_face; $src_im = imagecreatefromjpeg($src); $src_info = getimagesize($src); $dst_x = 20; $dst_y = 12; $src_x = 0; $src_y = 0; $src_w = $src_info[0]; $src_h = $src_info[1]; $alpha = 100; imagecopymerge($bg, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $alpha); $image_path = RELATIVE_ROOT_PATH . 'images/qmd/' . face_path(MEMBER_ID); if (!is_dir($image_path)) { jio()->MakeDir($image_path); } $image_file = $image_path . MEMBER_ID . '_o.png'; imagepng($bg, $image_file); imagedestroy($bg); return $image_file; }