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' : MainWPUtility::formatTimestamp(MainWPUtility::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 MainWPUtility::formatTimestamp(MainWPUtility::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 PagesSearch_handler($data, $website, &$output) { if (preg_match('/<mainwp>(.*)<\\/mainwp>/', $data, $results) > 0) { $pages = unserialize(base64_decode($results[1])); unset($results); foreach ($pages as $page) { if (isset($page['dts'])) { if (!stristr($page['dts'], '-')) { $page['dts'] = MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($page['dts'])); } } if (!isset($page['title']) || $page['title'] == '') { $page['title'] = '(No Title)'; } ob_start(); ?> <tr id="page-1" class="page-1 page type-page status-publish format-standard hentry category-uncategorized alternate iedit author-self" valign="top"> <th scope="row" class="check-column"><input type="checkbox" name="page[]" value="1"></th> <td class="page-title page-title column-title"> <input class="pageId" type="hidden" name="id" value="<?php echo $page['id']; ?> "/> <input class="allowedBulkActions" type="hidden" name="allowedBulkActions" value="|trash|delete|<?php if ($page['status'] == 'trash') { echo 'restore|'; } ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $website->id; ?> "/> <strong> <abbr title="<?php echo $page['title']; ?> "> <?php if ($page['status'] != 'trash') { ?> <a class="row-title" href="admin.php?page=SiteOpen&websiteid=<?php echo $website->id; ?> &location=<?php echo base64_encode('post.php?post=' . $page['id'] . '&action=edit'); ?> " title="Edit '<?php echo $page['title']; ?> '?"><?php echo $page['title']; ?> </a> <?php } else { ?> <?php echo $page['title']; ?> <?php } ?> </abbr> </strong> <div class="row-actions"> <?php if ($page['status'] != 'trash') { ?> <span class="edit"><a href="admin.php?page=SiteOpen&websiteid=<?php echo $website->id; ?> &location=<?php echo base64_encode('post.php?post=' . $page['id'] . '&action=edit'); ?> " title="Edit this item"><?php _e('Edit', 'mainwp'); ?> </a></span> <span class="trash"> | <a class="page_submitdelete" title="Move this item to the Trash" href="#"><?php _e('Trash', 'mainwp'); ?> </a> </span> <?php } ?> <?php if ($page['status'] == 'publish') { ?> <span class="view"> | <a href="<?php echo $website->url . (substr($website->url, -1) != '/' ? '/' : '') . '?p=' . $page['id']; ?> " target="_blank" title="View '<?php echo $page['title']; ?> '?" rel="permalink"><?php _e('View', 'mainwp'); ?> </a></span> <?php } ?> <?php if ($page['status'] == 'trash') { ?> <span class="restore"> <a class="page_submitrestore" title="Restore this item" href="#"><?php _e('Restore', 'mainwp'); ?> </a> </span> <span class="trash"> | <a class="page_submitdelete_perm" title="Delete this item permanently" href="#"><?php _e('Delete Permanently', 'mainwp'); ?> </a> </span> <?php } ?> </div> <div class="row-actions-working"><i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> </div> </td> <td class="author column-author"> <?php echo $page['author']; ?> </td> <td class="comments column-comments"> <div class="page-com-count-wrapper"> <a href="#" title="0 pending" class="post-com-count"><span class="comment-count"><abbr title="<?php echo $page['comment_count']; ?> "><?php echo $page['comment_count']; ?> </abbr></span></a> </div> </td> <td class="date column-date"><abbr title="<?php echo $page['dts']; ?> "><?php echo $page['dts']; ?> </abbr> </td> <td class="status column-status"><?php echo self::getStatus($page['status']); ?> </td> <td class="categories column-categories"> <a href="<?php echo $website->url; ?> " target="_blank"><?php echo $website->url; ?> </a> <div class="row-actions"> <span class="edit"><a href="admin.php?page=managesites&dashboard=<?php echo $website->id; ?> "><?php _e('Dashboard', 'mainwp'); ?> </a> | <a href="admin.php?page=SiteOpen&websiteid=<?php echo $website->id; ?> "><?php _e('WP Admin', 'mainwp'); ?> </a></span> </div> </td> </tr> <?php $newOutput = ob_get_clean(); echo $newOutput; MainWPCache::addBody('Page', $newOutput); $output->pages++; } unset($pages); } else { $output->errors[$website->id] = MainWPErrorHelper::getErrorMessage(new MainWPException('NOMAINWP', $website->url)); } }
public static function renderLastUpdate() { $currentwp = MainWPUtility::get_current_wpid(); if (!empty($currentwp)) { $website = MainWPDB::Instance()->getWebsiteById($currentwp); $dtsSync = $website->dtsSync; } else { $dtsSync = MainWPDB::Instance()->getFirstSyncedSite(); } if ($dtsSync == 0) { //No settings saved! return; } else { echo __('(Last complete sync: ', 'mainwp') . MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($dtsSync)) . ')'; } }
public static function render() { $tasks = MainWPDB::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 = MainWPDB::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 ? '-' : MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($task->last_run)); ?> <br /> <strong><?php _e('NEXT RUN: ', 'mainwp'); ?> </strong> <?php echo $task->last_run == 0 ? __('Any minute', 'mainwp') : MainWPUtility::formatTimestamp(($task->schedule == 'daily' ? 60 * 60 * 24 : ($task->schedule == 'weekly' ? 60 * 60 * 24 * 7 : 60 * 60 * 24 * 30)) + MainWPUtility::getTimestamp($task->last_run)); ?> </span> <div style="clear: left;"></div> </div> <?php } ?> </div> <?php } }
public static function showBackups(&$website, $fullBackups, $dbBackups) { $output = ''; echo '<table>'; $mwpDir = MainWPUtility::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;">' . MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp(filemtime($fullBackup))) . ' - ' . MainWPUtility::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;">' . MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp(filemtime($dbBackup))) . ' - ' . MainWPUtility::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>'; }
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 executeBackupTask($task, $nrOfSites = 0, $updateRun = true) { if ($updateRun) { MainWPDB::Instance()->updateBackupRun($task->id); } $task = MainWPDB::Instance()->getBackupTaskById($task->id); $completed_sites = $task->completed_sites; if ($completed_sites != '') { $completed_sites = json_decode($completed_sites, true); } if (!is_array($completed_sites)) { $completed_sites = array(); } $sites = array(); if ($task->groups == '') { if ($task->sites != '') { $sites = explode(',', $task->sites); } } else { $groups = explode(',', $task->groups); foreach ($groups as $groupid) { $group_sites = MainWPDB::Instance()->getWebsitesByGroupId($groupid); foreach ($group_sites as $group_site) { if (in_array($group_site->id, $sites)) { continue; } $sites[] = $group_site->id; } } } $errorOutput = null; $lastStartNotification = $task->lastStartNotificationSent; if ($updateRun && get_option('mainwp_notificationOnBackupStart') == 1 && $lastStartNotification < $task->last_run) { $email = MainWPDB::Instance()->getUserNotificationEmail($task->userid); if ($email != '') { $output = 'A scheduled backup has started with MainWP on ' . MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp(time())) . ' for the following ' . count($sites) . ' sites:<br />'; foreach ($sites as $siteid) { $website = MainWPDB::Instance()->getWebsiteById($siteid); $output .= ' • <a href="' . $website->url . '">' . MainWPUtility::getNiceURL($website->url) . '</a><br />'; } $output .= '<br />Backup Details:<br /><br />'; $output .= '<strong>Backup Task</strong>' . ' - ' . $task->name . '<br />'; $output .= '<strong>Backup Type</strong>' . ' - ' . ($task->type == 'db' ? 'DATABASE BACKUP' : 'FULL BACKUP') . '<br />'; $output .= '<strong>Backup Schedule</strong>' . ' - ' . strtoupper($task->schedule) . '<br />'; wp_mail($email, 'A Scheduled Backup has been Started - MainWP', MainWPUtility::formatEmail($email, $output), 'content-type: text/html'); MainWPDB::Instance()->updateBackupTaskWithValues($task->id, array('lastStartNotificationSent' => time())); } } $currentCount = 0; foreach ($sites as $siteid) { if (isset($completed_sites[$siteid]) && $completed_sites[$siteid] == true) { continue; } $website = MainWPDB::Instance()->getWebsiteById($siteid); try { $subfolder = str_replace('%task%', MainWPUtility::sanitize($task->name), $task->subfolder); $backupResult = MainWPManageSites::backupSite($siteid, $task, $subfolder); //When we receive a timeout, we return false.. if ($backupResult === false) { continue; } if ($errorOutput == null) { $errorOutput = ''; } $error = false; $tmpErrorOutput = ''; if (isset($backupResult['error'])) { $tmpErrorOutput .= $backupResult['error'] . '<br />'; $error = true; } if (isset($backupResult['ftp']) && $backupResult['ftp'] != 'success') { $tmpErrorOutput .= 'FTP: ' . $backupResult['ftp'] . '<br />'; $error = true; } if (isset($backupResult['dropbox']) && $backupResult['dropbox'] != 'success') { $tmpErrorOutput .= 'Dropbox: ' . $backupResult['dropbox'] . '<br />'; $error = true; } if (isset($backupResult['amazon']) && $backupResult['amazon'] != 'success') { $tmpErrorOutput .= 'Amazon: ' . $backupResult['amazon'] . '<br />'; $error = true; } if ($error) { $errorOutput .= 'Site: <strong>' . MainWPUtility::getNiceURL($website->url) . '</strong><br />'; $errorOutput .= $tmpErrorOutput . '<br />'; } } catch (Exception $e) { if ($errorOutput == null) { $errorOutput = ''; } $errorOutput .= 'Site: <strong>' . MainWPUtility::getNiceURL($website->url) . '</strong><br />'; $errorOutput .= MainWPErrorHelper::getErrorMessage($e) . '<br />'; $_error_output = MainWPErrorHelper::getErrorMessage($e); } $_backup_result = isset($backupResult) ? $backupResult : (isset($_error_output) ? $_error_output : ""); do_action('mainwp_managesite_schedule_backup', $website, array('type' => $task->type), $_backup_result); $currentCount++; $task = MainWPDB::Instance()->getBackupTaskById($task->id); $completed_sites = $task->completed_sites; if ($completed_sites != '') { $completed_sites = json_decode($completed_sites, true); } if (!is_array($completed_sites)) { $completed_sites = array(); } $completed_sites[$siteid] = true; MainWPDB::Instance()->updateCompletedSites($task->id, $completed_sites); if ($nrOfSites != 0 && $nrOfSites <= $currentCount) { break; } } //update completed sites if ($errorOutput != null) { MainWPDB::Instance()->updateBackupErrors($task->id, $errorOutput); } if (count($completed_sites) == count($sites)) { MainWPDB::Instance()->updateBackupCompleted($task->id); if (get_option('mainwp_notificationOnBackupFail') == 1) { $email = MainWPDB::Instance()->getUserNotificationEmail($task->userid); if ($email != '') { $task = MainWPDB::Instance()->getBackupTaskById($task->id); if ($task->backup_errors != '') { $errorOutput = 'Errors occurred while executing task: <strong>' . $task->name . '</strong><br /><br />' . $task->backup_errors; wp_mail($email, 'A Scheduled Backup had an Error - MainWP', MainWPUtility::formatEmail($email, $errorOutput), 'content-type: text/html'); MainWPDB::Instance()->updateBackupErrors($task->id, ''); } } } } return $errorOutput == ''; }
function column_last_post($item) { $output = ''; if ($item['last_post_gmt'] != 0) { $output .= MainWPUtility::formatTimestamp(MainWPUtility::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 renderSettings() { $userExtension = MainWPDB::Instance()->getUserExtension(); $pluginDir = $userExtension == null || ($userExtension->pluginDir == null || $userExtension->pluginDir == '') ? 'default' : $userExtension->pluginDir; $user_email = MainWPUtility::getNotificationEmail(); $siteview = $userExtension->site_view; $snAutomaticDailyUpdate = get_option('mainwp_automaticDailyUpdate'); $backup_before_upgrade = get_option('mainwp_backup_before_upgrade'); $lastAutomaticUpdate = MainWPDB::Instance()->getWebsitesLastAutomaticSync(); if ($lastAutomaticUpdate == 0) { $nextAutomaticUpdate = 'Any minute'; } else { if (MainWPDB::Instance()->getWebsitesCountWhereDtsAutomaticSyncSmallerThenStart() > 0 || MainWPDB::Instance()->getWebsitesCheckUpdatesCount() > 0) { $nextAutomaticUpdate = 'Processing your websites.'; } else { $nextAutomaticUpdate = MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp(mktime(0, 0, 0, date('n'), date('j') + 1))); } } if ($lastAutomaticUpdate == 0) { $lastAutomaticUpdate = 'Never'; } else { $lastAutomaticUpdate = MainWPUtility::formatTimestamp(MainWPUtility::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('Hide MainWP Child Plugin', '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 Network on Child Sites', 'mainwp'); ?> </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> </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'); ?> <?php MainWPUtility::renderToolTip(__('This address is used to send monitoring alerts.', 'mainwp')); ?> </th> <td> <input type="text" class="mainwp-field mainwp-email" 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'); ?> <?php MainWPUtility::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> <!-- todo: RS: Re-enable--> <!-- <tr>--> <!-- <th scope="row">Tips on login</th>--> <!-- <td>--> <!-- <input type="checkbox" name="mainwp_options_tips"--> <!-- id="mainwp_options_tips" --><?php //echo ($userExtension->tips == 1 ? 'checked="true"' : ''); ?> <!--"/>--> <!-- <label for="mainwp_options_tips">Enable "Did you know" tips</label>--> <!-- </td>--> <!-- </tr>--> <?php if (MainWPUtility::isAdmin()) { ?> <tr> <th scope="row"><?php _e('Optimize for Shared Hosting or Big Networks', 'mainwp'); ?> <?php MainWPUtility::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> <tr> <th scope="row"><?php _e('Show Basic SEO Stats', 'mainwp'); ?> <?php MainWPUtility::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> <tr> <th scope="row"><?php _e('Use Child Site Favicon', 'mainwp'); ?> <?php MainWPUtility::renderToolTip(__('Set to YES if you want to use Child Site Favicon.', 'mainwp')); ?> </th> <td> <div class="mainwp-checkbox"> <input type="checkbox" name="mainwp_use_favicon" id="mainwp_use_favicon" <?php echo get_option('mainwp_use_favicon', 1) == 1 ? 'checked="true"' : ''; ?> "/> <label for="mainwp_use_favicon"></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('View Upgrades per Site', 'mainwp'); ?> <?php MainWPUtility::renderToolTip(__('When this is disabled, the upgrades are shown per plugin/theme with a sublist of sites. When this is enabled, all the sites are shown with the plugin/theme upgrades available per site.', 'mainwp')); ?> </th> <td> <div class="mainwp-checkbox"> <input type="checkbox" name="mainwp_options_siteview" id="mainwp_options_siteview" size="35" <?php echo $siteview == 1 ? 'checked="true"' : ''; ?> /> <label for="mainwp_options_siteview"></label> </div> </td> </tr> <tr> <th scope="row"><?php _e('Require Backup Before Upgrade', 'mainwp'); ?> <?php MainWPUtility::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'); ?> <?php MainWPUtility::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> </td> <td> Last run: <?php echo $lastAutomaticUpdate; ?> <br /> Next run: <?php echo $nextAutomaticUpdate; ?> </td> </tr> </table> </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'); ?> <?php MainWPUtility::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="mainwp-field mainwp-settings-icon" 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'); ?> <?php MainWPUtility::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="mainwp-field mainwp-settings-icon" id="mainwp_maximumComments" value="<?php echo get_option('mainwp_maximumComments') === false ? 50 : get_option('mainwp_maximumComments'); ?> "/> </td> </tr> </tbody> </table> </div> </div> <?php }
function column_details($item) { $output = '<strong>' . __('LAST RUN MANUALLY: ', 'mainwp') . '</strong>' . ($item->last_run_manually == 0 ? '-' : MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($item->last_run_manually))) . '<br />'; $output .= '<strong>' . __('LAST RUN: ', 'mainwp') . '</strong>' . ($item->last_run == 0 ? '-' : MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($item->last_run))) . '<br />'; $output .= '<strong>' . __('LAST COMPLETED: ', 'mainwp') . '</strong>' . ($item->completed == 0 ? '-' : MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($item->completed))) . '<br />'; $output .= '<strong>' . __('NEXT RUN: ', 'mainwp') . '</strong>' . ($item->last_run == 0 ? __('Any minute', 'mainwp') : MainWPUtility::formatTimestamp(($item->schedule == 'daily' ? 60 * 60 * 24 : ($item->schedule == 'weekly' ? 60 * 60 * 24 * 7 : 60 * 60 * 24 * 30)) + MainWPUtility::getTimestamp($item->last_run))); $output .= '<strong>'; if ($item->last_run != 0 && $item->completed < $item->last_run) { $output .= __('<br />CURRENTLY RUNNING: ') . '</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 render() { $news = get_option('mainwp_news'); $newstimestamp = get_option('mainwp_news_timestamp'); if ($newstimestamp === false || time() - $newstimestamp > 60 * 60 * 24) { try { $result = MainWPUtility::http_post("do=news", "mainwp.com", "/versioncontrol/rqst.php", 80, 'main', true); } catch (Exception $e) { MainWPLogger::Instance()->warning('An error occured when trying to reach the MainWP server: ' . $e->getMessage()); } //get news.. if (isset($result[1])) { $news = json_decode($result[1], true); MainWPUtility::update_option('mainwp_news', $news); MainWPUtility::update_option('mainwp_news_timestamp', time()); } } if (!is_array($news) || count($news) == 0) { //No news.. ?> <div>No news items found.</div> <?php return; } ?> <div> <div id="mainwp-news-tabs" class="mainwp-row" style="border-top: 0px"> <?php $newsCategories = array(); foreach ($news as $newsItem) { if (!in_array($newsItem['category'], $newsCategories)) { $newsCategories[] = $newsItem['category']; } } for ($i = 0; $i < count($newsCategories); $i++) { $category = $newsCategories[$i]; /** @var $class string */ if (count($newsCategories) == 1) { $class = 'single'; } else { if ($i == count($newsCategories) - 1) { $class = 'right'; } else { if ($i == 0) { $class = 'left'; } else { $class = 'mid'; } } } if ($category == 'MainWP') { $class .= ' mainwp_action_down'; } ?> <a class="mainwp_action <?php echo $class; ?> mainwp-news-tab" href="#" name="<?php echo MainWPUtility::sanitize($category); ?> "><?php _e($category, 'mainwp'); ?> </a><?php } ?> </div> <div id="mainwp-news-list"> <?php $category = ''; foreach ($news as $newsItem) { if ($category != $newsItem['category']) { if ($category != '') { echo '</div>'; } echo '<div class="mainwp-news-items" name="' . MainWPUtility::sanitize($newsItem['category']) . '" ' . ($newsItem['category'] == 'MainWP' ? '' : 'style="display: none;"') . '>'; } ?> <div class="mainwp-news-item" title="<?php echo MainWPUtility::sanitize($newsItem['title']); ?> "> <strong><?php echo $newsItem['title']; ?> </strong><br /> <?php echo $newsItem['body']; ?> <div style="text-align: right"><em>Submitted <?php if (isset($newsItem['submitter']) && $newsItem['submitter'] != '') { echo 'by <strong>' . $newsItem['submitter'] . '</strong> '; } ?> at <strong><?php echo MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($newsItem['timestamp'])); ?> </strong></em></div> </div> <?php if ($category != $newsItem['category']) { $category = $newsItem['category']; } } if ($category != '') { echo '</div>'; } ?> </div> </div> <?php }