本文整理汇总了PHP中MainWP_Utility::fetchUrlAuthed方法的典型用法代码示例。如果您正苦于以下问题:PHP MainWP_Utility::fetchUrlAuthed方法的具体用法?PHP MainWP_Utility::fetchUrlAuthed怎么用?PHP MainWP_Utility::fetchUrlAuthed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainWP_Utility
的用法示例。
在下文中一共展示了MainWP_Utility::fetchUrlAuthed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgradePluginTheme
function upgradePluginTheme()
{
try {
$websiteId = $type = null;
$slugs = array();
if (isset($_POST['websiteId'])) {
$websiteId = $_POST['websiteId'];
}
if (isset($_POST['slugs'])) {
$slugs = $_POST['slugs'];
}
if (isset($_POST['type'])) {
$type = $_POST['type'];
}
$error = '';
if ($type == 'plugin' && !mainwp_current_user_can('dashboard', 'update_plugins')) {
$error = mainwp_do_not_have_permissions(__('update plugins', 'mainwp'), false);
} else {
if ($type == 'theme' && !mainwp_current_user_can('dashboard', 'update_themes')) {
$error = mainwp_do_not_have_permissions(__('update themes', 'mainwp'), false);
}
}
if (!empty($error)) {
die(json_encode(array('error' => $error)));
}
if (MainWP_Utility::ctype_digit($websiteId)) {
$website = MainWP_DB::Instance()->getWebsiteById($websiteId);
if (MainWP_Utility::can_edit_website($website)) {
$information = MainWP_Utility::fetchUrlAuthed($website, 'upgradeplugintheme', array('type' => $type, 'list' => urldecode(implode(',', $slugs))));
die(json_encode($information));
}
}
} catch (MainWP_Exception $e) {
die(json_encode(array('error' => $e->getMessage())));
}
die;
}
示例2: hookFetchUrlAuthed
public static function hookFetchUrlAuthed($pluginFile, $key, $websiteId, $what, $params)
{
if (!self::hookVerify($pluginFile, $key)) {
return false;
}
try {
$website = MainWP_DB::Instance()->getWebsiteById($websiteId);
if (!MainWP_Utility::can_edit_website($website)) {
throw new MainWP_Exception('You can not edit this website.');
}
return MainWP_Utility::fetchUrlAuthed($website, $what, $params);
} catch (MainWP_Exception $e) {
return array('error' => $e->getMessage());
}
}
示例3: action
public static function action($pAction)
{
$plugin = $_POST['plugin'];
$websiteIdEnc = $_POST['websiteId'];
if (empty($plugin)) {
die(json_encode(array('error' => 'Invalid Request.')));
}
$websiteId = $websiteIdEnc;
if (!MainWP_Utility::ctype_digit($websiteId)) {
die(json_encode(array('error' => 'Invalid Request.')));
}
$website = MainWP_DB::Instance()->getWebsiteById($websiteId);
if (!MainWP_Utility::can_edit_website($website)) {
die(json_encode(array('error' => 'You can not edit this website.')));
}
try {
$information = MainWP_Utility::fetchUrlAuthed($website, 'plugin_action', array('action' => $pAction, 'plugin' => $plugin));
} catch (MainWP_Exception $e) {
die(json_encode(array('error' => $e->getMessage())));
}
if (!isset($information['status']) || $information['status'] != 'SUCCESS') {
die(json_encode(array('error' => 'Unexpected error.')));
}
}
示例4: mainwp_cronupdatescheck_action
//.........这里部分代码省略.........
return;
}
if (get_option('mainwp_automaticDailyUpdate') != 1) {
return;
}
//Check if backups are required!
if (get_option('mainwp_backup_before_upgrade') == 1) {
$sitesCheckCompleted = get_option('mainwp_automaticUpdate_backupChecks');
if (!is_array($sitesCheckCompleted)) {
$sitesCheckCompleted = array();
}
$websitesToCheck = array();
foreach ($pluginsToUpdateNow as $websiteId => $slugs) {
$websitesToCheck[$websiteId] = true;
}
foreach ($themesToUpdateNow as $websiteId => $slugs) {
$websitesToCheck[$websiteId] = true;
}
foreach ($coreToUpdateNow as $websiteId) {
$websitesToCheck[$websiteId] = true;
}
foreach ($websitesToCheck as $siteId => $bool) {
if ($allWebsites[$siteId]->backup_before_upgrade == 0) {
$sitesCheckCompleted[$siteId] = true;
}
if (isset($sitesCheckCompleted[$siteId])) {
continue;
}
$dir = MainWP_Utility::getMainWPSpecificDir($siteId);
//Check if backup ok
$lastBackup = -1;
if (file_exists($dir) && ($dh = opendir($dir))) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..') {
$theFile = $dir . $file;
if (MainWP_Utility::isArchive($file) && !MainWP_Utility::isSQLArchive($file) && filemtime($theFile) > $lastBackup) {
$lastBackup = filemtime($theFile);
}
}
}
closedir($dh);
}
$backupRequired = $lastBackup < time() - 7 * 24 * 60 * 60 ? true : false;
if (!$backupRequired) {
$sitesCheckCompleted[$siteId] = true;
MainWP_Utility::update_option('mainwp_automaticUpdate_backupChecks', $sitesCheckCompleted);
continue;
}
try {
$result = MainWP_Manage_Sites::backup($siteId, 'full', '', '', 0, 0, 0, 0);
MainWP_Manage_Sites::backupDownloadFile($siteId, 'full', $result['url'], $result['local']);
$sitesCheckCompleted[$siteId] = true;
MainWP_Utility::update_option('mainwp_automaticUpdate_backupChecks', $sitesCheckCompleted);
} catch (Exception $e) {
$sitesCheckCompleted[$siteId] = false;
MainWP_Utility::update_option('mainwp_automaticUpdate_backupChecks', $sitesCheckCompleted);
}
}
} else {
$sitesCheckCompleted = null;
}
//Update plugins
foreach ($pluginsToUpdateNow as $websiteId => $slugs) {
if ($sitesCheckCompleted != null && $sitesCheckCompleted[$websiteId] == false) {
continue;
}
try {
MainWP_Utility::fetchUrlAuthed($allWebsites[$websiteId], 'upgradeplugintheme', array('type' => 'plugin', 'list' => urldecode(implode(',', $slugs))));
if (isset($information['sync']) && !empty($information['sync'])) {
MainWP_Sync::syncInformationArray($allWebsites[$websiteId], $information['sync']);
}
} catch (Exception $e) {
}
}
//Update themes
foreach ($themesToUpdateNow as $websiteId => $slugs) {
if ($sitesCheckCompleted != null && $sitesCheckCompleted[$websiteId] == false) {
continue;
}
try {
MainWP_Utility::fetchUrlAuthed($allWebsites[$websiteId], 'upgradeplugintheme', array('type' => 'theme', 'list' => urldecode(implode(',', $slugs))));
if (isset($information['sync']) && !empty($information['sync'])) {
MainWP_Sync::syncInformationArray($allWebsites[$websiteId], $information['sync']);
}
} catch (Exception $e) {
}
}
//Update core
foreach ($coreToUpdateNow as $websiteId) {
if ($sitesCheckCompleted != null && $sitesCheckCompleted[$websiteId] == false) {
continue;
}
try {
MainWP_Utility::fetchUrlAuthed($allWebsites[$websiteId], 'upgrade');
} catch (Exception $e) {
}
}
do_action('mainwp_cronupdatecheck_action', $pluginsNewUpdate, $pluginsToUpdate, $pluginsToUpdateNow, $themesNewUpdate, $themesToUpdate, $themesToUpdateNow, $coreNewUpdate, $coreToUpdate, $coreToUpdateNow);
}
}
示例5: action
public static function action($pAction, $theme)
{
$websiteIdEnc = $_POST['websiteId'];
$websiteId = $websiteIdEnc;
if (!MainWP_Utility::ctype_digit($websiteId)) {
die('FAIL');
}
$website = MainWP_DB::Instance()->getWebsiteById($websiteId);
if (!MainWP_Utility::can_edit_website($website)) {
die('FAIL');
}
try {
$information = MainWP_Utility::fetchUrlAuthed($website, 'theme_action', array('action' => $pAction, 'theme' => $theme));
} catch (MainWP_Exception $e) {
die('FAIL');
}
if (!isset($information['out']) || !isset($information['status']) || $information['status'] != 'SUCCESS') {
die('FAIL');
}
die($information['out']);
}
示例6: fetchChildServerInformation
public static function fetchChildServerInformation($siteId)
{
try {
$website = MainWP_DB::Instance()->getWebsiteById($siteId);
if (!MainWP_Utility::can_edit_website($website)) {
return __('This is not your website.', 'mainwp');
}
$serverInformation = MainWP_Utility::fetchUrlAuthed($website, 'serverInformation');
?>
<div id="mainwp-server-information-section">
<h2><i class="fa fa-server"></i>
<strong><?php
echo stripslashes($website->name);
?>
</strong> <?php
_e('Server Information');
?>
</h2>
<?php
echo $serverInformation['information'];
?>
</div>
<div id="mainwp-cron-schedules-section">
<h2><i class="fa fa-server"></i>
<strong><?php
echo stripslashes($website->name);
?>
</strong> <?php
_e('Cron Schedules', 'mainwp');
?>
</h2>
<?php
echo $serverInformation['cron'];
?>
</div>
<?php
if (isset($serverInformation['wpconfig'])) {
?>
<div id="mainwp-wp-config-section">
<h2><i class="fa fa-server"></i>
<strong><?php
echo stripslashes($website->name);
?>
</strong> <?php
_e('WP-Config File', 'mainwp');
?>
</h2>
<?php
echo $serverInformation['wpconfig'];
?>
</div>
<div id="mainwp-error-log-section">
<h2><i class="fa fa-server"></i>
<strong><?php
echo stripslashes($website->name);
?>
</strong> <?php
_e('Error Log', 'mainwp');
?>
</h2>
<?php
echo $serverInformation['error'];
?>
</div>
<?php
}
?>
<?php
} catch (MainWP_Exception $e) {
die(MainWP_Error_Helper::getErrorMessage($e));
} catch (Exception $e) {
die('Something went wrong processing your request.');
}
die;
}
示例7: getPostMeta
public static function getPostMeta($postId, $keys, $value, $websiteId)
{
if (!MainWP_Utility::ctype_digit($postId)) {
return;
}
if (!MainWP_Utility::ctype_digit($websiteId)) {
return;
}
$website = MainWP_DB::Instance()->getWebsiteById($websiteId);
if (!MainWP_Utility::can_edit_website($website)) {
return;
}
try {
$results = MainWP_Utility::fetchUrlAuthed($website, 'get_post_meta', array('id' => base64_encode($postId), 'keys' => base64_encode($keys), 'value' => base64_encode($value)));
} catch (MainWP_Exception $e) {
return;
}
return $results;
}
示例8: mainwp_force_destroy_sessions
function mainwp_force_destroy_sessions()
{
$this->secure_request('mainwp_force_destroy_sessions');
$website_id = isset($_POST['website_id']) ? (int) $_POST['website_id'] : 0;
if (!MainWP_DB::Instance()->getWebsiteById($website_id)) {
die(json_encode(array('error' => array('message' => __('This website does not exist', 'mainwp')))));
}
$website = MainWP_DB::Instance()->getWebsiteById($website_id);
if (!MainWP_Utility::can_edit_website($website)) {
die(json_encode(array('error' => array('message' => __('You cannot edit this website', 'mainwp')))));
}
try {
$information = MainWP_Utility::fetchUrlAuthed($website, 'settings_tools', array('action' => 'force_destroy_sessions'));
global $mainWP;
if ($mainWP->getVersion() == '2.0.22' || $mainWP->getVersion() == '2.0.23') {
if (get_option('mainwp_fixed_security_2022') != 1) {
update_option('mainwp_fixed_security_2022', 1);
}
}
} catch (Exception $e) {
$information = array('error' => __('fetchUrlAuthed exception', 'mainwp'));
}
die(json_encode($information));
}
示例9: upgradePluginTheme
public static function upgradePluginTheme($id, $type, $list)
{
if (isset($id) && MainWP_Utility::ctype_digit($id)) {
$website = MainWP_DB::Instance()->getWebsiteById($id);
if (MainWP_Utility::can_edit_website($website)) {
$information = MainWP_Utility::fetchUrlAuthed($website, 'upgradeplugintheme', array('type' => $type, 'list' => urldecode($list)));
if (isset($information['upgrades'])) {
$tmp = array();
//todo: 20130718: the syncing in else branch may be removed in the future, it now works with the sync below (just here for older childs..)
if (isset($information['sync'])) {
foreach ($information['upgrades'] as $k => $v) {
$tmp[urlencode($k)] = $v;
}
} else {
$decodedPluginUpgrades = json_decode($website->plugin_upgrades, true);
$decodedThemeUpgrades = json_decode($website->theme_upgrades, true);
$decodedPremiumUpgrades = json_decode(MainWP_DB::Instance()->getWebsiteOption($website, 'premium_upgrades'), true);
if (is_array($decodedPremiumUpgrades)) {
foreach ($decodedPremiumUpgrades as $crrSlug => $premiumUpgrade) {
if ($premiumUpgrade['type'] == 'plugin') {
if (!is_array($decodedPluginUpgrades)) {
$decodedPluginUpgrades = array();
}
$decodedPluginUpgrades[$crrSlug] = $premiumUpgrade;
} else {
if ($premiumUpgrade['type'] == 'theme') {
if (!is_array($decodedThemeUpgrades)) {
$decodedThemeUpgrades = array();
}
$decodedThemeUpgrades[$crrSlug] = $premiumUpgrade;
}
}
}
}
foreach ($information['upgrades'] as $k => $v) {
$tmp[urlencode($k)] = $v;
if ($v == 1) {
if ($type == 'plugin') {
if (isset($decodedPluginUpgrades[$k])) {
unset($decodedPluginUpgrades[$k]);
}
}
if ($type == 'theme') {
if (isset($decodedThemeUpgrades[$k])) {
unset($decodedThemeUpgrades[$k]);
}
}
}
}
if ($type == 'plugin') {
MainWP_DB::Instance()->updateWebsiteValues($website->id, array('plugin_upgrades' => json_encode($decodedPluginUpgrades)));
}
if ($type == 'theme') {
MainWP_DB::Instance()->updateWebsiteValues($website->id, array('theme_upgrades' => json_encode($decodedThemeUpgrades)));
}
}
return $tmp;
} else {
if (isset($information['error'])) {
throw new MainWP_Exception('WPERROR', $information['error']);
} else {
throw new MainWP_Exception('ERROR', 'Invalid response from site');
}
}
}
}
throw new MainWP_Exception('ERROR', __('Invalid request', 'mainwp'));
}
示例10: action_update
public static function action_update($pAction)
{
$postId = $_POST['postId'];
$websiteIdEnc = $_POST['websiteId'];
$post_data = $_POST['post_data'];
if (!MainWP_Utility::ctype_digit($postId)) {
die('FAIL');
}
$websiteId = $websiteIdEnc;
if (!MainWP_Utility::ctype_digit($websiteId)) {
die('FAIL');
}
$website = MainWP_DB::Instance()->getWebsiteById($websiteId);
if (!MainWP_Utility::can_edit_website($website)) {
die('FAIL');
}
try {
$information = MainWP_Utility::fetchUrlAuthed($website, 'post_action', array('action' => $pAction, 'id' => $postId, 'post_data' => $post_data));
} catch (MainWP_Exception $e) {
die('FAIL');
}
if (!isset($information['status']) || $information['status'] != 'SUCCESS') {
die('FAIL');
}
}
示例11: action
public static function action($pAction, $extra = '')
{
$userId = $_POST['userId'];
$userName = $_POST['userName'];
$websiteIdEnc = $_POST['websiteId'];
$pass = $_POST['update_password'];
if (!MainWP_Utility::ctype_digit($userId)) {
die(json_encode(array('error' => 'Invalid Request.')));
}
$websiteId = $websiteIdEnc;
if (!MainWP_Utility::ctype_digit($websiteId)) {
die(json_encode(array('error' => 'Invalid Request.')));
}
$website = MainWP_DB::Instance()->getWebsiteById($websiteId);
if (!MainWP_Utility::can_edit_website($website)) {
die(json_encode(array('error' => 'You can not edit this website.')));
}
if ($pAction == 'delete' && $website->adminname == $userName) {
die(json_encode(array('error' => __('This user is used for our secure link, it can not be deleted.', 'mainwp'))));
}
if ($pAction == 'changeRole' && $website->adminname == $userName) {
die(json_encode(array('error' => __('This user is used for our secure link, you can not change the role.', 'mainwp'))));
}
try {
$information = MainWP_Utility::fetchUrlAuthed($website, 'user_action', array('action' => $pAction, 'id' => $userId, 'extra' => $extra, 'user_pass' => $pass));
} catch (MainWP_Exception $e) {
die(json_encode(array('error' => $e->getMessage())));
}
if (!isset($information['status']) || $information['status'] != 'SUCCESS') {
die(json_encode(array('error' => 'Unexpected error.')));
}
}
示例12: scan
public static function scan()
{
if (!isset($_POST['childId'])) {
die(json_encode(array('error' => 'Wrong request')));
}
$website = MainWP_DB::Instance()->getWebsiteById($_POST['childId']);
if (!$website) {
die(json_encode(array('error' => 'Site not found')));
}
try {
$post_data = array('search' => 'mainwp-child-id-*', 'search_columns' => 'user_login,display_name,user_email');
$rslt = MainWP_Utility::fetchUrlAuthed($website, 'search_users', $post_data);
$usersfound = !(is_array($rslt) && count($rslt) == 0);
if (!$usersfound) {
//fallback to plugin search
$post_data = array('keyword' => 'WordPress admin security');
$post_data['status'] = 'active';
$post_data['filter'] = true;
$rslt = MainWP_Utility::fetchUrlAuthed($website, 'get_all_plugins', $post_data);
$pluginfound = !(is_array($rslt) && count($rslt) == 0);
if (!$pluginfound) {
die(json_encode(array('success' => 'No issues found.')));
}
}
die(json_encode(array('success' => 'mainwp-child-id users found (<a href="http://docs.mainwp.com/mainwp-cleanup/" target="_blank">solution</a>)')));
} catch (Exception $e) {
die('error');
}
}
示例13: unfixSecurityIssue
public static function unfixSecurityIssue()
{
if (!isset($_REQUEST['id']) || !MainWP_Utility::ctype_digit($_REQUEST['id'])) {
return '';
}
$website = MainWP_DB::Instance()->getWebsiteById($_REQUEST['id']);
if (!MainWP_Utility::can_edit_website($website)) {
return '';
}
$information = MainWP_Utility::fetchUrlAuthed($website, 'securityUnFix', array('feature' => $_REQUEST['feature']));
if (isset($information['sync']) && !empty($information['sync'])) {
MainWP_Sync::syncInformationArray($website, $information['sync']);
unset($information['sync']);
}
return $information;
}
示例14: updateChildsiteValue
public static function updateChildsiteValue()
{
if (isset($_POST['site_id']) && MainWP_Utility::ctype_digit($_POST['site_id'])) {
$website = MainWP_DB::Instance()->getWebsiteById($_POST['site_id']);
if (MainWP_Utility::can_edit_website($website)) {
$error = '';
$uniqueId = isset($_POST['unique_id']) ? $_POST['unique_id'] : '';
try {
$information = MainWP_Utility::fetchUrlAuthed($website, 'update_values', array('uniqueId' => $uniqueId));
} catch (MainWP_Exception $e) {
$error = $e->getMessage();
}
if ($error != '') {
die(json_encode(array('error' => $error)));
} else {
if (isset($information['result']) && $information['result'] == 'ok') {
die(json_encode(array('result' => 'SUCCESS')));
} else {
die(json_encode(array('undefined_error' => true)));
}
}
}
}
die(json_encode(array('error' => 'NO_SIDE_ID')));
}
示例15: syncSite
public static function syncSite(&$pWebsite = null, $pForceFetch = false, $pAllowDisconnect = true)
{
if ($pWebsite == null) {
return false;
}
$userExtension = MainWP_DB::Instance()->getUserExtensionByUserId($pWebsite->userid);
if ($userExtension == null) {
return false;
}
MainWP_Utility::endSession();
try {
$pluginDir = $pWebsite->pluginDir;
if ($pluginDir == '') {
$pluginDir = $userExtension->pluginDir;
}
$cloneEnabled = apply_filters('mainwp_clone_enabled', false);
$cloneSites = array();
if ($cloneEnabled) {
$disallowedCloneSites = get_option('mainwp_clone_disallowedsites');
if ($disallowedCloneSites === false) {
$disallowedCloneSites = array();
}
$websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser());
if ($websites) {
while ($websites && ($website = @MainWP_DB::fetch_object($websites))) {
if (in_array($website->id, $disallowedCloneSites)) {
continue;
}
if ($website->id == $pWebsite->id) {
continue;
}
$cloneSites[$website->id] = array('name' => $website->name, 'url' => $website->url, 'extauth' => $website->extauth, 'size' => $website->totalsize);
}
@MainWP_DB::free_result($websites);
}
}
$pluginConflicts = get_option('mainwp_pluginConflicts');
if ($pluginConflicts !== false) {
$pluginConflicts = array_keys($pluginConflicts);
}
$themeConflicts = get_option('mainwp_themeConflicts');
if ($themeConflicts !== false) {
$themeConflicts = array_keys($themeConflicts);
}
$othersData = apply_filters('mainwp-sync-others-data', array(), $pWebsite);
$information = MainWP_Utility::fetchUrlAuthed($pWebsite, 'stats', array('optimize' => get_option('mainwp_optimize') == 1 ? 1 : 0, 'heatMap' => MainWP_Extensions::isExtensionAvailable('mainwp-heatmap-extension') ? $userExtension->heatMap : 0, 'pluginDir' => $pluginDir, 'cloneSites' => !$cloneEnabled ? 0 : urlencode(json_encode($cloneSites)), 'pluginConflicts' => json_encode($pluginConflicts), 'themeConflicts' => json_encode($themeConflicts), 'othersData' => json_encode($othersData), 'server' => get_admin_url(), 'numberdaysOutdatePluginTheme' => get_option('mainwp_numberdays_Outdate_Plugin_Theme', 365)), true, $pForceFetch);
$return = self::syncInformationArray($pWebsite, $information, '', 1, false, $pAllowDisconnect);
return $return;
} catch (MainWP_Exception $e) {
$sync_errors = '';
$offline_check_result = 1;
if ($e->getMessage() == 'HTTPERROR') {
$sync_errors = __('HTTP error', 'mainwp') . ($e->getMessageExtra() != null ? ' - ' . $e->getMessageExtra() : '');
$offline_check_result = -1;
} else {
if ($e->getMessage() == 'NOMAINWP') {
$sync_errors = __('MainWP not detected', 'mainwp');
$offline_check_result = 1;
}
}
return self::syncInformationArray($pWebsite, $information, $sync_errors, $offline_check_result, true, $pAllowDisconnect);
}
}