class error_messages
{
/**
* Display error message
*
* @param string $file
* @param int $line
* @param string $message
*/
function Show_Error( $file, $line, $message )
{
$file_view = str_replace(".php", "", $file);
if( defined("_IS_CLI") )
{
$m = "FILE: {$file}\n* LINE: {$line}\n* MESS:{$message}";
Message($m);
die();
}
if( defined("_DEBUG") )
{
include_once(_JANEAIR_ROOT."janeair_error2.php");
} else {
include_once(_JANEAIR_ROOT."janeair_error3.php");
if( defined("_DEBUG_EMAIL") )
{
package("smtp/sendmail");
$body = "FILE: {$file}.
LINE: {$line}
MESS: {$message}";
SendMail(_DEBUG_EMAIL, "error on site:". getenv("HTTP_HOST"), $body);
}
}
include_once(_JANEAIR_ROOT."/core/done.php");
}
/**
* Enter description here...
*
* @param string $file
* @param int $line
*/
function ShowCode($file, $line, $end = 3)
{
$f = file($file);
$loop = true;
$i = 0;
$start = $line - $end ;
while ($loop)
{
$f[$start] = htmlspecialchars($f[$start]);
$f[$start] = str_replace("\t", " ", $f[$start]);
if( $start != ($line-1) ) { $return .= "
". ($start+1) ." ". $f[$start] ."
"; }
else {
$return .= "". ($start+1) ." ". $f[$start] ."
";
}
$start++;
if( $start > ($line + $end) ) { $loop = false; }
}
return $return;
}
/**
* Inform users that he requested non-existen controller
*
* @param null
*/
function unexists_controller()
{
if( _DEBUG == "true" ) {
error_messages::Show_Error(__FILE__,__LINE__,"Controller {$_GET['controller']} does not exists");
} else {
header("Location: /");
die();
}
}
function unexists_sub_controller()
{
if( defined("_DEBUG") ) {
die("Controller {$_GET['controller']}/{$_GET['action']} does not exists");
} else {
header("Location: /");
die();
}
}
function UnexistenDomain($host)
{
global $template;
$arr['domain'] = str_replace("www.","","".$_SERVER['SERVER_NAME']."");
echo $template -> Assign("common", "janeair", $arr);
die();
}
function suspended()
{
global $template;
$arr['domain'] = str_replace("www.","","".$_SERVER['SERVER_NAME']."");
echo $template -> Assign("common", "suspended", $arr);
die();
}
function forbiden()
{
echo "Forbiden: {$_SERVER['REQUEST_URI']}";
die();
}
}
function MD($f, $l)
{
error_messages::Show_Error($f, $l, sql::err());
}
function MDC($l)
{
echo "\n---------------------ERROR--------------------\nLINE:{$l}\nMESS:".mysql_error()."\n";
die();
}
?>
class helper
{
function Load($block_name)
{
if( file_exists("./blocks/{$block_name}.php") )
{
include_once("./blocks/{$block_name}.php");
eval("{$block_name}::Main();");
return;
}
if( file_exists(_JANEAIR_ROOT_CMS."/blocks/{$block_name}.php") )
{
include_once(_JANEAIR_ROOT_CMS."/blocks/{$block_name}.php");
eval("{$block_name}::Main();");
return;
}
}
}
?>
class HTMLForms
{
function Add($link)
{
return template::Assign("common", "add_button", array("link" => $link));
}
/**
* Create form element