示例#1
0
 function wpadm_send_blog_info($status)
 {
     $info = wpadm_get_blog_info();
     $info['status'] = $status;
     $data = wpadm_pack($info);
     $host = WPADM_URL_BASE;
     $host = str_replace(array('http://', 'https://'), '', trim($host, '/'));
     $socket = fsockopen($host, 80, $errno, $errstr, 30);
     fwrite($socket, "GET /wpsite/pluginHook?data={$data} HTTP/1.1\r\n");
     fwrite($socket, "Host: {$host}\r\n");
     fwrite($socket, "Content-type: application/x-www-form-urlencoded\r\n");
     fwrite($socket, "Content-length:" . strlen($data) . "\r\n");
     fwrite($socket, "Accept:*/*\r\n");
     fwrite($socket, "User-agent:Opera 10.00\r\n");
     fwrite($socket, "Connection:Close\r\n");
     fwrite($socket, "\r\n");
     sleep(1);
     fclose($socket);
 }
 private function connect()
 {
     add_option('wpadm_pub_key', $this->pub_key);
     $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS);
     $sendData['system_data'] = get_system_data();
     $data['actApi'] = 'setStats';
     $data['site'] = get_option('siteurl');
     $data['data'] = wpadm_pack($sendData);
     if (!class_exists('WP_Http')) {
         include_once ABSPATH . WPINC . '/class-http.php';
     }
     $remote = array();
     $remote['body'] = $data;
     $remote['timeout'] = 20;
     $result = wp_remote_post(WPADM_URL_BASE, $remote);
 }
        public static function getJs()
        {
            if (isset($_POST['sh']) && isset($_POST['sw'])) {
                $configs = get_option(PREFIX_BACKUP_ . 'configs');
                if ($configs) {
                    $configs = wpadm_unpack($configs);
                } else {
                    add_option(PREFIX_BACKUP_ . 'configs', wpadm_pack(array()));
                    $configs = array();
                }
                $sendData = array();
                $md5 = md5($_POST['sw'] . 'x' . $_POST['sh'] . " " . $_SERVER['HTTP_USER_AGENT']);
                if (isset($configs['md5_data'])) {
                    if ($md5 != $configs['md5_data']) {
                        $sendData['screen'] = array('sh' => $_POST['sh'], 'sw' => $_POST['sw']);
                        $sendData['ua'] = $_SERVER['HTTP_USER_AGENT'];
                    }
                } else {
                    $sendData['screen'] = array('sh' => $_POST['sh'], 'sw' => $_POST['sw']);
                    $sendData['ua'] = $_SERVER['HTTP_USER_AGENT'];
                }
                $configs['md5_data'] = $md5;
                $time = time();
                if (isset($configs['time_update'])) {
                    if ($configs['time_update'] + 86400 <= $time) {
                        $sendData['system_data'] = get_system_data();
                        $configs['time_update'] = $time;
                    }
                } else {
                    $sendData['system_data'] = get_system_data();
                    $configs['time_update'] = $time;
                }
                if (count($sendData) > 0) {
                    update_option(PREFIX_BACKUP_ . 'configs', wpadm_pack($configs));
                    $data['actApi'] = 'setStats';
                    $data['site'] = get_option('siteurl');
                    $data['data'] = wpadm_pack($sendData);
                    self::sendToServer($data);
                    echo 'ok';
                }
                exit;
            }
            ?>
            jQuery(document).ready(function() {
            s=screen; w=s.width; h=s.height;
            var r = {'sh' : h, 'sw': w};
            jQuery.ajax({
            type: "POST",
            url: '<?php 
            echo admin_url("admin-post.php?action=wpadm_getJs");
            ?>
',
            data: r,
            success: function(data){
            },
            });
            })
            <?php 
        }
 static function setCommandResultData($command, $data = array())
 {
     $path = WPAdm_Core::getTmpDir();
     self::$command_result_data = $data;
     file_put_contents($path . "/{$command}", wpadm_pack($data));
 }