2 // include_once($GLOBALS['srcdir'] . '/sql.inc');
3 include_once(dirname(__FILE__
) . '/sql.inc'); // fixes vulnerability with register_globals
5 // this function is related to the interface/language module.
7 function xl($constant,$mode='r',$prepend='',$append='') {
9 $sql="SELECT * FROM lang_definitions JOIN lang_constants ON " .
10 "lang_definitions.cons_id = lang_constants.cons_id WHERE " .
11 "lang_id='$lang_id' AND constant_name = '" .
12 addslashes($constant) . "' LIMIT 1";
13 $res=SqlStatement($sql);
14 $row=SqlFetchArray($res);
15 $string=$row['definition'];
16 if ($string=='') { $string="$constant"; }
17 $string="$prepend"."$string"."$append";
26 // ----------------------------------------------------------------------------
30 shows some informations for pages html header
35 function html_header_show() {
36 echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> '."\n";
40 // ----------------------------------------------------------------------------
42 * Returns a string padded to a certain length with another string.
44 * This method behaves exactly like str_pad but is multibyte safe.
46 * @param string $input The string to be padded.
47 * @param int $length The length of the resulting string.
48 * @param string $pad The string to pad the input string with. Must
49 * be in the same charset like the input string.
50 * @param const $type The padding type. One of STR_PAD_LEFT,
51 * STR_PAD_RIGHT, or STR_PAD_BOTH.
52 * @param string $charset The charset of the input and the padding
55 * @return string The padded string.
57 function mb_strpad($input, $length, $pad = ' ', $type = STR_PAD_RIGHT
, $charset = 'UTF-8') {
58 mb_internal_encoding($charset);
59 $mb_length = mb_strlen($input, $charset);
60 $sb_length = strlen($input);
61 $pad_length = mb_strlen($pad, $charset);
63 /* Return if we already have the length. */
64 if ($mb_length >= $length) {
68 /* Shortcut for single byte strings. */
69 if ($mb_length == $sb_length && $pad_length == strlen($pad)) {
70 return str_pad($input, $length, $pad, $type);
75 $left = $length - $mb_length;
76 $output = mb_substr(str_repeat($pad, ceil($left / $pad_length)), 0, $left, $charset) . $input;
79 $left = floor(($length - $mb_length) / 2);
80 $right = ceil(($length - $mb_length) / 2);
81 $output = mb_substr(str_repeat($pad, ceil($left / $pad_length)), 0, $left, $charset) .
83 mb_substr(str_repeat($pad, ceil($right / $pad_length)), 0, $right, $charset);
86 $right = $length - $mb_length;
87 $output = $input . mb_substr(str_repeat($pad, ceil($right / $pad_length)), 0, $right, $charset);