/**
 * 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;
}
/**
 * Smarty number compacttime modifier plugin
 *
 * Type:     modifier<br>
 * Name:     compacttime<br>
 * Purpose:  convert seconds into a string representing the "h:m:s"
 * @param string
 * @return string
 */
function smarty_modifier_compacttime($seconds, $format = "hh:mm:ss")
{
    return compacttime($seconds, $format);
}
Exemple #3
0
 xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
 xml_parser_set_option($xp, XML_OPTION_SKIP_WHITE, true);
 xml_parse_into_struct($xp, $xml, $vals, $index);
 xml_parser_free($xp);
 $markers = array();
 foreach ($vals as $m) {
     if ($m['tag'] != 'marker') {
         continue;
     }
     $set = $m['attributes'];
     $ip = $set['ip'];
     if ($iplist[$ip]) {
         $set = array_merge($set, $iplist[$ip]);
     }
     unset($set['ip'], $set['ipaddr']);
     $set['onlinetime'] = compacttime($set['onlinetime']);
     //		$set['activity_bar'] = pct_bar(array('pct' => $set['activity'], 'width' => 215, 'title' => "Activity: " . $set['activity'] . "%" ));
     if (!empty($set['lat']) and !empty($set['lng'])) {
         $markers[$ip] = $set;
     }
 }
 // now, spew out the markers XML
 $xml = "<markers>\n";
 $markers = array_merge($profiles, $markers);
 foreach ($markers as $m) {
     $node = "  <marker ";
     foreach ($m as $key => $val) {
         $node .= "{$key}=\"" . ps_escape_html($val) . "\" ";
     }
     $node .= "/>\n";
     $xml .= $node;
Exemple #4
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} ]";
 }
Exemple #5
0
function conv_onlinetime($time)
{
    return compacttime($time, 'hh:mm');
}