Bystac.net

everything I ever wanted is a minimal design (I'm minimalist freak!)...

the source,
X/X/2007
<?php    
/* Dispatcher */
    
$_page = isset($_GET['p']) 
            && !empty(
$_GET['p']) 
                ? 
$_GET['p'] : 'index';
/* End Dispatcher*/

/* Controller code :) */
    
$toView = array();
    
    switch (
get_post('action')) 
    {
        case 
'doContact':
            
$email get_post('email');
            
$subject get_post('email');
            
$message get_post('email');
            if (
$subject!=false 
                
&& $message!=false
                
&& $email!=false)
            {
                    
                
$res mail(get_myemail(), 
                    
'Contact From Bystac '.date('d/m/Y'),
                    
'email:'.htmlentities($email)."\n".
                    
'Subject:'.htmlentities($subject)."\n".
                    
'Message:'.htmlentities($message)."\n");
                    
                if (
$res) {
                    
$toView['response']    = 'Message sent. thank you.';
                } else {
                    
$toView['response']    = 'Message not sent. try again!';
                }
            }
            break;
    
        default:
            break;
    }

    
load_template($_page$toView);
/* End Controller */


/**********************/
/*      MVC FRAMEWORK   */

function get_post($name)
{
    
$value = isset($_POST[$name]) ? $_POST[$name] : '';

    return empty(
$value) ?  false $value;
}
//end get_post();

function get_myemail() 
{
    return 
'ihpraimov'.'@'.'gmail'.'com';
}

function 
load_template($name$vars=array())
{
    
$dir_templates $_SERVER['DOCUMENT_ROOT'].'/bystac/';
    
$template $dir_templates.$name.'.tpl.php';
    
    if (
is_template($template) == false)
    {
        return 
false;
    }
    
    
ob_start();
        if ( 
count($vars)>) {
            
extract($vars);
        }
        include_once 
$template;        
        
$content ob_get_contents();
    
ob_end_clean();
    
    include 
$dir_templates.'template.tpl.php';
}
//end load_template()

function is_template($name)
{    
    if ( ! 
file_exists($name) )
    {            
        print 
'<div class="box_error">
                Internal Error: template not found, admin notified.
</div>'
;
        exit;
    }
    
    return 
true;
}
//end is_template()


?>


Web traffic statistics bystac