Overview

Packages

  • None
  • WxRobot
    • Admin
    • Cmd
    • CoreFunctions
    • Exends
    • Install
    • Table
    • Uninstall
    • WxSDK

Classes

  • ErrorCode
  • PKCS7Encoder
  • Prpcrypt
  • SHA1
  • Weixin_BaseCore
  • WeiXin_SDK
  • Weixin_Template
  • WXBizMsgCrypt
  • WxRobot_Admin
  • WxRobot_Admin_Menu_Extends
  • WxRobot_Admin_Menu_Instro
  • WxRobot_Admin_Menu_Menu
  • WxRobot_Admin_Menu_Records
  • WxRobot_Admin_Menu_Reply
  • WxRobot_Admin_Menu_Setting
  • WxRobot_Admin_Menu_Statistics
  • WxRobot_Cmd
  • WxRobot_Cmd_Event
  • WxRobot_Cmd_Event_User
  • WxRobot_Cmd_Text
  • WxRobot_Extends
  • WxRobot_Install
  • WxRobot_Robot
  • WxRobot_SDK
  • WxRobot_Table_Extends
  • WxRobot_Table_Menu
  • WxRobot_Table_Records
  • WxRobot_Table_Reply
  • WxRobot_Uninstall
  • WxRobot_Wp
  • XMLParse

Functions

  • wx_admin_log
  • wx_is_xml
  • wx_notice_msg
  • wx_parse_xml
  • wx_random_big_pic
  • wx_random_small_pic
  • wx_request_array
  • wx_request_decode
  • wx_request_is_encode
  • wx_request_xml
  • wx_send_encode
  • Overview
  • Package
  • Class
  1: <?php
  2: /**
  3:  * WxRobot Admin
  4:  * 
  5:  * WP微信机器人后台菜单 - 通信记录页
  6:  *
  7:  * @author      midoks
  8:  * @category    Admin
  9:  * @package     WxRobot/Admin
 10:  * @since       5.3.0
 11:  */
 12: 
 13: if ( ! defined( 'ABSPATH' ) ) {
 14:     exit;
 15: }
 16: 
 17: /**
 18:  * WxRobot_Admin_Menu_Records 通信记录
 19:  */
 20: class WxRobot_Admin_Menu_Records{   
 21:     
 22:     /**
 23:      * 初始化钩子和过滤
 24:      *
 25:      * @return void
 26:      */
 27:     public function init(){}
 28: 
 29: 
 30:     /**
 31:      * 菜单初始化
 32:      *
 33:      * @return void
 34:      */
 35:     public function menu(){
 36:         add_submenu_page('weixin-robot',
 37:             'weixin-robot', 
 38:             '微信机器人记录',
 39:             'manage_options',
 40:             'weixin-robot-records',
 41:             array($this, 'weixin_robot_records'));
 42:     }
 43: 
 44:     /**
 45:      * @func 微信机器人记录
 46:      */
 47:     public function weixin_robot_records(){
 48:         //当前页
 49:         $paged = isset($_GET['paged']) ? $_GET['paged'] : 1;
 50:         //每页显示多少数据
 51:         $pageNum = 20;
 52:         $c = WxRobot_Table_Records::instance()->weixin_get_count();
 53:         $pagePos = ceil($c/$pageNum);
 54:         if($paged > $c){
 55:             $paged = $c;
 56:         }
 57:         if($paged < 1){
 58:             $page = 1;
 59:         }
 60: 
 61:         echo '<h2>微信机器人记录</h2>';
 62: 
 63:         do_action('weixin_robot_records_footer');
 64:         
 65:         $trTpl = "<tr class='wp_weixin_robot_table_head_tr'>
 66:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;color:#21759b;' scope='col'>%s</td>
 67:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;color:#21759b;' scope='col'>%s</td>
 68:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;color:#21759b;' scope='col'>%s</td>
 69:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;color:#21759b;' scope='col'>%s</td>
 70:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;color:#21759b;' scope='col'>%s</td>
 71:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;color:#21759b;' scope='col'>%s</td>
 72:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;color:#21759b;' scope='col'>%s</td>
 73:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;color:#21759b;' scope='col'>%s</td></tr>";
 74:         $tableHeadTpl = sprintf($trTpl, '序号ID', '开发者ID', '用户ID',
 75:             '消息类型', '消息内容', '消息时间', '回复', '响应时间');
 76: 
 77: 
 78:         $tableTrTpl = "<tr class='in_out_event'>
 79:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;width:40px;'>%s</td>
 80:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;width:100px;'>%s</td>
 81:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;width:180px;'>%s</td>
 82:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;width:50px;'>%s</td>
 83:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;'>%s</td>
 84:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;width:130px'>%s</td>
 85:             <td class='wp_weixin_robot_table_head_td' style='text-align:center;width:100px'>%s</td>
 86:             <td title='超过5s,则代表失败!!!' style='text-align:center;width:100px'>%s</td></tr>";
 87:         $tableBodyTpl = '';
 88:         $data = WxRobot_Table_Records::instance()->weixin_get_data($paged);
 89: 
 90:         foreach($data as $k=>$v){
 91:             //var_dump($v);
 92:             $tableHeadTpl .= sprintf($tableTrTpl,   $v['id'], $v['to'], $v['from'],
 93:                 $this->type_replace($v['msgtype']), $v['content'], $v['createtime'], $v['response'], $v['response_time']);
 94:         }
 95: 
 96:         //echo($tableTpl);
 97:         echo '<div class="metabox-holder"><div class="wrap">';
 98:         echo '<table class="wp-list-table widefat fixed" id="user_info">';
 99:         echo '<thead>';
100:         echo($tableHeadTpl);
101:         echo '</thead>';
102:         
103:         echo '<tbody>';
104:         echo($tableBodyTpl);
105:         echo '</tbody>';
106: 
107:         echo '<tfoot>';
108:         //分页显示
109:         echo '<tr><td colspan="8" class="wp_weixin_robot_table_head_td">';
110:         echo($this->weixin_info_page($c, $paged, $pageNum));
111:         echo '</td></tr></tfoot></table></div></div>';
112: 
113:         do_action('weixin_robot_records_footer');
114:         do_action('weixin_midoks_push');
115:     }
116: 
117:     /**
118:      * 消息类型转换
119:      *
120:      * @param string $type 类型
121:      * @return string
122:      */
123:     public function type_replace($type){
124:         switch($type){
125:             //文本消息  
126:             case 'text':return '文本';break;
127:             //图片消息
128:             case 'image':return '图片';break;
129:             //语音消息
130:             case 'voice':return '语音';break;
131:             //视频消息
132:             case 'video':return '视频';break;
133:             //事件消息
134:             case 'event':return '事件';break;
135:             //地理位置
136:             case 'location': return '地理';break;
137:             case 'link':return '连接';break;
138:             //默认消息
139:             default:return '文本';break;
140:         }
141:         return '你傻了吧';
142:     }
143: 
144:     /**
145:      * 分页功能 path版
146:      *
147:      * @param $total    共多少数据
148:      * @param $position 在第几页
149:      * @param $page     每页的数量
150:      * @param $show     显示多少li
151:      * @return void
152:      */
153:     public function weixin_info_page($total, $position, $page=5, $show=7){
154:         $prev = $position-1;//前页
155:         $next = $position+1;//下页
156:         //$showitems = 3;//显示多少li
157:         $big = ceil($show/2);
158:         $small = floor($show/2);//$show最好为奇数 
159:         $total_page = ceil($total/$page);//总页数
160:         //if($prev < 1){$prev = 1;}
161:         if($next > $total_page){$next = $total_page;}
162:         if($position > $total_page){$position = $total_page;}
163:         if(0 != $total_page){
164:             echo "<div>";
165:             echo("<span>总共{$total}条数据/当前第{$position}页<span>");
166:             /////////////////////////////////////////////
167:             echo("<span style='margin-left:30px'><a href='".get_pagenum_link(1)."#' class='fixed'>首页</a></span>");
168:             echo("<span style='margin-left:30px'><a class='p_prev' href='".get_pagenum_link($prev)."#'><<</a></span>");
169:             $j=0;
170:             for($i=1;$i<=$total_page;$i++){
171:                 $url = get_pagenum_link($i);
172:                 if($position==$i)
173:                     $strli = "<span style='margin-left:30px'><a href='".$url."#' class='current' >".$i.'</a></span>';
174:                 else
175:                     $strli =  "<span style='margin-left:30px'><a href='".$url."#' class='inactive' >".$i.'</a></span>';
176:                 if($total_page<=$show){echo $strli;}
177:                 if(($position+$small)>=$total_page){
178:                     //也是对的,下面为简化版
179:                     //if(($j<$show) && ($total_page>$show) && ($i>=($position-($small+($position+$small-$total_page))))){echo($strli);++$j;}
180:                     if(($j<$show) && ($total_page>$show) && ($i>=($total_page-(2*$small)))){echo($strli);++$j;}
181:                 }else{if(($j<$show) && ($total_page>$show) && ($i>=($position-$small))){echo($strli);++$j;}}
182:             }
183:             echo("<span style='margin-left:30px'><a class='p_next' href='".get_pagenum_link($next)."#'>>></a></span>");
184:             echo("<span style='margin-left:30px'><a href='".get_pagenum_link($total_page)."#'>尾页</a></span>");
185:             //////////////////////////////////////////////
186:             echo '</div>';
187:         }
188:     }
189:     
190: }
191: 
192: ?>
193: 
API documentation generated by ApiGen