// 1. 写消息到文件队列 $file = ""; if ($to_type == "user") { $file = write_content_to_file_with_uid($tuid, $content); } else { $file = write_content_to_file_with_gid($tuid, $content); } if (strlen($file) <= 0) { $res = show_info('fail', '系统出错'); echo json_encode($res); return; } // 1. 写消息到数据库 if ($to_type == "user") { $fnickB64 = base64_encode($fnick); $qid = write_queue_to_db($db, $mid, $tag_type, $fuid, $fnickB64, $tuid, "txt", $file, strlen($content), ""); if ($qid == -1) { $res = show_info('fail', '系统出错'); echo json_encode($res); return; } // 2. 给对方发送通知 $ret = send_notice_to_uid("user", $fuid, $fnickB64, $tuid, $tpid, $tag_type, $qid); if ($ret != true) { log_info("send notice to tuid:{$tuid} tag_type:{$tag_type} fail"); } $res = show_info('succ', '处理成功'); $res['qid'] = $qid; $res['queue_file'] = $file; } else { // 获取所有群组成员
echo json_encode($res); return 0; } // 查询队列表 $sql = "SELECT id FROM sc_queue WHERE fuid = {$fuid} AND tuid = {$tuid} AND tag_type = 'SYS' AND queue_type = 'rmf' AND expire = 0 LIMIT 1"; $stmt = $db->prepare($sql); $stmt->execute(); if ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $res = show_info('fail', '请求已经发送'); echo json_encode($res); return 0; } // ----- 操作 ----- // 1. 写消息到数据库 $fnickB64 = base64_encode($fnick); $pid = write_queue_to_db($db, $mid, $tag_type, $fuid, $fnickB64, $tuid, "rmf", "", 0, ""); if ($pid == -1) { $res = show_info('fail', '系统出错'); echo json_encode($res); return; } // 2. 给对方发送通知 log_info("send_notice_to_uid({$fuid}, {$fnickB64}, {$tuid}, {$tpid}, {$tag_type}, {$pid})"); $ret = send_notice_to_uid($fuid, $fnickB64, $tuid, $tpid, $tag_type, $pid); if ($ret != true) { log_info("send notice to tuid:{$tuid} tag_type:{$tag_type} fail"); } $res = show_info('succ', '处理成功'); echo json_encode($res); return; } catch (PDOException $e) {
return 1; } } if (move_uploaded_file($_FILES['voicename']['tmp_name'], $voice_file)) { } else { log_error("move_uploaded_file " . $_FILES['voicename']['tmp_name'] . " to {$voice_file} fail"); $res = show_info('fail', '系统临时错误 5101'); echo json_encode($res); return 1; } // 2. 写消息到数据库 $voice_st = lstat($voice_file); $voice_size = $voice_st['size']; $fnickB64 = base64_encode($fnick); $voice_url = str_replace(DATA_PATH, DATA_HOST, $voice_file); $qid = write_queue_to_db($db, $mid, $tag_type, $fuid, $fnickB64, $tuid, "voice", $voice_url, $voice_size, $durationInSeconds); if ($qid == -1) { $res = show_info('fail', '系统出错'); echo json_encode($res); return; } // 2. 给对方发送通知 $ret = send_notice_to_uid($fuid, $fnickB64, $tuid, $tpid, $tag_type, $qid); if ($ret != true) { log_info("send notice to tuid:{$tuid} tag_type:{$tag_type} fail"); } $res = show_info('succ', '处理成功'); $res['qid'] = $qid; $res['queue_file'] = $voice_url; echo json_encode($res); return;
$img_h = $wh_list[1]; $img = new Imagick($jpg_file); $img->thumbnailimage($img_w, $img_h); file_put_contents($jpg_thumb_file, $img); } else { log_error("move_uploaded_file " . $_FILES['jpgname']['tmp_name'] . " to {$jpg_file} fail"); $res = show_info('fail', '系统临时错误 5101'); echo json_encode($res); return 1; } // 2. 写消息到数据库 $img_st = lstat($jpg_file); $img_size = $img_st['size']; $fnickB64 = base64_encode($fnick); $jpg_url = str_replace(DATA_PATH, DATA_HOST, $jpg_thumb_file); $qid = write_queue_to_db($db, $mid, $tag_type, $fuid, $fnickB64, $tuid, "img", $jpg_url, $img_size, $img_wh); if ($qid == -1) { $res = show_info('fail', '系统出错'); echo json_encode($res); return; } // 2. 给对方发送通知 $ret = send_notice_to_uid($fuid, $fnickB64, $tuid, $tpid, $tag_type, $qid); if ($ret != true) { log_info("send notice to tuid:{$tuid} tag_type:{$tag_type} fail"); } $res = show_info('succ', '处理成功'); $res['qid'] = $qid; $res['queue_file'] = $jpg_url; echo json_encode($res); return;