throw new PDOException('系统出错(2001),请稍候重试 :)'); } $need_notice = true; } else { if ($action == "cancel" || $action == "reject") { } } // ----- 完成事务 ----- $db->commit(); $need_notice = true; if ($need_notice == true && $pid > 0) { $tpid = 0; $tag_type = "SYS_CFR"; // confirm friend relationship // 发送一个通知 $ret = send_notice_to_uid($tuid, $tnick, $fuid, $tpid, $tag_type, $pid); if ($ret == true) { $res = show_info('succ', '处理成功'); } else { $res = show_info('succ', '处理成功'); } echo json_encode($res); log_info("set friend action: send_notice_to_uid {$ret}"); return 0; } else { log_info("set friend action fail: 请选择执行的动作"); $res = show_info('fail', '请选择执行的动作'); echo json_encode($res); return 0; } } catch (PDOException $e) {
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; } catch (PDOException $e) { log_info("find user fail: " . $e->getMessage()); $res = show_info('fail', $e->getMessage()); echo json_encode($res); return 1; } }
$stmt->execute(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $members[] = $row['member_id']; } $qids = write_queue_to_db_for_group($db, $members, $mid, $tag_type, $fuid, $fnickB64, $tuid, "txt", $file, strlen($content), ""); if (count($qids) == 0) { $res = show_info('fail', '系统出错'); echo json_encode($res); return; } // 2. 给对方发送通知 foreach ($qids as $member_id => $qid) { if ($member_id == $fuid) { continue; } $ret = send_notice_to_uid("group", $tuid, $fnickB64, $member_id, $tpid, $tag_type, $qid); } $res = show_info('succ', '处理成功'); $res['qid'] = end($qids); $res['queue_file'] = $file; } echo json_encode($res); return; } catch (PDOException $e) { log_info("find user fail: " . $e->getMessage()); $res = show_info('fail', $e->getMessage()); echo json_encode($res); return 1; } } $res['status'] = 'fail';
// 1. 删除好友关系记录 $sql = "DELETE FROM sc_relationship WHERE (myid = {$uid} AND fid = {$tuid}) OR (myid = {$tuid} AND fid = {$uid}) LIMIT 2"; $stmt = $db->prepare($sql); if (!$stmt->execute()) { throw new PDOException('系统出错(2001),请稍候重试 :)'); } $affected_rows = $stmt->rowCount(); if ($affected_rows != 2) { throw new PDOException('系统出错(2001),请稍候重试 :)'); } $need_notice = true; if ($need_notice == true) { $pid = "0"; $nickname = "system"; // 发送一个通知 $ret = send_notice_to_uid($uid, $nickname, $tuid, $tpid, $tag_type, $pid); if ($ret == true) { $res = show_info('succ', '处理成功'); } else { $res = show_info('succ', '处理成功'); } echo json_encode($res); log_info("set friend action: send_notice_to_uid {$ret}"); return 0; } else { log_info("set friend action fail: 请选择执行的动作"); $res = show_info('fail', '请选择执行的动作'); echo json_encode($res); return 0; } } catch (PDOException $e) {