@@ -207,8 +207,7 @@ |
||
207 | 207 | $y = rand(0, $img_height / 2); |
208 | 208 | imagestring($im, $font_size, $x, $y, substr($word, $i, 1), $text_color); |
209 | 209 | $x += ($font_size * 2); |
210 | - } |
|
211 | - else |
|
210 | + } else |
|
212 | 211 | { |
213 | 212 | $y = rand($img_height / 2, $img_height - 3); |
214 | 213 | imagettftext($im, $font_size, $angle, $x, $y, $text_color, $font_path, substr($word, $i, 1)); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | That's it for now. If you have questions, ideas or problems, please write me at daniel AT dornhardt.com. |
238 | 238 | */ |
239 | - if (! defined('TI_VIEWS_DIR') ) { |
|
239 | + if ( ! defined('TI_VIEWS_DIR')) { |
|
240 | 240 | if (defined('APPPATH')) { |
241 | 241 | define('TI_VIEWS_DIR', APPPATH.'views/'); |
242 | 242 | } else { |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $GLOBALS['CI']->load->view($GLOBALS['TI_CURRENT_BASE_TEMPLATE']); |
286 | 286 | } |
287 | 287 | else { |
288 | - include realpath( TI_VIEWS_DIR . $GLOBALS['TI_CURRENT_BASE_TEMPLATE']); |
|
288 | + include realpath(TI_VIEWS_DIR.$GLOBALS['TI_CURRENT_BASE_TEMPLATE']); |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | */ |
372 | 372 | function block_rendering_neccessary() { |
373 | 373 | // check if no child did override this block |
374 | - if (!array_key_exists($GLOBALS['TI_CURRENT_BLOCKNAME'], $GLOBALS['TI_EXTENDED_BASE_TEMPLATE_DATA'] )) { |
|
374 | + if ( ! array_key_exists($GLOBALS['TI_CURRENT_BLOCKNAME'], $GLOBALS['TI_EXTENDED_BASE_TEMPLATE_DATA'])) { |
|
375 | 375 | return true; |
376 | 376 | } |
377 | 377 | // check if there is an extension marker in the child blocks data. If so, the |
@@ -283,8 +283,7 @@ |
||
283 | 283 | //echo 'tttttttttttt'; |
284 | 284 | if (isset($GLOBALS['CI'])) { |
285 | 285 | $GLOBALS['CI']->load->view($GLOBALS['TI_CURRENT_BASE_TEMPLATE']); |
286 | - } |
|
287 | - else { |
|
286 | + } else { |
|
288 | 287 | include realpath( TI_VIEWS_DIR . $GLOBALS['TI_CURRENT_BASE_TEMPLATE']); |
289 | 288 | } |
290 | 289 | } |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | return $form; |
81 | 81 | } |
82 | 82 | } |
83 | -if(!function_exists('form_breadcrumb')){ |
|
84 | - function form_breadcrumb($info=''){ |
|
85 | - $form=false; |
|
86 | - if(!empty($info)) |
|
87 | - $form.="<div class='breadcrumb'> |
|
83 | +if ( ! function_exists('form_breadcrumb')) { |
|
84 | + function form_breadcrumb($info = '') { |
|
85 | + $form = false; |
|
86 | + if ( ! empty($info)) |
|
87 | + $form .= "<div class='breadcrumb'> |
|
88 | 88 | <a href='".$info['url']."'>".$info['name']."</a> |
89 | 89 | </div>"; |
90 | 90 | return $form; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | </span> |
213 | 213 | </div> |
214 | 214 | </div>'; |
215 | - }else{ |
|
215 | + } else { |
|
216 | 216 | return "<div class='col-md-5 no-padding'><image "._parse_form_attributes($data, $defaults).$extra." /></div>"; |
217 | 217 | } |
218 | 218 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | { |
227 | 227 | // echo '<pre>'; print_r($data); exit; |
228 | 228 | //$data["class"] = "col-md-5 form-control"; |
229 | - $data['value']='Delete'; |
|
229 | + $data['value'] = 'Delete'; |
|
230 | 230 | $defaults = array('type' => 'button', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => 'Delete'); |
231 | 231 | |
232 | 232 | return "<div class='col-md-5 no-padding'><input "._parse_form_attributes($data, $defaults).$extra." /></div>"; |
@@ -377,21 +377,21 @@ discard block |
||
377 | 377 | |
378 | 378 | if ($extra != '') $extra = ' '.$extra; |
379 | 379 | $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; |
380 | - if(is_array($name)){ |
|
381 | - $str=null; |
|
382 | - foreach($name as $key=>$value){ |
|
383 | - if($key !='class' && $key!='disabled') |
|
384 | - $str.=$key."='$value' "; |
|
380 | + if (is_array($name)) { |
|
381 | + $str = null; |
|
382 | + foreach ($name as $key=>$value) { |
|
383 | + if ($key != 'class' && $key != 'disabled') |
|
384 | + $str .= $key."='$value' "; |
|
385 | 385 | } |
386 | - if(isset($name['disabled']) && $name['disabled']== 'disabled'){ |
|
387 | - $str.='disabled = "disabled"'; |
|
386 | + if (isset($name['disabled']) && $name['disabled'] == 'disabled') { |
|
387 | + $str .= 'disabled = "disabled"'; |
|
388 | 388 | } |
389 | 389 | $form = '<select '.$str." class='col-md-5 form-control selectpicker ".$name['class'].$extra."' data-live-search='true'>\n"; |
390 | - }else{ |
|
391 | - if(!empty($extra)){ |
|
392 | - $form = '<select name="'.$name.'"' .$multiple." class='col-md-5 form-control selectpicker ".$extra."' data-live-search='true'>\n"; |
|
393 | - }else{ |
|
394 | - $form = '<select name="'.$name.'"' .$multiple." class='col-md-5 form-control selectpicker' data-live-search='true'>\n"; |
|
390 | + } else { |
|
391 | + if ( ! empty($extra)) { |
|
392 | + $form = '<select name="'.$name.'"'.$multiple." class='col-md-5 form-control selectpicker ".$extra."' data-live-search='true'>\n"; |
|
393 | + } else { |
|
394 | + $form = '<select name="'.$name.'"'.$multiple." class='col-md-5 form-control selectpicker' data-live-search='true'>\n"; |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 | // if($extra != '' ){ |
@@ -418,12 +418,12 @@ discard block |
||
418 | 418 | { |
419 | 419 | $sel = (in_array($key, $selected)) ? ' selected="selected"' : ''; |
420 | 420 | |
421 | - $form .= '<option value="'.$key.'"'.$sel.'>'.(string) $val."</option>\n"; |
|
421 | + $form .= '<option value="'.$key.'"'.$sel.'>'.(string)$val."</option>\n"; |
|
422 | 422 | } |
423 | 423 | } |
424 | - if(isset($name['option_value']) && isset($name['option_text'])){ |
|
425 | - $sel= isset($name['value']) && $name['value']==$name['option_value']?'selected ="selected"':''; |
|
426 | - $form .= '<option value="'.$name['option_value'].'"'.$sel.'>'.(string) $name['option_text']."</option>\n"; |
|
424 | + if (isset($name['option_value']) && isset($name['option_text'])) { |
|
425 | + $sel = isset($name['value']) && $name['value'] == $name['option_value'] ? 'selected ="selected"' : ''; |
|
426 | + $form .= '<option value="'.$name['option_value'].'"'.$sel.'>'.(string)$name['option_text']."</option>\n"; |
|
427 | 427 | } |
428 | 428 | $form .= '</select>'; |
429 | 429 | //echo $form; exit; |
@@ -449,21 +449,21 @@ discard block |
||
449 | 449 | } |
450 | 450 | } |
451 | 451 | if ($extra != '') $extra = ' '.$extra; |
452 | - $class= isset($name['class']) && !empty($name['class']) ? "col-md-5 form-control selectpicker $name[class]" :"col-md-5 form-control selectpicker"; |
|
452 | + $class = isset($name['class']) && ! empty($name['class']) ? "col-md-5 form-control selectpicker $name[class]" : "col-md-5 form-control selectpicker"; |
|
453 | 453 | $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; |
454 | - if(is_array($name) && !isset($name["id"])){ |
|
454 | + if (is_array($name) && ! isset($name["id"])) { |
|
455 | 455 | $form = '<select name="'.$name['name'].'"'." class='$class' data-live-search='true'>\n"; |
456 | - }else if(is_array($name) && isset($name["id"])){ |
|
456 | + } else if (is_array($name) && isset($name["id"])) { |
|
457 | 457 | $form = '<select name="'.$name['name'].'" id="'.$name['id'].'"'."class='$class' data-live-search='true'>\n"; |
458 | 458 | } |
459 | - else{ |
|
460 | - $form = '<select name="'.$name.'"' .$multiple." class='$class' data-live-search='true'>\n"; |
|
459 | + else { |
|
460 | + $form = '<select name="'.$name.'"'.$multiple." class='$class' data-live-search='true'>\n"; |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | $form .= '<option value=""> --Select-- </option>'; |
464 | 464 | foreach ($options as $key => $val) |
465 | 465 | { |
466 | - $key = (string) $key; |
|
466 | + $key = (string)$key; |
|
467 | 467 | |
468 | 468 | if (is_array($val) && ! empty($val)) |
469 | 469 | { |
@@ -481,12 +481,12 @@ discard block |
||
481 | 481 | { |
482 | 482 | $sel = (in_array($key, $selected)) ? ' selected="selected"' : ''; |
483 | 483 | |
484 | - $form .= '<option value="'.$key.'"'.$sel.'>'.(string) $val."</option>\n"; |
|
484 | + $form .= '<option value="'.$key.'"'.$sel.'>'.(string)$val."</option>\n"; |
|
485 | 485 | } |
486 | 486 | } |
487 | - if(isset($name['option_value']) && isset($name['option_text'])){ |
|
488 | - $sel= isset($name['value']) && $name['value']==$name['option_value']?'selected ="selected"':''; |
|
489 | - $form .= '<option value="'.$name['option_value'].'"'.$sel.'>'.(string) $name['option_text']."</option>\n"; |
|
487 | + if (isset($name['option_value']) && isset($name['option_text'])) { |
|
488 | + $sel = isset($name['value']) && $name['value'] == $name['option_value'] ? 'selected ="selected"' : ''; |
|
489 | + $form .= '<option value="'.$name['option_value'].'"'.$sel.'>'.(string)$name['option_text']."</option>\n"; |
|
490 | 490 | } |
491 | 491 | $form .= '</select>'; |
492 | 492 | |
@@ -517,35 +517,35 @@ discard block |
||
517 | 517 | /* |
518 | 518 | ASTPP 3.0 For Search Display In |
519 | 519 | */ |
520 | - if ($extra != '' && !is_array($extra)) $extra = ' '.$extra; |
|
520 | + if ($extra != '' && ! is_array($extra)) $extra = ' '.$extra; |
|
521 | 521 | /**********************************************************/ |
522 | 522 | |
523 | - $class= isset($name['class']) && !empty($name['class']) ? "col-md-5 form-control selectpicker $name[class]" :"col-md-5 form-control selectpicker"; |
|
523 | + $class = isset($name['class']) && ! empty($name['class']) ? "col-md-5 form-control selectpicker $name[class]" : "col-md-5 form-control selectpicker"; |
|
524 | 524 | |
525 | 525 | $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; |
526 | 526 | /* |
527 | 527 | ASTPP 3.0 For Search Display In |
528 | 528 | */ |
529 | - if(empty($extra)){ |
|
529 | + if (empty($extra)) { |
|
530 | 530 | /*********************************/ |
531 | - if(is_array($name) && !isset($name["id"])){ |
|
531 | + if (is_array($name) && ! isset($name["id"])) { |
|
532 | 532 | $form = '<select name="'.$name['name'].'"'." class='col-md-5 form-control $class' style='margin-left:5px;' data-live-search='true'>\n"; |
533 | - }else if(is_array($name) && isset($name["id"])){ |
|
533 | + } else if (is_array($name) && isset($name["id"])) { |
|
534 | 534 | $form = '<select name="'.$name['name'].'" id="'.$name['id'].'"'."class='col-md-5 form-control $class' style='margin-left:5px;' data-live-search='true'>\n"; |
535 | - }else{ |
|
536 | - $form = '<select name="'.$name.'"' .$multiple." class='col-md-5 form-control $class' style='margin-left:5px;' data-live-search='true'>\n"; |
|
535 | + } else { |
|
536 | + $form = '<select name="'.$name.'"'.$multiple." class='col-md-5 form-control $class' style='margin-left:5px;' data-live-search='true'>\n"; |
|
537 | 537 | } |
538 | 538 | /* |
539 | 539 | ASTPP 3.0 For Search Display In |
540 | 540 | */ |
541 | - }else{ |
|
541 | + } else { |
|
542 | 542 | |
543 | 543 | $form = '<select name="'.$name['name'].'" id="'.$name['id'].'"'."class='".$extra['class']." $class' style='".$extra['style']."' data-live-search='true'>\n"; |
544 | 544 | } |
545 | 545 | //$form .= '<option value=""> --Select-- </option>'; |
546 | 546 | foreach ($options as $key => $val) |
547 | 547 | { |
548 | - $key = (string) $key; |
|
548 | + $key = (string)$key; |
|
549 | 549 | |
550 | 550 | if (is_array($val) && ! empty($val)) |
551 | 551 | { |
@@ -685,13 +685,13 @@ discard block |
||
685 | 685 | { |
686 | 686 | unset($defaults['checked']); |
687 | 687 | } |
688 | - $class=NULL; |
|
688 | + $class = NULL; |
|
689 | 689 | |
690 | 690 | //echo "<pre>".$value; print_r($extra); exit; |
691 | - if(isset($extra[$value]) && !empty($extra) && $extra[$value] == '0'){ |
|
692 | - $class='onoffswitch-inner'; |
|
693 | - }else{ |
|
694 | - $class='onoffswitch-inner'; |
|
691 | + if (isset($extra[$value]) && ! empty($extra) && $extra[$value] == '0') { |
|
692 | + $class = 'onoffswitch-inner'; |
|
693 | + } else { |
|
694 | + $class = 'onoffswitch-inner'; |
|
695 | 695 | } |
696 | 696 | /* if(isset($extra) && $extra != ''){ |
697 | 697 | if(isset($extra[0])){ |
@@ -83,10 +83,11 @@ discard block |
||
83 | 83 | if(!function_exists('form_breadcrumb')){ |
84 | 84 | function form_breadcrumb($info=''){ |
85 | 85 | $form=false; |
86 | - if(!empty($info)) |
|
87 | - $form.="<div class='breadcrumb'> |
|
86 | + if(!empty($info)) { |
|
87 | + $form.="<div class='breadcrumb'> |
|
88 | 88 | <a href='".$info['url']."'>".$info['name']."</a> |
89 | - </div>"; |
|
89 | + </div>"; |
|
90 | + } |
|
90 | 91 | return $form; |
91 | 92 | } |
92 | 93 | } |
@@ -212,7 +213,7 @@ discard block |
||
212 | 213 | </span> |
213 | 214 | </div> |
214 | 215 | </div>'; |
215 | - }else{ |
|
216 | + } else{ |
|
216 | 217 | return "<div class='col-md-5 no-padding'><image "._parse_form_attributes($data, $defaults).$extra." /></div>"; |
217 | 218 | } |
218 | 219 | |
@@ -375,22 +376,25 @@ discard block |
||
375 | 376 | } |
376 | 377 | } |
377 | 378 | |
378 | - if ($extra != '') $extra = ' '.$extra; |
|
379 | + if ($extra != '') { |
|
380 | + $extra = ' '.$extra; |
|
381 | + } |
|
379 | 382 | $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; |
380 | 383 | if(is_array($name)){ |
381 | 384 | $str=null; |
382 | 385 | foreach($name as $key=>$value){ |
383 | - if($key !='class' && $key!='disabled') |
|
384 | - $str.=$key."='$value' "; |
|
386 | + if($key !='class' && $key!='disabled') { |
|
387 | + $str.=$key."='$value' "; |
|
388 | + } |
|
385 | 389 | } |
386 | 390 | if(isset($name['disabled']) && $name['disabled']== 'disabled'){ |
387 | 391 | $str.='disabled = "disabled"'; |
388 | 392 | } |
389 | 393 | $form = '<select '.$str." class='col-md-5 form-control selectpicker ".$name['class'].$extra."' data-live-search='true'>\n"; |
390 | - }else{ |
|
394 | + } else{ |
|
391 | 395 | if(!empty($extra)){ |
392 | 396 | $form = '<select name="'.$name.'"' .$multiple." class='col-md-5 form-control selectpicker ".$extra."' data-live-search='true'>\n"; |
393 | - }else{ |
|
397 | + } else{ |
|
394 | 398 | $form = '<select name="'.$name.'"' .$multiple." class='col-md-5 form-control selectpicker' data-live-search='true'>\n"; |
395 | 399 | } |
396 | 400 | } |
@@ -448,15 +452,16 @@ discard block |
||
448 | 452 | $selected = array($_POST[$name]); |
449 | 453 | } |
450 | 454 | } |
451 | - if ($extra != '') $extra = ' '.$extra; |
|
455 | + if ($extra != '') { |
|
456 | + $extra = ' '.$extra; |
|
457 | + } |
|
452 | 458 | $class= isset($name['class']) && !empty($name['class']) ? "col-md-5 form-control selectpicker $name[class]" :"col-md-5 form-control selectpicker"; |
453 | 459 | $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; |
454 | 460 | if(is_array($name) && !isset($name["id"])){ |
455 | 461 | $form = '<select name="'.$name['name'].'"'." class='$class' data-live-search='true'>\n"; |
456 | - }else if(is_array($name) && isset($name["id"])){ |
|
462 | + } else if(is_array($name) && isset($name["id"])){ |
|
457 | 463 | $form = '<select name="'.$name['name'].'" id="'.$name['id'].'"'."class='$class' data-live-search='true'>\n"; |
458 | - } |
|
459 | - else{ |
|
464 | + } else{ |
|
460 | 465 | $form = '<select name="'.$name.'"' .$multiple." class='$class' data-live-search='true'>\n"; |
461 | 466 | } |
462 | 467 | |
@@ -517,7 +522,9 @@ discard block |
||
517 | 522 | /* |
518 | 523 | ASTPP 3.0 For Search Display In |
519 | 524 | */ |
520 | - if ($extra != '' && !is_array($extra)) $extra = ' '.$extra; |
|
525 | + if ($extra != '' && !is_array($extra)) { |
|
526 | + $extra = ' '.$extra; |
|
527 | + } |
|
521 | 528 | /**********************************************************/ |
522 | 529 | |
523 | 530 | $class= isset($name['class']) && !empty($name['class']) ? "col-md-5 form-control selectpicker $name[class]" :"col-md-5 form-control selectpicker"; |
@@ -530,15 +537,15 @@ discard block |
||
530 | 537 | /*********************************/ |
531 | 538 | if(is_array($name) && !isset($name["id"])){ |
532 | 539 | $form = '<select name="'.$name['name'].'"'." class='col-md-5 form-control $class' style='margin-left:5px;' data-live-search='true'>\n"; |
533 | - }else if(is_array($name) && isset($name["id"])){ |
|
540 | + } else if(is_array($name) && isset($name["id"])){ |
|
534 | 541 | $form = '<select name="'.$name['name'].'" id="'.$name['id'].'"'."class='col-md-5 form-control $class' style='margin-left:5px;' data-live-search='true'>\n"; |
535 | - }else{ |
|
542 | + } else{ |
|
536 | 543 | $form = '<select name="'.$name.'"' .$multiple." class='col-md-5 form-control $class' style='margin-left:5px;' data-live-search='true'>\n"; |
537 | 544 | } |
538 | 545 | /* |
539 | 546 | ASTPP 3.0 For Search Display In |
540 | 547 | */ |
541 | - }else{ |
|
548 | + } else{ |
|
542 | 549 | |
543 | 550 | $form = '<select name="'.$name['name'].'" id="'.$name['id'].'"'."class='".$extra['class']." $class' style='".$extra['style']."' data-live-search='true'>\n"; |
544 | 551 | } |
@@ -690,7 +697,7 @@ discard block |
||
690 | 697 | //echo "<pre>".$value; print_r($extra); exit; |
691 | 698 | if(isset($extra[$value]) && !empty($extra) && $extra[$value] == '0'){ |
692 | 699 | $class='onoffswitch-inner'; |
693 | - }else{ |
|
700 | + } else{ |
|
694 | 701 | $class='onoffswitch-inner'; |
695 | 702 | } |
696 | 703 | /* if(isset($extra) && $extra != ''){ |
@@ -28,8 +28,9 @@ |
||
28 | 28 | function get_configurations($db) { |
29 | 29 | $query = "SELECT * FROM system WHERE group_title IN ('global','opensips')"; |
30 | 30 | $res_conf = $db->run($query); |
31 | - foreach ($res_conf as $res_conf_key => $res_conf_value) |
|
32 | - $this->config[$res_conf_value['name']] = $res_conf_value['value']; |
|
31 | + foreach ($res_conf as $res_conf_key => $res_conf_value) { |
|
32 | + $this->config[$res_conf_value['name']] = $res_conf_value['value']; |
|
33 | + } |
|
33 | 34 | |
34 | 35 | return $this->config; |
35 | 36 | } |
@@ -24,97 +24,97 @@ discard block |
||
24 | 24 | |
25 | 25 | //Parse user and rates array which we got in cdr xml |
26 | 26 | function parse_rates_array($xml_rate, $constant_array, $logger) { |
27 | - $rates_array = array(); |
|
27 | + $rates_array = array(); |
|
28 | 28 | |
29 | - //decode string using urldecode |
|
30 | - $xml_rate = urldecode($xml_rate); |
|
31 | - $xml_rate_array = explode("||", $xml_rate); |
|
29 | + //decode string using urldecode |
|
30 | + $xml_rate = urldecode($xml_rate); |
|
31 | + $xml_rate_array = explode("||", $xml_rate); |
|
32 | 32 | |
33 | - foreach ($xml_rate_array as $rate_key => $rate_value) { |
|
34 | - $rates_array = explode("|", $rate_value); |
|
33 | + foreach ($xml_rate_array as $rate_key => $rate_value) { |
|
34 | + $rates_array = explode("|", $rate_value); |
|
35 | 35 | |
36 | - $user_id_param = $rates_array[count($rates_array) - 1]; |
|
37 | - $user_id = (substr($user_id_param, 0, 3) == 'UID') ? substr($user_id_param, 3) : 0; |
|
36 | + $user_id_param = $rates_array[count($rates_array) - 1]; |
|
37 | + $user_id = (substr($user_id_param, 0, 3) == 'UID') ? substr($user_id_param, 3) : 0; |
|
38 | 38 | |
39 | - foreach ($rates_array as $key => $value) { |
|
40 | - $rates_array_info[$user_id][$constant_array[substr($value, 0, 3)]] = substr($value, 3); |
|
41 | - } |
|
42 | - } |
|
43 | - return $rates_array_info; |
|
39 | + foreach ($rates_array as $key => $value) { |
|
40 | + $rates_array_info[$user_id][$constant_array[substr($value, 0, 3)]] = substr($value, 3); |
|
41 | + } |
|
42 | + } |
|
43 | + return $rates_array_info; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | //Process package |
47 | 47 | function process_package($xml_cdr, $user_id, $rates_array, $logger, $db) { |
48 | - $duration = $xml_cdr->variables->duration; |
|
49 | - $xml_cdr->variables->package_id = 0; |
|
50 | - $flag = false; |
|
51 | - if ($duration > 0 && $xml_cdr->variables->call_direction == 'outbound') { |
|
52 | - $destination_number = $xml_cdr->variables->effective_destination_number; |
|
53 | - |
|
54 | - $number_len = strlen($destination_number); |
|
55 | - $number_loop_str = '('; |
|
56 | - while ($number_len > 0) { |
|
57 | - $number_loop_str .= " code='".substr($destination_number, 0, $number_len)."' OR "; |
|
58 | - $number_len -= 1; |
|
59 | - } |
|
60 | - $number_loop_str .= " code='--')"; |
|
61 | - |
|
62 | - $query = "SELECT A.id as package_id,code,includedseconds FROM tbl_package AS A ,tbl_package_codes AS B WHERE ".$number_loop_str." AND B.package_id = A.id AND A.ratecard_id=".$rates_array['ratecard_id']." AND A.status=0 AND A.is_del=0 ORDER BY length(code) DESC"; |
|
63 | - $logger->log("Package Query : ".$query); |
|
64 | - $res_package = $db->run($query); |
|
65 | - |
|
66 | - foreach ($res_package as $res_package_key => $package_info) { |
|
67 | - if (isset($package_info['package_id'])) { |
|
68 | - $query = "SELECT SUM(used_seconds) as used_seconds FROM tbl_package_usage WHERE code=".$package_info['code']." AND package_id=".$package_info['package_id']." AND user_id=".$user_id; |
|
69 | - $logger->log("Package usage Query : ".$query); |
|
70 | - $res_pkg_usg = $db->run($query); |
|
71 | - $package_usage_info = $res_pkg_usg[0]; |
|
72 | - |
|
73 | - $used_seconds = (isset($package_usage_info['used_seconds'])) ? $package_usage_info['used_seconds'] : 0; |
|
74 | - |
|
75 | - $logger->log("Included seconds : ".$package_info['includedseconds'].", Used seconds : ".$used_seconds); |
|
76 | - if ($package_info['includedseconds'] > $used_seconds) { |
|
77 | - $remaining_seconds = $package_info['includedseconds'] - ($duration + $used_seconds); |
|
78 | - if ($remaining_seconds > 0) { |
|
79 | - $dud_sec = $duration; |
|
80 | - $duration = 0; |
|
81 | - } else { |
|
82 | - $dud_sec = $duration - abs($remaining_seconds); |
|
83 | - $duration = abs($remaining_seconds); |
|
84 | - } |
|
85 | - $flag = true; |
|
86 | - $xml_cdr->variables->package_id = $package_info['package_id']; |
|
87 | - |
|
88 | - $query = "INSERT INTO tbl_package_usage (package_id,user_id,code,used_seconds) VALUES (".$package_info['package_id'].",".$user_id.",'".$package_info['code']."',".$dud_sec.") ON DUPLICATE KEY UPDATE used_seconds=used_seconds+".$dud_sec; |
|
89 | - $logger->log("Package Usage Query : ".$query); |
|
90 | - $db->run($query); |
|
91 | - |
|
92 | - break; |
|
93 | - } |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - return array($duration, $flag); |
|
48 | + $duration = $xml_cdr->variables->duration; |
|
49 | + $xml_cdr->variables->package_id = 0; |
|
50 | + $flag = false; |
|
51 | + if ($duration > 0 && $xml_cdr->variables->call_direction == 'outbound') { |
|
52 | + $destination_number = $xml_cdr->variables->effective_destination_number; |
|
53 | + |
|
54 | + $number_len = strlen($destination_number); |
|
55 | + $number_loop_str = '('; |
|
56 | + while ($number_len > 0) { |
|
57 | + $number_loop_str .= " code='".substr($destination_number, 0, $number_len)."' OR "; |
|
58 | + $number_len -= 1; |
|
59 | + } |
|
60 | + $number_loop_str .= " code='--')"; |
|
61 | + |
|
62 | + $query = "SELECT A.id as package_id,code,includedseconds FROM tbl_package AS A ,tbl_package_codes AS B WHERE ".$number_loop_str." AND B.package_id = A.id AND A.ratecard_id=".$rates_array['ratecard_id']." AND A.status=0 AND A.is_del=0 ORDER BY length(code) DESC"; |
|
63 | + $logger->log("Package Query : ".$query); |
|
64 | + $res_package = $db->run($query); |
|
65 | + |
|
66 | + foreach ($res_package as $res_package_key => $package_info) { |
|
67 | + if (isset($package_info['package_id'])) { |
|
68 | + $query = "SELECT SUM(used_seconds) as used_seconds FROM tbl_package_usage WHERE code=".$package_info['code']." AND package_id=".$package_info['package_id']." AND user_id=".$user_id; |
|
69 | + $logger->log("Package usage Query : ".$query); |
|
70 | + $res_pkg_usg = $db->run($query); |
|
71 | + $package_usage_info = $res_pkg_usg[0]; |
|
72 | + |
|
73 | + $used_seconds = (isset($package_usage_info['used_seconds'])) ? $package_usage_info['used_seconds'] : 0; |
|
74 | + |
|
75 | + $logger->log("Included seconds : ".$package_info['includedseconds'].", Used seconds : ".$used_seconds); |
|
76 | + if ($package_info['includedseconds'] > $used_seconds) { |
|
77 | + $remaining_seconds = $package_info['includedseconds'] - ($duration + $used_seconds); |
|
78 | + if ($remaining_seconds > 0) { |
|
79 | + $dud_sec = $duration; |
|
80 | + $duration = 0; |
|
81 | + } else { |
|
82 | + $dud_sec = $duration - abs($remaining_seconds); |
|
83 | + $duration = abs($remaining_seconds); |
|
84 | + } |
|
85 | + $flag = true; |
|
86 | + $xml_cdr->variables->package_id = $package_info['package_id']; |
|
87 | + |
|
88 | + $query = "INSERT INTO tbl_package_usage (package_id,user_id,code,used_seconds) VALUES (".$package_info['package_id'].",".$user_id.",'".$package_info['code']."',".$dud_sec.") ON DUPLICATE KEY UPDATE used_seconds=used_seconds+".$dud_sec; |
|
89 | + $logger->log("Package Usage Query : ".$query); |
|
90 | + $db->run($query); |
|
91 | + |
|
92 | + break; |
|
93 | + } |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + return array($duration, $flag); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | //Process user/vendor cdr |
101 | 101 | function do_cdr_process($xml_cdr, $debit, $cost, $vendor_cost, $rates_array, $parent_id = 0, $parent_rates, $carrier_rates_array, $logger, $db) { |
102 | - $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".$xml_cdr->variables->entity_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->carrier_id."','".$xml_cdr->callflow[0]->caller_profile->originatee->originatee_caller_profile->network_addr."','".$xml_cdr->variables->sip_contact_host."','".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",'".$xml_cdr->variables->vendor_id."',".$vendor_cost.",".$rates_array['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array['code']."','".$rates_array['destination']."','".$rates_array['cost']."','".$parent_id."','".@$parent_rates['code']."','".@$parent_rates['destination']."','".@$parent_rates['cost']."','".@$carrier_rates_array['code']."','".@$carrier_rates_array['destination']."','".@$carrier_rates_array['cost']."','".$xml_cdr->variables->call_direction."','".urldecode($xml_cdr->variables->profile_start_stamp)."','".urldecode($xml_cdr->variables->answer_stamp)."','".urldecode($xml_cdr->variables->bridge_stamp)."','".urldecode($xml_cdr->variables->progress_stamp)."','".urldecode($xml_cdr->variables->progress_media_stamp)."','".urldecode($xml_cdr->variables->end_stamp)."',".$xml_cdr->variables->billmsec.",".$xml_cdr->variables->answermsec.",".$xml_cdr->variables->waitmsec.",".$xml_cdr->variables->progress_mediamsec.",".$xml_cdr->variables->flow_billmsec; |
|
102 | + $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".$xml_cdr->variables->entity_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->carrier_id."','".$xml_cdr->callflow[0]->caller_profile->originatee->originatee_caller_profile->network_addr."','".$xml_cdr->variables->sip_contact_host."','".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",'".$xml_cdr->variables->vendor_id."',".$vendor_cost.",".$rates_array['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array['code']."','".$rates_array['destination']."','".$rates_array['cost']."','".$parent_id."','".@$parent_rates['code']."','".@$parent_rates['destination']."','".@$parent_rates['cost']."','".@$carrier_rates_array['code']."','".@$carrier_rates_array['destination']."','".@$carrier_rates_array['cost']."','".$xml_cdr->variables->call_direction."','".urldecode($xml_cdr->variables->profile_start_stamp)."','".urldecode($xml_cdr->variables->answer_stamp)."','".urldecode($xml_cdr->variables->bridge_stamp)."','".urldecode($xml_cdr->variables->progress_stamp)."','".urldecode($xml_cdr->variables->progress_media_stamp)."','".urldecode($xml_cdr->variables->end_stamp)."',".$xml_cdr->variables->billmsec.",".$xml_cdr->variables->answermsec.",".$xml_cdr->variables->waitmsec.",".$xml_cdr->variables->progress_mediamsec.",".$xml_cdr->variables->flow_billmsec; |
|
103 | 103 | |
104 | - $query = "INSERT INTO tbl_cdrs (uniqueid,user_id,entity_id,callerid_name,callerid_number,dstnum,duration,carrier_id,carrierip,callerip,disposition,start_stamp,debit,cost,vendor_id,vendor_cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,carrier_code,carrier_code_destination ,carrier_cost,call_direction,profile_start_stamp,answer_stamp,bridge_stamp,progress_stamp,progress_media_stamp,end_stamp,billmsec,answermsec,waitmsec,progress_mediamsec,flow_billmsec) values ($query_string)"; |
|
104 | + $query = "INSERT INTO tbl_cdrs (uniqueid,user_id,entity_id,callerid_name,callerid_number,dstnum,duration,carrier_id,carrierip,callerip,disposition,start_stamp,debit,cost,vendor_id,vendor_cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,carrier_code,carrier_code_destination ,carrier_cost,call_direction,profile_start_stamp,answer_stamp,bridge_stamp,progress_stamp,progress_media_stamp,end_stamp,billmsec,answermsec,waitmsec,progress_mediamsec,flow_billmsec) values ($query_string)"; |
|
105 | 105 | |
106 | - $logger->log("CDR Query : ".$query); |
|
107 | - $db->run($query); |
|
106 | + $logger->log("CDR Query : ".$query); |
|
107 | + $db->run($query); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | //Process reseller cdr |
111 | 111 | function do_reseller_cdr_process($xml_cdr, $debit, $cost, $rates_array, $parent_id = 0, $parent_rates, $logger, $db) { |
112 | - $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",".$rates_array['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array['code']."','".$rates_array['destination']."','".$rates_array['cost']."','".$parent_id."','".@$parent_rates['code']."','".@$parent_rates['destination']."','".@$parent_rates['cost']."','".$xml_cdr->variables->call_direction."'"; |
|
112 | + $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",".$rates_array['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array['code']."','".$rates_array['destination']."','".$rates_array['cost']."','".$parent_id."','".@$parent_rates['code']."','".@$parent_rates['destination']."','".@$parent_rates['cost']."','".$xml_cdr->variables->call_direction."'"; |
|
113 | 113 | |
114 | - $query = "INSERT INTO tbl_cdrs_reseller (uniqueid,reseller_id,callerid_name,callerid_number,dstnum,duration,disposition,start_stamp,debit,cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,call_direction) values ($query_string)"; |
|
114 | + $query = "INSERT INTO tbl_cdrs_reseller (uniqueid,reseller_id,callerid_name,callerid_number,dstnum,duration,disposition,start_stamp,debit,cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,call_direction) values ($query_string)"; |
|
115 | 115 | |
116 | - $logger->log("CDR Query : ".$query); |
|
117 | - $db->run($query); |
|
116 | + $logger->log("CDR Query : ".$query); |
|
117 | + $db->run($query); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | //Update user balance |
@@ -122,19 +122,19 @@ discard block |
||
122 | 122 | * @param integer $entity_id |
123 | 123 | */ |
124 | 124 | function update_balance($user_id, $amount, $entity_id, $logger, $db) { |
125 | - if ($amount > 0) { |
|
126 | - $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+'; |
|
127 | - $query = "UPDATE tbl_users SET credit=credit$math_sign".$amount." WHERE id=".$user_id; |
|
128 | - $logger->log("Balance update : ".$query); |
|
129 | - $db->run($query); |
|
130 | - } |
|
125 | + if ($amount > 0) { |
|
126 | + $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+'; |
|
127 | + $query = "UPDATE tbl_users SET credit=credit$math_sign".$amount." WHERE id=".$user_id; |
|
128 | + $logger->log("Balance update : ".$query); |
|
129 | + $db->run($query); |
|
130 | + } |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | //Get user info |
134 | 134 | function get_user_info($parent_id, $db) { |
135 | - $query = "SELECT * FROM tbl_users WHERE id=".$parent_id; |
|
136 | - $res_user = $db->run($query); |
|
137 | - return $res_user[0]; |
|
135 | + $query = "SELECT * FROM tbl_users WHERE id=".$parent_id; |
|
136 | + $res_user = $db->run($query); |
|
137 | + return $res_user[0]; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | ?> |
@@ -23,61 +23,61 @@ |
||
23 | 23 | |
24 | 24 | class db extends PDO { |
25 | 25 | |
26 | - private $error; |
|
27 | - private $sql; |
|
28 | - private $bind; |
|
29 | - private $errorCallbackFunction; |
|
30 | - private $errorMsgFormat; |
|
26 | + private $error; |
|
27 | + private $sql; |
|
28 | + private $bind; |
|
29 | + private $errorCallbackFunction; |
|
30 | + private $errorMsgFormat; |
|
31 | 31 | |
32 | - public function __construct($dsn = "", $user = "", $passwd = "") { |
|
32 | + public function __construct($dsn = "", $user = "", $passwd = "") { |
|
33 | 33 | |
34 | - $config = parse_ini_file("/var/lib/astpp/astpp-config.conf"); |
|
34 | + $config = parse_ini_file("/var/lib/astpp/astpp-config.conf"); |
|
35 | 35 | |
36 | - $options = array( |
|
37 | - PDO::ATTR_PERSISTENT => true, |
|
38 | - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION |
|
39 | - ); |
|
36 | + $options = array( |
|
37 | + PDO::ATTR_PERSISTENT => true, |
|
38 | + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION |
|
39 | + ); |
|
40 | 40 | |
41 | - try { |
|
42 | - parent::__construct("mysql:host=".$config['dbhost'].";dbname=".$config['dbname']."", $config['dbuser'], $config['dbpass'], $options); |
|
43 | - } catch (PDOException $e) { |
|
41 | + try { |
|
42 | + parent::__construct("mysql:host=".$config['dbhost'].";dbname=".$config['dbname']."", $config['dbuser'], $config['dbpass'], $options); |
|
43 | + } catch (PDOException $e) { |
|
44 | 44 | |
45 | - $this->error = $e->getMessage(); |
|
46 | - } |
|
47 | - echo $this->error; |
|
48 | - } |
|
45 | + $this->error = $e->getMessage(); |
|
46 | + } |
|
47 | + echo $this->error; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param string $bind |
|
52 | - */ |
|
53 | - public function cleanup($bind) { |
|
54 | - if ( ! is_array($bind)) { |
|
55 | - if ( ! empty($bind)) |
|
56 | - $bind = array($bind); |
|
57 | - else |
|
58 | - $bind = array(); |
|
59 | - } |
|
60 | - return $bind; |
|
61 | - } |
|
50 | + /** |
|
51 | + * @param string $bind |
|
52 | + */ |
|
53 | + public function cleanup($bind) { |
|
54 | + if ( ! is_array($bind)) { |
|
55 | + if ( ! empty($bind)) |
|
56 | + $bind = array($bind); |
|
57 | + else |
|
58 | + $bind = array(); |
|
59 | + } |
|
60 | + return $bind; |
|
61 | + } |
|
62 | 62 | |
63 | - public function run($sql, $bind = "") { |
|
64 | - $this->sql = trim($sql); |
|
65 | - $this->bind = $this->cleanup($bind); |
|
66 | - $this->error = ""; |
|
63 | + public function run($sql, $bind = "") { |
|
64 | + $this->sql = trim($sql); |
|
65 | + $this->bind = $this->cleanup($bind); |
|
66 | + $this->error = ""; |
|
67 | 67 | |
68 | - try { |
|
69 | - $pdostmt = $this->prepare($this->sql); |
|
70 | - if ($pdostmt->execute($this->bind) !== false) { |
|
71 | - if (preg_match("/^(".implode("|", array("select", "describe", "pragma")).") /i", $this->sql)) |
|
72 | - return $pdostmt->fetchAll(PDO::FETCH_ASSOC); |
|
73 | - elseif (preg_match("/^(".implode("|", array("delete", "insert", "update")).") /i", $this->sql)) |
|
74 | - return $pdostmt->rowCount(); |
|
75 | - } |
|
76 | - } catch (PDOException $e) { |
|
77 | - $this->error = $e->getMessage(); |
|
78 | - return $this->error; |
|
79 | - } |
|
80 | - } |
|
68 | + try { |
|
69 | + $pdostmt = $this->prepare($this->sql); |
|
70 | + if ($pdostmt->execute($this->bind) !== false) { |
|
71 | + if (preg_match("/^(".implode("|", array("select", "describe", "pragma")).") /i", $this->sql)) |
|
72 | + return $pdostmt->fetchAll(PDO::FETCH_ASSOC); |
|
73 | + elseif (preg_match("/^(".implode("|", array("delete", "insert", "update")).") /i", $this->sql)) |
|
74 | + return $pdostmt->rowCount(); |
|
75 | + } |
|
76 | + } catch (PDOException $e) { |
|
77 | + $this->error = $e->getMessage(); |
|
78 | + return $this->error; |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | 82 | } |
83 | 83 |
@@ -52,10 +52,11 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function cleanup($bind) { |
54 | 54 | if ( ! is_array($bind)) { |
55 | - if ( ! empty($bind)) |
|
56 | - $bind = array($bind); |
|
57 | - else |
|
58 | - $bind = array(); |
|
55 | + if ( ! empty($bind)) { |
|
56 | + $bind = array($bind); |
|
57 | + } else { |
|
58 | + $bind = array(); |
|
59 | + } |
|
59 | 60 | } |
60 | 61 | return $bind; |
61 | 62 | } |
@@ -68,10 +69,11 @@ discard block |
||
68 | 69 | try { |
69 | 70 | $pdostmt = $this->prepare($this->sql); |
70 | 71 | if ($pdostmt->execute($this->bind) !== false) { |
71 | - if (preg_match("/^(".implode("|", array("select", "describe", "pragma")).") /i", $this->sql)) |
|
72 | - return $pdostmt->fetchAll(PDO::FETCH_ASSOC); |
|
73 | - elseif (preg_match("/^(".implode("|", array("delete", "insert", "update")).") /i", $this->sql)) |
|
74 | - return $pdostmt->rowCount(); |
|
72 | + if (preg_match("/^(".implode("|", array("select", "describe", "pragma")).") /i", $this->sql)) { |
|
73 | + return $pdostmt->fetchAll(PDO::FETCH_ASSOC); |
|
74 | + } elseif (preg_match("/^(".implode("|", array("delete", "insert", "update")).") /i", $this->sql)) { |
|
75 | + return $pdostmt->rowCount(); |
|
76 | + } |
|
75 | 77 | } |
76 | 78 | } catch (PDOException $e) { |
77 | 79 | $this->error = $e->getMessage(); |
@@ -154,8 +154,9 @@ |
||
154 | 154 | |
155 | 155 | $sp_gw_settings = json_decode($sp_gw_value['gateway_data'], true); |
156 | 156 | foreach ($sp_gw_settings as $sp_gw_settings_key => $sp_gw_settings_value) { |
157 | - if ($sp_gw_settings_value != "") |
|
158 | - $xml .= " <param name=\"" . $sp_gw_settings_key . "\" value=\"" . $sp_gw_settings_value . "\"/>\n"; |
|
157 | + if ($sp_gw_settings_value != "") { |
|
158 | + $xml .= " <param name=\"" . $sp_gw_settings_key . "\" value=\"" . $sp_gw_settings_value . "\"/>\n"; |
|
159 | + } |
|
159 | 160 | } |
160 | 161 | $xml .= " </gateway>\n"; |
161 | 162 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | //Build acl xml |
39 | -function load_acl($logger, $db,$config) { |
|
39 | +function load_acl($logger, $db, $config) { |
|
40 | 40 | $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; |
41 | 41 | $xml .= "<document type=\"freeswitch/xml\">\n"; |
42 | 42 | $xml .= " <section name=\"Configuration\" description=\"Configuration\">\n"; |
@@ -46,29 +46,29 @@ discard block |
||
46 | 46 | |
47 | 47 | //For customer and provider ips |
48 | 48 | $query = "SELECT ip FROM ip_map,accounts WHERE ip_map.accountid=accounts.id AND accounts.status=0 AND deleted=0"; |
49 | - $logger->log("ACL Query : " . $query); |
|
49 | + $logger->log("ACL Query : ".$query); |
|
50 | 50 | $res_acl = $db->run($query); |
51 | 51 | $logger->log($res_acl); |
52 | 52 | |
53 | 53 | foreach ($res_acl as $res_acl_key => $res_acl_value) { |
54 | - $xml .= " <node type=\"allow\" cidr=\"" . $res_acl_value['ip'] . "\"/>\n"; |
|
54 | + $xml .= " <node type=\"allow\" cidr=\"".$res_acl_value['ip']."\"/>\n"; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | //For gateways |
58 | 58 | $query = "SELECT * FROM gateways WHERE status=0"; |
59 | - $logger->log("Sofia Gateway Query : " . $query); |
|
59 | + $logger->log("Sofia Gateway Query : ".$query); |
|
60 | 60 | $sp_gw = $db->run($query); |
61 | 61 | $logger->log($sp_gw); |
62 | 62 | |
63 | 63 | foreach ($sp_gw as $sp_gw_key => $sp_gw_value) { |
64 | 64 | |
65 | - $sp_gw_settings = json_decode($sp_gw_value['gateway_data'], true); |
|
65 | + $sp_gw_settings = json_decode($sp_gw_value['gateway_data'], true); |
|
66 | 66 | foreach ($sp_gw_settings as $sp_gw_settings_key => $sp_gw_settings_value) { |
67 | 67 | if ($sp_gw_settings_value != "" && $sp_gw_settings_key == "proxy") |
68 | 68 | { |
69 | - $tmp_ip_arr = explode(":",$sp_gw_settings_value); |
|
70 | - if (!filter_var($tmp_ip_arr[0], FILTER_VALIDATE_IP) === false) { |
|
71 | - $xml .= " <node type=\"allow\" cidr=\"" . $tmp_ip_arr[0] . "/32\"/>\n"; |
|
69 | + $tmp_ip_arr = explode(":", $sp_gw_settings_value); |
|
70 | + if ( ! filter_var($tmp_ip_arr[0], FILTER_VALIDATE_IP) === false) { |
|
71 | + $xml .= " <node type=\"allow\" cidr=\"".$tmp_ip_arr[0]."/32\"/>\n"; |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | |
79 | 79 | //For opensips |
80 | - if($config['opensips'] == '0') |
|
80 | + if ($config['opensips'] == '0') |
|
81 | 81 | { |
82 | 82 | $xml .= "<node type=\"allow\" cidr=\"".$config['opensips_domain']."/32\"/>\n"; |
83 | 83 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $xml .= " </list>\n"; |
86 | 86 | |
87 | 87 | //For loopback |
88 | - if($config['opensips'] == '0') |
|
88 | + if ($config['opensips'] == '0') |
|
89 | 89 | { |
90 | 90 | $xml .= "<list name=\"loopback.auto\" default=\"allow\">\n"; |
91 | 91 | $xml .= "<node type=\"allow\" cidr=\"".$config['opensips_domain']."/32\"/>\n"; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | //For event handing |
96 | 96 | $xml .= "<list name=\"event\" default=\"deny\">\n"; |
97 | - $xml .= ($config['opensips'] == "0")?"<node type=\"allow\" cidr=\"".$config['opensips_domain']."/32\"/>\n":"\n"; |
|
97 | + $xml .= ($config['opensips'] == "0") ? "<node type=\"allow\" cidr=\"".$config['opensips_domain']."/32\"/>\n" : "\n"; |
|
98 | 98 | $xml .= "<node type=\"allow\" cidr=\"127.0.0.0/8\"/>\n"; |
99 | 99 | $xml .= "</list>\n"; |
100 | 100 | $xml .= " </network-lists>\n"; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $xml .= " <profiles>\n"; |
115 | 115 | |
116 | 116 | $query = "SELECT * FROM sip_profiles WHERE status=0"; |
117 | - $logger->log("Sofia Query : " . $query); |
|
117 | + $logger->log("Sofia Query : ".$query); |
|
118 | 118 | $res_sp = $db->run($query); |
119 | 119 | //$logger->log($res_sp); |
120 | 120 | |
@@ -122,40 +122,40 @@ discard block |
||
122 | 122 | |
123 | 123 | $settings = json_decode($sp_value['profile_data'], true); |
124 | 124 | //$logger->log(print_r($settings,true)); |
125 | - $xml .= " <profile name=\"" . $sp_value['name'] . "\">\n"; |
|
125 | + $xml .= " <profile name=\"".$sp_value['name']."\">\n"; |
|
126 | 126 | |
127 | 127 | $xml .= " <domains>\n"; |
128 | - $xml .= " <domain name=\"" . $sp_value['sip_ip'] . "\" alias=\"true\" parse=\"true\"/>\n"; |
|
128 | + $xml .= " <domain name=\"".$sp_value['sip_ip']."\" alias=\"true\" parse=\"true\"/>\n"; |
|
129 | 129 | $xml .= " </domains>\n"; |
130 | 130 | /*$xml .= " <aliases>\n"; |
131 | 131 | $xml .= " <alias name=\"" . $sp_value['sip_ip'] . "\"/>\n"; |
132 | 132 | $xml .= " </aliases>\n";*/ |
133 | 133 | |
134 | 134 | $xml .= " <settings>\n"; |
135 | - $xml .= " <param name=\"sip-ip\" value=\"" . $sp_value['sip_ip'] . "\"/>\n"; |
|
136 | - $xml .= " <param name=\"sip-port\" value=\"" . $sp_value['sip_port'] . "\"/>\n"; |
|
137 | - foreach($settings as $set_key => $set_val) |
|
135 | + $xml .= " <param name=\"sip-ip\" value=\"".$sp_value['sip_ip']."\"/>\n"; |
|
136 | + $xml .= " <param name=\"sip-port\" value=\"".$sp_value['sip_port']."\"/>\n"; |
|
137 | + foreach ($settings as $set_key => $set_val) |
|
138 | 138 | { |
139 | - $xml .= " <param name=\"" . $set_key . "\" value=\"" . $set_val . "\"/>\n"; |
|
139 | + $xml .= " <param name=\"".$set_key."\" value=\"".$set_val."\"/>\n"; |
|
140 | 140 | } |
141 | 141 | $xml .= " </settings>\n"; |
142 | 142 | |
143 | 143 | |
144 | 144 | //Gateway block start |
145 | 145 | $xml .= " <gateways>\n"; |
146 | - $query = "SELECT * FROM gateways WHERE sip_profile_id=" . $sp_value['id'] . " AND status=0"; |
|
147 | - $logger->log("Sofia Gateway Query : " . $query); |
|
146 | + $query = "SELECT * FROM gateways WHERE sip_profile_id=".$sp_value['id']." AND status=0"; |
|
147 | + $logger->log("Sofia Gateway Query : ".$query); |
|
148 | 148 | $sp_gw = $db->run($query); |
149 | 149 | $logger->log($sp_gw); |
150 | 150 | foreach ($sp_gw as $sp_gw_key => $sp_gw_value) { |
151 | - $xml .= " <gateway name=\"" . $sp_gw_value['name'] . "\">\n"; |
|
151 | + $xml .= " <gateway name=\"".$sp_gw_value['name']."\">\n"; |
|
152 | 152 | |
153 | 153 | |
154 | 154 | |
155 | - $sp_gw_settings = json_decode($sp_gw_value['gateway_data'], true); |
|
155 | + $sp_gw_settings = json_decode($sp_gw_value['gateway_data'], true); |
|
156 | 156 | foreach ($sp_gw_settings as $sp_gw_settings_key => $sp_gw_settings_value) { |
157 | 157 | if ($sp_gw_settings_value != "") |
158 | - $xml .= " <param name=\"" . $sp_gw_settings_key . "\" value=\"" . $sp_gw_settings_value . "\"/>\n"; |
|
158 | + $xml .= " <param name=\"".$sp_gw_settings_key."\" value=\"".$sp_gw_settings_value."\"/>\n"; |
|
159 | 159 | } |
160 | 160 | $xml .= " </gateway>\n"; |
161 | 161 | } |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | function load_directory($logger, $db) { |
178 | 178 | $xml = ""; |
179 | 179 | |
180 | - $query = "SELECT username,dir_params,dir_vars,number as accountcode,accountid FROM sip_devices,accounts WHERE sip_devices.status=0 AND accounts.status=0 AND accounts.deleted=0 AND accounts.id=sip_devices.accountid AND username='" . $_REQUEST['user']."' limit 1"; |
|
180 | + $query = "SELECT username,dir_params,dir_vars,number as accountcode,accountid FROM sip_devices,accounts WHERE sip_devices.status=0 AND accounts.status=0 AND accounts.deleted=0 AND accounts.id=sip_devices.accountid AND username='".$_REQUEST['user']."' limit 1"; |
|
181 | 181 | |
182 | - $logger->log("Directory Query : " . $query); |
|
182 | + $logger->log("Directory Query : ".$query); |
|
183 | 183 | $res_dir = $db->run($query); |
184 | 184 | $logger->log($res_dir); |
185 | 185 | |
@@ -187,21 +187,21 @@ discard block |
||
187 | 187 | $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; |
188 | 188 | $xml .= "<document type=\"freeswitch/xml\">\n"; |
189 | 189 | $xml .= " <section name=\"Directory\" description=\"Directory\">\n"; |
190 | - $xml .= " <domain name=\"" . $_REQUEST['domain'] . "\" alias=\"true\">\n"; |
|
191 | - $xml .= " <user id=\"" . $_REQUEST['user'] . "\">\n"; |
|
190 | + $xml .= " <domain name=\"".$_REQUEST['domain']."\" alias=\"true\">\n"; |
|
191 | + $xml .= " <user id=\"".$_REQUEST['user']."\">\n"; |
|
192 | 192 | |
193 | 193 | $params = json_decode($res_dir_value['dir_params'], true); |
194 | 194 | |
195 | 195 | $vars = json_decode($res_dir_value['dir_vars'], true); |
196 | 196 | $param_xml = $var_xml = ""; |
197 | - foreach($params as $parms_key => $res_dir_params) |
|
197 | + foreach ($params as $parms_key => $res_dir_params) |
|
198 | 198 | { |
199 | - $param_xml .= "<param name=\"" . $parms_key . "\" value=\"" . $res_dir_params . "\"/>\n"; |
|
199 | + $param_xml .= "<param name=\"".$parms_key."\" value=\"".$res_dir_params."\"/>\n"; |
|
200 | 200 | } |
201 | 201 | |
202 | - foreach($vars as $var_key => $res_dir_vars) |
|
202 | + foreach ($vars as $var_key => $res_dir_vars) |
|
203 | 203 | { |
204 | - $var_xml .= "<variable name=\"" . $var_key . "\" value=\"" . $res_dir_vars . "\"/>\n"; |
|
204 | + $var_xml .= "<variable name=\"".$var_key."\" value=\"".$res_dir_vars."\"/>\n"; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | $xml .= " <variables>\n"; |
215 | 215 | $xml .= $var_xml; |
216 | 216 | $xml .= "<variable name=\"sipcall\" value=\"true\"/>\n"; |
217 | - $xml .= "<variable name=\"accountcode\" value=\"" . $res_dir_value['accountcode'] . "\"/>\n"; |
|
218 | - $xml .= "<variable name=\"domain_name\" value=\"" . $_REQUEST['domain'] . "\"/>\n"; |
|
217 | + $xml .= "<variable name=\"accountcode\" value=\"".$res_dir_value['accountcode']."\"/>\n"; |
|
218 | + $xml .= "<variable name=\"domain_name\" value=\"".$_REQUEST['domain']."\"/>\n"; |
|
219 | 219 | $xml .= " </variables>\n"; |
220 | 220 | |
221 | 221 | $xml .= " </user>\n"; |
@@ -30,15 +30,15 @@ |
||
30 | 30 | $this->config = $lib->config; |
31 | 31 | $this->config['log_path'] = "/var/log/astpp/"; |
32 | 32 | if ($this->config['debug'] == '0') |
33 | - $this->fp = fopen($this->config['log_path'] . 'astpp_' . date('Y-m-d') . '.txt', 'a'); |
|
33 | + $this->fp = fopen($this->config['log_path'].'astpp_'.date('Y-m-d').'.txt', 'a'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | function log($log) { |
37 | 37 | if ($this->config['debug'] == '0') { |
38 | 38 | if (is_array($log)) |
39 | - fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . print_r($log, TRUE)); |
|
39 | + fwrite($this->fp, "[".date('Y-m-d H:i:s')."] ".print_r($log, TRUE)); |
|
40 | 40 | else |
41 | - fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . $log . "\n"); |
|
41 | + fwrite($this->fp, "[".date('Y-m-d H:i:s')."] ".$log."\n"); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 |
@@ -29,22 +29,25 @@ |
||
29 | 29 | function logger($lib) { |
30 | 30 | $this->config = $lib->config; |
31 | 31 | $this->config['log_path'] = "/var/log/astpp/"; |
32 | - if ($this->config['debug'] == '0') |
|
33 | - $this->fp = fopen($this->config['log_path'] . 'astpp_' . date('Y-m-d') . '.txt', 'a'); |
|
32 | + if ($this->config['debug'] == '0') { |
|
33 | + $this->fp = fopen($this->config['log_path'] . 'astpp_' . date('Y-m-d') . '.txt', 'a'); |
|
34 | + } |
|
34 | 35 | } |
35 | 36 | |
36 | 37 | function log($log) { |
37 | 38 | if ($this->config['debug'] == '0') { |
38 | - if (is_array($log)) |
|
39 | - fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . print_r($log, TRUE)); |
|
40 | - else |
|
41 | - fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . $log . "\n"); |
|
39 | + if (is_array($log)) { |
|
40 | + fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . print_r($log, TRUE)); |
|
41 | + } else { |
|
42 | + fwrite($this->fp, "[" . date('Y-m-d H:i:s') . "] " . $log . "\n"); |
|
43 | + } |
|
42 | 44 | } |
43 | 45 | } |
44 | 46 | |
45 | 47 | function close() { |
46 | - if ($this->config['debug'] == '0') |
|
47 | - fclose($this->fp); |
|
48 | + if ($this->config['debug'] == '0') { |
|
49 | + fclose($this->fp); |
|
50 | + } |
|
48 | 51 | } |
49 | 52 | |
50 | 53 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | header('Content-Type: text/xml'); |
30 | 30 | echo $xml; |
31 | 31 | } elseif ($_REQUEST['key_value'] == 'acl.conf') { |
32 | - $xml = load_acl($logger, $db,$config); |
|
32 | + $xml = load_acl($logger, $db, $config); |
|
33 | 33 | header('Content-Type: text/xml'); |
34 | 34 | echo $xml; |
35 | 35 | } else { |