forked from extern/egroupware
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
|
else
|
||||||
{
|
{
|
||||||
$GLOBALS['egw']->browser =& CreateObject('phpgwapi.browser');
|
$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;
|
echo $ical;
|
||||||
$GLOBALS['egw']->common->egw_exit();
|
$GLOBALS['egw']->common->egw_exit();
|
||||||
}
|
}
|
||||||
@ -1243,7 +1243,7 @@ class uiforms extends uical
|
|||||||
{
|
{
|
||||||
$ical =& ExecMethod2('calendar.boical.exportVCal',$events,'2.0'/*$content['version']*/);
|
$ical =& ExecMethod2('calendar.boical.exportVCal',$events,'2.0'/*$content['version']*/);
|
||||||
$GLOBALS['egw']->browser =& CreateObject('phpgwapi.browser');
|
$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;
|
echo $ical;
|
||||||
$GLOBALS['egw']->common->egw_exit();
|
$GLOBALS['egw']->common->egw_exit();
|
||||||
}
|
}
|
||||||
|
@ -438,7 +438,7 @@
|
|||||||
{
|
{
|
||||||
$this->browser = CreateObject('phpgwapi.browser');
|
$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;
|
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(($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;
|
$headers['Content-length'] = $body_length;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// $payload = '<?xml version="1.0"?\>' . "\n" . $this->serializeDebug() . $r->serialize();
|
// $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;
|
// print $payload;
|
||||||
echo $r;
|
echo $r;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@
|
|||||||
$payload = $GLOBALS['egw']->translation->convert("<?xml version=\"1.0\"?>\n" . $this->serializeDebug() . $r->serialize(),
|
$payload = $GLOBALS['egw']->translation->convert("<?xml version=\"1.0\"?>\n" . $this->serializeDebug() . $r->serialize(),
|
||||||
$GLOBALS['egw']->translation->charset(),'utf-8');
|
$GLOBALS['egw']->translation->charset(),'utf-8');
|
||||||
header("Content-type: text/xml");
|
header("Content-type: text/xml");
|
||||||
header("Content-length: " . $this->bytes($payload));
|
header("Content-length: " . bytes($payload));
|
||||||
echo $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
|
* add a method to the dispatch map
|
||||||
*/
|
*/
|
||||||
|
@ -28,6 +28,22 @@
|
|||||||
* because they are required to be available at the lowest level. *
|
* 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()
|
* @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();
|
$payload = '<?xml version="1.0"?>' . "\n" . $r->serialize();
|
||||||
Header('Content-type: text/xml');
|
Header('Content-type: text/xml');
|
||||||
Header('Content-length: ' . strlen($payload));
|
Header('Content-length: ' . bytes($payload));
|
||||||
print $payload;
|
print $payload;
|
||||||
$GLOBALS['egw']->common->phpgw_exit(False);
|
$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. */
|
/* Return the response to the client. */
|
||||||
header('Content-Type: ' . $server->getResponseContentType());
|
header('Content-Type: ' . $server->getResponseContentType());
|
||||||
header('Content-length: ' . strlen($out));
|
header('Content-length: ' . bytes($out));
|
||||||
header('Accept-Charset: UTF-8');
|
header('Accept-Charset: UTF-8');
|
||||||
echo $out;
|
echo $out;
|
||||||
|
Loading…
Reference in New Issue
Block a user