~ubuntu-dev/ubuntu/lucid/zabbix/lucid-201002101903

« back to all changes in this revision

Viewing changes to frontends/php/include/func.inc.php

  • Committer: Bazaar Package Importer
  • Author(s): Michael Ablassmeier
  • Date: 2009-04-05 19:10:27 UTC
  • mfrom: (1.1.9 upstream) (8.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090405191027-lxd44l6jqdcfp2bi
Tags: 1:1.6.4-1
* New upstream release.
* Fix zabbix-frontend-php.template, add missing questions for
  zabbix-server and port (Closes: #522076)
* Loosen up depends for libgnutls (Closes: #522074)

Show diffs side-by-side

added added

removed removed

Lines of Context:
161
161
function zbx_set_post_cookie($name, $value, $time=null){
162
162
        global $ZBX_PAGE_COOKIES;
163
163
 
164
 
        $ZBX_PAGE_COOKIES[] = array($name, $value, isset($time) ? $time : (0));
 
164
        $ZBX_PAGE_COOKIES[] = array($name, $value, isset($time)?$time:0);
165
165
}
166
166
 
167
167
/************ END COOKIES ************/
203
203
        $years = (int) ($time / (365*86400));
204
204
        $time -= $years*365*86400;
205
205
 
206
 
        $months = (int ) ($time / (30*86400));
207
 
        $time -= $months*30*86400;
 
206
        //$months = (int ) ($time / (30*86400));
 
207
        //$time -= $months*30*86400;
 
208
        
 
209
        $weeks = (int ) ($time / (7*86400));
 
210
        $time -= $weeks*7*86400;
208
211
         
209
212
        $days = (int) ($time / 86400);
210
213
        $time -= $days*86400;
225
228
        }
226
229
        
227
230
        $str =  (($years)?$years.'y ':'').
228
 
                        (($months)?$months.'m ':'').
 
231
//                      (($months)?$months.'m ':'').
 
232
                        (($weeks)?$weeks.'w ':'').
229
233
                        (($days)?$days.'d ':'').
230
234
                        (($hours && !$years)?$hours.'h ':'').
231
 
                        (($minutes && !$years && !$months)?$minutes.'m ':'').
232
 
                        ((!$years && !$months && !$days && (!$ms || $seconds))?$seconds.'s ':'').
233
 
                        (($ms && !$years && !$months && !$days && !$hours)?$ms.'ms':'');
 
235
                        (($minutes && !$years && !$weeks)?$minutes.'m ':'').
 
236
                        ((!$years && !$weeks && !$days && (!$ms || $seconds))?$seconds.'s ':'').
 
237
                        (($ms && !$years && !$weeks && !$days && !$hours)?$ms.'ms':'');
234
238
return $str;
235
239
}
236
240
 
290
294
/************* END SORT *************/
291
295
 
292
296
/************* ZBX MISC *************/
293
 
if(!function_exists('ctype_digit')){
294
 
        function ctype_digit($x){ 
295
 
                return preg_match('/^\\d+$/',$x); 
296
 
        }
 
297
 
 
298
// accepts parametr as integer either
 
299
function zbx_ctype_digit($x){ 
 
300
        return preg_match('/^\\d+$/',$x);
297
301
}
298
302
 
299
303
function zbx_numeric($value){
301
305
        if(zbx_empty($value)) return false;
302
306
        
303
307
        $value = strval($value);
304
 
return ctype_digit($value);
 
308
 
 
309
return preg_match('/^[-|+]?\\d+$/',$value);
305
310
}
306
311
 
307
312
function zbx_empty($value){
344
349
return $pos;
345
350
}
346
351
 
 
352
function zbx_substring($haystack, $start, $end=null){
 
353
        if($end < $start) return '';
 
354
        
 
355
        $len = zbx_strlen($haystack);
 
356
        if(is_null($end))
 
357
                $result = substr($haystack, $start);
 
358
        else
 
359
                $result = substr($haystack, $start, ($end - $start));
 
360
 
 
361
return $result;
 
362
}
 
363
 
347
364
function uint_in_array($needle,$haystack){
348
365
        foreach($haystack as $id => $value)
349
366
                if(bccomp($needle,$value) == 0) return true;