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: if( !class_exists('WxRobot_Admin_Menu_Setting') ):
 18: 
 19: /**
 20:  * WxRobot_Admin_Menu_Setting 插件功能配置类
 21:  */
 22: class WxRobot_Admin_Menu_Setting{
 23: 
 24: 
 25:     /**
 26:      * 菜单初始化
 27:      *
 28:      * @return void
 29:      */
 30:     public function menu(){
 31:         add_submenu_page('weixin-robot',
 32:             'weixin-robot', 
 33:             '微信机器人设置',
 34:             'manage_options',
 35:             'weixin-robot-setting',
 36:             array($this, 'weixin_robot_setting'));
 37:     }
 38: 
 39:     /**
 40:      * 显示配置选项
 41:      *
 42:      * @return void
 43:      */
 44:     public function weixin_robot_setting(){
 45: 
 46:         $this->weixin_robot_setting_post();
 47: 
 48:         echo '<div class="wrap"><div class="narrow">';
 49:         echo '<form  method="POST">';
 50:         echo '<h2>微信机器人配置</h2>';
 51:         echo '<table class="form-table">';
 52: 
 53:         $this->weixin_robot_setting_table();
 54: 
 55:         echo '<input type="hidden" name="weixin_robot_setting" value="true" />';
 56:         echo '</table>';
 57:         echo '<p class="submit"><input name="submit" type="submit" class="button-primary" value="保存设置" /></p>';
 58:         echo '</form></div></div>';
 59:         
 60:         do_action('weixin_midoks_push');
 61:     }
 62: 
 63:     /**
 64:      * 更新配置信息
 65:      *
 66:      * @return void
 67:      */
 68:     public function weixin_robot_setting_post(){
 69:         
 70:         if( isset($_POST['submit']) && isset($_POST['weixin_robot_setting'])){
 71: 
 72:             $newp = $_POST['weixin_robot_options'];
 73:             $this->options['ai']                        = $newp['ai'];
 74:             $this->options['as']                        = $newp['as'];
 75:             $this->options['subscribe']                 = $newp['subscribe'];
 76:             $this->options['token_url']                 = empty($newp['token_url']) ? 'midoks' : $newp['token_url'];
 77:             $this->options['token']                     = empty($newp['token']) ? 'midoks' : $newp['token'];
 78:             $this->options['opt_pic_show']              = empty($newp['opt_pic_show']) ? '' : $newp['opt_pic_show'];
 79:             $this->options['opt_big_show']              = empty($newp['opt_big_show']) ? '' : $newp['opt_big_show'];
 80:             $this->options['opt_small_show']            = $newp['opt_small_show'];
 81:             $this->options['weixin_robot_debug']        = $newp['weixin_robot_debug'];
 82:             $this->options['weixin_robot_record']       = $newp['weixin_robot_record'];
 83:             $this->options['weixin_robot_helper']       = trim($newp['weixin_robot_helper']);
 84:             $this->options['weixin_robot_helper_is']    = $newp['weixin_robot_helper_is'];
 85:             $this->options['EncodingAESKey']            = $newp['EncodingAESKey'];
 86:             update_option(WEIXIN_ROBOT_OPTIONS, $this->options);
 87: 
 88:             wx_notice_msg('配置更新成功!!!');
 89:         }
 90:     }
 91: 
 92:     /**
 93:      * 配置选项
 94:      *
 95:      * @return void
 96:      */
 97:     public function weixin_robot_setting_table(){
 98:         global $wp;
 99:         $options = get_option(WEIXIN_ROBOT_OPTIONS);
100:         $current_url = home_url(add_query_arg(array(),$wp->request));
101: 
102:         //关注
103:         echo '<tr  valign="top"><th scope="row">订阅事件提示(subscribe)</th>';
104:         echo '<td><textarea name="weixin_robot_options[subscribe]" style="width:350px;height:50px;" class="regular-text code">'
105:             .$options['subscribe'].'</textarea><br />当用户关注时,发送的消息</td></tr>';
106: 
107:         //Token URL
108:         echo '<tr  valign="top"><th scope="row">URL(服务器地址)</th>';
109:         echo '<td><input id="weixin_token_url" url="'.$current_url.'" type="text" name="weixin_robot_options[token_url]" value="';
110:         if(!empty($options['token_url'])){ echo($options['token_url']); }
111:         echo '" size="35"></input><br /><span><b id="weixin_token_url_exp">'.$current_url.'/?'.$options['token_url'].'</b><br/>URL(服务器地址)</span></td></tr>';
112:         echo('<script>jQuery(function($){  $("#weixin_token_url").keyup(function(){
113:             var u = $(this).attr("url");
114:             var t = $(this).val();
115:             $("#weixin_token_url_exp").text(u+"/?"+t);
116:         });  });</script>');
117: 
118:         //Token
119:         echo '<tr  valign="top"><th scope="row">Token(令牌)</th>';
120:         echo '<td><input type="text" name="weixin_robot_options[token]" value="';
121:         if(!empty($options['token'])){ echo($options['token']); }
122:         echo '" size="35"></input><br />Token(令牌)</td></tr>';
123: 
124:         
125: 
126:         //图片最优显示
127:         echo '<tr  valign="top"><th scope="row">图片最优显示</th>';
128:         echo '<td><input type="checkbox" name="weixin_robot_options[opt_pic_show]"  value="true" ';
129:         if( $options['opt_pic_show'] == 'true' ){ echo ' checked="checked"'; }
130:         echo '/>
131:             <br/>是否开启最优图片获取.
132:             <br/>1.开启后会在文章中匹配第一个张图片(如果有多张图片).
133:             <br/>2.如果没有找到,返回你的下面默认大小图片地址
134:             <br/>3.如过默认大小也没有设置,会返会本插件自带图片
135:             <br/><span style="color:red">note:开启图片防盗链的话,还是不要开启为好.覆盖原来的图片就很好!</span></td></tr>';
136: 
137:         //大图地址
138:         echo '<tr valign="top"><th scope="row">大图显示地址</th>';
139:         echo '<td><textarea name="weixin_robot_options[opt_big_show]" style="width:350px;height:50px;" class="regular-text code">'
140:             .$options['opt_big_show'].'</textarea><br/>多个图片地址,回车换行来区分|官方建议大图为:360*200</td></tr>';
141: 
142:         //小图地址
143:         echo '<tr valign="top"><th scope="row">小图显示地址</th>';
144:         echo '<td><textarea name="weixin_robot_options[opt_small_show]" style="width:350px;height:50px;" class="regular-text code">'
145:             .$options['opt_small_show'].'</textarea><br/>多个图片地址,回车换行来区分|官方建议大图为:200*200</td></tr>';
146: 
147: 
148:         //数据开启数据记录
149:         echo '<tr  valign="top"><th scope="row">是否开启数据记录</th>';
150:         echo '<td><input type="checkbox" name="weixin_robot_options[weixin_robot_record]"  value="true" ';
151:         if( $options['weixin_robot_record'] == 'true' ){ echo ' checked="checked"'; }
152:         echo '/><td></tr>';
153: 
154:         //是否开启测试模式
155:         echo '<tr  valign="top"><th scope="row">是否开启测试模式</th>';
156:         echo '<td><input type="checkbox" name="weixin_robot_options[weixin_robot_debug]"  value="true"';
157:         if( $options['weixin_robot_debug'] == 'true' ){ echo ' checked="checked"'; }
158:         echo '/></td></tr>';
159: 
160:         //帮助信息
161:         echo '<tr valign="top"><th scope="row">帮助信息</th>';
162:         echo '<td><textarea name="weixin_robot_options[weixin_robot_helper]" style="width:350px;height:100px;" class="regular-text code">'
163:             .$options['weixin_robot_helper'].'</textarea><br/><span style="color:red;">帮助信息(note:微信一行12字左右)</span></td></tr>';
164: 
165:         //是否启动无此命令不回复选项(设置后台,无匹配关键字将不返回任何信息)
166:         echo '<tr  valign="top"><th scope="row">是否启动无此匹配命令不回复</th>';
167:         echo '<td><input type="checkbox" name="weixin_robot_options[weixin_robot_helper_is]"  value="true"';
168:         if( $options['weixin_robot_helper_is'] == 'true' ){ echo ' checked="checked"'; }
169:         echo '/><br/>开启后,只有<span style="color:red;">?</span>回复帮助信息</td>';
170: 
171:         //服务号设置(公司相关)
172:         //ai
173:         echo '<tr valign="top"><td scope="row" colspan="2"><h2>服务号设置</h2><br/>说明:如果你不是服务号,请不要设置</td></tr>';
174:         echo '<tr valign="top"><th scope="row">appID</th>';
175:         echo '<td><input type="text" name="weixin_robot_options[ai]" value="'
176:             .$options['ai'].'" size="35"></input><br />微信公众平台开发者ID(第三方用户唯一凭证)</td></tr>';
177:         
178:         //as
179:         echo '<tr valign="top"><th scope="row">appsecret</th>';
180:         echo '<td><input type="text" name="weixin_robot_options[as]" value="'
181:             .$options['as'].'" size="35"></input><br />appsecret(第三方用户唯一凭证密钥)</td></tr>';
182:         
183:         //EncodingAESKey
184:         echo '<tr valign="top"><th scope="row">EncodingAESKey(密钥)</th>';
185:         echo '<td><input type="text" name="weixin_robot_options[EncodingAESKey]" value="';
186:         if(!empty($options['EncodingAESKey'])){ echo($options['EncodingAESKey']); }
187:         echo '" size="35"></input><br />EncodingAESKey(消息加解密密钥)[安全和兼容模式必须填写]</td></tr>';
188: 
189:         do_action('wx_admin_setting');
190:     }
191:     
192: }
193: 
194: endif;
195: ?>
196: 
API documentation generated by ApiGen