public static function render() { self::renderHeader(''); ?> <a class="button-primary mwp-child-scan" href="#"><?php _e('Scan', "mainwp"); ?> </a> <?php $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser()); if (!$websites) { echo __('<p>No websites to scan.</p>', 'mainwp'); } else { ?> <table id="mwp_child_scan_childsites"> <tr><th>Child</th><th>Status</th></tr> <?php while ($websites && ($website = @MainWPDB::fetch_object($websites))) { $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;"/> '; } } if ($website->sync_errors == '') { echo '<tr siteid="' . $website->id . '"><td title="' . $website->url . '">' . $imgfavi . ' ' . stripslashes($website->name) . ':</td><td></td></tr>'; } else { echo '<tr><td title="' . $website->url . '">' . $imgfavi . ' ' . stripslashes($website->name) . ':</td><td>Sync errors</td></tr>'; } } @MainWPDB::free_result($websites); ?> </table> <?php } ?> <?php self::renderFooter(''); }
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 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 ! " ? $ % ^ & ).', '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'); } }
public static function prepareUpload() { include_once ABSPATH . '/wp-admin/includes/plugin-install.php'; $output = array(); $output['sites'] = array(); if ($_POST['selected_by'] == 'site') { //Get sites foreach ($_POST['selected_sites'] as $enc_id) { $websiteid = $enc_id; if (MainWPUtility::ctype_digit($websiteid)) { $website = MainWPDB::Instance()->getWebsiteById($websiteid); $output['sites'][$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name')); } } } else { //Get sites from group foreach ($_POST['selected_groups'] as $enc_id) { $groupid = $enc_id; if (MainWPUtility::ctype_digit($groupid)) { $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupId($groupid)); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if ($website->sync_errors != '') { continue; } $output['sites'][$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name')); } @MainWPDB::free_result($websites); } } } $output['urls'] = array(); foreach ($_POST['files'] as $file) { $output['urls'][] = MainWPUtility::getDownloadUrl('bulk', $file); } $output['urls'] = implode('||', $output['urls']); $output['urls'] = apply_filters('mainwp_installbulk_prepareupload', $output['urls']); die(json_encode($output)); }
public static function renderWidget($renew, $pExit = true) { $current_wpid = MainWPUtility::get_current_wpid(); if (empty($current_wpid)) { return; } $sql = MainWPDB::Instance()->getSQLWebsiteById($current_wpid); $websites = MainWPDB::Instance()->query($sql); $allPlugins = array(); if ($websites) { $website = @MainWPDB::fetch_object($websites); if ($website && $website->plugins != '') { $plugins = json_decode($website->plugins, 1); if (is_array($plugins) && count($plugins) != 0) { foreach ($plugins as $plugin) { $allPlugins[] = $plugin; } } } @MainWPDB::free_result($websites); } $actived_plugins = MainWPUtility::getSubArrayHaving($allPlugins, 'active', 1); $actived_plugins = MainWPUtility::sortmulti($actived_plugins, 'name', 'desc'); $inactive_plugins = MainWPUtility::getSubArrayHaving($allPlugins, 'active', 0); $inactive_plugins = MainWPUtility::sortmulti($inactive_plugins, 'name', 'desc'); ?> <div class="clear"> <a class="mainwp_action left mainwp_action_down plugins_actived_lnk" href="#"><?php _e('Active', 'mainwp'); ?> (<?php echo count($actived_plugins); ?> )</a><a class="mainwp_action mid plugins_inactive_lnk right" href="#" ><?php _e('Inactive', 'mainwp'); ?> (<?php echo count($inactive_plugins); ?> )</a><br/><br/> <div class="mainwp_plugins_active"> <?php for ($i = 0; $i < count($actived_plugins); $i++) { ?> <div class="mainwp-row mainwp-active"> <input class="pluginSlug" type="hidden" name="slug" value="<?php echo $actived_plugins[$i]['slug']; ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $website->id; ?> "/> <span class="mainwp-left-col"> <a href="<?php echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . dirname($actived_plugins[$i]['slug']) . '&TB_iframe=true&width=640&height=477'; ?> " target="_blank" class="thickbox" title="More information about <?php echo $actived_plugins[$i]['name']; ?> "> <?php echo $actived_plugins[$i]['name']; ?> </a><?php echo " " . $actived_plugins[$i]['version']; ?> </span> <div class="mainwp-right-col pluginsAction"> <?php if (mainwp_current_user_can("dashboard", "activate_deactivate_plugins")) { ?> <a href="#" class="mainwp-plugin-deactivate"><i class="fa fa-toggle-off"></i> <?php _e('Deactivate', 'mainwp'); ?> </a> <?php } ?> </div> <div style="clear: left;"></div> <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> </div> <div> </div> </div> <?php } ?> </div> <div class="mainwp_plugins_inactive" style="display: none"> <?php for ($i = 0; $i < count($inactive_plugins); $i++) { ?> <div class="mainwp-row mainwp-inactive"> <input class="pluginSlug" type="hidden" name="slug" value="<?php echo $inactive_plugins[$i]['slug']; ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $website->id; ?> "/> <span class="mainwp-left-col"> <a href="<?php echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . dirname($inactive_plugins[$i]['slug']) . '&TB_iframe=true&width=640&height=477'; ?> " target="_blank" class="thickbox" title="More information about <?php echo $inactive_plugins[$i]['name']; ?> "> <?php echo $inactive_plugins[$i]['name']; ?> </a><?php echo " " . $inactive_plugins[$i]['version']; ?> </span> <div class="mainwp-right-col pluginsAction"> <?php if (mainwp_current_user_can("dashboard", "activate_deactivate_plugins")) { ?> <a href="#" class="mainwp-plugin-activate"><i class="fa fa-toggle-on"></i> <?php _e('Activate', 'mainwp'); ?> </a> | <?php } ?> <?php if (mainwp_current_user_can("dashboard", "delete_plugins")) { ?> <a href="#" class="mainwp-plugin-delete mainwp-red"><i class="fa fa-trash"></i> <?php _e('Delete', 'mainwp'); ?> </a> <?php } ?> </div> <div style="clear: left;"></div> <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> </div> <div> </div> </div> <?php } ?> </div> </div> <div class="clear"></div> <?php if ($pExit == true) { exit; } }
public static function select_categories_box($params) { $title = $params['title']; $type = isset($params['type']) ? $params['type'] : 'checkbox'; $show_group = isset($params['show_group']) ? $params['show_group'] : true; $selected_by = !empty($params['selected_by']) ? $params['selected_by'] : 'site'; $class = isset($params['class']) ? $params['class'] : ''; $style = isset($params['style']) ? $params['style'] : ''; $selected_cats = is_array($params['selected_cats']) ? $params['selected_cats'] : array(); $prefix = $params['prefix']; if ($type == 'checkbox') { $cbox_prefix = '[]'; } $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser()); $groups = MainWPDB::Instance()->getNotEmptyGroups(); ?> <div class="mainwp_select_sites_box mainwp_select_categories <?php if ($class) { echo " {$class}"; } ?> "<?php if ($style) { echo ' style="' . $style . '"'; } ?> > <div class="postbox"> <h3 class="box_title mainwp_box_title"><?php echo $title ? $title : _e("Select Categories", 'mainwp'); ?> </h3> <div class="inside mainwp_inside "> <input type="hidden" name="select_by_<?php echo $prefix; ?> " class="select_by" value="<?php echo $selected_by; ?> " /> <?php if ($show_group) { ?> <div class="mainwp_ss_site_link" <?php echo $selected_by == 'group' ? 'style="display: inline-block;"' : ''; ?> ><a href="#" onClick="return mainwp_ss_cats_select_by(this, 'site')"><?php _e('By site', 'mainwp'); ?> </a></div> <div class="mainwp_ss_site_text" <?php echo $selected_by == 'group' ? 'style="display: none;"' : ''; ?> ><?php _e('By site', 'mainwp'); ?> </div> | <div class="mainwp_ss_group_link" <?php echo $selected_by == 'group' ? 'style="display: none;"' : ''; ?> ><a href="#" onClick="return mainwp_ss_cats_select_by(this, 'group')"><?php _e('By group', 'mainwp'); ?> </a></div> <div class="mainwp_ss_group_text" <?php echo $selected_by == 'group' ? 'style="display: inline-block;"' : ''; ?> ><?php _e('By group', 'mainwp'); ?> </div> <?php } ?> <div class="selected_sites" <?php echo $selected_by == 'group' ? 'style = "display: none"' : ''; ?> > <?php if (!$websites) { echo __('<p>No websites have been found.</p>', 'mainwp'); } else { while ($websites && ($website = @MainWPDB::fetch_object($websites))) { $cats = isset($selected_cats[$website->id]) && is_array($selected_cats[$website->id]) ? $selected_cats[$website->id] : array(); ?> <div class="categories_site_<?php echo $website->id; ?> "> <div class="categories_list_header"> <div><?php echo stripslashes($website->name); ?> </div> <label><span class="url"><?php echo $website->url; ?> </span></label> </div> <div class="categories_list_<?php echo $website->id; ?> "> <?php if (count($cats) == 0) { echo '<p>No selected categories.</p>'; } else { foreach ($cats as $cat) { echo '<div class="mainwp_selected_sites_item selected_sites_item_checked"> <input type="' . $type . '" name="sites_selected_cats_' . $prefix . $cbox_prefix . '" value="' . $website->id . "," . $cat['term_id'] . "," . $cat['name'] . '" id="sites_selected_cats_' . $prefix . $cat['term_id'] . '" checked="true" /><label>' . $cat['name'] . '</label> </div>'; } } ?> </div> <div class="mainwp_categories_list_bottom"> <div style="float:right"> <a href="#" rel="<?php echo $prefix; ?> " class="load_more_cats" onClick="return mainwp_ss_cats_more(this, <?php echo $website->id; ?> , 'site')"><?php _e('Reload', 'mainwp'); ?> </a> <span class="mainwp_more_loading"><i class="fa fa-spinner fa-pulse"></i></span> </div> <div class="clearfix"></div> </div> </div> <?php } @MainWPDB::free_result($websites); } ?> </div> <div class="selected_groups" <?php echo $selected_by == 'group' ? 'style = "display: block"' : ''; ?> > <?php if (count($groups) == 0) { echo __('<p>No groups with entries have been found.</p>', 'mainwp'); } foreach ($groups as $gid => $group) { ?> <div class="categories_group_<?php echo $gid; ?> "> <div class="mainwp_groups_list_header"> <div><?php echo $group->name; ?> </div> </div> <?php $websites = MainWPDB::Instance()->getWebsitesByGroupIds(array($gid)); foreach ($websites as $website) { $id = $website->id; $cats = isset($selected_cats[$id]) && is_array($selected_cats[$id]) ? $selected_cats[$id] : array(); ?> <div class="categories_site_<?php echo $id; ?> "> <div class="categories_list_header"> <div><?php echo stripslashes($website->name); ?> </div> <label><span class="url"><?php echo $website->url; ?> </span></label> </div> <div class="categories_list_<?php echo $id; ?> "> <?php if (count($cats) == 0) { echo __('<p>No selected categories.</p>', 'mainwp'); } else { foreach ($cats as $cat) { echo '<div class="mainwp_selected_sites_item selected_sites_item_checked"> <input type="' . $type . '" name="groups_selected_cats_' . $prefix . $cbox_prefix . '" value="' . $id . "," . $cat['term_id'] . "," . $cat['name'] . '" id="groups_selected_cats_' . $prefix . $cat['term_id'] . '" checked="true" /><label>' . $cat['name'] . '</label> </div>'; } } ?> </div> <div class="mainwp_categories_list_bottom"> <div style="float:right"> <a href="#" rel="<?php echo $prefix; ?> " class="load_more_cats" onClick="return mainwp_ss_cats_more(this, <?php echo $id; ?> , 'group')">Reload</a> <span class="mainwp_more_loading"><i class="fa fa-spinner fa-pulse"></i></span> </div> <div class="clearfix"></div> </div> </div> <?php } ?> </div> <?php } ?> </div> </div> </div> </div> <?php }
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)); }
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 renderWidget($renew, $pExit = true) { $current_wpid = MainWPUtility::get_current_wpid(); if (empty($current_wpid)) { return; } $sql = MainWPDB::Instance()->getSQLWebsiteById($current_wpid); $websites = MainWPDB::Instance()->query($sql); $allPlugins = array(); if ($websites) { $website = @MainWPDB::fetch_object($websites); if ($website && $website->plugins != '') { $plugins = json_decode($website->plugins, 1); if (is_array($plugins) && count($plugins) != 0) { foreach ($plugins as $plugin) { $allPlugins[] = $plugin; } } } @MainWPDB::free_result($websites); } $actived_plugins = MainWPUtility::getSubArrayHaving($allPlugins, 'active', 1); $actived_plugins = MainWPUtility::sortmulti($actived_plugins, 'name', 'desc'); $inactive_plugins = MainWPUtility::getSubArrayHaving($allPlugins, 'active', 0); $inactive_plugins = MainWPUtility::sortmulti($inactive_plugins, 'name', 'desc'); $plugins_outdate = array(); if (count($allPlugins) > 0 && $website) { $plugins_outdate = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'plugins_outdate_info'), true); if (!is_array($plugins_outdate)) { $plugins_outdate = array(); } $pluginsOutdateDismissed = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'plugins_outdate_dismissed'), true); if (is_array($pluginsOutdateDismissed)) { $plugins_outdate = array_diff_key($plugins_outdate, $pluginsOutdateDismissed); } $userExtension = MainWPDB::Instance()->getUserExtension(); $decodedDismissedPlugins = json_decode($userExtension->dismissed_plugins, true); if (is_array($decodedDismissedPlugins)) { $plugins_outdate = array_diff_key($plugins_outdate, $decodedDismissedPlugins); } } ?> <div class="clear mwp_plugintheme_widget"> <a class="mainwp_action left mainwp_action_down plugins_actived_lnk" href="#"><?php _e('Active', 'mainwp'); ?> (<?php echo count($actived_plugins); ?> )</a><a class="mainwp_action mid plugins_inactive_lnk right" href="#" ><?php _e('Inactive', 'mainwp'); ?> (<?php echo count($inactive_plugins); ?> )</a><br/><br/> <div class="mainwp_plugins_active"> <?php $str_format = __(" | Last Updated %s Days Ago", "mainwp"); for ($i = 0; $i < count($actived_plugins); $i++) { $outdate_notice = ""; $slug = $actived_plugins[$i]['slug']; if (isset($plugins_outdate[$slug])) { $plugin_outdate = $plugins_outdate[$slug]; $now = new \DateTime(); $last_updated = $plugin_outdate['last_updated']; $plugin_last_updated_date = new \DateTime('@' . $last_updated); $diff_in_days = $now->diff($plugin_last_updated_date)->format('%a'); $outdate_notice = sprintf($str_format, $diff_in_days); } ?> <div class="mainwp-row mainwp-active"> <input class="pluginSlug" type="hidden" name="slug" value="<?php echo $actived_plugins[$i]['slug']; ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $website->id; ?> "/> <span class="mainwp-left-col"> <a href="<?php echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . dirname($actived_plugins[$i]['slug']) . '&TB_iframe=true&width=640&height=477'; ?> " target="_blank" class="thickbox" title="More information about <?php echo $actived_plugins[$i]['name']; ?> "> <?php echo $actived_plugins[$i]['name']; ?> </a><?php echo " " . $actived_plugins[$i]['version']; ?> <?php echo $outdate_notice; ?> </span> <div class="mainwp-right-col pluginsAction"> <?php if (mainwp_current_user_can("dashboard", "activate_deactivate_plugins")) { ?> <a href="#" class="mainwp-plugin-deactivate"><i class="fa fa-toggle-off"></i> <?php _e('Deactivate', 'mainwp'); ?> </a> <?php } ?> </div> <div style="clear: left;"></div> <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> </div> <div> </div> </div> <?php } ?> </div> <div class="mainwp_plugins_inactive" style="display: none"> <?php for ($i = 0; $i < count($inactive_plugins); $i++) { $outdate_notice = ""; $slug = $inactive_plugins[$i]['slug']; if (isset($plugins_outdate[$slug])) { $plugin_outdate = $plugins_outdate[$slug]; $now = new \DateTime(); $last_updated = $plugin_outdate['last_updated']; $plugin_last_updated_date = new \DateTime('@' . $last_updated); $diff_in_days = $now->diff($plugin_last_updated_date)->format('%a'); $outdate_notice = sprintf($str_format, $diff_in_days); } ?> <div class="mainwp-row mainwp-inactive"> <input class="pluginSlug" type="hidden" name="slug" value="<?php echo $inactive_plugins[$i]['slug']; ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $website->id; ?> "/> <span class="mainwp-left-col"> <a href="<?php echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . dirname($inactive_plugins[$i]['slug']) . '&TB_iframe=true&width=640&height=477'; ?> " target="_blank" class="thickbox" title="More information about <?php echo $inactive_plugins[$i]['name']; ?> "> <?php echo $inactive_plugins[$i]['name']; ?> </a><?php echo " " . $inactive_plugins[$i]['version']; ?> <?php echo $outdate_notice; ?> </span> <div class="mainwp-right-col pluginsAction"> <?php if (mainwp_current_user_can("dashboard", "activate_deactivate_plugins")) { ?> <a href="#" class="mainwp-plugin-activate"><i class="fa fa-toggle-on"></i> <?php _e('Activate', 'mainwp'); ?> </a> | <?php } ?> <?php if (mainwp_current_user_can("dashboard", "delete_plugins")) { ?> <a href="#" class="mainwp-plugin-delete mainwp-red"><i class="fa fa-trash"></i> <?php _e('Delete', 'mainwp'); ?> </a> <?php } ?> </div> <div style="clear: left;"></div> <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> </div> <div> </div> </div> <?php } ?> </div> </div> <div class="clear"></div> <?php if ($pExit == true) { exit; } }
public static function renderSites() { $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); if (!$websites) { return; } $total_securityIssues = 0; @MainWPDB::data_seek($websites, 0); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if (MainWPUtility::ctype_digit($website->securityIssues)) { $total_securityIssues += $website->securityIssues; } } //We found some with security issues! if ($total_securityIssues > 0) { ?> <div class="clear"> <div class="mainwp-row-top darkred"> <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php echo $total_securityIssues; ?> </span> <?php _e('Security issue', 'mainwp'); echo $total_securityIssues > 1 ? 's' : ''; ?> </span> <span class="mainwp-mid-col"> </span> <span class="mainwp-right-col"><a href="#" id="mainwp_securityissues_show" onClick="return rightnow_show('securityissues');"><?php _e('Show All', 'mainwp'); ?> </a> <input type="button" class="securityIssues_dashboard_allFixAll button-primary" value="<?php _e('Fix All', 'mainwp'); ?> "/></span> </div> <div id="wp_securityissues" style="display: none"> <?php @MainWPDB::data_seek($websites, 0); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if (!MainWPUtility::ctype_digit($website->securityIssues) || $website->securityIssues == 0) { continue; } ?> <div class="mainwp-row" siteid="<?php echo $website->id; ?> "> <span class="mainwp-left-col"><a href="admin.php?page=managesites&scanid=<?php echo $website->id; ?> "><?php echo stripslashes($website->name); ?> </a></span> <span class="mainwp-mid-col"><span class="<?php echo $website->securityIssues > 0 ? 'darkred' : 'mainwp_ga_plus'; ?> "><span class="mainwp-rightnow-number"><?php echo $website->securityIssues; ?> </span> Issue<?php echo $website->securityIssues > 1 ? 's' : ''; ?> </span></span> <span class="mainwp-right-col"><?php if ($website->securityIssues == 0) { ?> <input type="button" class="securityIssues_dashboard_unfixAll button" value="<?php _e('Unfix All', 'mainwp'); ?> "/> <?php } else { ?> <input type="button" class="securityIssues_dashboard_fixAll button-primary" value="<?php _e('Fix All', 'mainwp'); ?> "/> <?php } ?> <i class="fa fa-spinner fa-pulse img-loader" style="display: none;"></i> </span> </div> <?php } ?> </div> </div> <?php } }
public static function renderIgnore() { $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser()); $userExtension = MainWPDB::Instance()->getUserExtension(); $decodedIgnoredThemes = json_decode($userExtension->ignored_themes, true); $ignoredThemes = is_array($decodedIgnoredThemes) && count($decodedIgnoredThemes) > 0; $cnt = 0; while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if ($website->is_ignoreThemeUpdates) { continue; } $tmpDecodedIgnoredThemes = json_decode($website->ignored_themes, true); if (!is_array($tmpDecodedIgnoredThemes) || count($tmpDecodedIgnoredThemes) == 0) { continue; } $cnt++; } self::renderHeader('Ignore'); ?> <table id="mainwp-table" class="wp-list-table widefat" cellspacing="0"> <caption><?php _e('Globally Ignored Themes', 'mainwp'); ?> </caption> <thead> <tr> <th scope="col" class="manage-column" style="width: 300px"><?php _e('Theme', 'mainwp'); ?> </th> <th scope="col" class="manage-column" style="width: 650px"><?php _e('Theme File', 'mainwp'); ?> </th> <th scope="col" class="manage-column" style="text-align: right; padding-right: 10px"><?php if ($ignoredThemes) { ?> <a href="#" class="button-primary mainwp-unignore-globally-all" onClick="return rightnow_themes_unignore_globally_all();"><?php _e('Allow All', 'mainwp'); ?> </a><?php } ?> </th> </tr> </thead> <tbody id="globally-ignored-themes-list" class="list:sites"> <?php if ($ignoredThemes) { ?> <?php foreach ($decodedIgnoredThemes as $ignoredTheme => $ignoredThemeName) { ?> <tr theme_slug="<?php echo urlencode($ignoredTheme); ?> "> <td> <strong><?php echo $ignoredThemeName; ?> </strong> </td> <td> <?php echo $ignoredTheme; ?> </td> <td style="text-align: right; padding-right: 30px"> <?php if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) { ?> <a href="#" onClick="return rightnow_themes_unignore_globally('<?php echo urlencode($ignoredTheme); ?> ')"><i class="fa fa-check"></i> <?php _e('Allow', 'mainwp'); ?> </a> <?php } ?> </td> </tr> <?php } ?> <?php } else { ?> <tr><td colspan="2"><?php _e('No ignored themes', 'mainwp'); ?> </td></tr> <?php } ?> </tbody> </table> <table id="mainwp-table" class="wp-list-table widefat" cellspacing="0"> <caption><?php _e('Per Site Ignored Themes', 'mainwp'); ?> </caption> <thead> <tr> <th scope="col" class="manage-column" style="width: 300px"><?php _e('Site', 'mainwp'); ?> </th> <th scope="col" class="manage-column" style="width: 650px"><?php _e('Themes', 'mainwp'); ?> </th> <th scope="col" class="manage-column" style="text-align: right; padding-right: 10px"><?php if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) { if ($cnt > 0) { ?> <a href="#" class="button-primary mainwp-unignore-detail-all" onClick="return rightnow_themes_unignore_detail_all();"><?php _e('Allow All', 'mainwp'); ?> </a><?php } } ?> </th> </tr> </thead> <tbody id="ignored-themes-list" class="list:sites"> <?php if ($cnt > 0) { @MainWPDB::data_seek($websites, 0); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if ($website->is_ignoreThemeUpdates) { continue; } $decodedIgnoredThemes = json_decode($website->ignored_themes, true); if (!is_array($decodedIgnoredThemes) || count($decodedIgnoredThemes) == 0) { continue; } $first = true; foreach ($decodedIgnoredThemes as $ignoredTheme => $ignoredThemeName) { ?> <tr site_id="<?php echo $website->id; ?> " theme_slug="<?php echo urlencode($ignoredTheme); ?> "> <td> <span class="websitename" <?php if (!$first) { echo 'style="display: none;"'; } else { $first = false; } ?> > <a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $website->id); ?> "><?php echo stripslashes($website->name); ?> </a> </span> </td> <td> <strong><?php echo $ignoredThemeName; ?> </strong> (<?php echo $ignoredTheme; ?> ) </td> <td style="text-align: right; padding-right: 30px"> <?php if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) { ?> <a href="#" onClick="return rightnow_themes_unignore_detail('<?php echo urlencode($ignoredTheme); ?> ', <?php echo $website->id; ?> )"><i class="fa fa-check"></i> <?php _e('Allow', 'mainwp'); ?> </a> <?php } ?> </td> </tr> <?php } } @MainWPDB::free_result($websites); } else { ?> <tr><td colspan="3"><?php _e('No ignored themes', 'mainwp'); ?> </td></tr> <?php } ?> </tbody> </table> <?php self::renderFooter('Ignore'); }
public static function syncSite(&$pWebsite = null, $pForceFetch = false, $pAllowDisconnect = true) { if ($pWebsite == null) { return false; } $userExtension = MainWPDB::Instance()->getUserExtensionByUserId($pWebsite->userid); if ($userExtension == null) { return false; } MainWPUtility::endSession(); try { $pluginDir = $pWebsite->pluginDir; if ($pluginDir == '') { $pluginDir = $userExtension->pluginDir; } $cloneEnabled = apply_filters('mainwp_clone_enabled', false); $cloneSites = array(); if ($cloneEnabled) { $disallowedCloneSites = get_option('mainwp_clone_disallowedsites'); if ($disallowedCloneSites === false) { $disallowedCloneSites = array(); } $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser()); if ($websites) { while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if (in_array($website->id, $disallowedCloneSites)) { continue; } if ($website->id == $pWebsite->id) { continue; } $cloneSites[$website->id] = array('name' => $website->name, 'url' => $website->url, 'extauth' => $website->extauth, 'size' => $website->totalsize); } @MainWPDB::free_result($websites); } } $pluginConflicts = get_option('mainwp_pluginConflicts'); if ($pluginConflicts !== false) { $pluginConflicts = array_keys($pluginConflicts); } $themeConflicts = get_option('mainwp_themeConflicts'); if ($themeConflicts !== false) { $themeConflicts = array_keys($themeConflicts); } $othersData = apply_filters('mainwp-sync-others-data', array(), $pWebsite); $information = MainWPUtility::fetchUrlAuthed($pWebsite, 'stats', array('optimize' => get_option("mainwp_optimize") == 1 ? 1 : 0, 'heatMap' => MainWPExtensions::isExtensionAvailable('mainwp-heatmap-extension') ? $userExtension->heatMap : 0, 'pluginDir' => $pluginDir, 'cloneSites' => !$cloneEnabled ? 0 : urlencode(json_encode($cloneSites)), 'pluginConflicts' => json_encode($pluginConflicts), 'themeConflicts' => json_encode($themeConflicts), 'othersData' => json_encode($othersData)), true, $pForceFetch); $return = self::syncInformationArray($pWebsite, $information, '', 1, false, $pAllowDisconnect); return $return; } catch (MainWPException $e) { $sync_errors = ''; $offline_check_result = 1; if ($e->getMessage() == 'HTTPERROR') { $sync_errors = __('HTTP error', 'mainwp') . ($e->getMessageExtra() != null ? ' - ' . $e->getMessageExtra() : ''); $offline_check_result = -1; } else { if ($e->getMessage() == 'NOMAINWP') { $sync_errors = __('MainWP not detected', 'mainwp'); $offline_check_result = 1; } } return self::syncInformationArray($pWebsite, $information, $sync_errors, $offline_check_result, true, $pAllowDisconnect); } }
public static function renderIgnoredAbandoned() { $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser()); $userExtension = MainWPDB::Instance()->getUserExtension(); $decodedIgnoredPlugins = json_decode($userExtension->dismissed_plugins, true); $ignoredPlugins = is_array($decodedIgnoredPlugins) && count($decodedIgnoredPlugins) > 0; $cnt = 0; while ($websites && ($website = @MainWPDB::fetch_object($websites))) { $tmpDecodedDismissedPlugins = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'plugins_outdate_dismissed'), true); if (!is_array($tmpDecodedDismissedPlugins) || count($tmpDecodedDismissedPlugins) == 0) { continue; } $cnt++; } self::renderHeader('IgnoreAbandoned'); ?> <table id="mainwp-table" class="wp-list-table widefat" cellspacing="0"> <caption><?php _e('Globally Ignored Abandoned Plugins', 'mainwp'); ?> </caption> <thead> <tr> <th scope="col" class="manage-column" style="width: 300px"><?php _e('Plugin', 'mainwp'); ?> </th> <th scope="col" class="manage-column" style="width: 650px"><?php _e('Plugin File', 'mainwp'); ?> </th> <th scope="col" class="manage-column" style="text-align: right; padding-right: 10px"><?php if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) { if ($ignoredPlugins) { ?> <a href="#" class="button-primary mainwp-unignore-globally-all" onClick="return rightnow_plugins_abandoned_unignore_globally_all();"><?php _e('Allow All', 'mainwp'); ?> </a><?php } } ?> </th> </tr> </thead> <tbody id="globally-ignored-plugins-list" class="list:sites"> <?php if ($ignoredPlugins) { foreach ($decodedIgnoredPlugins as $ignoredPlugin => $ignoredPluginName) { ?> <tr plugin_slug="<?php echo urlencode($ignoredPlugin); ?> "> <td> <strong><a href="<?php echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . urlencode(dirname($ignoredPlugin)) . '&TB_iframe=true&width=640&height=477'; ?> " target="_blank" class="thickbox" title="More information about <?php echo $ignoredPluginName; ?> "><?php echo $ignoredPluginName; ?> </a></strong> </td> <td> <?php echo $ignoredPlugin; ?> </td> <td style="text-align: right; padding-right: 30px"> <?php if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) { ?> <a href="#" onClick="return rightnow_plugins_abandoned_unignore_globally('<?php echo urlencode($ignoredPlugin); ?> ')"><i class="fa fa-check"></i> <?php _e('Allow', 'mainwp'); ?> </a> <?php } ?> </td> </tr> <?php } ?> <?php } else { ?> <tr><td colspan="2"><?php _e('No ignored abandoned plugins', 'mainwp'); ?> </td></tr> <?php } ?> </tbody> </table> <table id="mainwp-table" class="wp-list-table widefat" cellspacing="0"> <caption><?php _e('Per Site Ignored Abandoned Plugins', 'mainwp'); ?> </caption> <thead> <tr> <th scope="col" class="manage-column" style="width: 300px"><?php _e('Site', 'mainwp'); ?> </th> <th scope="col" class="manage-column" style="width: 650px"><?php _e('Plugins', 'mainwp'); ?> </th> <th scope="col" class="manage-column" style="text-align: right; padding-right: 10px"><?php if ($cnt > 0) { ?> <a href="#" class="button-primary mainwp-unignore-detail-all" onClick="return rightnow_plugins_unignore_abandoned_detail_all();"><?php _e('Allow All', 'mainwp'); ?> </a><?php } ?> </th> </tr> </thead> <tbody id="ignored-plugins-list" class="list:sites"> <?php if ($cnt > 0) { @MainWPDB::data_seek($websites, 0); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { $decodedIgnoredPlugins = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'plugins_outdate_dismissed'), true); if (!is_array($decodedIgnoredPlugins) || count($decodedIgnoredPlugins) == 0) { continue; } $first = true; foreach ($decodedIgnoredPlugins as $ignoredPlugin => $ignoredPluginName) { ?> <tr site_id="<?php echo $website->id; ?> " plugin_slug="<?php echo urlencode($ignoredPlugin); ?> "> <td> <span class="websitename" <?php if (!$first) { echo 'style="display: none;"'; } else { $first = false; } ?> > <a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $website->id); ?> "><?php echo stripslashes($website->name); ?> </a> </span> </td> <td> <strong><a href="<?php echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . urlencode(dirname($ignoredPlugin)) . '&TB_iframe=true&width=640&height=477'; ?> " target="_blank" class="thickbox" title="More information about <?php echo $ignoredPluginName; ?> "><?php echo $ignoredPluginName; ?> </a></strong> (<?php echo $ignoredPlugin; ?> ) </td> <td style="text-align: right; padding-right: 30px"> <a href="#" onClick="return rightnow_plugins_unignore_abandoned_detail('<?php echo urlencode($ignoredPlugin); ?> ', <?php echo $website->id; ?> )"><i class="fa fa-check"></i> <?php _e('Allow', 'mainwp'); ?> </a> </td> </tr> <?php } } @MainWPDB::free_result($websites); } else { ?> <tr><td colspan="3"><?php _e('No ignored abandoned plugins', 'mainwp'); ?> </td></tr> <?php } ?> </tbody> </table> <?php self::renderFooter('IgnoreAbandoned'); }
public static function renderWidget($renew, $pExit = true) { $current_wpid = MainWPUtility::get_current_wpid(); if (empty($current_wpid)) { return; } $sql = MainWPDB::Instance()->getSQLWebsiteById($current_wpid); $websites = MainWPDB::Instance()->query($sql); $allThemes = array(); if ($websites) { $website = @MainWPDB::fetch_object($websites); if ($website && $website->themes != '') { $themes = json_decode($website->themes, 1); if (is_array($themes) && count($themes) != 0) { foreach ($themes as $theme) { $allThemes[] = $theme; } } } @MainWPDB::free_result($websites); } $actived_themes = MainWPUtility::getSubArrayHaving($allThemes, 'active', 1); $actived_themes = MainWPUtility::sortmulti($actived_themes, 'name', 'desc'); $inactive_themes = MainWPUtility::getSubArrayHaving($allThemes, 'active', 0); $inactive_themes = MainWPUtility::sortmulti($inactive_themes, 'name', 'desc'); ?> <div class="clear"> <a class="mainwp_action left mainwp_action_down themes_actived_lnk" href="#"><?php _e('Active', 'mainwp'); ?> (<?php echo count($actived_themes); ?> )</a><a class="mainwp_action mid themes_inactive_lnk right" href="#" ><?php _e('Inactive', 'mainwp'); ?> (<?php echo count($inactive_themes); ?> )</a><br/><br/> <div class="mainwp_themes_active"> <?php for ($i = 0; $i < count($actived_themes); $i++) { ?> <div class="mainwp-row mainwp-active"> <input class="themeName" type="hidden" name="name" value="<?php echo $actived_themes[$i]['name']; ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $website->id; ?> "/> <span class="mainwp-left-col"> <?php echo $actived_themes[$i]['name'] . " " . $actived_themes[$i]['version']; ?> </span> </div> <?php } ?> </div> <div class="mainwp_themes_inactive" style="display: none"> <?php for ($i = 0; $i < count($inactive_themes); $i++) { ?> <div class="mainwp-row mainwp-inactive"> <input class="themeName" type="hidden" name="name" value="<?php echo $inactive_themes[$i]['name']; ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $website->id; ?> "/> <span class="mainwp-left-col"> <?php echo $inactive_themes[$i]['name'] . " " . $inactive_themes[$i]['version']; ?> </span> <div class="mainwp-right-col themesAction"> <?php if (mainwp_current_user_can("dashboard", "activate_themes")) { ?> <a href="#" class="mainwp-theme-activate"><i class="fa fa-toggle-on"></i> <?php _e('Activate', 'mainwp'); ?> </a> | <?php } ?> <?php if (mainwp_current_user_can("dashboard", "delete_themes")) { ?> <a href="#" class="mainwp-theme-delete mainwp-red"><i class="fa fa-trash"></i> <?php _e('Delete', 'mainwp'); ?> </a> <?php } ?> </div> <div style="clear: left;"></div> <div class="mainwp-row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> </div> <div> </div> </div> <?php } ?> </div> </div> <div class="clear"></div> <?php if ($pExit == true) { exit; } }
public static function posting() { //Posts the saved sites ?> <div class="wrap"> <!-- <img src="--><?php //echo plugins_url('images/icons/mainwp-post.png', dirname(__FILE__)); ?> <!--" style="float: left; margin-right: 8px; margin-top: 7px ;" alt="MainWP Post" height="32"/>--> <h2>New Post</h2> <?php do_action("mainwp_bulkpost_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) { if (isset($_GET['id'])) { $id = $_GET['id']; $post = get_post($id); if ($post) { // die('<pre>'.print_r($post, 1).'</pre>'); $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))); /** @deprecated */ $post_category = base64_decode(get_post_meta($id, '_categories', true)); $post_tags = base64_decode(get_post_meta($id, '_tags', true)); $post_slug = base64_decode(get_post_meta($id, '_slug', true)); $post_custom = get_post_custom($id); // if (isset($post_custom['_tags'])) $post_custom['_tags'] = base64_decode(trim($post_custom['_tags'])); 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(); // $results = apply_filters('mainwp-pre-posting-posts', array($post), true); // $post = $results[0]; $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_tags' => $post_tags, '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(); if (count($dbwebsites) > 0) { $post_data = array('new_post' => base64_encode(serialize($new_post)), 'post_custom' => base64_encode(serialize($post_custom)), 'post_category' => base64_encode($post_category), 'post_featured_image' => base64_encode($post_featured_image), 'mainwp_upload_dir' => base64_encode(serialize($mainwp_upload_dir))); 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-post', $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); } ?> <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 $website->name; ?> </a> : <?php echo isset($output->ok[$website->id]) && $output->ok[$website->id] == 1 ? 'New post created. ' . "<a href=\"" . $output->link[$website->id] . "\" target=\"_blank\">View Post</a>" : 'ERROR: ' . $output->errors[$website->id]; ?> </p> <?php } ?> </div> <?php } // if ($post) } else { ?> <div class="error below-h2"> <p><strong><?php _e('ERROR', 'mainwp'); ?> </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=PostBulkAdd" 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 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> </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> </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> </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> </div> </div> <?php } ?> </div> </div> <div class="clear"></div> <?php if ($pExit == true) { exit; } }
public static function renderSites() { $globalView = true; $current_wpid = MainWPUtility::get_current_wpid(); if ($current_wpid) { $sql = MainWPDB::Instance()->getSQLWebsiteById($current_wpid); $globalView = false; } else { $sql = MainWPDB::Instance()->getSQLWebsitesForCurrentUser(); } $websites = MainWPDB::Instance()->query($sql); if (!$websites) { return; } $userExtension = MainWPDB::Instance()->getUserExtension(); $total_themesIgnored = $total_pluginsIgnored = 0; if ($globalView) { $decodedIgnoredPlugins = json_decode($userExtension->ignored_plugins, true); $decodedIgnoredThemes = json_decode($userExtension->ignored_themes, true); $total_pluginsIgnored = is_array($decodedIgnoredPlugins) ? count($decodedIgnoredPlugins) : 0; $total_themesIgnored = is_array($decodedIgnoredThemes) ? count($decodedIgnoredThemes) : 0; } $globalIgnoredPluginConflicts = json_decode($userExtension->ignored_pluginConflicts, true); if (!is_array($globalIgnoredPluginConflicts)) { $globalIgnoredPluginConflicts = array(); } $globalIgnoredThemeConflicts = json_decode($userExtension->ignored_themeConflicts, true); if (!is_array($globalIgnoredThemeConflicts)) { $globalIgnoredThemeConflicts = array(); } $total_wp_upgrades = 0; $total_plugin_upgrades = 0; $total_theme_upgrades = 0; $total_sync_errors = 0; $total_uptodate = 0; $total_offline = 0; $total_conflict = 0; $allPlugins = array(); $pluginsInfo = array(); $allThemes = array(); $themesInfo = array(); @MainWPDB::data_seek($websites, 0); $currentSite = null; $pluginsIgnored_perSites = $themesIgnored_perSites = array(); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if (!$globalView) { $currentSite = $website; } $wp_upgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'wp_upgrades'), true); if ($website->is_ignoreCoreUpdates) { $wp_upgrades = array(); } if (is_array($wp_upgrades) && count($wp_upgrades) > 0) { $total_wp_upgrades++; } $plugin_upgrades = json_decode($website->plugin_upgrades, true); if ($website->is_ignorePluginUpdates) { $plugin_upgrades = array(); } $theme_upgrades = json_decode($website->theme_upgrades, true); if ($website->is_ignoreThemeUpdates) { $theme_upgrades = array(); } $decodedPremiumUpgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'premium_upgrades'), true); if (is_array($decodedPremiumUpgrades)) { foreach ($decodedPremiumUpgrades as $crrSlug => $premiumUpgrade) { $premiumUpgrade['premium'] = true; if ($premiumUpgrade['type'] == 'plugin') { if (!is_array($plugin_upgrades)) { $plugin_upgrades = array(); } if (!$website->is_ignorePluginUpdates) { $plugin_upgrades[$crrSlug] = $premiumUpgrade; } } else { if ($premiumUpgrade['type'] == 'theme') { if (!is_array($theme_upgrades)) { $theme_upgrades = array(); } if (!$website->is_ignoreThemeUpdates) { $theme_upgrades[$crrSlug] = $premiumUpgrade; } } } } } if (is_array($plugin_upgrades)) { $ignored_plugins = json_decode($website->ignored_plugins, true); if (is_array($ignored_plugins)) { $plugin_upgrades = array_diff_key($plugin_upgrades, $ignored_plugins); } $ignored_plugins = json_decode($userExtension->ignored_plugins, true); if (is_array($ignored_plugins)) { $plugin_upgrades = array_diff_key($plugin_upgrades, $ignored_plugins); } $total_plugin_upgrades += count($plugin_upgrades); } if (is_array($theme_upgrades)) { $ignored_themes = json_decode($website->ignored_themes, true); if (is_array($ignored_themes)) { $theme_upgrades = array_diff_key($theme_upgrades, $ignored_themes); } $ignored_themes = json_decode($userExtension->ignored_themes, true); if (is_array($ignored_themes)) { $theme_upgrades = array_diff_key($theme_upgrades, $ignored_themes); } $total_theme_upgrades += count($theme_upgrades); } $ignored_plugins = json_decode($website->ignored_plugins, true); $ignored_themes = json_decode($website->ignored_themes, true); if (is_array($ignored_plugins)) { $ignored_plugins = array_filter($ignored_plugins); $pluginsIgnored_perSites = array_merge($pluginsIgnored_perSites, $ignored_plugins); } if (is_array($ignored_themes)) { $ignored_themes = array_filter($ignored_themes); $themesIgnored_perSites = array_merge($themesIgnored_perSites, $ignored_themes); } if ($userExtension->site_view == 0) { //Keep track of all the plugins & themes if (is_array($plugin_upgrades)) { foreach ($plugin_upgrades as $slug => $plugin_upgrade) { if (!isset($allPlugins[$slug])) { $allPlugins[$slug] = 1; } else { $allPlugins[$slug]++; } $pluginsInfo[$slug] = array('name' => $plugin_upgrade['Name'], 'slug' => $plugin_upgrade['update']['slug'], 'premium' => isset($plugin_upgrade['premium']) ? $plugin_upgrade['premium'] : 0); } } ksort($allPlugins); if (is_array($theme_upgrades)) { foreach ($theme_upgrades as $slug => $theme_upgrade) { if (!isset($allThemes[$slug])) { $allThemes[$slug] = 1; } else { $allThemes[$slug]++; } $themesInfo[$slug] = array('name' => $theme_upgrade['Name'], 'premium' => isset($theme_upgrade['premium']) ? $theme_upgrade['premium'] : 0); } } ksort($allThemes); } if ($website->sync_errors != '') { $total_sync_errors++; } if ($website->uptodate == 1) { $total_uptodate++; } if ($website->offline_check_result == -1) { $total_offline++; } $pluginConflicts = json_decode($website->pluginConflicts, true); $themeConflicts = json_decode($website->themeConflicts, true); $ignoredPluginConflicts = json_decode($website->ignored_pluginConflicts, true); if (!is_array($ignoredPluginConflicts)) { $ignoredPluginConflicts = array(); } $ignoredThemeConflicts = json_decode($website->ignored_themeConflicts, true); if (!is_array($ignoredThemeConflicts)) { $ignoredThemeConflicts = array(); } $isConflict = false; if (count($pluginConflicts) > 0) { foreach ($pluginConflicts as $pluginConflict) { if (!in_array($pluginConflict, $ignoredPluginConflicts) && !in_array($pluginConflict, $globalIgnoredPluginConflicts)) { $isConflict = true; } } } if (!$isConflict && count($themeConflicts) > 0) { foreach ($themeConflicts as $themeConflict) { if (!in_array($themeConflict, $ignoredThemeConflicts) && !in_array($themeConflict, $globalIgnoredThemeConflicts)) { $isConflict = true; } } } if ($isConflict) { $total_conflict++; } } $errorsDismissed = get_user_option('mainwp_syncerrors_dismissed'); ?> <div class="clear"> <div id="mainwp-right-now-message" class="mainwp-right-now-error" <?php if ($total_sync_errors <= 0 || $globalView && $errorsDismissed) { echo ' style="display: none;"'; } ?> > <p> <?php if ($globalView) { ?> <span id="mainwp-right-now-message-content"><?php echo $total_sync_errors; ?> <?php echo _n('Site Timed Out / Errored', 'Sites Timed Out / Errored', $total_sync_errors, 'mainwp'); ?> (There was an error syncing some of your sites. <a href="http://docs.mainwp.com/sync-error/">Please check this help doc for possible solutions.</a>)</span><span style="float: right;"><a href="#" id="mainwp-right-now-message-dismiss"><i class="fa fa-times-circle"></i> <?php _e('Dismiss', 'mainwp'); ?> </a></span> <?php } else { ?> <span id="mainwp-right-now-message-content"><a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $currentSite->id); ?> "><?php echo stripslashes($currentSite->name); ?> </a> <?php _e('Timed Out / Errored', 'mainwp'); ?> (There was an error syncing some of your sites. <a href="http://docs.mainwp.com/sync-error/">Please check this help doc for possible solutions.</a>)</span> <?php } ?> </p> </div> </div> <?php $total_pluginsIgnored += count($pluginsIgnored_perSites); $total_themesIgnored += count($themesIgnored_perSites); //WP Upgrades part: $total_upgrades = $total_wp_upgrades + $total_plugin_upgrades + $total_theme_upgrades; ?> <div class="clear"> <div class="mainwp-row-top"> <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php echo $total_upgrades; ?> </span> <?php _e('Upgrade', 'mainwp'); if (count($total_upgrades) > 1) { ?> s<?php } ?> <?php _e('available', 'mainwp'); ?> </span> <span class="mainwp-mid-col"> </span> <?php if (mainwp_current_user_can("dashboard", "update_wordpress") && mainwp_current_user_can("dashboard", "update_plugins") && mainwp_current_user_can("dashboard", "update_themes")) { ?> <span class="mainwp-right-col"><?php if ($total_upgrades == 0) { ?> <a class="button" disabled="disabled"><?php _e('Upgrade Everything', 'mainwp'); ?> </a><?php } else { ?> <a href="#" onClick="return rightnow_global_upgrade_all();" class="mainwp-upgrade-button button"><?php _e('Upgrade Everything', 'mainwp'); ?> </a><?php } ?> </span> <?php } ?> </div> </div> <div class="clear"> <div class="mainwp-row"> <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php echo $total_wp_upgrades; ?> </span> <?php _e('WordPress upgrade', 'mainwp'); if (count($total_wp_upgrades) > 1) { ?> s<?php } ?> <?php _e('available', 'mainwp'); ?> </span> <span class="mainwp-mid-col"> </span> <span class="mainwp-right-col"> <a href="#" id="mainwp_upgrades_show" onClick="return rightnow_show('upgrades');"><i class="fa fa-eye-slash"></i> <?php _e('Show', 'mainwp'); ?> </a> <?php if (mainwp_current_user_can("dashboard", "update_wordpress")) { if ($total_wp_upgrades > 0) { ?> <a href="#" onClick="return rightnow_wordpress_global_upgrade_all();" class="button-primary"><?php echo _n('Upgrade', 'Upgrade All', $total_wp_upgrades, 'mainwp'); ?> </a> <?php } else { ?> <a class="button" disabled="disabled"><?php _e('No Upgrades', 'mainwp'); ?> </a> <?php } ?> <?php } ?> </span> </div> <div id="wp_upgrades" style="display: none"> <?php @MainWPDB::data_seek($websites, 0); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if ($website->is_ignoreCoreUpdates) { continue; } $wp_upgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'wp_upgrades'), true); if (count($wp_upgrades) == 0 && $website->sync_errors == '') { continue; } ?> <div class="mainwp-row mainwp_wordpress_upgrade" site_id="<?php echo $website->id; ?> " site_name="<?php echo rawurlencode($website->name); ?> " updated="<?php echo count($wp_upgrades) > 0 ? '0' : '1'; ?> "> <span class="mainwp-left-col"><a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $website->id); ?> "><?php echo stripslashes($website->name); ?> </a><input type="hidden" id="wp_upgraded_<?php echo $website->id; ?> " value="<?php if (count($wp_upgrades) > 0) { echo '0'; } else { echo '1'; } ?> "/></span> <span class="mainwp-mid-col wordpressInfo" id="wp_upgrade_<?php echo $website->id; ?> "><?php if (count($wp_upgrades) > 0) { echo $wp_upgrades['current'] . " to " . $wp_upgrades['new']; } else { if ($website->sync_errors != '') { echo __('Site Error - No update Information available', 'mainwp'); } else { echo __("Hooray, No Updates Available!", 'mainwp'); } } ?> </span> <span class="mainwp-right-col wordpressAction"><div id="wp_upgradebuttons_<?php echo $website->id; ?> "> <?php if (mainwp_current_user_can("dashboard", "update_wordpress")) { if (count($wp_upgrades) > 0) { ?> <a href="#" class="mainwp-upgrade-button button" onClick="rightnow_upgrade(<?php echo $website->id; ?> )"><?php _e('Upgrade', 'mainwp'); ?> </a> <?php } } ?> <a href="<?php echo $website->url; ?> " target="_blank" class="mainwp-open-button button" ><?php _e('Open', 'mainwp'); ?> </a></div></span> </div> <?php } ?> </div> </div> <?php //WP plugin upgrades! ?> <div class="clear"> <div class="mainwp-row"> <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php echo $total_plugin_upgrades; ?> </span> <?php _e('Plugin upgrade', 'mainwp'); if ($total_plugin_upgrades > 1) { ?> s<?php } ?> <?php _e('available', 'mainwp'); ?> </span> <span class="mainwp-mid-col"><a href="<?php echo admin_url('admin.php?page=PluginsIgnore'); ?> "><?php _e('Ignored', 'mainwp'); ?> (<?php echo $total_pluginsIgnored; ?> )</a></span> <span class="mainwp-right-col"><a href="#" id="mainwp_plugin_upgrades_show" onClick="return rightnow_show('plugin_upgrades');"><i class="fa fa-eye-slash"></i> <?php _e('Show', 'mainwp'); ?> </a> <?php if (mainwp_current_user_can("dashboard", "update_plugins")) { if ($total_plugin_upgrades > 0 && $userExtension->site_view == 1) { ?> <a href="#" onClick="return rightnow_plugins_global_upgrade_all();" class="button-primary"><?php echo _n('Upgrade', 'Upgrade All', $total_plugin_upgrades, 'mainwp'); ?> </a><?php } else { if ($total_plugin_upgrades > 0 && $userExtension->site_view == 0) { ?> <a href="#" onClick="return rightnow_plugins_global_upgrade_all();" class="button-primary"><?php echo _n('Upgrade', 'Upgrade All', $total_plugin_upgrades, 'mainwp'); ?> </a><?php } else { ?> <a class="button" disabled="disabled"><?php _e('No Upgrades', 'mainwp'); ?> </a> <?php } } } ?> </span> </div> <div id="wp_plugin_upgrades" style="display: none"> <?php if ($userExtension->site_view == 1) { @MainWPDB::data_seek($websites, 0); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if ($website->is_ignorePluginUpdates) { continue; } $plugin_upgrades = json_decode($website->plugin_upgrades, true); $decodedPremiumUpgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'premium_upgrades'), true); if (is_array($decodedPremiumUpgrades)) { foreach ($decodedPremiumUpgrades as $crrSlug => $premiumUpgrade) { $premiumUpgrade['premium'] = true; if ($premiumUpgrade['type'] == 'plugin') { if (!is_array($plugin_upgrades)) { $plugin_upgrades = array(); } $plugin_upgrades[$crrSlug] = $premiumUpgrade; } } } $ignored_plugins = json_decode($website->ignored_plugins, true); if (is_array($ignored_plugins)) { $plugin_upgrades = array_diff_key($plugin_upgrades, $ignored_plugins); } $ignored_plugins = json_decode($userExtension->ignored_plugins, true); if (is_array($ignored_plugins)) { $plugin_upgrades = array_diff_key($plugin_upgrades, $ignored_plugins); } if ($globalView) { ?> <div class="mainwp-row"> <span class="mainwp-left-col"><a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $website->id); ?> "><?php echo stripslashes($website->name); ?> </a><input type="hidden" id="wp_upgraded_plugin_<?php echo $website->id; ?> " value="<?php if (count($plugin_upgrades) > 0) { echo '0'; } else { echo '1'; } ?> "/></span> <span class="mainwp-mid-col" id="wp_upgrade_plugin_<?php echo $website->id; ?> "> <?php if (count($plugin_upgrades) > 0) { ?> <a href="#" id="mainwp_plugin_upgrades_<?php echo $website->id; ?> _show" onClick="return rightnow_show('plugin_upgrades_<?php echo $website->id; ?> ', true);"><?php echo count($plugin_upgrades); ?> <?php _e('Upgrade', 'mainwp'); echo count($plugin_upgrades) > 1 ? 's' : ''; ?> </a> <?php } else { if ($website->sync_errors != '') { echo __('Site Error - No update Information available', 'mainwp'); } else { echo __("Hooray, No Updates Available!", 'mainwp'); } } ?> </span> <span class="mainwp-right-col"><div id="wp_upgradebuttons_plugin_<?php echo $website->id; ?> "> <?php if (mainwp_current_user_can("dashboard", "update_plugins")) { if (count($plugin_upgrades) > 0) { ?> <a href="#" class="mainwp-upgrade-button button" onClick="return rightnow_upgrade_plugin_all(<?php echo $website->id; ?> )"><?php echo _n('Upgrade', 'Upgrade All', count($plugin_upgrades), 'mainwp'); ?> </a> <?php } ?> <?php } ?> <a href="<?php echo $website->url; ?> " target="_blank" class="mainwp-open-button button"><?php _e('Open', 'mainwp'); ?> </a> </div></span> </div> <?php } ?> <div id="wp_plugin_upgrades_<?php echo $website->id; ?> " site_id="<?php echo $website->id; ?> " site_name="<?php echo rawurlencode($website->name); ?> " <?php if ($globalView) { ?> style="display: none"<?php } ?> > <?php foreach ($plugin_upgrades as $plugin_name => $plugin_upgrade) { $plugin_name = urlencode($plugin_name); ?> <div class="mainwp-row" plugin_slug="<?php echo $plugin_name; ?> " premium="<?php echo isset($plugin_upgrade['premium']) ? $plugin_upgrade['premium'] : 0 ? 1 : 0; ?> " updated="0"> <span class="mainwp-left-col"> <?php if ($globalView) { ?> <?php } ?> <a href="<?php echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_upgrade['update']['slug'] . '&url=' . (isset($plugin_upgrade['PluginURI']) ? rawurlencode($plugin_upgrade['PluginURI']) : '') . '&name=' . rawurlencode($plugin_upgrade['Name']) . '&TB_iframe=true&width=640&height=477'; ?> " target="_blank" class="thickbox" title="More information about <?php echo $plugin_upgrade['Name']; ?> "><?php echo $plugin_upgrade['Name']; ?> </a><input type="hidden" id="wp_upgraded_plugin_<?php echo $website->id; ?> _<?php echo $plugin_name; ?> " value="0"/></span> <span class="mainwp-mid-col pluginsInfo" id="wp_upgrade_plugin_<?php echo $website->id; ?> _<?php echo $plugin_name; ?> "><?php echo $plugin_upgrade['Version']; ?> to <?php echo $plugin_upgrade['update']['new_version']; ?> </span> <span class="mainwp-right-col pluginsAction"> <div id="wp_upgradebuttons_plugin_<?php echo $website->id; ?> _<?php echo $plugin_name; ?> "> <?php if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) { ?> <a href="#" onClick="return rightnow_plugins_ignore_detail('<?php echo $plugin_name; ?> ', '<?php echo urlencode($plugin_upgrade['Name']); ?> ', <?php echo $website->id; ?> )" class="button"><?php _e('Ignore', 'mainwp'); ?> </a> <?php } ?> <?php if (mainwp_current_user_can("dashboard", "update_plugins")) { ?> <a href="#" class="mainwp-upgrade-button button" onClick="return rightnow_upgrade_plugin(<?php echo $website->id; ?> , '<?php echo $plugin_name; ?> ')"><?php _e('Upgrade', 'mainwp'); ?> </a> <?php } ?> </div> </span> </div> <?php } ?> </div> <?php } } else { foreach ($allPlugins as $slug => $cnt) { $plugin_name = urlencode($slug); if ($globalView) { ?> <div class="mainwp-row"> <span class="mainwp-left-col"> <a href="<?php echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . $pluginsInfo[$slug]['slug'] . '&url=' . (isset($plugin_upgrade['PluginURI']) ? rawurlencode($plugin_upgrade['PluginURI']) : '') . '&name=' . rawurlencode($plugin_upgrade['Name']) . '&TB_iframe=true&width=640&height=477'; ?> " target="_blank" class="thickbox" title="More information about <?php echo $pluginsInfo[$slug]['name']; ?> "> <?php echo $pluginsInfo[$slug]['name']; ?> </a> </span> <span class="mainwp-mid-col"> <a href="#" onClick="return rightnow_plugins_detail('<?php echo $plugin_name; ?> ');"> <?php echo $cnt; ?> <?php _e('Upgrade', 'mainwp'); echo $cnt > 1 ? 's' : ''; ?> </a> </span> <span class="mainwp-right-col"> <?php if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) { ?> <a href="#" class="button" onClick="return rightnow_plugins_ignore_all('<?php echo $plugin_name; ?> ', '<?php echo urlencode($pluginsInfo[$slug]['name']); ?> ')"><?php _e('Ignore Globally', 'mainwp'); ?> </a> <?php } ?> <?php if (mainwp_current_user_can("dashboard", "update_plugins")) { ?> <?php if ($cnt > 0) { ?> <a href="#" class="mainwp-upgrade-button button" onClick="return rightnow_plugins_upgrade_all('<?php echo $plugin_name; ?> ', '<?php echo urlencode($pluginsInfo[$slug]['name']); ?> ')"><?php echo _n('Upgrade', 'Upgrade All', $cnt, 'mainwp'); ?> </a><?php } else { ?> <a class="button" disabled="disabled"><?php _e('No Upgrades', 'mainwp'); ?> </a> <?php } ?> <?php } ?> </span> </div> <?php } ?> <div plugin_slug="<?php echo $plugin_name; ?> " plugin_name="<?php echo urlencode($pluginsInfo[$slug]['name']); ?> " premium="<?php echo $pluginsInfo[$slug]['premium'] ? 1 : 0; ?> " <?php if ($globalView) { ?> style="display: none"<?php } ?> > <?php @MainWPDB::data_seek($websites, 0); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if ($website->is_ignorePluginUpdates) { continue; } $plugin_upgrades = json_decode($website->plugin_upgrades, true); $decodedPremiumUpgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'premium_upgrades'), true); if (is_array($decodedPremiumUpgrades)) { foreach ($decodedPremiumUpgrades as $crrSlug => $premiumUpgrade) { $premiumUpgrade['premium'] = true; if ($premiumUpgrade['type'] == 'plugin') { if (!is_array($plugin_upgrades)) { $plugin_upgrades = array(); } $plugin_upgrades[$crrSlug] = $premiumUpgrade; } } } $ignored_plugins = json_decode($website->ignored_plugins, true); if (is_array($ignored_plugins)) { $plugin_upgrades = array_diff_key($plugin_upgrades, $ignored_plugins); } if (!isset($plugin_upgrades[$slug])) { continue; } $plugin_upgrade = $plugin_upgrades[$slug]; ?> <div class="mainwp-row" site_id="<?php echo $website->id; ?> " site_name="<?php echo rawurlencode($website->name); ?> " updated="0"> <span class="mainwp-left-col"> <?php if ($globalView) { ?> <a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $website->id); ?> "><?php echo stripslashes($website->name); ?> </a> <?php } else { ?> <a href="<?php echo admin_url() . 'plugin-install.php?tab=plugin-information&plugin=' . $pluginsInfo[$slug]['slug'] . '&TB_iframe=true&width=640&height=477'; ?> " target="_blank" class="thickbox" title="More information about <?php echo $pluginsInfo[$slug]['name']; ?> "> <?php echo $pluginsInfo[$slug]['name']; ?> </a> <?php } ?> </span> <span class="mainwp-mid-col pluginsInfo"><?php echo $plugin_upgrade['Version']; ?> to <?php echo $plugin_upgrade['update']['new_version']; ?> </span> <span class="mainwp-right-col pluginsAction"> <?php if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) { ?> <a href="#" class="button" onClick="return rightnow_plugins_ignore_detail('<?php echo $plugin_name; ?> ', '<?php echo urlencode($plugin_upgrade['Name']); ?> ', <?php echo $website->id; ?> )"><?php _e('Ignore', 'mainwp'); ?> </a> <?php } ?> <?php if (mainwp_current_user_can("dashboard", "update_plugins")) { ?> <a href="#" class="mainwp-upgrade-button button" onClick="return rightnow_plugins_upgrade('<?php echo $plugin_name; ?> ', <?php echo $website->id; ?> )"><?php _e('Upgrade', 'mainwp'); ?> </a> <?php } ?> </span> </div> <?php } ?> </div> <?php } } ?> </div> </div> <?php //WP theme upgrades! ?> <div class="clear"> <div class="mainwp-row"> <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php echo $total_theme_upgrades; ?> </span> <?php _e('Theme upgrade', 'mainwp'); if ($total_theme_upgrades > 1) { ?> s<?php } ?> <?php _e('available', 'mainwp'); ?> </span> <span class="mainwp-mid-col"><a href="<?php echo admin_url('admin.php?page=ThemesIgnore'); ?> "><?php _e('Ignored', 'mainwp'); ?> (<?php echo $total_themesIgnored; ?> )</a></span> <span class="mainwp-right-col"><a href="#" id="mainwp_theme_upgrades_show" onClick="return rightnow_show('theme_upgrades');"><i class="fa fa-eye-slash"></i> <?php _e('Show', 'mainwp'); ?> </a> <?php if (mainwp_current_user_can("dashboard", "update_themes")) { ?> <?php if ($total_theme_upgrades > 0 && $userExtension->site_view == 1) { ?> <a href="#" onClick="return rightnow_themes_global_upgrade_all();" class="button-primary"><?php echo _n('Upgrade', 'Upgrade All', $total_theme_upgrades, 'mainwp'); ?> </a><?php } else { if ($total_theme_upgrades > 0 && $userExtension->site_view == 0) { ?> <a href="#" onClick="return rightnow_themes_global_upgrade_all();" class="button-primary"><?php echo _n('Upgrade', 'Upgrade All', $total_theme_upgrades, 'mainwp'); ?> </a><?php } else { ?> <a class="button" disabled="disabled"><?php _e('No Upgrades', 'mainwp'); ?> </a> <?php } } ?> <?php } ?> </span> </div> <div id="wp_theme_upgrades" style="display: none"> <?php if ($userExtension->site_view == 1) { @MainWPDB::data_seek($websites, 0); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if ($website->is_ignoreThemeUpdates) { continue; } $theme_upgrades = json_decode($website->theme_upgrades, true); $decodedPremiumUpgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'premium_upgrades'), true); if (is_array($decodedPremiumUpgrades)) { foreach ($decodedPremiumUpgrades as $crrSlug => $premiumUpgrade) { $premiumUpgrade['premium'] = true; if ($premiumUpgrade['type'] == 'theme') { if (!is_array($theme_upgrades)) { $theme_upgrades = array(); } $theme_upgrades[$crrSlug] = $premiumUpgrade; } } } $ignored_themes = json_decode($website->ignored_themes, true); if (is_array($ignored_themes)) { $theme_upgrades = array_diff_key($theme_upgrades, $ignored_themes); } $ignored_themes = json_decode($userExtension->ignored_themes, true); if (is_array($ignored_themes)) { $theme_upgrades = array_diff_key($theme_upgrades, $ignored_themes); } if ($globalView) { ?> <div class="mainwp-row"> <span class="mainwp-left-col"><a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $website->id); ?> "><?php echo stripslashes($website->name); ?> </a><input type="hidden" id="wp_upgraded_theme_<?php echo $website->id; ?> " value="<?php if (count($theme_upgrades) > 0) { echo '0'; } else { echo '1'; } ?> "/></span> <span class="mainwp-mid-col" id="wp_upgrade_theme_<?php echo $website->id; ?> "> <?php if (count($theme_upgrades) > 0) { ?> <a href="#" id="mainwp_theme_upgrades_<?php echo $website->id; ?> _show" onClick="return rightnow_show('theme_upgrades_<?php echo $website->id; ?> ', true);"><?php echo count($theme_upgrades); ?> <?php _e('Upgrade', 'mainwp'); echo count($theme_upgrades) > 1 ? 's' : ''; ?> </a> <?php } else { if ($website->sync_errors != '') { echo __('Site Error - No update Information available', 'mainwp'); } else { echo __("Hooray, No Updates Available!", 'mainwp'); } } ?> </span> <span class="mainwp-right-col"> <div id="wp_upgradebuttons_theme_<?php echo $website->id; ?> "> <?php if (mainwp_current_user_can("dashboard", "update_themes")) { ?> <?php if (count($theme_upgrades) > 0) { ?> <a href="#" class="mainwp-upgrade-button button" onClick="return rightnow_upgrade_theme_all(<?php echo $website->id; ?> )"><?php echo _n('Upgrade', 'Upgrade All', count($theme_upgrades), 'mainwp'); ?> </a> <?php } ?> <?php } ?> <a href="<?php echo $website->url; ?> " target="_blank" class="mainwp-open-button button"><?php _e('Open', 'mainwp'); ?> </a> </div> </span> </div> <?php } ?> <div id="wp_theme_upgrades_<?php echo $website->id; ?> " site_id="<?php echo $website->id; ?> " site_name="<?php echo rawurlencode($website->name); ?> " <?php if ($globalView) { ?> style="display: none"<?php } ?> > <?php foreach ($theme_upgrades as $theme_name => $theme_upgrade) { $theme_name = urlencode($theme_name); ?> <div class="mainwp-row" theme_slug="<?php echo $theme_name; ?> " theme_name="<?php echo urlencode($themesInfo[$slug]['name']); ?> " premium="<?php echo $themesInfo[$slug]['premium'] ? 1 : 0; ?> " updated="0"> <span class="mainwp-left-col"><?php if ($globalView) { ?> <?php } echo $theme_upgrade['Name']; ?> <input type="hidden" id="wp_upgraded_theme_<?php echo $website->id; ?> _<?php echo $theme_name; ?> " value="0"/></span> <span class="mainwp-mid-col pluginsInfo" id="wp_upgrade_theme_<?php echo $website->id; ?> _<?php echo $theme_name; ?> "><?php echo $theme_upgrade['Version']; ?> to <?php echo $theme_upgrade['update']['new_version']; ?> </span> <span class="mainwp-right-col pluginsAction"> <div id="wp_upgradebuttons_theme_<?php echo $website->id; ?> _<?php echo $theme_name; ?> "> <?php if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) { ?> <a href="#" class="button" onClick="return rightnow_themes_ignore_detail('<?php echo $theme_name; ?> ', '<?php echo urlencode($theme_upgrade['Name']); ?> ', <?php echo $website->id; ?> )"><?php _e('Ignore', 'mainwp'); ?> </a> <?php } ?> <?php if (mainwp_current_user_can("dashboard", "update_themes")) { ?> <a href="#" class="mainwp-upgrade-button button" onClick="rightnow_upgrade_theme(<?php echo $website->id; ?> , '<?php echo $theme_name; ?> ')"><?php _e('Upgrade', 'mainwp'); ?> </a> <?php } ?> </div> </span> </div> <?php } ?> </div> <?php } } else { foreach ($allThemes as $slug => $cnt) { $theme_name = urlencode($slug); if ($globalView) { ?> <div class="mainwp-row"> <span class="mainwp-left-col"> <?php echo $themesInfo[$slug]['name']; ?> </span> <span class="mainwp-mid-col"> <a href="#" onClick="return rightnow_themes_detail('<?php echo $theme_name; ?> ');"> <?php echo $cnt; ?> <?php _e('Upgrade', 'mainwp'); echo $cnt > 1 ? 's' : ''; ?> </a> </span> <span class="mainwp-right-col"> <?php if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) { ?> <a href="#" class="button" onClick="return rightnow_themes_ignore_all('<?php echo $theme_name; ?> ', '<?php echo urlencode($themesInfo[$slug]['name']); ?> ')"><?php _e('Ignore Globally', 'mainwp'); ?> </a> <?php } ?> <?php if (mainwp_current_user_can("dashboard", "update_themes")) { ?> <?php if ($cnt > 0) { ?> <a href="#" class="mainwp-upgrade-button button" onClick="return rightnow_themes_upgrade_all('<?php echo $theme_name; ?> ', '<?php echo urlencode($themesInfo[$slug]['name']); ?> ')"><?php echo _n('Upgrade', 'Upgrade All', $cnt, 'mainwp'); ?> </a><?php } else { ?> <a class="button" disabled="disabled"><?php _e('No Upgrades', 'mainwp'); ?> </a> <?php } ?> <?php } ?> </span> </div> <?php } ?> <div theme_slug="<?php echo $theme_name; ?> " theme_name="<?php echo urlencode($themesInfo[$slug]['name']); ?> " premium="<?php echo $themesInfo[$slug]['premium'] ? 1 : 0; ?> " <?php if ($globalView) { ?> style="display: none"<?php } ?> > <?php @MainWPDB::data_seek($websites, 0); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if ($website->is_ignoreThemeUpdates) { continue; } $theme_upgrades = json_decode($website->theme_upgrades, true); $decodedPremiumUpgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'premium_upgrades'), true); if (is_array($decodedPremiumUpgrades)) { foreach ($decodedPremiumUpgrades as $crrSlug => $premiumUpgrade) { $premiumUpgrade['premium'] = true; if ($premiumUpgrade['type'] == 'theme') { if (!is_array($theme_upgrades)) { $theme_upgrades = array(); } $theme_upgrades[$crrSlug] = $premiumUpgrade; } } } $ignored_themes = json_decode($website->ignored_themes, true); if (is_array($ignored_themes)) { $theme_upgrades = array_diff_key($theme_upgrades, $ignored_themes); } if (!isset($theme_upgrades[$slug])) { continue; } $theme_upgrade = $theme_upgrades[$slug]; ?> <div class="mainwp-row" site_id="<?php echo $website->id; ?> " site_name="<?php echo rawurlencode($website->name); ?> " updated="0"> <span class="mainwp-left-col"> <?php if ($globalView) { ?> <a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $website->id); ?> "><?php echo stripslashes($website->name); ?> </a> <?php } else { echo $themesInfo[$slug]['name']; } ?> </span> <span class="mainwp-mid-col pluginsInfo"><?php echo $theme_upgrade['Version']; ?> to <?php echo $theme_upgrade['update']['new_version']; ?> </span> <span class="mainwp-right-col pluginsAction"> <?php if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) { ?> <a href="#" class="button" onClick="return rightnow_themes_ignore_detail('<?php echo $theme_name; ?> ', '<?php echo urlencode($theme_upgrade['Name']); ?> ', <?php echo $website->id; ?> )"><?php _e('Ignore', 'mainwp'); ?> </a> <?php } ?> <?php if (mainwp_current_user_can("dashboard", "update_themes")) { ?> <a href="#" class="mainwp-upgrade-button button" onClick="return rightnow_themes_upgrade('<?php echo $theme_name; ?> ', <?php echo $website->id; ?> )"><?php _e('Upgrade', 'mainwp'); ?> </a> <?php } ?> </span> </div> <?php } ?> </div> <?php } } ?> </div> </div> <?php //Sync errors! if ($total_sync_errors > 0) { ?> <div class="clear"> <div class="mainwp-row"> <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php echo $total_sync_errors; ?> </span> Error<?php if ($total_sync_errors > 1) { ?> s<?php } ?> </span> <span class="mainwp-mid-col"> </span> <span class="mainwp-right-col"><a href="#" id="mainwp_errors_show" onClick="return rightnow_show('errors');"><i class="fa fa-eye-slash"></i> <?php _e('Show', 'mainwp'); ?> </a></span> </div> <div id="wp_errors" style="display: none"> <?php @MainWPDB::data_seek($websites, 0); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if ($website->sync_errors == '') { continue; } ?> <div class="mainwp-row"> <span class="mainwp-left-col"><a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $website->id); ?> "><?php echo stripslashes($website->name); ?> </a></span> <span class="mainwp-mid-col"><?php echo $website->sync_errors; ?> </span> <span class="mainwp-right-col"><a href="#" class="mainwp_rightnow_site_reconnect" siteid="<?php echo $website->id; ?> "><?php _e('Reconnect', 'mainwp'); ?> </a> | <a href="<?php echo $website->url; ?> " target="_blank"><?php _e('Open', 'mainwp'); ?> </a></span> </div> <?php } ?> </div> </div> <?php } ?> <?php //Good - some are up to date! if ($total_uptodate > 0) { ?> <div class="clear"> <div class="mainwp-row"> <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php echo $total_uptodate; ?> </span> <?php _e('Up to date', 'mainwp'); ?> </span> <span class="mainwp-mid-col"> </span> <span class="mainwp-right-col"><a href="#" id="mainwp_uptodate_show" onClick="return rightnow_show('uptodate');"><i class="fa fa-eye-slash"></i> <?php _e('Show', 'mainwp'); ?> </a></span> </div> <div id="wp_uptodate" style="display: none"> <?php @MainWPDB::data_seek($websites, 0); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if ($website->uptodate != 1) { continue; } ?> <div class="mainwp-row"> <span class="mainwp-left-col"><a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $website->id); ?> "><?php echo stripslashes($website->name); ?> </a></span> <span class="mainwp-mid-col"> </span> <span class="mainwp-right-col"><a href="<?php echo $website->url; ?> " target="_blank"><?php _e('Open', 'mainwp'); ?> </a></span> </div> <?php } ?> </div> </div> <?php } ?> <?php @MainWPDB::data_seek($websites, 0); $site_ids = array(); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { $site_ids[] = $website->id; } do_action('mainwp_rightnow_widget_bottom', $site_ids, $globalView); ?> <div class="clear"> <div class="mainwp-row"> <span class="mainwp-left-col"><span class="mainwp-rightnow-number"> <img class="down-img" style="margin-bottom: -3px;" title="<?php echo $total_sync_errors > 0 ? 'Site Disconnected' : ($total_conflict > 0 ? 'Plugin or Theme Conflict Found' : ($total_offline > 0 ? 'Site is Offline' : 'Site is Online')); ?> " alt="<?php echo $total_sync_errors > 0 ? 'Sync errors' : ($total_conflict > 0 ? 'Conflict Found' : ($total_offline > 0 ? 'Site Down' : 'Site Up')); ?> " src="<?php echo plugins_url('images/' . ($total_sync_errors > 0 ? 'disconnected' : ($total_conflict > 0 ? 'conflict' : ($total_offline > 0 ? 'down' : 'up'))) . '.png', dirname(__FILE__)); ?> " /></span> <span style="font-size: 18px !important;"><?php _e('Status', 'mainwp'); ?> </span></span> <span class="mainwp-mid-col"> </span> <span class="mainwp-right-col"><a href="#" id="mainwp_status_show" onClick="return rightnow_show('status');"><i class="fa fa-eye-slash"></i> <?php _e('Show', 'mainwp'); ?> </a></span> </div> <div id="wp_status" style="display: none"> <?php //Loop 3 times, first we show the conflicts, then we show the down sites, then we show the up sites $SYNCERRORS = 0; $CONFLICTS = 1; $DOWN = 2; $UP = 3; for ($j = 0; $j <= 3; $j++) { @MainWPDB::data_seek($websites, 0); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { $pluginConflicts = json_decode($website->pluginConflicts, true); $themeConflicts = json_decode($website->themeConflicts, true); $ignoredPluginConflicts = json_decode($website->ignored_pluginConflicts, true); if (!is_array($ignoredPluginConflicts)) { $ignoredPluginConflicts = array(); } $ignoredThemeConflicts = json_decode($website->ignored_themeConflicts, true); if (!is_array($ignoredThemeConflicts)) { $ignoredThemeConflicts = array(); } $hasSyncErrors = $website->sync_errors != ''; $isConflict = false; if (!$hasSyncErrors) { if (count($pluginConflicts) > 0) { foreach ($pluginConflicts as $pluginConflict) { if (!in_array($pluginConflict, $ignoredPluginConflicts) && !in_array($pluginConflict, $globalIgnoredPluginConflicts)) { $isConflict = true; } } } if (!$isConflict && count($themeConflicts) > 0) { foreach ($themeConflicts as $themeConflict) { if (!in_array($themeConflict, $ignoredThemeConflicts) && !in_array($themeConflict, $globalIgnoredThemeConflicts)) { $isConflict = true; } } } } $isDown = !$hasSyncErrors && !$isConflict && $website->offline_check_result == -1; $isUp = !$hasSyncErrors && !$isConflict && !$isDown; if ($j == $SYNCERRORS && !$hasSyncErrors) { continue; } if ($j == $CONFLICTS && !$isConflict) { continue; } if ($j == $DOWN && !$isDown) { continue; } if ($j == $UP && !$isUp) { continue; } ?> <div class="mainwp-row"> <span class="mainwp-left-col"><a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $website->id); ?> "><?php echo stripslashes($website->name); ?> </a></span> <span class="mainwp-mid-col"> <?php if ($isConflict) { ?> <span class="mainwp_status_conflict"><?php _e('Conflict Found', 'mainwp'); ?> </span> <?php } ?> </span> <span class="mainwp-right-col"> <?php if ($hasSyncErrors) { ?> <div style="position: absolute; padding-right: 10px; right: 50px;"><a href="#" class="mainwp_rightnow_site_reconnect" siteid="<?php echo $website->id; ?> "><?php _e('Reconnect', 'mainwp'); ?> </a><br /></div> <img class="down-img" title="Site Disconnected" alt="Sync Errors" src="<?php echo plugins_url('images/disconnected.png', dirname(__FILE__)); ?> " /> <?php } else { if ($isConflict) { ?> <img class="down-img" title="Plugin or Theme Conflict Found" alt="Conflict Found" src="<?php echo plugins_url('images/conflict.png', dirname(__FILE__)); ?> " /> <?php } else { if ($isDown) { ?> <img class="down-img" title="Site is Offline" alt="Site Down" src="<?php echo plugins_url('images/down.png', dirname(__FILE__)); ?> " /> <?php } else { ?> <img class="down-img" title="Site is Online" alt="Site Up" src="<?php echo plugins_url('images/up.png', dirname(__FILE__)); ?> " /> <?php } } } ?> </span> </div> <?php } } ?> </div> </div> <div class="clear"></div> <div id="rightnow-upgrade-status-box" title="Upgrade" style="display: none; text-align: center"> <div id="rightnow-upgrade-status-progress"></div> <span id="rightnow-upgrade-status-current">0</span> / <span id="rightnow-upgrade-status-total"></span> <?php _e('upgraded', 'mainwp'); ?> <div style="height: 160px; overflow: auto; margin-top: 20px; margin-bottom: 10px; text-align: left"> <table style="width: 100%" id="rightnow-upgrade-list"> </table> </div> <input id="rightnow-upgrade-status-close" type="button" name="Close" value="<?php _e('Close', 'mainwp'); ?> " class="button" /> </div> <div id="rightnow-backup-box" title="Full backup required" style="display: none; text-align: center"> <div style="height: 190px; overflow: auto; margin-top: 20px; margin-bottom: 10px; text-align: left" id="rightnow-backup-content"> </div> <input id="rightnow-backup-all" type="button" name="Backup All" value="<?php _e('Backup All', 'mainwp'); ?> " class="button-primary" /> <input id="rightnow-backup-ignore" type="button" name="Ignore" value="<?php _e('Ignore', 'mainwp'); ?> " class="button" /> </div> <div id="rightnow-backupnow-box" title="Full backup" style="display: none; text-align: center"> <div style="height: 190px; overflow: auto; margin-top: 20px; margin-bottom: 10px; text-align: left" id="rightnow-backupnow-content"> </div> <input id="rightnow-backupnow-close" type="button" name="Ignore" value="<?php _e('Cancel', 'mainwp'); ?> " class="button" /> </div> <?php @MainWPDB::free_result($websites); }
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; }
public static function renderChild() { self::renderHeader('ServerInformationChild'); $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser()); echo 'Child Site: <select name="" id="mainwp_serverInformation_child"><option value="-1">-- Select site</option>'; while ($websites && ($website = @MainWPDB::fetch_object($websites))) { echo '<option value="' . $website->id . '">' . stripslashes($website->name) . '</option>'; } @MainWPDB::free_result($websites); echo '</select><br /><br /><div id="mainwp_serverInformation_child_loading"><i class="fa fa-spinner fa-pulse"></i> ' . __('Loading server information..', 'mainwp') . '</div><div id="mainwp_serverInformation_child_resp"></div>'; self::renderFooter('ServerInformationChild'); }
public static function renderTest() { if (!mainwp_current_user_can("dashboard", "test_connection")) { mainwp_do_not_have_permissions("test connection"); return; } ?> <div id="mainwp_managesites_test_errors" class="mainwp_error error"></div> <div id="mainwp_managesites_test_message" class="mainwp_updated updated"></div> <form method="POST" action="" enctype="multipart/form-data" id="mainwp_testconnection_form"> <div class="mainwp_info-box-blue"> <span><?php _e('The Test Connection feature is specifically testing what your Dashboard can "see" and what your Dashboard "sees" and what my Dashboard "sees" or what your browser "sees" can be completely different things.', 'mainwp'); ?> </span> </div> <div class="postbox"> <h3 class="mainwp_box_title"><span><i class="fa fa-cog"></i> <?php _e('Test a Site Connection', 'mainwp'); ?> </span></h3> <div class="inside"> <table class="form-table"> <tr class="form-field form-required"> <th scope="row"><?php _e('Site URL:', 'mainwp'); ?> </th> <td> <input type="text" id="mainwp_managesites_test_wpurl" name="mainwp_managesites_add_wpurl" value="<?php if (isset($_REQUEST['site'])) { echo $_REQUEST['site']; } ?> " autocompletelist="mainwp-test-sites" class="mainwp_autocomplete" /><span class="mainwp-form_hint">Proper Format: <strong>http://address.com/</strong> or <strong>http://www.address.com/</strong></span> <datalist id="mainwp-test-sites"> <?php $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser()); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { echo '<option>' . $website->url . '</option>'; } @MainWPDB::free_result($websites); ?> </datalist> <br/><em><?php _e('Please only use the domain URL, do not add /wp-admin.', 'mainwp'); ?> </em> </td> </tr> </table> </div> </div> <div class="postbox"> <h3 class="mainwp_box_title"><span><i class="fa fa-cog"></i> <?php _e('Advanced Options', 'mainwp'); ?> </span></h3> <div class="inside"> <table class="form-table"> <tr class="form-field form-required"> <th scope="row"><?php _e('Verify certificate', 'mainwp'); ?> <?php MainWPUtility::renderToolTip(__('Verify the childs SSL certificate. This should be disabled if you are using out of date or self signed certificates.', 'mainwp')); ?> </th> <td> <select id="mainwp_managesites_test_verifycertificate" name="mainwp_managesites_test_verifycertificate"> <option selected value="1"><?php _e('Yes', 'mainwp'); ?> </option> <option value="0"><?php _e('No', 'mainwp'); ?> </option> <option value="2"><?php _e('Use Global Setting', 'mainwp'); ?> </option> </select> <em>(<?php _e('Default: Yes', 'mainwp'); ?> )</em> </td> </tr> <!-- fake fields are a workaround for chrome autofill getting the wrong fields --> <input style="display:none" type="text" name="fakeusernameremembered"/> <input style="display:none" type="password" name="fakepasswordremembered"/> <tr> <td colspan="2"><div class="mainwp_info-box"><?php _e('If your Child Site is protected with HTTP basic authentication, please set the username and password for authentication here.', 'mainwp'); ?> </div></td> </tr> <tr class="form-field form-required"> <th scope="row"><?php _e('HTTP username: '******'mainwp'); ?> </th> <td><input type="text" id="mainwp_managesites_test_http_user" style="width: 350px;" name="mainwp_managesites_test_http_user" value="" class="mainwp-field mainwp-username"/></td> </tr> <tr class="form-field form-required"> <th scope="row"><?php _e('HTTP password: '******'mainwp'); ?> </th> <td><input type="password" id="mainwp_managesites_test_http_pass" style="width: 350px;" name="mainwp_managesites_test_http_pass" value="" class="mainwp-field mainwp-password"/></td> </tr> </table> </form> </div> </div> <p class="submit"><input type="button" name="mainwp_managesites_test" id="mainwp_managesites_test" class="button-primary" value="<?php _e('Test Connection', 'mainwp'); ?> "/></p> <?php }
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> <?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 checkWebsite() { if (!isset($_POST['websiteid'])) { //Check all websites $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser()); } else { $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsiteById($_POST['websiteid'])); if (!$websites) { return 0; } } $output = array(); if (!$websites) { $emailOutput = ''; } else { $emailOutput = null; } $errors = false; while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if (self::performCheck($website, true, $emailOutput)) { $output[$website->id] = 1; } else { $output[$website->id] = -1; $errors = true; } } @MainWPDB::free_result($websites); if ($emailOutput != null) { if ($errors) { $emailOutput .= '<br /><br />Please take a look at the issues and make sure everything is ok.'; } $email = MainWPDB::Instance()->getUserNotificationEmail($website->userid); wp_mail($email, $errors ? 'Down Time Alert - MainWP' : 'Up Time Alert - MainWP', MainWPUtility::formatEmail($email, $emailOutput), array('From: "' . get_option('admin_email') . '" <' . get_option('admin_email') . '>', 'content-type: text/html')); } return array('result' => $output); }