hxp
2025-06-09 6c3f6335c70859ded94a1ad8d218acb0ac34239c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
set_time_limit(300); //暂时设置本脚本执行时间300秒
include_once "/Common/Logging.php";
include_once "/Common/CommFunc.php";
include_once "/Account/User.php";
include_once "/language/lang.php";
 
 
\Logging\CreateLogging("AddPersonalCompensation.php");
 
$Permission = \User\Permission::P_PersonalMailSend;
$spid = $_SESSION['spid'];
$user = new \User\User($_SESSION['UserAccount']);
if (!$user->HavePermission($Permission)) {
    exit;
}
 
\Logging\LogInfo("_SESSION:" . print_r($_SESSION, true));
\Logging\LogInfo("_POST:" . print_r($_POST, true));
 
$spID = $user->GetSPID();
$readTempContent = \CommFunc\GetFileContents("MailTemp/" . $spID . "_Person.json", "[]");
$mailTempArray = json_decode($readTempContent, true);
if (!$mailTempArray || !count($mailTempArray)) {
    echo "邮件模板加载异常!";
    return;
}
 
$tempCount = count($mailTempArray);
$massSendMaxNum = intval($_POST['massSendMaxNum']);
// echo "<br/>tempCount: " . $tempCount;
// echo "<br/>massSendMaxNum: " . $massSendMaxNum;
 
$postUrl = 'http://' . $_SERVER['HTTP_HOST'] . "/Common/GMCmdProcess.php";
\Logging\LogInfo("postUrl:" . $postUrl);
 
for ($num = 0; $num <= $massSendMaxNum; $num++) {
    if (!array_key_exists("playerList" . $num, $_POST)) {
        continue;
    }
    $tempIndex = $_POST["MailTemp" . $num]; // 模板索引
    if ($tempIndex >= $tempCount) {
        continue;
    }
    $tempInfo = $mailTempArray[$tempIndex];
 
    $pack_data = array();
    $pack_data["playerList"] = $_POST["playerList" . $num];
    $pack_data["queryType"] = $_POST["queryType" . $num];
    $pack_data['playerFind'] = "0"; // 实际不用该参数,兼容旧版用
 
    $pack_data['EndTime'] = date('Y-m-d', strtotime('+' . $tempInfo["EndDays"] . ' day')) . " 00:00:00";
    $pack_data["Title"] = $tempInfo["Title"];
    $pack_data["Text"] = $tempInfo["Text"];
    $pack_data["Gold"] = $tempInfo["Gold"];
    $pack_data["GoldPaper"] = $tempInfo["GoldPaper"];
    $pack_data["Silver"] = $tempInfo["Silver"];
 
    # 物品信息
    $pack_data["itemNums"] = implode(",", array_keys($tempInfo["Items"]));
    foreach ($tempInfo["Items"] as $itemIndex => $itemInfo) {
        $pack_data["ItemID" . $itemIndex] = $itemInfo[0];
        $pack_data["ItemCnt" . $itemIndex] = $itemInfo[1];
        $pack_data["IsBind" . $itemIndex] = $itemInfo[2];
    }
 
    $pack_data["key"] = $_POST["key"];
    $pack_data["Permission"] = \User\Permission::P_PersonalMailSend;
    $pack_data["pack_type"] = "GMT_AddPersonalCompensation"; // 群发模板仅针对个人邮件
 
    $pack_data['tool_page'] = $_SESSION['tool_page'];
    $pack_data['session_username'] = $_SESSION['username']; // post的username参数key做区分,防止功能有同参数名导致覆盖
 
    \Lang\setLang(\Lang\getLang());
    $pack_data['spid'] = $_SESSION['spid'];
    $pack_data['lang'] = \Lang\getLang();
 
    echo '<hr />';
    echo \Lang\gettext("发送邮件") . ": " . $tempInfo["Name"] . "<br/>";
    echo \Lang\gettext("发送目标") . ": " . $pack_data["playerList"] . "<br/>";
    $ret = \CommFunc\DoPost($postUrl, $pack_data, true);
    \Logging\LogInfo("----------------" . $num);
    \Logging\LogInfo("sendData: " . print_r($pack_data, true));
    \Logging\LogInfo("---");
    \Logging\LogInfo("sendRet : " . print_r($ret, true));
    echo $ret;
    echo "<br/>";
}