mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 07:53:39 +01:00
global bytes() function returning the number of bytes of a string, independent of mbstring available and mbstring.func_overload set
This commit is contained in:
parent
2bce586215
commit
f1bc6ab712
@ -1220,7 +1220,7 @@ class uiforms extends uical
|
||||
else
|
||||
{
|
||||
$GLOBALS['egw']->browser =& CreateObject('phpgwapi.browser');
|
||||
$GLOBALS['egw']->browser->content_header('event.ics','text/calendar',strlen($ical));
|
||||
$GLOBALS['egw']->browser->content_header('event.ics','text/calendar',bytes($ical));
|
||||
echo $ical;
|
||||
$GLOBALS['egw']->common->egw_exit();
|
||||
}
|
||||
@ -1243,7 +1243,7 @@ class uiforms extends uical
|
||||
{
|
||||
$ical =& ExecMethod2('calendar.boical.exportVCal',$events,'2.0'/*$content['version']*/);
|
||||
$GLOBALS['egw']->browser =& CreateObject('phpgwapi.browser');
|
||||
$GLOBALS['egw']->browser->content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',strlen($ical));
|
||||
$GLOBALS['egw']->browser->content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical));
|
||||
echo $ical;
|
||||
$GLOBALS['egw']->common->egw_exit();
|
||||
}
|
||||
|
@ -438,7 +438,7 @@
|
||||
{
|
||||
$this->browser = CreateObject('phpgwapi.browser');
|
||||
}
|
||||
$this->browser->content_header('schema-backup-'.date('YmdHi').'.inc.php','text/plain',strlen($def));
|
||||
$this->browser->content_header('schema-backup-'.date('YmdHi').'.inc.php','text/plain',bytes($def));
|
||||
echo "<?php\n\t/* eGroupWare schema-backup from ".date('Y-m-d H:i:s')." */\n\n".$def;
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +286,7 @@
|
||||
}
|
||||
if(($success = $this->PutLine($this->request_method.' '.$request_uri.' HTTP/'.$this->protocol_version)))
|
||||
{
|
||||
if(($body_length = strlen($request_body)))
|
||||
if(($body_length = bytes($request_body)))
|
||||
{
|
||||
$headers['Content-length'] = $body_length;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@
|
||||
else
|
||||
{
|
||||
// $payload = '<?xml version="1.0"?\>' . "\n" . $this->serializeDebug() . $r->serialize();
|
||||
// Header("Content-type: text/xml\r\nContent-length: " . strlen($payload));
|
||||
// Header("Content-type: text/xml\r\nContent-length: " . bytes($payload));
|
||||
// print $payload;
|
||||
echo $r;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@
|
||||
$payload = $GLOBALS['egw']->translation->convert("<?xml version=\"1.0\"?>\n" . $this->serializeDebug() . $r->serialize(),
|
||||
$GLOBALS['egw']->translation->charset(),'utf-8');
|
||||
header("Content-type: text/xml");
|
||||
header("Content-length: " . $this->bytes($payload));
|
||||
header("Content-length: " . bytes($payload));
|
||||
echo $payload;
|
||||
}
|
||||
|
||||
@ -121,24 +121,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* mbstring.func_overload save strlen version: counting the bytes not the chars
|
||||
*
|
||||
* @param string $str
|
||||
* @return int
|
||||
*/
|
||||
function bytes($str)
|
||||
{
|
||||
static $func_overload;
|
||||
|
||||
if (is_null($func_overload))
|
||||
{
|
||||
$func_overload = @extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
|
||||
}
|
||||
return $func_overload & 2 ? mb_strlen($str,'ascii') : strlen($str);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* add a method to the dispatch map
|
||||
*/
|
||||
|
@ -28,6 +28,22 @@
|
||||
* because they are required to be available at the lowest level. *
|
||||
\***************************************************************************/
|
||||
|
||||
/**
|
||||
* Return the number of bytes of a string, independent of mbstring.func_overload
|
||||
* AND the availability of mbstring
|
||||
*
|
||||
* @param string $str
|
||||
* @return int
|
||||
*/
|
||||
function bytes($str)
|
||||
{
|
||||
static $func_overload;
|
||||
|
||||
if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
|
||||
|
||||
return $func_overload & 2 ? mb_strlen($str,'ascii') : strlen($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal Not to be used directly. Should only be used by print_debug()
|
||||
*/
|
||||
|
@ -167,7 +167,7 @@
|
||||
);
|
||||
$payload = '<?xml version="1.0"?>' . "\n" . $r->serialize();
|
||||
Header('Content-type: text/xml');
|
||||
Header('Content-length: ' . strlen($payload));
|
||||
Header('Content-length: ' . bytes($payload));
|
||||
print $payload;
|
||||
$GLOBALS['egw']->common->phpgw_exit(False);
|
||||
}
|
||||
|
2
rpc.php
2
rpc.php
@ -117,6 +117,6 @@ $out = $server->getResponse($input, $params);
|
||||
|
||||
/* Return the response to the client. */
|
||||
header('Content-Type: ' . $server->getResponseContentType());
|
||||
header('Content-length: ' . strlen($out));
|
||||
header('Content-length: ' . bytes($out));
|
||||
header('Accept-Charset: UTF-8');
|
||||
echo $out;
|
||||
|
Loading…
Reference in New Issue
Block a user