Exemplo n.º 1
0
    public static function PagesSearch_handler($data, $website, &$output)
    {
        if (preg_match('/<mainwp>(.*)<\\/mainwp>/', $data, $results) > 0) {
            $pages = unserialize(base64_decode($results[1]));
            unset($results);
            foreach ($pages as $page) {
                if (isset($page['dts'])) {
                    if (!stristr($page['dts'], '-')) {
                        $page['dts'] = MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($page['dts']));
                    }
                }
                if (!isset($page['title']) || $page['title'] == '') {
                    $page['title'] = '(No Title)';
                }
                ob_start();
                ?>
            <tr id="page-1"
                class="page-1 page type-page status-publish format-standard hentry category-uncategorized alternate iedit author-self"
                valign="top">
                <th scope="row" class="check-column"><input type="checkbox" name="page[]" value="1"></th>
                <td class="page-title page-title column-title">
                    <input class="pageId" type="hidden" name="id" value="<?php 
                echo $page['id'];
                ?>
"/>
                    <input class="allowedBulkActions" type="hidden" name="allowedBulkActions" value="|trash|delete|<?php 
                if ($page['status'] == 'trash') {
                    echo 'restore|';
                }
                ?>
"/>
                    <input class="websiteId" type="hidden" name="id" value="<?php 
                echo $website->id;
                ?>
"/>

                    <strong>
                        <abbr title="<?php 
                echo $page['title'];
                ?>
">
                        <?php 
                if ($page['status'] != 'trash') {
                    ?>
                        <a class="row-title"
                           href="admin.php?page=SiteOpen&websiteid=<?php 
                    echo $website->id;
                    ?>
&location=<?php 
                    echo base64_encode('post.php?post=' . $page['id'] . '&action=edit');
                    ?>
"
                           title="Edit '<?php 
                    echo $page['title'];
                    ?>
'?"><?php 
                    echo $page['title'];
                    ?>
</a>
                        <?php 
                } else {
                    ?>
                        <?php 
                    echo $page['title'];
                    ?>
                        <?php 
                }
                ?>
                        </abbr>
                    </strong>

                    <div class="row-actions">
                        <?php 
                if ($page['status'] != 'trash') {
                    ?>
                        <span class="edit"><a
                                href="admin.php?page=SiteOpen&websiteid=<?php 
                    echo $website->id;
                    ?>
&location=<?php 
                    echo base64_encode('post.php?post=' . $page['id'] . '&action=edit');
                    ?>
"
                                title="Edit this item"><?php 
                    _e('Edit', 'mainwp');
                    ?>
</a></span>
                        <span class="trash">
                            | <a class="page_submitdelete" title="Move this item to the Trash" href="#"><?php 
                    _e('Trash', 'mainwp');
                    ?>
</a>
                    </span>
                        <?php 
                }
                ?>

                        <?php 
                if ($page['status'] == 'publish') {
                    ?>
                        <span class="view">
                            | <a
                                href="<?php 
                    echo $website->url . (substr($website->url, -1) != '/' ? '/' : '') . '?p=' . $page['id'];
                    ?>
"
                                target="_blank" title="View '<?php 
                    echo $page['title'];
                    ?>
'?" rel="permalink"><?php 
                    _e('View', 'mainwp');
                    ?>
</a></span>
                        <?php 
                }
                ?>
                        <?php 
                if ($page['status'] == 'trash') {
                    ?>
                        <span class="restore">
                           <a class="page_submitrestore" title="Restore this item" href="#"><?php 
                    _e('Restore', 'mainwp');
                    ?>
</a>
                        </span>
                        <span class="trash">
                            | <a class="page_submitdelete_perm" title="Delete this item permanently" href="#"><?php 
                    _e('Delete
                            Permanently', 'mainwp');
                    ?>
</a>
                        </span>
                        <?php 
                }
                ?>
                    </div>
                    <div class="row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
                _e('Please wait', 'mainwp');
                ?>
                    </div>
                </td>
                <td class="author column-author">
                    <?php 
                echo $page['author'];
                ?>
                </td>
                <td class="comments column-comments">
                    <div class="page-com-count-wrapper">
                        <a href="#" title="0 pending" class="post-com-count"><span
                                class="comment-count"><abbr title="<?php 
                echo $page['comment_count'];
                ?>
"><?php 
                echo $page['comment_count'];
                ?>
</abbr></span></a>
                    </div>
                </td>
                <td class="date column-date"><abbr
                        title="<?php 
                echo $page['dts'];
                ?>
"><?php 
                echo $page['dts'];
                ?>
</abbr>
                </td>
                <td class="status column-status"><?php 
                echo self::getStatus($page['status']);
                ?>
                </td>
                <td class="categories column-categories">
                    <a href="<?php 
                echo $website->url;
                ?>
" target="_blank"><?php 
                echo $website->url;
                ?>
</a>
                    <div class="row-actions">
                        <span class="edit"><a href="admin.php?page=managesites&dashboard=<?php 
                echo $website->id;
                ?>
"><?php 
                _e('Dashboard', 'mainwp');
                ?>
</a> | <a href="admin.php?page=SiteOpen&websiteid=<?php 
                echo $website->id;
                ?>
"><?php 
                _e('WP Admin', 'mainwp');
                ?>
</a></span>
                    </div>
                </td>
            </tr>
            <?php 
                $newOutput = ob_get_clean();
                echo $newOutput;
                MainWPCache::addBody('Page', $newOutput);
                $output->pages++;
            }
            unset($pages);
        } else {
            $output->errors[$website->id] = MainWPErrorHelper::getErrorMessage(new MainWPException('NOMAINWP', $website->url));
        }
    }
Exemplo n.º 2
0
 public function cache_add_body($page, $body)
 {
     MainWPCache::addBody($page, $body);
 }
Exemplo n.º 3
0
    protected static function usersSearchHandlerRenderer($users, $website)
    {
        $return = 0;
        foreach ($users as $user) {
            ob_start();
            ?>
        <tr id="user-1" class="alternate">
            <th scope="row" class="check-column"><input type="checkbox" name="user[]" value="1"></th>
            <td class="username column-username">
                <input class="userId" type="hidden" name="id" value="<?php 
            echo $user['id'];
            ?>
"/>
                <input class="userName" type="hidden" name="name" value="<?php 
            echo $user['login'];
            ?>
"/>
                <input class="websiteId" type="hidden" name="id"
                       value="<?php 
            echo $website->id;
            ?>
"/>

                <?php 
            if (isset($user['avatar'])) {
                echo $user['avatar'];
            }
            ?>
                <strong><abbr title="<?php 
            echo $user['login'];
            ?>
"><?php 
            echo $user['login'];
            ?>
</abbr></strong>

                <div class="row-actions">
                    <span class="edit"><a
                            href="admin.php?page=SiteOpen&websiteid=<?php 
            echo $website->id;
            ?>
&location=<?php 
            echo base64_encode('user-edit.php?user_id=' . $user['id']);
            ?>
"
                            title="Edit this user"><?php 
            _e('Edit', 'mainwp');
            ?>
</a>
                    </span>
                    <?php 
            if ($user['id'] != 1 && $user['login'] != $website->adminname) {
                ?>
                    <span class="trash">
                        | <a class="user_submitdelete" title="Delete this user" href="#"><?php 
                _e('Delete', 'mainwp');
                ?>
</a>
                    </span>
                    <?php 
            } else {
                if ($user['id'] == 1 || $user['login'] == $website->adminname) {
                    ?>
                    <span class="trash">
                        | <span title="This user is used for our secure link, it can not be deleted." style="color: gray"><?php 
                    _e('Delete', 'mainwp');
                    ?>
&nbsp;&nbsp;<?php 
                    MainWPUtility::renderToolTip(__('This user is used for our secure link, it can not be deleted.', 'mainwp'), 'http://docs.mainwp.com/deleting-secure-link-admin', 'images/info.png', 'float: none !important;');
                    ?>
</span>
                    </span>
                    <?php 
                }
            }
            ?>
                </div>
                <div class="row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php 
            _e('Please wait', 'mainwp');
            ?>
                </div>
            </td>
            <td class="name column-name"><?php 
            echo $user['display_name'];
            ?>
</td>
            <td class="email column-email"><a
                    href="mailto:<?php 
            echo $user['email'];
            ?>
"><?php 
            echo $user['email'];
            ?>
</a></td>
            <td class="role column-role"><?php 
            echo self::getRole($user['role']);
            ?>
</td>
            <td class="posts column-posts" style="text-align: left; padding-left: 1.7em ;"><a href="<?php 
            echo admin_url('admin.php?page=PostBulkManage&siteid=' . $website->id . '&userid=' . $user['id']);
            ?>
"><?php 
            echo $user['post_count'];
            ?>
</a></td>
            <td class="website column-website"><a
                    href="<?php 
            echo $website->url;
            ?>
"><?php 
            echo $website->url;
            ?>
</a>
                    <div class="row-actions">
                        <span class="edit"><a href="admin.php?page=managesites&dashboard=<?php 
            echo $website->id;
            ?>
"><?php 
            _e('Dashboard', 'mainwp');
            ?>
</a> | <a href="admin.php?page=SiteOpen&websiteid=<?php 
            echo $website->id;
            ?>
"><?php 
            _e('WP Admin', 'mainwp');
            ?>
</a></span>
                    </div>
            </td>
        </tr>
        <?php 
            $newOutput = ob_get_clean();
            echo $newOutput;
            MainWPCache::addBody('Users', $newOutput);
            $return++;
        }
        return $return;
    }
Exemplo n.º 4
0
    public static function renderTable($keyword, $status, $groups, $sites)
    {
        MainWPCache::initCache('Themes');
        $output = new stdClass();
        $output->errors = array();
        $output->themes = array();
        if (get_option('mainwp_optimize') == 1) {
            //Search in local cache
            if ($sites != '') {
                foreach ($sites as $k => $v) {
                    if (MainWPUtility::ctype_digit($v)) {
                        $website = MainWPDB::Instance()->getWebsiteById($v);
                        $allThemes = json_decode($website->themes, true);
                        for ($i = 0; $i < count($allThemes); $i++) {
                            $theme = $allThemes[$i];
                            if ($status == "active" || $status == "inactive") {
                                if ($theme['active'] == 1 && $status !== "active") {
                                    continue;
                                } else {
                                    if ($theme['active'] != 1 && $status !== "inactive") {
                                        continue;
                                    }
                                }
                            }
                            if ($keyword != '' && !stristr($theme['title'], $keyword)) {
                                continue;
                            }
                            $theme['websiteid'] = $website->id;
                            $theme['websiteurl'] = $website->url;
                            $output->themes[] = $theme;
                        }
                    }
                }
            }
            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;
                            }
                            $allThemes = json_decode($website->themes, true);
                            for ($i = 0; $i < count($allThemes); $i++) {
                                $theme = $allThemes[$i];
                                if ($status == "active" || $status == "inactive") {
                                    if ($theme['active'] == 1 && $status !== "active") {
                                        continue;
                                    } else {
                                        if ($theme['active'] != 1 && $status !== "inactive") {
                                            continue;
                                        }
                                    }
                                }
                                if ($keyword != '' && !stristr($theme['title'], $keyword)) {
                                    continue;
                                }
                                $theme['websiteid'] = $website->id;
                                $theme['websiteurl'] = $website->url;
                                $output->themes[] = $theme;
                            }
                        }
                        @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_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)) {
                return;
            }
        }
        MainWPCache::addContext('Themes', 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 ($status == 'inactive') {
            ?>
                <?php 
            if (mainwp_current_user_can("dashboard", "activate_themes")) {
                ?>
                    <option value="activate"><?php 
                _e('Activate', 'mainwp');
                ?>
</option>
                <?php 
            }
            ?>
                <?php 
            if (mainwp_current_user_can("dashboard", "delete_themes")) {
                ?>
    
                    <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_theme_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 
        if (count($output->themes) == 0) {
            ?>
        No themes found
        <?php 
            $newOutput = ob_get_clean();
            echo $newOutput;
            MainWPCache::addBody('Themes', $newOutput);
            return;
        }
        //Map per siteId
        $sites = array();
        //id -> url
        $siteThemes = array();
        //site_id -> theme_version_name -> theme obj
        $themes = array();
        //name_version -> name
        $themesVersion = array();
        //name_version -> title_version
        $themesRealVersion = $themesSlug = array();
        //name_version -> title_version
        foreach ($output->themes as $theme) {
            $sites[$theme['websiteid']] = $theme['websiteurl'];
            $themes[$theme['name'] . '_' . $theme['version']] = $theme['name'];
            $themesSlug[$theme['name'] . '_' . $theme['version']] = $theme['slug'];
            $themesVersion[$theme['name'] . '_' . $theme['version']] = $theme['title'] . ' ' . $theme['version'];
            $themesRealVersion[$theme['name'] . '_' . $theme['version']] = $theme['version'];
            if (!isset($siteThemes[$theme['websiteid']]) || !is_array($siteThemes[$theme['websiteid']])) {
                $siteThemes[$theme['websiteid']] = array();
            }
            $siteThemes[$theme['websiteid']][$theme['name'] . '_' . $theme['version']] = $theme;
        }
        ?>
<div id="mainwp-table-overflow" style="overflow: auto !important ;">
    <table class="wp-list-table widefat fixed pages" style="width: auto; word-wrap: normal">
        <thead>
        <tr>
            <th class="headcol"></th>
            <?php 
        foreach ($themesVersion as $theme_name => $theme_title) {
            echo '<th style="height: 100px; padding: 5px ;">
                    <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="' . $themes[$theme_name] . '" id="' . $theme_name . '" version="' . $themesRealVersion[$theme_name] . '" class="mainwp_theme_check_all" style="margin: 3px 0px 0px 0px; display: none ; " />
                    <label for="' . $theme_name . '">' . $theme_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 ($themesVersion as $theme_name => $theme_title) {
                echo '<td style="text-align: center">';
                if (isset($siteThemes[$site_id]) && isset($siteThemes[$site_id][$theme_name])) {
                    echo '<input type="checkbox" value="' . $themes[$theme_name] . '" version="' . $themesRealVersion[$theme_name] . '" slug="' . $themesSlug[$theme_name] . '" class="selected_theme" />';
                }
                echo '</td>';
            }
            ?>
            </tr>
                <?php 
        }
        ?>
        </tbody>
    </table>
</div>
        <?php 
        $newOutput = ob_get_clean();
        echo $newOutput;
        MainWPCache::addBody('Themes', $newOutput);
    }