function _validate_ip_addr($ipaddr) { $ipaddr = trim($ipaddr); if (!preg_match('/^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/', $ipaddr, $m)) { return false; } for ($i = 1; $i <= 4; ++$i) { $m[$i] = (int) lTrim($m[$i], '0'); if ($m[$i] > 255) { return false; } } $ipaddr = $m[1] . '.' . $m[2] . '.' . $m[3] . '.' . $m[4]; if (in_array(@ip2long($ipaddr), array(false, null, -1, 0), true)) { return false; } return $ipaddr; }
} else { gs_log(GS_LOG_NOTICE, "IP {$remote_ip} is not in GS_CALL_INIT_FROM_NET => not allowed to init call"); die_not_allowed('You are not allowed to init a call.'); } ##################################################################### # user ##################################################################### if (!isset($_REQUEST['user'])) { gs_log(GS_LOG_NOTICE, 'No user code specified. Use user='******'No user code specified. Use user='******'user']); if (gs_get_conf('GS_LVM_USER_6_DIGIT_INT')) { # hack to compare user names as if they were integers # padded to 6 digits $user_code = lTrim($user_code, '0'); if (strLen($user_code) < 6) { $user_code = str_pad($user_code, 6, '0', STR_PAD_LEFT); } } $user = @gs_user_get($user_code); if (isGsError($user)) { gs_log(GS_LOG_NOTICE, $user->getMsg()); die_invalid($user->getMsg()); } if ($user['nobody_index'] > 0) { gs_log(GS_LOG_NOTICE, 'Nobody user. Not allowed to init a call.'); die_not_allowed('Nobody user. Not allowed to init a call.'); } $db = gs_db_master_connect(); if (!$db) {
function widget($args, $instance) { extract($args); /* ------------------------------------ :: WIDGET VARIABLES ------------------------------------ */ // Option Keys $keys = array('width', 'height', 'gallery_height', 'imgheight', 'imgwidth', 'img_align', 'timeout', 'orderby', 'sortby', 'tween', 'animation', 'animation_type', 'title', 'excerpt', 'datasource', 'attachedmedia', 'pagepost_id', 'gallerycats', 'gallerypostformat', 'flickr_set', 'slidesetid', 'productcats', 'producttags', 'mediacats'); foreach ($keys as $key) { if (empty($instance[$key])) { $instance[$key] = ''; } } $title = apply_filters('widget_title', $instance['title']); if (!$instance['width']) { $NV_imgwidth = '290'; } else { $NV_imgwidth = $instance['width']; } if (!$instance['height']) { $NV_imgheight = '170'; } else { $NV_imgheight = $instance['height']; } if (!$instance['gallery_height']) { $NV_galleryheight = '200'; } else { $NV_galleryheight = $instance['gallery_height']; } $NV_galleryheight = 'height="' . $NV_galleryheight . '"'; $NV_imgheight = 'imgheight="' . $NV_imgheight . '"'; $NV_imgwidth = 'imgwidth="' . $NV_imgwidth . '"'; if ($instance['excerpt']) { $excerpt = 'excerpt="' . $instance['excerpt'] . '"'; } else { $excerpt = ''; } if ($instance['img_align']) { $image_align = 'image_align="' . $instance['img_align'] . '"'; } else { $image_align = ''; } $timeout = $instance['timeout'] != '' ? 'timeout="' . $instance['timeout'] . '"' : 'timeout="10"'; if ($instance['orderby']) { $orderby = 'orderby="' . $instance['orderby'] . '"'; } else { $orderby = ''; } if ($instance['sortby']) { $sortby = 'sortby="' . $instance['sortby'] . '"'; } else { $sortby = ''; } $tween = 'tween="' . $instance['tween_type'] . '"'; $animation = 'animation="' . $instance['animation_type'] . '"'; /* ------------------------------------ :: DISPLAY WIDGET ------------------------------------ */ echo "<li class=\"widget sidebar-slider\">"; /* Display the widget title if one was input (before and after defined by themes). */ if (isset($title)) { echo $before_title . $title . $after_title; } $chars = array("[", "]", "-"); global $NV_is_widget; $NV_is_widget = true; $galid = str_replace($chars, "", $this->get_field_name('id')); if ($instance['datasource'] == $this->get_field_id('data-1')) { $NV_datasource = 'attached_id="' . $instance['attachedmedia'] . '"'; } elseif ($instance['datasource'] == $this->get_field_id('data-2') || $instance['gallerycats'] != '') { if ($instance['gallerycats'] != '') { $string = ''; foreach ($instance['gallerycats'] as $value) { $string = $string . $value . ","; } $cats = lTrim($string, ','); $NV_datasource = 'categories="' . $cats . '"'; } if ($instance['gallerypostformat'] != '') { $NV_datasource .= $NV_datasource . ' post_format="' . $instance['gallerypostformat'] . '"'; } } elseif ($instance['datasource'] == $this->get_field_id('data-3')) { $NV_datasource = 'flickr_set="' . $instance['flickrset'] . '"'; } elseif ($instance['datasource'] == $this->get_field_id('data-4') || $instance['slidesetid'] != '') { $string = ''; foreach ($instance['slidesetid'] as $value) { $string = $string . $value . ","; } $slidesets = lTrim($string, ','); $NV_datasource = 'slidesetid="' . $slidesets . '"'; } elseif ($instance['datasource'] == $this->get_field_id('data-5')) { if ($instance['productcats']) { foreach ($instance['productcats'] as $value) { $string = $string . $value . ","; } $pcats = lTrim($string, ','); $NV_datasource = 'product_categories="' . $pcats . '"'; } if ($instance['producttags']) { foreach ($instance['producttags'] as $value) { $string = $string . $value . ","; } $ptags = lTrim($string, ','); $NV_datasource .= 'product_tags="' . $ptags . '"'; } } elseif ($instance['datasource'] == $this->get_field_id('data-6')) { foreach ($instance['mediacats'] as $value) { $string = $string . $value . ","; } $mediacats = lTrim($string, ','); $NV_datasource = 'media_categories="' . $mediacats . '"'; } elseif ($instance['datasource'] == $this->get_field_id('data-8')) { $NV_datasource = 'pagepost_id="' . $instance['pagepost_id'] . '"'; } $content_type = $instance['content_type'] != '' ? $instance['content_type'] : 'image'; echo do_shortcode('[postgallery_slider content="' . $content_type . '" ' . $NV_datasource . ' columns="1" id="' . $galid . '" imageeffect="' . $instance['img_effect'] . '" ' . $NV_galleryheight . ' ' . $NV_imgwidth . ' ' . $NV_imgheight . ' ' . $timeout . ' ' . $excerpt . ' ' . $orderby . ' ' . $sortby . ' ' . $tween . ' ' . $animation . ' ' . $image_align . ' width="290" align="center"/]'); echo "</li>"; }
{ if ($val > $max) { $val = $max; } if ($val < $min) { $val = $min; } } $action = @$_REQUEST['action']; if ($action === 'report') { $fr_y = abs((int) lTrim(@$_REQUEST['fr_y'], '0')); $fr_m = abs((int) lTrim(@$_REQUEST['fr_m'], '0')); $fr_d = abs((int) lTrim(@$_REQUEST['fr_d'], '0')); $to_y = abs((int) lTrim(@$_REQUEST['to_y'], '0')); $to_m = abs((int) lTrim(@$_REQUEST['to_m'], '0')); $to_d = abs((int) lTrim(@$_REQUEST['to_d'], '0')); _check_range($fr_y, 1980, 2030); _check_range($to_y, 1980, 2030); _check_range($fr_m, 1, 12); _check_range($to_m, 1, 12); _check_range($fr_d, 1, (int) date('t', mkTime(12, 1, 1, $fr_m, 15, $fr_y))); _check_range($to_d, 1, (int) date('t', mkTime(12, 1, 1, $to_m, 15, $to_y))); } else { $action = ''; $now = time(); $default_to = $now; $default_fr = $now - 7 * 24 * 3600; $fr_y = (int) date('Y', $default_fr); $fr_m = (int) date('n', $default_fr); $fr_d = (int) date('j', $default_fr); $to_y = (int) date('Y', $default_to);
function _normalize_ip_addr($addr) { $addr = preg_replace('/[^0-9.]/', '', $addr); if ($addr == '') { return null; } $addr_parts = explode('.', $addr); $addr = ''; for ($i = 0; $i <= 3; ++$i) { $part = (int) lTrim(@$addr_parts[$i], '0 '); if ($part > 255) { $part = 255; } elseif ($part < 0) { $part = 0; } $addr .= $part; if ($i < 3) { $addr .= '.'; } } return $addr; }
/* $out = array( ' * Port 1 Type TE Prot. PMP L2Link DOWN L1Link:DOWN Blocked:0 Debug:0', ' * Port 2 Type TE Prot. PMP L2Link DOWN L1Link:DOWN Blocked:0 Debug:0', ' * Port 3 Type TE Prot. PMP L2Link DOWN L1Link:DOWN Blocked:0 Debug:0', ' * Port 4 Type TE Prot. PMP L2Link DOWN L1Link:DOWN Blocked:0 Debug:0' ); $err = 0; */ if ($err === 0) { foreach ($out as $line) { $line = strToLower($line); if (!preg_match('/ port[\\s:]*([0-9]+)/', $line, $m)) { continue; } $port = (int) lTrim($m[1], '0'); if (preg_match('/ type[\\s:]*(te|nt)/', $line, $m)) { $asterisk_misdn_ports[$port]['type'] = strToLower($m[1]); } else { $asterisk_misdn_ports[$port]['type'] = null; } if (preg_match('/ prot\\.[\\s:]*(ptp|pmp)/', $line, $m)) { $asterisk_misdn_ports[$port]['protocol'] = strToLower($m[1]); if ($asterisk_misdn_ports[$port]['protocol'] === 'pmp') { $asterisk_misdn_ports[$port]['protocol'] = 'ptmp'; } } else { $asterisk_misdn_ports[$port]['protocol'] = null; } if (preg_match('/ l1link[\\s:]*(down|up)/', $line, $m)) { $asterisk_misdn_ports[$port]['l1link'] = strToLower($m[1]);
if ($GS_Softkeys->retrieve_keys($phone_type, array('{GS_PROV_HOST}' => gs_get_conf('GS_PROV_HOST'), '{GS_P_PBX}' => $pbx, '{GS_P_EXTEN}' => $user_ext, '{GS_P_ROUTE_PREFIX}' => $hp_route_prefix, '{GS_P_USER}' => $user['user']))) { $softkeys = $GS_Softkeys->get_keys(); } } if (!is_array($softkeys)) { gs_log(GS_LOG_WARNING, 'Failed to get softkeys'); } else { foreach ($softkeys as $key_name => $key_defs) { if (array_key_exists('slf', $key_defs)) { $key_def = $key_defs['slf']; } elseif (array_key_exists('inh', $key_defs)) { $key_def = $key_defs['inh']; } else { continue; } $key_idx = (int) lTrim(subStr($key_name, 1), '0'); if ($key_idx > $max_key - 1) { continue; } if ($key_def['function'] === 'empty') { continue; } //setting('fkey', $key_idx, $key_def['function'] .' '. $key_def['data'], array('context'=>'active')); if ($key_idx < 7) { # gxp2000, gxp2010, gxp2020 psetting('P' . ($key_idx + 323), subStr($key_def['function'], 1)); //psetting('P'.($key_idx*3+301), '0'); //psetting('P'.($key_idx*3+302), ''); psetting('P' . ($key_idx * 3 + 303), $key_def['data']); } elseif ($key_idx >= 7) { # gxp2010
$mf = 59; } $mf = str_pad($mf, 2, '0', STR_PAD_LEFT); echo '<span class="nobr">'; echo '<input type="text" name="' . $route['id'] . '-r_h_from_h" value="', $hf, '" size="2" maxlength="2" class="r" />:'; echo '<input type="text" name="' . $route['id'] . '-r_h_from_m" value="', $mf, '" size="2" maxlength="2" class="r" /> -'; echo '</span> ', "\n"; $tmp = explode(':', $route['h_to']); $ht = (int) lTrim(@$tmp[0], '0-'); if ($ht < 0) { $ht = 0; } elseif ($ht > 24) { $ht = 24; } $ht = str_pad($ht, 2, '0', STR_PAD_LEFT); $mt = (int) lTrim(@$tmp[1], '0-'); if ($mt < 0) { $mt = 0; } elseif ($mt > 59) { $mt = 59; } $mt = str_pad($mt, 2, '0', STR_PAD_LEFT); if ($ht . ':' . $mt < $hf . ':' . $mf) { $ht = $hf; $hm = $mf; } echo '<span class="nobr">'; echo '<input type="text" name="' . $route['id'] . '-r_h_to_h" value="', $ht, '" size="2" maxlength="2" class="r" />:'; echo '<input type="text" name="' . $route['id'] . '-r_h_to_m" value="', $mt, '" size="2" maxlength="2" class="r" />'; echo '</span>'; echo '</td>', "\n";
function genDurationInWords($a) { $engStr = ''; $mStr = ''; $sStr = ''; $cnt = count($a); //hours if ($cnt == 3) { if ($a[0] != '') { $n = lTrim($a[0], '0'); if ($n == 1) { $engStr = $n . ' hour'; } else { if ($n != 0) { $engStr = $n . ' hours'; } } } } //minutes if ($cnt == 3) { $i = 1; } else { if ($cnt == 2) { $i = 0; } } if ($a[$i] != '') { $n = lTrim($a[$i], '0'); if ($n == 1) { $mStr = $n . ' minute'; } else { if ($n != 0) { $mStr = $n . ' minutes'; } } } //seconds if ($cnt == 3) { $i = 2; } else { if ($cnt == 2) { $i = 1; } else { $i = 0; } } if ($a[$i] != '') { $n = lTrim($a[$i], '0'); if ($n == 1) { $sStr = $n . ' second'; } else { if ($n != 0) { $sStr = $n . ' seconds'; } } } return $engStr . ' ' . $mStr . ' ' . $sStr; }
/** * @return boolean * @param string $className * @param string $namespace */ protected static function isNamespaceClass($className, $namespace) { return 0 === strPos(lTrim($className, NS), $namespace . NS); }
foreach ($m as $lease_def) { $ip_addr = $lease_def[1]; $lease = array('start' => null, 'end' => null, 'hwt' => null, 'mac' => null, 'name' => null, 'bstate' => 'active'); $lease_def = subStr($lease_def[0], 6 + strLen($ip_addr) + 1); $lm = array(); preg_match_all('/^\\s*([a-z\\-]+)\\s*([^;\\n$]*)/mS', $lease_def, $lm, PREG_SET_ORDER); foreach ($lm as $line_def) { switch ($line_def[1]) { case 'starts': if (preg_match('/^[0-6]\\s+([0-9]{4})\\/([0-9]{2})\\/([0-9]{2})\\s+([0-9]{2}):([0-9]{2}):([0-9]{2})/S', $line_def[2], $p)) { $lease['start'] = gmMkTime((int) lTrim($p[4], '0'), (int) lTrim($p[5], '0'), (int) lTrim($p[6], '0'), (int) lTrim($p[2], '0'), (int) lTrim($p[3], '0'), (int) lTrim($p[1], '0')); } break; case 'ends': if (preg_match('/^[0-6]\\s+([0-9]{4})\\/([0-9]{2})\\/([0-9]{2})\\s+([0-9]{2}):([0-9]{2}):([0-9]{2})/S', $line_def[2], $p)) { $lease['end'] = gmMkTime((int) lTrim($p[4], '0'), (int) lTrim($p[5], '0'), (int) lTrim($p[6], '0'), (int) lTrim($p[2], '0'), (int) lTrim($p[3], '0'), (int) lTrim($p[1], '0')); } elseif (preg_match('/^never/S', $line_def[2], $p)) { $lease['end'] = PHP_INT_MAX; } break; case 'hardware': if (preg_match('/^([a-z0-9\\-_]+)\\s+(([0-9a-zA-Z]{1,2}:?)+)/S', $line_def[2], $p)) { $lease['hwt'] = $p[1]; switch ($lease['hwt']) { case 'ethernet': $lease['hwt'] = 'en'; break; case 'unknown-0': $lease['hwt'] = 'u0'; break; case 'unknown-1':
continue; } $mac_addr = $m[0]; $devices[$mac_addr]['mac'] = $mac_addr; $devices[$mac_addr]['ip'] = $ip_addr_parts; } unset($out); kSort($devices); $c = 0; foreach ($devices as $mac_addr => $device) { echo '<tr class="', $c % 2 === 0 ? 'odd' : 'even', '" height="25">', "\n"; //echo '<td><code>', $device['mac'] ,'</code></td>' ,"\n"; echo '<td style="vertical-align:middle; padding-top:0.3em;"><small><code>', $device['mac'], '</code></small></td>', "\n"; echo '<td style="vertical-align:middle;">'; for ($i = 1; $i <= 4; ++$i) { $device['ip'][$i] = lTrim($device['ip'][$i], '0'); if ($device['ip'][$i] == '') { $device['ip'][$i] = '0'; } /* echo str_replace(' ', ' ', str_pad($device['ip'][$i], 3, ' ', STR_PAD_LEFT)); if ($i < 4) echo '.'; */ } $device['ip'][0] = $device['ip'][1] . '.' . $device['ip'][2] . '.' . $device['ip'][3] . '.' . $device['ip'][4]; echo $device['ip'][0]; echo '</td>', "\n"; $phone_type = mac_addr_to_phone_type($device['mac']); echo '<td style="vertical-align:middle;">', $phone_type['title'], '</td>', "\n"; $can_take_over = $phone_type['key'] != ''; /*
} if ($height < 50) { $height = 180; } $padt = 12; $padb = 22; $padl = 40; $padr = 14; $cw = $width - $padl - $padr; $ch = $height - $padt - $padb; $fr_y = (int) lTrim(@$_REQUEST['fy'], '0-'); $fr_m = (int) lTrim(@$_REQUEST['fm'], '0-'); $fr_d = (int) lTrim(@$_REQUEST['fd'], '0-'); $to_y = (int) lTrim(@$_REQUEST['ty'], '0-'); $to_m = (int) lTrim(@$_REQUEST['tm'], '0-'); $to_d = (int) lTrim(@$_REQUEST['td'], '0-'); $fr = mkTime(0, 0, 0, $fr_m, $fr_d, $fr_y); $to = mkTime(23, 59, 59, $to_m, $to_d, $to_y); if ($to < $fr) { $tmp = $fr; $fr = $to; $to = $tmp; } $time_range = $to - $fr; $time_range_days = $time_range / (60 * 60 * 24); if ($time_range_days <= 2) { $xtstr = '+1 hours'; $xdfmt = 'H'; } elseif ($time_range_days <= 31) { $xtstr = '+1 days'; $xdfmt = 'j';
$res[] = $rt; } asort($res); foreach ($res as $r) { echo '<tr class="', ++$i % 2 ? 'odd' : 'even', '">', "\n"; echo '<td class="r">', htmlEnt($r['target']), '</td>', "\n"; if ($edit == $r['target']) { echo '<td class="c">'; $hf = (int) lTrim(@$r['hour'], '0-'); if ($hf < 0) { $hf = 0; } elseif ($hf > 23) { $hf = 23; } $hf = str_pad($hf, 2, '0', STR_PAD_LEFT); $mf = (int) lTrim(@$r['minute'], '0-'); if ($mf < 0) { $mf = 0; } elseif ($mf > 59) { $mf = 59; } $mf = str_pad($mf, 2, '0', STR_PAD_LEFT); echo '<span class="nobr">'; echo '<input type="text" name="add_hour" value="', $hf, '" size="2" maxlength="2" class="r" />:'; echo '<input type="text" name="add_minute" value="', $mf, '" size="2" maxlength="2" class="r" />'; echo '</span> ', "\n"; echo '</td>', "\n"; echo '<td>', "\n"; echo '<button type="submit" title="', __('Speichern'), '" class="plain">'; echo '<img alt="', __('Speichern'), '" src="', GS_URL_PATH, 'crystal-svg/16/act/filesave.png" />'; echo '</button>', "\n";
//setting('fkey', $key_idx, $key_def['function'] .' '. $key_def['data'], array('context'=>'active')); # Keys on Phone if ($key_idx >= 1 && $key_idx <= 10) { psetting('memory' . $key_idx . '|path', '/yealink/config/vpPhone/vpPhone.ini'); psetting('memory' . $key_idx . '|Line', '0'); psetting('memory' . $key_idx . '|Value', $key_def['data']); psetting('memory' . $key_idx . '|DKtype', subStr($key_def['function'], 1)); # for BLF if (subStr($key_def['function'], 1) == 16) { psetting('memory' . $key_idx . '|type', 'blf'); psetting('memory' . $key_idx . '|PickupValue', '*81*' . $key_def['data']); } } # Keys on Expansion Modul if ($key_idx >= 100) { $key_tmp = (int) lTrim(subStr($key_idx, 1), '0'); psetting('Key' . $key_tmp . '|path', '/yealink/config/vpPhone/Ext38_0000000000000' . subStr($key_idx, 0, 1) . '.cfg'); psetting('Key' . $key_tmp . '|Line', '0'); psetting('Key' . $key_tmp . '|Value', $key_def['data']); psetting('Key' . $key_tmp . '|DKtype', subStr($key_def['function'], 1)); # for BLF if (subStr($key_def['function'], 1) == 16) { psetting('Key' . $key_tmp . '|type', 'blf'); psetting('Key' . $key_tmp . '|PickupValue', '*81*' . $key_def['data']); } } } } # XML Browser for Phonebook on Line Key 2 psetting('memory12|path', '/yealink/config/vpPhone/vpPhone.ini'); psetting('memory12|Value', $prov_url_tiptel . 'pb.php?u=' . $user_ext);
function retrieve_keys($phone_type, $variables = array()) { if ($this->_user_id > 0) { $this->_keys = gs_keys_get_by_user($this->_user_name, $phone_type); } else { $this->_keys = gs_keys_get_by_profile($this->_profile_id, $phone_type); } if (isGsError($this->_keys) || !is_array($this->_keys)) { gs_log(GS_LOG_NOTICE, isGsError($this->_keys) ? $this->_keys->getMsg() : 'Failed to get softkeys'); $this->_keys = null; return false; } if (is_array($variables) && count($variables) > 0) { $search = array_keys($variables); $replace = array_values($variables); unset($variables); foreach ($this->_keys as $key_name => $key_defs) { foreach ($key_defs as $inh_slf => $key_def) { if ($this->_keys[$key_name][$inh_slf]['data'] != '') { $this->_keys[$key_name][$inh_slf]['data'] = str_replace($search, $replace, $key_def['data']); } } } } # key "fkey0"/"P1" should be set to "line" # $this->_keys['f000']['slf'] = array('key' => 'f000', 'function' => 'line', 'data' => '', 'label' => 'Line', 'user_writeable' => 0, '_set_by' => 'p', '_setter' => null); # get the pickup groups # $pgroups = array(); $rs = $this->_db->execute('SELECT DISTINCT(`p`.`id`) `id`, `p`.`title` ' . 'FROM ' . '`pickupgroups_users` `pu` JOIN ' . '`pickupgroups` `p` ON (`p`.`id`=`pu`.`group_id`) ' . 'WHERE `pu`.`user_id`=' . (int) $this->_user_id . ' ' . 'ORDER BY `p`.`id` ' . 'LIMIT 10'); while ($r = $rs->fetchRow()) { $pgroups[$r['id']] = $r['title']; } # fix some key definitions # foreach ($this->_keys as $key_name => $key_defs) { foreach ($key_defs as $inh_slf => $key_def) { # make sure the user does not set keys for pickup groups # which he/she does not belong to # if (in_array($key_def['function'], array('dest', 'blf'), true) && subStr($key_def['data'], 0, 2) === '*8') { if (preg_match('/(?:^|[:])\\*8\\*([0-9]+)/S', $key_def['data'], $m)) { $pgrpid = (int) lTrim($m[1], '0'); } else { $pgrpid = 0; } if ($pgrpid > 0) { if (!array_key_exists($pgrpid, $pgroups)) { $pgrpid = 0; } } if ($pgrpid < 1) { unset($this->_keys[$key_name][$inh_slf]); } else { $this->_keys[$key_name][$inh_slf]['data'] = '*8*' . str_pad($pgrpid, 5, '0', STR_PAD_LEFT); $title = mb_subStr(trim($pgroups[$pgrpid]), 0, 20); $this->_keys[$key_name][$inh_slf]['label'] = 'Grp. ' . ($title != '' ? $title : $pgrpid); unset($pgroups[$pgrpid]); } } } } # find free keys for the remaining pickup groups (if any) # //FIXME ? return true; }
// backwards compatible with post id if (is_numeric($cat_isnum)) { $field = 'id'; } else { $field = 'name'; } $cats_slugs = ''; $cat_array = explode(',', $cats); foreach ($cat_array as $cat) { $term = get_term_by($field, $cat, 'category'); if (!empty($term)) { $cats_slugs .= "," . $term->slug; } } $cats = $cats_slugs; $cats = lTrim($cats, ','); $cats = preg_replace('/[^A-Za-z0-9() ,-]/', '', $cats); $paged = isset($paged) ? $paged : ''; /* ------------------------------------ :: GRID ONLY ------------------------------------ */ // Show number of posts on a page if (empty($NV_gridshowposts) && empty($NV_gridfilter) && empty($NV_gallerynumposts) && $NV_show_slider == 'gridgallery') { $numposts = "6"; } elseif (!empty($NV_gallerynumposts) && empty($NV_gridfilter)) { $numposts = $NV_gallerynumposts; } elseif (!empty($NV_gridshowposts) && empty($NV_gridfilter)) { $numposts = $NV_gridshowposts; } elseif (!empty($NV_gridfilter)) {
function gs_queue_status($host, $ext, $getMembers, $getCallers) { static $hosts = array(); if (gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) { $host = '127.0.0.1'; } if (!isset($hosts[$host])) { $hosts[$host] = array('sock' => null, 'lasttry' => 0); } if (!is_resource($hosts[$host]['sock'])) { if ($hosts[$host]['lasttry'] > time() - 60) { # we have tried less than a minute ago $hosts[$host]['lasttry'] = time(); return false; } $hosts[$host]['lasttry'] = time(); $sock = @fSockOpen($host, 5038, $err, $errMsg, 2); if (!is_resource($sock)) { gs_log(GS_LOG_WARNING, 'Connection to AMI on ' . $host . ' failed'); return false; } $data = _sock_read($sock, 3, '/[\\r\\n]/'); if (!preg_match('/^Asterisk [^\\/]+\\/(\\d(?:\\.\\d)?)/mis', $data, $m)) { gs_log(GS_LOG_WARNING, 'Incompatible Asterisk manager interface on ' . $host); $m = array(1 => '0.0'); } else { if ($m[1] > '1.1') { # Asterisk 1.4: manager 1.0 # Asterisk 1.6: manager 1.1 gs_log(GS_LOG_NOTICE, 'Asterisk manager interface on ' . $host . ' speaks a new protocol version (' . $m[1] . ')'); # let's try anyway and hope to understand it } } $hosts[$host]['sock'] = $sock; $req = "Action: Login\r\n" . "Username: "******"gscc" . "\r\n" . "Secret: " . "gspass" . "\r\n" . "Events: off\r\n" . "\r\n"; @fWrite($sock, $req, strLen($req)); @fFlush($sock); $data = _sock_read2($sock, 5, '/\\r\\n\\r\\n/S'); if (!preg_match('/Authentication accepted/i', $data)) { gs_log(GS_LOG_WARNING, 'Authentication to AMI on ' . $host . ' failed'); $hosts[$host]['sock'] = null; return false; } } else { $sock = $hosts[$host]['sock']; } $queue_stats = array('maxlen' => null, 'calls' => null, 'holdtime' => null, 'completed' => null, 'abandoned' => null, 'sl' => null, 'slp' => null); if ($getMembers) { $queue_stats['members'] = array(); } if ($getCallers) { $queue_stats['callers'] = array(); } $default_member = array('dynamic' => null, 'calls' => null, 'lastcall' => null, 'devstate' => null, 'paused' => null); $default_caller = array('channel' => null, 'cidnum' => null, 'cidname' => null, 'wait' => null); $req = "Action: QueueStatus\r\n" . "Queue: " . $ext . "\r\n" . "\r\n"; @fWrite($sock, $req, strLen($req)); @fFlush($sock); $resp = trim(_sock_read2($sock, 2, '/Event:\\s*QueueStatusComplete\\r\\n\\r\\n/i')); //echo "\n$resp\n\n"; if (!preg_match('/^Response:\\s*Success/is', $resp)) { return false; } $resp = preg_split('/\\r\\n\\r\\n/S', $resp); /* echo "<pre>"; print_r($resp); echo "</pre>"; */ $manager_ok = false; foreach ($resp as $pkt) { $pkt = lTrim($pkt); if (preg_match('/^Event:\\s*QueueParams/is', $pkt)) { if (!preg_match('/^Queue:\\s*' . $ext . '/mis', $pkt)) { continue; } //echo $pkt, "\n\n"; if (preg_match('/^Max:\\s*(\\d+)/mis', $pkt, $m)) { $queue_stats['maxlen'] = (int) $m[1] > 0 ? (int) $m[1] : null; } if (preg_match('/^Calls:\\s*(\\d+)/mis', $pkt, $m)) { $queue_stats['calls'] = (int) $m[1]; } if (preg_match('/^Holdtime:\\s*(\\d+)/mis', $pkt, $m)) { $queue_stats['holdtime'] = (int) $m[1]; } if (preg_match('/^Completed:\\s*(\\d+)/mis', $pkt, $m)) { $queue_stats['completed'] = (int) $m[1]; } if (preg_match('/^Abandoned:\\s*(\\d+)/mis', $pkt, $m)) { $queue_stats['abandoned'] = (int) $m[1]; } if (preg_match('/^ServiceLevel:\\s*(\\d+)/mis', $pkt, $m)) { $queue_stats['sl'] = (int) $m[1]; } if (preg_match('/^ServiceLevelPerf:\\s*(\\d+?(\\.\\d+)?)/mis', $pkt, $m)) { $queue_stats['slp'] = (double) $m[1]; } $manager_ok = true; } elseif ($getMembers && preg_match('/^Event:\\s*QueueMember/is', $pkt)) { if (!preg_match('/^Queue:\\s*' . $ext . '/mis', $pkt)) { continue; } if (!preg_match('/^Location:\\s*([A-Z\\d\\/]+)/mis', $pkt, $m)) { continue; } $loc = $m[1]; $queue_stats['members'][$loc] = $default_member; //echo $pkt, "\n\n"; if (preg_match('/^Membership:\\s*([a-z]+)/mis', $pkt, $m)) { $queue_stats['members'][$loc]['dynamic'] = $m[1] != 'static'; } if (preg_match('/^CallsTaken:\\s*(\\d+)/mis', $pkt, $m)) { $queue_stats['members'][$loc]['calls'] = (int) $m[1]; } if (preg_match('/^LastCall:\\s*(\\d+)/mis', $pkt, $m)) { $queue_stats['members'][$loc]['lastcall'] = (int) $m[1]; } if (preg_match('/^Status:\\s*(\\d+)/mis', $pkt, $m)) { $queue_stats['members'][$loc]['devstate'] = (int) $m[1]; } if (preg_match('/^Paused:\\s*(\\d+)/mis', $pkt, $m)) { $queue_stats['members'][$loc]['paused'] = (int) $m[1] > 0; } } elseif ($getCallers && preg_match('/^Event:\\s*QueueEntry/is', $pkt)) { if (!preg_match('/^Queue:\\s*' . $ext . '/mis', $pkt)) { continue; } if (!preg_match('/^Position:\\s*(\\d+)/mis', $pkt, $m)) { continue; } $pos = (int) $m[1]; $queue_stats['callers'][$pos] = $default_caller; //echo $pkt, "\n\n"; if (preg_match('/^Channel:\\s*([^\\n\\r]+)/mis', $pkt, $m)) { $queue_stats['callers'][$pos]['dynamic'] = trim($m[1]); } if (preg_match('/^CallerID:\\s*([^\\n\\r]+)/mis', $pkt, $m)) { $queue_stats['callers'][$pos]['cidnum'] = strToLower(trim($m[1])) != 'unknown' ? trim($m[1]) : null; } if (preg_match('/^CallerIDName:\\s*([^\\n\\r]+)/mis', $pkt, $m)) { $queue_stats['callers'][$pos]['cidname'] = strToLower(trim($m[1])) != 'unknown' ? trim($m[1]) : null; } if (preg_match('/^Wait:\\s*(\\d+)/mis', $pkt, $m)) { $queue_stats['callers'][$pos]['wait'] = (int) $m[1]; } } } if (!$manager_ok && $getMembers) { # failed to get information about the queue from the manager # interface. this happens after a reload of Asterisk when # no call has entered the queue using Queue() yet $queue_stats['calls'] = 0; $queue_stats['completed'] = 0; $queue_stats['abandoned'] = 0; $queue_stats['holdtime'] = 0; include_once GS_DIR . 'inc/db_connect.php'; $db = @gs_db_slave_connect(); if (!$db) { return $queue_stats; } $maxlen = (int) $db->executeGetOne('SELECT `maxlen` FROM `ast_queues` WHERE `name`=\'' . $db->escape($ext) . '\''); $queue_stats['maxlen'] = $maxlen > 0 ? $maxlen : null; $rs = $db->execute('SELECT `interface` FROM `ast_queue_members` WHERE `queue_name`=\'' . $db->escape($ext) . '\''); $queue_members = array(); while ($r = $rs->fetchRow()) { if (strToUpper(subStr($r['interface'], 0, 4)) == 'SIP/') { $queue_members[] = subStr($r['interface'], 4); } else { $queue_members[] = $r['interface']; } } if (count($queue_members) < 1) { return $queue_stats; } foreach ($queue_members as $queue_member) { $queue_stats['members']['SIP/' . $queue_member] = $default_member; } $ext_states = @gs_extstate($host, $queue_members); if (!is_array($ext_states)) { return $queue_stats; } foreach ($queue_members as $queue_member) { $queue_stats['members']['SIP/' . $queue_member]['devstate'] = extstate_to_devstate(@$ext_states[$queue_member]); } } /* echo "<pre>"; print_r($queue_stats); echo "</pre>"; */ return $queue_stats; }
/** * Возвращает первое пространство имём класса * * @return boolean * @param string $className */ protected static function extractFirstNamespace($className) { $pos = strPos($className, NS, 1); if (false === $pos) { return null; } return lTrim(subStr($className, 0, $pos), NS); }
} echo ' <small>(', htmlEnt(__('Standard')), ': ', htmlEnt('G.711a'), ')</small>', "\n"; echo '</td>', "\n"; echo '<td class="transp xs gray"><code>allow</code></td>', "\n"; echo '</tr>', "\n"; echo '<tr class="m">', "\n"; echo '<th>', __('Erlaubtes IP-Subnetz'), ' <sup>[5]</sup>:</th>', "\n"; echo '<td>', "\n"; @(list($permit_ip_addr, $permit_cidr_netmask) = explode('/', @$gw_params['permit'])); $permit_ip_addr_parts = explode('.', @$permit_ip_addr); //echo '<input type="text" name="gw-param-permit" value="', htmlEnt(@$gw_params['permit']) ,'" class="r" size="31" maxlength="50" />',"\n"; echo '<input type="text" name="gw-param-permit-0" value="', (int) lTrim(@$permit_ip_addr_parts[0], '0 '), '" class="r" size="3" maxlength="3" style="max-width:3.1em;" />.'; echo '<input type="text" name="gw-param-permit-1" value="', (int) lTrim(@$permit_ip_addr_parts[1], '0 '), '" class="r" size="3" maxlength="3" style="max-width:3.1em;" />.'; echo '<input type="text" name="gw-param-permit-2" value="', (int) lTrim(@$permit_ip_addr_parts[2], '0 '), '" class="r" size="3" maxlength="3" style="max-width:3.1em;" />.'; echo '<input type="text" name="gw-param-permit-3" value="', (int) lTrim(@$permit_ip_addr_parts[3], '0 '), '" class="r" size="3" maxlength="3" style="max-width:3.1em;" />', "\n"; echo ' / <input type="text" name="gw-param-permit-mask" value="', (int) lTrim(@$permit_cidr_netmask, '0 '), '" class="r" size="2" maxlength="2" style="max-width:2.4em;" />', "\n"; echo ' <small>(', htmlEnt(__('Standard')), ': ', htmlEnt('0.0.0.0/0'), ')</small>', "\n"; echo '</td>', "\n"; echo '<td class="transp xs gray"><code>permit</code></td>', "\n"; echo '</tr>', "\n"; if ($gw['name'] == '') { $gw['name'] = 'gw_...'; } ?> </tbody> </table> <br /> <button type="submit"> <img alt=" " src="<?php
if (Count($Group->Childs)) { #----------------------------------------------------------------------- $Table->AddChild($Group); #----------------------------------------------------------------------- $UniqID = UniqID('ID'); #----------------------------------------------------------------------- $Group = new Tag('TBODY', array('id' => $UniqID)); } #------------------------------------------------------------------------- $Td = new Tag('TD', array('colspan' => 2, 'class' => 'Separator'), $Row); #------------------------------------------------------------------------- if (Preg_Match('/^(\\-|\\+)/', $Row, $Matches)) { #----------------------------------------------------------------------- $Td->AddAttribs(array('style' => 'cursor:pointer;', 'onclick' => SPrintF("var Style = document.getElementById('%s').style;Style.display = (Style.display != 'none'?'none':'');", $UniqID))); #----------------------------------------------------------------------- $Td->AddText(SPrintF('+ %s', lTrim($Row, '-+')), TRUE); #----------------------------------------------------------------------- if (Next($Matches) != '+') { $Group->AddAttribs(array('style' => 'display:none;')); } } #------------------------------------------------------------------------- $Tr->AddChild($Td); #------------------------------------------------------------------------- $Table->AddChild($Tr); } } #------------------------------------------------------------------------------- if (Count($Group->Childs)) { $Table->AddChild($Group); }