Example #1
0
    function load()
    {
        parent::load();
        $this->sendMail = TRUE;
        $this->isInbox = TRUE;
        $this->viewOnly = FALSE;
        $this->showFriendPane = FALSE;
        $this->errorText = '';
        $this->showList = !(isset($_GET['t']) && is_numeric($_GET['t']) && intval($_GET['t']) == 1);
        $this->selectedTabIndex = isset($_GET['t']) && is_numeric($_GET['t']) && 1 <= intval($_GET['t']) && intval($_GET['t']) <= 2 ? intval($_GET['t']) : 0;
        $this->friendList = array();
        $friends_player_ids = trim($this->data['friend_players']);
        if ($friends_player_ids != '') {
            $friends_player_ids = explode('
', $friends_player_ids);
            foreach ($friends_player_ids as $friend) {
                list($playerId, $playerName) = explode(' ', $friend);
                $this->friendList[$playerId] = $playerName;
            }
        }
        $m = new MessageModel();
        if (!$this->isPost()) {
            if (isset($_GET['uid']) && is_numeric($_GET['uid']) && 0 < intval($_GET['uid'])) {
                $this->receiver = $m->getPlayerNameById(intval($_GET['uid']));
                $this->showList = FALSE;
                $this->selectedTabIndex = 1;
            } else {
                if (isset($_GET['id']) && is_numeric($_GET['id']) && 0 < intval($_GET['id'])) {
                    $result = $m->getMessage($this->player->playerId, intval($_GET['id']));
                    if ($result->next()) {
                        $this->viewOnly = TRUE;
                        $this->showList = FALSE;
                        $this->isInbox = $result->row['to_player_id'] == $this->player->playerId;
                        $this->sendMail = !$this->isInbox;
                        $this->receiver = $this->isInbox ? $result->row['from_player_name'] : $result->row['to_player_name'];
                        $this->subject = $result->row['msg_title'];
                        $this->body = $this->getFilteredText($result->row['msg_body']);
                        $this->messageDate = $result->row['mdate'];
                        $this->messageTime = $result->row['mtime'];
                        $this->selectedTabIndex = $this->isInbox ? 0 : 2;
                        if ($this->isInbox && !$result->row['is_readed'] && !$this->player->isSpy) {
                            $m->markMessageAsReaded($this->player->playerId, intval($_GET['id']));
                            --$this->data['new_mail_count'];
                        }
                    } else {
                        $this->showList = TRUE;
                        $this->selectedTabIndex = 0;
                    }
                    $result->free();
                }
            }
        } else {
            if (isset($_POST['sm'])) {
                $this->receiver = trim($_POST['an']);
                $this->subject = trim($_POST['be']);
                $this->body = $_POST['message'];
                if (trim($this->receiver) == '') {
                    $this->showList = FALSE;
                    $this->selectedTabIndex = 1;
                    $this->errorText = messages_p_noreceiver . '<p></p>';
                    $m->dispose();
                    return null;
                }
                if (trim($this->body) == '') {
                    $this->showList = FALSE;
                    $this->selectedTabIndex = 1;
                    $this->errorText = messages_p_nobody . '<p></p>';
                    $m->dispose();
                    return null;
                }
                if (strtolower(trim($this->receiver)) == '[ally]' && 0 < intval($this->data['alliance_id']) && $this->hasAllianceSendMessageRole()) {
                    $pids = trim($m->getAlliancePlayersId(intval($this->data['alliance_id'])));
                    if ($pids != '') {
                        if ($this->subject == '') {
                            $this->subject = messages_p_emptysub;
                        }
                        $arr = explode(',', $pids);
                        foreach ($arr as $apid) {
                            if ($apid == $this->player->playerId) {
                                continue;
                            }
                            $m->sendMessage($this->player->playerId, $this->data['name'], $apid, $m->getPlayerNameById($apid), $this->subject, $this->body);
                        }
                        $this->showList = TRUE;
                        $this->selectedTabIndex = 2;
                    }
                } else {
                    $receiverPlayerId = $m->getPlayerIdByName($this->receiver);
                    if (0 < intval($receiverPlayerId)) {
                        if ($receiverPlayerId == $this->player->playerId) {
                            $this->showList = FALSE;
                            $this->selectedTabIndex = 1;
                            $this->errorText = '<b>' . messages_p_noloopback . '</b><p></p>';
                        } else {
                            if ($this->subject == '') {
                                $this->subject = messages_p_emptysub;
                            }
                            $m->sendMessage($this->player->playerId, $this->data['name'], $receiverPlayerId, $this->receiver, $this->subject, $this->body);
                            $this->showList = TRUE;
                            $this->selectedTabIndex = 2;
                        }
                    } else {
                        $this->showList = FALSE;
                        $this->selectedTabIndex = 1;
                        $this->errorText = messages_p_notexists . ' <b>' . $this->receiver . '</b><p></p>';
                    }
                }
            } else {
                if (isset($_POST['fm'])) {
                    $this->receiver = trim($_POST['an']);
                    $this->subject = trim($_POST['be']);
                    $this->body = $_POST['message'];
                    $this->showList = FALSE;
                    $this->selectedTabIndex = 1;
                    $this->showFriendPane = TRUE;
                    if ($_POST['fm'] != '' && is_numeric($_POST['fm'])) {
                        $playerId = intval($_POST['fm']);
                        if (0 < $playerId && isset($this->friendList[$playerId])) {
                            unset($this->friendList[$playerId]);
                        }
                    } else {
                        if (isset($_POST['mfriends'])) {
                            foreach ($_POST['mfriends'] as $friendName) {
                                $friendName = trim($friendName);
                                if ($friendName == '') {
                                    continue;
                                }
                                $playerId = intval($m->getPlayerIdByName($friendName));
                                if (0 < $playerId && !isset($this->friendList[$playerId]) && $playerId != $this->player->playerId) {
                                    $this->friendList[$playerId] = $friendName;
                                    continue;
                                }
                            }
                        }
                    }
                    $friends = '';
                    foreach ($this->friendList as $k => $v) {
                        if ($friends != '') {
                            $friends .= '
';
                        }
                        $friends .= $k . ' ' . $v;
                    }
                    $m->saveFriendList($this->player->playerId, $friends);
                } else {
                    if (isset($_POST['rm'])) {
                        $this->receiver = trim($_POST['an']);
                        $this->subject = trim($_POST['be']);
                        $this->body = PHP_EOL . PHP_EOL . '_________________________________' . PHP_EOL . text_from_lang . ' ' . $this->receiver . ':' . PHP_EOL . PHP_EOL . $_POST['message'];
                        preg_match('/^(RE)\\^?([0-9]*):([\\w\\W]*)$/', $this->subject, $matches);
                        if (sizeof($matches) == 4) {
                            $this->subject = 'RE^' . ($matches[2] + 1) . ':' . $matches[3];
                        } else {
                            $this->subject = 'RE: ' . $this->subject;
                        }
                        $this->showList = FALSE;
                        $this->selectedTabIndex = 1;
                    } else {
                        if (isset($_POST['dm'])) {
                            if (isset($_POST['dm'])) {
                                foreach ($_POST['dm'] as $messageId) {
                                    if ($m->deleteMessage($this->player->playerId, $messageId)) {
                                        --$this->data['new_mail_count'];
                                        continue;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if ($this->showList) {
            $rowsCount = $m->getMessageListCount($this->player->playerId, $this->selectedTabIndex == 0);
            $this->pageCount = 0 < $rowsCount ? ceil($rowsCount / $this->pageSize) : 1;
            $this->pageIndex = isset($_GET['p']) && is_numeric($_GET['p']) && intval($_GET['p']) < $this->pageCount ? intval($_GET['p']) : 0;
            $this->dataList = $m->getMessageList($this->player->playerId, $this->selectedTabIndex == 0, $this->pageIndex, $this->pageSize);
            if (0 < $this->data['new_mail_count']) {
                $this->data['new_mail_count'] = $m->syncMessages($this->player->playerId);
            }
        }
        $m->dispose();
    }
Example #2
0
 function newReadQuiz($quizNumber, $m, $quizArray)
 {
     switch ($quizNumber) {
         case 6:
             $this->clientAction = 2;
             require_once MODEL_PATH . 'msg.php';
             $mm = new MessageModel();
             $messageId = $mm->sendMessage(1, $this->appConfig['system']['adminName'], $this->player->playerId, $this->data['name'], guide_task_msg_subject, guide_task_msg_body);
             $quizArray[] = $messageId;
             $m->setGuideTask($this->player->playerId, implode(',', $quizArray));
             break;
         case 7:
             $map_size = $this->setupMetadata['map_size'];
             $_x = $this->data['rel_x'];
             $_y = $this->data['rel_y'];
             $mapMatrix = implode(',', $this->__getVillageMatrix($map_size, $_x, $_y, 3));
             $reader = $m->getVillagesMatrix($mapMatrix);
             $availableVillages = array();
             while ($reader->next()) {
                 if (!$reader->row['is_oasis'] && 0 < intval($reader->row['player_id']) && intval($reader->row['player_id']) != $this->player->playerId) {
                     $availableVillages[] = array($reader->row['rel_x'], $reader->row['rel_y'], $reader->row['village_name']);
                     continue;
                 }
             }
             if (sizeof($availableVillages) == 0) {
                 $availableVillages[] = array($this->data['rel_x'], $this->data['rel_y'], $this->data['village_name']);
             }
             $r_indx = mt_rand(0, sizeof($availableVillages) - 1);
             $this->guideData['vname'] = $availableVillages[$r_indx][2];
             $quizArray[] = implode('|', $availableVillages[$r_indx]);
             $m->setGuideTask($this->player->playerId, implode(',', $quizArray));
             break;
         case 20:
         case 21:
             $this->taskState = $quizArray[sizeof($quizArray) - 1] == 1 ? 2 : 0;
             $this->guideData['troop_id'] = $this->getFirstTroopId($this->data['tribe_id']);
             $this->guideData['troop_name'] = constant('troop_' . $this->guideData['troop_id']);
     }
 }
Example #3
0
 function kaixinMessageAction()
 {
     $title = "寒假不规划,开学差距大";
     $type = 1;
     $messageType = Common_Config::UDO_SCHOOL_MESSAGE_TYPE;
     $retry = 0;
     $result = -1;
     $messageModel = new MessageModel();
     $receiveUserId = $messageModel->kaixinUser();
     //print_r($receiveUserId);
     //print_r($receiveUserId);
     $text = "乐学课堂2016年最走心的陪伴式学习";
     //print_r($receiveUserId);
     //print_r($text);
     $custom_data_raw = json_encode(array("school_id" => 2782, "course_id" => "", "url" => "http://123.57.182.19:8520/"));
     $mid = $messageModel->messageLog($type, $messageType, $custom_data_raw, 0, $receiveUserId, null, $title, $text);
     $custom_data = json_encode(array("id" => $mid, "school_id" => 2782, "course_id" => "", "url" => "http://123.57.224.126:8524/", "prof_type" => 100, "title" => $title, "text" => $text));
     //print_r($custom_data);
     //如果发送失败,再尝试三次
     while ($retry <= 3 and $result == -1) {
         $result = $messageModel->sendMessage($type, $custom_data, $receiveUserId, $custom_data, $title, $text);
         //print_r($result);
         $retry++;
     }
     //print_r($retry);
     //print_r($result);
 }
Example #4
0
 function checkUncertainNotify()
 {
     $tblTrans = new DB_Udo_TransNotify();
     $messageModel = new MessageModel();
     //ignore_user_abort();//关掉浏览器,PHP脚本也可以继续执行.
     set_time_limit(0);
     // 通过set_time_limit(0)可以让程序无限制的执行下去
     $interval = 5;
     // 每隔半小时运行
     $isSolid = Common_Config::NOTIFY_UNCERTAIN;
     $now = time();
     $diff = 60 * 60;
     do {
         //查询是否存在限时内未确认的交易状态
         $result = $tblTrans->fetchAll("uid,transNo,createTime", "where isSolid = {$isSolid} and ({$now}-createTime)<= {$diff}");
         if ($result) {
             $userArray = [];
             foreach ($result as $k => $value) {
                 $notify = $this->getOrderResult($value['uid'], $value['transNo']);
                 //如果存在状态改变的,就将接收消息的用户列表中插入一条数据
                 if ($notify != Common_Error::ERROR_TRANS_UNKNOWN) {
                     array_push($userArray, $value['uid']);
                 }
             }
             //如果有接收用户,那么发送消息
             if ($userArray) {
                 $type = 1;
                 $custom_data = "";
                 $title = "支付状态确认";
                 $text = "您有一笔订单的交易状态已经确认";
                 $messageModel->sendMessage($type, $custom_data, $userArray, $custom_data, $title, $text);
             }
         } else {
             $result = $tblTrans->fetchAll("id,uid,transNo,createTime", "where isSolid = {$isSolid} and ({$now}-createTime)> {$diff}");
             $userArray = [];
             foreach ($result as $k => $value) {
                 array_push($userArray, $value['id']);
                 $notifySolid = Common_Config::NOTIFY_SOLID;
                 //$update = $tblTrans->update("{$value['id']}",array("transNo = {$notifySolid}"));
                 $update = $tblTrans->query("update udo_trans_notify set isSolid = {$notifySolid} where id = {$value['id']}");
             }
             //如果有接收用户,那么发送消息
             if ($userArray) {
                 $type = 1;
                 $custom_data = "";
                 $title = "支付状态确认";
                 $text = "您有一笔订单的交易已经关闭";
                 $messageModel->sendMessage($type, $custom_data, $userArray, $custom_data, $title, $text);
             }
         }
         //$result = $tblTrans->scalar("*","where isSolid = {$isSolid} and ({$now}-createTime)< {$diff}");
         //这里是你要执行的代码
         //sleep($interval);// 等待5分钟
     } while (true);
 }