本文整理汇总了PHP中mb_subStr函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_subStr函数的具体用法?PHP mb_subStr怎么用?PHP mb_subStr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mb_subStr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mb_str_pad
function mb_str_pad($str, $len, $padstr = ' ', $padtype = STR_PAD_RIGHT, $enc = '')
{
if (!function_exists('mb_strlen')) {
return str_pad($str, $len, $padstr, $padtype);
}
if ($enc === '') {
$enc = mb_internal_encoding();
}
$strlen = mb_strLen($str, $enc);
$flen = $len - $strlen;
if ($flen <= 0) {
return $str;
}
$pad = str_repeat($padstr, $flen);
switch ($padtype) {
case STR_PAD_RIGHT:
$pad = mb_subStr($pad, 0, $flen, $enc);
return $str . $pad;
case STR_PAD_LEFT:
$pad = mb_subStr($pad, 0, $flen, $enc);
return $pad . $str;
case STR_PAD_BOTH:
$flenh = $flen / 2;
$padl = mb_subStr($pad, 0, floor($flenh), $enc);
$padr = mb_subStr($pad, 0, ceil($flenh), $enc);
return $padl . $str . $padr;
default:
trigger_error('mb_str_pad(): Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH.', E_USER_WARNING);
return null;
}
}
示例2: gs_user_comment_set
function gs_user_comment_set($user, $comment = '')
{
if (!preg_match('/^[a-z0-9\\-_.]+$/', $user)) {
return new GsError('User must be alphanumeric.');
}
$comment = mb_subStr($comment, 0, 200);
# connect to db
#
$db = gs_db_master_connect();
if (!$db) {
return new GsError('Could not connect to database.');
}
# get user_id
#
$user_id = $db->executeGetOne('SELECT `id` FROM `users` WHERE `user`=\'' . $db->escape($user) . '\'');
if (!$user_id) {
return new GsError('Unknown user.');
}
# set comment
#
$ok = $db->execute('UPDATE `users` SET `user_comment`=\'' . $db->escape($comment) . '\' WHERE `id`=' . $user_id);
if (!$ok) {
return new GsError('Failed to set comment.');
}
return true;
}
示例3: parse
/**
* @return string
* @param string $string
*/
public static function parse($string)
{
$toParse = mb_subStr($string, 2, -2, 'UTF-8');
$toParse = trim($toParse);
$toParse = preg_replace('/^\\s*\\*[^@]/m', '', $toParse);
$parts = preg_split('/(@(?:description|param))\\s*/', $toParse, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$count = count($parts);
$result = array();
for ($i = 0; $i < $count; ++$i) {
$tag = strToLower(subStr($parts[$i], 1));
if ($i + 1 >= $count) {
continue;
}
if ('@' != $parts[$i + 1][0]) {
$function = 'parse' . ucFirst($tag);
$item = self::$function($parts[$i + 1]);
$item['name'] = $tag;
$result[] = $item;
++$i;
}
}
return $result;
}
示例4: __
echo ' ', __('Anlage'), ':', "\n";
echo '<select name="boi_host_id" tabindex="100" onchange="this.form.submit();">', "\n";
$tmp_host_id = null;
if (!$rs) {
gs_log(GS_LOG_WARNING, 'Failed to get nodes / foreign hosts');
} else {
while ($r = $rs->fetchRow()) {
if ($tmp_host_id !== null) {
continue;
}
# do not show foreign host twice for local admins
echo '<option value="', $r['id'], '"';
if ($r['id'] === $_SESSION['sudo_user']['boi_host_id']) {
echo ' selected="selected"';
}
echo '>', htmlEnt(mb_subStr($r['comment'], 0, 20));
if ($r['id'] === $_SESSION['real_user']['info']['host_id'] || !$_SESSION['real_user']['info']['host_is_foreign'] && $r['id'] === 0) {
echo ' •';
$tmp_host_id = $r['id'];
}
echo '</option>', "\n";
}
}
unset($tmp_host_id);
echo '</select>', "\n";
echo '</div>', "\n";
}
echo '</form>', "\n";
}
?>
<br style="float:none; clear:right;" />
示例5: setting
# g723.1
setting('codec_size', $i, '20');
# 20 ms, valid values: 20, 30, 40, 60
# G.723.1 needs 30 or 60 ms. All other codecs work with 20, 40 and 60 ms only.
setting('user_host', $i, $host);
setting('user_outbound', $i, $sip_proxy_and_sbc['sip_proxy_from_wan']);
setting('user_proxy_require', $i, '');
setting('user_shared_line', $i, 'off');
setting('user_name', $i, $user_ext);
setting('user_pname', $i, $user_ext);
setting('user_pass', $i, $user['secret']);
//setting('user_hash' ,$i, md5($user['secret']));
//setting('user_hash' ,$i, md5($user_ext .':'. $host .':'. $user['secret']));
//setting('user_hash' ,$i, md5($user_ext .':'. 'asterisk' .':'. $user['secret']));
setting('user_realname', $i, $user['callerid']);
setting('user_idle_text', $i, $user_ext . ' ' . mb_subStr($user['firstname'], 0, 1) . '. ' . $user['lastname']);
setting('record_missed_calls', $i, 'on');
setting('record_dialed_calls', $i, 'off');
setting('record_received_calls', $i, 'off');
# andere Accounts
#
for ($i = 2; $i <= 12; ++$i) {
setting('user_active', $i, 'off', null, true);
setting('allow_mismatched_sdp_answers', $i, 'on');
}
# Account 1 als aktiv setzen
#
psetting('active_line', '1');
#####################################################################
# Kurzwahlen loeschen
#####################################################################
示例6: psetting
$softkey['data'] = $prov_url_aastra.'login.php?a=login';
else
$softkey['data'] = $prov_url_aastra.'login.php';
break;
}
psetting($key_name.' type' , $softkey['function'], true, $dynamic);
psetting($key_name.' value', $softkey['data' ], true, $dynamic);
psetting($key_name.' label', $softkey['label' ], true, $dynamic);
}
}
#####################################################################
# SIP
#####################################################################
psetting('sip screen name' , $user_ext .' '. mb_subStr($user['firstname'],0,1) .'. '. $user['lastname'], true, $dynamic);
psetting('sip display name' , $user['firstname'].' '.$user['lastname'], true, $dynamic);
psetting('sip user name' , $user_ext, true, $dynamic);
psetting('sip auth name' , $user_ext, true, $dynamic);
psetting('sip password' , $user['secret'], true, $dynamic);
psetting('sip registrar ip' , $host, true, $dynamic);
psetting('sip outbound proxy' , ($sip_proxy_and_sbc['sip_proxy_from_wan'] != '' ? $sip_proxy_and_sbc['sip_proxy_from_wan'] : $host), true, $dynamic );
psetting('sip proxy ip' , $host, true, $dynamic);
#####################################################################
# other settings
#####################################################################
/*
#setting('language', 0, $prov_url_aastra .'lang_en.txt'); # English. Default
setting('language', 1, $prov_url_aastra .'lang/lang_de.txt');
示例7: psetting
psetting('https_port', '443');
psetting('http_client_user', '');
psetting('http_client_password', '');
psetting('http_proxy_user', '');
psetting('http_proxy_password', '');
psetting('emergency_proxy', '');
psetting('emergency_numbers', '');
#####################################################################
# USER settings
#####################################################################
for ($i = 1; $i < 10; ++$i) {
setting('user_active', $i, 'off');
}
foreach ($users as $i => $user) {
setting('user_active', $i, 'on');
setting('user_realname', $i, $user['ext'] . ' ' . mb_subStr($user['firstname'], 0, 1) . '. ' . $user['lastname']);
setting('user_name', $i, $user['ext']);
setting('user_host', $i, $user['host']);
setting('user_outbound', $i, '');
setting('user_authname', $i, $user['ext']);
setting('user_pass', $i, $user['secret']);
setting('user_mailbox', $i, $user['mailbox']);
setting('user_pbxtype', $i, 'asterisk');
setting('rtp_encryption', $i, 'off');
setting('user_country_code', $i, '');
setting('area_code', $i, '');
setting('user_expiry', $i, '3600');
setting('user_sip_info', $i, '0');
setting('conference_uri', $i, '');
setting('codec1_name', $i, '8');
setting('codec2_name', $i, '0');
示例8: __
?>
><?php
echo __('Zentrale');
?>
</option>
<?php
$rs = $DB->execute('SELECT `id`, `host`, `comment` FROM `hosts` WHERE `is_foreign`=1 ORDER BY `comment`');
if ($rs->numRows() > 0) {
echo '<option value="" disabled="disabled">-</option>', "\n";
}
while ($r = $rs->fetchRow()) {
echo '<option value="', $r['id'], '"';
if ($r['id'] == $pbx_id) {
echo ' selected="selected"';
}
echo '>', htmlEnt(mb_subStr($r['comment'], 0, 20)), ' (', htmlEnt($r['host']), ')', '</option>', "\n";
}
?>
</select>
</td>
<td>
<select name="phone_type">
<option value=""><?php
echo __('alle');
?>
</option>
<?php
foreach ($phone_types as $phone_type_name => $phone_type_display) {
echo '<option value="', $phone_type_name, '"';
if ($phone_type_name === $phone_type) {
echo ' selected="selected"';
示例9: psetting
}
if (in_array($phone_model, array('bt200', 'bt201'), true)) {
psetting('P270', $user_ext);
# Account Name ( maxlength 96 )
}
psetting('P47', $host);
# SIP Server
psetting('P48', $sip_proxy_and_sbc['sip_proxy_from_wan']);
# Outbound Proxy
psetting('P35', $user_ext);
# SIP User ID
psetting('P36', $user_ext);
# Authentication ID
psetting('P34', $user['secret']);
# SIP Authentication Password (cleartext)
psetting('P3', $user_ext . ' ' . mb_subStr($user['firstname'], 0, 1) . '. ' . $user['lastname']);
# Display (CallerID) Name
psetting('P103', '0');
# Use DNS SRV ( 0 = no, 1 = yes )
psetting('P63', '1');
# UserID is phone number ( 0 = no, 1 = yes )
psetting('P31', '1');
# SIP Registration ( 0 = no register, 1 = register )
psetting('P81', '1');
# Unregister on Reboot ( 0 = no, 1 = yes )
if (in_array($phone_model, array('ht287', 'bt110'), true)) {
psetting('P239', '300');
# Register Expiration (in seconds | default 3600)
}
if (in_array($phone_model, array('bt200', 'bt201', 'gxp280', 'gxp1200', 'gxp2000', 'gxp2010', 'gxp2020', 'gxv3000', 'gxv3005', 'gxv3140'), true)) {
psetting('P32', '5');
示例10: defined
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
\*******************************************************************/
defined('GS_VALID') or die('No direct access.');
include_once GS_DIR . 'inc/util.php';
include_once GS_DIR . 'inc/gs-fns/gs_callforward_get.php';
include_once GS_DIR . 'inc/gs-fns/gs_prov_phone_checkcfg.php';
include_once GS_DIR . 'inc/gs-fns/gs_user_comment_get.php';
include_once GS_DIR . 'inc/gs-fns/gs_user_comment_set.php';
$action = array_key_exists('action', $_REQUEST) ? $_REQUEST['action'] : '';
if (!@$_SESSION['sudo_user']['info']['host_is_foreign']) {
if ($action === 'reboot') {
gs_prov_phone_checkcfg_by_ext($_SESSION['sudo_user']['info']['ext'], true);
} elseif ($action === 'setcomment') {
$comment = rTrim(mb_subStr(trim(@$_REQUEST['comment']), 0, 200));
gs_user_comment_set($_SESSION['sudo_user']['name'], $comment);
}
}
echo '<h2>';
if (@$MODULES[$SECTION]['icon']) {
echo '<img alt=" " src="', GS_URL_PATH, str_replace('%s', '32', $MODULES[$SECTION]['icon']), '" /> ';
}
if (count($MODULES[$SECTION]['sub']) > 1) {
echo $MODULES[$SECTION]['title'], ' - ';
}
echo $MODULES[$SECTION]['sub'][$MODULE]['title'];
echo '</h2>', "\n";
//echo '<br />', "\n";
echo '<h2>', __('Willkommen'), ', ', htmlEnt($_SESSION['sudo_user']['info']['firstname'] . ' ' . $_SESSION['sudo_user']['info']['lastname']), '!</h2>', "\n";
if ($_SESSION['sudo_user']['name'] === 'sysadmin') {
示例11: gs_boi_get_gui_menu
function gs_boi_get_gui_menu($api, $host, $role, $ext, $session = null)
{
$old_default_socket_timeout = ini_get('default_socket_timeout');
ini_set('default_socket_timeout', 8);
$old_soap_wsdl_cache_ttl = ini_get('soap.wsdl_cache_ttl');
ini_set('soap.wsdl_cache_ttl', 3600);
gs_log(GS_LOG_DEBUG, 'BOI SOAP: Getting menu for ' . $role . ', ' . $ext . ' from ' . $host);
$SoapClient = gs_get_soap_client($api, 'guiintegration', $host);
if (!$SoapClient) {
return false;
}
try {
if ($session !== null) {
$SoapClient->__setCookie('session', $session);
}
$ret = $SoapClient->getMenu(gs_boi_gs_role_to_server_role($role), $ext);
/*
$ret = $SoapClient->__soapCall( 'getMenu',
array( gs_boi_gs_role_to_server_role($role), $ext),
null
);
*/
//print_r($ret);
if ($ret === null || $ret === false) {
gs_log(GS_LOG_WARNING, 'Got empty SOAP response!');
return false;
} else {
$ret = obj2arr_r($ret);
if (is_array($ret) && array_key_exists('menu', $ret)) {
$ret = $ret['menu'];
}
//echo "<pre>", print_r($ret, true) ,"</pre>";
$ret = _fix_broken_soap_array($ret);
/*
$ret = array(
array('title' => "Anruflisten" , 'link' => '' ),
array('title' => "gew\xC3\xA4hlt" , 'link' => '/dl/g'),
array('title' => "verpa\xC3\x9Ft" , 'link' => '/dl/v'),
array('title' => "angenommen" , 'link' => '/dl/a'),
array('title' => "Statistik" , 'link' => '' ),
array('title' => "Queues" , 'link' => '/s/q' ),
array('title' => "Gespr\xC3\xA4che", 'link' => '/s/g' )
);
*/
//echo "<pre>", print_r($ret, true) ,"</pre>";
if (!is_array($ret)) {
return false;
}
$menu = array();
//$main_menu_cnt = 0;
//$sub_menu_cnt = 0;
foreach ($ret as $entry) {
if (!is_array($entry)) {
continue;
}
if (!array_key_exists('title', $entry) || !array_key_exists('link', $entry)) {
continue;
}
if (trim($entry['link']) == '') {
# is a main menu
//++$main_menu_cnt;
//$menu['boi'.$main_menu_cnt] = array(
$key = 'boi-' . mb_subStr(preg_replace('/[^a-z0-9\\-_]/', '', str_replace(array("ä", "ö", "ü", "ß"), array('ae', 'oe', 'ue', 'ss'), str_replace(' ', '-', mb_strToLower(html_entity_decode($entry['title']))))), 0, 20);
while (array_key_exists($key, $menu)) {
$key .= '-';
}
$menu[$key] = array('is_boi' => true, 'title' => htmlEnt(html_entity_decode(trim($entry['title']), ENT_QUOTES, 'UTF-8')), 'icon' => 'crystal-svg/%s/act/misc.png', 'sub' => array());
# html_entity_decode() is done because the other party already
# encodes special characters although it shouldn't. don't remove
# the htmlEnt() around it - doing so would make this vulnerable.
//$sub_menu_cnt = 0;
} else {
//$main_menu_idx = count($menu)-1;
end($menu);
$main_menu_idx = key($menu);
if (!array_key_exists($main_menu_idx, $menu)) {
continue;
}
//++$sub_menu_cnt;
//$menu[$main_menu_idx]['sub']['boi'.$sub_menu_cnt] = 3;
$key = mb_subStr(preg_replace('/[^a-z0-9\\-_]/', '', str_replace(array("ä", "ö", "ü", "ß"), array('ae', 'oe', 'ue', 'ss'), str_replace(' ', '-', mb_strToLower(html_entity_decode($entry['title']))))), 0, 20);
while (array_key_exists($key, $menu[$main_menu_idx]['sub'])) {
$key .= '-';
}
if (subStr($entry['link'], 0, 1) !== '/') {
$entry['link'] = '/' . $entry['link'];
}
$menu[$main_menu_idx]['sub'][$key] = array('title' => htmlEnt(html_entity_decode(trim($entry['title']), ENT_QUOTES, 'UTF-8')), 'boi_url' => trim($entry['link']));
# see comment about html_entity_decode() above
}
}
//echo "<pre>"; print_r($menu); echo "</pre>";
return $menu;
}
} catch (SOAPFault $SoapFault) {
//print_r($ret);
gs_log(GS_LOG_WARNING, 'SOAP error: ' . $SoapFault->faultstring . ' (' . @$SoapFault->faultcode . ')');
return false;
}
//.........这里部分代码省略.........
示例12: gs_utf8_decompose_first_to_ascii
function gs_utf8_decompose_first_to_ascii($str)
{
return gs_utf8_decompose_to_ascii(mb_subStr($str, 0, 1)) . mb_subStr($str, 1);
}
示例13: IN
$rs_hosts = $DB->execute(
'SELECT `id`, `host`, `comment` '.
'FROM `hosts` '.
'WHERE `is_foreign`=1 AND `id` NOT IN ( '.
'SELECT `host_id` '.
'FROM `boi_perms` '.
'WHERE `user_id`='.(int)$r['uid'].' AND `roles`<>\'\' '.
') '.
'ORDER BY `comment`'
);
echo '<optgroup label="', __('Fremd-Hosts') ,'">',"\n";
while ($h = $rs_hosts->fetchRow()) {
echo '<option value="',$h['id'],'">';
$comment = mb_subStr($h['comment'], 0, 25+1);
if (mb_strLen($comment) > 25)
$comment = mb_subStr($h['comment'], 0, 25-1) ."\xE2\x80\xA6";
elseif (trim($comment) === '') $comment = '#'.$h['id'];
echo htmlEnt($comment) ,' -- ', htmlEnt($h['host']);
if ($h['id'] == $r['hid']) echo ' (•)';
echo '</option>',"\n";
}
echo '</optgroup>',"\n";
echo '</select>' ,"\n";
echo '</td>' ,"\n";
echo "<td>\n";
//echo '[save]';
echo "</td>\n";
echo "</tr>\n";
?>
示例14: _set_cfg
# ???
_set_cfg('reg-number', null, $user_ext);
# ???
_set_cfg('fully-qualified-phone-no', null, $user_ext);
# ???
_set_cfg('sip-pwd', null, $user['secret']);
_set_cfg('sip-name', null, _siemens_xml_esc(mb_subStr(rTrim(preg_replace('/<[^>]*>/', '', $user['callerid'])), 0, 24)));
_set_cfg('register-by-name', null, 'false');
$tmp = $user_ext . ' ';
if ($user['firstname'] != '') {
$tmp .= mb_subStr($user['firstname'], 0, 1);
}
if ($user['lastname'] != '') {
$tmp .= mb_subStr($user['lastname'], 0, 3);
}
$tmp = _siemens_xml_esc(mb_subStr(rTrim($tmp), 0, 24));
_set_cfg('display-id', null, _siemens_xml_esc($tmp));
# max. 24 chars
_set_cfg('display-id-unicode', null, _siemens_xml_esc($tmp));
# "
_set_cfg('use-display-id', null, 'true');
_set_cfg('reg-addr', null, $host);
_set_cfg('reg-port', null, '5060');
_set_cfg('registrar-addr', null, $host);
_set_cfg('registrar-port', null, '5060');
_set_cfg('outbound-proxy', null, $sip_proxy_and_sbc['sip_proxy_from_wan'] != '' ? 'true' : 'false');
_set_cfg('outbound-proxy-user', null, $sip_proxy_and_sbc['sip_proxy_from_wan'] != '' ? 'true' : 'false');
_set_cfg('sgnl-gateway-addr', null, $sip_proxy_and_sbc['sip_proxy_from_wan'] != '' ? $sip_proxy_and_sbc['sip_proxy_from_wan'] : $host);
_set_cfg('sgnl-gateway-addr-user', null, $sip_proxy_and_sbc['sip_proxy_from_wan'] != '' ? $sip_proxy_and_sbc['sip_proxy_from_wan'] : $host);
_set_cfg('sgnl-gateway-port', null, '5060');
_set_cfg('sgnl-gateway-port-user', null, '5060');
示例15: exec
exec('locale -a | grep -i ' . qsa('^' . $lang . '_') . ' 2>>/dev/null', $out, $err);
if ($err != 0) {
gs_log(GS_LOG_NOTICE, 'Failed to find locales on your system');
} else {
$lfound = setLocale(LC_TIME, $out);
if ($lfound === false) {
gs_log(GS_LOG_NOTICE, 'Your system does not have any locales like "' . $lang . '_*"');
} else {
gs_log(GS_LOG_NOTICE, 'Using locale "' . $lfound . '" as a fallback');
}
}
}
$wdays = array('mo' => 'Mon', 'tu' => 'Tue', 'we' => 'Wed', 'th' => 'Thu', 'fr' => 'Fri', 'sa' => 'Sat', 'su' => 'Sun');
$wdaysl = array();
foreach ($wdays as $col => $wdca) {
$wdaysl[$col] = mb_subStr(strFTime('%a', strToTime('last ' . $wdca)), 0, 1);
}
unset($wdays);
setLocale(LC_TIME, array($oldLocale, 'C'));
$i = 0;
$rs = $DB->execute('SELECT * from `queue_cf_timerules` WHERE `_queue_id`=' . $queue_id . ' ORDER BY `ord`');
while ($route = $rs->fetchRow()) {
echo '<input type="hidden" name="tr_' . $route['id'] . '" value="' . $route['id'] . '" />';
echo '<tr><td>';
echo $route['ord'];
echo '</td><td>';
foreach ($wdaysl as $col => $v) {
echo '<span class="nobr"><input type="checkbox" name="' . $route['id'] . '-d_', $col, '" id="ipt-' . $route['id'] . '-r_d_', $col, '" value="1" ', $route['d_' . $col] ? 'checked="checked" ' : '', '/>';
echo '<label for="ipt-r_d_', $col, '">', $v, '</label></span>';
}
echo '</td>', "\n";