示例#1
0
function commify($str)
{
    $n = strlen($str);
    if ($n <= 3) {
        $return = $str;
    } else {
        $pre = substr($str, 0, $n - 3);
        $post = substr($str, $n - 3, 3);
        $pre = commify($pre);
        $return = "{$pre},{$post}";
    }
    return $return;
}
function pleac_Putting_Commas_in_Numbers()
{
    // PHP offers the 'number_format' built-in function to, among many other format tasks,
    // commify numbers. Perl-compatible [as well as extended] regexes are also available
    function commify_series($s)
    {
        return number_format($s, 0, '', ',');
    }
    // ------------
    $hits = 3456789;
    printf("Your website received %s accesses last month\n", commify_series($hits));
    // ----------------------------
    function commify($s)
    {
        return strrev(preg_replace('/(\\d\\d\\d)(?=\\d)(?!\\d*\\.)/', '${1},', strrev($s)));
    }
    // ------------
    $hits = 3456789;
    echo commify(sprintf("Your website received %d accesses last month\n", $hits));
}
/**
 * Smarty award_format modifier plugin
 *
 * Type:     modifier<br>
 * Name:     award_format<br>
 * Purpose:  format award values either via sprintf or using php code
 * @param string
 * @param string
 * @return string
 */
function smarty_modifier_award_format($value, $format)
{
    /*	# using eval for this is way too insecure. So I'm hard coding specific format values
    	if (strpos($format, "code:") === 0) {
    		$code = substr($format, 5);
    		if (!preg_match('/;$/',$code)) $code .= ';';			// make sure there's a trailing ";"
    		$code = sprintf("return $code", $value);
    		return eval($code);
    	} else {
    		return sprintf($format, $value);
    	}
    */
    switch ($format) {
        case "commify":
            return commify($value);
        case "compacttime":
            return compacttime($value);
        case "date":
            return date("Y-m-d", $value);
        case "datetime":
            return date("Y-m-d H:i:s", $value);
    }
    return $format[0] == '%' ? sprintf($format, $value) : $value;
}
示例#4
0
if (defined('SQZ_ENABLED') && SQZ_ENABLED == TRUE) {
    $query = "SELECT SUM(counter) FROM " . DEFAULTLOGTABLE . " ";
    $result = perform_query($query, $dbLink) or die(mysql_error());
    $row = fetch_array($result);
    $totalrows = commify($row[0]);
    // die ("Total COUNT rows: $totalrows");
} else {
    if (defined('COUNT_ROWS') && COUNT_ROWS == TRUE && $num_results) {
        $totalrows = commify(get_total_rows(DEFAULTLOGTABLE));
        // die ("Total COUNT rows:" . $totalrows);
    } else {
        // Get Total number of rows
        $query = "SELECT count(*) from " . DEFAULTLOGTABLE;
        $result = perform_query($query, $dbLink) or die(mysql_error());
        $numrows = mysql_num_rows($result);
        $totalrows = commify($numrows);
        // die ("Total rows: $query<br>" . $totalrows);
    }
}
// A new pie graph
$graph = new PieGraph(640, 480, 'auto');
$graph->SetShadow();
// Title setup
/* cdukes - 2-28-08: Added a test to notify the user if they selected more TopX than what was available in the database
    Example: Selecting Top 100 when only 50 hosts are in the DB
	 */
$numhosts = count($host);
// die("Hostcount:$numhosts \nTopx: $topx\n");
if ($numhosts >= $topx) {
    $graph->title->Set("Top {$topx} Hosts of " . $totalrows . " total messages");
} else {
示例#5
0
 function award_format($value, $format = '%s')
 {
     if (substr($format, 0, 1) == '%') {
         return sprintf($format, $value);
     }
     switch ($format) {
         case "commify":
             return commify($value);
         case "compacttime":
             return compacttime($value);
         case "date":
             return ps_date_stamp($value);
         case "datetime":
             return ps_datetime_stamp($value);
     }
     // the [brackets] will help troubleshoot issues when a invalid format is specified
     return "[ {$value} ]";
 }
示例#6
0
 $queryresult = perform_query($sql, $dbLink, $_SERVER['PHP_SELF']);
 while ($line = fetch_array($queryresult)) {
     $hms[] = $line['Day'];
     $count = intval($line['value']);
     if (!is_int($count)) {
         $count = 0;
     }
     $array[] = $count;
     $v = intval($line['avg']);
     if (is_int($v)){
         $avg[] = $v;
     }
 }
 if (empty($array)) $array[] = 0;
 $bar->set_values( $array );
 $bar->set_tooltip("#val#<br>Average = ".commify($avg[0]));
 $bar2->set_values( ($avg) );
 $bar2->set_colour( "#40FF40" );
 $bar2->set_tooltip("#val#<br>Average [#x_label#]");
 //
 // create a Y Axis object
 //
 $y = new y_axis();
 // grid steps:
 $y->set_range( 0, max($array), round(max($array)/10));
 $chart->set_y_axis( $y );
 $x_labels = new x_axis_labels();
 $x_labels->set_vertical();
 $x_labels->set_labels( $hms );
 $x = new x_axis();
 $x->set_labels( $x_labels );
$total = mysql_fetch_row($result);
$count = $total[0];
// echo "<pre>";
// echo(print_r($_COOKIE));
// echo "</pre>";
// die();
if( $count >0 ) { 
?>
<script type="text/javascript">
var limit = <?php echo ($_SESSION['PORTLET_HOSTS_LIMIT'])?>;
var cnt = <?php echo $count?>;
if (cnt < 11) {
    $('#portlet-header_Hosts').text("Last " + cnt + " Hosts");
    } else {
    $('#portlet-header_Hosts').text("Last " + limit + " Hosts");
    $('#portlet-header_Hosts').append(" (<?php echo commify($count)?> total)")
};
</script>
<table class="hoverTable" id="tblHosts">
<thead class="ui-widget-header">
  <tr>
    <th width="5%" style="text-align:left"></th>
    <th width="45%" style="text-align:left">Host</th>
    <th width="25%" style="text-align:left">Seen</th>
    <th width="25%" style="text-align:left">Last Seen</th>
  </tr>
</thead>
  <tbody>
<?php
        $sql = "SELECT * FROM (SELECT * FROM hosts where rbac(".$_SESSION['rbac'].", rbac_key) and hidden='false' ORDER BY lastseen DESC) AS result LIMIT ". $_SESSION['PORTLET_HOSTS_LIMIT']; 
        $result = perform_query($sql, $dbLink, "portlet-hosts.php"); 
示例#8
0
    while (false !== ($file = readdir($handle))) {
        if (preg_match("/^dumpfile/", $file)) {
            $date_string_from_files[] = substr($file, 9, 4) . "-" . substr($file, 13, 2) . "-" . substr($file, 15, 2);
        }
    }
    closedir($handle);
}
$prettydate = date('l, F d, Y', strtotime($date_str));
switch ($action) {
    case "info":
        if (in_array($date_str, $date_string_from_files)) {
            $sql = "SELECT records FROM archives where archive='dumpfile_{$date_str_nodash}.txt'";
            $result = perform_query($sql, $dbLink, $_SERVER['PHP_SELF']);
            $count = mysql_num_rows($result);
            $row = fetch_array($result);
            echo commify($row["records"]) . " events available for import. <br />";
            echo "You may select \"Import Now\" to begin importing all data from {$prettydate}<br />";
        } else {
            echo $apath . "dumpfile_{$date_str_nodash}.txt is missing or invalid<br />";
        }
        break;
    case "import":
        // if the file has already been decompressed, then look for the logfile
        $logfile = $apath . "/_import_{$date_str_nodash}.log";
        if (file_exists($logfile)) {
            echo "Logfile:<br />";
            $loghandle = fopen($logfile, rb);
            while (!feof($loghandle)) {
                echo fgets($loghandle, 8192) . "<br>";
            }
            fclose($loghandle);
示例#9
0
function commify_callback($matches)
{
    return commify($matches[0]);
}
<i>Use this link to reference this query directly: </i>
<a href="<?php 
echo $_SERVER["PHP_SELF"] . "?offset=" . $offset . $ParamsGET;
?>
">QUERY</a><br>
</center></td></tr></table>
-->
<table>
<tr><td>
<a href="index.php?pageId=searchform">BACK TO SEARCH</a><br>
<?php 
/* cdukes - 2-28-08: Added !stristr($_SERVER[REQUEST_URI],"graph") below so that people didn't get confused by the results
   displayed on a Top 10 search (since below would show TOTAL results, not selected results, ie. Selected = 10 for Top 10)
   */
if (defined('COUNT_ROWS') && COUNT_ROWS == TRUE && $num_results && !stristr($_SERVER[REQUEST_URI], "graph")) {
    echo "<i>Number of Entries Found</i>: <b>" . commify($num_results) . "</b>";
}
?>
</td><td>
<div class="sevlegend">
SEVERITY LEGEND<br>
<?php 
/*<table>
	<tr>
	<td class="sev0">DEBUG</td>
	<td class="sev1">INFO</td>
	<td class="sev2">NOTICE</td>
	<td class="sev3">WARNING</td>
	<td class="sev4">ERROR</td>
	<td class="sev5">CRIT</td>
	<td class="sev6">ALERT</td>
示例#11
0
function isk($str)
{
    $str = $str + 0;
    if (preg_match("/^(\\d+)\\.(\\d+)\$/", $str, $matches)) {
        return commify($matches[1]) . '.' . $matches[2] . ' ISK';
    }
    return commify($str + 0) . " ISK";
}
示例#12
0
</div>
<div class="spacer"></div>
<script type="text/javascript">
//------------------------------------------------------------
// Display the total matching DB entries along with the X of X entries
//------------------------------------------------------------
<?php
if ($total_found < $limit) {
    $limit = $total_found;
}
?>
var total = '<?php echo $total?>'
if (total < 1) {
    total = 'No results found for date range <?php echo "$start - $end<br>Time to search: $time seconds";?>'
} else {
    total = '<?php echo "Displaying Top ".commify($total)." Matches of ".commify($total_found)." possible<br>Date Range: $start - $end<br>Time to search: $time seconds";?>';
}

$("#portlet-header_Search_Results").html("<div style='text-align: center'>" + total + "</div>");
</script>

<!-- BEGIN Add Save URL icon to search results -->
<script type="text/javascript">
$("#portlet-header_Search_Results").prepend('<span id="export" class="ui-icon ui-icon-print"></span>');
$("#portlet-header_Search_Results").prepend('<span id="span_results_save_icon" class="ui-icon ui-icon-disk"></span>');
//---------------------------------------------------------------
// END: Save URL function
//---------------------------------------------------------------
</script>
<?php
require_once ($basePath . "/portlet_footer.php");
示例#13
0
        $last_post = $lang['NO_POSTS'];
        if (!($fname_html =& $forums['forum_name_html'][$sf_forum_id])) {
            continue;
        }
        if ($sf_data['forum_status'] == FORUM_LOCKED) {
            $folder_image = $images['forum_locked'];
        } elseif (is_unread($sf_data['topic_last_post_time'], $sf_last_tid, $sf_forum_id)) {
            $folder_image = $images['forum_new'];
        }
        $last_post_user = profile_url(array('username' => $sf_data['sf_last_username'], 'user_id' => $sf_data['sf_last_user_id'], 'user_rank' => $sf_data['user_rank']));
        if ($sf_data['forum_last_post_id']) {
            $last_post = bb_date($sf_data['topic_last_post_time'], $bb_cfg['last_post_date_format']);
            $last_post .= "<br />{$last_post_user}";
            $last_post .= '<a href="' . POST_URL . $sf_data['forum_last_post_id'] . '#' . $sf_data['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" class="icon2" alt="latest" title="' . $lang['VIEW_LATEST_POST'] . '" /></a>';
        }
        $template->assign_block_vars('f', array('FORUM_FOLDER_IMG' => $folder_image, 'FORUM_NAME' => $fname_html, 'FORUM_DESC' => $forums['f'][$sf_forum_id]['forum_desc'], 'U_VIEWFORUM' => FORUM_URL . $sf_forum_id, 'TOPICS' => commify($sf_data['forum_topics']), 'POSTS' => commify($sf_data['forum_posts']), 'LAST_POST' => $last_post));
        if ($sf_data['forum_last_post_id']) {
            $template->assign_block_vars('f.last', array('FORUM_LAST_POST' => true, 'SHOW_LAST_TOPIC' => $show_last_topic, 'LAST_TOPIC_ID' => $sf_data['last_topic_id'], 'LAST_TOPIC_TIP' => $sf_data['last_topic_title'], 'LAST_TOPIC_TITLE' => str_short($sf_data['last_topic_title'], $last_topic_max_len), 'LAST_POST_TIME' => bb_date($sf_data['topic_last_post_time'], $bb_cfg['last_post_date_format']), 'LAST_POST_ID' => $sf_data['forum_last_post_id'], 'LAST_POST_USER' => $last_post_user, 'ICON_LATEST_REPLY' => $images['icon_latest_reply']));
        } else {
            $template->assign_block_vars('f.last', array('FORUM_LAST_POST' => false));
        }
    }
}
unset($rowset);
$datastore->rm('cat_forums');
// Topics per page
$topics_per_page = $bb_cfg['topics_per_page'];
$select_tpp = '';
if ($is_auth['auth_mod']) {
    if ($req_tpp = abs(intval(@$_REQUEST['tpp'])) and in_array($req_tpp, $bb_cfg['allowed_topics_per_page'])) {
        $topics_per_page = $req_tpp;
// Get EventId
// -------------------------
$sql = "SELECT COUNT(*) FROM (SELECT eid FROM snare_eid where eid>0 and hidden='false') AS result";
$result = perform_query($sql, $dbLink, $_REQUEST['pageId']);
$total = mysql_fetch_row($result);
$count = $total[0];
if( $count >0 ) { 
?>
<script type="text/javascript">
var limit = <?php echo ($_SESSION['PORTLET_EID_LIMIT'])?>;
var cnt = <?php echo $count?>;
if (cnt < 11) {
    $('#portlet-header_Snare_EventId').text("Last " + cnt + " Windows Event ID's");
    } else {
    $('#portlet-header_Snare_EventId').text("Last " + limit + " Windows Event ID's");
    $('#portlet-header_Snare_EventId').append(" (<?php echo commify($count)?> total)")
};
</script>
<table class="hoverTable">
<thead class="ui-widget-header">
  <tr>
    <th width="5%" style="text-align:left"></th>
    <th width="45%" style="text-align:left">Windows Event Id</th>
    <th width="25%" style="text-align:left">Seen</th>
    <th width="25%" style="text-align:left">Last Seen</th>
  </tr>
</thead>
  <tbody>
<?php
        $sql = "SELECT * FROM (SELECT * FROM snare_eid where eid>0 and hidden='false' ORDER BY lastseen DESC) AS result LIMIT ". $_SESSION['PORTLET_EID_LIMIT']; 
        $result = perform_query($sql, $dbLink, "portlet-snare_eid.php"); 
示例#15
0
<?php
$basePath = dirname( __FILE__ );
require_once ($basePath . "/../common_funcs.php");
?>
<img style='float: left; border: 0 none; padding-right: 1.5em; padding-left: 1.5em; width: 200px;' src='images/lztri.png' alt='Go Go LogZilla!'/>
<table class="header">
<tr><td>
	<h2 class="logo"><?php echo $_SESSION['PROGNAME'] ." v".$_SESSION['VERSION']."".$_SESSION['VERSION_SUB']." by Clayton Dukes (cdukes@logzilla.pro)";?></h2>
</td><td class="headerright">
</td></tr></table>
<table class="headerbottom"><tr><td>
</table>
<table class="pagecontent">
<tr><td><span class="longtext">
<h3 class="title">Overview</h3>
LogZilla specializes in providing a proactive approach to network management by monitoring network status in real time.  Our network management software is the choice of thousands of IT professionals interested in improving network uptime, increasing network efficiency, reducing internal costs and eliminating unwanted network traffic

<h3 class="title">Local License Information</h3>
<ul>
<li>The license for this copy of LogZilla will expire on <?php echo $_SESSION['LZ_LIC_EXPIRES']?></li>
<li>Maximum number of messages per day: <?php echo commify($_SESSION['LZ_LIC_MSGLIMIT'])?></li>
<li>Maximum number of hosts: <?php echo commify($_SESSION['LZ_LIC_HOSTS'])?></li>
<li>Authentication modules: <?php echo $_SESSION['LZ_LIC_AUTH']?></li>
<li>Adhoc Charts: <?php echo $_SESSION['LZ_LIC_ADHOC']?></li>
<li>Email Alerts: <?php echo $_SESSION['LZ_LIC_TRIGGERS']?></li>
<li>RBAC Security Controls: <?php echo $_SESSION['LZ_LIC_RBAC']?></li>
</ul>
</table>
示例#16
0
function abbr_dmg($name, $weapon)
{
    return "<acronym title='" . commify($weapon['damage']) . "'>" . abbrnum0($weapon['damage'], 1) . "</acronym>";
}
// Get Mnemonics
// -------------------------
$sql = "SELECT COUNT(*) FROM (SELECT crc FROM mne where hidden='false') AS result";
$result = perform_query($sql, $dbLink, $_REQUEST['pageId']);
$total = mysql_fetch_row($result);
$count = $total[0];
if( $count >0 ) { 
?>
<script type="text/javascript">
var limit = <?php echo ($_SESSION['PORTLET_MNE_LIMIT'])?>;
var cnt = <?php echo $count?>;
if (cnt < 11) {
    $('#portlet-header_Mnemonics').text("Last " + cnt + " Cisco Mnemonics");
    } else {
    $('#portlet-header_Mnemonics').text("Last " + limit + " Cisco Mnemonics");
    $('#portlet-header_Mnemonics').append(" (<?php echo commify($count)?> total)")
};
</script>
<table class="hoverTable">
<thead class="ui-widget-header">
  <tr>
    <th width="5%" style="text-align:left"></th>
    <th width="45%" style="text-align:left">Mnemonic</th>
    <th width="25%" style="text-align:left">Seen</th>
    <th width="25%" style="text-align:left">Last Seen</th>
  </tr>
</thead>
  <tbody>
<?php
        $sql = "SELECT * FROM (SELECT * FROM mne where hidden='false' ORDER BY lastseen DESC) AS result LIMIT ". $_SESSION['PORTLET_MNE_LIMIT']; 
        $result = perform_query($sql, $dbLink, "portlet-mnemonics.php"); 
示例#18
0
 function team_wins($value, $data)
 {
     global $cms;
     $bar = dual_bar(array('pct1' => $data['axiskillspct'], 'pct2' => $data['allieskillspct'], 'title1' => commify($data['axiskills']) . " " . $cms->trans("Axis Kills") . " (" . $data['axiskillspct'] . "%)", 'title2' => commify($data['allieskills']) . " " . $cms->trans("Ally Kills") . " (" . $data['allieskillspct'] . "%)"));
     return $bar;
 }
示例#19
0
function dmg($dmg)
{
    return "<acronym title='" . commify($dmg) . "'>" . abbrnum0($dmg) . "</acronym>";
}
示例#20
0
    foreach ($c['f'] as $fid => $f) {
        if (!($fname_html =& $forum_name_html[$fid])) {
            continue;
        }
        $is_sf = $f['forum_parent'];
        $forums_count++;
        $new = is_unread($f['last_post_time'], $f['last_topic_id'], $f['forum_id']) ? '_new' : '';
        $folder_image = $is_sf ? $images["icon_minipost{$new}"] : $images["forum{$new}"];
        if ($f['forum_status'] == FORUM_LOCKED) {
            $folder_image = $is_sf ? $images['icon_minipost'] : $images['forum_locked'];
        }
        if ($is_sf) {
            $template->assign_block_vars('c.f.sf', array('SF_ID' => $fid, 'SF_NAME' => $fname_html, 'SF_NEW' => $new ? ' new' : ''));
            continue;
        }
        $template->assign_block_vars('c.f', array('FORUM_FOLDER_IMG' => $folder_image, 'FORUM_ID' => $fid, 'FORUM_NAME' => $fname_html, 'FORUM_DESC' => $f['forum_desc'], 'POSTS' => commify($f['forum_posts']), 'TOPICS' => commify($f['forum_topics']), 'LAST_SF_ID' => isset($f['last_sf_id']) ? $f['last_sf_id'] : null, 'MODERATORS' => isset($moderators[$fid]) ? join(', ', $moderators[$fid]) : '', 'FORUM_FOLDER_ALT' => $new ? $lang['NEW'] : $lang['OLD']));
        if ($f['last_post_id']) {
            $template->assign_block_vars('c.f.last', array('LAST_TOPIC_ID' => $f['last_topic_id'], 'LAST_TOPIC_TIP' => $f['last_topic_title'], 'LAST_TOPIC_TITLE' => wbr(str_short($f['last_topic_title'], $last_topic_max_len)), 'LAST_POST_TIME' => bb_date($f['last_post_time'], $bb_cfg['last_post_date_format']), 'LAST_POST_USER' => profile_url(array('username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank']))));
        }
    }
}
$template->assign_vars(array('SHOW_FORUMS' => $forums_count, 'SHOW_MAP' => isset($_GET['map']) && !IS_GUEST, 'PAGE_TITLE' => $viewcat ? $cat_title_html[$viewcat] : $lang['HOME'], 'NO_FORUMS_MSG' => $only_new ? $lang['NO_NEW_POSTS'] : $lang['NO_FORUMS'], 'TOTAL_TOPICS' => sprintf($lang['POSTED_TOPICS_TOTAL'], $stats['topiccount']), 'TOTAL_POSTS' => sprintf($lang['POSTED_ARTICLES_TOTAL'], $stats['postcount']), 'TOTAL_USERS' => sprintf($lang['REGISTERED_USERS_TOTAL'], $stats['usercount']), 'TOTAL_GENDER' => $bb_cfg['gender'] ? sprintf($lang['USERS_TOTAL_GENDER'], $stats['male'], $stats['female'], $stats['unselect']) : '', 'NEWEST_USER' => sprintf($lang['NEWEST_USER'], profile_url($stats['newestuser'])), 'TORRENTS_STAT' => $bb_cfg['tor_stats'] ? sprintf($lang['TORRENTS_STAT'], $stats['torrentcount'], humn_size($stats['size'])) : '', 'PEERS_STAT' => $bb_cfg['tor_stats'] ? sprintf($lang['PEERS_STAT'], $stats['peers'], $stats['seeders'], $stats['leechers']) : '', 'SPEED_STAT' => $bb_cfg['tor_stats'] ? sprintf($lang['SPEED_STAT'], humn_size($stats['speed']) . '/s') : '', 'SHOW_MOD_INDEX' => $bb_cfg['show_mod_index'], 'FORUM_IMG' => $images['forum'], 'FORUM_NEW_IMG' => $images['forum_new'], 'FORUM_LOCKED_IMG' => $images['forum_locked'], 'SHOW_ONLY_NEW_MENU' => true, 'ONLY_NEW_POSTS_ON' => $only_new == ONLY_NEW_POSTS, 'ONLY_NEW_TOPICS_ON' => $only_new == ONLY_NEW_TOPICS, 'U_SEARCH_NEW' => "search.php?new=1", 'U_SEARCH_SELF_BY_MY' => "search.php?uid={$userdata['user_id']}&amp;o=1", 'U_SEARCH_LATEST' => "search.php?search_id=latest", 'U_SEARCH_UNANSWERED' => "search.php?search_id=unanswered", 'SHOW_LAST_TOPIC' => $show_last_topic));
// Set tpl vars for bt_userdata
if ($bb_cfg['bt_show_dl_stat_on_index'] && !IS_GUEST) {
    show_bt_userdata($userdata['user_id']);
}
// Latest news
if ($bb_cfg['show_latest_news']) {
    if (!($latest_news = $datastore->get('latest_news'))) {
        $datastore->update('latest_news');
        $latest_news = $datastore->get('latest_news');