~kampka/ubuntu/quantal/zabbix/upstart-support

« 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-06-28 19:11:29 UTC
  • mfrom: (19.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090628191129-5esmmf2h3tbff1fv
* New upstream release
* Merge upstream config file to template (Closes: #528426)
* Move logrotate from Depends to Suggests (Closes: #534096)
* Server should not crash anymore if postgresql transaction fails
  (Closes: #520197)
* Update fr.po (Closes: #527559)
* Update es.po (Closes: #527600)
* Update sv.po (Closes: #528571)
* Update it.po (Closes: #529157)
* Update cs.po (Closes: #529502)
* Update de.po (Closes: #532344)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
        foreach($ref_tab as $id => $obj){
27
27
                $obj['interval'] = (isset($obj['interval']))?$obj['interval']:60;
28
28
                zbx_add_post_js(get_refresh_obj_script($obj));
29
 
                
 
29
 
30
30
                $min = ($min < $obj['interval'])?$min:$obj['interval'];
31
31
        }
32
32
        zbx_add_post_js('updater.interval = 10; updater.check4Update();');
35
35
function get_refresh_obj_script($obj){
36
36
        $obj['url'] = isset($obj['url'])?$obj['url']:'';
37
37
        $obj['url'].= (zbx_empty($obj['url'])?'?':'&').'output=html';
38
 
        
 
38
 
39
39
return 'updater.setObj4Update("'.$obj['id'].'",'.$obj['interval'].',"'.$obj['url'].'",{"favobj": "refresh", "favid": "'.$obj['id'].'"});';
40
40
}
41
41
 
43
43
 
44
44
        $menu['menu_'.$id][] = array(S_REFRESH, null, null, array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader')));
45
45
        $intervals = array('10','30','60', '120','600','900');
46
 
        
 
46
 
47
47
        foreach($intervals as $key => $value){
48
48
                $menu['menu_'.$id][] = array(
49
 
                                        S_EVERY.SPACE.$value.SPACE.S_SECONDS_SMALL, 
 
49
                                        S_EVERY.SPACE.$value.SPACE.S_SECONDS_SMALL,
50
50
                                        'javascript: setRefreshRate("'.$id.'",'.$value.');'.
51
 
                                        'void(0);',     
52
 
                                        null, 
 
51
                                        'void(0);',
 
52
                                        null,
53
53
                                        array('outer' => ($value == $cur_interval)?'pum_b_submenu':'pum_o_submenu', 'inner'=>array('pum_i_submenu')
54
54
                        ));
55
55
        }
183
183
 *      zbx_date2age
184
184
 *
185
185
 * description:
186
 
 *      Calculate and convert timestamp to string representation. 
 
186
 *      Calculate and convert timestamp to string representation.
187
187
 *
188
188
 * author: Aly
189
189
 */
205
205
 
206
206
        //$months = (int ) ($time / (30*86400));
207
207
        //$time -= $months*30*86400;
208
 
        
 
208
 
209
209
        $weeks = (int ) ($time / (7*86400));
210
210
        $time -= $weeks*7*86400;
211
 
         
 
211
 
212
212
        $days = (int) ($time / 86400);
213
213
        $time -= $days*86400;
214
 
        
 
214
 
215
215
        $hours = (int) ($time / 3600);
216
216
        $time -= $hours*3600;
217
 
        
 
217
 
218
218
        $minutes = (int) ($time / 60);
219
219
        $time -= $minutes*60;
220
 
        
 
220
 
221
221
        if($time >= 1){
222
222
                $seconds = round($time,2);
223
223
                $ms = 0;
226
226
                $seconds = 0;
227
227
                $ms = round($time,3) * 1000;
228
228
        }
229
 
        
 
229
 
230
230
        $str =  (($years)?$years.'y ':'').
231
231
//                      (($months)?$months.'m ':'').
232
232
                        (($weeks)?$weeks.'w ':'').
239
239
}
240
240
 
241
241
function getmicrotime(){
242
 
        list($usec, $sec) = explode(" ",microtime()); 
243
 
        return ((float)$usec + (float)$sec); 
 
242
        list($usec, $sec) = explode(" ",microtime());
 
243
        return ((float)$usec + (float)$sec);
244
244
}
245
245
 
246
246
/************* END DATE *************/
260
260
        $array = $new_array;
261
261
        return true;
262
262
}
263
 
        
 
263
 
264
264
function asort_by_key(&$array, $key){
265
265
        if(!is_array($array)) {
266
266
                error('Incorrect type of asort_by_key');
267
267
                return array();
268
268
        }
269
 
        
 
269
 
270
270
        $key = htmlspecialchars($key);
271
271
        uasort($array, create_function('$a,$b', 'return $a[\''.$key.'\'] - $b[\''.$key.'\'];'));
272
272
return $array;
296
296
/************* ZBX MISC *************/
297
297
 
298
298
// accepts parametr as integer either
299
 
function zbx_ctype_digit($x){ 
 
299
function zbx_ctype_digit($x){
300
300
        return preg_match('/^\\d+$/',$x);
301
301
}
302
302
 
303
303
function zbx_numeric($value){
304
304
        if(is_array($value)) return false;
305
305
        if(zbx_empty($value)) return false;
306
 
        
 
306
 
307
307
        $value = strval($value);
308
308
 
309
309
return preg_match('/^[-|+]?\\d+$/',$value);
310
310
}
311
311
 
312
312
function zbx_empty($value){
313
 
        if(is_null($value)) return true;                
 
313
        if(is_null($value)) return true;
314
314
        if(is_array($value) && empty($value)) return true;
315
315
        if(is_string($value) && ($value === '')) return true;
316
316
return false;
317
317
}
318
 
        
 
318
 
319
319
function zbx_strlen(&$str){
320
320
        if(!$strlen = strlen($str)) return $strlen;
321
 
        
 
321
 
322
322
        $reallen = 0;
323
323
        $fbin= 1 << 7;
324
324
        $sbin= 1 << 6;
341
341
function zbx_stristr($haystack,$needle){
342
342
        $haystack_B = strtoupper($haystack);
343
343
        $needle = strtoupper($needle);
344
 
        
 
344
 
345
345
        $pos = strpos($haystack_B,$needle);
346
346
        if($pos !== FALSE){
347
347
                $pos = substr($haystack,$pos);
351
351
 
352
352
function zbx_substring($haystack, $start, $end=null){
353
353
        if($end < $start) return '';
354
 
        
 
354
 
355
355
        $len = zbx_strlen($haystack);
356
356
        if(is_null($end))
357
357
                $result = substr($haystack, $start);
372
372
                return in_array($needle,$haystack,$strict);
373
373
        }
374
374
        else if($strict){
375
 
                foreach($haystack as $id => $value) 
 
375
                foreach($haystack as $id => $value)
376
376
                        if($needle === $value) return true;
377
377
        }
378
378
        else{