function column_details($item) { $output = '<strong>' . __('LAST RUN MANUALLY: ', 'mainwp') . '</strong>' . ($item->last_run_manually == 0 ? '-' : MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($item->last_run_manually))) . '<br />'; $output .= '<strong>' . __('LAST RUN: ', 'mainwp') . '</strong>' . ($item->last_run == 0 ? '-' : MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($item->last_run))) . '<br />'; $output .= '<strong>' . __('LAST COMPLETED: ', 'mainwp') . '</strong>' . ($item->completed == 0 ? '-' : MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($item->completed))) . '<br />'; $output .= '<strong>' . __('NEXT RUN: ', 'mainwp') . '</strong>' . ($item->last_run == 0 ? __('Any minute', 'mainwp') : MainWP_Utility::formatTimestamp(($item->schedule == 'daily' ? 60 * 60 * 24 : ($item->schedule == 'weekly' ? 60 * 60 * 24 * 7 : 60 * 60 * 24 * 30)) + MainWP_Utility::getTimestamp($item->last_run))); $output .= '<strong>'; if ($item->last_run != 0 && $item->completed < $item->last_run) { $output .= __('<br />CURRENTLY RUNNING: ', 'mainwp') . '</strong>'; $completed_sites = $item->completed_sites; if ($completed_sites != '') { $completed_sites = json_decode($completed_sites, 1); } if (!is_array($completed_sites)) { $completed_sites = array(); } $output .= count($completed_sites) . ' / ' . count($item->the_sites); } return $output; }
public static function PostsSearch_handler($data, $website, &$output) { if (preg_match('/<mainwp>(.*)<\\/mainwp>/', $data, $results) > 0) { $posts = unserialize(base64_decode($results[1])); unset($results); foreach ($posts as $post) { if (isset($post['dts'])) { if (!stristr($post['dts'], '-')) { $post['dts'] = MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($post['dts'])); } } if (!isset($post['title']) || $post['title'] == '') { $post['title'] = '(No Title)'; } ob_start(); ?> <tr id="post-1" class="post-1 post type-post status-publish format-standard hentry category-uncategorized alternate iedit author-self" valign="top"> <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="1"></th> <td class="post-title page-title column-title"> <input class="postId" type="hidden" name="id" value="<?php echo $post['id']; ?> "/> <input class="allowedBulkActions" type="hidden" name="allowedBulkActions" value="|trash|delete|<?php if ($post['status'] == 'publish') { echo 'unpublish|'; } if ($post['status'] == 'pending') { echo 'approve|'; } if ($post['status'] == 'trash') { echo 'restore|'; } if ($post['status'] == 'future' || $post['status'] == 'draft') { echo 'publish|'; } ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $website->id; ?> "/> <strong> <abbr title="<?php echo $post['title']; ?> "> <?php if ($post['status'] != 'trash') { ?> <a class="row-title" href="admin.php?page=SiteOpen&websiteid=<?php echo $website->id; ?> &location=<?php echo base64_encode('post.php?post=' . $post['id'] . '&action=edit'); ?> " title="Edit '<?php echo $post['title']; ?> '"><?php echo $post['title']; ?> </a> <?php } else { ?> <?php echo $post['title']; ?> <?php } ?> </abbr> </strong> <div class="row-actions"> <?php if ($post['status'] != 'trash') { ?> <span class="edit"><a href="admin.php?page=SiteOpen&websiteid=<?php echo $website->id; ?> &location=<?php echo base64_encode('post.php?post=' . $post['id'] . '&action=edit'); ?> " title="Edit this item"><?php _e('Edit', 'mainwp'); ?> </a></span> <span class="trash"> | <a class="post_submitdelete" title="Move this item to the Trash" href="#"><?php _e('Trash', 'mainwp'); ?> </a> </span> <?php } ?> <?php if ($post['status'] == 'future' || $post['status'] == 'draft') { ?> <span class="publish"> | <a class="post_submitpublish" title="Publish this item" href="#"><?php _e('Publish', 'mainwp'); ?> </a> </span> <?php } ?> <?php if ($post['status'] == 'pending') { ?> <span class="post-approve"> | <a class="post_submitapprove" title="Approve this item" href="#"><?php _e('Approve', 'mainwp'); ?> </a> </span> <?php } ?> <?php if ($post['status'] == 'publish') { ?> <span class="view"> | <a href="<?php echo $website->url . (substr($website->url, -1) != '/' ? '/' : '') . '?p=' . $post['id']; ?> " target="_blank" title="View “<?php echo $post['title']; ?> �?" rel="permalink"><?php _e('View', 'mainwp'); ?> </a> </span> <span class="unpublish"> | <a class="post_submitunpublish" title="Unpublish this item" href="#"><?php _e('Unpublish', 'mainwp'); ?> </a> </span> <?php } ?> <?php if ($post['status'] == 'trash') { ?> <span class="restore"> <a class="post_submitrestore" title="Restore this item" href="#"><?php _e('Restore', 'mainwp'); ?> </a> </span> <span class="trash"> | <a class="post_submitdelete_perm" title="Delete this item permanently" href="#"><?php _e('Delete Permanently', 'mainwp'); ?> </a> </span> <?php } ?> </div> <div class="row-actions-working"> <i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> </div> </td> <td class="author column-author"> <?php echo $post['author']; ?> </td> <td class="categories column-categories"> <?php echo $post['categories']; ?> </td> <td class="tags column-tags"><?php echo $post['tags'] == '' ? 'No Tags' : $post['tags']; ?> </td> <td class="comments column-comments"> <div class="post-com-count-wrapper"> <a href="<?php echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $website->id . '&postid=' . $post['id']); ?> " title="0 pending" class="post-com-count"><span class="comment-count"><abbr title="<?php echo $post['comment_count']; ?> "><?php echo $post['comment_count']; ?> </abbr></span></a> </div> </td> <td class="date column-date"><abbr title="<?php echo $post['dts']; ?> "><?php echo $post['dts']; ?> </abbr> </td> <td class="date column-status"><?php echo self::getStatus($post['status']); ?> </td> <td class="categories column-categories"> <a href="<?php echo $website->url; ?> " target="_blank"><?php echo $website->url; ?> </a> <div class="row-actions"> <span class="edit"><a href="admin.php?page=managesites&dashboard=<?php echo $website->id; ?> "><?php _e('Dashboard', 'mainwp'); ?> </a> | <a href="admin.php?page=SiteOpen&websiteid=<?php echo $website->id; ?> "><?php _e('WP Admin', 'mainwp'); ?> </a></span> </div> </td> </tr> <?php $newOutput = ob_get_clean(); echo $newOutput; MainWP_Cache::addBody('Post', $newOutput); $output->posts++; } unset($posts); } else { $output->errors[$website->id] = MainWP_Error_Helper::getErrorMessage(new MainWP_Exception('NOMAINWP', $website->url)); } }
public static function showBackups(&$website, $fullBackups, $dbBackups) { $output = ''; echo '<table>'; $mwpDir = MainWP_Utility::getMainWPDir(); $mwpDir = $mwpDir[0]; foreach ($fullBackups as $key => $fullBackup) { $downloadLink = admin_url('?sig=' . md5(filesize($fullBackup)) . '&mwpdl=' . rawurlencode(str_replace($mwpDir, '', $fullBackup))); $output .= '<tr><td style="width: 400px;">' . MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp(filemtime($fullBackup))) . ' - ' . MainWP_Utility::human_filesize(filesize($fullBackup)); $output .= '</td><td><a title="' . basename($fullBackup) . '" href="' . $downloadLink . '" class="button">Download</a></td>'; $output .= '<td><a href="admin.php?page=SiteRestore&websiteid=' . $website->id . '&f=' . base64_encode($downloadLink) . '&size=' . filesize($fullBackup) . '" class="mainwp-upgrade-button button" target="_blank" title="' . basename($fullBackup) . '">Restore</a></td></tr>'; } if ($output == '') { echo '<br />' . __('No full backup has been taken yet', 'mainwp') . '<br />'; } else { echo '<strong style="font-size: 14px">' . __('Last backups from your files:', 'mainwp') . '</strong>' . $output; } echo '</table><br/><table>'; $output = ''; foreach ($dbBackups as $key => $dbBackup) { $downloadLink = admin_url('?sig=' . md5(filesize($dbBackup)) . '&mwpdl=' . rawurlencode(str_replace($mwpDir, '', $dbBackup))); $output .= '<tr><td style="width: 400px;">' . MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp(filemtime($dbBackup))) . ' - ' . MainWP_Utility::human_filesize(filesize($dbBackup)) . '</td><td><a title="' . basename($dbBackup) . '" href="' . $downloadLink . '" download class="button">Download</a></td></tr>'; } if ($output == '') { echo '<br />' . __('No database only backup has been taken yet', 'mainwp') . '<br /><br />'; } else { echo '<strong style="font-size: 14px">' . __('Last backups from your database:', 'mainwp') . '</strong>' . $output; } echo '</table>'; }
function column_last_post($item) { $output = ''; if ($item['last_post_gmt'] != 0) { $output .= MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($item['last_post_gmt'])) . '<br />'; } $output .= sprintf('<a href="admin.php?page=PostBulkAdd&select=%s">' . '<i class="fa fa-plus"></i> ' . __('Add New', 'mainwp') . '</a>', $item['id']); return $output; }
public static function renderCron() { self::renderHeader('ServerInformationCron'); $schedules = array('Backups' => 'mainwp_cron_last_backups', 'Backups continue' => 'mainwp_cron_last_backups_continue', 'Updates check' => 'mainwp_cron_last_updatescheck', 'Stats' => 'mainwp_cron_last_stats', 'Ping childs' => 'mainwp_cron_last_ping', 'Offline checks' => 'mainwp_cron_last_offlinecheck', 'Conflicts update' => 'mainwp_cron_last_cronconflicts'); ?> <table id="mainwp-table" class="wp-list-table widefat" cellspacing="0"> <thead> <tr> <th scope="col" class="manage-column sorted" style=""><span><?php _e('Schedule', 'mainwp'); ?> </span> </th> <th scope="col" class="manage-column column-posts" style=""> <span><?php _e('Last run', 'mainwp'); ?> </span></th> </tr> </thead> <tbody> <?php foreach ($schedules as $schedule => $option) { ?> <tr> <td><?php echo $schedule; ?> </td> <td><?php echo get_option($option) === false || get_option($option) == 0 ? 'Never run' : MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp(get_option($option))); ?> </td> </tr> <?php } ?> </tbody> </table> <br/> <?php $cron_array = _get_cron_array(); $schedules = wp_get_schedules(); ?> <table id="mainwp-table" class="wp-list-table widefat" cellspacing="0"> <thead> <tr> <th scope="col" class="manage-column sorted" style=""><span><?php _e('Next due', 'mainwp'); ?> </span> </th> <th scope="col" class="manage-column column-posts" style=""> <span><?php _e('Schedule', 'mainwp'); ?> </span></th> <th scope="col" class="manage-column column-posts" style=""> <span><?php _e('Hook', 'mainwp'); ?> </span></th> </tr> </thead> <tbody id="the-sites-list" class="list:sites"> <?php foreach ($cron_array as $time => $cron) { foreach ($cron as $hook => $cron_info) { foreach ($cron_info as $key => $schedule) { ?> <tr> <td><?php echo MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($time)); ?> </td> <td><?php echo isset($schedules[$schedule['schedule']]) ? $schedules[$schedule['schedule']]['display'] : ''; ?> </td> <td><?php echo $hook; ?> </td> </tr> <?php } } } ?> </tbody> </table> <?php self::renderFooter('ServerInformationCron'); }
public static function renderSites() { $sql = MainWP_DB::Instance()->getSQLWebsitesForCurrentUser(); $websites = MainWP_DB::Instance()->query($sql); if (!$websites) { return; } $all_sites_synced = true; $top_row = true; ?> <div class="clear"> <div id="wp_syncs"> <?php ob_start(); @MainWP_DB::data_seek($websites, 0); while ($websites && ($website = @MainWP_DB::fetch_object($websites))) { if (empty($website) || $website->sync_errors != '') { continue; } if (time() - $website->dtsSync < 60 * 60 * 24) { continue; } $all_sites_synced = false; $lastSyncTime = !empty($website->dtsSync) ? MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($website->dtsSync)) : ''; ?> <div class="<?php echo $top_row ? 'mainwp-row-top' : 'mainwp-row'; ?> mainwp_wp_sync" site_id="<?php echo $website->id; ?> " site_name="<?php echo rawurlencode($website->name); ?> "> <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_sync<?php echo $website->id; ?> " /></span> <span class="mainwp-mid-col wordpressInfo" id="wp_sync_<?php echo $website->id; ?> "> <?php echo $lastSyncTime; ?> </span> <span class="mainwp-right-col wordpressAction"> <div id="wp_syncs_<?php echo $website->id; ?> "> <a class="mainwp-upgrade-button button" onClick="rightnow_wp_sync('<?php echo $website->id; ?> ')"><?php _e('Sync Now', 'mainwp'); ?> </a> </div> </span> </div> <?php $top_row = false; } $output = ob_get_clean(); if ($all_sites_synced) { echo esc_html__('All sites have been synced within the last 24 hours', 'mainwp') . "."; } else { echo '<div class="mainwp_info-box-red">' . esc_html__('Sites not synced in the last 24 hours.', 'mainwp') . '</div>'; echo $output; } ?> </div> </div> <?php @MainWP_DB::free_result($websites); }
public static function renderLastUpdate() { $currentwp = MainWP_Utility::get_current_wpid(); if (!empty($currentwp)) { $website = MainWP_DB::Instance()->getWebsiteById($currentwp); $dtsSync = $website->dtsSync; } else { $dtsSync = MainWP_DB::Instance()->getFirstSyncedSite(); } if ($dtsSync == 0) { //No settings saved! return; } else { echo __('(Last complete sync: ', 'mainwp') . MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($dtsSync)) . ')'; } }
public static function renderSites($renew, $pExit = true) { $current_wpid = MainWP_Utility::get_current_wpid(); if ($current_wpid) { $sql = MainWP_DB::Instance()->getSQLWebsiteById($current_wpid); } else { $sql = MainWP_DB::Instance()->getSQLWebsitesForCurrentUser(); } $websites = MainWP_DB::Instance()->query($sql); $allPages = array(); if ($websites) { while ($websites && ($website = @MainWP_DB::fetch_object($websites))) { if ($website->recent_pages == '') { continue; } $pages = json_decode($website->recent_pages, 1); if (count($pages) == 0) { continue; } foreach ($pages as $page) { $page['website'] = (object) array('id' => $website->id, 'url' => $website->url); $allPages[] = $page; } } @MainWP_DB::free_result($websites); } $recent_pages_published = MainWP_Utility::getSubArrayHaving($allPages, 'status', 'publish'); $recent_pages_published = MainWP_Utility::sortmulti($recent_pages_published, 'dts', 'desc'); $recent_pages_draft = MainWP_Utility::getSubArrayHaving($allPages, 'status', 'draft'); $recent_pages_draft = MainWP_Utility::sortmulti($recent_pages_draft, 'dts', 'desc'); $recent_pages_pending = MainWP_Utility::getSubArrayHaving($allPages, 'status', 'pending'); $recent_pages_pending = MainWP_Utility::sortmulti($recent_pages_pending, 'dts', 'desc'); $recent_pages_trash = MainWP_Utility::getSubArrayHaving($allPages, 'status', 'trash'); $recent_pages_trash = MainWP_Utility::sortmulti($recent_pages_trash, 'dts', 'desc'); ?> <div class="clear"> <a href="<?php echo admin_url('admin.php?page=PageBulkAdd&select=' . ($current_wpid ? $current_wpid : 'all')); ?> " class="button-primary" style="float: right"><?php _e('Add New', 'mainwp'); ?> </a> <a class="mainwp_action left mainwp_action_down recent_posts_published_lnk" href="#"><?php _e('Published', 'mainwp'); ?> (<?php echo count($recent_pages_published); ?> )</a><a class="mainwp_action mid recent_posts_draft_lnk" href="#"><?php _e('Draft', 'mainwp'); ?> (<?php echo count($recent_pages_draft); ?> )</a><a class="mainwp_action mid recent_posts_pending_lnk" href="#"><?php _e('Pending', 'mainwp'); ?> (<?php echo count($recent_pages_pending); ?> )</a><a class="mainwp_action right recent_posts_trash_lnk" href="#"><?php _e('Trash', 'mainwp'); ?> (<?php echo count($recent_pages_trash); ?> )</a><br/><br/> <div class="recent_posts_published"> <?php for ($i = 0; $i < count($recent_pages_published) && $i < 5; $i++) { if (!isset($recent_pages_published[$i]['title']) || $recent_pages_published[$i]['title'] == '') { $recent_pages_published[$i]['title'] = '(No Title)'; } if (isset($recent_pages_published[$i]['dts'])) { if (!stristr($recent_pages_published[$i]['dts'], '-')) { $recent_pages_published[$i]['dts'] = MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($recent_pages_published[$i]['dts'])); } } ?> <div class="mainwp-row mainwp-recent"> <input class="postId" type="hidden" name="id" value="<?php echo $recent_pages_published[$i]['id']; ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $recent_pages_published[$i]['website']->id; ?> "/> <span class="mainwp-left-col" style="width: 60% !important; margin-right: 1em;"><a href="<?php echo $recent_pages_published[$i]['website']->url; ?> ?p=<?php echo $recent_pages_published[$i]['id']; ?> " target="_blank"><?php echo htmlentities($recent_pages_published[$i]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?> </a></span> <span class="mainwp-mid-col"> <a href="<?php echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_pages_published[$i]['website']->id . '&postid=' . $recent_pages_published[$i]['id']); ?> " title="<?php echo $recent_pages_published[$i]['comment_count']; ?> " class="post-com-count" style="display: inline-block !important;"> <span class="comment-count"><?php echo $recent_pages_published[$i]['comment_count']; ?> </span> </a> </span> <span class="mainwp-right-col"> <a href="<?php echo $recent_pages_published[$i]['website']->url; ?> " target="_blank"> <i class="fa fa-external-link"></i> <?php echo MainWP_Utility::getNiceURL($recent_pages_published[$i]['website']->url); ?> </a> <br/> <?php echo $recent_pages_published[$i]['dts']; ?> </span> <div style="clear: left;"></div> <div class="mainwp-row-actions"> <a href="#" class="mainwp-post-unpublish"><?php _e('Unpublish', 'mainwp'); ?> </a> | <a href="admin.php?page=SiteOpen&websiteid=<?php echo $recent_pages_published[$i]['website']->id; ?> &location=<?php echo base64_encode('post.php?action=editpost&post=' . $recent_pages_published[$i]['id'] . '&action=edit'); ?> " title="Edit this post"><?php _e('Edit', 'mainwp'); ?> </a> | <a href="#" class="mainwp-post-trash"><?php _e('Trash', 'mainwp'); ?> </a>| <a href="<?php echo $recent_pages_published[$i]['website']->url . (substr($recent_pages_published[$i]['website']->url, -1) != '/' ? '/' : '') . '?p=' . $recent_pages_published[$i]['id']; ?> " target="_blank" title="View '<?php echo $recent_pages_published[$i]['title']; ?> '" rel="permalink"><?php _e('View', 'mainwp'); ?> </a> | <a href="admin.php?page=PageBulkManage" class="mainwp-post-viewall"><?php _e('View All', 'mainwp'); ?> </a> </div> <div class="mainwp-row-actions-working"> <i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> <div> </div> </div> </div> <?php } ?> </div> <div class="recent_posts_draft" style="display: none"> <?php for ($i = 0; $i < count($recent_pages_draft) && $i < 5; $i++) { if (!isset($recent_pages_draft[$i]['title']) || $recent_pages_draft[$i]['title'] == '') { $recent_pages_draft[$i]['title'] = '(No Title)'; } if (isset($recent_pages_draft[$i]['dts'])) { if (!stristr($recent_pages_draft[$i]['dts'], '-')) { $recent_pages_draft[$i]['dts'] = MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($recent_pages_draft[$i]['dts'])); } } ?> <div class="mainwp-row mainwp-recent"> <input class="postId" type="hidden" name="id" value="<?php echo $recent_pages_draft[$i]['id']; ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $recent_pages_draft[$i]['website']->id; ?> "/> <span class="mainwp-left-col" style="width: 60% !important; margin-right: 1em;"><a href="<?php echo $recent_pages_draft[$i]['website']->url; ?> ?p=<?php echo $recent_pages_draft[$i]['id']; ?> " target="_blank"><?php echo htmlentities($recent_pages_draft[$i]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?> </a></span> <span class="mainwp-mid-col"> <a href="<?php echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_pages_draft[$i]['website']->id . '&postid=' . $recent_pages_draft[$i]['id']); ?> " title="<?php echo $recent_pages_draft[$i]['comment_count']; ?> " class="post-com-count" style="display: inline-block !important;"> <span class="comment-count"><?php echo $recent_pages_draft[$i]['comment_count']; ?> </span> </a> </span> <span class="mainwp-right-col"><?php echo MainWP_Utility::getNiceURL($recent_pages_draft[$i]['website']->url); ?> <br/><?php echo $recent_pages_draft[$i]['dts']; ?> </span> <div style="clear: left;"></div> <div class="mainwp-row-actions"> <a href="#" class="mainwp-post-publish"><?php _e('Publish', 'mainwp'); ?> </a> | <a href="admin.php?page=SiteOpen&websiteid=<?php echo $recent_pages_draft[$i]['website']->id; ?> &location=<?php echo base64_encode('post.php?action=editpost&post=' . $recent_pages_draft[$i]['id'] . '&action=edit'); ?> " title="Edit this post"><?php _e('Edit', 'mainwp'); ?> </a> | <a href="#" class="mainwp-post-trash"><?php _e('Trash', 'mainwp'); ?> </a> | <a href="admin.php?page=PostBulkManage" class="mainwp-post-viewall"><?php _e('View All', 'mainwp'); ?> </a> </div> <div class="mainwp-row-actions-working"> <i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> </div> <div> </div> </div> <?php } ?> </div> <div class="recent_posts_pending" style="display: none"> <?php for ($i = 0; $i < count($recent_pages_pending) && $i < 5; $i++) { if (!isset($recent_pages_pending[$i]['title']) || $recent_pages_pending[$i]['title'] == '') { $recent_pages_pending[$i]['title'] = '(No Title)'; } if (isset($recent_pages_pending[$i]['dts'])) { if (!stristr($recent_pages_pending[$i]['dts'], '-')) { $recent_pages_pending[$i]['dts'] = MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($recent_pages_pending[$i]['dts'])); } } ?> <div class="mainwp-row mainwp-recent"> <input class="postId" type="hidden" name="id" value="<?php echo $recent_pages_pending[$i]['id']; ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $recent_pages_pending[$i]['website']->id; ?> "/> <span class="mainwp-left-col" style="width: 60% !important; margin-right: 1em;"><a href="<?php echo $recent_pages_pending[$i]['website']->url; ?> ?p=<?php echo $recent_pages_pending[$i]['id']; ?> " target="_blank"><?php echo htmlentities($recent_pages_pending[$i]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?> </a></span> <span class="mainwp-mid-col"> <a href="<?php echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_pages_pending[$i]['website']->id . '&postid=' . $recent_pages_pending[$i]['id']); ?> " title="<?php echo $recent_pages_pending[$i]['comment_count']; ?> " class="post-com-count" style="display: inline-block !important;"> <span class="comment-count"><?php echo $recent_pages_pending[$i]['comment_count']; ?> </span> </a> </span> <span class="mainwp-right-col"><?php echo MainWP_Utility::getNiceURL($recent_pages_pending[$i]['website']->url); ?> <br/><?php echo $recent_pages_pending[$i]['dts']; ?> </span> <div style="clear: left;"></div> <div class="mainwp-row-actions"> <a href="#" class="mainwp-post-publish"><?php _e('Publish', 'mainwp'); ?> </a> | <a href="admin.php?page=SiteOpen&websiteid=<?php echo $recent_pages_pending[$i]['website']->id; ?> &location=<?php echo base64_encode('post.php?action=editpost&post=' . $recent_pages_pending[$i]['id'] . '&action=edit'); ?> " title="Edit this post"><?php _e('Edit', 'mainwp'); ?> </a> | <a href="#" class="mainwp-post-trash"><?php _e('Trash', 'mainwp'); ?> </a> | <a href="admin.php?page=PostBulkManage" class="mainwp-post-viewall"><?php _e('View All', 'mainwp'); ?> </a> </div> <div class="mainwp-row-actions-working"> <i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> </div> <div> </div> </div> <?php } ?> </div> <div class="recent_posts_trash" style="display: none"> <?php for ($i = 0; $i < count($recent_pages_trash) && $i < 5; $i++) { if (!isset($recent_pages_trash[$i]['title']) || $recent_pages_trash[$i]['title'] == '') { $recent_pages_trash[$i]['title'] = '(No Title)'; } if (isset($recent_pages_trash[$i]['dts'])) { if (!stristr($recent_pages_trash[$i]['dts'], '-')) { $recent_pages_trash[$i]['dts'] = MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($recent_pages_trash[$i]['dts'])); } } ?> <div class="mainwp-row mainwp-recent"> <input class="postId" type="hidden" name="id" value="<?php echo $recent_pages_trash[$i]['id']; ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $recent_pages_trash[$i]['website']->id; ?> "/> <span class="mainwp-left-col" style="width: 60% !important; margin-right: 1em;"><?php echo $recent_pages_trash[$i]['title']; ?> </span> <span class="mainwp-mid-col"> <a href="<?php echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_pages_trash[$i]['website']->id . '&postid=' . $recent_pages_trash[$i]['id']); ?> " title="<?php echo $recent_pages_trash[$i]['comment_count']; ?> " class="post-com-count" style="display: inline-block !important;"> <span class="comment-count"><?php echo $recent_pages_trash[$i]['comment_count']; ?> </span> </a> </span> <span class="mainwp-right-col"><?php echo MainWP_Utility::getNiceURL($recent_pages_trash[$i]['website']->url); ?> <br/><?php echo $recent_pages_trash[$i]['dts']; ?> </span> <div style="clear: left;"></div> <div class="mainwp-row-actions"> <a href="#" class="mainwp-post-restore"><?php _e('Restore', 'mainwp'); ?> </a> | <a href="#" class="mainwp-post-delete delete" style="color: red;"><?php _e('Delete Permanently', 'mainwp'); ?> </a> </div> <div class="mainwp-row-actions-working"> <i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> </div> <div> </div> </div> <?php } ?> </div> </div> <div class="clear"></div> <?php if ($pExit == true) { exit; } }
public static function renderSettings() { $userExtension = MainWP_DB::Instance()->getUserExtension(); $pluginDir = $userExtension == null || ($userExtension->pluginDir == null || $userExtension->pluginDir == '') ? 'default' : $userExtension->pluginDir; $user_email = MainWP_Utility::getNotificationEmail(); $siteview = $userExtension->site_view; $snAutomaticDailyUpdate = get_option('mainwp_automaticDailyUpdate'); $backup_before_upgrade = get_option('mainwp_backup_before_upgrade'); $lastAutomaticUpdate = MainWP_DB::Instance()->getWebsitesLastAutomaticSync(); if ($lastAutomaticUpdate == 0) { $nextAutomaticUpdate = 'Any minute'; } else { if (MainWP_DB::Instance()->getWebsitesCountWhereDtsAutomaticSyncSmallerThenStart() > 0 || MainWP_DB::Instance()->getWebsitesCheckUpdatesCount() > 0) { $nextAutomaticUpdate = 'Processing your websites.'; } else { $nextAutomaticUpdate = MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp(mktime(0, 0, 0, date('n'), date('j') + 1))); } } if ($lastAutomaticUpdate == 0) { $lastAutomaticUpdate = 'Never'; } else { $lastAutomaticUpdate = MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($lastAutomaticUpdate)); } ?> <div class="postbox" id="mainwp-hide-child-plugin-settings"> <h3 class="mainwp_box_title"> <span><i class="fa fa-cog"></i> <?php _e('Network Optimization', 'mainwp'); ?> </span></h3> <div class="inside"> <div class="mainwp_info-box-red" style="margin-top: 5px;"><?php _e('<strong>STOP BEFORE TURNING ON!</strong> Hiding the Child Plugin does require the plugin to make changes to your .htaccess file that in rare instances or server configurations could cause problems.', 'mainwp'); ?> </div> <table class="form-table"> <tbody> <tr> <th scope="row"><?php _e('Hide MainWP Child Plugin from Search Engines', 'mainwp'); ?> <br/> <em style="font-size: 12px;">(<?php _e('does not hide from users', 'mainwp'); ?> )</em> </th> <td> <table> <tr> <td valign="top" style="padding-left: 0; padding-right: 5px; padding-top: 0px; padding-bottom: 0px; vertical-align: top;"> <div class="mainwp-checkbox"> <input type="checkbox" value="hidden" name="mainwp_options_footprint_plugin_folder" id="mainwp_options_footprint_plugin_folder_default" <?php echo $pluginDir == 'hidden' ? 'checked="true"' : ''; ?> /><label for="mainwp_options_footprint_plugin_folder_default"></label> </div> </td> <td valign="top" style="padding: 0"> <label for="mainwp_options_footprint_plugin_folder_default"> <em><?php _e('This will make anyone including Search Engines trying find your Child Plugin encounter a 404 page. Hiding the Child Plugin does require the plugin to make changes to your .htaccess file that in rare instances or server configurations could cause problems.', 'mainwp'); ?> </em> </label> </td> </tr> </table> </td> </tr> <tr> <th scope="row"><?php _e('Optimize for Shared Hosting or Big Networks', 'mainwp'); ?> <?php MainWP_Utility::renderToolTip(__('Updates will be cached for quick loading. A manual refresh from the Dashboard is required to view new plugins, themes, pages or users. Recommended for Networks over 50 sites.', 'mainwp')); ?> </th> <td> <div class="mainwp-checkbox"> <input type="checkbox" name="mainwp_optimize" id="mainwp_optimize" <?php echo get_option('mainwp_optimize') == 1 ? 'checked="true"' : ''; ?> /> <label for="mainwp_optimize"></label> </div> </td> </tr> </tbody> </table> </div> </div> <div class="postbox" id="mainwp-global-options-settings"> <h3 class="mainwp_box_title"> <span><i class="fa fa-cog"></i> <?php _e('Global Options', 'mainwp'); ?> </span></h3> <div class="inside"> <table class="form-table"> <tbody> <tr> <th scope="row"><?php _e('Notification Email', 'mainwp'); MainWP_Utility::renderToolTip(__('This address is used to send monitoring alerts.', 'mainwp')); ?> </th> <td> <input type="text" class="" name="mainwp_options_email" size="35" value="<?php echo $user_email; ?> "/><span class="mainwp-form_hint"><?php _e('This address is used to send monitoring alerts.', 'mainwp'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Use WP-Cron', 'mainwp'); MainWP_Utility::renderToolTip(__('When not using WP-Cron you will need to set up a cron job via your hosting.', 'mainwp'), 'http://docs.mainwp.com/disable-wp-cron/'); ?> </th> <td> <div class="mainwp-checkbox"> <input type="checkbox" name="mainwp_options_wp_cron" id="mainwp_options_wp_cron" <?php echo get_option('mainwp_wp_cron') == 1 || get_option('mainwp_wp_cron') === false ? 'checked="true"' : ''; ?> /> <label for="mainwp_options_wp_cron"></label> </div> </td> </tr> <?php if (MainWP_Utility::isAdmin()) { ?> <tr> <th scope="row"><?php _e('Show Basic SEO Stats', 'mainwp'); MainWP_Utility::renderToolTip(__('This requires your Dashboard to query the Google servers for this information.', 'mainwp')); ?> </th> <td> <div class="mainwp-checkbox"> <input type="checkbox" name="mainwp_seo" id="mainwp_seo" <?php echo get_option('mainwp_seo') == 1 ? 'checked="true"' : ''; ?> /> <label for="mainwp_seo"></label> </div> </td> </tr> <?php } ?> </tbody> </table> </div> </div> <div class="postbox" id="mainwp-upgrade-options-settings"> <h3 class="mainwp_box_title"> <span><i class="fa fa-cog"></i> <?php _e('Upgrade Options', 'mainwp'); ?> </span></h3> <div class="inside"> <table class="form-table"> <tbody> <tr> <th scope="row"><?php _e('Require Backup Before Upgrade', 'mainwp'); MainWP_Utility::renderToolTip(__('With this option enabled, when you try to upgrade a plugin, theme or WordPress core, MainWP will check if there is a full backup created for the site(s) you are trying to upgrade in last 7 days. If you have a fresh backup of the site(s) MainWP will proceed to the upgrade process, if not it will ask you to create a full backup.', 'mainwp')); ?> </th> <td> <div class="mainwp-checkbox"> <input type="checkbox" name="mainwp_backup_before_upgrade" id="mainwp_backup_before_upgrade" size="35" <?php echo $backup_before_upgrade == 1 ? 'checked="true"' : ''; ?> /> <label for="mainwp_backup_before_upgrade"></label> </div> </td> </tr> <tr> <th scope="row"><?php _e('Automatic Daily Update', 'mainwp'); MainWP_Utility::renderToolTip(__('Choose to have MainWP install updates, or notify you by email of available updates. Updates apply to WordPress Core files, Plugins and Themes.', 'mainwp')); ?> </th> <td> <table class="mainwp-nomarkup"> <tr> <td valign="top"> <span class="mainwp-select-bg"> <select name="mainwp_automaticDailyUpdate" id="mainwp_automaticDailyUpdate"> <option value="2" <?php if ($snAutomaticDailyUpdate === false || $snAutomaticDailyUpdate == 2) { ?> selected<?php } ?> >E-mail Notifications of New Updates</option> <option value="1" <?php if ($snAutomaticDailyUpdate == 1) { ?> selected<?php } ?> >Install Trusted Updates</option> <option value="0" <?php if ($snAutomaticDailyUpdate !== false && $snAutomaticDailyUpdate == 0) { ?> selected<?php } ?> >Off</option> </select> <label></label> </span> <br/><em><?php _e('Last run: ', 'mainwp'); echo $lastAutomaticUpdate; ?> </em> <br /><em><?php _e('Next run: ', 'mainwp'); echo $nextAutomaticUpdate; ?> </em> </td> </tr> </table> </td> </tr> <tr> <th scope="row"><?php _e('Abandoned Plugins/Thems Tolerance', 'mainwp'); MainWP_Utility::renderToolTip(__("In case the plugin or theme author didn't release an update for the set number of days, the plugin/theme will be marked and Possibly Abandoned.", 'mainwp')); ?> </th> <td> <input type="text" name="mainwp_numberdays_Outdate_Plugin_Theme" class="" id="mainwp_numberdays_Outdate_Plugin_Theme" value="<?php echo get_option('mainwp_numberdays_Outdate_Plugin_Theme') === false ? 365 : get_option('mainwp_numberdays_Outdate_Plugin_Theme'); ?> "/> </td> </tr> </tbody> </table> </div> </div> <div class="postbox" id="mainwp-date-return-options-settings"> <h3 class="mainwp_box_title"><span><i class="fa fa-cog"></i> <?php _e('Data Return Options', 'mainwp'); ?> </span> </h3> <div class="inside"> <table class="form-table"> <tbody> <tr> <th scope="row"><?php _e('Maximum Number of Posts/Pages', 'mainwp'); MainWP_Utility::renderToolTip(__('0 for unlimited, CAUTION: a large amount will decrease the speed and might crash the communication.', 'mainwp')); ?> </th> <td> <input type="text" name="mainwp_maximumPosts" class="" id="mainwp_maximumPosts" value="<?php echo get_option('mainwp_maximumPosts') === false ? 50 : get_option('mainwp_maximumPosts'); ?> "/> </td> </tr> <tr> <th scope="row"><?php _e('Maximum Number of Comments', 'mainwp'); MainWP_Utility::renderToolTip(__('0 for unlimited, CAUTION: a large amount will decrease the speed and might crash the communication.', 'mainwp')); ?> </th> <td> <input type="text" name="mainwp_maximumComments" class="" id="mainwp_maximumComments" value="<?php echo get_option('mainwp_maximumComments') === false ? 50 : get_option('mainwp_maximumComments'); ?> "/> </td> </tr> </tbody> </table> </div> </div> <?php }
public static function executeBackupTask($task, $nrOfSites = 0, $updateRun = true) { if ($updateRun) { MainWP_DB::Instance()->updateBackupRun($task->id); } $task = MainWP_DB::Instance()->getBackupTaskById($task->id); $completed_sites = $task->completed_sites; if ($completed_sites != '') { $completed_sites = json_decode($completed_sites, true); } if (!is_array($completed_sites)) { $completed_sites = array(); } $sites = array(); if ($task->groups == '') { if ($task->sites != '') { $sites = explode(',', $task->sites); } } else { $groups = explode(',', $task->groups); foreach ($groups as $groupid) { $group_sites = MainWP_DB::Instance()->getWebsitesByGroupId($groupid); foreach ($group_sites as $group_site) { if (in_array($group_site->id, $sites)) { continue; } $sites[] = $group_site->id; } } } $errorOutput = null; $lastStartNotification = $task->lastStartNotificationSent; if ($updateRun && get_option('mainwp_notificationOnBackupStart') == 1 && $lastStartNotification < $task->last_run) { $email = MainWP_DB::Instance()->getUserNotificationEmail($task->userid); if ($email != '') { $output = 'A scheduled backup has started with MainWP on ' . MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp(time())) . ' for the following ' . count($sites) . ' sites:<br />'; foreach ($sites as $siteid) { $website = MainWP_DB::Instance()->getWebsiteById($siteid); $output .= ' • <a href="' . $website->url . '">' . MainWP_Utility::getNiceURL($website->url) . '</a><br />'; } $output .= '<br />Backup Details:<br /><br />'; $output .= '<strong>Backup Task</strong>' . ' - ' . $task->name . '<br />'; $output .= '<strong>Backup Type</strong>' . ' - ' . ($task->type == 'db' ? 'DATABASE BACKUP' : 'FULL BACKUP') . '<br />'; $output .= '<strong>Backup Schedule</strong>' . ' - ' . strtoupper($task->schedule) . '<br />'; wp_mail($email, 'A Scheduled Backup has been Started - MainWP', MainWP_Utility::formatEmail($email, $output), 'content-type: text/html'); MainWP_DB::Instance()->updateBackupTaskWithValues($task->id, array('lastStartNotificationSent' => time())); } } $currentCount = 0; foreach ($sites as $siteid) { if (isset($completed_sites[$siteid]) && $completed_sites[$siteid] == true) { continue; } $website = MainWP_DB::Instance()->getWebsiteById($siteid); try { $subfolder = str_replace('%task%', MainWP_Utility::sanitize($task->name), $task->subfolder); $backupResult = MainWP_Manage_Sites::backupSite($siteid, $task, $subfolder); //When we receive a timeout, we return false.. if ($backupResult === false) { continue; } if ($errorOutput == null) { $errorOutput = ''; } $error = false; $tmpErrorOutput = ''; if (isset($backupResult['error'])) { $tmpErrorOutput .= $backupResult['error'] . '<br />'; $error = true; } if (isset($backupResult['ftp']) && $backupResult['ftp'] != 'success') { $tmpErrorOutput .= 'FTP: ' . $backupResult['ftp'] . '<br />'; $error = true; } if (isset($backupResult['dropbox']) && $backupResult['dropbox'] != 'success') { $tmpErrorOutput .= 'Dropbox: ' . $backupResult['dropbox'] . '<br />'; $error = true; } if (isset($backupResult['amazon']) && $backupResult['amazon'] != 'success') { $tmpErrorOutput .= 'Amazon: ' . $backupResult['amazon'] . '<br />'; $error = true; } if ($error) { $errorOutput .= 'Site: <strong>' . MainWP_Utility::getNiceURL($website->url) . '</strong><br />'; $errorOutput .= $tmpErrorOutput . '<br />'; } } catch (Exception $e) { if ($errorOutput == null) { $errorOutput = ''; } $errorOutput .= 'Site: <strong>' . MainWP_Utility::getNiceURL($website->url) . '</strong><br />'; $errorOutput .= MainWP_Error_Helper::getErrorMessage($e) . '<br />'; $_error_output = MainWP_Error_Helper::getErrorMessage($e); } $_backup_result = isset($backupResult) ? $backupResult : (isset($_error_output) ? $_error_output : ''); do_action('mainwp_managesite_schedule_backup', $website, array('type' => $task->type), $_backup_result); $currentCount++; $task = MainWP_DB::Instance()->getBackupTaskById($task->id); $completed_sites = $task->completed_sites; if ($completed_sites != '') { $completed_sites = json_decode($completed_sites, true); } if (!is_array($completed_sites)) { $completed_sites = array(); } $completed_sites[$siteid] = true; MainWP_DB::Instance()->updateCompletedSites($task->id, $completed_sites); if ($nrOfSites != 0 && $nrOfSites <= $currentCount) { break; } } //update completed sites if ($errorOutput != null) { MainWP_DB::Instance()->updateBackupErrors($task->id, $errorOutput); } if (count($completed_sites) == count($sites)) { MainWP_DB::Instance()->updateBackupCompleted($task->id); if (get_option('mainwp_notificationOnBackupFail') == 1) { $email = MainWP_DB::Instance()->getUserNotificationEmail($task->userid); if ($email != '') { $task = MainWP_DB::Instance()->getBackupTaskById($task->id); if ($task->backup_errors != '') { $errorOutput = 'Errors occurred while executing task: <strong>' . $task->name . '</strong><br /><br />' . $task->backup_errors; wp_mail($email, 'A Scheduled Backup had an Error - MainWP', MainWP_Utility::formatEmail($email, $errorOutput), 'content-type: text/html'); MainWP_DB::Instance()->updateBackupErrors($task->id, ''); } } } } return $errorOutput == ''; }
public static function render() { $tasks = MainWP_DB::Instance()->getBackupTasksForUser(); if (count($tasks) == 0) { echo 'You have no scheduled backup tasks. <a href="admin.php?page=ManageBackupsAddNew">Go create one!</a>'; } else { ?> <div class"mainwp-row-top" style="text-align: right; margin-bottom: 1em;"> <a href="admin.php?page=ManageBackups" class="button" ><?php _e('Manage Backups', 'mainwp'); ?> </a> <?php if (mainwp_current_user_can('dashboard', 'add_backup_tasks')) { ?> <a href="admin.php?page=ManageBackupsAddNew" class="button-primary" ><?php _e('Add New Task', 'mainwp'); ?> </a> <?php } ?> </div> <div id="mainwp-backup-tasks-widget"> <style> @keyframes blinker { 0% { background: #7fb100 ;} 100% { background: #446200 ;} } @-webkit-keyframes blinker { 0% { background: #7fb100 ;} 100% { background: #446200 ;} } .mainwp-blink-me { animation: blinker 1s linear 0s infinite alternate; -webkit-animation: blinker 1s linear 0s infinite alternate; } </style> <?php foreach ($tasks as $task) { $sites = array(); if ($task->groups != '') { $groups = explode(',', $task->groups); foreach ($groups as $groupid) { $group_sites = MainWP_DB::Instance()->getWebsitesByGroupId($groupid); foreach ($group_sites as $group_site) { if (in_array($group_site->id, $sites)) { continue; } $sites[] = $group_site->id; } } } else { if ($task->sites != '') { $sites = explode(',', $task->sites); } } ?> <div class="mainwp-row mainwp-recent"> <span class="mainwp-left-col" style="width: 40%"> <strong><a href="admin.php?page=ManageBackups&id=<?php echo $task->id; ?> "><?php echo $task->name; ?> </a></strong><br /> <span style="font-size: 11px">(<?php echo strtoupper($task->schedule); ?> - <?php echo $task->type == 'db' ? __('Database Backup', 'mainwp') : __('Full Backup', 'mainwp'); ?> )</span> </span> <span class="mainwp-mid-col"> <?php if ($task->paused == 1) { echo '<span title="Paused" style="background: #999; padding: .3em 1em; color: white; border-radius: 15px; -moz-border-radius: 15px; -webkit-border-radius: 15px;">' . count($sites) . '</span>'; } else { if (count($sites) == 0) { echo '<span title="0 Scheduled Websites" style="background: #c80000; padding: .3em 1em; color: white; border-radius: 15px; -moz-border-radius: 15px; -webkit-border-radius: 15px;">0</span>'; } else { if ($task->last_run != 0 && $task->completed < $task->last_run) { echo '<span title="Backup in Progress" class="mainwp-blink-me" style="padding: .3em 1em; color: white; border-radius: 15px; -moz-border-radius: 15px; -webkit-border-radius: 15px;">' . count($sites) . '</span>'; } else { echo '<span title="Scheduled Websites" style="background: #7fb100; padding: .3em 1em; color: white; border-radius: 15px; -moz-border-radius: 15px; -webkit-border-radius: 15px;">' . count($sites) . '</span>'; } } } ?> </span> <span class="mainwp-right-col" style="width: 40%; text-align: left;"> <strong><?php _e('LAST RUN: ', 'mainwp'); ?> </strong> <?php echo $task->last_run == 0 ? '-' : MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($task->last_run)); ?> <br /> <strong><?php _e('NEXT RUN: ', 'mainwp'); ?> </strong> <?php echo $task->last_run == 0 ? __('Any minute', 'mainwp') : MainWP_Utility::formatTimestamp(($task->schedule == 'daily' ? 60 * 60 * 24 : ($task->schedule == 'weekly' ? 60 * 60 * 24 * 7 : 60 * 60 * 24 * 30)) + MainWP_Utility::getTimestamp($task->last_run)); ?> </span> <div style="clear: left;"></div> </div> <?php } ?> </div> <?php } }