当前位置: 首页>>代码示例>>PHP>>正文


PHP MainWP_Utility::fetchUrlNotAuthed方法代码示例

本文整理汇总了PHP中MainWP_Utility::fetchUrlNotAuthed方法的典型用法代码示例。如果您正苦于以下问题:PHP MainWP_Utility::fetchUrlNotAuthed方法的具体用法?PHP MainWP_Utility::fetchUrlNotAuthed怎么用?PHP MainWP_Utility::fetchUrlNotAuthed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MainWP_Utility的用法示例。


在下文中一共展示了MainWP_Utility::fetchUrlNotAuthed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addSite

 public static function addSite($website)
 {
     $error = '';
     $message = '';
     if ($website) {
         $error = __('Your site is already added to MainWP', 'mainwp');
     } else {
         try {
             //Add
             if (function_exists('openssl_pkey_new')) {
                 $conf = array('private_key_bits' => 384);
                 $conf_loc = MainWP_System::get_openssl_conf();
                 if (!empty($conf_loc)) {
                     $conf['config'] = $conf_loc;
                 }
                 $res = openssl_pkey_new($conf);
                 @openssl_pkey_export($res, $privkey, null, $conf);
                 $pubkey = openssl_pkey_get_details($res);
                 $pubkey = $pubkey['key'];
             } else {
                 $privkey = '-1';
                 $pubkey = '-1';
             }
             $url = $_POST['managesites_add_wpurl'];
             $pluginConflicts = get_option('mainwp_pluginConflicts');
             if ($pluginConflicts !== false) {
                 $pluginConflicts = array_keys($pluginConflicts);
             }
             $themeConflicts = get_option('mainwp_themeConflicts');
             if ($themeConflicts !== false) {
                 $themeConflicts = array_keys($themeConflicts);
             }
             // to fix bug
             if (is_array($pluginConflicts)) {
                 $pluginConflicts = array_filter($pluginConflicts);
             }
             if (is_array($themeConflicts)) {
                 $themeConflicts = array_filter($themeConflicts);
             }
             $verifyCertificate = !isset($_POST['verify_certificate']) || empty($_POST['verify_certificate']) ? null : $_POST['verify_certificate'];
             $sslVersion = MainWP_Utility::getCURLSSLVersion(!isset($_POST['ssl_version']) || empty($_POST['ssl_version']) ? null : $_POST['ssl_version']);
             $addUniqueId = isset($_POST['managesites_add_uniqueId']) ? $_POST['managesites_add_uniqueId'] : '';
             $http_user = isset($_POST['managesites_add_http_user']) ? $_POST['managesites_add_http_user'] : '';
             $http_pass = isset($_POST['managesites_add_http_pass']) ? $_POST['managesites_add_http_pass'] : '';
             $information = MainWP_Utility::fetchUrlNotAuthed($url, $_POST['managesites_add_wpadmin'], 'register', array('pubkey' => $pubkey, 'server' => get_admin_url(), 'uniqueId' => $addUniqueId, 'pluginConflicts' => json_encode($pluginConflicts), 'themeConflicts' => json_encode($themeConflicts)), false, $verifyCertificate, $http_user, $http_pass, $sslVersion);
             if (isset($information['error']) && $information['error'] != '') {
                 $error = $information['error'];
             } else {
                 if (isset($information['register']) && $information['register'] == 'OK') {
                     //Add website to database
                     $groupids = array();
                     $groupnames = array();
                     if (isset($_POST['groupids'])) {
                         foreach ($_POST['groupids'] as $group) {
                             $groupids[] = $group;
                         }
                     }
                     if (isset($_POST['groupnames']) && $_POST['groupnames'] != '' || isset($_POST['groupnames_import']) && $_POST['groupnames_import'] != '') {
                         if ($_POST['groupnames']) {
                             $tmpArr = explode(',', $_POST['groupnames']);
                         } else {
                             if ($_POST['groupnames_import']) {
                                 $tmpArr = explode(';', $_POST['groupnames_import']);
                             }
                         }
                         foreach ($tmpArr as $tmp) {
                             $group = MainWP_DB::Instance()->getGroupByNameForUser(trim($tmp));
                             if ($group) {
                                 if (!in_array($group->id, $groupids)) {
                                     $groupids[] = $group->id;
                                 }
                             } else {
                                 $groupnames[] = trim($tmp);
                             }
                         }
                     }
                     if (!isset($information['uniqueId']) || empty($information['uniqueId'])) {
                         $addUniqueId = '';
                     }
                     $http_user = isset($_POST['managesites_add_http_user']) ? $_POST['managesites_add_http_user'] : '';
                     $http_pass = isset($_POST['managesites_add_http_pass']) ? $_POST['managesites_add_http_pass'] : '';
                     global $current_user;
                     $id = MainWP_DB::Instance()->addWebsite($current_user->ID, $_POST['managesites_add_wpname'], $_POST['managesites_add_wpurl'], $_POST['managesites_add_wpadmin'], base64_encode($pubkey), base64_encode($privkey), $information['nossl'], isset($information['nosslkey']) ? $information['nosslkey'] : null, $groupids, $groupnames, $verifyCertificate, $addUniqueId, $http_user, $http_pass, $sslVersion);
                     $message = sprintf(__('Site successfully added - Visit the Site\'s %sDashboard%s now.', 'mainwp'), '<a href="admin.php?page=managesites&dashboard=' . $id . '" style="text-decoration: none;" title="' . __('Dashboard', 'mainwp') . '">', '</a>');
                     $website = MainWP_DB::Instance()->getWebsiteById($id);
                     MainWP_Sync::syncInformationArray($website, $information);
                 } else {
                     $error = __('Undefined error.', 'mainwp');
                 }
             }
         } catch (MainWP_Exception $e) {
             if ($e->getMessage() == 'HTTPERROR') {
                 $error = 'HTTP error' . ($e->getMessageExtra() != null ? ' - ' . $e->getMessageExtra() : '');
             } else {
                 if ($e->getMessage() == 'NOMAINWP') {
                     $error = __('No MainWP Child plugin detected, first install and activate the plugin and add your site to MainWP afterwards. If you continue experiencing this issue please ', 'mainwp');
                     if ($e->getMessageExtra() != null) {
                         $error .= sprintf(__('test your connection %shere%s or ', 'mainwp'), '<a href="' . admin_url('admin.php?page=managesites&do=test&site=' . urlencode($e->getMessageExtra())) . '">', '</a>');
                     }
                     $error .= sprintf(__('post as much information as possible on the error in the %ssupport forum%s.', 'mainwp'), '<a href="https://mainwp.com/forum/">', '</a>');
//.........这里部分代码省略.........
开发者ID:senlin,项目名称:mainwp,代码行数:101,代码来源:view-mainwp-manage-sites-view.php

示例2: performAllChecks

 public static function performAllChecks()
 {
     $websites = MainWP_DB::Instance()->getOfflineChecks();
     foreach ($websites as $website) {
         if ($website->sync_errors != '') {
             try {
                 //Add
                 if (function_exists('openssl_pkey_new')) {
                     $conf = array('private_key_bits' => 384);
                     $conf_loc = MainWP_System::get_openssl_conf();
                     if (!empty($conf_loc)) {
                         $conf['config'] = $conf_loc;
                     }
                     $res = openssl_pkey_new($conf);
                     @openssl_pkey_export($res, $privkey, null, $conf);
                     $pubkey = openssl_pkey_get_details($res);
                     $pubkey = $pubkey['key'];
                 } else {
                     $privkey = '-1';
                     $pubkey = '-1';
                 }
                 $information = MainWP_Utility::fetchUrlNotAuthed($website->url, $website->adminname, 'register', array('pubkey' => $pubkey, 'server' => get_admin_url(), 'uniqueId' => $website->uniqueId), false, $website->verify_certificate, $website->http_user, $website->http_pass, $website->ssl_version);
                 if (!isset($information['error']) || $information['error'] == '') {
                     if (isset($information['register']) && $information['register'] == 'OK') {
                         //Update website
                         MainWP_DB::Instance()->updateWebsiteValues($website->id, array('pubkey' => base64_encode($pubkey), 'privkey' => base64_encode($privkey), 'nossl' => $information['nossl'], 'nosslkey' => isset($information['nosslkey']) ? $information['nosslkey'] : '', 'uniqueId' => isset($information['uniqueId']) ? $information['uniqueId'] : ''));
                         $message = 'Site successfully reconnected';
                         MainWP_Sync::syncInformationArray($website, $information);
                     }
                 }
             } catch (Exception $e) {
             }
         }
         self::performCheck($website);
     }
 }
开发者ID:jexmex,项目名称:mainwp,代码行数:36,代码来源:page-mainwp-offline-checks.php

示例3: checkSite

 public static function checkSite()
 {
     $website = MainWP_DB::Instance()->getWebsitesByUrl($_POST['url']);
     $ret = array();
     if (MainWP_Utility::can_edit_website($website)) {
         //Already added to the database - so exists.
         $ret['response'] = 'ERROR You already added your site to MainWP';
     } else {
         try {
             $verify_cert = !isset($_POST['verify_certificate']) || empty($_POST['verify_certificate']) && $_POST['verify_certificate'] !== '0' ? null : $_POST['verify_certificate'];
             $http_user = isset($_POST['http_user']) ? $_POST['http_user'] : '';
             $http_pass = isset($_POST['http_pass']) ? $_POST['http_pass'] : '';
             $information = MainWP_Utility::fetchUrlNotAuthed($_POST['url'], $_POST['admin'], 'stats', null, false, $verify_cert, $http_user, $http_pass);
             //Fetch the stats with the given admin name
             if (isset($information['wpversion'])) {
                 //Version found - able to add
                 $ret['response'] = 'OK';
             } else {
                 if (isset($information['error'])) {
                     //Error
                     $ret['response'] = 'ERROR ' . $information['error'];
                 } else {
                     //Should not occur?
                     $ret['response'] = 'ERROR';
                 }
             }
         } catch (MainWP_Exception $e) {
             //Exception - error
             $ret['response'] = $e->getMessage();
         }
     }
     $ret['check_me'] = isset($_POST['check_me']) ? $_POST['check_me'] : null;
     die(json_encode($ret));
 }
开发者ID:reeslo,项目名称:mainwp,代码行数:34,代码来源:page-mainwp-manage-sites.php


注:本文中的MainWP_Utility::fetchUrlNotAuthed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。