Example #1
0
function wpsCreateNetworkMenu()
{
    $reqCap = 'administrator';
    if (current_user_can($reqCap) && function_exists('add_menu_page')) {
        add_menu_page('WP Security', 'WP Security', $reqCap, WPS_PLUGIN_PREFIX, array('WsdPlugin', 'pageMain'), WsdUtil::imageUrl('logo-small.png'));
        add_submenu_page(WPS_PLUGIN_PREFIX, 'Dashboard', 'Dashboard', $reqCap, WPS_PLUGIN_PREFIX, array('WsdPlugin', 'pageMain'));
        add_submenu_page(WPS_PLUGIN_PREFIX, 'Database', 'Database', $reqCap, WPS_PLUGIN_PREFIX . 'database', array('WsdPlugin', 'pageDatabase'));
        add_submenu_page(WPS_PLUGIN_PREFIX, 'WP Info', 'WP Info', $reqCap, WPS_PLUGIN_PREFIX . 'scanner', array('WsdPlugin', 'pageWpInfo'));
        add_submenu_page(WPS_PLUGIN_PREFIX, 'WP File Scan', 'WP File Scan', $reqCap, WPS_PLUGIN_PREFIX . 'wpscan', array('WsdPlugin', 'pageWpFileScan'));
        add_submenu_page(WPS_PLUGIN_PREFIX, 'Live traffic', 'Live traffic', $reqCap, WPS_PLUGIN_PREFIX . 'live_traffic', array('WsdPlugin', 'pageLiveTraffic'));
        add_submenu_page(WPS_PLUGIN_PREFIX, 'Blog', 'Blog', $reqCap, WPS_PLUGIN_PREFIX . 'blog', array('WsdPlugin', 'pageBlog'));
        add_submenu_page(WPS_PLUGIN_PREFIX, 'Settings', 'Settings', $reqCap, WPS_PLUGIN_PREFIX . 'settings', array('WsdPlugin', 'pageSettings'));
        add_submenu_page(WPS_PLUGIN_PREFIX, 'About', 'About', $reqCap, WPS_PLUGIN_PREFIX . 'about', array('WsdPlugin', 'pageAbout'));
    }
}
Example #2
0
/**
 * @public
 * @param $optName
 * @param $getMaxRssEntries
 */
function wpsPlugin_handleDisplayRssData($optName, $getMaxRssEntries)
{
    $data = wpsPlugin_GetFeedData($getMaxRssEntries);
    wpsPlugin_updateRssFeedOption($optName, $data);
    echo str_ireplace("url('rss.png')", "url('" . WsdUtil::imageUrl('rss.png') . "')", $data);
}
 /**
  * @internal
  * @param $maxEntries
  * @param int $lastID
  * @return mixed|string|void
  */
 public static final function _ajaxGetFrom($maxEntries, $lastID = 0)
 {
     $result = array('type' => 'success', 'data' => array());
     // get the last ID from db
     $dbLastID = self::getLastID();
     if (empty($dbLastID)) {
         $result['data'][] = '<tr data-id="0"><td><p style="margin: 5px 5px; font-weight: bold; color: #cc0000">' . __('No data yet.', WpsSettings::TEXT_DOMAIN) . '</p></td></tr>';
         return json_encode($result);
     }
     // no change - nothing to display
     if ($lastID == $dbLastID) {
         return json_encode($result);
     }
     if ($lastID == 0) {
         $getFrom = $maxEntries;
     } else {
         $getFrom = $dbLastID - $lastID;
         if ($getFrom < 1) {
             return json_encode($result);
         }
     }
     $data = self::getTrafficData($getFrom);
     if (empty($data)) {
         $result['data'][] = '<tr data-id="0"><td><p style="margin: 5px 5px; font-weight: bold; color: #cc0000">' . __('No data yet.', WpsSettings::TEXT_DOMAIN) . '</p></td></tr>';
     } else {
         $data = array_reverse($data);
         foreach ($data as $entry) {
             $req = trim($entry->entryRequestedUrl);
             $e = '<tr data-id="' . $entry->entryId . '"><td class="wsd-scan-entry">';
             $e .= '<div>';
             if (empty($entry->entryReferrer)) {
                 $ref = '';
             } else {
                 // Ignore page refresh
                 $ref = trim($entry->entryReferrer);
                 if (strcasecmp($req, $ref) == 0) {
                     continue;
                 }
                 $url = strip_tags(urldecode($req));
                 $url = esc_html($url, ENT_QUOTES);
                 $ref = ' ' . __('coming from', WpsSettings::TEXT_DOMAIN) . ' <span class="w-entry"><span>' . $url . '</span></span>';
             }
             // add geo-location + flag
             $country = '';
             $city = '';
             $flag = '';
             if (!empty($entry->entryCountry)) {
                 $country = $entry->entryCountry;
                 $pos = strpos($country, ',');
                 if (false !== $pos) {
                     $code = substr($country, $pos + 1);
                     $flag = WsdUtil::imageUrl('flags/' . strtolower($code) . '.png');
                     $country = substr($country, 0, $pos);
                 }
             }
             if (!empty($entry->entryCity)) {
                 $city = $entry->entryCity;
             }
             if (!empty($flag)) {
                 $flag = trim($flag);
                 if (false !== ($pos = strpos($flag, ' republic of,kr.png'))) {
                     $flag = WsdUtil::imageUrl('flags/kr.png');
                 }
                 $flag = '<img src="' . $flag . '" alt="' . $flag . '" title="' . $flag . '"/>';
             }
             $ipInfoUrl = "http://dnsquery.org/ipwhois/{$entry->entryIp}";
             $ipInfoTitle = __('Lookup this IP. Opens in a new window/tab', WpsSettings::TEXT_DOMAIN);
             $geoInfo = '<span>';
             if (!empty($country)) {
                 if (!empty($flag)) {
                     $geoInfo .= $flag;
                 }
                 if (!empty($city)) {
                     $geoInfo .= ' ' . $city . ',';
                 }
                 if (!empty($country)) {
                     $geoInfo .= ' ' . $country;
                 }
                 $geoInfo .= ' (<span class="w-ip"><a href="' . $ipInfoUrl . '" title="' . $ipInfoTitle . '" target="_blank">' . $entry->entryIp . '</a></span>)';
             } else {
                 $geoInfo = __('Unknown location', WpsSettings::TEXT_DOMAIN) . ' (<span class="w-ip"><a href="' . $ipInfoUrl . '" title="' . $ipInfoTitle . '" target="_blank">' . $entry->entryIp . '</a></span>)';
             }
             $geoInfo .= '</span>';
             $reqUrl = strip_tags(urldecode($req));
             $reqUrl = esc_html($reqUrl, ENT_QUOTES);
             $e .= '<p style="margin-bottom: 1px;">' . $geoInfo;
             $e .= $ref . ' ' . __('requested', WpsSettings::TEXT_DOMAIN) . ' <span class="w-entry"><span>' . $reqUrl . '</span></span></p>';
             $e .= '<p style="margin-bottom: 1px;"><strong>' . __('Date', WpsSettings::TEXT_DOMAIN) . '</strong>: <span class="w-date">' . $entry->entryTime . '</span></p>';
             $e .= '<p style="margin-bottom: 1px;"><strong>' . __('Agent', WpsSettings::TEXT_DOMAIN) . '</strong>: <span class="w-ua">' . htmlentities($entry->entryUA, ENT_QUOTES) . '</span></p>';
             $e .= '</div>';
             $e .= '</td></tr>';
             $result['data'][] = $e;
         }
     }
     return json_encode($result);
 }
Example #4
0
        var maxEntries = ((<?php 
    echo $keepNumEntriesLiveTraffic;
    ?>
 > 100) ? 100 : <?php 
    echo $keepNumEntriesLiveTraffic;
    ?>
);
        var queue = new liveTrafficQueue(
            $
            ,"<?php 
    echo admin_url('admin-ajax.php');
    ?>
"
            ,"ajaxGetTrafficData"
            ,"<?php 
    echo WsdUtil::imageUrl('ajax-loader.gif');
    ?>
"
            ,maxEntries);

        queue.retrieveData();

        <?php 
    /*[ enable autoload only if refresh rate > 0 ]*/
    ?>
        <?php 
    if ($liveTrafficRefreshRateAjax > 0) {
        ?>
 window.setInterval(function(){ queue.retrieveData(); }, <?php 
        echo $liveTrafficRefreshRateAjax * 1000;
        ?>
if (!WsdUtil::canLoad()) {
    return;
}
/*
 * DISPLAY AVAILABLE DOWNLOADS
 *======================================================
 */
$files = WsdUtil::getAvailableBackupFiles();
if (empty($files)) {
    echo '<p>No backups files found.</p>';
} else {
    echo '<div class="acx-section-box">';
    echo '<ul id="bck-list" data-nonce="' . wp_create_nonce("wpsBackupFileDelete_nonce") . '">';
    foreach ($files as $fileName) {
        echo '<li style="overflow: hidden;">';
        echo '<a href="#" title="Delete this backup" class="acx-delete-bck" style="margin-top: 3px; margin-right: 7px; float: left;"><img src="' . WsdUtil::imageUrl('minus.gif') . '"/></a>';
        echo '<a href="', WPS_PLUGIN_URL . 'res/backups/', $fileName, '" title="', __('Click to download'), '" style="float: left;">', $fileName, '</a>';
        echo '</li>';
    }
    echo '</ul>';
    echo '</div>';
}
?>
<script type="text/javascript">
    jQuery(document).ready(function($){
        function deleteBackupFile($,adminPostUrl, serverMethod, nonce, fileName, $item)
        {
            $.ajax({
                type : "post",
                dataType : "json",
                cache: false,