function saveimage($dir, $allow_water = true) { //image object require_once APP_ROOT_PATH . "system/utils/es_imagecls.php"; $image = new es_imagecls(); $image->max_size = intval(app_conf("MAX_IMAGE_SIZE")); $image->init($_FILES['file'], $dir); if ($image->save()) { $img_item['url'] = $image->file['target']; $img_item['path'] = $image->file['local_target']; $img_item['name'] = $image->file['prefix']; $img_item['width'] = $image->file['width']; $img_item['height'] = $image->file['height']; } else { if ($image->error_code == -105) { return array('error' => 1, 'message' => '上传的图片太大'); } elseif ($image->error_code == -104 || $image->error_code == -103 || $image->error_code == -102 || $image->error_code == -101) { return array('error' => 1, 'message' => '非法图像'); } exit; } //水印处理 if ($allow_water && intval(app_conf("IS_WATER_MARK"))) { $is_water = intval(app_conf("IS_WATER_MARK")); } $water_image = APP_ROOT_PATH . app_conf("WATER_MARK"); $alpha = intval(app_conf("WATER_ALPHA")); $place = intval(app_conf("WATER_POSITION")); if ($is_water) { $dirs = pathinfo($img_item['url']); $dir = $dirs['dirname']; $dir = $dir . "/origin/"; $paths = pathinfo($img_item['path']); $path = $paths['dirname']; $path = $path . "/origin/"; if (!is_dir($path)) { @mkdir($path); @chmod($path, 0777); } $filename = $paths['basename']; @file_put_contents($path . $filename, @file_get_contents($img_item['path'])); $image->water($img_item['path'], $water_image, $alpha, $place); if ($GLOBALS['distribution_cfg']['OSS_TYPE'] && $GLOBALS['distribution_cfg']['OSS_TYPE'] != "NONE") { syn_to_remote_image_server($img_item['url']); //同步水印图 syn_to_remote_image_server($dir . $filename); //同步原图 } } else { if ($GLOBALS['distribution_cfg']['OSS_TYPE'] && $GLOBALS['distribution_cfg']['OSS_TYPE'] != "NONE") { syn_to_remote_image_server($img_item['url']); } } return $img_item; }
function get_spec_gif_anmation($url, $width, $height) { require_once APP_ROOT_PATH . "system/utils/gif_encoder.php"; require_once APP_ROOT_PATH . "system/utils/gif_reader.php"; require_once APP_ROOT_PATH . "system/utils/es_imagecls.php"; $gif = new GIFReader(); $gif->load($url); $imagec = new es_imagecls(); foreach ($gif->IMGS['frames'] as $k => $img) { $im = imagecreatefromstring($gif->getgif($k)); $im = $imagec->make_thumb($im, $img['FrameWidth'], $img['FrameHeight'], "gif", $width, $height, $gen = 1); ob_start(); imagegif($im); $content = ob_get_contents(); ob_end_clean(); $frames[] = $content; $framed[] = $img['frameDelay']; } $gif_maker = new GIFEncoder($frames, $framed, 0, 2, 0, 0, 0, "bin"); return $gif_maker->GetAnimation(); }
/** * 分享点评的上传,上传到comment目录,按日期划分 * 错误返回 error!=0,message错误消息, error=1000表示未登录 * 正确时返回 error=0, url: ./public格式的文件相对路径 path:物理路径 name:文件名 * thumb->preview 100x100的小图 url,path */ public function upload_topic() { global_run(); if (empty($GLOBALS['user_info'])) { $data['error'] = 1000; //未登录 $data['msg'] = $GLOBALS['lang']['PLEASE_LOGIN_FIRST']; ajax_return($data); } //上传处理 //创建comment目录 if (!is_dir(APP_ROOT_PATH . "public/comment")) { @mkdir(APP_ROOT_PATH . "public/comment"); @chmod(APP_ROOT_PATH . "public/comment", 0777); } $dir = to_date(NOW_TIME, "Ym"); if (!is_dir(APP_ROOT_PATH . "public/comment/" . $dir)) { @mkdir(APP_ROOT_PATH . "public/comment/" . $dir); @chmod(APP_ROOT_PATH . "public/comment/" . $dir, 0777); } $dir = $dir . "/" . to_date(NOW_TIME, "d"); if (!is_dir(APP_ROOT_PATH . "public/comment/" . $dir)) { @mkdir(APP_ROOT_PATH . "public/comment/" . $dir); @chmod(APP_ROOT_PATH . "public/comment/" . $dir, 0777); } $dir = $dir . "/" . to_date(NOW_TIME, "H"); if (!is_dir(APP_ROOT_PATH . "public/comment/" . $dir)) { @mkdir(APP_ROOT_PATH . "public/comment/" . $dir); @chmod(APP_ROOT_PATH . "public/comment/" . $dir, 0777); } if (app_conf("IS_WATER_MARK") == 1) { $img_result = save_image_upload($_FILES, "file", "comment/" . $dir, $whs = array('preview' => array(50, 50, 1, 0)), 1, 1); } else { $img_result = save_image_upload($_FILES, "file", "comment/" . $dir, $whs = array('preview' => array(50, 50, 1, 0)), 0, 1); } if (intval($img_result['error']) != 0) { ajax_return($img_result); } else { if ($GLOBALS['distribution_cfg']['OSS_TYPE'] && $GLOBALS['distribution_cfg']['OSS_TYPE'] != "NONE") { syn_to_remote_image_server($img_result['file']['url']); syn_to_remote_image_server($img_result['file']['thumb']['preview']['url']); } } $data_result['error'] = 0; $data_result['url'] = $img_result['file']['url']; $data_result['path'] = $img_result['file']['path']; $data_result['name'] = $img_result['file']['name']; $data_result['thumb'] = $img_result['file']['thumb']; require_once APP_ROOT_PATH . "system/utils/es_imagecls.php"; $image = new es_imagecls(); $info = $image->getImageInfo($img_result['file']['path']); $image_data['width'] = intval($info[0]); $image_data['height'] = intval($info[1]); $image_data['name'] = valid_str($_FILES['file']['name']); $image_data['filesize'] = filesize($img_result['file']['path']); $image_data['create_time'] = NOW_TIME; $image_data['user_id'] = intval($GLOBALS['user_info']['id']); $image_data['user_name'] = strim($GLOBALS['user_info']['user_name']); $image_data['path'] = $img_result['file']['thumb']['preview']['url']; $image_data['o_path'] = $img_result['file']['url']; $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_image", $image_data); $data_result['id'] = intval($GLOBALS['db']->insert_id()); ajax_return($data_result); }
public function water($source, $water, $alpha = 80, $position = "0") { //检查文件是否存在 if (!file_exists($source) || !file_exists($water)) { return false; } //图片信息 $sInfo = es_imagecls::getImageInfo($source); $wInfo = es_imagecls::getImageInfo($water); //如果图片小于水印图片,不生成图片 if ($sInfo["0"] < $wInfo["0"] || $sInfo['1'] < $wInfo['1']) { return false; } if (is_animated_gif($source)) { require_once APP_ROOT_PATH . "system/utils/gif_encoder.php"; require_once APP_ROOT_PATH . "system/utils/gif_reader.php"; $gif = new GIFReader(); $gif->load($source); foreach ($gif->IMGS['frames'] as $k => $img) { $im = imagecreatefromstring($gif->getgif($k)); //为im加水印 $sImage = $im; $wCreateFun = "imagecreatefrom" . $wInfo['type']; if (!function_exists($wCreateFun)) { $wCreateFun = 'imagecreatefromjpeg'; } $wImage = $wCreateFun($water); //设定图像的混色模式 imagealphablending($wImage, true); switch (intval($position)) { case 0: break; //左上 //左上 case 1: $posY = 0; $posX = 0; //生成混合图像 imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha); break; //右上 //右上 case 2: $posY = 0; $posX = $sInfo[0] - $wInfo[0]; //生成混合图像 imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha); break; //左下 //左下 case 3: $posY = $sInfo[1] - $wInfo[1]; $posX = 0; //生成混合图像 imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha); break; //右下 //右下 case 4: $posY = $sInfo[1] - $wInfo[1]; $posX = $sInfo[0] - $wInfo[0]; //生成混合图像 imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha); break; //居中 //居中 case 5: $posY = $sInfo[1] / 2 - $wInfo[1] / 2; $posX = $sInfo[0] / 2 - $wInfo[0] / 2; //生成混合图像 imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha); break; } //end im加水印 ob_start(); imagegif($sImage); $content = ob_get_contents(); ob_end_clean(); $frames[] = $content; $framed[] = $img['frameDelay']; } $gif_maker = new GIFEncoder($frames, $framed, 0, 2, 0, 0, 0, "bin"); $image_rs = $gif_maker->GetAnimation(); //如果没有给出保存文件名,默认为原图像名 @unlink($source); //保存图像 file_put_contents($source, $image_rs); return true; } //建立图像 $sCreateFun = "imagecreatefrom" . $sInfo['type']; if (!function_exists($sCreateFun)) { $sCreateFun = 'imagecreatefromjpeg'; } $sImage = $sCreateFun($source); $wCreateFun = "imagecreatefrom" . $wInfo['type']; if (!function_exists($wCreateFun)) { $wCreateFun = 'imagecreatefromjpeg'; } $wImage = $wCreateFun($water); //设定图像的混色模式 imagealphablending($wImage, true); switch (intval($position)) { case 0: break; //左上 //左上 case 1: $posY = 0; $posX = 0; //生成混合图像 imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha); break; //右上 //右上 case 2: $posY = 0; $posX = $sInfo[0] - $wInfo[0]; //生成混合图像 imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha); break; //左下 //左下 case 3: $posY = $sInfo[1] - $wInfo[1]; $posX = 0; //生成混合图像 imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha); break; //右下 //右下 case 4: $posY = $sInfo[1] - $wInfo[1]; $posX = $sInfo[0] - $wInfo[0]; //生成混合图像 imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha); break; //居中 //居中 case 5: $posY = $sInfo[1] / 2 - $wInfo[1] / 2; $posX = $sInfo[0] / 2 - $wInfo[0] / 2; //生成混合图像 imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo[0], $wInfo[1], $alpha); break; } //如果没有给出保存文件名,默认为原图像名 @unlink($source); //保存图像 imagejpeg($sImage, $source, 100); imagedestroy($sImage); }
} if (intval($img_result['error']) != 0) { ajax_return($img_result); } else { if (app_conf("PUBLIC_DOMAIN_ROOT") != '') { $paths = pathinfo($img_result['topic_image']['url']); $path = str_replace("./", "", $paths['dirname']); $filename = $paths['basename']; $pathwithoupublic = str_replace("public/", "", $path); $syn_url = app_conf("PUBLIC_DOMAIN_ROOT") . "/es_file.php?username="******"IMAGE_USERNAME") . "&password="******"IMAGE_PASSWORD") . "&file=" . SITE_DOMAIN . APP_ROOT . "/" . $path . "/" . $filename . "&path=" . $pathwithoupublic . "/&name=" . $filename . "&act=0"; @file_get_contents($syn_url); } } $data['error'] = 0; $data['message'] = $img_result['topic_image']['thumb']['thumb']['url']; $data['name'] = valid_str($_FILES['topic_image']['name']); require_once APP_ROOT_PATH . "system/utils/es_imagecls.php"; $image = new es_imagecls(); $info = $image->getImageInfo($img_result['topic_image']['path']); $image_data['width'] = intval($info[0]); $image_data['height'] = intval($info[1]); $image_data['name'] = valid_str($_FILES['topic_image']['name']); $image_data['filesize'] = filesize($img_result['topic_image']['path']); $image_data['create_time'] = TIME_UTC; $image_data['user_id'] = intval($GLOBALS['user_info']['id']); $image_data['user_name'] = addslashes($GLOBALS['user_info']['user_name']); $image_data['path'] = $img_result['topic_image']['thumb']['thumb']['url']; $image_data['o_path'] = $img_result['topic_image']['url']; $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_image", $image_data); $data['id'] = intval($GLOBALS['db']->insert_id()); ajax_return($data);
function save_image_upload($upd_file, $key = '', $dir = 'temp', $whs = array(), $is_water = false, $need_return = false) { require_once APP_ROOT_PATH . "system/utils/es_imagecls.php"; $image = new es_imagecls(); $image->max_size = intval(app_conf("MAX_IMAGE_SIZE")); $list = array(); if (empty($key)) { foreach ($upd_file as $fkey => $file) { $list[$fkey] = false; $image->init($file, $dir); if ($image->save()) { $list[$fkey] = array(); $list[$fkey]['url'] = $image->file['target']; $list[$fkey]['path'] = $image->file['local_target']; $list[$fkey]['name'] = $image->file['prefix']; } else { if ($image->error_code == -105) { if ($need_return) { return array('error' => 1, 'message' => '上传的图片太大'); } else { echo "上传的图片太大"; } } elseif ($image->error_code == -104 || $image->error_code == -103 || $image->error_code == -102 || $image->error_code == -101) { if ($need_return) { return array('error' => 1, 'message' => '非法图像'); } else { echo "非法图像"; } } exit; } } } else { $list[$key] = false; $image->init($upd_file[$key], $dir); if ($image->save()) { $list[$key] = array(); $list[$key]['url'] = $image->file['target']; $list[$key]['path'] = $image->file['local_target']; $list[$key]['name'] = $image->file['prefix']; } else { if ($image->error_code == -105) { if ($need_return) { return array('error' => 1, 'message' => '上传的图片太大'); } else { echo "上传的图片太大"; } } elseif ($image->error_code == -104 || $image->error_code == -103 || $image->error_code == -102 || $image->error_code == -101) { if ($need_return) { return array('error' => 1, 'message' => '非法图像'); } else { echo "非法图像"; } } exit; } } $water_image = APP_ROOT_PATH . app_conf("WATER_MARK"); $alpha = app_conf("WATER_ALPHA"); $place = app_conf("WATER_POSITION"); foreach ($list as $lkey => $item) { //循环生成规格图 foreach ($whs as $tkey => $wh) { $list[$lkey]['thumb'][$tkey]['url'] = false; $list[$lkey]['thumb'][$tkey]['path'] = false; if ($wh[0] > 0 || $wh[1] > 0) { $thumb_type = isset($wh[2]) ? intval($wh[2]) : 0; //剪裁还是缩放, 0缩放 1剪裁 if ($thumb = $image->thumb($item['path'], $wh[0], $wh[1], $thumb_type)) { $list[$lkey]['thumb'][$tkey]['url'] = $thumb['url']; $list[$lkey]['thumb'][$tkey]['path'] = $thumb['path']; if (isset($wh[3]) && intval($wh[3]) > 0) { $paths = pathinfo($list[$lkey]['thumb'][$tkey]['path']); $path = $paths['dirname']; $path = $path . "/origin/"; if (!is_dir($path)) { @mkdir($path); @chmod($path, 0777); } $filename = $paths['basename']; @file_put_contents($path . $filename, @file_get_contents($list[$lkey]['thumb'][$tkey]['path'])); $image->water($list[$lkey]['thumb'][$tkey]['path'], $water_image, $alpha, $place); } } } } if ($is_water) { $paths = pathinfo($item['path']); $path = $paths['dirname']; $path = $path . "/origin/"; if (!is_dir($path)) { @mkdir($path); @chmod($path, 0777); } $filename = $paths['basename']; @file_put_contents($path . $filename, @file_get_contents($item['path'])); $image->water($item['path'], $water_image, $alpha, $place); } } return $list; }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $root = array(); $content = strim($GLOBALS['request']['content']); $source = strim($GLOBALS['request']['source']); $source = str_replace("来自", "", $source); $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); if (intval($user_data['id']) == 0) { $root['return'] = 0; $root['info'] = "请先登录"; output($root); } if (isset($_FILES['image_1'])) { //开始上传 //上传处理 //创建comment目录 if (!is_dir(APP_ROOT_PATH . "public/comment")) { @mkdir(APP_ROOT_PATH . "public/comment"); @chmod(APP_ROOT_PATH . "public/comment", 0777); } $dir = to_date(get_gmtime(), "Ym"); if (!is_dir(APP_ROOT_PATH . "public/comment/" . $dir)) { @mkdir(APP_ROOT_PATH . "public/comment/" . $dir); @chmod(APP_ROOT_PATH . "public/comment/" . $dir, 0777); } $dir = $dir . "/" . to_date(get_gmtime(), "d"); if (!is_dir(APP_ROOT_PATH . "public/comment/" . $dir)) { @mkdir(APP_ROOT_PATH . "public/comment/" . $dir); @chmod(APP_ROOT_PATH . "public/comment/" . $dir, 0777); } $dir = $dir . "/" . to_date(get_gmtime(), "H"); if (!is_dir(APP_ROOT_PATH . "public/comment/" . $dir)) { @mkdir(APP_ROOT_PATH . "public/comment/" . $dir); @chmod(APP_ROOT_PATH . "public/comment/" . $dir, 0777); } if (app_conf("IS_WATER_MARK") == 1) { $img_result = save_image_upload($_FILES, "image_1", "comment/" . $dir, $whs = array('thumb' => array(100, 100, 1, 0)), 1, 1); } else { $img_result = save_image_upload($_FILES, "image_1", "comment/" . $dir, $whs = array('thumb' => array(100, 100, 1, 0)), 0, 1); } if (app_conf("PUBLIC_DOMAIN_ROOT") != '') { $paths = pathinfo($img_result['topic_image']['url']); $path = str_replace("./", "", $paths['dirname']); $filename = $paths['basename']; $pathwithoupublic = str_replace("public/", "", $path); $syn_url = app_conf("PUBLIC_DOMAIN_ROOT") . "/es_file.php?username="******"IMAGE_USERNAME") . "&password="******"IMAGE_PASSWORD") . "&file=" . get_domain() . APP_ROOT . "/" . $path . "/" . $filename . "&path=" . $pathwithoupublic . "/&name=" . $filename . "&act=0"; @file_get_contents($syn_url); } require_once APP_ROOT_PATH . "system/utils/es_imagecls.php"; $image = new es_imagecls(); $info = $image->getImageInfo($img_result['image_1']['path']); $image_data['width'] = intval($info[0]); $image_data['height'] = intval($info[1]); $image_data['name'] = valid_str($_FILES['image_1']['name']); $image_data['filesize'] = filesize($img_result['image_1']['path']); $image_data['create_time'] = get_gmtime(); $image_data['user_id'] = intval($GLOBALS['user_info']['id']); $image_data['user_name'] = addslashes($GLOBALS['user_info']['user_name']); $image_data['path'] = $img_result['image_1']['thumb']['thumb']['url']; $image_data['o_path'] = $img_result['image_1']['url']; $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_image", $image_data); $image_id = intval($GLOBALS['db']->insert_id()); //end 上传 } if ($image_id > 0) { $attach_list = array(array("id" => $image_id, "type" => "image")); } else { $attach_list = array(); } $id = insert_topic(valid_str($content), $title = "", $type = "", $group = "", $relay_id = 0, $fav_id = 0, $group_data = array(), $attach_list); if ($id) { increase_user_active($user_data['id'], "发表了一则分享"); $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '" . $source . "' where id = " . intval($id)); } $syn_data['content'] = $content; //$syn_data['img'] = get_abs_img_root($GLOBALS['db']->getOne("select o_path from ".DB_PREFIX."topic_image where id = ".intval($image_id))); $syn_data['img'] = $GLOBALS['db']->getOne("select o_path from " . DB_PREFIX . "topic_image where id = " . intval($image_id)); if ($syn_data['img']) { $syn_data['img'] = APP_ROOT_PATH . $syn_data['img']; } //开始同步 if (intval($GLOBALS['request']['is_syn_sina'])) { //$GLOBALS['db']->query("update ".DB_PREFIX."user set is_syn_sina = 1 where id = ".intval($user_data['id'])); //$func_name = strim($GLOBALS['request']['type'])."_Sina"; //$result_sina = $func_name($syn_data); $result_sina = Sina($syn_data); $ext_info = ""; if (!$result_sina['status']) { if (intval($result_sina['code']) == 21316 || intval($result_sina['code']) == 21317) { $ext_info .= " 请先绑定新浪微博"; } if (intval($result_sina['code']) == 21314 || intval($result_sina['code']) == 21315) { $ext_info .= " 新浪微博授权过期"; } } } if (intval($GLOBALS['request']['is_syn_tencent'])) { //$GLOBALS['db']->query("update ".DB_PREFIX."user set is_syn_tencent = 1 where id = ".intval($user_data['id'])); // $func_name = strim($GLOBALS['request']['type'])."_Tencent"; // $result_tencent = $func_name($syn_data); $result_tencent = Tencent($syn_data); if (!$result_tencent['status']) { if (intval($result_tencent['code']) == 0) { $ext_info .= " 请先绑定腾讯微博"; } if (intval($result_tencent['code']) == 14) { $ext_info .= " 腾讯微博未实名认证"; } if (intval($result_tencent['code']) == 10017 || intval($result_tencent['code']) == 10018 || intval($result_tencent['code']) == 10019 || intval($result_tencent['code']) == 36 || intval($result_tencent['code']) == 37 || intval($result_tencent['code']) == 38) { $ext_info .= " 腾讯微博授权过期"; } } } $root['return'] = 1; $root['status'] = 1; $root['info'] = "发布成功" . $ext_info; output($root); }
public function save() { global_run(); if (empty($GLOBALS['user_info'])) { $data['status'] = -1; $data['info'] = ""; ajax_return($data); } require_once APP_ROOT_PATH . "system/model/review.php"; $deal_id = intval($_REQUEST['deal_id']); $youhui_id = intval($_REQUEST['youhui_id']); $event_id = intval($_REQUEST['event_id']); $location_id = intval($_REQUEST['location_id']); $order_item_id = intval($_REQUEST['order_item_id']); $youhui_log_id = intval($_REQUEST['youhui_log_id']); $event_submit_id = intval($_REQUEST['event_submit_id']); $param = array("deal_id" => $deal_id, "youhui_id" => $youhui_id, "event_id" => $event_id, "location_id" => $location_id, "order_item_id" => $order_item_id, "youhui_log_id" => $youhui_log_id, "event_submit_id" => $event_submit_id); $checker = check_dp_status($GLOBALS['user_info']['id'], $param); if (!$checker['status']) { showErr($checker['info'], 1); } $content = strim(valid_str($_REQUEST['content'])); //点评内容 $dp_point = intval($_REQUEST['dp_point']); //总评分 if ($dp_point <= 0) { $data['status'] = 0; $data['info'] = "请为总评打分"; ajax_return($data); } $dp_image = array(); //点评图片 foreach ($_REQUEST['dp_image'] as $k => $v) { if (strim($v) != "") { $dp_image[] = strim($v); } } $tag_group = array(); //标签分组 foreach ($_REQUEST['dp_tags'] as $k => $tags_arr) { foreach ($tags_arr as $v) { if (strim($v) != "") { $v_array = preg_split("/[ ,]/", $v); foreach ($v_array as $kk => $vv) { if (strim($vv) != "") { $tag_group[$k][] = strim(valid_str($vv)); } } } } } $point_group = array(); //评分分组 foreach ($_REQUEST['dp_point_group'] as $k => $v) { if (intval($v) > 0) { $point_group[$k] = intval($v); } else { $name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "point_group where id = " . intval($k)); $info = "请打分"; if ($name) { $info = "请为" . $name . "打分"; } $data['status'] = 0; $data['info'] = $info; ajax_return($data); } } $result = save_review($GLOBALS['user_info']['id'], $param, $content, $dp_point, $dp_image, $tag_group, $point_group); if ($result['status']) { //分享 $attach_list = array(); if ($result['deal_id'] > 0) { require_once APP_ROOT_PATH . "system/model/deal.php"; $deal_info = get_deal($result['deal_id']); if ($deal_info['uname'] != "") { $url_key = $deal_info['uname']; } else { $url_key = $deal_info['id']; } $type = "dealcomment"; $url_route = array('rel_app_index' => 'index', 'rel_route' => 'deal#' . $url_key, 'rel_param' => ''); //同步图片 if ($deal_info['icon']) { require_once APP_ROOT_PATH . "system/utils/es_imagecls.php"; $imagecls = new es_imagecls(); $info = $imagecls->getImageInfo(APP_ROOT_PATH . $deal_info['icon']); $image_data['width'] = intval($info[0]); $image_data['height'] = intval($info[1]); $image_data['name'] = $deal_info['sub_name']; $image_data['filesize'] = filesize(APP_ROOT_PATH . $deal_info['icon']); $image_data['create_time'] = NOW_TIME; $image_data['user_id'] = intval($GLOBALS['user_info']['id']); $image_data['user_name'] = strim($GLOBALS['user_info']['user_name']); $image_data['path'] = $deal_info['icon']; $image_data['o_path'] = $deal_info['icon']; $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_image", $image_data); $img_id = intval($GLOBALS['db']->insert_id()); $attach_list[] = array("type" => "image", "id" => intval($img_id)); } } elseif ($result['youhui_id'] > 0) { require_once APP_ROOT_PATH . "system/model/youhui.php"; $youhui_info = get_youhui($result['youhui_id']); $type = "youhuicomment"; $url_route = array('rel_app_index' => 'index', 'rel_route' => 'youhui#' . $result['youhui_id'], 'rel_param' => ''); //同步图片 if ($youhui_info['icon']) { require_once APP_ROOT_PATH . "system/utils/es_imagecls.php"; $imagecls = new es_imagecls(); $info = $imagecls->getImageInfo(APP_ROOT_PATH . $youhui_info['icon']); $image_data['width'] = intval($info[0]); $image_data['height'] = intval($info[1]); $image_data['name'] = $youhui_info['name']; $image_data['filesize'] = filesize(APP_ROOT_PATH . $youhui_info['icon']); $image_data['create_time'] = NOW_TIME; $image_data['user_id'] = intval($GLOBALS['user_info']['id']); $image_data['user_name'] = strim($GLOBALS['user_info']['user_name']); $image_data['path'] = $youhui_info['icon']; $image_data['o_path'] = $youhui_info['icon']; $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_image", $image_data); $img_id = intval($GLOBALS['db']->insert_id()); $attach_list[] = array("type" => "image", "id" => intval($img_id)); } } elseif ($result['event_id'] > 0) { require_once APP_ROOT_PATH . "system/model/event.php"; $event_info = get_event($result['youhui_id']); $type = "eventcomment"; $url_route = array('rel_app_index' => 'index', 'rel_route' => 'event#' . $result['event_id'], 'rel_param' => ''); //同步图片 if ($event_info['icon']) { require_once APP_ROOT_PATH . "system/utils/es_imagecls.php"; $imagecls = new es_imagecls(); $info = $imagecls->getImageInfo(APP_ROOT_PATH . $event_info['icon']); $image_data['width'] = intval($info[0]); $image_data['height'] = intval($info[1]); $image_data['name'] = $event_info['name']; $image_data['filesize'] = filesize(APP_ROOT_PATH . $event_info['icon']); $image_data['create_time'] = NOW_TIME; $image_data['user_id'] = intval($GLOBALS['user_info']['id']); $image_data['user_name'] = strim($GLOBALS['user_info']['user_name']); $image_data['path'] = $event_info['icon']; $image_data['o_path'] = $event_info['icon']; $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_image", $image_data); $img_id = intval($GLOBALS['db']->insert_id()); $attach_list[] = array("type" => "image", "id" => intval($img_id)); } } else { require_once APP_ROOT_PATH . "system/model/supplier.php"; $location_info = get_location($result['location_id']); $type = "slocationcomment"; $url_route = array('rel_app_index' => 'index', 'rel_route' => 'store#' . $result['location_id'], 'rel_param' => ''); //同步图片 if ($location_info['preview']) { require_once APP_ROOT_PATH . "system/utils/es_imagecls.php"; $imagecls = new es_imagecls(); $info = $imagecls->getImageInfo(APP_ROOT_PATH . $location_info['preview']); $image_data['width'] = intval($info[0]); $image_data['height'] = intval($info[1]); $image_data['name'] = $location_info['name']; $image_data['filesize'] = filesize(APP_ROOT_PATH . $location_info['preview']); $image_data['create_time'] = NOW_TIME; $image_data['user_id'] = intval($GLOBALS['user_info']['id']); $image_data['user_name'] = strim($GLOBALS['user_info']['user_name']); $image_data['path'] = $location_info['preview']; $image_data['o_path'] = $location_info['preview']; $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_image", $image_data); $img_id = intval($GLOBALS['db']->insert_id()); $attach_list[] = array("type" => "image", "id" => intval($img_id)); } } foreach ($_REQUEST['topic_image_id'] as $att_id) { if (intval($att_id) > 0) { $attach_list[] = array("type" => "image", "id" => intval($att_id)); } } require_once APP_ROOT_PATH . "system/model/topic.php"; $tid = insert_topic($content, "", $type, $group = "", $relay_id = 0, $fav_id = 0, $group_data = "", $attach_list, $url_route); if ($tid) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '网站' where id = " . intval($tid)); } $result['jump'] = url($url_route['rel_app_index'], $url_route['rel_route'], $url_route['rel_param']); ajax_return($result); } else { ajax_return($result); } }