function message_info($condition = '', $orderby = ' i.id DESC ', $offset = 0, $count = 20) { $limit = " limit {$offset}, {$count}"; $sql = 'SELECT i.*,f.id as fid,f.file_name,f.file_path FROM ' . DB_PREFIX . 'interview i LEFT JOIN ' . DB_PREFIX . 'files f ON i.cover_pic = f.id WHERE i.isclose=0 ' . $condition . $orderby . $limit; $res = $this->db->query($sql); $k = array(); while (!false == ($r = $this->db->fetch_array($res))) { $arr['id'] = $r['id']; $arr['title'] = $r['title']; $arr['start_time'] = $r['start_time']; $arr['end_time'] = $r['end_time']; //$a = unserialize($r['moderator']); //$r['moderator'] = $a[key($a)]; $r['moderator'] = unserialize($r['moderator']); $arr['moderator'] = empty($r['moderator']) ? $r['moderator'] : ''; $b = unserialize($r['honor_guests']); $arr['honor_guests'] = empty($b) ? '' : $b; $arr['object_type'] = $this->settings['object_type'][$r['object_type']]; $arr['description'] = $r['description']; $arr['is_pre_ask'] = $r['is_pre_ask']; $arr['need_login'] = $r['nedd_login']; $arr['cover_pic'] = $r['file_path'] && $r['file_name'] ? hg_material_link(IMG_URL, app_to_dir(APP_UNIQUEID), $r['file_path'], $r['file_name']) : ''; $k[] = $arr; } return $k; }
public function get_material_by_ids() { if (!$this->input['material_ids']) { $this->errorOutput(NO_IDS); } $material_ids = explode(',', $this->input['material_ids']); $material_ids = implode("','", $material_ids); $sql = "SELECT id,bundle_id,filepath, filename,type,mark,filesize,create_time \r\n FROM " . DB_PREFIX . "material WHERE 1 AND id IN('" . $material_ids . "')"; $q = $this->db->query($sql); $ret = array(); while ($row = $this->db->fetch_array($q)) { $row['host'] = hg_getimg_host($row['bs']); $row['dir'] = app_to_dir($row['bundle_id'], $row['mark']); $ret[] = $row; } $this->addItem($ret); $this->output(); }
public function show() { $interviewid = $this->input['interview_id']; if (empty($interviewid)) { //$this->errorOutput('无效参数'); } //首页图片 $res = $this->db->query_first('SELECT cover_pic FROM ' . DB_PREFIX . 'interview where id=' . $interviewid); $cover_pic = $res['cover_pic']; $offset = $this->input['offset'] ? intval(urldecode($this->input['offset'])) : 0; $count = $this->input['count'] ? intval(urldecode($this->input['count'])) : 10; $limit = " limit {$offset}, {$count}"; $orderby = ' ORDER BY order_id DESC'; $condition = $this->get_condition(); $sql = 'SELECT * FROM ' . DB_PREFIX . 'files WHERE interview_id=' . $interviewid . $condition . $orderby . $limit; $q = $this->db->query($sql); while ($r = $this->db->fetch_array($q)) { $r['interview_id'] = $interviewid; $r['cover_pic'] = $cover_pic; $r['create_time'] = date('Y-m-d H:i:s', $r['create_time']); $r['file_size'] = round($r['file_size'] / 1024 / 8, 2) . ' KB'; switch ($r['show_pos']) { case 0: $r['show_pos'] = '头部'; break; case 1: $r['show_pos'] = '背景'; break; case 2: $r['show_pos'] = '其它'; break; } $r['ori_pic'] = hg_material_link(IMG_URL, app_to_dir(APP_UNIQUEID), $r['file_path'], $r['file_name']); //$r['ori_pic'] = $this->obj->pic_path($r['server_mark'], $r['file_path'], $r['file_name'], ''); //$r['pic'] = $this->obj->pic_path($r['server_mark'], $r['file_path'], $r['file_name'], '50x50'); $r['pic'] = hg_material_link(IMG_URL, app_to_dir(APP_UNIQUEID), $r['file_path'], $r['file_name'], '40x30/'); $this->addItem($r); } $this->output(); }
/** * 头像编辑 * Enter description here ... * @param unknown_type $member_id * @param unknown_type $files * @return boolean */ public function avatarEdit($member_id, $files, $type = '') { if (!$member_id) { return false; } if ($type == 1) { $avatar = $files; } else { $avatar['Filedata'] = $files; } $type = $type ? $type : 2; //$material = $this->mMaterial->addMaterial($avatar, $member_id); $sql = "SELECT * FROM " . DB_PREFIX . "member WHERE id=" . $member_id; $f = $this->db->query_first($sql); //头像传两分 $sql = "SELECT * FROM " . DB_PREFIX . "member_avatar WHERE member_id=" . $member_id . " ORDER BY orderid DESC"; $sen = $this->db->query_first($sql); $data = array(); if (!$f['dir']) { $data['dir'] = app_to_dir('avatars', 'img'); $data['filepath'] = '0000/' . (intval($member_id / 10000) < 10 ? '0' . intval($member_id / 10000) : intval($member_id / 10000)) . '/'; $data['name_prefix'] = hg_generate_user_salt(4) . $member_id . hg_generate_user_salt(2); $data['orderid'] = 1; $data['filename'] = $data['name_prefix'] . '0000.jpg'; } else { $data['dir'] = $f['dir']; $data['filepath'] = $f['filepath']; $data['name_prefix'] = $sen['name_prefix']; $data['orderid'] = $sen['orderid'] + 1; // $data['filename'] = $f['filename']; $data['filename'] = $sen['name_prefix'] . hg_order_num($data['orderid']) . '.jpg'; } $material_nodb = $this->mMaterial->addMaterialNodb($avatar, $type, $data['dir'] . $data['filepath'], $data['filename']); //覆盖一份 if (empty($material_nodb)) { return false; } $material = array(); if (!empty($sen)) { $data['orderid'] = $sen['orderid'] + 1; $data['name_prefix'] = $sen['name_prefix']; } $material = array('member_id' => $member_id, 'member_name' => $f['member_name'], 'host' => $material_nodb['host'], 'dir' => $data['dir'], 'filepath' => $data['filepath'], 'filename' => $data['name_prefix'] . hg_order_num($data['orderid']) . '.jpg', 'name_prefix' => $data['name_prefix'], 'orderid' => $data['orderid'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip()); $material_tmp_nodb = $this->mMaterial->addMaterialNodb($avatar, $type, $material['dir'] . $material['filepath'], $material['filename']); //保存一份 if (empty($material_tmp_nodb)) { return false; } else { $sql_avatar = "INSERT INTO " . DB_PREFIX . "member_avatar SET "; $space = ""; foreach ($material as $key => $value) { $sql_avatar .= $space . $key . "='" . $value . "'"; $space = ','; } $this->db->query($sql_avatar); } if (!empty($material) && $material['host']) { /* $albums_info = array( 'id' => $material['id'], 'host' => $material['host'] . $material['dir'], 'filepath' => $material['filepath'] . $material['filename'], ); include_once(ROOT_PATH . 'lib/class/albums.class.php'); $this->albums = new albums(); $ret = $this->albums->add_sys_albums(3, serialize($albums_info)); */ $sql = "UPDATE " . DB_PREFIX . "member SET avatar=1, host='" . $material['host'] . "', dir='" . $data['dir'] . "',filepath='" . $data['filepath'] . "', filename='" . $data['filename'] . "' WHERE id = " . $member_id; $this->db->query($sql); } $avatar = array('host' => $material['host'], 'dir' => $data['dir'], 'filepath' => $data['filepath'], 'filename' => $data['filename']); return $avatar; //return false; }
public function create_map_vote_question() { if (empty($this->input['app_bundle']) || empty($this->input['module_bundle']) || empty($this->input['name'])) { $this->errorOutput('参数不完整'); } $app_bundle = urldecode($this->input['app_bundle']); $module_bundle = urldecode($this->input['module_bundle']); $srcFile = hg_getimg_dir() . app_to_dir($app_bundle) . urldecode($this->input['srcFile']); $dstPath = hg_getimg_dir() . "material/sketch_map/" . $app_bundle . "/" . $module_bundle . "/"; hg_mkdir($dstPath); $name = urldecode($this->input['name']); $title = urldecode($this->input['title']); $url = hg_getimg_host() . "material/sketch_map/" . $app_bundle . "/" . $module_bundle . "/" . $name; $save_file_path = $dstPath . $name; if ($this->check_file($save_file_path)) { $this->addItem($url); $this->output(); } else { //示意图拷贝到背景上 $vote_map_bg = CUR_CONF_PATH . "font/vote_map_bg.png"; $vote_map_bg_info = @getimagesize($vote_map_bg); switch ($vote_map_bg_info[2]) { case 3: $map = imagecreatefrompng($vote_map_bg); break; case 2: $map = imagecreatefromjpeg($vote_map_bg); break; case 1: $map = imagecreatefromgif($vote_map_bg); break; default: return false; } imagesavealpha($map, true); //$size = array('width' => 355,'height' => 200); //$map = imagecreatetruecolor($size['width'], $size['height']); //$color =imagecolorallocate($map, 245, 245, 245); //imagefill($map, 0, 0, $color); $title = explode(',', $title); $tit = '投票:' . $title[0]; unset($title[0]); $option = array(); foreach ($title as $k => $v) { $arr = explode('_', $v); list($name, $single_total) = $arr; $option[] = array('title' => $name, 'single_total' => $single_total); } $black = imagecolorallocate($map, 0, 0, 0); imagettftext($map, 12, 0, 70, 30, $black, "../font/simhei.ttf", $tit); $total_num = 0; foreach ($option as $k => $v) { $total_num += $v['single_total']; } $num = 2; for ($i = 0; $i < $num; $i++) { imagettftext($map, 10, 0, 70, 75 + 40 * $i, $black, "../font/simhei.ttf", $option[$i]['title']); /* $bar_size = array('width' => 300,'height' => 30); $progress_size = array('width'=>150,'height'=>20); $bar = imagecreatetruecolor($bar_size['width'], $bar_size['height']); $bar_color = imagecolorallocate($bar, 245, 245, 245); imagefill($bar, 0, 0, $bar_color); $progress = imagecreatetruecolor($progress_size['width'], $progress_size['height']); $progress_color = imagecolorallocate($progress, 245, 245, 245); imagefill($progress, 0, 0, $progress_color); $black_color = imagecolorallocate($progress, 0, 0, 0); imagerectangle($progress, 0, 0, $progress_size['width']-1, $progress_size['height']-1, $black_color); if($total_num !=0) { $per = $option[$i]['single_total']/$total_num; } else { $per = 0; } $per_width = $per * ($progress_size['width']-2); $per = round($per*100) . '%'; $blue =imagecolorallocate($progress, 65, 122, 201); if($per_width != 0 ) { imagefilledrectangle($progress, 1, 1, $per_width, $progress_size['height']-2, $blue); } imagecopy($bar, $progress, 1, 5, 0, 0, $progress_size['width'], $progress_size['height']); $color = imagecolorallocate($bar, 0, 0, 0); $str = $option[$i]['single_total'] . '(' . $per . ')'; imagettftext($bar, 10, 0, $progress_size['width']+10, 20, $color, '../font/simhei.ttf', $str); imagecopy($map, $bar, 70, 65+50*$i, 0, 0, $bar_size['width'], $bar_size['height']); */ } $option_num = count($option); $gray = imagecolorallocate($map, 189, 189, 189); if ($option_num >= $num) { $option = "共" . $option_num . "个选项"; imagettftext($map, 9, 0, 70, 68 + 40 * 2, $gray, "../font/simhei.ttf", $option); } imagealphablending($map, false); imagepng($map, $save_file_path); imagedestroy($map); $this->addItem($url); $this->output(); } }
public function imgdata2pic($imgdata, $app_bundle, $type = 'png') { if (empty($imgdata)) { return false; } $info = array('host' => hg_getimg_host(), 'dir' => app_to_dir($app_bundle), 'filepath' => date('Y', TIMENOW) . '/' . date('m', TIMENOW) . '/', 'filename' => md5(hg_generate_salt(4) . TIMENOW) . '.' . $type); $img_dir = hg_getimg_dir() . $info['dir'] . $info['filepath']; if (!hg_mkdir($img_dir) || !is_writeable($img_dir)) { $this->errorOutput($img_dir . '目录不可写'); } $imgdata = str_replace('data:image/png;base64,', '', $imgdata); $imgdata = strpos($imgdata, 'data:') !== false ? $imgdata : base64_decode($imgdata); hg_file_write($img_dir . $info['filename'], $imgdata); return $info; }
public function delete() { $id = urldecode($this->input['id']); $sql = "SELECT * FROM " . DB_PREFIX . "material WHERE id IN(" . $id . ")"; $r = $this->db->query($sql); while ($row = $this->db->fetch_array($r)) { hg_editTrue_material(hg_getimg_dir($row["bs"]) . app_to_dir($row['bundle_id']) . $row['filepath'], $row['filename']); hg_delete_material(hg_getimg_dir($row["bs"]) . app_to_dir($row['bundle_id']) . $row['filepath'], $row['filename']); } $sql = "DELETE FROM " . DB_PREFIX . "material WHERE id IN(" . $id . ")"; $this->db->query($sql); return true; }