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='') {
11 if ($GLOBALS['use_set_names_utf8']) sqlQuery("SET NAMES utf8");
13 $sql="SELECT * FROM lang_definitions JOIN lang_constants ON " .
14 "lang_definitions.cons_id = lang_constants.cons_id WHERE " .
15 "lang_id='$lang_id' AND constant_name = '" .
16 addslashes($constant) . "' LIMIT 1";
17 $res=SqlStatement($sql);
18 $row=SqlFetchArray($res);
19 $string=$row['definition'];
20 if ($string=='') { $string="$constant"; }
21 $string="$prepend"."$string"."$append";
30 // ----------------------------------------------------------------------------
34 shows some informations for pages html header
39 function html_header_show() {
40 echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> '."\n";
44 // ----------------------------------------------------------------------------
46 * Returns a string padded to a certain length with another string.
48 * This method behaves exactly like str_pad but is multibyte safe.
50 * @param string $input The string to be padded.
51 * @param int $length The length of the resulting string.
52 * @param string $pad The string to pad the input string with. Must
53 * be in the same charset like the input string.
54 * @param const $type The padding type. One of STR_PAD_LEFT,
55 * STR_PAD_RIGHT, or STR_PAD_BOTH.
56 * @param string $charset The charset of the input and the padding
59 * @return string The padded string.
61 function mb_strpad($input, $length, $pad = ' ', $type = STR_PAD_RIGHT
, $charset = 'UTF-8') {
62 mb_internal_encoding($charset);
63 $mb_length = mb_strlen($input, $charset);
64 $sb_length = strlen($input);
65 $pad_length = mb_strlen($pad, $charset);
67 /* Return if we already have the length. */
68 if ($mb_length >= $length) {
72 /* Shortcut for single byte strings. */
73 if ($mb_length == $sb_length && $pad_length == strlen($pad)) {
74 return str_pad($input, $length, $pad, $type);
79 $left = $length - $mb_length;
80 $output = mb_substr(str_repeat($pad, ceil($left / $pad_length)), 0, $left, $charset) . $input;
83 $left = floor(($length - $mb_length) / 2);
84 $right = ceil(($length - $mb_length) / 2);
85 $output = mb_substr(str_repeat($pad, ceil($left / $pad_length)), 0, $left, $charset) .
87 mb_substr(str_repeat($pad, ceil($right / $pad_length)), 0, $right, $charset);
90 $right = $length - $mb_length;
91 $output = $input . mb_substr(str_repeat($pad, ceil($right / $pad_length)), 0, $right, $charset);