forked from levhita/ThaFrame
/
functions.inc.php
54 lines (46 loc) · 1.39 KB
/
functions.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Holds general use functions
* @package ThaFrame
* @author Argel Arias <levhita@gmail.com>
* @copyright Copyright (c) 2007, Argel Arias <levhita@gmail.com>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
require_once(THAFRAME."/core/format_functions.inc.php");
/**
* loads an Error Page.
*
* @param string $page
* @todo make it posible to load a php file with the original url as parameter.
*/
function loadErrorPage($page){
if(file_exists(TO_WEB_ROOT ."/pages/$page.html")){
header("Location: ". SYSTEM_WEB_ROOT . "/pages/$page.html");
} else {
header('Content-Type: text/html; charset=UTF-8');
readfile(THAFRAME . "/pages/$page.html");
}
die();
}
function strleft($s1, $s2)
{
return substr($s1, 0, strpos($s1, $s2));
}
function t(){
global $_translation;
if ( func_num_args()<= 0 ) {
throw new LengthException('Translation function expects at least one parameter.');
}
$original = (string)func_get_arg(0);
$search = array();
$replace = array();
for ($i = 1;$i < func_num_args();$i++) {
$search[] = "%$i%";
$replace[] = func_get_arg($i);
}
if ( array_key_exists($original, $_translation) ){
$original = $_translation[$original];
}
return str_replace($search, $replace, $original);
}
?>