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


PHP MainWP_DB::Instance方法代码示例

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


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

示例1: render

    public static function render()
    {
        $current_wpid = MainWP_Utility::get_current_wpid();
        if (!MainWP_Utility::ctype_digit($current_wpid)) {
            return;
        }
        $website = MainWP_DB::Instance()->getWebsiteById($current_wpid, true);
        ?>
		<div id="mainwp-notes-area">
			<div id="mainwp-notes-note" style="padding-bottom: 1em;">
				<?php 
        if ($website->note == '') {
            echo 'No Saved Notes';
        } else {
            echo $website->note;
        }
        ?>
			</div>
			<div style="text-align: center; border-top: 1px Solid #f4f4f4; padding-top: 1em;">
				<a href="#" class="mainwp_notes_show_all button button-primary" id="mainwp_notes_<?php 
        echo $website->id;
        ?>
"><?php 
        _e('Edit Notes', 'mainwp');
        ?>
</a>
			</div>
		</div>
		<?php 
    }
开发者ID:senlin,项目名称:mainwp,代码行数:30,代码来源:widget-mainwp-notes.php

示例2: sync

 public function sync($args, $assoc_args)
 {
     $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser());
     WP_CLI::line('Syncing ' . MainWP_DB::num_rows($websites) . ' sites');
     $warnings = 0;
     $errors = 0;
     while ($websites && ($website = @MainWP_DB::fetch_object($websites))) {
         WP_CLI::line('  -> ' . $website->name . ' (' . $website->url . ')');
         try {
             if (MainWP_Sync::syncSite($website)) {
                 WP_CLI::success('  Sync succeeded');
             } else {
                 WP_CLI::warning('  Sync failed');
                 $warnings++;
             }
         } catch (Exception $e) {
             WP_CLI::error('  Sync failed');
             $errors++;
         }
     }
     @MainWP_DB::free_result($websites);
     if ($errors > 0) {
         WP_CLI::error('Sync completed with errors');
     } else {
         if ($warnings > 0) {
             WP_CLI::warning('Sync completed with warnings');
         } else {
             WP_CLI::success('Sync completed');
         }
     }
 }
开发者ID:jexmex,项目名称:mainwp,代码行数:31,代码来源:class-mainwp-wp-cli-command.php

示例3: handleSettingsPost

 public static function handleSettingsPost()
 {
     if (isset($_POST['submit'])) {
         $userExtension = MainWP_DB::Instance()->getUserExtension();
         $userExtension->heatMap = !isset($_POST['mainwp_options_footprint_heatmap']) ? 1 : 0;
         $userExtension->pluginDir = !isset($_POST['mainwp_options_footprint_plugin_folder']) ? 'default' : 'hidden';
         MainWP_DB::Instance()->updateUserExtension($userExtension);
         return true;
     }
     return false;
 }
开发者ID:sacredwebsite,项目名称:mainwp,代码行数:11,代码来源:widget-mainwp-footprint.php

示例4: 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

示例5: 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));
 }
开发者ID:jexmex,项目名称:mainwp,代码行数:24,代码来源:class-mainwp-post-handler.php

示例6: 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.')));
     }
 }
开发者ID:senlin,项目名称:mainwp,代码行数:24,代码来源:widget-mainwp-widget-plugins.php

示例7: renderMetabox

    public static function renderMetabox()
    {
        $website = MainWP_Utility::get_current_wpid();
        if (!$website) {
            return;
        }
        $website = MainWP_DB::Instance()->getWebsiteById($website);
        MainWP_Manage_Sites::showBackups($website);
        ?>
		<?php 
        if (mainwp_current_user_can('dashboard', 'execute_backups')) {
            ?>
			<hr/>
			<div style="text-align: center;">
				<a href="<?php 
            echo admin_url('admin.php?page=managesites&backupid=' . $website->id);
            ?>
" class="button-primary"><?php 
            _e('Backup Now', 'mainwp');
            ?>
</a>
			</div>
		<?php 
        }
        ?>
		<?php 
    }
开发者ID:sacredwebsite,项目名称:mainwp,代码行数:27,代码来源:page-mainwp-manage-backups.php

示例8: mwp_setup_notification_save

 public function mwp_setup_notification_save()
 {
     check_admin_referer('mwp-setup');
     $important_notification = !isset($_POST['mwp_setup_options_important_notification']) ? 0 : 1;
     update_option('mwp_setup_importantNotification', $important_notification);
     MainWP_Utility::update_option('mainwp_notificationOnBackupFail', $important_notification);
     MainWP_Utility::update_option('mainwp_automaticDailyUpdate', $important_notification ? 2 : 0);
     $userExtension = MainWP_DB::Instance()->getUserExtension();
     $userExtension->offlineChecksOnlineNotification = $important_notification;
     $userExtension->user_email = isset($_POST['mwp_setup_options_email']) && !empty($_POST['mwp_setup_options_email']) ? $_POST['mwp_setup_options_email'] : "";
     MainWP_DB::Instance()->updateUserExtension($userExtension);
     wp_redirect($this->get_next_step_link());
     exit;
 }
开发者ID:reeslo,项目名称:mainwp,代码行数:14,代码来源:page-mainwp-setup-wizard.php

示例9: hookGetGroups

 /**
  * @param string $pluginFile Extension plugin file to verify
  * @param string $key The child-key
  * @param int $groupid The id of the group you wish to retrieve
  * @param bool $for_manager
  *
  * @return array|bool An array of arrays, the inner-array contains the id/name/array of site ids for the supplied groupid/all groups. False when something goes wrong.
  */
 public static function hookGetGroups($pluginFile, $key, $groupid, $for_manager = false)
 {
     if (!self::hookVerify($pluginFile, $key)) {
         return false;
     }
     if ($for_manager && (!defined('MWP_TEAMCONTROL_PLUGIN_SLUG') || !mainwp_current_user_can('extension', dirname(MWP_TEAMCONTROL_PLUGIN_SLUG)))) {
         return false;
     }
     if (isset($groupid)) {
         $group = MainWP_DB::Instance()->getGroupById($groupid);
         if (!MainWP_Utility::can_edit_group($group)) {
             return false;
         }
         $websites = MainWP_DB::Instance()->getWebsitesByGroupId($group->id);
         $websitesOut = array();
         foreach ($websites as $website) {
             $websitesOut[] = $website->id;
         }
         return array(array('id' => $groupid, 'name' => $group->name, 'websites' => $websitesOut));
     }
     $groups = MainWP_DB::Instance()->getGroupsAndCount(null, $for_manager);
     $output = array();
     foreach ($groups as $group) {
         $websites = MainWP_DB::Instance()->getWebsitesByGroupId($group->id);
         $websitesOut = array();
         foreach ($websites as $website) {
             if (in_array($website->id, $websitesOut)) {
                 continue;
             }
             $websitesOut[] = $website->id;
         }
         $output[] = array('id' => $group->id, 'name' => $group->name, 'websites' => $websitesOut);
     }
     return $output;
 }
开发者ID:jexmex,项目名称:mainwp,代码行数:43,代码来源:page-mainwp-extensions.php

示例10: display_rows

 function display_rows()
 {
     foreach ($this->items as $item) {
         $sites = $item->sites == '' ? array() : explode(',', $item->sites);
         $groups = $item->groups == '' ? array() : explode(',', $item->groups);
         foreach ($groups as $group) {
             $websites = MainWP_DB::Instance()->getWebsitesByGroupId($group);
             if ($websites == null) {
                 continue;
             }
             foreach ($websites as $website) {
                 if (!in_array($website->id, $sites)) {
                     $sites[] = $website->id;
                 }
             }
         }
         $item->the_sites = $sites;
         $this->single_row($item);
     }
 }
开发者ID:jexmex,项目名称:mainwp,代码行数:20,代码来源:table-mainwp-manage-backups-list-table.php

示例11: update

 function update()
 {
     MainWP_DB::Instance()->update();
     MainWP_DB::Instance()->install();
 }
开发者ID:reeslo,项目名称:mainwp,代码行数:5,代码来源:class-mainwp-system.php

示例12: renderSites

    public static function renderSites($renew, $pExit = true)
    {
        $current_wpid = MainWP_Utility::get_current_wpid();
        if ($current_wpid) {
            $sql = MainWP_DB::Instance()->getSQLWebsiteById($current_wpid);
        } else {
            $sql = MainWP_DB::Instance()->getSQLWebsitesForCurrentUser();
        }
        $websites = MainWP_DB::Instance()->query($sql);
        $allPages = array();
        if ($websites) {
            while ($websites && ($website = @MainWP_DB::fetch_object($websites))) {
                if ($website->recent_pages == '') {
                    continue;
                }
                $pages = json_decode($website->recent_pages, 1);
                if (count($pages) == 0) {
                    continue;
                }
                foreach ($pages as $page) {
                    $page['website'] = (object) array('id' => $website->id, 'url' => $website->url);
                    $allPages[] = $page;
                }
            }
            @MainWP_DB::free_result($websites);
        }
        $recent_pages_published = MainWP_Utility::getSubArrayHaving($allPages, 'status', 'publish');
        $recent_pages_published = MainWP_Utility::sortmulti($recent_pages_published, 'dts', 'desc');
        $recent_pages_draft = MainWP_Utility::getSubArrayHaving($allPages, 'status', 'draft');
        $recent_pages_draft = MainWP_Utility::sortmulti($recent_pages_draft, 'dts', 'desc');
        $recent_pages_pending = MainWP_Utility::getSubArrayHaving($allPages, 'status', 'pending');
        $recent_pages_pending = MainWP_Utility::sortmulti($recent_pages_pending, 'dts', 'desc');
        $recent_pages_trash = MainWP_Utility::getSubArrayHaving($allPages, 'status', 'trash');
        $recent_pages_trash = MainWP_Utility::sortmulti($recent_pages_trash, 'dts', 'desc');
        ?>
		<div class="clear">
			<a href="<?php 
        echo admin_url('admin.php?page=PageBulkAdd&select=' . ($current_wpid ? $current_wpid : 'all'));
        ?>
" class="button-primary" style="float: right"><?php 
        _e('Add New', 'mainwp');
        ?>
</a>
			<a class="mainwp_action left mainwp_action_down recent_posts_published_lnk" href="#"><?php 
        _e('Published', 'mainwp');
        ?>
 (<?php 
        echo count($recent_pages_published);
        ?>
)</a><a class="mainwp_action mid recent_posts_draft_lnk" href="#"><?php 
        _e('Draft', 'mainwp');
        ?>
 (<?php 
        echo count($recent_pages_draft);
        ?>
)</a><a class="mainwp_action mid recent_posts_pending_lnk" href="#"><?php 
        _e('Pending', 'mainwp');
        ?>
 (<?php 
        echo count($recent_pages_pending);
        ?>
)</a><a class="mainwp_action right recent_posts_trash_lnk" href="#"><?php 
        _e('Trash', 'mainwp');
        ?>
 (<?php 
        echo count($recent_pages_trash);
        ?>
)</a><br/><br/>

			<div class="recent_posts_published">
				<?php 
        for ($i = 0; $i < count($recent_pages_published) && $i < 5; $i++) {
            if (!isset($recent_pages_published[$i]['title']) || $recent_pages_published[$i]['title'] == '') {
                $recent_pages_published[$i]['title'] = '(No Title)';
            }
            if (isset($recent_pages_published[$i]['dts'])) {
                if (!stristr($recent_pages_published[$i]['dts'], '-')) {
                    $recent_pages_published[$i]['dts'] = MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($recent_pages_published[$i]['dts']));
                }
            }
            ?>
					<div class="mainwp-row mainwp-recent">
						<input class="postId" type="hidden" name="id" value="<?php 
            echo $recent_pages_published[$i]['id'];
            ?>
"/>
						<input class="websiteId" type="hidden" name="id" value="<?php 
            echo $recent_pages_published[$i]['website']->id;
            ?>
"/>
						<span class="mainwp-left-col" style="width: 60% !important; margin-right: 1em;"><a href="<?php 
            echo $recent_pages_published[$i]['website']->url;
            ?>
?p=<?php 
            echo $recent_pages_published[$i]['id'];
            ?>
" target="_blank"><?php 
            echo htmlentities($recent_pages_published[$i]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8');
            ?>
</a></span>
//.........这里部分代码省略.........
开发者ID:senlin,项目名称:mainwp,代码行数:101,代码来源:widget-mainwp-recent-pages.php

示例13: extra_tablenav

    function extra_tablenav($which)
    {
        ?>


		<div class="alignleft actions">
			<form method="GET" action="">
				<input type="hidden" value="<?php 
        echo esc_attr($_REQUEST['page']);
        ?>
" name="page"/>
				<select name="g">
					<option value=""><?php 
        _e('All Groups', 'mainwp');
        ?>
</option>
					<?php 
        $groups = MainWP_DB::Instance()->getGroupsForCurrentUser();
        foreach ($groups as $group) {
            echo '<option value="' . $group->id . '" ' . (isset($_REQUEST['g']) && $_REQUEST['g'] == $group->id ? 'selected' : '') . '>' . stripslashes($group->name) . '</option>';
        }
        ?>
				</select>

				<input type="hidden" value="<?php 
        echo $_REQUEST['page'];
        ?>
" name="page"/>
				<select name="status">
					<option value=""><?php 
        _e('All Statuses', 'mainwp');
        ?>
</option>
					<option value="online" <?php 
        echo isset($_REQUEST['status']) && $_REQUEST['status'] == 'online' ? 'selected' : '';
        ?>
>Online</option>
					<option value="offline" <?php 
        echo isset($_REQUEST['status']) && $_REQUEST['status'] == 'offline' ? 'selected' : '';
        ?>
>Offline</option>
					<option value="disconnected" <?php 
        echo isset($_REQUEST['status']) && $_REQUEST['status'] == 'disconnected' ? 'selected' : '';
        ?>
>Disconnected</option>
					<option value="update" <?php 
        echo isset($_REQUEST['status']) && $_REQUEST['status'] == 'update' ? 'selected' : '';
        ?>
>Available update</option>
				</select>
				<input type="submit" value="<?php 
        _e('Display');
        ?>
" class="button" name="">
			</form>
		</div>

		<div class="alignleft actions">
			<form method="GET" action="">
				<input type="hidden" value="<?php 
        echo $_REQUEST['page'];
        ?>
" name="page"/>
				<input type="text" value="<?php 
        echo isset($_REQUEST['s']) ? esc_attr($_REQUEST['s']) : '';
        ?>
"
					autocompletelist="sites" name="s" class="mainwp_autocomplete"/>
				<datalist id="sites">
					<?php 
        if (MainWP_DB::is_result($this->items)) {
            while ($this->items && ($item = @MainWP_DB::fetch_array($this->items))) {
                echo '<option>' . $item['name'] . '</option>';
            }
            MainWP_DB::data_seek($this->items, 0);
        }
        ?>
				</datalist>
				<input type="submit" value="<?php 
        _e('Search Sites');
        ?>
" class="button" name=""/>
			</form>
		</div>
		<?php 
    }
开发者ID:sacredwebsite,项目名称:mainwp,代码行数:86,代码来源:table-mainwp-manage-sites-list-table.php

示例14: updateWebsite

 public function updateWebsite($websiteid, $userid, $name, $siteadmin, $groupids, $groupnames, $offlineChecks, $pluginDir, $maximumFileDescriptorsOverride, $maximumFileDescriptorsAuto, $maximumFileDescriptors, $verifyCertificate = 1, $archiveFormat, $uniqueId = '', $http_user = null, $http_pass = null, $sslVersion = 0)
 {
     if (MainWP_Utility::ctype_digit($websiteid) && MainWP_Utility::ctype_digit($userid)) {
         $website = MainWP_DB::Instance()->getWebsiteById($websiteid);
         if (MainWP_Utility::can_edit_website($website)) {
             //update admin
             $this->wpdb->query('UPDATE ' . $this->tableName('wp') . ' SET name="' . $this->escape($name) . '", adminname="' . $this->escape($siteadmin) . '",offline_checks="' . $this->escape($offlineChecks) . '",pluginDir="' . $this->escape($pluginDir) . '",maximumFileDescriptorsOverride = ' . ($maximumFileDescriptorsOverride ? 1 : 0) . ',maximumFileDescriptorsAuto= ' . ($maximumFileDescriptorsAuto ? 1 : 0) . ',maximumFileDescriptors = ' . $maximumFileDescriptors . ', verify_certificate="' . intval($verifyCertificate) . '", ssl_version="' . intval($sslVersion) . '", uniqueId="' . $this->escape($uniqueId) . '", http_user="' . $this->escape($http_user) . '", http_pass="' . $this->escape($http_pass) . '"  WHERE id=' . $websiteid);
             $this->wpdb->query('UPDATE ' . $this->tableName('wp_settings_backup') . ' SET archiveFormat = "' . $this->escape($archiveFormat) . '" WHERE wpid=' . $websiteid);
             //remove groups
             $this->wpdb->query('DELETE FROM ' . $this->tableName('wp_group') . ' WHERE wpid=' . $websiteid);
             //Remove GA stats
             $showErrors = $this->wpdb->hide_errors();
             do_action('mainwp_ga_delete_site', $websiteid);
             if ($showErrors) {
                 $this->wpdb->show_errors();
             }
             //add groups with groupnames
             foreach ($groupnames as $groupname) {
                 if ($this->wpdb->insert($this->tableName('group'), array('userid' => $userid, 'name' => $this->escape($groupname)))) {
                     $groupids[] = $this->wpdb->insert_id;
                 }
             }
             //add groupids
             foreach ($groupids as $groupid) {
                 $this->wpdb->insert($this->tableName('wp_group'), array('wpid' => $websiteid, 'groupid' => $groupid));
             }
             return true;
         }
     }
     return false;
 }
开发者ID:sacredwebsite,项目名称:mainwp,代码行数:31,代码来源:class-mainwp-db.php

示例15: doImport

 public static function doImport()
 {
     if (isset($_POST['select_by'])) {
         $selected_sites = array();
         if (isset($_POST['selected_sites']) && is_array($_POST['selected_sites'])) {
             foreach ($_POST['selected_sites'] as $selected) {
                 $selected_sites[] = $selected;
             }
         }
         $selected_groups = array();
         if (isset($_POST['selected_groups']) && is_array($_POST['selected_groups'])) {
             foreach ($_POST['selected_groups'] as $selected) {
                 $selected_groups[] = $selected;
             }
         }
     }
     $user_to_add = array('user_pass' => $_POST['pass1'], 'user_login' => $_POST['user_login'], 'user_url' => $_POST['url'], 'user_email' => $_POST['email'], 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'role' => $_POST['role']);
     $ret = array();
     $dbwebsites = array();
     $not_valid = array();
     $error_sites = '';
     if ($_POST['select_by'] == 'site') {
         //Get all selected websites
         foreach ($selected_sites as $url) {
             if (!empty($url)) {
                 $website = MainWP_DB::Instance()->getWebsitesByUrl($url);
                 if ($website) {
                     $dbwebsites[$website[0]->id] = MainWP_Utility::mapSite($website[0], array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                 } else {
                     $not_valid[] = __("Error - The website doesn't exist in the Network.", 'mainwp') . " " . $url;
                     $error_sites .= $url . ';';
                 }
             }
         }
     } else {
         //Get all websites from the selected groups
         foreach ($selected_groups as $group) {
             if (MainWP_DB::Instance()->getGroupsByName($group)) {
                 $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesByGroupName($group));
                 if ($websites) {
                     while ($websites && ($website = @MainWP_DB::fetch_object($websites))) {
                         $dbwebsites[$website->id] = MainWP_Utility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                     }
                     @MainWP_DB::free_result($websites);
                 } else {
                     $not_valid[] = __('Error - These are not websites in the group. ', 'mainwp') . $group;
                     $error_sites .= $group . ';';
                 }
             } else {
                 $not_valid[] = __("Error - The group doesn't exist in the Network. ", 'mainwp') . $group;
                 $error_sites .= $group . ';';
             }
         }
     }
     if (count($dbwebsites) > 0) {
         $post_data = array('new_user' => base64_encode(serialize($user_to_add)), 'send_password' => isset($_POST['send_password']) ? $_POST['send_password'] : '');
         $output = new stdClass();
         $output->ok = array();
         $output->errors = array();
         MainWP_Utility::fetchUrlsAuthed($dbwebsites, 'newuser', $post_data, array(MainWP_Bulk_Add::getClassName(), 'PostingBulk_handler'), $output);
     }
     $ret['ok_list'] = $ret['error_list'] = array();
     foreach ($dbwebsites as $website) {
         if (isset($output->ok[$website->id]) && $output->ok[$website->id] == 1) {
             $ret['ok_list'][] = 'New user(s) created: ' . stripslashes($website->name);
         } else {
             $ret['error_list'][] = $output->errors[$website->id] . ' ' . stripslashes($website->name);
             $error_sites .= $website->url . ';';
         }
     }
     foreach ($not_valid as $val) {
         $ret['error_list'][] = $val;
     }
     $ret['failed_logging'] = '';
     if (!empty($error_sites)) {
         $error_sites = rtrim($error_sites, ';');
         $ret['failed_logging'] = $_POST['user_login'] . ',' . $_POST['email'] . ',' . $_POST['first_name'] . ',' . $_POST['last_name'] . ',' . $_POST['url'] . ',' . $_POST['pass1'] . ',' . intval($_POST['send_password']) . ',' . $_POST['role'] . ',' . $error_sites . ',';
     }
     $ret['line_number'] = $_POST['line_number'];
     die(json_encode($ret));
 }
开发者ID:senlin,项目名称:mainwp,代码行数:81,代码来源:page-mainwp-user.php


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