Beispiel #1
0
 public function warningForWebsite($pWebsite, $pAction, $pMessage, $addStackTrace = true)
 {
     if (empty($pWebsite)) {
         return false;
     }
     $stackTrace = '';
     if ($addStackTrace) {
         @ob_start();
         @debug_print_backtrace();
         $stackTrace = "\n" . @ob_get_clean();
     }
     return $this->log('[' . $pWebsite->name . '] [' . MainWPUtility::getNiceURL($pWebsite->url) . ']  ::' . $pAction . ':: ' . $pMessage . $stackTrace, self::WARNING);
 }
    public static function getWebsiteListContent()
    {
        $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser());
        while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
            ?>
            <li class="managegroups_site-listitem"><input type="checkbox" name="sites" value="<?php 
            echo $website->id;
            ?>
" id="<?php 
            echo MainWPUtility::getNiceURL($website->url);
            ?>
" class="mainwp-checkbox2"><label for="<?php 
            echo MainWPUtility::getNiceURL($website->url);
            ?>
" class="mainwp-label2"><span class="website_url" style="display: none;"><?php 
            echo MainWPUtility::getNiceURL($website->url);
            ?>
</span><span class="website_name"><?php 
            echo stripslashes($website->name);
            ?>
</span></label></li>
            <?php 
        }
        @MainWPDB::free_result($websites);
    }
    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);
        $allPosts = array();
        if ($websites) {
            while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                if ($website->recent_posts == '') {
                    continue;
                }
                $posts = json_decode($website->recent_posts, 1);
                if (count($posts) == 0) {
                    continue;
                }
                foreach ($posts as $post) {
                    $post['website'] = (object) array('id' => $website->id, 'url' => $website->url);
                    $allPosts[] = $post;
                }
            }
            @MainWPDB::free_result($websites);
        }
        $recent_posts_published = MainWPUtility::getSubArrayHaving($allPosts, 'status', 'publish');
        $recent_posts_published = MainWPUtility::sortmulti($recent_posts_published, 'dts', 'desc');
        $recent_posts_draft = MainWPUtility::getSubArrayHaving($allPosts, 'status', 'draft');
        $recent_posts_draft = MainWPUtility::sortmulti($recent_posts_draft, 'dts', 'desc');
        $recent_posts_pending = MainWPUtility::getSubArrayHaving($allPosts, 'status', 'pending');
        $recent_posts_pending = MainWPUtility::sortmulti($recent_posts_pending, 'dts', 'desc');
        $recent_posts_trash = MainWPUtility::getSubArrayHaving($allPosts, 'status', 'trash');
        $recent_posts_trash = MainWPUtility::sortmulti($recent_posts_trash, 'dts', 'desc');
        ?>
        <div class="clear">
            <a href="<?php 
        echo admin_url('admin.php?page=PostBulkAdd&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_posts_published);
        ?>
)</a><a class="mainwp_action mid recent_posts_draft_lnk" href="#" ><?php 
        _e('Draft', 'mainwp');
        ?>
 (<?php 
        echo count($recent_posts_draft);
        ?>
)</a><a class="mainwp_action mid recent_posts_pending_lnk" href="#"><?php 
        _e('Pending', 'mainwp');
        ?>
 (<?php 
        echo count($recent_posts_pending);
        ?>
)</a><a class="mainwp_action right recent_posts_trash_lnk" href="#"><?php 
        _e('Trash', 'mainwp');
        ?>
 (<?php 
        echo count($recent_posts_trash);
        ?>
)</a><br/><br/>
            <div class="recent_posts_published">
                <?php 
        for ($i = 0; $i < count($recent_posts_published) && $i < 5; $i++) {
            if (!isset($recent_posts_published[$i]['title']) || $recent_posts_published[$i]['title'] == '') {
                $recent_posts_published[$i]['title'] = '(No Title)';
            }
            if (isset($recent_posts_published[$i]['dts'])) {
                if (!stristr($recent_posts_published[$i]['dts'], '-')) {
                    $recent_posts_published[$i]['dts'] = MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($recent_posts_published[$i]['dts']));
                }
            }
            ?>
                <div class="mainwp-row mainwp-recent">
                    <input class="postId" type="hidden" name="id" value="<?php 
            echo $recent_posts_published[$i]['id'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $recent_posts_published[$i]['website']->id;
            ?>
"/>
                    <span class="mainwp-left-col" style="width: 60% !important;  margin-right: 1em;"><a href="<?php 
            echo $recent_posts_published[$i]['website']->url;
            ?>
?p=<?php 
            echo $recent_posts_published[$i]['id'];
            ?>
" target="_blank"><?php 
            echo htmlentities($recent_posts_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_posts_published[$i]['website']->id . '&postid=' . $recent_posts_published[$i]['id']);
            ?>
" title="<?php 
            echo $recent_posts_published[$i]['comment_count'];
            ?>
" class="post-com-count" style="display: inline-block !important;">
                                <span class="comment-count"><?php 
            echo $recent_posts_published[$i]['comment_count'];
            ?>
</span>
                            </a>
                    </span>
                    <span class="mainwp-right-col"><a href="<?php 
            echo $recent_posts_published[$i]['website']->url;
            ?>
" target="_blank"><i class="fa fa-external-link"></i> <?php 
            echo MainWPUtility::getNiceURL($recent_posts_published[$i]['website']->url);
            ?>
</a> <br/><?php 
            echo $recent_posts_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_posts_published[$i]['website']->id;
            ?>
&location=<?php 
            echo base64_encode('post.php?action=editpost&post=' . $recent_posts_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_posts_published[$i]['website']->url . (substr($recent_posts_published[$i]['website']->url, -1) != '/' ? '/' : '') . '?p=' . $recent_posts_published[$i]['id'];
            ?>
" target="_blank" title="View '<?php 
            echo $recent_posts_published[$i]['title'];
            ?>
'" rel="permalink"><?php 
            _e('View', '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>&nbsp;</div>
                    </div>
                </div>
                <?php 
        }
        ?>
            </div>

            <div class="recent_posts_draft" style="display: none">
                <?php 
        for ($i = 0; $i < count($recent_posts_draft) && $i < 5; $i++) {
            if (!isset($recent_posts_draft[$i]['title']) || $recent_posts_draft[$i]['title'] == '') {
                $recent_posts_draft[$i]['title'] = '(No Title)';
            }
            if (isset($recent_posts_draft[$i]['dts'])) {
                if (!stristr($recent_posts_draft[$i]['dts'], '-')) {
                    $recent_posts_draft[$i]['dts'] = MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($recent_posts_draft[$i]['dts']));
                }
            }
            ?>
                <div class="mainwp-row mainwp-recent">
                    <input class="postId" type="hidden" name="id" value="<?php 
            echo $recent_posts_draft[$i]['id'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $recent_posts_draft[$i]['website']->id;
            ?>
"/>
                    <span class="mainwp-left-col" style="width: 60% !important;  margin-right: 1em;"><a href="<?php 
            echo $recent_posts_draft[$i]['website']->url;
            ?>
?p=<?php 
            echo $recent_posts_draft[$i]['id'];
            ?>
" target="_blank"><?php 
            echo htmlentities($recent_posts_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_posts_draft[$i]['website']->id . '&postid=' . $recent_posts_draft[$i]['id']);
            ?>
" title="<?php 
            echo $recent_posts_draft[$i]['comment_count'];
            ?>
" class="post-com-count" style="display: inline-block !important;">
                                <span class="comment-count"><?php 
            echo $recent_posts_draft[$i]['comment_count'];
            ?>
</span>
                            </a>
                    </span>
                    <span class="mainwp-right-col"><?php 
            echo MainWPUtility::getNiceURL($recent_posts_draft[$i]['website']->url);
            ?>
 <br/><?php 
            echo $recent_posts_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_posts_draft[$i]['website']->id;
            ?>
&location=<?php 
            echo base64_encode('post.php?action=editpost&post=' . $recent_posts_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_posts_pending) && $i < 5; $i++) {
            if (!isset($recent_posts_pending[$i]['title']) || $recent_posts_pending[$i]['title'] == '') {
                $recent_posts_pending[$i]['title'] = '(No Title)';
            }
            if (isset($recent_posts_pending[$i]['dts'])) {
                if (!stristr($recent_posts_pending[$i]['dts'], '-')) {
                    $recent_posts_pending[$i]['dts'] = MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($recent_posts_pending[$i]['dts']));
                }
            }
            ?>
                <div class="mainwp-row mainwp-recent">
                    <input class="postId" type="hidden" name="id" value="<?php 
            echo $recent_posts_pending[$i]['id'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $recent_posts_pending[$i]['website']->id;
            ?>
"/>
                    <span class="mainwp-left-col" style="width: 60% !important;  margin-right: 1em;"><a href="<?php 
            echo $recent_posts_pending[$i]['website']->url;
            ?>
?p=<?php 
            echo $recent_posts_pending[$i]['id'];
            ?>
" target="_blank"><?php 
            echo htmlentities($recent_posts_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_posts_pending[$i]['website']->id . '&postid=' . $recent_posts_pending[$i]['id']);
            ?>
" title="<?php 
            echo $recent_posts_pending[$i]['comment_count'];
            ?>
" class="post-com-count" style="display: inline-block !important;">
                                <span class="comment-count"><?php 
            echo $recent_posts_pending[$i]['comment_count'];
            ?>
</span>
                            </a>
                    </span>
                    <span class="mainwp-right-col"><?php 
            echo MainWPUtility::getNiceURL($recent_posts_pending[$i]['website']->url);
            ?>
 <br/><?php 
            echo $recent_posts_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_posts_pending[$i]['website']->id;
            ?>
&location=<?php 
            echo base64_encode('post.php?action=editpost&post=' . $recent_posts_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_posts_trash) && $i < 5; $i++) {
            if (!isset($recent_posts_trash[$i]['title']) || $recent_posts_trash[$i]['title'] == '') {
                $recent_posts_trash[$i]['title'] = '(No Title)';
            }
            if (isset($recent_posts_trash[$i]['dts'])) {
                if (!stristr($recent_posts_trash[$i]['dts'], '-')) {
                    $recent_posts_trash[$i]['dts'] = MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($recent_posts_trash[$i]['dts']));
                }
            }
            ?>
                <div class="mainwp-row mainwp-recent">
                    <input class="postId" type="hidden" name="id" value="<?php 
            echo $recent_posts_trash[$i]['id'];
            ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $recent_posts_trash[$i]['website']->id;
            ?>
"/>
                    <span class="mainwp-left-col" style="width: 60% !important;  margin-right: 1em;"><?php 
            echo htmlentities($recent_posts_trash[$i]['title'], ENT_COMPAT | ENT_HTML401, "UTF-8");
            ?>
</span>
                    <span class="mainwp-mid-col">
                            <a href="<?php 
            echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_posts_trash[$i]['website']->id . '&postid=' . $recent_posts_trash[$i]['id']);
            ?>
" title="<?php 
            echo $recent_posts_trash[$i]['comment_count'];
            ?>
" class="post-com-count" style="display: inline-block !important;">
                                <span class="comment-count"><?php 
            echo $recent_posts_trash[$i]['comment_count'];
            ?>
</span>
                            </a>
                    </span>
                    <span class="mainwp-right-col"><?php 
            echo MainWPUtility::getNiceURL($recent_posts_trash[$i]['website']->url);
            ?>
 <br/><?php 
            echo $recent_posts_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;
        }
    }
Beispiel #4
0
    function update_footer()
    {
        if (!self::isMainWPPages()) {
            return;
        }
        $current_wpid = MainWPUtility::get_current_wpid();
        if ($current_wpid) {
            $website = MainWPDB::Instance()->getWebsiteById($current_wpid);
            $websites = array($website);
        } else {
            $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser(false, null, 'wp_sync.dtsSync DESC, wp.url ASC'));
        }
        ob_start();
        $cntr = 0;
        if (is_array($websites)) {
            for ($i = 0; $i < count($websites); $i++) {
                $website = $websites[$i];
                if ($website->sync_errors == '') {
                    $cntr++;
                    echo '<input type="hidden" name="dashboard_wp_ids[]" class="dashboard_wp_id" value="' . $website->id . '" />';
                }
            }
        } else {
            if ($websites !== false) {
                while ($website = @MainWPDB::fetch_object($websites)) {
                    if ($website->sync_errors == '') {
                        $cntr++;
                        echo '<input type="hidden" name="dashboard_wp_ids[]" class="dashboard_wp_id" value="' . $website->id . '" />';
                    }
                }
            }
        }
        ?>
        <div id="refresh-status-box" title="Syncing Websites" style="display: none; text-align: center">
            <div id="refresh-status-progress"></div>
            <span id="refresh-status-current">0</span> / <span id="refresh-status-total"><?php 
        echo $cntr;
        ?>
</span> <span id="refresh-status-text"><?php 
        _e('synced', 'mainwp');
        ?>
</span>
            <div style="height: 160px; overflow: auto; margin-top: 20px; margin-bottom: 10px; text-align: left" id="refresh-status-content">
                <table style="width: 100%">
                <?php 
        if (is_array($websites)) {
            for ($i = 0; $i < count($websites); $i++) {
                $website = $websites[$i];
                if ($website->sync_errors == '') {
                    echo '<tr><td>' . MainWPUtility::getNiceURL($website->url) . '</td><td style="width: 80px"><span class="refresh-status-wp" niceurl="' . MainWPUtility::getNiceURL($website->url) . '" siteid="' . $website->id . '">PENDING</span></td></tr>';
                } else {
                    echo '<tr class="mainwp_wp_offline"><td>' . MainWPUtility::getNiceURL($website->url) . '</td><td style="width: 80px"><span class="refresh-status-wp" niceurl="' . MainWPUtility::getNiceURL($website->url) . '" siteid="' . $website->id . '">DISCONNECTED</span></td></tr>';
                }
            }
        } else {
            @MainWPDB::data_seek($websites, 0);
            while ($website = @MainWPDB::fetch_object($websites)) {
                if ($website->sync_errors == '') {
                    echo '<tr><td>' . MainWPUtility::getNiceURL($website->url) . '</td><td style="width: 80px"><span class="refresh-status-wp" niceurl="' . MainWPUtility::getNiceURL($website->url) . '" siteid="' . $website->id . '">PENDING</span></td></tr>';
                } else {
                    echo '<tr class="mainwp_wp_offline"><td>' . MainWPUtility::getNiceURL($website->url) . '</td><td style="width: 80px"><span class="refresh-status-wp" niceurl="' . MainWPUtility::getNiceURL($website->url) . '" siteid="' . $website->id . '">DISCONNECTED</span></td></tr>';
                }
            }
        }
        ?>
                </table>
            </div>
            <input id="refresh-status-close" type="button" name="Close" value="Close" class="button" />
        </div>
    <?php 
        if (!self::isHideFooter()) {
            self::sites_fly_menu();
            self::add_new_links();
        }
        $newOutput = ob_get_clean();
        $output = "";
        if (!self::isHideFooter()) {
            $output .= '<a href="javascript:void(0)" id="dashboard_refresh" title="Sync Data" class="mainwp-left-margin-2 mainwp-green"><i class="fa fa-refresh fa-2x"></i></a> <a id="mainwp-add-new-button" class="mainwp-blue mainwp-left-margin-2" title="Add New" href="javascript:void(0)"><i class="fa fa-plus fa-2x"></i></a> <a class="mainwp-red mainwp-left-margin-2" title="Get MainWP Extensions" href="https://extensions.mainwp.com" target="_blank"><i class="fa fa-shopping-cart fa-2x"></i></a> <a class="mainwp-white mainwp-left-margin-2" title="Get Support" href="http://support.mainwp.com" target="_blank"><i class="fa fa-life-ring fa-2x"></i></a>' . '<a href="https://www.facebook.com/mainwp" class="mainwp-link-clean mainwp-left-margin-2" style="color: #3B5998;" target="_blank"><i class="fa fa-facebook-square fa-2x"></i></a> ' . ' <a href="https://twitter.com/mymainwp" class="mainwp-link-clean" target="_blank" style="color: #4099FF;"><i class="fa fa-twitter-square fa-2x"></i></a>.';
        }
        return $output . $newOutput;
    }
 public static function executeBackupTask($task, $nrOfSites = 0, $updateRun = true)
 {
     if ($updateRun) {
         MainWPDB::Instance()->updateBackupRun($task->id);
     }
     $task = MainWPDB::Instance()->getBackupTaskById($task->id);
     $completed_sites = $task->completed_sites;
     if ($completed_sites != '') {
         $completed_sites = json_decode($completed_sites, true);
     }
     if (!is_array($completed_sites)) {
         $completed_sites = array();
     }
     $sites = array();
     if ($task->groups == '') {
         if ($task->sites != '') {
             $sites = explode(',', $task->sites);
         }
     } else {
         $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;
             }
         }
     }
     $errorOutput = null;
     $lastStartNotification = $task->lastStartNotificationSent;
     if ($updateRun && get_option('mainwp_notificationOnBackupStart') == 1 && $lastStartNotification < $task->last_run) {
         $email = MainWPDB::Instance()->getUserNotificationEmail($task->userid);
         if ($email != '') {
             $output = 'A scheduled backup has started with MainWP on ' . MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp(time())) . ' for the following ' . count($sites) . ' sites:<br />';
             foreach ($sites as $siteid) {
                 $website = MainWPDB::Instance()->getWebsiteById($siteid);
                 $output .= '&nbsp;&bull;&nbsp;<a href="' . $website->url . '">' . MainWPUtility::getNiceURL($website->url) . '</a><br />';
             }
             $output .= '<br />Backup Details:<br /><br />';
             $output .= '<strong>Backup Task</strong>' . ' - ' . $task->name . '<br />';
             $output .= '<strong>Backup Type</strong>' . ' - ' . ($task->type == 'db' ? 'DATABASE BACKUP' : 'FULL BACKUP') . '<br />';
             $output .= '<strong>Backup Schedule</strong>' . ' - ' . strtoupper($task->schedule) . '<br />';
             wp_mail($email, 'A Scheduled Backup has been Started - MainWP', MainWPUtility::formatEmail($email, $output), 'content-type: text/html');
             MainWPDB::Instance()->updateBackupTaskWithValues($task->id, array('lastStartNotificationSent' => time()));
         }
     }
     $currentCount = 0;
     foreach ($sites as $siteid) {
         if (isset($completed_sites[$siteid]) && $completed_sites[$siteid] == true) {
             continue;
         }
         $website = MainWPDB::Instance()->getWebsiteById($siteid);
         try {
             $subfolder = str_replace('%task%', MainWPUtility::sanitize($task->name), $task->subfolder);
             $backupResult = MainWPManageSites::backupSite($siteid, $task, $subfolder);
             //When we receive a timeout, we return false..
             if ($backupResult === false) {
                 continue;
             }
             if ($errorOutput == null) {
                 $errorOutput = '';
             }
             $error = false;
             $tmpErrorOutput = '';
             if (isset($backupResult['error'])) {
                 $tmpErrorOutput .= $backupResult['error'] . '<br />';
                 $error = true;
             }
             if (isset($backupResult['ftp']) && $backupResult['ftp'] != 'success') {
                 $tmpErrorOutput .= 'FTP: ' . $backupResult['ftp'] . '<br />';
                 $error = true;
             }
             if (isset($backupResult['dropbox']) && $backupResult['dropbox'] != 'success') {
                 $tmpErrorOutput .= 'Dropbox: ' . $backupResult['dropbox'] . '<br />';
                 $error = true;
             }
             if (isset($backupResult['amazon']) && $backupResult['amazon'] != 'success') {
                 $tmpErrorOutput .= 'Amazon: ' . $backupResult['amazon'] . '<br />';
                 $error = true;
             }
             if ($error) {
                 $errorOutput .= 'Site: <strong>' . MainWPUtility::getNiceURL($website->url) . '</strong><br />';
                 $errorOutput .= $tmpErrorOutput . '<br />';
             }
         } catch (Exception $e) {
             if ($errorOutput == null) {
                 $errorOutput = '';
             }
             $errorOutput .= 'Site: <strong>' . MainWPUtility::getNiceURL($website->url) . '</strong><br />';
             $errorOutput .= MainWPErrorHelper::getErrorMessage($e) . '<br />';
             $_error_output = MainWPErrorHelper::getErrorMessage($e);
         }
         $_backup_result = isset($backupResult) ? $backupResult : (isset($_error_output) ? $_error_output : "");
         do_action('mainwp_managesite_schedule_backup', $website, array('type' => $task->type), $_backup_result);
         $currentCount++;
         $task = MainWPDB::Instance()->getBackupTaskById($task->id);
         $completed_sites = $task->completed_sites;
         if ($completed_sites != '') {
             $completed_sites = json_decode($completed_sites, true);
         }
         if (!is_array($completed_sites)) {
             $completed_sites = array();
         }
         $completed_sites[$siteid] = true;
         MainWPDB::Instance()->updateCompletedSites($task->id, $completed_sites);
         if ($nrOfSites != 0 && $nrOfSites <= $currentCount) {
             break;
         }
     }
     //update completed sites
     if ($errorOutput != null) {
         MainWPDB::Instance()->updateBackupErrors($task->id, $errorOutput);
     }
     if (count($completed_sites) == count($sites)) {
         MainWPDB::Instance()->updateBackupCompleted($task->id);
         if (get_option('mainwp_notificationOnBackupFail') == 1) {
             $email = MainWPDB::Instance()->getUserNotificationEmail($task->userid);
             if ($email != '') {
                 $task = MainWPDB::Instance()->getBackupTaskById($task->id);
                 if ($task->backup_errors != '') {
                     $errorOutput = 'Errors occurred while executing task: <strong>' . $task->name . '</strong><br /><br />' . $task->backup_errors;
                     wp_mail($email, 'A Scheduled Backup had an Error - MainWP', MainWPUtility::formatEmail($email, $errorOutput), 'content-type: text/html');
                     MainWPDB::Instance()->updateBackupErrors($task->id, '');
                 }
             }
         }
     }
     return $errorOutput == '';
 }
 public static function backup($pSiteId, $pType, $pSubfolder, $pExclude, $excludebackup, $excludecache, $excludenonwp, $excludezip, $pFilename = null, $pFileNameUID = '', $pArchiveFormat = false, $pMaximumFileDescriptorsOverride = false, $pMaximumFileDescriptorsAuto = false, $pMaximumFileDescriptors = false, $pLoadFilesBeforeZip = false, $pid = false, $append = false)
 {
     if (trim($pFilename) == '') {
         $pFilename = null;
     }
     $backup_result = array();
     //Creating a backup
     $website = MainWPDB::Instance()->getWebsiteById($pSiteId);
     $subfolder = str_replace('%sitename%', MainWPUtility::sanitize($website->name), $pSubfolder);
     $subfolder = str_replace('%url%', MainWPUtility::sanitize(MainWPUtility::getNiceURL($website->url)), $subfolder);
     $subfolder = str_replace('%type%', $pType, $subfolder);
     $subfolder = str_replace('%date%', MainWPUtility::date('Ymd'), $subfolder);
     $subfolder = str_replace('%task%', '', $subfolder);
     $subfolder = str_replace('%', '', $subfolder);
     $subfolder = MainWPUtility::removePreSlashSpaces($subfolder);
     $subfolder = MainWPUtility::normalize_filename($subfolder);
     if (!MainWPUtility::can_edit_website($website)) {
         throw new MainWPException('You are not allowed to backup this site');
     }
     $websiteCleanUrl = $website->url;
     if (substr($websiteCleanUrl, -1) == '/') {
         $websiteCleanUrl = substr($websiteCleanUrl, 0, -1);
     }
     $websiteCleanUrl = str_replace(array('http://', 'https://', '/'), array('', '', '-'), $websiteCleanUrl);
     //Normal flow: use website & fallback to global
     if ($pMaximumFileDescriptorsOverride == false) {
         if ($website->maximumFileDescriptorsOverride == 1) {
             $maximumFileDescriptorsAuto = $website->maximumFileDescriptorsAuto == 1;
             $maximumFileDescriptors = $website->maximumFileDescriptors;
         } else {
             $maximumFileDescriptorsAuto = get_option('mainwp_maximumFileDescriptorsAuto');
             $maximumFileDescriptors = get_option('mainwp_maximumFileDescriptors');
             $maximumFileDescriptors = $maximumFileDescriptors === false ? 150 : $maximumFileDescriptors;
         }
     } else {
         if ($pArchiveFormat != 'global' && $pMaximumFileDescriptorsOverride == 1) {
             $maximumFileDescriptorsAuto = $pMaximumFileDescriptorsAuto == 1;
             $maximumFileDescriptors = $pMaximumFileDescriptors;
         } else {
             $maximumFileDescriptorsAuto = get_option('mainwp_maximumFileDescriptorsAuto');
             $maximumFileDescriptors = get_option('mainwp_maximumFileDescriptors');
             $maximumFileDescriptors = $maximumFileDescriptors === false ? 150 : $maximumFileDescriptors;
         }
     }
     $file = str_replace(array('%sitename%', '%url%', '%date%', '%time%', '%type%'), array(MainWPUtility::sanitize($website->name), $websiteCleanUrl, MainWPUtility::date('m-d-Y'), MainWPUtility::date('G\\hi\\ms\\s'), $pType), $pFilename);
     $file = str_replace('%', '', $file);
     $file = MainWPUtility::normalize_filename($file);
     //Normal flow: check site settings & fallback to global
     if ($pLoadFilesBeforeZip == false) {
         $loadFilesBeforeZip = $website->loadFilesBeforeZip;
         if ($loadFilesBeforeZip == 1) {
             $loadFilesBeforeZip = get_option('mainwp_options_loadFilesBeforeZip');
             $loadFilesBeforeZip = $loadFilesBeforeZip == 1 || $loadFilesBeforeZip === false;
         } else {
             $loadFilesBeforeZip = $loadFilesBeforeZip == 2;
         }
     } else {
         if ($pArchiveFormat == 'global' || $pLoadFilesBeforeZip == 1) {
             $loadFilesBeforeZip = get_option('mainwp_options_loadFilesBeforeZip');
             $loadFilesBeforeZip = $loadFilesBeforeZip == 1 || $loadFilesBeforeZip === false;
         } else {
             $loadFilesBeforeZip = $pLoadFilesBeforeZip == 2;
         }
     }
     //Nomral flow: check site settings & fallback to global
     if ($pArchiveFormat == false) {
         $archiveFormat = MainWPUtility::getCurrentArchiveExtension($website);
     } else {
         if ($pArchiveFormat == 'global') {
             $archiveFormat = MainWPUtility::getCurrentArchiveExtension();
         } else {
             $archiveFormat = $pArchiveFormat;
         }
     }
     MainWPUtility::endSession();
     $information = MainWPUtility::fetchUrlAuthed($website, 'backup', array('type' => $pType, 'exclude' => $pExclude, 'excludebackup' => $excludebackup, 'excludecache' => $excludecache, 'excludenonwp' => $excludenonwp, 'excludezip' => $excludezip, 'ext' => $archiveFormat, 'file_descriptors_auto' => $maximumFileDescriptorsAuto, 'file_descriptors' => $maximumFileDescriptors, 'loadFilesBeforeZip' => $loadFilesBeforeZip, MainWPUtility::getFileParameter($website) => $file, 'fileUID' => $pFileNameUID, 'pid' => $pid, 'append' => $append ? 1 : 0), false, false, false);
     do_action('mainwp_managesite_backup', $website, array('type' => $pType), $information);
     if (isset($information['error'])) {
         throw new MainWPException($information['error']);
     } else {
         if ($pType == 'db' && !$information['db']) {
             throw new MainWPException('Database backup failed.');
         } else {
             if ($pType == 'full' && !$information['full']) {
                 throw new MainWPException('Full backup failed.');
             } else {
                 if (isset($information['db'])) {
                     if ($information['db'] != false) {
                         $backup_result['url'] = $information['db'];
                         $backup_result['type'] = 'db';
                     } else {
                         if ($information['full'] != false) {
                             $backup_result['url'] = $information['full'];
                             $backup_result['type'] = 'full';
                         }
                     }
                     if (isset($information['size'])) {
                         $backup_result['size'] = $information['size'];
                     }
                     $backup_result['subfolder'] = $subfolder;
                     $dir = MainWPUtility::getMainWPSpecificDir($pSiteId);
                     $fm_date = MainWPUtility::sanitize_file_name(MainWPUtility::date(get_option('date_format')));
                     $fm_time = MainWPUtility::sanitize_file_name(MainWPUtility::date(get_option('time_format')));
                     if ($pType == 'db') {
                         $localBackupFile = $dir . 'db-' . $websiteCleanUrl . '-' . $fm_date . '-' . $fm_time . MainWPUtility::getRealExtension($information['db']);
                         $localRegexFile = 'db-' . $websiteCleanUrl . '-(.*)-(.*).sql(\\.zip|\\.tar|\\.tar\\.gz|\\.tar\\.bz2)?';
                     } else {
                         $localBackupFile = $dir . 'full-' . $websiteCleanUrl . '-' . $fm_date . '-' . $fm_time . MainWPUtility::getRealExtension($information['full']);
                         $localRegexFile = 'full-' . $websiteCleanUrl . '-(.*)-(.*).(zip|tar|tar.gz|tar.bz2)';
                     }
                     if ($pFilename != null) {
                         $filename = str_replace(array('%sitename%', '%url%', '%date%', '%time%', '%type%'), array(MainWPUtility::sanitize($website->name), $websiteCleanUrl, $fm_date, $fm_time, $pType), $pFilename);
                         $filename = str_replace('%', '', $filename);
                         $localBackupFile = $dir . $filename;
                         $localBackupFile = MainWPUtility::normalize_filename($localBackupFile);
                         if ($pType == 'db') {
                             $localBackupFile .= MainWPUtility::getRealExtension($information['db']);
                         } else {
                             $localBackupFile .= MainWPUtility::getRealExtension($information['full']);
                         }
                     }
                     $backup_result['local'] = $localBackupFile;
                     $backup_result['regexfile'] = $localRegexFile;
                     return $backup_result;
                 } else {
                     throw new MainWPException('Database backup failed due to an undefined error');
                 }
             }
         }
     }
 }
Beispiel #7
0
    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 
    }
Beispiel #8
0
    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 
    }
 public static function hookGetSites($pluginFile, $key, $websiteid, $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($websiteid) && $websiteid != null) {
         $website = MainWPDB::Instance()->getWebsiteById($websiteid);
         if (!MainWPUtility::can_edit_website($website)) {
             return false;
         }
         if (!mainwp_current_user_can("site", $websiteid)) {
             return false;
         }
         return array(array('id' => $websiteid, 'url' => MainWPUtility::getNiceURL($website->url, true), 'name' => $website->name, 'totalsize' => $website->totalsize));
     }
     $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser(false, null, 'wp.url', false, false, null, $for_manager));
     $output = array();
     while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
         $output[] = array('id' => $website->id, 'url' => MainWPUtility::getNiceURL($website->url, true), 'name' => $website->name, 'totalsize' => $website->totalsize);
     }
     @MainWPDB::free_result($websites);
     return $output;
 }
Beispiel #10
0
    public static function renderAllThemesTable($output = null)
    {
        $keyword = null;
        $search_status = 'all';
        if ($output == null) {
            $keyword = isset($_POST['keyword']) && !empty($_POST['keyword']) ? trim($_POST["keyword"]) : null;
            $search_status = isset($_POST['status']) ? $_POST['status'] : "all";
            $search_theme_status = isset($_POST['theme_status']) ? $_POST['theme_status'] : "all";
            $output = new stdClass();
            $output->errors = array();
            $output->themes = array();
            if (get_option('mainwp_optimize') == 1) {
                //Fetch all!
                //Build websites array
                //Search in local cache
                $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser());
                while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                    $allThemes = json_decode($website->themes, true);
                    for ($i = 0; $i < count($allThemes); $i++) {
                        $theme = $allThemes[$i];
                        if ($search_theme_status != "all") {
                            if ($theme['active'] == 1 && $search_theme_status !== "active") {
                                continue;
                            } else {
                                if ($theme['active'] != 1 && $search_theme_status !== "inactive") {
                                    continue;
                                }
                            }
                        }
                        if ($keyword != '' && stristr($theme['name'], $keyword) === false) {
                            continue;
                        }
                        $theme['websiteid'] = $website->id;
                        $theme['websiteurl'] = $website->url;
                        $output->themes[] = $theme;
                    }
                }
                @MainWPDB::free_result($websites);
            } else {
                //Fetch all!
                //Build websites array
                $dbwebsites = array();
                $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser());
                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);
                $post_data = array('keyword' => $keyword);
                if ($search_theme_status == "active" || $search_theme_status == "inactive") {
                    $post_data['status'] = $search_theme_status;
                    $post_data['filter'] = true;
                } else {
                    $post_data['status'] = "";
                    $post_data['filter'] = false;
                }
                MainWPUtility::fetchUrlsAuthed($dbwebsites, 'get_all_themes', $post_data, array(MainWPThemes::getClassName(), 'ThemesSearch_handler'), $output);
                if (count($output->errors) > 0) {
                    foreach ($output->errors as $siteid => $error) {
                        echo '<strong>Error on ' . MainWPUtility::getNiceURL($dbwebsites[$siteid]->url) . ': ' . $error . ' <br /></strong>';
                    }
                    echo '<br />';
                }
                if (count($output->errors) == count($dbwebsites)) {
                    session_start();
                    $_SESSION['SNThemesAll'] = $output;
                    return;
                }
            }
            if (session_id() == '') {
                session_start();
            }
            $_SESSION['SNThemesAll'] = $output;
            $_SESSION['SNThemesAllStatus'] = array('keyword' => $keyword, 'status' => $search_status, 'theme_status' => $search_theme_status);
        } else {
            if (isset($_SESSION['SNThemesAllStatus'])) {
                $keyword = $_SESSION['SNThemesAllStatus']['keyword'];
                $search_status = $_SESSION['SNThemesAllStatus']['status'];
                $search_theme_status = $_SESSION['SNThemesAllStatus']['theme_status'];
            }
        }
        if (count($output->themes) == 0) {
            ?>
        No themes found
        <?php 
            return;
        }
        ?>
    <div class="alignleft">
        <select name="bulk_action" id="mainwp_bulk_action">
            <option value="none"><?php 
        _e('Choose Action', 'mainwp');
        ?>
</option>
            <option value="trust"><?php 
        _e('Trust', 'mainwp');
        ?>
</option>
            <option value="untrust"><?php 
        _e('Untrust', 'mainwp');
        ?>
</option>
        </select> <input type="button" name="" id="mainwp_bulk_trust_themes_action_apply" class="button" value="<?php 
        _e('Confirm', 'mainwp');
        ?>
"/> <span id="mainwp_bulk_action_loading"><i class="fa fa-spinner fa-pulse"></i></span>
    </div>
    <div class="clear"></div>
    <?php 
        //Map per siteId
        $themes = array();
        //name_version -> slug
        foreach ($output->themes as $theme) {
            $themes[$theme['slug']] = $theme;
        }
        asort($themes);
        $userExtension = MainWPDB::Instance()->getUserExtension();
        $decodedIgnoredThemes = json_decode($userExtension->ignored_themes, true);
        $trustedThemes = json_decode($userExtension->trusted_themes, true);
        if (!is_array($trustedThemes)) {
            $trustedThemes = array();
        }
        $trustedThemesNotes = json_decode($userExtension->trusted_themes_notes, true);
        if (!is_array($trustedThemesNotes)) {
            $trustedThemesNotes = array();
        }
        ?>
        <table id="mainwp_themes_all_table" class="wp-list-table widefat fixed posts tablesorter" cellspacing="0">
            <thead>
            <tr>
                <th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input name="themes" type="checkbox"></th>
                <th scope="col" id="info" class="manage-column column-cb check-column" style=""></th>
                <th scope="col" id="theme" class="manage-column column-title sortable desc" style="">
                    <a href="#"><span><?php 
        _e('Theme', 'mainwp');
        ?>
</span><span class="sorting-indicator"></span></a>
                </th>
                 <th scope="col" id="thmstatus" class="manage-column column-title sortable desc" style="">
                    <a href="#"><span><?php 
        _e('Status', 'mainwp');
        ?>
</span><span class="sorting-indicator"></span></a>
                </th>
                <th scope="col" id="trustlvl" class="manage-column column-title sortable desc" style="">
                    <a href="#"><span><?php 
        _e('Trust Level', 'mainwp');
        ?>
</span><span class="sorting-indicator"></span></a>
                </th>
                <th scope="col" id="ignoredstatus" class="manage-column column-title sortable desc" style="">
                    <a href="#"><span><?php 
        _e('Ignored Status', 'mainwp');
        ?>
</span><span class="sorting-indicator"></span></a>
                </th>
                <th scope="col" id="notes" class="manage-column column-posts" style=""><?php 
        _e('Notes', 'mainwp');
        ?>
</th>
            </tr>
            </thead>

            <tfoot>
            <tr>
                <th scope="col" class="manage-column column-cb check-column" style=""><input name="themes" type="checkbox"></th>
                <th scope="col" id="info_footer" class="manage-column column-cb check-column" style=""></th>
                <th scope="col" id="theme_footer" class="manage-column column-title sortable desc" style=""><span><?php 
        _e('Theme', 'mainwp');
        ?>
</span></th>
                <th scope="col" id="thmstatus_footer" class="manage-column column-posts" style=""><?php 
        _e('Status', 'mainwp');
        ?>
</th>
                <th scope="col" id="trustlvl_footer" class="manage-column column-posts" style=""><?php 
        _e('Trust Level', 'mainwp');
        ?>
</th>
                <th scope="col" id="ignoredstatus_footer" class="manage-column column-posts" style=""><?php 
        _e('Ignored Status', 'mainwp');
        ?>
</th>
                <th scope="col" id="notes_footer" class="manage-column column-posts" style=""><?php 
        _e('Notes', 'mainwp');
        ?>
</th>
            </tr>
            </tfoot>

            <tbody id="the-posts-list" class="list:posts">
                <?php 
        foreach ($themes as $slug => $theme) {
            $name = $theme['name'];
            if (!empty($search_status) && $search_status != "all") {
                if ($search_status == "trust" && !in_array($slug, $trustedThemes)) {
                    continue;
                } else {
                    if ($search_status == "untrust" && in_array($slug, $trustedThemes)) {
                        continue;
                    } else {
                        if ($search_status == "ignored" && !isset($decodedIgnoredThemes[$slug])) {
                            continue;
                        }
                    }
                }
            }
            ?>
                    <tr id="post-1" class="post-1 post type-post status-publish format-standard hentry category-uncategorized alternate iedit author-self" valign="top" theme_slug="<?php 
            echo urlencode($slug);
            ?>
" theme_name="<?php 
            echo rawurlencode($name);
            ?>
">
                        <th scope="row" class="check-column"><input type="checkbox" name="theme[]" value="<?php 
            echo urlencode($slug);
            ?>
"></th>
                        <td scope="col" id="info_content" class="manage-column" style=""> <?php 
            if (isset($decodedIgnoredThemes[$slug])) {
                MainWPUtility::renderToolTip('Ignored themes will NOT be auto-updated.', null, 'images/icons/mainwp-red-info-16.png');
            }
            ?>
</td>
                        <td scope="col" id="theme_content" class="manage-column sorted" style="">
                            <?php 
            echo $name;
            ?>
                        </td>
                        <td scope="col" id="plgstatus_content" class="manage-column" style="">
                            <?php 
            echo $theme['active'] == 1 ? __("Active", "mainwp") : __("Inactive", "mainwp");
            ?>
                        </td>
                        <td scope="col" id="trustlvl_content" class="manage-column" style="">
                            <?php 
            if (in_array($slug, $trustedThemes)) {
                echo '<font color="#7fb100">Trusted</font>';
            } else {
                echo '<font color="#c00">Not Trusted</font>';
            }
            ?>
                        </td>
                        <td scope="col" id="ignoredstatus_content" class="manage-column" style="">
                            <?php 
            if (isset($decodedIgnoredThemes[$slug])) {
                echo '<font color="#c00">Ignored</font>';
            }
            ?>
                        </td>
                        <td scope="col" id="notes_content" class="manage-column" style="">
                            <img src="<?php 
            echo plugins_url('images/notes.png', dirname(__FILE__));
            ?>
" class="mainwp_notes_img" <?php 
            if (!isset($trustedThemesNotes[$slug]) || $trustedThemesNotes[$slug] == '') {
                echo 'style="display: none;"';
            }
            ?>
 />
                            <a href="#" class="mainwp_trusted_theme_notes_show"><i class="fa fa-pencil"></i> <?php 
            _e('Open', 'mainwp');
            ?>
</a>
                            <div style="display: none" class="note"><?php 
            if (isset($trustedThemesNotes[$slug])) {
                echo $trustedThemesNotes[$slug];
            }
            ?>
</div>
                        </td>
                    </tr>
                            <?php 
        }
        ?>
            </tbody>
        </table>
        <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"></span>
            </div>
            <div id="mainwp_notes_content">
                <textarea style="width: 580px !important; height: 300px;"
                          id="mainwp_notes_note"></textarea>
            </div>
            <form>
                <div style="float: right" id="mainwp_notes_status"></div>
                <input type="button" class="button cont button-primary" id="mainwp_trusted_theme_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_slug" value=""/>
            </form>
        </div>
        <div class="pager" id="pager">
            <form>
                <img src="<?php 
        echo plugins_url('images/first.png', dirname(__FILE__));
        ?>
" class="first">
                <img src="<?php 
        echo plugins_url('images/prev.png', dirname(__FILE__));
        ?>
" class="prev">
                <input type="text" class="pagedisplay">
                <img src="<?php 
        echo plugins_url('images/next.png', dirname(__FILE__));
        ?>
" class="next">
                <img src="<?php 
        echo plugins_url('images/last.png', dirname(__FILE__));
        ?>
" class="last">
                <span>&nbsp;&nbsp;<?php 
        _e('Show:', 'mainwp');
        ?>
 </span><select class="pagesize">
                    <option selected="selected" value="10">10</option>
                    <option value="20">20</option>
                    <option value="30">30</option>
                    <option value="40">40</option>
                </select><span> <?php 
        _e('Plugins per page', 'mainwp');
        ?>
</span>
            </form>
        </div>

        <?php 
    }
Beispiel #11
0
    public static function renderTable($keyword, $status, $groups, $sites)
    {
        MainWPCache::initCache('Plugins');
        $output = new stdClass();
        $output->errors = array();
        $output->plugins = array();
        if (get_option('mainwp_optimize') == 1) {
            if ($sites != '') {
                foreach ($sites as $k => $v) {
                    if (MainWPUtility::ctype_digit($v)) {
                        $website = MainWPDB::Instance()->getWebsiteById($v);
                        $allPlugins = json_decode($website->plugins, true);
                        for ($i = 0; $i < count($allPlugins); $i++) {
                            $plugin = $allPlugins[$i];
                            if ($status == "active" || $status == "inactive") {
                                if ($plugin['active'] != ($status == 'active' ? 1 : 0)) {
                                    continue;
                                }
                            }
                            if ($keyword != '' && !stristr($plugin['name'], $keyword)) {
                                continue;
                            }
                            $plugin['websiteid'] = $website->id;
                            $plugin['websiteurl'] = $website->url;
                            $output->plugins[] = $plugin;
                        }
                    }
                }
            }
            if ($groups != '') {
                //Search in local cache
                foreach ($groups as $k => $v) {
                    if (MainWPUtility::ctype_digit($v)) {
                        $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupId($v));
                        while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                            if ($website->sync_errors != '') {
                                continue;
                            }
                            $allPlugins = json_decode($website->plugins, true);
                            for ($i = 0; $i < count($allPlugins); $i++) {
                                $plugin = $allPlugins[$i];
                                if ($status == "active" || $status == "inactive") {
                                    if ($plugin['active'] != ($status == 'active' ? 1 : 0)) {
                                        continue;
                                    }
                                }
                                if ($keyword != '' && !stristr($plugin['name'], $keyword)) {
                                    continue;
                                }
                                $plugin['websiteid'] = $website->id;
                                $plugin['websiteurl'] = $website->url;
                                $output->plugins[] = $plugin;
                            }
                        }
                        @MainWPDB::free_result($websites);
                    }
                }
            }
        } else {
            //Fetch all!
            //Build websites array
            $dbwebsites = array();
            if ($sites != '') {
                foreach ($sites as $k => $v) {
                    if (MainWPUtility::ctype_digit($v)) {
                        $website = MainWPDB::Instance()->getWebsiteById($v);
                        $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                    }
                }
            }
            if ($groups != '') {
                foreach ($groups as $k => $v) {
                    if (MainWPUtility::ctype_digit($v)) {
                        $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupId($v));
                        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);
                    }
                }
            }
            $post_data = array('keyword' => $keyword);
            if ($status == "active" || $status == "inactive") {
                $post_data['status'] = $status;
                $post_data['filter'] = true;
            } else {
                $post_data['status'] = "";
                $post_data['filter'] = false;
            }
            MainWPUtility::fetchUrlsAuthed($dbwebsites, 'get_all_plugins', $post_data, array(MainWPPlugins::getClassName(), 'PluginsSearch_handler'), $output);
            if (count($output->errors) > 0) {
                foreach ($output->errors as $siteid => $error) {
                    echo '<strong>Error on ' . MainWPUtility::getNiceURL($dbwebsites[$siteid]->url) . ': ' . $error . ' <br /></strong>';
                }
                echo '<br />';
            }
            if (count($output->errors) == count($dbwebsites)) {
                return;
            }
        }
        MainWPCache::addContext('Plugins', array('keyword' => $keyword, 'the_status' => $status));
        ob_start();
        ?>
    <div class="alignleft">
        <select name="bulk_action" id="mainwp_bulk_action">
            <option value="none"><?php 
        _e('Choose Action', 'mainwp');
        ?>
</option>
            <?php 
        if (mainwp_current_user_can("dashboard", "activate_deactivate_plugins")) {
            ?>
            <?php 
            if ($status == 'active') {
                ?>
            <option value="deactivate"><?php 
                _e('Deactivate', 'mainwp');
                ?>
</option>
            <?php 
            }
            ?>
            <?php 
        }
        ?>
            <?php 
        if ($status == 'inactive') {
            ?>
            <?php 
            if (mainwp_current_user_can("dashboard", "activate_deactivate_plugins")) {
                ?>
            <option value="activate"><?php 
                _e('Activate', 'mainwp');
                ?>
</option>
            <?php 
            }
            ?>
            <?php 
            if (mainwp_current_user_can("dashboard", "delete_plugins")) {
                ?>
            <option value="delete"><?php 
                _e('Delete', 'mainwp');
                ?>
</option>            
            <?php 
            }
            ?>
            <?php 
        }
        ?>
  
            <?php 
        if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) {
            ?>
   
            <option value="ignore_updates"><?php 
            _e('Ignore Updates', 'mainwp');
            ?>
</option>    
            <?php 
        }
        ?>
  
        </select> <input type="button" name="" id="mainwp_bulk_plugins_action_apply" class="button" value="<?php 
        _e('Confirm', 'mainwp');
        ?>
"/> <span id="mainwp_bulk_action_loading"><i class="fa fa-spinner fa-pulse"></i></span>&nbsp;<span><a href="http://docs.mainwp.com/why-does-the-mainwp-client-plugin-not-show-up-on-the-plugin-list-for-my-managed-site/" target="_blank"><?php 
        _e('Why does the MainWP Child Plugin NOT show here?', 'mainwp');
        ?>
</a></span>
    </div>
    <div class="clear"></div>


    <?php 
        if (count($output->plugins) == 0) {
            ?>
        No plugins found
        <?php 
            $newOutput = ob_get_clean();
            echo $newOutput;
            MainWPCache::addBody('Plugins', $newOutput);
            return;
        }
        //Map per siteId
        $sites = array();
        //id -> url
        $sitePlugins = array();
        //site_id -> plugin_version_name -> plugin obj
        $plugins = array();
        //name_version -> slug
        $pluginsVersion = $pluginsName = array();
        //name_version -> title_version
        foreach ($output->plugins as $plugin) {
            $sites[$plugin['websiteid']] = $plugin['websiteurl'];
            $plugins[$plugin['name'] . '_' . $plugin['version']] = $plugin['slug'];
            $pluginsName[$plugin['name'] . '_' . $plugin['version']] = $plugin['name'];
            $pluginsVersion[$plugin['name'] . '_' . $plugin['version']] = $plugin['name'] . ' ' . $plugin['version'];
            if (!isset($sitePlugins[$plugin['websiteid']]) || !is_array($sitePlugins[$plugin['websiteid']])) {
                $sitePlugins[$plugin['websiteid']] = array();
            }
            $sitePlugins[$plugin['websiteid']][$plugin['name'] . '_' . $plugin['version']] = $plugin;
        }
        ?>
<div id="mainwp-table-overflow" style="overflow: auto !important ;">
    <table class="ui-tinytable wp-list-table widefat fixed pages" style="width: auto; word-wrap: normal">
        <thead>
        <tr>
            <th class="headcol"></th>
            <?php 
        foreach ($pluginsVersion as $plugin_name => $plugin_title) {
            echo '<th style="height: 100px; padding: 5px ;" class="long">
<p style="font-family: Arial, Sans-Serif; text-shadow: none ; width: 100px !important; height: 30px ; text-align: center; width: auto; height: auto; font-size: 13px; -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); -o-transform: rotate(-90deg); -ms-transform: rotate(-90deg); writing-mode: lr-tb; ">
<input type="checkbox" value="' . $plugins[$plugin_name] . '" id="' . $plugin_name . '" class="mainwp_plugin_check_all" style="margin: 3px 0px 0px 0px; display: none ; " />
<label for="' . $plugin_name . '">' . $plugin_title . '</label>
</p>
</th>';
        }
        ?>
        </tr>
        </thead>
        <tbody>
            <?php 
        foreach ($sites as $site_id => $site_url) {
            ?>
            <tr>
                <td class="headcol">
                    <input class="websiteId" type="hidden" name="id" value="<?php 
            echo $site_id;
            ?>
"/>
                    <label for="<?php 
            echo $site_url;
            ?>
"><strong><?php 
            echo $site_url;
            ?>
</strong></label>
                    &nbsp;&nbsp;<input type="checkbox" value="" id="<?php 
            echo $site_url;
            ?>
"
                                       class="mainwp_site_check_all" style="display: none ;"/>
                </td>
                <?php 
            foreach ($pluginsVersion as $plugin_name => $plugin_title) {
                echo '<td class="long" style="text-align: center">';
                if (isset($sitePlugins[$site_id]) && isset($sitePlugins[$site_id][$plugin_name])) {
                    echo '<input type="checkbox" value="' . $plugins[$plugin_name] . '" name="' . $pluginsName[$plugin_name] . '" class="selected_plugin" />';
                }
                echo '</td>';
            }
            ?>
            </tr>
                <?php 
        }
        ?>
        </tbody>
    </table>
</div>
        <?php 
        $newOutput = ob_get_clean();
        echo $newOutput;
        MainWPCache::addBody('Plugins', $newOutput);
    }