Beispiel #1
0
 function mainwp_cronupdatescheck_action()
 {
     MainWPLogger::Instance()->info('CRON :: updates check');
     @ignore_user_abort(true);
     @set_time_limit(0);
     $mem = '512M';
     @ini_set('memory_limit', $mem);
     @ini_set('max_execution_time', 0);
     MainWPUtility::update_option('mainwp_cron_last_updatescheck', time());
     $mainwpAutomaticDailyUpdate = get_option('mainwp_automaticDailyUpdate');
     $mainwpLastAutomaticUpdate = get_option('mainwp_updatescheck_last');
     if ($mainwpLastAutomaticUpdate == date('d/m/Y')) {
         MainWPLogger::Instance()->debug('CRON :: updates check :: already updated today');
         return;
     }
     $websites = MainWPDB::Instance()->getWebsitesCheckUpdates(4);
     MainWPLogger::Instance()->debug('CRON :: updates check :: found ' . count($websites) . ' websites');
     $userid = null;
     foreach ($websites as $website) {
         $websiteValues = array('dtsAutomaticSyncStart' => time());
         if ($userid == null) {
             $userid = $website->userid;
         }
         MainWPDB::Instance()->updateWebsiteSyncValues($website->id, $websiteValues);
     }
     if (count($websites) == 0) {
         $busyCounter = MainWPDB::Instance()->getWebsitesCountWhereDtsAutomaticSyncSmallerThenStart();
         if ($busyCounter == 0) {
             MainWPLogger::Instance()->debug('CRON :: updates check :: got to the mail part');
             //Send the email & update all to this time!
             $mail = '';
             $sendMail = false;
             $sitesCheckCompleted = null;
             if (get_option('mainwp_backup_before_upgrade') == 1) {
                 $sitesCheckCompleted = get_option('mainwp_automaticUpdate_backupChecks');
                 if (!is_array($sitesCheckCompleted)) {
                     $sitesCheckCompleted = null;
                 }
             }
             $pluginsNewUpdate = get_option('mainwp_updatescheck_mail_update_plugins_new');
             if (!is_array($pluginsNewUpdate)) {
                 $pluginsNewUpdate = array();
             }
             $pluginsToUpdate = get_option('mainwp_updatescheck_mail_update_plugins');
             if (!is_array($pluginsToUpdate)) {
                 $pluginsToUpdate = array();
             }
             $ignoredPluginsNewUpdate = get_option('mainwp_updatescheck_mail_ignore_plugins_new');
             if (!is_array($ignoredPluginsNewUpdate)) {
                 $ignoredPluginsNewUpdate = array();
             }
             $ignoredPluginsToUpdate = get_option('mainwp_updatescheck_mail_ignore_plugins');
             if (!is_array($ignoredPluginsToUpdate)) {
                 $ignoredPluginsToUpdate = array();
             }
             if (count($pluginsNewUpdate) != 0 || count($pluginsToUpdate) != 0 || count($ignoredPluginsNewUpdate) != 0 || count($ignoredPluginsToUpdate) != 0) {
                 $sendMail = true;
                 $mail .= '<div><strong>WordPress Plugin Updates</strong></div>';
                 $mail .= '<ul>';
                 $mail .= $this->print_updates_array_lines($pluginsNewUpdate, null);
                 $mail .= $this->print_updates_array_lines($pluginsToUpdate, $sitesCheckCompleted);
                 $mail .= $this->print_updates_array_lines($ignoredPluginsNewUpdate, null);
                 $mail .= $this->print_updates_array_lines($ignoredPluginsToUpdate, null);
                 $mail .= '</ul>';
             }
             $themesNewUpdate = get_option('mainwp_updatescheck_mail_update_themes_new');
             if (!is_array($themesNewUpdate)) {
                 $themesNewUpdate = array();
             }
             $themesToUpdate = get_option('mainwp_updatescheck_mail_update_themes');
             if (!is_array($themesToUpdate)) {
                 $themesToUpdate = array();
             }
             $ignoredThemesNewUpdate = get_option('mainwp_updatescheck_mail_ignore_themes_new');
             if (!is_array($ignoredThemesNewUpdate)) {
                 $ignoredThemesNewUpdate = array();
             }
             $ignoredThemesToUpdate = get_option('mainwp_updatescheck_mail_ignore_themes');
             if (!is_array($ignoredThemesToUpdate)) {
                 $ignoredThemesToUpdate = array();
             }
             if (count($themesNewUpdate) != 0 || count($themesToUpdate) != 0 || count($ignoredThemesNewUpdate) != 0 || count($ignoredThemesToUpdate) != 0) {
                 $sendMail = true;
                 $mail .= '<div><strong>WordPress Themes Updates</strong></div>';
                 $mail .= '<ul>';
                 $mail .= $this->print_updates_array_lines($themesNewUpdate, null);
                 $mail .= $this->print_updates_array_lines($themesToUpdate, $sitesCheckCompleted);
                 $mail .= $this->print_updates_array_lines($ignoredThemesNewUpdate, null);
                 $mail .= $this->print_updates_array_lines($ignoredThemesToUpdate, null);
                 $mail .= '</ul>';
             }
             $coreNewUpdate = get_option('mainwp_updatescheck_mail_update_core_new');
             if (!is_array($coreNewUpdate)) {
                 $coreNewUpdate = array();
             }
             $coreToUpdate = get_option('mainwp_updatescheck_mail_update_core');
             if (!is_array($coreToUpdate)) {
                 $coreToUpdate = array();
             }
             $ignoredCoreNewUpdate = get_option('mainwp_updatescheck_mail_ignore_core_new');
             if (!is_array($ignoredCoreNewUpdate)) {
                 $ignoredCoreNewUpdate = array();
             }
             $ignoredCoreToUpdate = get_option('mainwp_updatescheck_mail_ignore_core');
             if (!is_array($ignoredCoreToUpdate)) {
                 $ignoredCoreToUpdate = array();
             }
             if (count($coreNewUpdate) != 0 || count($coreToUpdate) != 0 || count($ignoredCoreNewUpdate) != 0 || count($ignoredCoreToUpdate) != 0) {
                 $sendMail = true;
                 $mail .= '<div><strong>WordPress Core Updates</strong></div>';
                 $mail .= '<ul>';
                 $mail .= $this->print_updates_array_lines($coreNewUpdate, null);
                 $mail .= $this->print_updates_array_lines($coreToUpdate, $sitesCheckCompleted);
                 $mail .= $this->print_updates_array_lines($ignoredCoreNewUpdate, null);
                 $mail .= $this->print_updates_array_lines($ignoredCoreToUpdate, null);
                 $mail .= '</ul>';
             }
             $pluginConflicts = get_option('mainwp_updatescheck_mail_pluginconflicts');
             if ($pluginConflicts === false) {
                 $pluginConflicts = '';
             }
             if ($pluginConflicts != '') {
                 $sendMail = true;
                 $mail .= '<div><strong>WordPress Plugin Conflicts</strong></div>';
                 $mail .= '<ul>';
                 $mail .= $pluginConflicts;
                 $mail .= '</ul>';
             }
             $themeConflicts = get_option('mainwp_updatescheck_mail_themeconflicts');
             if ($themeConflicts === false) {
                 $themeConflicts = '';
             }
             if ($themeConflicts != '') {
                 $sendMail = true;
                 $mail .= '<div><strong>WordPress Theme Conflicts</strong></div>';
                 $mail .= '<ul>';
                 $mail .= $themeConflicts;
                 $mail .= '</ul>';
             }
             MainWPUtility::update_option('mainwp_automaticUpdate_backupChecks', '');
             MainWPUtility::update_option('mainwp_updatescheck_mail_update_core_new', '');
             MainWPUtility::update_option('mainwp_updatescheck_mail_update_plugins_new', '');
             MainWPUtility::update_option('mainwp_updatescheck_mail_update_themes_new', '');
             MainWPUtility::update_option('mainwp_updatescheck_mail_update_core', '');
             MainWPUtility::update_option('mainwp_updatescheck_mail_update_plugins', '');
             MainWPUtility::update_option('mainwp_updatescheck_mail_update_themes', '');
             MainWPUtility::update_option('mainwp_updatescheck_mail_ignore_core', '');
             MainWPUtility::update_option('mainwp_updatescheck_mail_ignore_plugins', '');
             MainWPUtility::update_option('mainwp_updatescheck_mail_ignore_themes', '');
             MainWPUtility::update_option('mainwp_updatescheck_mail_ignore_core_new', '');
             MainWPUtility::update_option('mainwp_updatescheck_mail_ignore_plugins_new', '');
             MainWPUtility::update_option('mainwp_updatescheck_mail_ignore_themes_new', '');
             MainWPUtility::update_option('mainwp_updatescheck_mail_pluginconflicts', '');
             MainWPUtility::update_option('mainwp_updatescheck_mail_themeconflicts', '');
             MainWPUtility::update_option('mainwp_updatescheck_last', date('d/m/Y'));
             if (!$sendMail) {
                 MainWPLogger::Instance()->debug('CRON :: updates check :: sendMail is false');
                 return;
             }
             if ($mainwpAutomaticDailyUpdate !== false && $mainwpAutomaticDailyUpdate != 0) {
                 //Create a nice email to send
                 $email = get_option('mainwp_updatescheck_mail_email');
                 MainWPLogger::Instance()->debug('CRON :: updates check :: send mail to ' . $email);
                 if ($email != false && $email != '') {
                     $mail = '<div>We noticed the following updates are available on your MainWP Dashboard. (<a href="' . site_url() . '">' . site_url() . '</a>)</div>
                              <div></div>
                              ' . $mail . '
                              Update Key: (<strong><span style="color:#008000">Trusted</span></strong>) will be auto updated within 24 hours. (<strong><span style="color:#ff0000">Not Trusted</span></strong>) you will need to log into your Main Dashboard and update
                              <div> </div>
                              <div>If your MainWP is configured to use Auto Updates these upgrades will be installed in the next 24 hours. To find out how to enable automatic updates please see the FAQs below.</div>
                              <div><a href="http://docs.mainwp.com/marking-a-plugin-as-trusted/" style="color:#446200" target="_blank">http://docs.mainwp.com/marking-a-plugin-as-trusted/</a></div>
                              <div><a href="http://docs.mainwp.com/marking-a-theme-as-trusted/" style="color:#446200" target="_blank">http://docs.mainwp.com/marking-a-theme-as-trusted/</a></div>
                              <div><a href="http://docs.mainwp.com/marking-a-sites-wp-core-updates-as-trusted/" style="color:#446200" target="_blank">http://docs.mainwp.com/marking-a-sites-wp-core-updates-as-trusted/</a></div>';
                     wp_mail($email, 'MainWP - Trusted Updates', MainWPUtility::formatEmail($email, $mail), array('From: "' . get_option('admin_email') . '" <' . get_option('admin_email') . '>', 'content-type: text/html'));
                 }
             }
         }
     } else {
         $userExtension = MainWPDB::Instance()->getUserExtensionByUserId($userid);
         $decodedIgnoredPlugins = json_decode($userExtension->ignored_plugins, true);
         if (!is_array($decodedIgnoredPlugins)) {
             $decodedIgnoredPlugins = array();
         }
         $trustedPlugins = json_decode($userExtension->trusted_plugins, true);
         if (!is_array($trustedPlugins)) {
             $trustedPlugins = array();
         }
         $decodedIgnoredThemes = json_decode($userExtension->ignored_themes, true);
         if (!is_array($decodedIgnoredThemes)) {
             $decodedIgnoredThemes = array();
         }
         $trustedThemes = json_decode($userExtension->trusted_themes, true);
         if (!is_array($trustedThemes)) {
             $trustedThemes = array();
         }
         $coreToUpdateNow = array();
         $coreToUpdate = array();
         $coreNewUpdate = array();
         $ignoredCoreToUpdate = array();
         $ignoredCoreNewUpdate = array();
         $pluginsToUpdateNow = array();
         $pluginsToUpdate = array();
         $pluginsNewUpdate = array();
         $ignoredPluginsToUpdate = array();
         $ignoredPluginsNewUpdate = array();
         $themesToUpdateNow = array();
         $themesToUpdate = array();
         $themesNewUpdate = array();
         $ignoredThemesToUpdate = array();
         $ignoredThemesNewUpdate = array();
         $pluginConflicts = '';
         $themeConflicts = '';
         $allWebsites = array();
         $infoTrustedText = ' (<span style="color:#008000"><strong>Trusted</strong></span>)';
         $infoNotTrustedText = ' (<strong><span style="color:#ff0000">Not Trusted</span></strong>)';
         foreach ($websites as $website) {
             $websiteDecodedIgnoredPlugins = json_decode($website->ignored_plugins, true);
             if (!is_array($websiteDecodedIgnoredPlugins)) {
                 $websiteDecodedIgnoredPlugins = array();
             }
             $websiteDecodedIgnoredThemes = json_decode($website->ignored_themes, true);
             if (!is_array($websiteDecodedIgnoredThemes)) {
                 $websiteDecodedIgnoredThemes = array();
             }
             //Perform check & update
             if (!MainWPSync::syncSite($website, false, true)) {
                 $websiteValues = array('dtsAutomaticSync' => time());
                 MainWPDB::Instance()->updateWebsiteSyncValues($website->id, $websiteValues);
                 continue;
             }
             $website = MainWPDB::Instance()->getWebsiteById($website->id);
             /** Check core upgrades **/
             $websiteLastCoreUpgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'last_wp_upgrades'), true);
             $websiteCoreUpgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'wp_upgrades'), true);
             //Run over every update we had last time..
             if (isset($websiteCoreUpgrades['current'])) {
                 $infoTxt = '<a href="' . admin_url('admin.php?page=managesites&dashboard=' . $website->id) . '">' . $website->name . '</a> - ' . $websiteCoreUpgrades['current'] . ' to ' . $websiteCoreUpgrades['new'];
                 $infoNewTxt = '*NEW* <a href="' . admin_url('admin.php?page=managesites&dashboard=' . $website->id) . '">' . $website->name . '</a> - ' . $websiteCoreUpgrades['current'] . ' to ' . $websiteCoreUpgrades['new'];
                 $newUpdate = !(isset($websiteLastCoreUpgrades['current']) && $websiteLastCoreUpgrades['current'] == $websiteCoreUpgrades['current'] && $websiteLastCoreUpgrades['new'] == $websiteCoreUpgrades['new']);
                 if ($website->automatic_update == 1) {
                     if ($newUpdate) {
                         $coreNewUpdate[] = array($website->id, $infoNewTxt, $infoTrustedText);
                     } else {
                         //Check ignore ? $ignoredCoreToUpdate
                         $coreToUpdateNow[] = $website->id;
                         $allWebsites[$website->id] = $website;
                         $coreToUpdate[] = array($website->id, $infoTxt, $infoTrustedText);
                     }
                 } else {
                     if ($newUpdate) {
                         $ignoredCoreNewUpdate[] = array($website->id, $infoNewTxt, $infoNotTrustedText);
                     } else {
                         $ignoredCoreToUpdate[] = array($website->id, $infoTxt, $infoNotTrustedText);
                     }
                 }
             }
             /** Check plugins **/
             $websiteLastPlugins = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'last_plugin_upgrades'), true);
             $websitePlugins = json_decode($website->plugin_upgrades, true);
             /** Check themes **/
             $websiteLastThemes = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'last_theme_upgrades'), true);
             $websiteThemes = json_decode($website->theme_upgrades, true);
             $decodedPremiumUpgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'premium_upgrades'), true);
             if (is_array($decodedPremiumUpgrades)) {
                 foreach ($decodedPremiumUpgrades as $slug => $premiumUpgrade) {
                     if ($premiumUpgrade['type'] == 'plugin') {
                         if (!is_array($websitePlugins)) {
                             $websitePlugins = array();
                         }
                         $websitePlugins[$slug] = $premiumUpgrade;
                     } else {
                         if ($premiumUpgrade['type'] == 'theme') {
                             if (!is_array($websiteThemes)) {
                                 $websiteThemes = array();
                             }
                             $websiteThemes[$slug] = $premiumUpgrade;
                         }
                     }
                 }
             }
             //Run over every update we had last time..
             foreach ($websitePlugins as $pluginSlug => $pluginInfo) {
                 if (isset($decodedIgnoredPlugins[$pluginSlug]) || isset($websiteDecodedIgnoredPlugins[$pluginSlug])) {
                     continue;
                 }
                 $infoTxt = '<a href="' . admin_url('admin.php?page=managesites&dashboard=' . $website->id) . '">' . $website->name . '</a> - ' . $pluginInfo['Name'] . ' ' . $pluginInfo['Version'] . ' to ' . $pluginInfo['update']['new_version'];
                 $infoNewTxt = '*NEW* <a href="' . admin_url('admin.php?page=managesites&dashboard=' . $website->id) . '">' . $website->name . '</a> - ' . $pluginInfo['Name'] . ' ' . $pluginInfo['Version'] . ' to ' . $pluginInfo['update']['new_version'];
                 $newUpdate = !(isset($websiteLastPlugins[$pluginSlug]) && $pluginInfo['Version'] == $websiteLastPlugins[$pluginSlug]['Version'] && $pluginInfo['update']['new_version'] == $websiteLastPlugins[$pluginSlug]['update']['new_version']);
                 //update this..
                 if (in_array($pluginSlug, $trustedPlugins)) {
                     //Trusted
                     if ($newUpdate) {
                         $pluginsNewUpdate[] = array($website->id, $infoNewTxt, $infoTrustedText);
                     } else {
                         $pluginsToUpdateNow[$website->id][] = $pluginSlug;
                         $allWebsites[$website->id] = $website;
                         $pluginsToUpdate[] = array($website->id, $infoTxt, $infoTrustedText);
                     }
                 } else {
                     //Not trusted
                     if ($newUpdate) {
                         $ignoredPluginsNewUpdate[] = array($website->id, $infoNewTxt, $infoNotTrustedText);
                     } else {
                         $ignoredPluginsToUpdate[] = array($website->id, $infoTxt, $infoNotTrustedText);
                     }
                 }
             }
             //Run over every update we had last time..
             foreach ($websiteThemes as $themeSlug => $themeInfo) {
                 if (isset($decodedIgnoredThemes[$themeSlug]) || isset($websiteDecodedIgnoredThemes[$themeSlug])) {
                     continue;
                 }
                 $infoTxt = '<a href="' . admin_url('admin.php?page=managesites&dashboard=' . $website->id) . '">' . $website->name . '</a> - ' . $themeInfo['Name'] . ' ' . $themeInfo['Version'] . ' to ' . $themeInfo['update']['new_version'];
                 $infoNewTxt = '*NEW* <a href="' . admin_url('admin.php?page=managesites&dashboard=' . $website->id) . '">' . $website->name . '</a> - ' . $themeInfo['Name'] . ' ' . $themeInfo['Version'] . ' to ' . $themeInfo['update']['new_version'];
                 $newUpdate = !(isset($websiteLastThemes[$themeSlug]) && $themeInfo['Version'] == $websiteLastThemes[$themeSlug]['Version'] && $themeInfo['update']['new_version'] == $websiteLastThemes[$themeSlug]['update']['new_version']);
                 //update this..
                 if (in_array($themeSlug, $trustedThemes)) {
                     //Trusted
                     if ($newUpdate) {
                         $themesNewUpdate[] = array($website->id, $infoNewTxt, $infoTrustedText);
                     } else {
                         $themesToUpdateNow[$website->id][] = $themeSlug;
                         $allWebsites[$website->id] = $website;
                         $themesToUpdate[] = array($website->id, $infoTxt, $infoTrustedText);
                     }
                 } else {
                     //Not trusted
                     if ($newUpdate) {
                         $ignoredThemesNewUpdate[] = array($website->id, $infoNewTxt, $infoNotTrustedText);
                     } else {
                         $ignoredThemesToUpdate[] = array($website->id, $infoTxt, $infoNotTrustedText);
                     }
                 }
             }
             /**
              * Show plugin conflicts
              */
             $sitePluginConflicts = json_decode($website->pluginConflicts, true);
             if (count($sitePluginConflicts) > 0) {
                 $infoTxt = '<a href="' . admin_url('admin.php?page=managesites&dashboard=' . $website->id) . '">' . $website->name . '</a> - ';
                 $pluginConflicts .= '<li>' . $infoTxt;
                 $added = false;
                 foreach ($sitePluginConflicts as $sitePluginConflict) {
                     if ($added) {
                         $pluginConflicts .= ', ';
                     }
                     $pluginConflicts .= $sitePluginConflict;
                     $added = true;
                 }
                 $pluginConflicts .= '</li>' . "\n";
             }
             /**
              * Show theme conflicts
              */
             $siteThemeConflicts = json_decode($website->themeConflicts, true);
             if (count($siteThemeConflicts) > 0) {
                 $infoTxt = '<a href="' . admin_url('admin.php?page=managesites&dashboard=' . $website->id) . '">' . $website->name . '</a> - ';
                 $themeConflicts .= '<li>' . $infoTxt;
                 $added = false;
                 foreach ($siteThemeConflicts as $siteThemeConflict) {
                     if ($added) {
                         $themeConflicts .= ', ';
                     }
                     $themeConflicts .= $siteThemeConflict;
                     $added = true;
                 }
                 $themeConflicts .= '</li>' . "\n";
             }
             //Loop over last plugins & current plugins, check if we need to upgrade them..
             $user = get_userdata($website->userid);
             $email = MainWPUtility::getNotificationEmail($user);
             MainWPUtility::update_option('mainwp_updatescheck_mail_email', $email);
             MainWPDB::Instance()->updateWebsiteSyncValues($website->id, array('dtsAutomaticSync' => time()));
             MainWPDB::Instance()->updateWebsiteOption($website, 'last_wp_upgrades', json_encode($websiteCoreUpgrades));
             MainWPDB::Instance()->updateWebsiteOption($website, 'last_plugin_upgrades', $website->plugin_upgrades);
             MainWPDB::Instance()->updateWebsiteOption($website, 'last_theme_upgrades', $website->theme_upgrades);
         }
         if (count($coreNewUpdate) != 0) {
             $coreNewUpdateSaved = get_option('mainwp_updatescheck_mail_update_core_new');
             MainWPUtility::update_option('mainwp_updatescheck_mail_update_core_new', MainWPUtility::array_merge($coreNewUpdateSaved, $coreNewUpdate));
         }
         if (count($pluginsNewUpdate) != 0) {
             $pluginsNewUpdateSaved = get_option('mainwp_updatescheck_mail_update_plugins_new');
             MainWPUtility::update_option('mainwp_updatescheck_mail_update_plugins_new', MainWPUtility::array_merge($pluginsNewUpdateSaved, $pluginsNewUpdate));
         }
         if (count($themesNewUpdate) != 0) {
             $themesNewUpdateSaved = get_option('mainwp_updatescheck_mail_update_themes_new');
             MainWPUtility::update_option('mainwp_updatescheck_mail_update_themes_new', MainWPUtility::array_merge($themesNewUpdateSaved, $themesNewUpdate));
         }
         if (count($coreToUpdate) != 0) {
             $coreToUpdateSaved = get_option('mainwp_updatescheck_mail_update_core');
             MainWPUtility::update_option('mainwp_updatescheck_mail_update_core', MainWPUtility::array_merge($coreToUpdateSaved, $coreToUpdate));
         }
         if (count($pluginsToUpdate) != 0) {
             $pluginsToUpdateSaved = get_option('mainwp_updatescheck_mail_update_plugins');
             MainWPUtility::update_option('mainwp_updatescheck_mail_update_plugins', MainWPUtility::array_merge($pluginsToUpdateSaved, $pluginsToUpdate));
         }
         if (count($themesToUpdate) != 0) {
             $themesToUpdateSaved = get_option('mainwp_updatescheck_mail_update_themes');
             MainWPUtility::update_option('mainwp_updatescheck_mail_update_themes', MainWPUtility::array_merge($themesToUpdateSaved, $themesToUpdate));
         }
         if (count($ignoredCoreToUpdate) != 0) {
             $ignoredCoreToUpdateSaved = get_option('mainwp_updatescheck_mail_ignore_core');
             MainWPUtility::update_option('mainwp_updatescheck_mail_ignore_core', MainWPUtility::array_merge($ignoredCoreToUpdateSaved, $ignoredCoreToUpdate));
         }
         if (count($ignoredCoreNewUpdate) != 0) {
             $ignoredCoreNewUpdateSaved = get_option('mainwp_updatescheck_mail_ignore_core_new');
             MainWPUtility::update_option('mainwp_updatescheck_mail_ignore_core_new', MainWPUtility::array_merge($ignoredCoreNewUpdateSaved, $ignoredCoreNewUpdate));
         }
         if (count($ignoredPluginsToUpdate) != 0) {
             $ignoredPluginsToUpdateSaved = get_option('mainwp_updatescheck_mail_ignore_plugins');
             MainWPUtility::update_option('mainwp_updatescheck_mail_ignore_plugins', MainWPUtility::array_merge($ignoredPluginsToUpdateSaved, $ignoredPluginsToUpdate));
         }
         if (count($ignoredPluginsNewUpdate) != 0) {
             $ignoredPluginsNewUpdateSaved = get_option('mainwp_updatescheck_mail_ignore_plugins_new');
             MainWPUtility::update_option('mainwp_updatescheck_mail_ignore_plugins_new', MainWPUtility::array_merge($ignoredPluginsNewUpdateSaved, $ignoredPluginsNewUpdate));
         }
         if (count($ignoredThemesToUpdate) != 0) {
             $ignoredThemesToUpdateSaved = get_option('mainwp_updatescheck_mail_ignore_themes');
             MainWPUtility::update_option('mainwp_updatescheck_mail_ignore_themes', MainWPUtility::array_merge($ignoredThemesToUpdateSaved, $ignoredThemesToUpdate));
         }
         if (count($ignoredThemesNewUpdate) != 0) {
             $ignoredThemesNewUpdateSaved = get_option('mainwp_updatescheck_mail_ignore_themes_new');
             MainWPUtility::update_option('mainwp_updatescheck_mail_ignore_themes_new', MainWPUtility::array_merge($ignoredThemesNewUpdateSaved, $ignoredThemesNewUpdate));
         }
         if ($pluginConflicts != '') {
             $pluginConflictsSaved = get_option('mainwp_updatescheck_mail_pluginconflicts');
             if ($pluginConflictsSaved == false) {
                 $pluginConflictsSaved = '';
             }
             MainWPUtility::update_option('mainwp_updatescheck_mail_pluginconflicts', $pluginConflictsSaved . $pluginConflicts);
         }
         if ($themeConflicts != '') {
             $themeConflictsSaved = get_option('mainwp_updatescheck_mail_themeconflicts');
             if ($themeConflictsSaved == false) {
                 $themeConflictsSaved = '';
             }
             MainWPUtility::update_option('mainwp_updatescheck_mail_themeconflicts', $themeConflictsSaved . $themeConflicts);
         }
         if (count($coreToUpdate) == 0 && count($pluginsToUpdate) == 0 && count($themesToUpdate) == 0 && count($ignoredCoreToUpdate) == 0 && count($ignoredCoreNewUpdate) == 0 && count($ignoredPluginsToUpdate) == 0 && count($ignoredPluginsNewUpdate) == 0 && count($ignoredThemesToUpdate) == 0 && count($ignoredThemesNewUpdate) == 0 && $pluginConflicts == '' && $themeConflicts == '') {
             return;
         }
         if (get_option('mainwp_automaticDailyUpdate') != 1) {
             return;
         }
         //Check if backups are required!
         if (get_option('mainwp_backup_before_upgrade') == 1) {
             $sitesCheckCompleted = get_option('mainwp_automaticUpdate_backupChecks');
             if (!is_array($sitesCheckCompleted)) {
                 $sitesCheckCompleted = array();
             }
             $websitesToCheck = array();
             foreach ($pluginsToUpdateNow as $websiteId => $slugs) {
                 $websitesToCheck[$websiteId] = true;
             }
             foreach ($themesToUpdateNow as $websiteId => $slugs) {
                 $websitesToCheck[$websiteId] = true;
             }
             foreach ($coreToUpdateNow as $websiteId) {
                 $websitesToCheck[$websiteId] = true;
             }
             foreach ($websitesToCheck as $siteId => $bool) {
                 if ($allWebsites[$siteId]->backup_before_upgrade == 0) {
                     $sitesCheckCompleted[$siteId] = true;
                 }
                 if (isset($sitesCheckCompleted[$siteId])) {
                     continue;
                 }
                 $dir = MainWPUtility::getMainWPSpecificDir($siteId);
                 //Check if backup ok
                 $lastBackup = -1;
                 if (file_exists($dir) && ($dh = opendir($dir))) {
                     while (($file = readdir($dh)) !== false) {
                         if ($file != '.' && $file != '..') {
                             $theFile = $dir . $file;
                             if (MainWPUtility::isArchive($file) && !MainWPUtility::isSQLArchive($file) && filemtime($theFile) > $lastBackup) {
                                 $lastBackup = filemtime($theFile);
                             }
                         }
                     }
                     closedir($dh);
                 }
                 $backupRequired = $lastBackup < time() - 7 * 24 * 60 * 60 ? true : false;
                 if (!$backupRequired) {
                     $sitesCheckCompleted[$siteId] = true;
                     MainWPUtility::update_option('mainwp_automaticUpdate_backupChecks', $sitesCheckCompleted);
                     continue;
                 }
                 try {
                     $result = MainWPManageSites::backup($siteId, 'full', '', '', 0, 0, 0, 0);
                     MainWPManageSites::backupDownloadFile($siteId, 'full', $result['url'], $result['local']);
                     $sitesCheckCompleted[$siteId] = true;
                     MainWPUtility::update_option('mainwp_automaticUpdate_backupChecks', $sitesCheckCompleted);
                 } catch (Exception $e) {
                     $sitesCheckCompleted[$siteId] = false;
                     MainWPUtility::update_option('mainwp_automaticUpdate_backupChecks', $sitesCheckCompleted);
                 }
             }
         } else {
             $sitesCheckCompleted = null;
         }
         //Update plugins
         foreach ($pluginsToUpdateNow as $websiteId => $slugs) {
             if ($sitesCheckCompleted != null && $sitesCheckCompleted[$websiteId] == false) {
                 continue;
             }
             try {
                 MainWPUtility::fetchUrlAuthed($allWebsites[$websiteId], 'upgradeplugintheme', array('type' => 'plugin', 'list' => urldecode(implode(',', $slugs))));
                 if (isset($information['sync']) && !empty($information['sync'])) {
                     MainWPSync::syncInformationArray($allWebsites[$websiteId], $information['sync']);
                 }
             } catch (Exception $e) {
             }
         }
         //Update themes
         foreach ($themesToUpdateNow as $websiteId => $slugs) {
             if ($sitesCheckCompleted != null && $sitesCheckCompleted[$websiteId] == false) {
                 continue;
             }
             try {
                 MainWPUtility::fetchUrlAuthed($allWebsites[$websiteId], 'upgradeplugintheme', array('type' => 'theme', 'list' => urldecode(implode(',', $slugs))));
                 if (isset($information['sync']) && !empty($information['sync'])) {
                     MainWPSync::syncInformationArray($allWebsites[$websiteId], $information['sync']);
                 }
             } catch (Exception $e) {
             }
         }
         //Update core
         foreach ($coreToUpdateNow as $websiteId) {
             if ($sitesCheckCompleted != null && $sitesCheckCompleted[$websiteId] == false) {
                 continue;
             }
             try {
                 MainWPUtility::fetchUrlAuthed($allWebsites[$websiteId], 'upgrade');
             } catch (Exception $e) {
             }
         }
         do_action('mainwp_cronupdatecheck_action', $pluginsNewUpdate, $pluginsToUpdate, $pluginsToUpdateNow, $themesNewUpdate, $themesToUpdate, $themesToUpdateNow, $coreNewUpdate, $coreToUpdate, $coreToUpdateNow);
     }
 }
    public static function renderAllSites(&$website, $updated, $groups, $statusses, $pluginDir)
    {
        if (!mainwp_current_user_can("dashboard", "edit_sites")) {
            mainwp_do_not_have_permissions("edit sites");
            return;
        }
        $remote_destinations = apply_filters('mainwp_backups_remote_get_destinations', null, array('website' => $website->id));
        $hasRemoteDestinations = $remote_destinations == null ? $remote_destinations : count($remote_destinations);
        ?>
        <div class="error below-h2" style="display: none;" id="ajax-error-zone"></div>
        <div id="ajax-information-zone" class="updated" style="display: none;"></div>
        <?php 
        if ($updated) {
            ?>
            <div id="mainwp_managesites_edit_message" class="updated"><p><?php 
            _e('Website updated.', 'mainwp');
            ?>
</p></div>
            <?php 
        }
        ?>
        <form method="POST" action="" id="mainwp-edit-single-site-form" enctype="multipart/form-data">
            <div class="postbox">
            <h3 class="mainwp_box_title"><i class="fa fa-cog"></i> <?php 
        _e('General Options', 'mainwp');
        ?>
</h3>
            <div class="inside">
            <table class="form-table">
                <tbody>
                <tr>
                    <th scope="row"><?php 
        _e('Site Name', 'mainwp');
        ?>
</th>
                    <td><input type="text" name="mainwp_managesites_edit_sitename"
                               value="<?php 
        echo stripslashes($website->name);
        ?>
" class="regular-text mainwp-field mainwp-site"/></td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Site URL', 'mainwp');
        ?>
</th>
                    <td><input type="text" id="mainwp_managesites_edit_siteurl" disabled="disabled"
                               value="<?php 
        echo $website->url;
        ?>
" class="regular-text mainwp-field mainwp-url" /> <span
                            class="mainwp-form_hint-display"><?php 
        _e('Site URL cannot be changed.', 'mainwp');
        ?>
</span></td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Administrator Username', 'mainwp');
        ?>
</th>
                    <td><input type="text" name="mainwp_managesites_edit_siteadmin"
                               id="mainwp_managesites_edit_siteadmin"
                               value="<?php 
        echo $website->adminname;
        ?>
"
                               class="regular-text  mainwp-field mainwp-username"/></td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Groups', 'mainwp');
        ?>
</th>
                    <td>
                        <input type="text" name="mainwp_managesites_edit_addgroups"
                               id="mainwp_managesites_edit_addgroups" value=""
                               class="regular-text  mainwp-field mainwp-groups"/> <span
                            class="mainwp-form_hint"><?php 
        _e('Separate groups by commas (e.g. Group 1, Group 2).', 'mainwp');
        ?>
</span>

                        <div id="selected_groups" style="display: block; width: 25em">
                            <?php 
        if (count($groups) == 0) {
            echo 'No groups added yet.';
        }
        $groupsSite = MainWPDB::Instance()->getGroupsByWebsiteId($website->id);
        foreach ($groups as $group) {
            echo '<div class="mainwp_selected_groups_item"><input type="checkbox" name="selected_groups[]" value="' . $group->id . '" ' . (isset($groupsSite[$group->id]) && $groupsSite[$group->id] ? 'checked' : '') . ' />&nbsp' . $group->name . '</div>';
        }
        ?>
                        </div>
                        <span class="description"><?php 
        _e('Or assign existing groups.', 'mainwp');
        ?>
</span>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Offline Checks', 'mainwp');
        ?>
</th>
                    <td>
                        <input type="radio" name="offline_checks" id="check_disabled" value="disabled"
                            <?php 
        echo !in_array($website->offline_checks, $statusses) ? 'checked="true"' : '';
        ?>
 /> <?php 
        _e('Disabled', 'mainwp');
        ?>
 &nbsp;&nbsp;&nbsp;
                        <input type="radio" name="offline_checks" id="check_hourly"
                               value="hourly" <?php 
        echo $website->offline_checks == 'hourly' ? 'checked="true"' : '';
        ?>
/> <?php 
        _e('Hourly', 'mainwp');
        ?>
 &nbsp;&nbsp;&nbsp;
                        <input type="radio" name="offline_checks" id="check_2xday"
                               value="2xday" <?php 
        echo $website->offline_checks == '2xday' ? 'checked="true"' : '';
        ?>
/> <?php 
        _e('2x Day', 'mainwp');
        ?>
 &nbsp;&nbsp;&nbsp;
                        <input type="radio" name="offline_checks" id="check_daily"
                               value="daily" <?php 
        echo $website->offline_checks == 'daily' ? 'checked="true"' : '';
        ?>
/> <?php 
        _e('Daily', 'mainwp');
        ?>
 &nbsp;&nbsp;&nbsp;
                        <input type="radio" name="offline_checks" id="check_weekly" value="weekly"
                            <?php 
        echo $website->offline_checks == 'weekly' ? 'checked="true"' : '';
        ?>
/>
                        Weekly  &nbsp;
                    <span class="mainwp-form_hint-display"><?php 
        _e('Notifications are sent to:', 'mainwp');
        ?>
 <?php 
        echo MainWPUtility::getNotificationEmail();
        ?>
                        (<?php 
        _e('this address can be changed', 'mainwp');
        ?>
 <a
                                href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=Settings"><?php 
        _e('here', 'mainwp');
        ?>
</a>)</span>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Client Plugin Folder Option', 'mainwp');
        ?>
 <?php 
        MainWPUtility::renderToolTip('Default, files/folders on the child site are viewable.<br />Hidden, when attempting to view files a 404 file will be returned, however a footprint does still exist.<br /><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.</strong>');
        ?>
</th>
                    <td>
                        <div class="mainwp-radio" style="float: left;">
                          <input type="radio" value="" name="mainwp_options_footprint_plugin_folder" id="mainwp_options_footprint_plugin_folder_global" <?php 
        echo $pluginDir == '' ? 'checked="true"' : '';
        ?>
"/>
                          <label for="mainwp_options_footprint_plugin_folder_global"></label>
                        </div>Global Setting (<a href="<?php 
        echo admin_url('admin.php?page=Settings#network-footprint');
        ?>
">Change Here</a>)<br/>
                        <div class="mainwp-radio" style="float: left;">
                          <input type="radio" value="default" name="mainwp_options_footprint_plugin_folder" id="mainwp_options_footprint_plugin_folder_default" <?php 
        echo $pluginDir == 'default' ? 'checked="true"' : '';
        ?>
"/>
                          <label for="mainwp_options_footprint_plugin_folder_default"></label>
                        </div>Default<br/>
                        <div class="mainwp-radio" style="float: left;">
                          <input type="radio" value="hidden" name="mainwp_options_footprint_plugin_folder" id="mainwp_options_footprint_plugin_folder_hidden" <?php 
        echo $pluginDir == 'hidden' ? 'checked="true"' : '';
        ?>
/>
                          <label for="mainwp_options_footprint_plugin_folder_hidden"></label>
                        </div>Hidden (<strong>Note: </strong><i>If the heatmap is turned on, the heatmap javascript will still be visible.</i>) <br/>
                    </td>
                </tr>               
                <tr>
                    <th scope="row"><?php 
        _e('Require Backup Before Upgrade', 'mainwp');
        ?>
 <?php 
        MainWPUtility::renderToolTip(__('Backup only works when enabled in the global settings as well.', 'mainwp'), admin_url('admin.php?page=Settings'));
        ?>
</th>
                    <td>
                         <select id="mainwp_backup_before_upgrade" name="mainwp_backup_before_upgrade">
                             <option <?php 
        echo $website->backup_before_upgrade == 1 ? "selected" : "";
        ?>
 value="1"><?php 
        _e('Yes', 'mainwp');
        ?>
</option>
                             <option <?php 
        echo $website->backup_before_upgrade == 0 ? "selected" : "";
        ?>
 value="0"><?php 
        _e('No', 'mainwp');
        ?>
</option>
                             <option <?php 
        echo $website->backup_before_upgrade == 2 ? "selected" : "";
        ?>
 value="2"><?php 
        _e('Use Global Setting', 'mainwp');
        ?>
</option>
                         </select> <i>(<?php 
        _e('Default', 'mainwp');
        ?>
: <?php 
        _e('Use Global Setting', 'mainwp');
        ?>
)</i>
                         
                    </td>
                </tr>
                 <tr>
                    <th scope="row"><?php 
        _e('Auto Update Core', 'mainwp');
        ?>
 <?php 
        MainWPUtility::renderToolTip('Auto update only works when enabled in the global settings as well.', admin_url('admin.php?page=Settings'));
        ?>
</th>
                    <td>
                        <div class="mainwp-checkbox">
                        <input type="checkbox" name="mainwp_automaticDailyUpdate"
                               id="mainwp_automaticDailyUpdate" <?php 
        echo $website->automatic_update == 1 ? 'checked="true"' : '';
        ?>
 />
                        <label for="mainwp_automaticDailyUpdate"></label>
                        </div>
                    </td>
                </tr>
                <?php 
        if (mainwp_current_user_can("dashboard", "ignore_unignore_updates")) {
            ?>
                <tr>
                    <th scope="row"><?php 
            _e('Ignore Core Updates', 'mainwp');
            ?>
 <?php 
            MainWPUtility::renderToolTip('Set to YES if you want to Ignore Core Updates.');
            ?>
</th>
                    <td>
                        <div class="mainwp-checkbox">
                        <input type="checkbox" name="mainwp_is_ignoreCoreUpdates"
                               id="mainwp_is_ignoreCoreUpdates" <?php 
            echo $website->is_ignoreCoreUpdates == 1 ? 'checked="true"' : '';
            ?>
 />
                        <label for="mainwp_is_ignoreCoreUpdates"></label>
                        </div>
                    </td>
                </tr>  
                <tr>
                    <th scope="row"><?php 
            _e('Ignore All Plugin Updates', 'mainwp');
            ?>
 <?php 
            MainWPUtility::renderToolTip('Set to YES if you want to Ignore All Plugin Updates.');
            ?>
</th>
                    <td>
                        <div class="mainwp-checkbox">
                        <input type="checkbox" name="mainwp_is_ignorePluginUpdates"
                               id="mainwp_is_ignorePluginUpdates" <?php 
            echo $website->is_ignorePluginUpdates == 1 ? 'checked="true"' : '';
            ?>
 />
                        <label for="mainwp_is_ignorePluginUpdates"></label>
                        </div>
                    </td>
                </tr>  
                <tr>
                    <th scope="row"><?php 
            _e('Ignore All Theme Updates', 'mainwp');
            ?>
 <?php 
            MainWPUtility::renderToolTip('Set to YES if you want to Ignore All Theme Updates.');
            ?>
</th>
                    <td>
                        <div class="mainwp-checkbox">
                        <input type="checkbox" name="mainwp_is_ignoreThemeUpdates"
                               id="mainwp_is_ignoreThemeUpdates" <?php 
            echo $website->is_ignoreThemeUpdates == 1 ? 'checked="true"' : '';
            ?>
 />
                        <label for="mainwp_is_ignoreThemeUpdates"></label>
                        </div>
                    </td>
                </tr>
                <?php 
        }
        ?>
                <?php 
        do_action('mainwp_extension_sites_edit_tablerow', $website);
        ?>
                </tbody>
            </table>
            </div>
            </div>
            <div class="clear"></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" style="width: 100%">
                <?php 
        $disabled_unique = empty($website->uniqueId) ? true : false;
        ?>
 
                <tr class="form-field form-required">
                    <th scope="row"><?php 
        _e('Child Unique Security
                      ID: ', 'mainwp');
        MainWPUtility::renderToolTip('The Unique Security ID adds additional protection between the Child plugin and your Main Dashboard. The Unique Security ID will need to match when being added to the Main Dashboard. This is additional security and should not be needed in most situations.');
        ?>
</th>
                    <td><input type="text" id="mainwp_managesites_edit_uniqueId" style="width: 350px;" <?php 
        echo $disabled_unique ? 'disabled="disabled"' : '';
        ?>
                             name="mainwp_managesites_edit_uniqueId" value="<?php 
        echo $website->uniqueId;
        ?>
" class="mainwp-field mainwp-unique-id"/><span class="mainwp-form_hint">The Unique Security ID adds additional protection between the Child plugin and your Main Dashboard. The Unique Security ID will need to match when being added to the Main Dashboard. This is additional security and should not be needed in most situations.</span></td>
                </tr>                
                 <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_edit_verifycertificate" name="mainwp_managesites_edit_verifycertificate">
                             <option <?php 
        echo $website->verify_certificate == 1 ? "selected" : "";
        ?>
 value="1"><?php 
        _e('Yes', 'mainwp');
        ?>
</option>
                             <option <?php 
        echo $website->verify_certificate == 0 ? "selected" : "";
        ?>
 value="0"><?php 
        _e('No', 'mainwp');
        ?>
</option>
                             <option <?php 
        echo $website->verify_certificate == 2 ? "selected" : "";
        ?>
 value="2"><?php 
        _e('Use Global Setting', 'mainwp');
        ?>
</option>
                         </select> <i>(Default: Yes)</i>
                    </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_edit_http_user" style="width: 350px;" name="mainwp_managesites_edit_http_user" value="<?php 
        echo empty($website->http_user) ? '' : $website->http_user;
        ?>
" 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_edit_http_pass" style="width: 350px;" name="mainwp_managesites_edit_http_pass" value="<?php 
        echo empty($website->http_pass) ? '' : $website->http_pass;
        ?>
" class="mainwp-field mainwp-password"/></td>
                </tr>
            </table>
            </div>
            </div>
            
            <div class="clear"></div>
            <div class="postbox">
            <h3 class="mainwp_box_title"><span><i class="fa fa-cog"></i> <?php 
        _e('Backup Settings', 'mainwp');
        ?>
</span></h3>
            <div class="inside">
            <table class="form-table" style="width: 100%">
                <?php 
        $globalArchiveFormat = get_option('mainwp_archiveFormat');
        if ($globalArchiveFormat == false) {
            $globalArchiveFormat = 'tar.gz';
        }
        if ($globalArchiveFormat == 'zip') {
            $globalArchiveFormatText = 'Zip';
        } else {
            if ($globalArchiveFormat == 'tar') {
                $globalArchiveFormatText = 'Tar';
            } else {
                if ($globalArchiveFormat == 'tar.gz') {
                    $globalArchiveFormatText = 'Tar GZip';
                } else {
                    if ($globalArchiveFormat == 'tar.bz2') {
                        $globalArchiveFormatText = 'Tar BZip2';
                    }
                }
            }
        }
        $backupSettings = MainWPDB::Instance()->getWebsiteBackupSettings($website->id);
        $archiveFormat = $backupSettings->archiveFormat;
        $useGlobal = $archiveFormat == 'global';
        ?>
                <tr>
                    <th scope="row"><?php 
        _e('Archive Format', 'mainwp');
        ?>
 <?php 
        MainWPUtility::renderToolTip(__('', 'mainwp'));
        ?>
</th>
                    <td>
                        <table class="mainwp-nomarkup">
                            <tr>
                                <td valign="top">
                                    <span class="mainwp-select-bg"><select name="mainwp_archiveFormat" id="mainwp_archiveFormat">
                                        <option value="global" <?php 
        if ($useGlobal) {
            ?>
selected<?php 
        }
        ?>
>Global setting (<?php 
        echo $globalArchiveFormatText;
        ?>
)</option>
                                        <option value="zip" <?php 
        if ($archiveFormat == 'zip') {
            ?>
selected<?php 
        }
        ?>
>Zip</option>
                                        <option value="tar" <?php 
        if ($archiveFormat == 'tar') {
            ?>
selected<?php 
        }
        ?>
>Tar</option>
                                        <option value="tar.gz" <?php 
        if ($archiveFormat == 'tar.gz') {
            ?>
selected<?php 
        }
        ?>
>Tar GZip</option>
                                        <option value="tar.bz2" <?php 
        if ($archiveFormat == 'tar.bz2') {
            ?>
selected<?php 
        }
        ?>
>Tar BZip2</option>
                                    </select><label></label></span>
                                </td>
                                <td>
                                    <i>
                                    <span id="info_global" class="archive_info" <?php 
        if (!$useGlobal) {
            ?>
style="display: none;"<?php 
        }
        ?>
><?php 
        if ($globalArchiveFormat == 'zip') {
            ?>
Uses PHP native Zip-library, when missing, the PCLZip library included in Wordpress will be used. (Good compression, fast with native zip-library)<?php 
        } elseif ($globalArchiveFormat == 'tar') {
            ?>
Uses PHP native Zip-library, when missing, the PCLZip library included in Wordpress will be used. (Good compression, fast with native zip-library)<?php 
        } elseif ($globalArchiveFormat == 'tar.gz') {
            ?>
Creates a GZipped tar-archive. (Good compression, fast, low memory usage)<?php 
        } elseif ($globalArchiveFormat == 'tar.bz2') {
            ?>
Creates a BZipped tar-archive. (Best compression, fast, low memory usage)<?php 
        }
        ?>
</span>
                                    <span id="info_zip" class="archive_info" <?php 
        if ($archiveFormat != 'zip') {
            ?>
style="display: none;"<?php 
        }
        ?>
>Uses PHP native Zip-library, when missing, the PCLZip library included in Wordpress will be used. (Good compression, fast with native zip-library)</span>
                                    <span id="info_tar" class="archive_info" <?php 
        if ($archiveFormat != 'tar') {
            ?>
style="display: none;"<?php 
        }
        ?>
>Creates an uncompressed tar-archive. (No compression, fast, low memory usage)</span>
                                    <span id="info_tar.gz" class="archive_info" <?php 
        if ($archiveFormat != 'tar.gz') {
            ?>
style="display: none;"<?php 
        }
        ?>
>Creates a GZipped tar-archive. (Good compression, fast, low memory usage)</span>
                                    <span id="info_tar.bz2" class="archive_info" <?php 
        if ($archiveFormat != 'tar.bz2') {
            ?>
style="display: none;"<?php 
        }
        ?>
>Creates a BZipped tar-archive. (Best compression, fast, low memory usage)</span>
                                    </i>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>

                <?php 
        $maximumFileDescriptorsOverride = $website->maximumFileDescriptorsOverride == 1;
        $maximumFileDescriptorsAuto = $website->maximumFileDescriptorsAuto == 1;
        $maximumFileDescriptors = $website->maximumFileDescriptors;
        ?>
                <tr class="archive_method archive_zip" <?php 
        if ($archiveFormat != 'zip') {
            ?>
style="display: none;"<?php 
        }
        ?>
>
                    <th scope="row"><?php 
        _e('Maximum File Descriptors on Child', 'mainwp');
        ?>
 <?php 
        MainWPUtility::renderToolTip('The maximum number of open file descriptors on the child hosting.', 'http://docs.mainwp.com/maximum-number-of-file-descriptors/');
        ?>
</th>
                    <td>
                        <div class="mainwp-radio" style="float: left;">
                          <input type="radio" value="" name="mainwp_options_maximumFileDescriptorsOverride" id="mainwp_options_maximumFileDescriptorsOverride_global" <?php 
        echo !$maximumFileDescriptorsOverride ? 'checked="true"' : '';
        ?>
"/>
                          <label for="mainwp_options_maximumFileDescriptorsOverride_global"></label>
                        </div>Global Setting (<a href="<?php 
        echo admin_url('admin.php?page=Settings');
        ?>
">Change Here</a>)<br/>
                        <div class="mainwp-radio" style="float: left;">
                          <input type="radio" value="override" name="mainwp_options_maximumFileDescriptorsOverride" id="mainwp_options_maximumFileDescriptorsOverride_override" <?php 
        echo $maximumFileDescriptorsOverride ? 'checked="true"' : '';
        ?>
"/>
                          <label for="mainwp_options_maximumFileDescriptorsOverride_override"></label>
                        </div>Override<br/><br />

                        <div style="float: left">Auto Detect:&nbsp;</div><div class="mainwp-checkbox"><input type="checkbox" id="mainwp_maximumFileDescriptorsAuto" name="mainwp_maximumFileDescriptorsAuto" <?php 
        echo $maximumFileDescriptorsAuto ? 'checked="checked"' : '';
        ?>
 /> <label for="mainwp_maximumFileDescriptorsAuto"></label></div><div style="float: left"><i>(<?php 
        _e('Enter a fallback value because not all hosts support this function.', 'mainwp');
        ?>
)</i></div><div style="clear:both"></div>
                        <input type="text" name="mainwp_options_maximumFileDescriptors" id="mainwp_options_maximumFileDescriptors"
                               value="<?php 
        echo $maximumFileDescriptors;
        ?>
"/><span class="mainwp-form_hint"><?php 
        _e('The maximum number of open file descriptors on the child hosting.  0 sets unlimited.', 'mainwp');
        ?>
</span>
                    </td>
                </tr>
                <tr class="archive_method archive_zip" <?php 
        if ($archiveFormat != 'zip') {
            ?>
style="display: none;"<?php 
        }
        ?>
>
                    <th scope="row"><?php 
        _e('Load Files in Memory Before Zipping', 'mainwp');
        ?>
 <?php 
        MainWPUtility::renderToolTip('This causes the files to be opened and closed immediately, using less simultaneous I/O operations on the disk. For huge sites with a lot of files we advise to disable this, memory usage will drop but we will use more file handlers when backing up.', 'http://docs.mainwp.com/load-files-memory/');
        ?>
</th>
                    <td>
                        <input type="radio" name="mainwp_options_loadFilesBeforeZip" id="mainwp_options_loadFilesBeforeZip_global" value="1" <?php 
        if ($website->loadFilesBeforeZip == false || $website->loadFilesBeforeZip == 1) {
            ?>
checked="true"<?php 
        }
        ?>
/> Global setting (<a href="<?php 
        echo admin_url('admin.php?page=Settings');
        ?>
">Change Here</a>)<br />
                        <input type="radio" name="mainwp_options_loadFilesBeforeZip" id="mainwp_options_loadFilesBeforeZip_yes" value="2" <?php 
        if ($website->loadFilesBeforeZip == 2) {
            ?>
checked="true"<?php 
        }
        ?>
/> Yes<br />
                        <input type="radio" name="mainwp_options_loadFilesBeforeZip" id="mainwp_options_loadFilesBeforeZip_no" value="0" <?php 
        if ($website->loadFilesBeforeZip == 0) {
            ?>
checked="true"<?php 
        }
        ?>
/> No<br />
                    </td>
                </tr>
                <?php 
        if ($hasRemoteDestinations !== null) {
            do_action('mainwp_backups_remote_settings', array('website' => $website->id, 'hide' => 'no'));
        }
        ?>
            </table>
            </div>
            </div>
            
            <?php 
        $plugin_upgrades = json_decode($website->plugin_upgrades, true);
        if (!is_array($plugin_upgrades)) {
            $plugin_upgrades = array();
        }
        $userExtension = MainWPDB::Instance()->getUserExtension();
        $globalIgnoredPluginConflicts = json_decode($userExtension->ignored_pluginConflicts, true);
        ?>
            <?php 
        do_action('mainwp-extension-sites-edit', $website);
        ?>
<p class="submit"><input type="submit" name="submit" id="submit" class="button-primary"
                                     value="<?php 
        _e('Update Site', 'mainwp');
        ?>
"/></p>
        </form>       
        <?php 
    }
    public static function render()
    {
        if (!mainwp_current_user_can("dashboard", "manage_offline_checks")) {
            mainwp_do_not_have_permissions("manage offline checks");
            return;
        }
        $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesForCurrentUser());
        $statusses = array('hourly', '2xday', 'daily', 'weekly');
        do_action("mainwp-pageheader-settings", "OfflineChecks");
        ?>
        <div class="mainwp_info-box">
            <strong><?php 
        _e('Notifications will be sent to', 'mainwp');
        ?>
 <i><?php 
        echo MainWPUtility::getNotificationEmail();
        ?>
</i> (<a href="<?php 
        echo admin_url();
        ?>
admin.php?page=Settings"><?php 
        _e('change', 'mainwp');
        ?>
</a>)</strong>
            <br /><br /><?php 
        _e('MainWP performs two tests when checking your site for up-time.', 'mainwp');
        ?>
            <br />
            <?php 
        _e('The first test we do is to check that the domain is valid.', 'mainwp');
        ?>
            <br />
            <?php 
        _e('If this test passes we use a browser emulator to visit the website, this sends out a user agent (just like your web browser from your computer) and waits for a status message.', 'mainwp');
        ?>
            <br />
            <?php 
        _e('We report any http status code from 200-399 as a success. Any other http status code returned is considered "offline" which is treated as a failure.', 'mainwp');
        ?>
        </div>
        <table class="wp-list-table widefat fixed" id="mainwp_offlinechecks">
            <thead>
                <tr>
                    <th scope="col" class="manage-column" style="text-align: left"><?php 
        _e('Site', 'mainwp');
        ?>
</th>
                    <th scope="col" id="col_status" class="manage-column"><?php 
        _e('Status', 'mainwp');
        ?>
</th>
                    <th scope="col" id="col_disabled" class="manage-column"><a href="#" class="mainwp_offline_check_bulk" value="disabled"><?php 
        _e('Disabled', 'mainwp');
        ?>
</a></th>
                    <th scope="col" id="col_hourly" class="manage-column"><a href="#" class="mainwp_offline_check_bulk" value="hourly"><?php 
        _e('Hourly', 'mainwp');
        ?>
</a></th>
                    <th scope="col" id="col_2timesday" class="manage-column"><a href="#" class="mainwp_offline_check_bulk" value="2xday"><?php 
        _e('2x Day', 'mainwp');
        ?>
</a></th>
                    <th scope="col" id="col_daily" class="manage-column"><a href="#" class="mainwp_offline_check_bulk" value="daily"><?php 
        _e('Daily', 'mainwp');
        ?>
</a></th>
                    <th scope="col" id="col_weekly" class="manage-column"><a href="#" class="mainwp_offline_check_bulk" value="weekly"><?php 
        _e('Weekly', 'mainwp');
        ?>
</a></th>
                    <th scope="col" id="col_test" class="manage-column"><a href="#" class="button button-primary" id="mainwp_offline_check_check_all"><?php 
        _e('Check All', 'mainwp');
        ?>
</a></th>
                </tr>
            </thead>
            <tbody id="the-list">
            <?php 
        while ($websites && ($website = @MainWPDB::fetch_object($websites))) {
            ?>
                <tr>
                    <input type="hidden" name="offline_check_website_id" id="offline_check_website_id"
                           value="<?php 
            echo $website->id;
            ?>
" />
                    <td class="url"><a href="admin.php?page=managesites&dashboard=<?php 
            echo $website->id;
            ?>
"><?php 
            echo stripslashes($website->name);
            ?>
</a> <span class="offline_check_saved"><?php 
            _e('Saved', 'mainwp');
            ?>
</span></td>
                    <td>
                        <img class="down-img" title="Site Offline" src="<?php 
            echo plugins_url('images/down.png', dirname(__FILE__));
            ?>
" <?php 
            echo $website->offline_check_result == -1 ? '' : 'style="display:none;"';
            ?>
 />
                        <img class="up-img" title="Site Online" src="<?php 
            echo plugins_url('images/up.png', dirname(__FILE__));
            ?>
" <?php 
            echo $website->offline_check_result == 1 ? '' : 'style="display:none;"';
            ?>
 />
                    </td>
                    <td class="column-rating"><input type="radio" id="disabled" class="mainwp_offline_check" value="disabled"
                               name="offline_check_<?php 
            echo $website->id;
            ?>
"
                        <?php 
            echo !in_array($website->offline_checks, $statusses) ? 'checked="true"' : '';
            ?>
 /></td>
                    <td><input type="radio" id="hourly" class="mainwp_offline_check" value="hourly"
                               name="offline_check_<?php 
            echo $website->id;
            ?>
"
                        <?php 
            echo $website->offline_checks == 'hourly' ? 'checked="true"' : '';
            ?>
 /></td>
                    <td><input type="radio" id="2xday" class="mainwp_offline_check" value="2xday"
                               name="offline_check_<?php 
            echo $website->id;
            ?>
"
                        <?php 
            echo $website->offline_checks == '2xday' ? 'checked="true"' : '';
            ?>
 /></td>
                    <td><input type="radio" id="daily" class="mainwp_offline_check" value="daily"
                               name="offline_check_<?php 
            echo $website->id;
            ?>
"
                        <?php 
            echo $website->offline_checks == 'daily' ? 'checked="true"' : '';
            ?>
 /></td>
                    <td><input type="radio" id="weekly" class="mainwp_offline_check" value="weekly"
                               name="offline_check_<?php 
            echo $website->id;
            ?>
"
                        <?php 
            echo $website->offline_checks == 'weekly' ? 'checked="true"' : '';
            ?>
 /></td>
                    <td><a href="#" class="mainwp_offline_check_check"><?php 
            _e('Check', 'mainwp');
            ?>
</a></td>
                </tr>
                <?php 
        }
        ?>
            </tbody>
        </table>
    <?php 
        do_action("mainwp-pagefooter-settings", "OfflineChecks");
    }
    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>
                            &nbsp;&nbsp;Last run: <?php 
        echo $lastAutomaticUpdate;
        ?>
                            <br />&nbsp;&nbsp;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 
    }