Ejemplo n.º 1
0
    public static function posting()
    {
        ?>
    <div class="wrap">
      <?php 
        //  Use this to add a new page. To bulk change pages click on the "Manage" tab.
        do_action("mainwp_bulkpage_before_post", $_GET['id']);
        $skip_post = false;
        if (isset($_GET['id'])) {
            if ('yes' == get_post_meta($_GET['id'], '_mainwp_skip_posting', true)) {
                $skip_post = true;
                wp_delete_post($_GET['id'], true);
            }
        }
        if (!$skip_post) {
            //Posts the saved sites
            if (isset($_GET['id'])) {
                $id = $_GET['id'];
                $post = get_post($id);
                if ($post) {
                    $selected_by = get_post_meta($id, '_selected_by', true);
                    $selected_sites = unserialize(base64_decode(get_post_meta($id, '_selected_sites', true)));
                    $selected_groups = unserialize(base64_decode(get_post_meta($id, '_selected_groups', true)));
                    $post_slug = base64_decode(get_post_meta($id, '_slug', true));
                    $post_custom = get_post_custom($id);
                    include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php';
                    $post_featured_image = get_post_thumbnail_id($id);
                    $mainwp_upload_dir = wp_upload_dir();
                    $new_post = array('post_title' => $post->post_title, 'post_content' => $post->post_content, 'post_status' => $post->post_status, 'post_date' => $post->post_date, 'post_date_gmt' => $post->post_date_gmt, 'post_type' => 'page', 'post_name' => $post_slug, 'post_excerpt' => $post->post_excerpt, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'id_spin' => $post->ID);
                    if ($post_featured_image != null) {
                        //Featured image is set, retrieve URL
                        $img = wp_get_attachment_image_src($post_featured_image, 'full');
                        $post_featured_image = $img[0];
                    }
                    $dbwebsites = array();
                    if ($selected_by == 'site') {
                        //Get all selected websites
                        foreach ($selected_sites as $k) {
                            if (MainWPUtility::ctype_digit($k)) {
                                $website = MainWPDB::Instance()->getWebsiteById($k);
                                $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                            }
                        }
                    } else {
                        //Get all websites from the selected groups
                        foreach ($selected_groups as $k) {
                            if (MainWPUtility::ctype_digit($k)) {
                                $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupId($k));
                                while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                                    if ($website->sync_errors != '') {
                                        continue;
                                    }
                                    $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                                }
                                @MainWPDB::free_result($websites);
                            }
                        }
                    }
                    $output = new stdClass();
                    $output->ok = array();
                    $output->errors = array();
                    $startTime = time();
                    if (count($dbwebsites) > 0) {
                        $post_data = array('new_post' => base64_encode(serialize($new_post)), 'post_custom' => base64_encode(serialize($post_custom)), 'post_featured_image' => base64_encode($post_featured_image), 'mainwp_upload_dir' => base64_encode(serialize($mainwp_upload_dir)));
                        $post_data = apply_filters("mainwp_bulkpage_posting", $post_data, $id);
                        MainWPUtility::fetchUrlsAuthed($dbwebsites, 'newpost', $post_data, array(MainWPBulkAdd::getClassName(), 'PostingBulk_handler'), $output);
                    }
                    $failed_posts = array();
                    foreach ($dbwebsites as $website) {
                        if ($output->ok[$website->id] == 1 && isset($output->added_id[$website->id])) {
                            do_action('mainwp-post-posting-page', $website, $output->added_id[$website->id], isset($output->link[$website->id]) ? $output->link[$website->id] : null);
                            do_action('mainwp-bulkposting-done', $post, $website, $output);
                        } else {
                            $failed_posts[] = $website->id;
                        }
                    }
                    $del_post = true;
                    $saved_draft = get_post_meta($id, "_saved_as_draft", true);
                    if ($saved_draft == "yes") {
                        if (count($failed_posts) > 0) {
                            $del_post = false;
                            update_post_meta($post->ID, "_selected_sites", base64_encode(serialize($failed_posts)));
                            update_post_meta($post->ID, "_selected_groups", "");
                            wp_update_post(array("ID" => $id, 'post_status' => 'draft'));
                        }
                    }
                    if ($del_post) {
                        wp_delete_post($id, true);
                    }
                    $countSites = 0;
                    foreach ($dbwebsites as $website) {
                        if (isset($output->ok[$website->id]) && $output->ok[$website->id] == 1) {
                            $countSites++;
                        }
                    }
                    if (!empty($countSites)) {
                        $seconds = time() - $startTime;
                        MainWPTwitter::updateTwitterInfo('new_page', $countSites, $seconds, 1, $startTime, 1);
                    }
                    if (MainWPTwitter::enabledTwitterMessages()) {
                        $twitters = MainWPTwitter::getTwitterNotice('new_page');
                        if (is_array($twitters)) {
                            foreach ($twitters as $timeid => $twit_mess) {
                                if (!empty($twit_mess)) {
                                    $sendText = MainWPTwitter::getTwitToSend('new_page', $timeid);
                                    ?>
                                    <div class="mainwp-tips mainwp_info-box-blue twitter"><span class="mainwp-tip" twit-what="new_page" twit-id="<?php 
                                    echo $timeid;
                                    ?>
"><?php 
                                    echo $twit_mess;
                                    ?>
</span>&nbsp;<?php 
                                    MainWPTwitter::genTwitterButton($sendText);
                                    ?>
<span><a href="#" class="mainwp-dismiss-twit" ><i class="fa fa-times-circle"></i> <?php 
                                    _e('Dismiss', 'mainwp');
                                    ?>
</a></span></div>
                                <?php 
                                }
                            }
                        }
                    }
                }
                ?>
                <div id="message" class="updated">
                    <?php 
                foreach ($dbwebsites as $website) {
                    ?>
                    <p><a href="<?php 
                    echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
                    ?>
"><?php 
                    echo stripslashes($website->name);
                    ?>
</a>
                        : <?php 
                    echo isset($output->ok[$website->id]) && $output->ok[$website->id] == 1 ? 'New page created. ' . "<a href=\"" . $output->link[$website->id] . "\"  target=\"_blank\">View Page</a>" : 'ERROR: ' . $output->errors[$website->id];
                    ?>
</p>
                    <?php 
                }
                ?>
                </div>
               
                <?php 
            } else {
                ?>
                <div class="error below-h2">
                    <p><strong>ERROR</strong>: <?php 
                _e('An undefined error occured.', 'mainwp');
                ?>
</p>
                </div>               
                <?php 
            }
        }
        // no skip posting
        ?>
        <br/>
        <a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=PageBulkAdd" class="add-new-h2" target="_top"><?php 
        _e('Add New', 'mainwp');
        ?>
</a>
        <a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=mainwp_tab" class="add-new-h2" target="_top"><?php 
        _e('Return
            to Dashboard', 'mainwp');
        ?>
</a>
                
    </div>
    <?php 
    }
    public static function render()
    {
        $show_form = true;
        if (isset($_POST['updateadminpassword'])) {
            check_admin_referer('mainwp_updateadminpassword', 'security');
            $errors = array();
            if (isset($_POST['select_by'])) {
                $selected_sites = array();
                if (isset($_POST['selected_sites']) && is_array($_POST['selected_sites'])) {
                    foreach ($_POST['selected_sites'] as $selected) {
                        $selected_sites[] = $selected;
                    }
                }
                $selected_groups = array();
                if (isset($_POST['selected_groups']) && is_array($_POST['selected_groups'])) {
                    foreach ($_POST['selected_groups'] as $selected) {
                        $selected_groups[] = $selected;
                    }
                }
                if ($_POST['select_by'] == 'group' && count($selected_groups) == 0 || $_POST['select_by'] == 'site' && count($selected_sites) == 0) {
                    $errors[] = __('Please select the sites or groups where you want to change the admin password.', 'mainwp');
                }
            } else {
                $errors[] = __('Please select whether you want to change the admin password for specific sites or groups.', 'mainwp');
            }
            if (!isset($_POST['pass1']) || $_POST['pass1'] == '' || !isset($_POST['pass2']) || $_POST['pass2'] == '') {
                $errors[] = __('Please enter the password twice.', 'mainwp');
            } else {
                if ($_POST['pass1'] != $_POST['pass2']) {
                    $errors[] = __('Please enter the same password in the two password fields.', 'mainwp');
                }
            }
            if (count($errors) == 0) {
                $show_form = false;
                $new_password = array('user_pass' => $_POST['pass1']);
                $dbwebsites = array();
                if ($_POST['select_by'] == 'site') {
                    //Get all selected websites
                    foreach ($selected_sites as $k) {
                        if (MainWPUtility::ctype_digit($k)) {
                            $website = MainWPDB::Instance()->getWebsiteById($k);
                            $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                        }
                    }
                } else {
                    //Get all websites from the selected groups
                    foreach ($selected_groups as $k) {
                        if (MainWPUtility::ctype_digit($k)) {
                            $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupId($k));
                            while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                                if ($website->sync_errors != '') {
                                    continue;
                                }
                                $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                            }
                            @MainWPDB::free_result($websites);
                        }
                    }
                }
                if (count($dbwebsites) > 0) {
                    $post_data = array('new_password' => base64_encode(serialize($new_password)));
                    $output = new stdClass();
                    $output->ok = array();
                    $output->errors = array();
                    MainWPUtility::fetchUrlsAuthed($dbwebsites, 'newadminpassword', $post_data, array(MainWPBulkAdd::getClassName(), 'PostingBulk_handler'), $output);
                }
            }
        }
        if (!$show_form) {
            //Added to..
            ?>
            <div class="wrap">
                <img src="<?php 
            echo plugins_url('images/icons/mainwp-passwords.png', dirname(__FILE__));
            ?>
" style="float: left; margin-right: 8px; margin-top: 7px ;" alt="MainWP Passwords" height="32"/><h2 id="add-new-user"> Update Admin Passwords</h2>
                <div id="message" class="updated">
                    <?php 
            foreach ($dbwebsites as $website) {
                ?>
                        <p><a href="<?php 
                echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
                ?>
"><?php 
                echo stripslashes($website->name);
                ?>
</a>: <?php 
                echo isset($output->ok[$website->id]) && $output->ok[$website->id] == 1 ? __('Admin password updated.', 'mainwp') : __('ERROR: ', 'mainwp') . $output->errors[$website->id];
                ?>
</p>
            <?php 
            }
            ?>
                </div>
                <br />
                <a href="<?php 
            echo get_admin_url();
            ?>
admin.php?page=UpdateAdminPasswords" class="add-new-h2" target="_top"><?php 
            _e('Update admin passwords', 'mainwp');
            ?>
</a>
                <a href="<?php 
            echo get_admin_url();
            ?>
admin.php?page=mainwp_tab" class="add-new-h2" target="_top"><?php 
            _e('Return to Dashboard', 'mainwp');
            ?>
</a>
            </div>
            <?php 
        } else {
            // header in User page
            MainWPUser::renderHeader('UpdateAdminPasswords');
            ?>
            <form action="" method="post" name="createuser" id="createuser" class="add:users: validate">

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

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

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

            </form>
            <?php 
            MainWPUser::renderFooter('UpdateAdminPasswords');
        }
    }
Ejemplo n.º 3
0
 public static function doImport()
 {
     if (isset($_POST['select_by'])) {
         $selected_sites = array();
         if (isset($_POST['selected_sites']) && is_array($_POST['selected_sites'])) {
             foreach ($_POST['selected_sites'] as $selected) {
                 $selected_sites[] = $selected;
             }
         }
         $selected_groups = array();
         if (isset($_POST['selected_groups']) && is_array($_POST['selected_groups'])) {
             foreach ($_POST['selected_groups'] as $selected) {
                 $selected_groups[] = $selected;
             }
         }
     }
     $user_to_add = array('user_pass' => $_POST['pass1'], 'user_login' => $_POST['user_login'], 'user_url' => $_POST['url'], 'user_email' => $_POST['email'], 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'role' => $_POST['role']);
     $ret = array();
     $dbwebsites = array();
     $not_valid = array();
     $error_sites = "";
     if ($_POST['select_by'] == 'site') {
         //Get all selected websites
         foreach ($selected_sites as $url) {
             if (!empty($url)) {
                 $website = MainWPDB::Instance()->getWebsitesByUrl($url);
                 if ($website) {
                     $dbwebsites[$website[0]->id] = MainWPUtility::mapSite($website[0], array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                 } else {
                     $not_valid[] = "Error - The website doesn't exist in the Network. " . $url;
                     $error_sites .= $url . ";";
                 }
             }
         }
     } else {
         //Get all websites from the selected groups
         foreach ($selected_groups as $group) {
             if (MainWPDB::Instance()->getGroupsByName($group)) {
                 $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupName($group));
                 if ($websites) {
                     while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
                         $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                     }
                     @MainWPDB::free_result($websites);
                 } else {
                     $not_valid[] = __("Error - These are not websites in the group. ", 'mainwp') . $group;
                     $error_sites .= $group . ";";
                 }
             } else {
                 $not_valid[] = __("Error - The group doesn't exist in the Network. ", 'mainwp') . $group;
                 $error_sites .= $group . ";";
             }
         }
     }
     if (count($dbwebsites) > 0) {
         $post_data = array('new_user' => base64_encode(serialize($user_to_add)), 'send_password' => isset($_POST['send_password']) ? $_POST['send_password'] : '');
         $output = new stdClass();
         $output->ok = array();
         $output->errors = array();
         MainWPUtility::fetchUrlsAuthed($dbwebsites, 'newuser', $post_data, array(MainWPBulkAdd::getClassName(), 'PostingBulk_handler'), $output);
     }
     $ret['ok_list'] = $ret['error_list'] = array();
     foreach ($dbwebsites as $website) {
         if (isset($output->ok[$website->id]) && $output->ok[$website->id] == 1) {
             $ret['ok_list'][] = 'New user(s) created: ' . stripslashes($website->name);
         } else {
             $ret['error_list'][] = $output->errors[$website->id] . " " . stripslashes($website->name);
             $error_sites .= $website->url . ";";
         }
     }
     foreach ($not_valid as $val) {
         $ret['error_list'][] = $val;
     }
     $ret['failed_logging'] = "";
     if (!empty($error_sites)) {
         $error_sites = rtrim($error_sites, ';');
         $ret['failed_logging'] = $_POST['user_login'] . "," . $_POST['email'] . "," . $_POST['first_name'] . "," . $_POST['last_name'] . "," . $_POST['url'] . "," . $_POST['pass1'] . "," . intval($_POST['send_password']) . "," . $_POST['role'] . "," . $error_sites . ",";
     }
     $ret['line_number'] = $_POST['line_number'];
     die(json_encode($ret));
 }
Ejemplo n.º 4
0
 public static function performUpload()
 {
     MainWPUtility::endSession();
     //Fetch info..
     $post_data = array('url' => json_encode(explode('||', $_POST['urls'])), 'type' => $_POST['type']);
     if ($_POST['activatePlugin'] == 'true') {
         $post_data['activatePlugin'] = 'yes';
     }
     if ($_POST['overwrite'] == 'true') {
         $post_data['overwrite'] = true;
     }
     $output = new stdClass();
     $output->ok = array();
     $output->errors = array();
     $websites = array(MainWPDB::Instance()->getWebsiteById($_POST['siteId']));
     MainWPUtility::fetchUrlsAuthed($websites, 'installplugintheme', $post_data, array(MainWPInstallBulk::getClassName(), 'InstallPluginTheme_handler'), $output);
     die(json_encode($output));
 }
Ejemplo n.º 5
0
 public static function hookFetchUrlsAuthed($pluginFile, $key, $dbwebsites, $what, $params, $handle, $output)
 {
     if (!self::hookVerify($pluginFile, $key)) {
         return false;
     }
     return MainWPUtility::fetchUrlsAuthed($dbwebsites, $what, $params, $handle, $output);
 }
Ejemplo n.º 6
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 
    }
Ejemplo n.º 7
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);
    }
Ejemplo n.º 8
0
 public static function getTerms($websiteid, $prefix = '', $what = 'site', $gen_type = 'post')
 {
     $output = new stdClass();
     $output->errors = array();
     $output->cats = array();
     $dbwebsites = array();
     if ($what == 'group') {
         $input_name = 'groups_selected_cats_' . $prefix . '[]';
     } else {
         $input_name = 'sites_selected_cats_' . $prefix . '[]';
     }
     if (!empty($websiteid)) {
         if (MainWPUtility::ctype_digit($websiteid)) {
             $website = MainWPDB::Instance()->getWebsiteById($websiteid);
             $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
         }
     }
     if ($gen_type == 'post') {
         $bkc_option_path = 'default_keywords_post';
         $keyword_option = 'keywords_page';
     } else {
         if ($gen_type == 'page') {
             $bkc_option_path = 'default_keywords_page';
             $keyword_option = 'keywords_page';
         }
     }
     if ($prefix == 'bulk') {
         $opt = apply_filters('mainwp-get-options', $value = '', 'mainwp_content_extension', 'bulk_keyword_cats', $bkc_option_path);
         $selected_cats = unserialize(base64_decode($opt));
     } else {
         $opt = apply_filters('mainwp-get-options', $value = '', 'mainwp_content_extension', $keyword_option);
         if (is_array($opt) && is_array($opt[$prefix])) {
             $selected_cats = unserialize(base64_decode($opt[$prefix]['selected_cats']));
         }
     }
     $selected_cats = is_array($selected_cats) ? $selected_cats : array();
     $ret = "";
     if (count($dbwebsites) > 0) {
         $opt = apply_filters('mainwp-get-options', $value = '', 'mainwp_content_extension', 'taxonomy');
         $post_data = array('taxonomy' => base64_encode($opt));
         MainWPUtility::fetchUrlsAuthed($dbwebsites, 'get_terms', $post_data, array(MainWPPost::getClassName(), 'PostsGetTerms_handler'), $output);
         foreach ($dbwebsites as $siteid => $website) {
             $cats = array();
             if (is_array($selected_cats[$siteid])) {
                 foreach ($selected_cats[$siteid] as $val) {
                     $cats[] = $val['term_id'];
                 }
             }
             if (!empty($output->errors[$siteid])) {
                 $ret .= '<p> Error - ' . $output->errors[$siteid] . '</p>';
             } else {
                 if (count($output->cats[$siteid]) > 0) {
                     foreach ($output->cats[$siteid] as $cat) {
                         if ($cat->term_id) {
                             if (in_array($cat->term_id, $cats)) {
                                 $checked = ' checked="checked" ';
                             } else {
                                 $checked = '';
                             }
                             $ret .= '<div class="mainwp_selected_sites_item ' . (!empty($checked) ? 'selected_sites_item_checked' : '') . '"><input type="checkbox" name="' . $input_name . '" value="' . $siteid . "," . $cat->term_id . "," . $cat->name . '" ' . $checked . '/><label>' . $cat->name . '</label></div>';
                         }
                     }
                 } else {
                     $ret .= '<p>No categories have been found</p>';
                 }
             }
         }
     } else {
         $ret .= '<p>Error - no site</p>';
     }
     echo $ret;
 }