コード例 #1
0
ファイル: MainWPNotes.widget.php プロジェクト: BjornW/mainwp
    public static function render()
    {
        $current_wpid = MainWPUtility::get_current_wpid();
        if (!MainWPUtility::ctype_digit($current_wpid)) {
            return;
        }
        $website = MainWPDB::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 
    }
コード例 #2
0
 public static function scan()
 {
     if (!isset($_POST['childId'])) {
         die(json_encode(array('error' => 'Wrong request')));
     }
     $website = MainWPDB::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 = MainWPUtility::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 = MainWPUtility::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');
     }
 }
コード例 #3
0
 public static function handleSettingsPost()
 {
     if (isset($_POST['submit'])) {
         $userExtension = MainWPDB::Instance()->getUserExtension();
         $userExtension->heatMap = !isset($_POST['mainwp_options_footprint_heatmap']) ? 1 : 0;
         $userExtension->pluginDir = !isset($_POST['mainwp_options_footprint_plugin_folder']) ? 'default' : 'hidden';
         MainWPDB::Instance()->updateUserExtension($userExtension);
         return true;
     }
     return false;
 }
コード例 #4
0
ファイル: MainWPMain.page.php プロジェクト: sdmtt/mainwp
    public static function renderDashboardBody($websites, $pDashboard, $pScreenLayout)
    {
        $opts = get_option("mainwp_opts_showhide_sections", false);
        $hide_shortcuts = is_array($opts) && isset($opts['welcome_shortcuts']) && $opts['welcome_shortcuts'] == 'hide' ? true : false;
        ?>
    <form action="admin-post.php" method="post">
        <?php 
        wp_nonce_field('mainwp_tab-general');
        ?>
        <?php 
        wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
        ?>
        <?php 
        wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
        ?>
        <input type="hidden" name="action" value="save_howto_testPages_general"/>
            <div id="mainwp-welocme-bar" class="welcome-panel" style="padding-left: 2em;">
            <table id="mainwp-refresh-bar" width="100%">
                <tbody><tr><td>
                <div id="mainwp-welocme-bar-top">
                    <span style="float:right;">
                    <a style="font-size: 18px;" class="button-hero button mainwp-upgrade-button" id="dashboard_refresh" title="<?php 
        echo MainWPRightNow::renderLastUpdate();
        ?>
"><?php 
        _e('<i class="fa fa-refresh"></i> Sync Data', 'mainwp');
        ?>
</a>
                    <a style="font-size: 18px;" class="button-hero button-primary button" target="_blank" href="https://extensions.mainwp.com"><?php 
        _e('<i class="fa fa-cart-plus"></i> Get New Extensions', 'mainwp');
        ?>
</a>
                    </span>
                    <?php 
        $current_wp_id = MainWPUtility::get_current_wpid();
        $website = null;
        if (!empty($current_wp_id)) {
            $website = $websites[0];
        }
        $imgfavi = "";
        if ($website !== null) {
            if (get_option('mainwp_use_favicon', 1) == 1) {
                $favi = MainWPDB::Instance()->getWebsiteOption($website, 'favi_icon', "");
                $favi_url = MainWPUtility::get_favico_url($favi, $website);
                $imgfavi = '<img src="' . $favi_url . '" width="16" height="16" style="vertical-align:middle;"/>&nbsp;';
            }
        }
        if (time() - ($website == null ? MainWPDB::Instance()->getFirstSyncedSite() : $website->dtsSync) > 60 * 60 * 24) {
            ?>
<h3><i class="fa fa-flag"></i> <?php 
            _e('Your MainWP Dashboard has not been synced for 24 hours!', 'mainwp');
            ?>
</h3>
                <p class="about-description"><?php 
            _e('Click the Sync Data button to get the latest data from child sites.', 'mainwp');
            ?>
</p>
                    <?php 
        } else {
            ?>
                    <h3><?php 
            echo $website == null ? __('Welcome to Your MainWP Dashboard!', 'mainwp') : sprintf(__('Welcome to %s Dashboard!', 'mainwp'), stripslashes($website->name));
            ?>
</h3>
                    <p class="about-description"><?php 
            echo $website == null ? __('Manage your WordPress sites with ease.', 'mainwp') : sprintf(__('This information is only for %s%s', 'mainwp'), $imgfavi, MainWPUtility::getNiceURL($website->url, true));
            ?>
</p>
                    <?php 
        }
        ?>
                </div>
                <br/>
                <span style="float: right; margin-right: 1em;"><a id="mainwp-link-showhide-welcome-shortcuts" status="<?php 
        echo $hide_shortcuts ? "hide" : "show";
        ?>
" href="#"><?php 
        echo $hide_shortcuts ? __('Show Shortcuts', 'mainwp') : __('Hide Shortcuts', 'mainwp');
        ?>
</a></span>
                <div id="mainwp-welcome-bar-shotcuts" style="clear: both;<?php 
        echo $hide_shortcuts ? "display: none;" : "";
        ?>
" > 
                    <div class="welcome-panel-column">
                        <h4><?php 
        _e('Get Started', 'mainwp');
        ?>
</h4>
                        <ul>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=managesites&do=new"><i class="fa fa-globe"></i> <?php 
        _e('Add New Site', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=ManageGroups"><i class="fa fa-globe"></i> <?php 
        _e('Create Child Site Groups', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=ManageBackupsAddNew"><i class="fa fa-hdd-o"></i> <?php 
        _e('Schedule Backups', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=Settings"><i class="fa fa-cogs"></i> <?php 
        _e('Check MainWP Settings', 'mainwp');
        ?>
</a></li>
                            
                        </ul>
                    </div>
                    <div class="welcome-panel-column">
                        <h4><?php 
        _e('Next Steps', 'mainwp');
        ?>
</h4>
                        <ul>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=PostBulkAdd"><i class="fa fa-file-text"></i> <?php 
        _e('Add Post to Child Site(s)', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=PageBulkAdd"><i class="fa fa-file"></i> <?php 
        _e('Add Page to Child Site(s)', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=PluginsInstall"><i class="fa fa-plug"></i> <?php 
        _e('Add Plugin to Child Site(s)', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=ThemesInstall"><i class="fa fa-paint-brush"></i> <?php 
        _e('Add Theme to Child Site(s)', 'mainwp');
        ?>
</a></li>
                        </ul>
                    </div>
                    <div class="welcome-panel-column welcome-panel-last">
                        <h4><?php 
        _e('More Actions', 'mainwp');
        ?>
</h4>
                        <ul>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=managesites&do=test"><i class="fa fa-globe"></i> <?php 
        _e('Test Connection', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=Extensions"><i class="fa fa-plug"></i> <?php 
        _e('Manage Extensions', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=ServerInformation"><i class="fa fa-server"></i> <?php 
        _e('Check MainWP Requirements', 'mainwp');
        ?>
</a></li>
                            <li><a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=DashboardOptions"><i class="fa fa-cogs"></i> <?php 
        _e('Set Your Preferences', 'mainwp');
        ?>
</a></li>
                        </ul>
                    </div>
                </div>
            <div id="dashboard_refresh_statusextra" style="display: none"> <i class="fa fa-spinner fa-pulse"></i> </div>
            </div>
            <div id="mainwp_dashboard_refresh_status"></div>
            </td></tr></tbody>
         </table>
        </div>
        <div id="mainwp_main_errors" class="mainwp_error"></div>
    </form>

    <?php 
        if (empty($current_wp_id) && MainWPTwitter::enabledTwitterMessages()) {
            $filter = array('upgrade_everything', 'upgrade_all_wp_core', 'upgrade_all_plugins', 'upgrade_all_themes');
            foreach ($filter as $what) {
                $twitters = MainWPTwitter::getTwitterNotice($what);
                if (is_array($twitters)) {
                    foreach ($twitters as $timeid => $twit_mess) {
                        if (!empty($twit_mess)) {
                            $sendText = MainWPTwitter::getTwitToSend($what, $timeid);
                            ?>
                            <div class="mainwp-tips mainwp_info-box-blue twitter"><span class="mainwp-tip" twit-what="<?php 
                            echo $what;
                            ?>
" twit-id="<?php 
                            echo $timeid;
                            ?>
"><?php 
                            echo $twit_mess;
                            ?>
</span>&nbsp;<?php 
                            MainWPTwitter::genTwitterButton($sendText);
                            ?>
<span><a href="#" class="mainwp-dismiss-twit" ><i class="fa fa-times-circle"></i> <?php 
                            _e('Dismiss', 'mainwp');
                            ?>
</a></span></div>
                        <?php 
                        }
                    }
                }
            }
            ?>
    <?php 
        }
        ?>
       
                                
    <div id="dashboard-widgets-wrap">

    <?php 
        require_once ABSPATH . 'wp-admin/includes/dashboard.php';
        wp_dashboard();
        ?>

    <div class="clear"></div>
    </div><!-- dashboard-widgets-wrap -->
    <?php 
    }
コード例 #5
0
 public static function performUpload()
 {
     MainWPUtility::endSession();
     //Fetch info..
     $post_data = array('url' => json_encode(explode('||', $_POST['urls'])), 'type' => $_POST['type']);
     if ($_POST['activatePlugin'] == 'true') {
         $post_data['activatePlugin'] = 'yes';
     }
     if ($_POST['overwrite'] == 'true') {
         $post_data['overwrite'] = true;
     }
     $output = new stdClass();
     $output->ok = array();
     $output->errors = array();
     $websites = array(MainWPDB::Instance()->getWebsiteById($_POST['siteId']));
     MainWPUtility::fetchUrlsAuthed($websites, 'installplugintheme', $post_data, array(MainWPInstallBulk::getClassName(), 'InstallPluginTheme_handler'), $output);
     die(json_encode($output));
 }
コード例 #6
0
 function mainwp_force_destroy_sessions()
 {
     $this->secure_request('mainwp_force_destroy_sessions');
     $website_id = isset($_POST['website_id']) ? (int) $_POST['website_id'] : 0;
     if (!MainWPDB::Instance()->getWebsiteById($website_id)) {
         die(json_encode(array('error' => array('message' => __("This website does not exist", 'mainwp')))));
     }
     $website = MainWPDB::Instance()->getWebsiteById($website_id);
     if (!MainWPUtility::can_edit_website($website)) {
         die(json_encode(array('error' => array('message' => __("You cannot edit this website", 'mainwp')))));
     }
     try {
         $information = MainWPUtility::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));
 }
コード例 #7
0
ファイル: MainWPUser.page.php プロジェクト: HasClass0/mainwp
 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 = MainWPDB::Instance()->getWebsitesByUrl($url);
                 if ($website) {
                     $dbwebsites[$website[0]->id] = MainWPUtility::mapSite($website[0], array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                 } else {
                     $not_valid[] = "Error - The website doesn't exist in the Network. " . $url;
                     $error_sites .= $url . ";";
                 }
             }
         }
     } else {
         //Get all websites from the selected groups
         foreach ($selected_groups as $group) {
             if (MainWPDB::Instance()->getGroupsByName($group)) {
                 $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupName($group));
                 if ($websites) {
                     while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                         $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                     }
                     @MainWPDB::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();
         MainWPUtility::fetchUrlsAuthed($dbwebsites, 'newuser', $post_data, array(MainWPBulkAdd::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));
 }
コード例 #8
0
    public static function render()
    {
        $username = get_option("mainwp_api_username");
        $password = MainWPUtility::decrypt(get_option('mainwp_api_password'), 'MainWPAPI');
        $userExtension = MainWPDB::Instance()->getUserExtension();
        $pluginDir = $userExtension == null || ($userExtension->pluginDir == null || $userExtension->pluginDir == '') ? 'default' : $userExtension->pluginDir;
        ?>
    <div class="wrap"><a href="https://mainwp.com" id="mainwplogo" title="MainWP" target="_blank"><img
            src="<?php 
        echo plugins_url('images/logo.png', dirname(__FILE__));
        ?>
" height="50" alt="MainWP"/></a>
        <img src="<?php 
        echo plugins_url('images/icons/mainwp-passwords.png', dirname(__FILE__));
        ?>
"
             style="float: left; margin-right: 8px; margin-top: 7px ;" alt="MainWP Password" height="32"/>

        <h2><?php 
        _e('MainWP Login Settings', 'mainwp');
        ?>
</h2>

        <div id="mainwp_api_errors" class="mainwp_error error" style="display: none"></div>
        <div id="mainwp_api_message" class="mainwp_updated updated" style="display: none"></div>
        <br />

        <h3><?php 
        _e('Initial MainWP Settings', 'mainwp');
        ?>
</h3>
        <table class="form-table">
            <tbody>
            <tr>
                <th scope="row"><?php 
        _e('Hide Network on Child Sites', 'mainwp');
        ?>
</th>
                <td>
                    <table>
                        <tr>
                            <td valign="top" style="padding-left: 0; padding-right: 5px; padding-top: 0px; padding- bottom: 0px;">
                                <input type="checkbox" value="default" name="mainwp_options_footprint_plugin_folder" id="mainwp_options_footprint_plugin_folder_default" <?php 
        echo $pluginDir == 'hidden' ? 'checked="true"' : '';
        ?>
/>
                            </td>
                            <td valign="top" style="padding: 0">
                              <label for="mainwp_options_footprint_plugin_folder_default">
                                  <?php 
        _e('This will make anyone including Search Engines trying find your Child Plugin encounter a 404 page. Hiding the Child Plugin does require the plugin to make changes to your .htaccess file that in rare instances or server configurations could cause problems.', 'mainwp');
        ?>
                              </label>
                              <div class="mainwp_info-box" style="width: 650px; font-weight: bold; margin-top: 5px;"><?php 
        _e('We recommend you have this option checked. You can change these settings any time on the settings page.', 'mainwp');
        ?>
</div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            </tbody>
        </table>

        <h3><?php 
        _e('MainWP login', 'mainwp');
        ?>
</h3>
        <table class="form-table">
            <tbody>
            <tr>
                <th scope="row"><label for="mainwp_api_username"><?php 
        _e('Username', 'mainwp');
        ?>
</label></th>
                <td>
                    <input type="text" name="mainwp_api_username" id="mainwp_api_username" size="35"
                           value="<?php 
        echo $username;
        ?>
"/>
                </td>
            </tr>
            <tr>
                <th scope="row"><label for="mainwp_api_password"><?php 
        _e('Password', 'mainwp');
        ?>
</label></th>
                <td>
                    <input type="password" name="mainwp_api_password" id="mainwp_api_password" size="35"
                           value="<?php 
        echo $password;
        ?>
"/>
                </td>
            </tr>
            </tbody>
        </table>
        <p class="submit">
            <input type="button" name="submit" id="mainwp-api-submit" class="button-primary" value="<?php 
        _e('Save Settings', 'mainwp');
        ?>
"/>
        </p>
    </div>
    <?php 
    }
コード例 #9
0
    public static function render()
    {
        $tasks = MainWPDB::Instance()->getBackupTasksForUser();
        if (count($tasks) == 0) {
            echo 'You have no scheduled backup tasks. <a href="admin.php?page=ManageBackupsAddNew">Go create one!</a>';
        } else {
            ?>
		<div class"mainwp-row-top" style="text-align: right; margin-bottom: 1em;">                     
                    <a href="admin.php?page=ManageBackups" class="button" ><?php 
            _e('Manage Backups', 'mainwp');
            ?>
</a>
                    <?php 
            if (mainwp_current_user_can("dashboard", "add_backup_tasks")) {
                ?>
                    &nbsp;&nbsp;<a href="admin.php?page=ManageBackupsAddNew" class="button-primary" ><?php 
                _e('Add New Task', 'mainwp');
                ?>
</a>
                    <?php 
            }
            ?>
		</div>
		<div id="mainwp-backup-tasks-widget">
			<style>
			@keyframes blinker {
				0% { background: #7fb100 ;}
				100% { background: #446200 ;}
			}
			@-webkit-keyframes blinker {
				0% { background: #7fb100 ;}
				100% { background: #446200 ;}
			}

			.mainwp-blink-me {
				animation: blinker 1s linear 0s infinite alternate;
				-webkit-animation: blinker 1s linear 0s infinite alternate;
			}
			</style>
		<?php 
            foreach ($tasks as $task) {
                $sites = array();
                if ($task->groups != '') {
                    $groups = explode(',', $task->groups);
                    foreach ($groups as $groupid) {
                        $group_sites = MainWPDB::Instance()->getWebsitesByGroupId($groupid);
                        foreach ($group_sites as $group_site) {
                            if (in_array($group_site->id, $sites)) {
                                continue;
                            }
                            $sites[] = $group_site->id;
                        }
                    }
                } else {
                    if ($task->sites != '') {
                        $sites = explode(',', $task->sites);
                    }
                }
                ?>
			<div class="mainwp-row mainwp-recent">
				<span class="mainwp-left-col" style="width: 40%">
					<strong><a href="admin.php?page=ManageBackups&id=<?php 
                echo $task->id;
                ?>
"><?php 
                echo $task->name;
                ?>
</a></strong><br /><span style="font-size: 11px">(<?php 
                echo strtoupper($task->schedule);
                ?>
 - <?php 
                echo $task->type == 'db' ? __('Database Backup', 'mainwp') : __('Full Backup', 'mainwp');
                ?>
)</span>
				</span>
				<span class="mainwp-mid-col">
					<?php 
                if ($task->paused == 1) {
                    echo '<span title="Paused"  style="background: #999; padding: .3em 1em; color: white; border-radius: 15px; -moz-border-radius: 15px; -webkit-border-radius: 15px;">' . count($sites) . '</span>';
                } else {
                    if (count($sites) == 0) {
                        echo '<span title="0 Scheduled Websites" style="background: #c80000; padding: .3em 1em; color: white; border-radius: 15px; -moz-border-radius: 15px; -webkit-border-radius: 15px;">0</span>';
                    } else {
                        if ($task->last_run != 0 && $task->completed < $task->last_run) {
                            echo '<span title="Backup in Progress" class="mainwp-blink-me" style="padding: .3em 1em; color: white; border-radius: 15px; -moz-border-radius: 15px; -webkit-border-radius: 15px;">' . count($sites) . '</span>';
                        } else {
                            echo '<span title="Scheduled Websites" style="background: #7fb100; padding: .3em 1em; color: white; border-radius: 15px; -moz-border-radius: 15px; -webkit-border-radius: 15px;">' . count($sites) . '</span>';
                        }
                    }
                }
                ?>
				</span>
				<span class="mainwp-right-col" style="width: 40%; text-align: left;">
					<strong><?php 
                _e('LAST RUN: ', 'mainwp');
                ?>
</strong>&nbsp;<?php 
                echo $task->last_run == 0 ? '-' : MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($task->last_run));
                ?>
<br />
					<strong><?php 
                _e('NEXT RUN: ', 'mainwp');
                ?>
</strong>&nbsp;<?php 
                echo $task->last_run == 0 ? __('Any minute', 'mainwp') : MainWPUtility::formatTimestamp(($task->schedule == 'daily' ? 60 * 60 * 24 : ($task->schedule == 'weekly' ? 60 * 60 * 24 * 7 : 60 * 60 * 24 * 30)) + MainWPUtility::getTimestamp($task->last_run));
                ?>
				</span>
				<div style="clear: left;"></div>
            </div>
             <?php 
            }
            ?>
        </div>
        <?php 
        }
    }
コード例 #10
0
    public static function render()
    {
        $show_form = true;
        if (isset($_POST['updateadminpassword'])) {
            check_admin_referer('mainwp_updateadminpassword', 'security');
            $errors = array();
            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;
                    }
                }
                if ($_POST['select_by'] == 'group' && count($selected_groups) == 0 || $_POST['select_by'] == 'site' && count($selected_sites) == 0) {
                    $errors[] = __('Please select the sites or groups where you want to change the admin password.', 'mainwp');
                }
            } else {
                $errors[] = __('Please select whether you want to change the admin password for specific sites or groups.', 'mainwp');
            }
            if (!isset($_POST['pass1']) || $_POST['pass1'] == '' || !isset($_POST['pass2']) || $_POST['pass2'] == '') {
                $errors[] = __('Please enter the password twice.', 'mainwp');
            } else {
                if ($_POST['pass1'] != $_POST['pass2']) {
                    $errors[] = __('Please enter the same password in the two password fields.', 'mainwp');
                }
            }
            if (count($errors) == 0) {
                $show_form = false;
                $new_password = array('user_pass' => $_POST['pass1']);
                $dbwebsites = array();
                if ($_POST['select_by'] == 'site') {
                    //Get all selected websites
                    foreach ($selected_sites as $k) {
                        if (MainWPUtility::ctype_digit($k)) {
                            $website = MainWPDB::Instance()->getWebsiteById($k);
                            $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                        }
                    }
                } else {
                    //Get all websites from the selected groups
                    foreach ($selected_groups as $k) {
                        if (MainWPUtility::ctype_digit($k)) {
                            $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupId($k));
                            while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                                if ($website->sync_errors != '') {
                                    continue;
                                }
                                $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                            }
                            @MainWPDB::free_result($websites);
                        }
                    }
                }
                if (count($dbwebsites) > 0) {
                    $post_data = array('new_password' => base64_encode(serialize($new_password)));
                    $output = new stdClass();
                    $output->ok = array();
                    $output->errors = array();
                    MainWPUtility::fetchUrlsAuthed($dbwebsites, 'newadminpassword', $post_data, array(MainWPBulkAdd::getClassName(), 'PostingBulk_handler'), $output);
                }
            }
        }
        if (!$show_form) {
            //Added to..
            ?>
            <div class="wrap">
                <img src="<?php 
            echo plugins_url('images/icons/mainwp-passwords.png', dirname(__FILE__));
            ?>
" style="float: left; margin-right: 8px; margin-top: 7px ;" alt="MainWP Passwords" height="32"/><h2 id="add-new-user"> Update Admin Passwords</h2>
                <div id="message" class="updated">
                    <?php 
            foreach ($dbwebsites as $website) {
                ?>
                        <p><a href="<?php 
                echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
                ?>
"><?php 
                echo stripslashes($website->name);
                ?>
</a>: <?php 
                echo isset($output->ok[$website->id]) && $output->ok[$website->id] == 1 ? __('Admin password updated.', 'mainwp') : __('ERROR: ', 'mainwp') . $output->errors[$website->id];
                ?>
</p>
            <?php 
            }
            ?>
                </div>
                <br />
                <a href="<?php 
            echo get_admin_url();
            ?>
admin.php?page=UpdateAdminPasswords" class="add-new-h2" target="_top"><?php 
            _e('Update admin passwords', 'mainwp');
            ?>
</a>
                <a href="<?php 
            echo get_admin_url();
            ?>
admin.php?page=mainwp_tab" class="add-new-h2" target="_top"><?php 
            _e('Return to Dashboard', 'mainwp');
            ?>
</a>
            </div>
            <?php 
        } else {
            // header in User page
            MainWPUser::renderHeader('UpdateAdminPasswords');
            ?>
            <form action="" method="post" name="createuser" id="createuser" class="add:users: validate">

                <input type="hidden" name="security" value="<?php 
            echo wp_create_nonce('mainwp_updateadminpassword');
            ?>
" />

                <div class="mainwp_config_box_right">
                    <?php 
            MainWPUI::select_sites_box(__("Select Sites to Update", 'mainwp'));
            ?>
                </div>

                <div class="mainwp_config_box_left postbox mainwp-postbox">
                <h3 class="mainwp_box_title"><i class="fa fa-key"></i> <?php 
            _e('Bulk Update Administrator Passwords', 'mainwp');
            ?>
</h3>
                <div class="inside">
                <table class="form-table">
                    <tr class="form-field form-required">
                        <th scope="row"><label for="pass1"><?php 
            _e('Enter New Password ', 'mainwp');
            ?>
<br /><span class="description"><?php 
            _e('(twice, required)', 'mainwp');
            ?>
</span></label></th>
                        <td><input name="user_login" type="hidden" id="user_login" value="admin">
                            <input class="mainwp-field mainwp-password" name="pass1" type="password" id="pass1" autocomplete="off" />
                            <br />
                            <input class="mainwp-field mainwp-password" name="pass2" type="password" id="pass2" autocomplete="off" />
                            <br />
                            <div id="pass-strength-result" style="display: block;"><?php 
            _e('Strength indicator', 'mainwp');
            ?>
</div>
                            <p class="description indicator-hint" style="clear:both;"><?php 
            _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).', 'mainwp');
            ?>
</p>
                        </td>
                    </tr>
                    <tr><td></td><td colspan="2"><input type="submit" name="updateadminpassword" id="bulk_updateadminpassword" class="button-primary" value="<?php 
            _e('Update Now', 'mainwp');
            ?>
"  /></td></tr>
                </table>
                </div>
                </div>

            </form>
            <?php 
            MainWPUser::renderFooter('UpdateAdminPasswords');
        }
    }
コード例 #11
0
 public static function action_update($pAction)
 {
     $postId = $_POST['postId'];
     $websiteIdEnc = $_POST['websiteId'];
     $post_data = $_POST['post_data'];
     if (!MainWPUtility::ctype_digit($postId)) {
         die('FAIL');
     }
     $websiteId = $websiteIdEnc;
     if (!MainWPUtility::ctype_digit($websiteId)) {
         die('FAIL');
     }
     $website = MainWPDB::Instance()->getWebsiteById($websiteId);
     if (!MainWPUtility::can_edit_website($website)) {
         die('FAIL');
     }
     try {
         $information = MainWPUtility::fetchUrlAuthed($website, 'post_action', array('action' => $pAction, 'id' => $postId, 'post_data' => $post_data));
     } catch (MainWPException $e) {
         die('FAIL');
     }
     if (!isset($information['status']) || $information['status'] != 'SUCCESS') {
         die('FAIL');
     }
 }
コード例 #12
0
 public function hookGetWebsitesByGroupIds($ids, $userId = null)
 {
     return MainWPDB::Instance()->getWebsitesByGroupIds($ids, $userId);
 }
コード例 #13
0
ファイル: MainWPDB.class.php プロジェクト: HasClass0/mainwp
 public function query($sql)
 {
     if ($sql == null) {
         return false;
     }
     $result = @self::_query($sql, $this->wpdb->dbh);
     if (!$result || @MainWPDB::num_rows($result) == 0) {
         return false;
     }
     return $result;
 }
コード例 #14
0
ファイル: MainWPMain.page.php プロジェクト: HasClass0/mainwp
    public static function renderDashboardBody($websites, $pDashboard, $pScreenLayout)
    {
        ?>
    <form action="admin-post.php" method="post">
        <?php 
        wp_nonce_field('mainwp_tab-general');
        ?>
        <?php 
        wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
        ?>
        <?php 
        wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
        ?>
        <input type="hidden" name="action" value="save_howto_testPages_general"/>
        <div class="postbox" style="padding-top: 1em;">
            <table id="mainwp-refresh-bar" width="100%">
                <tbody><tr>
                    <?php 
        $current_wp_id = MainWPUtility::get_current_wpid();
        $website = null;
        if (!empty($current_wp_id)) {
            $website = $websites[0];
        }
        $imgfavi = "";
        if ($website !== null) {
            if (get_option('mainwp_use_favicon', 1) == 1) {
                $favi = MainWPDB::Instance()->getWebsiteOption($website, 'favi_icon', "");
                $favi_url = MainWPUtility::get_favico_url($favi, $website);
                $imgfavi = '<img src="' . $favi_url . '" width="16" height="16" style="vertical-align:middle;"/>&nbsp;';
            }
        }
        if (time() - ($website == null ? MainWPDB::Instance()->getFirstSyncedSite() : $website->dtsSync) > 60 * 60 * 24) {
            ?>
                <td id="mainwp-welcome-bar" width="47%" style="padding-left: 1em;">
                    <span class="mainwp-reminder"><?php 
            _e('Your MainWP Dashboard has not been synced for 24 hours! Click the Sync Data button to get the latest data from child sites.', 'mainwp');
            ?>
</span><br/>
                </td>
                    <?php 
        } else {
            ?>
                <td id="mainwp-welcome-bar" width="47%" style="padding-left: 1em;">
                    <span style="font-size: 24px"><?php 
            echo $website == null ? __('Welcome to Your MainWP Dashboard!', 'mainwp') : sprintf(__('Welcome to %s Dashboard!', 'mainwp'), stripslashes($website->name));
            ?>
</span><br/>
                    <span style="font-style: italic; font-size: 14px;"><?php 
            echo $website == null ? __('Manage your WordPress sites with ease.', 'mainwp') : sprintf(__('This information is only for %s%s', 'mainwp'), $imgfavi, MainWPUtility::getNiceURL($website->url, true));
            ?>
</span>
                </td>
                    <?php 
        }
        ?>
                <td id="mainwp-refresh-bar-buttons">
                <a class="button-hero button mainwp-upgrade-button" id="dashboard_refresh" title="<?php 
        echo MainWPRightNow::renderLastUpdate();
        ?>
"><?php 
        _e('<i class="fa fa-refresh"></i> Sync Data', 'mainwp');
        ?>
</a>
                <a class="button-hero button-primary button mainwp-addsite-button" href="admin.php?page=managesites&do=new"><?php 
        _e('<i class="fa fa-plus"></i> Add New Site', 'mainwp');
        ?>
</a>
                <a class="button-hero button-primary button mainwp-button-red" target="_blank" href="https://extensions.mainwp.com"><?php 
        _e('<i class="fa fa-cart-plus"></i> Get New Extensions', 'mainwp');
        ?>
</a>
                </td>
            <div id="dashboard_refresh_statusextra" style="display: none"> <i class="fa fa-spinner fa-pulse"></i> </div>
                </tr></tbody>
            </table>
            <div id="mainwp_dashboard_refresh_status"></div>
        </div>
        <div id="mainwp_main_errors" class="mainwp_error"></div>
    </form>

    <div id="dashboard-widgets-wrap">

    <?php 
        require_once ABSPATH . 'wp-admin/includes/dashboard.php';
        wp_dashboard();
        ?>

    <div class="clear"></div>
    </div><!-- dashboard-widgets-wrap -->
    <?php 
    }
コード例 #15
0
    public static function renderSites($renew, $pExit = true)
    {
        $current_wpid = MainWPUtility::get_current_wpid();
        if ($current_wpid) {
            $sql = MainWPDB::Instance()->getSQLWebsiteById($current_wpid);
        } else {
            $sql = MainWPDB::Instance()->getSQLWebsitesForCurrentUser();
        }
        $websites = MainWPDB::Instance()->query($sql);
        $allPages = array();
        if ($websites) {
            while ($websites && ($website = @MainWPDB::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;
                }
            }
            @MainWPDB::free_result($websites);
        }
        $recent_pages_published = MainWPUtility::getSubArrayHaving($allPages, 'status', 'publish');
        $recent_pages_published = MainWPUtility::sortmulti($recent_pages_published, 'dts', 'desc');
        $recent_pages_draft = MainWPUtility::getSubArrayHaving($allPages, 'status', 'draft');
        $recent_pages_draft = MainWPUtility::sortmulti($recent_pages_draft, 'dts', 'desc');
        $recent_pages_pending = MainWPUtility::getSubArrayHaving($allPages, 'status', 'pending');
        $recent_pages_pending = MainWPUtility::sortmulti($recent_pages_pending, 'dts', 'desc');
        $recent_pages_trash = MainWPUtility::getSubArrayHaving($allPages, 'status', 'trash');
        $recent_pages_trash = MainWPUtility::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'] = MainWPUtility::formatTimestamp(MainWPUtility::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>
                    <span class="mainwp-mid-col">
                            <a href="<?php 
            echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_pages_published[$i]['website']->id . '&postid=' . $recent_pages_published[$i]['id']);
            ?>
" title="<?php 
            echo $recent_pages_published[$i]['comment_count'];
            ?>
" class="post-com-count" style="display: inline-block !important;">
                                <span class="comment-count"><?php 
            echo $recent_pages_published[$i]['comment_count'];
            ?>
</span>
                            </a>
                    </span>
                    <span class="mainwp-right-col"><a href="<?php 
            echo $recent_pages_published[$i]['website']->url;
            ?>
" target="_blank"><i class="fa fa-external-link"></i> <?php 
            echo MainWPUtility::getNiceURL($recent_pages_published[$i]['website']->url);
            ?>
</a> <br/><?php 
            echo $recent_pages_published[$i]['dts'];
            ?>
</span>

                    <div style="clear: left;"></div>
                    <div class="mainwp-row-actions"><a href="#" class="mainwp-post-unpublish"><?php 
            _e('Unpublish', 'mainwp');
            ?>
</a> | <a href="admin.php?page=SiteOpen&websiteid=<?php 
            echo $recent_pages_published[$i]['website']->id;
            ?>
&location=<?php 
            echo base64_encode('post.php?action=editpost&post=' . $recent_pages_published[$i]['id'] . '&action=edit');
            ?>
" title="Edit this post"><?php 
            _e('Edit', 'mainwp');
            ?>
</a> | <a href="#" class="mainwp-post-trash"><?php 
            _e('Trash', 'mainwp');
            ?>
</a>| <a href="<?php 
            echo $recent_pages_published[$i]['website']->url . (substr($recent_pages_published[$i]['website']->url, -1) != '/' ? '/' : '') . '?p=' . $recent_pages_published[$i]['id'];
            ?>
" target="_blank" title="View '<?php 
            echo $recent_pages_published[$i]['title'];
            ?>
'" rel="permalink"><?php 
            _e('View', 'mainwp');
            ?>
</a> | <a href="admin.php?page=PageBulkManage" class="mainwp-post-viewall"><?php 
            _e('View All', 'mainwp');
            ?>
</a></div>
                    <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
            _e('Please wait', 'mainwp');
            ?>
                    <div>&nbsp;</div>
                    </div>
                </div>
                <?php 
        }
        ?>
            </div>

            <div class="recent_posts_draft" style="display: none">
                <?php 
        for ($i = 0; $i < count($recent_pages_draft) && $i < 5; $i++) {
            if (!isset($recent_pages_draft[$i]['title']) || $recent_pages_draft[$i]['title'] == '') {
                $recent_pages_draft[$i]['title'] = '(No Title)';
            }
            if (isset($recent_pages_draft[$i]['dts'])) {
                if (!stristr($recent_pages_draft[$i]['dts'], '-')) {
                    $recent_pages_draft[$i]['dts'] = MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($recent_pages_draft[$i]['dts']));
                }
            }
            ?>
                <div class="mainwp-row mainwp-recent">
                    <input class="postId" type="hidden" name="id" value="<?php 
            echo $recent_pages_draft[$i]['id'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $recent_pages_draft[$i]['website']->id;
            ?>
"/>
                    <span class="mainwp-left-col" style="width: 60% !important;  margin-right: 1em;"><a href="<?php 
            echo $recent_pages_draft[$i]['website']->url;
            ?>
?p=<?php 
            echo $recent_pages_draft[$i]['id'];
            ?>
" target="_blank"><?php 
            echo htmlentities($recent_pages_draft[$i]['title'], ENT_COMPAT | ENT_HTML401, "UTF-8");
            ?>
</a></span>
                    <span class="mainwp-mid-col">
                            <a href="<?php 
            echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_pages_draft[$i]['website']->id . '&postid=' . $recent_pages_draft[$i]['id']);
            ?>
" title="<?php 
            echo $recent_pages_draft[$i]['comment_count'];
            ?>
" class="post-com-count" style="display: inline-block !important;">
                                <span class="comment-count"><?php 
            echo $recent_pages_draft[$i]['comment_count'];
            ?>
</span>
                            </a>
                    </span>
                    <span class="mainwp-right-col"><?php 
            echo MainWPUtility::getNiceURL($recent_pages_draft[$i]['website']->url);
            ?>
 <br/><?php 
            echo $recent_pages_draft[$i]['dts'];
            ?>
</span>

                    <div style="clear: left;"></div>
                    <div class="mainwp-row-actions"><a href="#" class="mainwp-post-publish"><?php 
            _e('Publish', 'mainwp');
            ?>
</a> | <a href="admin.php?page=SiteOpen&websiteid=<?php 
            echo $recent_pages_draft[$i]['website']->id;
            ?>
&location=<?php 
            echo base64_encode('post.php?action=editpost&post=' . $recent_pages_draft[$i]['id'] . '&action=edit');
            ?>
" title="Edit this post"><?php 
            _e('Edit', 'mainwp');
            ?>
</a> | <a href="#" class="mainwp-post-trash"><?php 
            _e('Trash', 'mainwp');
            ?>
</a> | <a href="admin.php?page=PostBulkManage" class="mainwp-post-viewall"><?php 
            _e('View All', 'mainwp');
            ?>
</a></div>
                    <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
            _e('Please wait', 'mainwp');
            ?>
                    </div>
                    <div>&nbsp;</div>
                </div>
                <?php 
        }
        ?>
            </div>

            <div class="recent_posts_pending" style="display: none">
                <?php 
        for ($i = 0; $i < count($recent_pages_pending) && $i < 5; $i++) {
            if (!isset($recent_pages_pending[$i]['title']) || $recent_pages_pending[$i]['title'] == '') {
                $recent_pages_pending[$i]['title'] = '(No Title)';
            }
            if (isset($recent_pages_pending[$i]['dts'])) {
                if (!stristr($recent_pages_pending[$i]['dts'], '-')) {
                    $recent_pages_pending[$i]['dts'] = MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($recent_pages_pending[$i]['dts']));
                }
            }
            ?>
                <div class="mainwp-row mainwp-recent">
                    <input class="postId" type="hidden" name="id" value="<?php 
            echo $recent_pages_pending[$i]['id'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $recent_pages_pending[$i]['website']->id;
            ?>
"/>
                    <span class="mainwp-left-col" style="width: 60% !important;  margin-right: 1em;"><a href="<?php 
            echo $recent_pages_pending[$i]['website']->url;
            ?>
?p=<?php 
            echo $recent_pages_pending[$i]['id'];
            ?>
" target="_blank"><?php 
            echo htmlentities($recent_pages_pending[$i]['title'], ENT_COMPAT | ENT_HTML401, "UTF-8");
            ?>
</a></span>
                    <span class="mainwp-mid-col">
                            <a href="<?php 
            echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_pages_pending[$i]['website']->id . '&postid=' . $recent_pages_pending[$i]['id']);
            ?>
" title="<?php 
            echo $recent_pages_pending[$i]['comment_count'];
            ?>
" class="post-com-count" style="display: inline-block !important;">
                                <span class="comment-count"><?php 
            echo $recent_pages_pending[$i]['comment_count'];
            ?>
</span>
                            </a>
                    </span>
                    <span class="mainwp-right-col"><?php 
            echo MainWPUtility::getNiceURL($recent_pages_pending[$i]['website']->url);
            ?>
 <br/><?php 
            echo $recent_pages_pending[$i]['dts'];
            ?>
</span>

                    <div style="clear: left;"></div>
                    <div class="mainwp-row-actions"><a href="#" class="mainwp-post-publish"><?php 
            _e('Publish', 'mainwp');
            ?>
</a> | <a href="admin.php?page=SiteOpen&websiteid=<?php 
            echo $recent_pages_pending[$i]['website']->id;
            ?>
&location=<?php 
            echo base64_encode('post.php?action=editpost&post=' . $recent_pages_pending[$i]['id'] . '&action=edit');
            ?>
" title="Edit this post"><?php 
            _e('Edit', 'mainwp');
            ?>
</a> | <a href="#" class="mainwp-post-trash"><?php 
            _e('Trash', 'mainwp');
            ?>
</a> | <a href="admin.php?page=PostBulkManage" class="mainwp-post-viewall"><?php 
            _e('View All', 'mainwp');
            ?>
</a></div>
                    <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
            _e('Please wait', 'mainwp');
            ?>
                    </div>
                    <div>&nbsp;</div>
                </div>
                <?php 
        }
        ?>
            </div>
            <div class="recent_posts_trash" style="display: none">
                <?php 
        for ($i = 0; $i < count($recent_pages_trash) && $i < 5; $i++) {
            if (!isset($recent_pages_trash[$i]['title']) || $recent_pages_trash[$i]['title'] == '') {
                $recent_pages_trash[$i]['title'] = '(No Title)';
            }
            if (isset($recent_pages_trash[$i]['dts'])) {
                if (!stristr($recent_pages_trash[$i]['dts'], '-')) {
                    $recent_pages_trash[$i]['dts'] = MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($recent_pages_trash[$i]['dts']));
                }
            }
            ?>
                <div class="mainwp-row mainwp-recent">
                    <input class="postId" type="hidden" name="id" value="<?php 
            echo $recent_pages_trash[$i]['id'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $recent_pages_trash[$i]['website']->id;
            ?>
"/>
                    <span class="mainwp-left-col" style="width: 60% !important;  margin-right: 1em;"><?php 
            echo $recent_pages_trash[$i]['title'];
            ?>
</span>
                    <span class="mainwp-mid-col">
                            <a href="<?php 
            echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_pages_trash[$i]['website']->id . '&postid=' . $recent_pages_trash[$i]['id']);
            ?>
" title="<?php 
            echo $recent_pages_trash[$i]['comment_count'];
            ?>
" class="post-com-count" style="display: inline-block !important;">
                                <span class="comment-count"><?php 
            echo $recent_pages_trash[$i]['comment_count'];
            ?>
</span>
                            </a>
                    </span>
                    <span class="mainwp-right-col"><?php 
            echo MainWPUtility::getNiceURL($recent_pages_trash[$i]['website']->url);
            ?>
 <br/><?php 
            echo $recent_pages_trash[$i]['dts'];
            ?>
</span>

                    <div style="clear: left;"></div>
                    <div class="mainwp-row-actions"><a href="#" class="mainwp-post-restore"><?php 
            _e('Restore', 'mainwp');
            ?>
</a> | <a href="#" class="mainwp-post-delete delete" style="color: red;"><?php 
            _e('Delete Permanently', 'mainwp');
            ?>
</a></div>
                    <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
            _e('Please wait', 'mainwp');
            ?>
                    </div>
                    <div>&nbsp;</div>
                </div>
                <?php 
        }
        ?>
            </div>
        </div>
    <div class="clear"></div>
    <?php 
        if ($pExit == true) {
            exit;
        }
    }
コード例 #16
0
 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 = MainWPDB::Instance()->getGroupById($groupid);
         if (!MainWPUtility::can_edit_group($group)) {
             return false;
         }
         $websites = MainWPDB::Instance()->getWebsitesByGroupId($group->id);
         $websitesOut = array();
         foreach ($websites as $website) {
             $websitesOut[] = $website->id;
         }
         return array(array('id' => $groupid, 'name' => $group->name, 'websites' => $websitesOut));
     }
     $groups = MainWPDB::Instance()->getGroupsAndCount(null, $for_manager);
     $output = array();
     foreach ($groups as $group) {
         $websites = MainWPDB::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;
 }
コード例 #17
0
    function extra_tablenav($which)
    {
        ?>


    <div class="alignleft actions">
        <form method="GET" action="">
            <input type="hidden" value="<?php 
        echo $_REQUEST['page'];
        ?>
" name="page"/>
            <select name="g">
                <option value=""><?php 
        _e('All Groups', 'mainwp');
        ?>
</option>
                <?php 
        $groups = MainWPDB::Instance()->getGroupsForCurrentUser();
        foreach ($groups as $group) {
            echo '<option value="' . $group->id . '" ' . (isset($_REQUEST['g']) && $_REQUEST['g'] == $group->id ? 'selected' : '') . '>' . $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']) ? $_REQUEST['s'] : '';
        ?>
"
                   autocompletelist="sites" name="s" class="mainwp_autocomplete"/>
            <datalist id="sites">
    <?php 
        if (MainWPDB::is_result($this->items)) {
            while ($this->items && ($item = @MainWPDB::fetch_array($this->items))) {
                echo '<option>' . $item['name'] . '</option>';
            }
            MainWPDB::data_seek($this->items, 0);
        }
        ?>
            </datalist>
            <input type="submit" value="<?php 
        _e('Search Sites');
        ?>
" class="button" name=""/>
        </form>
    </div>
    <?php 
    }
コード例 #18
0
ファイル: MainWPUtility.class.php プロジェクト: BjornW/mainwp
 public static function getCurrentArchiveExtension($website = false, $task = false)
 {
     $useSite = true;
     if ($task != false) {
         if ($task->archiveFormat == 'global') {
             $useGlobal = true;
             $useSite = false;
         } else {
             if ($task->archiveFormat == '' || $task->archiveFormat == 'site') {
                 $useGlobal = false;
                 $useSite = true;
             } else {
                 $archiveFormat = $task->archiveFormat;
                 $useGlobal = false;
                 $useSite = false;
             }
         }
     }
     if ($useSite) {
         if ($website == false) {
             $useGlobal = true;
         } else {
             $backupSettings = MainWPDB::Instance()->getWebsiteBackupSettings($website->id);
             $archiveFormat = $backupSettings->archiveFormat;
             $useGlobal = $archiveFormat == 'global';
         }
     }
     if ($useGlobal) {
         $archiveFormat = get_option('mainwp_archiveFormat');
         if ($archiveFormat === false) {
             $archiveFormat = 'tar.gz';
         }
     }
     return $archiveFormat;
 }
コード例 #19
0
ファイル: MainWPSystem.class.php プロジェクト: sdmtt/mainwp
 function update()
 {
     MainWPDB::Instance()->update();
     MainWPDB::Instance()->install();
 }
コード例 #20
0
    public static function render()
    {
        $current_wpid = MainWPUtility::get_current_wpid();
        if (!MainWPUtility::ctype_digit($current_wpid)) {
            return;
        }
        $website = MainWPDB::Instance()->getWebsiteById($current_wpid, true);
        ?>
    <div class="mainwp-row-top">
        <div style="display: inline-block; width: 100px;"><?php 
        _e('Groups:', 'mainwp');
        ?>
</div>
        <?php 
        echo $website->groups == '' ? 'None' : $website->groups;
        ?>
    </div>
    <div class="mainwp-row">
        <div style="display: inline-block; width: 100px;"><?php 
        _e('Notes:', 'mainwp');
        ?>
</div>
        <a href="#" class="mainwp_notes_show_all" id="mainwp_notes_<?php 
        echo $website->id;
        ?>
"><i class="fa fa-pencil"></i> <?php 
        _e('Open Notes', 'mainwp');
        ?>
</a><img src="<?php 
        echo plugins_url('images/notes.png', dirname(__FILE__));
        ?>
" class="mainwp_notes_img" id="mainwp_notes_img_<?php 
        echo $website->id;
        ?>
" <?php 
        if ($website->note == '') {
            echo 'style="display: none;"';
        }
        ?>
 />
    </div>
    <span style="display: none"
          id="mainwp_notes_<?php 
        echo $website->id;
        ?>
_note"><?php 
        echo $website->note;
        ?>
</span>
    <div class="mainwp-row">
        <div style="display: inline-block; width: 100px;"><?php 
        _e('Go to:', 'mainwp');
        ?>
</div>
        <a href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php 
        echo $website->id;
        ?>
" target="_blank"><i class="fa fa-external-link"></i> <?php 
        _e('WP Admin', 'mainwp');
        ?>
</a> | <a target="_blank" href="<?php 
        echo $website->url;
        ?>
"><i class="fa fa-external-link"></i> <?php 
        _e('Front Page', 'mainwp');
        ?>
</a>
    </div>
    <div class="mainwp-row">
        <div style="display: inline-block; width: 100px;"><?php 
        _e('Child Site:', 'mainwp');
        ?>
</div>
        <a href="admin.php?page=managesites&id=<?php 
        echo $website->id;
        ?>
"><i class="fa fa-pencil-square-o"></i> <?php 
        _e('Edit', 'mainwp');
        ?>
</a> | <a target="_blank" href="admin.php?page=managesites&scanid=<?php 
        echo $website->id;
        ?>
"><i class="fa fa-shield"></i> <?php 
        _e('Security Scan', 'mainwp');
        ?>
</a>
    </div>

    <?php 
        do_action("mainwp_shortcuts_widget", $website);
        ?>
    <div id="mainwp_notes_overlay" class="mainwp_overlay"></div>
    <div id="mainwp_notes" class="mainwp_popup">
        <a id="mainwp_notes_closeX" class="mainwp_closeX" style="display: inline; "></a>

        <div id="mainwp_notes_title" class="mainwp_popup_title"><a href="<?php 
        echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
        ?>
"><?php 
        echo stripslashes($website->name);
        ?>
</a></div>
        <div id="mainwp_notes_content">
            <textarea style="width: 580px !important; height: 300px;"
                      id="mainwp_notes_note"></textarea>
        </div>
        <div><em>Allowed HTML Tags: &lt;p&gt;, &lt;strong&gt;, &lt;em&gt;, &lt;br/&gt;, &lt;hr/&gt;, &lt;a&gt; </em></div><br/>
        <form>
            <div style="float: right" id="mainwp_notes_status"></div>
            <input type="button" class="button cont button-primary" id="mainwp_notes_save" value="<?php 
        _e('Save Note', 'mainwp');
        ?>
"/>
            <input type="button" class="button cont" id="mainwp_notes_cancel" value="<?php 
        _e('Close', 'mainwp');
        ?>
"/>
            <input type="hidden" id="mainwp_notes_websiteid" value=""/>
        </form>
    </div>
    <?php 
    }
コード例 #21
0
 function mainwp_testwp()
 {
     $this->secure_request('mainwp_testwp');
     $url = null;
     $name = null;
     $http_user = null;
     $http_pass = null;
     $verifyCertificate = 1;
     if (isset($_POST['url'])) {
         $url = $_POST['url'];
         $verifyCertificate = $_POST['test_verify_cert'];
         $http_user = $_POST['http_user'];
         $http_pass = $_POST['http_pass'];
     } else {
         if (isset($_POST['siteid'])) {
             $website = MainWPDB::Instance()->getWebsiteById($_POST['siteid']);
             if ($website) {
                 $url = $website->url;
                 $name = $website->name;
                 $verifyCertificate = $website->verify_certificate;
                 $http_user = $website->http_user;
                 $http_pass = $website->http_pass;
             }
         }
     }
     $rslt = MainWPUtility::tryVisit($url, $verifyCertificate, $http_user, $http_pass);
     if (isset($rslt['error']) && $rslt['error'] != '' && substr($url, -9) != 'wp-admin/') {
         if (substr($url, -1) != '/') {
             $url .= '/';
         }
         $url .= 'wp-admin/';
         $newrslt = MainWPUtility::tryVisit($url, $verifyCertificate, $http_user, $http_pass);
         if (isset($newrslt['error']) && $rslt['error'] != '') {
             $rslt = $newrslt;
         }
     }
     if ($name != null) {
         $rslt['sitename'] = $name;
     }
     die(json_encode($rslt));
 }
コード例 #22
0
 public static function renderMetabox()
 {
     $website = MainWPUtility::get_current_wpid();
     if (!$website) {
         return;
     }
     $website = MainWPDB::Instance()->getWebsiteById($website);
     MainWPManageSitesView::showSEOWidget($website);
 }
コード例 #23
0
 public static function checkBackups()
 {
     //if (get_option('mainwp_backup_before_upgrade') != 1) return true;
     if (!is_array($_POST['sites'])) {
         return true;
     }
     $global_backup_before_upgrade = get_option('mainwp_backup_before_upgrade');
     $output = array();
     foreach ($_POST['sites'] as $siteId) {
         $website = MainWPDB::Instance()->getWebsiteById($siteId);
         if ($website->backup_before_upgrade == 0 || $website->backup_before_upgrade == 2 && $global_backup_before_upgrade == 0) {
             continue;
         }
         $dir = MainWPUtility::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 (MainWPUtility::isArchive($file) && !MainWPUtility::isSQLArchive($file) && filemtime($theFile) > $lastBackup) {
                         $lastBackup = filemtime($theFile);
                     }
                 }
             }
             closedir($dh);
         }
         $output['sites'][$siteId] = $lastBackup < time() - 7 * 24 * 60 * 60 ? false : true;
     }
     return $output;
 }
コード例 #24
0
    public static function renderMetabox()
    {
        $website = MainWPUtility::get_current_wpid();
        if (!$website) {
            return;
        }
        $website = MainWPDB::Instance()->getWebsiteById($website);
        MainWPManageSites::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 
    }
コード例 #25
0
 public static function updateGroup()
 {
     if (isset($_POST['groupId']) && MainWPUtility::ctype_digit($_POST['groupId'])) {
         $group = MainWPDB::Instance()->getGroupById($_POST['groupId']);
         if (MainWPUtility::can_edit_group($group)) {
             MainWPDB::Instance()->clearGroup($group->id);
             if (isset($_POST['websiteIds'])) {
                 foreach ($_POST['websiteIds'] as $websiteId) {
                     $website = MainWPDB::Instance()->getWebsiteById($websiteId);
                     if (MainWPUtility::can_edit_website($website)) {
                         MainWPDB::Instance()->updateGroupSite($group->id, $website->id);
                     }
                 }
             }
             die(json_encode(array('result' => true)));
         }
     }
     die(json_encode(array('result' => false)));
 }
コード例 #26
0
 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);
                 $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 = $_POST['verify_certificate'];
             $addUniqueId = $_POST['managesites_add_uniqueId'];
             $http_user = $_POST['managesites_add_http_user'];
             $http_pass = $_POST['managesites_add_http_pass'];
             $information = MainWPUtility::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);
             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 = MainWPDB::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 = $_POST['managesites_add_http_user'];
                     $http_pass = $_POST['managesites_add_http_pass'];
                     global $current_user;
                     $id = MainWPDB::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);
                     $message = sprintf(__('Site successfully added - Visit the Site\'s <a href="admin.php?page=managesites&dashboard=%d" style="text-decoration: none;" title="Dashboard">Dashboard</a> now.', 'mainwp'), $id);
                     $website = MainWPDB::Instance()->getWebsiteById($id);
                     MainWPSync::syncInformationArray($website, $information);
                 } else {
                     $error = 'Undefined error';
                 }
             }
         } catch (MainWPException $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 .= __('test your connection <a href="' . admin_url('admin.php?page=managesites&do=test&site=' . urlencode($e->getMessageExtra())) . '">here</a> or ', 'mainwp');
                     }
                     $error .= __('post as much information as possible on the error in the <a href="https://mainwp.com/forum/">support forum</a>.', 'mainwp');
                 } else {
                     $error = $e->getMessage();
                 }
             }
         }
     }
     return array($message, $error);
 }
コード例 #27
0
 protected static function getMySQLVersion()
 {
     return MainWPDB::Instance()->getMySQLVersion();
 }
コード例 #28
0
    public static function renderSettings()
    {
        $userExtension = MainWPDB::Instance()->getUserExtension();
        $onlineNotifications = $userExtension == null || ($userExtension->offlineChecksOnlineNotification == null || $userExtension->offlineChecksOnlineNotification == '') ? '0' : $userExtension->offlineChecksOnlineNotification;
        ?>
    <div class="postbox" id="mainwp-offline-check-options-settings">
    <h3 class="mainwp_box_title"><span><i class="fa fa-cog"></i> <?php 
        _e('Offline Check Options', 'mainwp');
        ?>
</span></h3>
    <div class="inside">
    <table class="form-table">
        <tbody>
        <tr>
            <th scope="row"><?php 
        _e('Online Notifications', 'mainwp');
        ?>
 <?php 
        MainWPUtility::renderToolTip(__('Network will monitor your sites for downtime and uptime.  By default emails are only sent when your site is down.', 'mainwp'));
        ?>
</th>
            <td>
            	<div class="mainwp-checkbox">
                <input type="checkbox" name="mainwp_options_offlinecheck_onlinenotification"
                       id="mainwp_options_offlinecheck_onlinenotification" <?php 
        echo $onlineNotifications == 1 ? 'checked="true"' : '';
        ?>
 />
                <label for="mainwp_options_offlinecheck_onlinenotification"></label>
               </div><?php 
        _e('Enable notifications even when the website is online', 'mainwp');
        ?>
            </td>
        </tr>
        </tbody>
    </table>
    </div>
    </div>
    <?php 
    }
コード例 #29
0
ファイル: MainWPPage.page.php プロジェクト: sdmtt/mainwp
    public static function posting()
    {
        ?>
    <div class="wrap">
      <?php 
        //  Use this to add a new page. To bulk change pages click on the "Manage" tab.
        do_action("mainwp_bulkpage_before_post", $_GET['id']);
        $skip_post = false;
        if (isset($_GET['id'])) {
            if ('yes' == get_post_meta($_GET['id'], '_mainwp_skip_posting', true)) {
                $skip_post = true;
                wp_delete_post($_GET['id'], true);
            }
        }
        if (!$skip_post) {
            //Posts the saved sites
            if (isset($_GET['id'])) {
                $id = $_GET['id'];
                $post = get_post($id);
                if ($post) {
                    $selected_by = get_post_meta($id, '_selected_by', true);
                    $selected_sites = unserialize(base64_decode(get_post_meta($id, '_selected_sites', true)));
                    $selected_groups = unserialize(base64_decode(get_post_meta($id, '_selected_groups', true)));
                    $post_slug = base64_decode(get_post_meta($id, '_slug', true));
                    $post_custom = get_post_custom($id);
                    include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php';
                    $post_featured_image = get_post_thumbnail_id($id);
                    $mainwp_upload_dir = wp_upload_dir();
                    $new_post = array('post_title' => $post->post_title, 'post_content' => $post->post_content, 'post_status' => $post->post_status, 'post_date' => $post->post_date, 'post_date_gmt' => $post->post_date_gmt, 'post_type' => 'page', 'post_name' => $post_slug, 'post_excerpt' => $post->post_excerpt, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'id_spin' => $post->ID);
                    if ($post_featured_image != null) {
                        //Featured image is set, retrieve URL
                        $img = wp_get_attachment_image_src($post_featured_image, 'full');
                        $post_featured_image = $img[0];
                    }
                    $dbwebsites = array();
                    if ($selected_by == 'site') {
                        //Get all selected websites
                        foreach ($selected_sites as $k) {
                            if (MainWPUtility::ctype_digit($k)) {
                                $website = MainWPDB::Instance()->getWebsiteById($k);
                                $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                            }
                        }
                    } else {
                        //Get all websites from the selected groups
                        foreach ($selected_groups as $k) {
                            if (MainWPUtility::ctype_digit($k)) {
                                $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupId($k));
                                while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                                    if ($website->sync_errors != '') {
                                        continue;
                                    }
                                    $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                                }
                                @MainWPDB::free_result($websites);
                            }
                        }
                    }
                    $output = new stdClass();
                    $output->ok = array();
                    $output->errors = array();
                    $startTime = time();
                    if (count($dbwebsites) > 0) {
                        $post_data = array('new_post' => base64_encode(serialize($new_post)), 'post_custom' => base64_encode(serialize($post_custom)), 'post_featured_image' => base64_encode($post_featured_image), 'mainwp_upload_dir' => base64_encode(serialize($mainwp_upload_dir)));
                        $post_data = apply_filters("mainwp_bulkpage_posting", $post_data, $id);
                        MainWPUtility::fetchUrlsAuthed($dbwebsites, 'newpost', $post_data, array(MainWPBulkAdd::getClassName(), 'PostingBulk_handler'), $output);
                    }
                    $failed_posts = array();
                    foreach ($dbwebsites as $website) {
                        if ($output->ok[$website->id] == 1 && isset($output->added_id[$website->id])) {
                            do_action('mainwp-post-posting-page', $website, $output->added_id[$website->id], isset($output->link[$website->id]) ? $output->link[$website->id] : null);
                            do_action('mainwp-bulkposting-done', $post, $website, $output);
                        } else {
                            $failed_posts[] = $website->id;
                        }
                    }
                    $del_post = true;
                    $saved_draft = get_post_meta($id, "_saved_as_draft", true);
                    if ($saved_draft == "yes") {
                        if (count($failed_posts) > 0) {
                            $del_post = false;
                            update_post_meta($post->ID, "_selected_sites", base64_encode(serialize($failed_posts)));
                            update_post_meta($post->ID, "_selected_groups", "");
                            wp_update_post(array("ID" => $id, 'post_status' => 'draft'));
                        }
                    }
                    if ($del_post) {
                        wp_delete_post($id, true);
                    }
                    $countSites = 0;
                    foreach ($dbwebsites as $website) {
                        if (isset($output->ok[$website->id]) && $output->ok[$website->id] == 1) {
                            $countSites++;
                        }
                    }
                    if (!empty($countSites)) {
                        $seconds = time() - $startTime;
                        MainWPTwitter::updateTwitterInfo('new_page', $countSites, $seconds, 1, $startTime, 1);
                    }
                    if (MainWPTwitter::enabledTwitterMessages()) {
                        $twitters = MainWPTwitter::getTwitterNotice('new_page');
                        if (is_array($twitters)) {
                            foreach ($twitters as $timeid => $twit_mess) {
                                if (!empty($twit_mess)) {
                                    $sendText = MainWPTwitter::getTwitToSend('new_page', $timeid);
                                    ?>
                                    <div class="mainwp-tips mainwp_info-box-blue twitter"><span class="mainwp-tip" twit-what="new_page" twit-id="<?php 
                                    echo $timeid;
                                    ?>
"><?php 
                                    echo $twit_mess;
                                    ?>
</span>&nbsp;<?php 
                                    MainWPTwitter::genTwitterButton($sendText);
                                    ?>
<span><a href="#" class="mainwp-dismiss-twit" ><i class="fa fa-times-circle"></i> <?php 
                                    _e('Dismiss', 'mainwp');
                                    ?>
</a></span></div>
                                <?php 
                                }
                            }
                        }
                    }
                }
                ?>
                <div id="message" class="updated">
                    <?php 
                foreach ($dbwebsites as $website) {
                    ?>
                    <p><a href="<?php 
                    echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
                    ?>
"><?php 
                    echo stripslashes($website->name);
                    ?>
</a>
                        : <?php 
                    echo isset($output->ok[$website->id]) && $output->ok[$website->id] == 1 ? 'New page created. ' . "<a href=\"" . $output->link[$website->id] . "\"  target=\"_blank\">View Page</a>" : 'ERROR: ' . $output->errors[$website->id];
                    ?>
</p>
                    <?php 
                }
                ?>
                </div>
               
                <?php 
            } else {
                ?>
                <div class="error below-h2">
                    <p><strong>ERROR</strong>: <?php 
                _e('An undefined error occured.', 'mainwp');
                ?>
</p>
                </div>               
                <?php 
            }
        }
        // no skip posting
        ?>
        <br/>
        <a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=PageBulkAdd" class="add-new-h2" target="_top"><?php 
        _e('Add New', 'mainwp');
        ?>
</a>
        <a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=mainwp_tab" class="add-new-h2" target="_top"><?php 
        _e('Return
            to Dashboard', 'mainwp');
        ?>
</a>
                
    </div>
    <?php 
    }
コード例 #30
0
 public static function action($pAction)
 {
     $plugin = $_POST['plugin'];
     $websiteIdEnc = $_POST['websiteId'];
     if (empty($plugin)) {
         die(json_encode(array('error' => 'Invalid Request.')));
     }
     $websiteId = $websiteIdEnc;
     if (!MainWPUtility::ctype_digit($websiteId)) {
         die(json_encode(array('error' => 'Invalid Request.')));
     }
     $website = MainWPDB::Instance()->getWebsiteById($websiteId);
     if (!MainWPUtility::can_edit_website($website)) {
         die(json_encode(array('error' => 'You can not edit this website.')));
     }
     try {
         $information = MainWPUtility::fetchUrlAuthed($website, 'plugin_action', array('action' => $pAction, 'plugin' => $plugin));
     } catch (MainWPException $e) {
         die(json_encode(array('error' => $e->getMessage())));
     }
     if (!isset($information['status']) || $information['status'] != 'SUCCESS') {
         die(json_encode(array('error' => 'Unexpected error.')));
     }
 }