Example #1
0
/**
 * @internal
 * @param $optName
 * @param $optData
 */
function wpsPlugin_updateRssFeedOption($optName, $optData)
{
    $obj = new stdClass();
    $obj->expires = time() + 24 * 60 * 60;
    $obj->data = $optData;
    WpsOption::updateOption($optName, $obj);
}
Example #2
0
 function wpsPluginValidateSettingsForm($refreshRates)
 {
     if (isset($_POST['max_number_live_traffic']) && isset($_POST['refreshRateOption'])) {
         // validate input $_POST['max_number_live_traffic']
         $keepNumEntriesLiveTraffic = intval($_POST['max_number_live_traffic']);
         if ($keepNumEntriesLiveTraffic == 0) {
             $keepNumEntriesLiveTraffic = 0;
         } elseif (!preg_match("/[0-9]{1,5}/", $keepNumEntriesLiveTraffic)) {
             $keepNumEntriesLiveTraffic = 500;
         }
         // validate input $_POST['refreshRateOption']
         $liveTrafficRefreshRateAjax = intval($_POST['refreshRateOption']);
         if (!in_array($liveTrafficRefreshRateAjax, $refreshRates)) {
             $liveTrafficRefreshRateAjax = 10;
         } elseif ($_POST['refreshRateOption'] == 0) {
             $liveTrafficRefreshRateAjax = 0;
         } elseif (!preg_match("/[0-9]{1,2}/", $liveTrafficRefreshRateAjax)) {
             $liveTrafficRefreshRateAjax = 10;
         }
         // update settings
         WpsOption::updateOption('WPS_KEEP_NUM_ENTRIES_LT', $keepNumEntriesLiveTraffic);
         WpsOption::updateOption('WPS_REFRESH_RATE_AJAX_LT', $liveTrafficRefreshRateAjax);
         return array($keepNumEntriesLiveTraffic, $liveTrafficRefreshRateAjax);
     } else {
         exit('Invalid request.');
     }
 }
Example #3
0
function wpsIsValidInstall()
{
    if (wpsIsMultisite()) {
        $_ = WpsOption::getOption('WPS_NETWORK_INSTALL');
        if (empty($_)) {
            return false;
        }
    }
    return true;
}
Example #4
0
 /**
  * @internal
  * @param $userID
  */
 public static function _watchUserInfoUpdated($userID)
 {
     // If an admin user's password has been updated
     if (!empty($_POST['pass1'])) {
         $userInfo = self::_getUserInfo($userID);
         $userName = $userInfo['userName'];
         $userRole = $userInfo['userRole'];
         if ($userRole == 'administrator') {
             global $wpsPluginAlertsArray;
             $actionName = $wpsPluginAlertsArray['watch_admin_password_update']['name'];
             $alertType = $wpsPluginAlertsArray['watch_admin_password_update']['type'];
             if (wpsIsMultisite()) {
                 global $wpdb;
                 $blogID = $wpdb->blogid;
                 $blogName = WpsOption::getOption('blogname', $blogID);
                 self::alert($actionName, $alertType, WpsSettings::ALERT_MEDIUM, sprintf(__('Administrator (<strong>%s</strong>) of blog <strong>%s</strong> has updated their password.', WpsSettings::TEXT_DOMAIN), $userName, $blogName), __('<p>This alert is generated every time an administrator\'s password is updated.</p>', WpsSettings::TEXT_DOMAIN));
             } else {
                 self::alert($actionName, $alertType, WpsSettings::ALERT_MEDIUM, sprintf(__('Administrator (<strong>%s</strong>) has updated their password.', WpsSettings::TEXT_DOMAIN), $userName), __('<p>This alert is generated every time an administrator\'s password is updated.</p>', WpsSettings::TEXT_DOMAIN));
             }
         }
     }
 }
Example #5
0
require 'res/inc/WsdCheck.php';
require 'res/inc/WsdScheduler.php';
require 'res/inc/WsdWatch.php';
require 'res/inc/WsdLiveTraffic.php';
require 'res/inc/WsdWpScanner.php';
require 'res/inc/wss-functions.php';
//#!--
if (wpsIsMultisite()) {
    add_action('network_admin_menu', 'wpsCreateNetworkMenu');
    add_action('admin_menu', 'wpsCreateSiteMenu');
} else {
    add_action('admin_menu', 'wpsCreateNetworkMenu');
}
add_action('init', array('WsdUtil', 'loadPluggable'));
add_action('init', array('WsdPlugin', 'loadResources'));
$wpsCanRun = (bool) WpsOption::getOption(WpsSettings::CAN_RUN_TASKS_OPTION_NAME);
if ($wpsCanRun) {
    add_action('init', array('WsdLiveTraffic', 'registerHit'));
    add_action('wp_ajax_ajaxGetTrafficData', array('WsdLiveTraffic', 'ajaxGetTrafficData'));
    add_action('wp_ajax_nopriv_ajaxGetTrafficData', array('WsdLiveTraffic', 'ajaxGetTrafficData'));
}
add_action('wp_ajax_ajaxDeleteBackupFile', array('WsdUtil', 'ajaxDeleteBackupFile'));
add_action('wp_dashboard_setup', array('WsdUtil', 'addDashboardWidget'));
register_activation_hook(__FILE__, 'wpsNetworkActivate');
register_deactivation_hook(__FILE__, 'wpsNetworkDeactivate');
register_uninstall_hook(__FILE__, array('WsdPlugin', 'uninstall'));
//#++
// Add custom links on plugins page
function wssCustomLinks($links)
{
    if (wpsIsValidInstall()) {
Example #6
0
 public static function stopScan($completed = false, $failReason = '')
 {
     $scanID = self::$_scanID;
     if (empty($scanID)) {
         $optData = WpsOption::getOption(WpsSettings::WP_FILE_SCAN_OPTION_NAME);
         if (empty($optData)) {
             wssLog('Empty $optData. Checking db table for any incomplete scan.');
             $sid = WsdWpScanner::getLastScanID_table();
             if (empty($sid)) {
                 wssLog('No incomplete scans found either.');
                 return;
             } else {
                 wssLog("Incomplete scan found: {$sid}");
                 $scanID = $sid;
             }
         } else {
             $scanID = $optData['SCAN_ID'];
             if (empty($scanID)) {
                 return;
             }
         }
     }
     $m = __METHOD__ . '() ';
     wssLog($m . 'triggered.');
     if ($completed) {
         self::_markScanCompleted();
     } else {
         wssLog('Fail reason: ' . $failReason);
         self::_markScanFailed($scanID, $failReason);
     }
     WsdWPScanSettings::deleteSettings();
     wssLog('Scan (' . $scanID . ') marked as ' . ($completed ? 'completed' : 'failed') . ' and options deleted.' . PHP_EOL . str_repeat('=', 50));
 }
Example #7
0
 /**
  * @public
  * @static
  * Add the rss widget to dashboard
  * @return void
  */
 static function addDashboardWidget()
 {
     $rssWidgetData = WpsOption::getOption('WSD-RSS-WGT-DISPLAY');
     if ($rssWidgetData == 'yes') {
         if (wpsIsMultisite()) {
             global $wpdb;
             $old_blog = $wpdb->blogid;
             // Get all blog ids
             $blogIds = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}");
             foreach ($blogIds as $blog_id) {
                 switch_to_blog($blog_id);
                 wp_add_dashboard_widget('acx_plugin_dashboard_widget', __('Acunetix news and updates', WpsSettings::TEXT_DOMAIN), array('WsdUtil', 'displayDashboardWidget'));
             }
             switch_to_blog($old_blog);
             wp_add_dashboard_widget('acx_plugin_dashboard_widget', __('Acunetix news and updates', WpsSettings::TEXT_DOMAIN), array('WsdUtil', 'displayDashboardWidget'));
         } else {
             wp_add_dashboard_widget('acx_plugin_dashboard_widget', __('Acunetix news and updates', WpsSettings::TEXT_DOMAIN), array('WsdUtil', 'displayDashboardWidget'));
         }
     }
 }
Example #8
0
 public static function uninstall()
 {
     WpsOption::deleteOption(WpsSettings::LIVE_TRAFFIC_ENTRIES);
     WpsOption::deleteOption('WPS_KEEP_NUM_ENTRIES_LT');
     WpsOption::deleteOption('WPS_REFRESH_RATE_AJAX_LT');
     WpsOption::deleteOption(WpsSettings::PLUGIN_SETTINGS_OPTION_NAME);
     global $wpdb;
     $wpdb->query("DROP TABLE IF EXISTS " . WsdPlugin::getTableName(WpsSettings::SCAN_TABLE_NAME));
     $wpdb->query("DROP TABLE IF EXISTS " . WsdPlugin::getTableName(WpsSettings::SCANS_TABLE_NAME));
     $wpdb->query("DROP TABLE IF EXISTS " . WsdPlugin::getTableName(WpsSettings::ALERTS_TABLE_NAME));
     $wpdb->query("DROP TABLE IF EXISTS " . WsdPlugin::getTableName(WpsSettings::LIVE_TRAFFIC_TABLE_NAME));
 }
Example #9
0
        // live traffic
        $liveTrafficEnabled = isset($_POST['chk_lt_display']) ? intval($_POST['chk_lt_display']) : 0;
        if (empty($liveTrafficEnabled)) {
            // hide
            $enableLiveTraffic = false;
            WpsOption::updateOption(WpsSettings::ENABLE_LIVE_TRAFFIC, false);
        } else {
            // show
            $enableLiveTraffic = true;
            WpsOption::updateOption(WpsSettings::ENABLE_LIVE_TRAFFIC, true);
            wssLog("Live traffic tool enabled.");
        }
        WpsOption::updateOption(WpsSettings::PLUGIN_SETTINGS_OPTION_NAME, $settings);
        $settings = WpsOption::getOption(WpsSettings::PLUGIN_SETTINGS_OPTION_NAME);
    } elseif (isset($_POST['deleteRssDataButton'])) {
        WpsOption::deleteOption(WpsSettings::FEED_DATA_OPTION_NAME);
    }
}
?>
<div class="wrap wsdplugin_content">
    <h2><?php 
echo WPS_PLUGIN_NAME . ' - ' . __('Settings', WpsSettings::TEXT_DOMAIN);
?>
</h2>

    <p class="clear"></p>
    <div style="clear: both; display: block;">
        <div class="metabox-holder">
            <div class="inner-sidebar1 postbox">
                <h3 class="hndle" style="cursor: default;"><span><?php 
echo __('Settings', WpsSettings::TEXT_DOMAIN);
 public static final function registerHit()
 {
     // check if live traffic tool is enabled
     $liveTrafficToolEnabled = WpsOption::getOption(WpsSettings::ENABLE_LIVE_TRAFFIC);
     if (!$liveTrafficToolEnabled) {
         return;
     }
     if (is_admin()) {
         return;
     }
     global $wpdb;
     $blogID = $wpdb->blogid;
     $url = self::getRequestedUrl();
     if (self::isUrlExcluded($url)) {
         return;
     }
     $ip = self::getIP();
     $referrer = self::getReferrer();
     $ua = self::getUserAgent();
     $geoIpInfo = self::_getGeoIpInfo($ip);
     $country = $geoIpInfo['country'];
     $city = $geoIpInfo['city'];
     $query = $wpdb->prepare("INSERT INTO " . WsdPlugin::getTableName(WpsSettings::LIVE_TRAFFIC_TABLE_NAME) . " (entryTime, entryIp, entryReferrer, entryUA, entryRequestedUrl, entryCountry, entryCity, blogId)\n                            VALUES(CURRENT_TIMESTAMP, %s, %s, %s, %s, %s, %s, %d)", $ip, $referrer, $ua, $url, $country, $city, $blogID);
     if (false === @$wpdb->query($query)) {
         return;
     }
     $numEvents = 0;
     $optData = WpsOption::getOption(WpsSettings::LIVE_TRAFFIC_ENTRIES);
     if (empty($optData)) {
         WpsOption::addOption(WpsSettings::LIVE_TRAFFIC_ENTRIES, $numEvents);
     } else {
         $numEvents = intval($optData);
     }
     WpsOption::updateOption(WpsSettings::LIVE_TRAFFIC_ENTRIES, $numEvents + 1);
 }