testing fullscreen video on why-guy.com
Using the jQuery plugin bigvideo.js its possible to load MP4 OGG and ... let try if we can display a (live) streamControler:
defined('BASEPATH') OR exit('No direct script access allowed');
class Site extends CI_Controller {
public function __construct(){
parent::__construct(); // load the constructor from the parent class
$date = date("Y-m-d"); // used for logging
$time = date("H:i:s"); // used for logging
$ip = $_SERVER['REMOTE_ADDR']; // used for logging
$this->load->helper('url'); // load the helper object used for redirects
$this->load->library('parser'); // load the parser
$this->load->database(); // load the database
$this->load->model('iplog_model'); // load the news model
$this->load->helper('html');
$this->meta = array(array('name' => 'robots',
'content' => 'no-cache'),
array('name' => 'keywords',
'content' => 'why-guy.com, curious, blog, gallery, tech, development, security, fun'),
array('name' => 'description',
'content' => 'why-guy.com galleries. Read the blog for tech, security, development and fun ..'),
array('name' => 'author',
'content' => 'guy ten bruggencate'),
array('name' => 'revisit-after',
'content' => '1 month'),
array('name' => 'Content-type',
'content' => 'text/html; charset=utf-8', 'type' => 'equiv'));
$this->headerData = array("metatags" => meta($this->meta));
if($this->iplog_model->checkIfIpExists($ip) == TRUE){
$this->iplog_model->updateFromIplink($ip, $date, $time); //known address update record
}ELSE{
$dns = gethostbyaddr($ip);
$this->iplog_model->insertIntoIplink($ip, $dns, $date, $time); //new address insert into ip_link
}
$this->iplog_model->insertIntoIplog($ip, $_SERVER['REQUEST_URI'], $date, $time); //always write to the log
}
public function index(){
redirect('/','refresh'); //redirect the page
}
/*
* sitemap
*/
public function map(){
//build the news map -> categories
$catNewsMap[]=array("slug" => "http://www.why-guy.com/blog/bycategory/development/",
"changefreq"=> "weekly",
"title" => "");
$catNewsMap[]=array("slug" => "http://www.why-guy.com/blog/bycategory/security/",
"changefreq"=> "weekly",
"title" => "");
$catNewsMap[]=array("slug" => "http://www.why-guy.com/blog/bycategory/projects/",
"changefreq"=> "weekly",
"title" => "");
$catNewsMap[]=array("slug" => "http://www.why-guy.com/blog/bycategory/fun/",
"changefreq"=> "weekly",
"title" => "");
//build the news map -> search blogs
$query = $this->db->query('SELECT `name`,`date`,`time` FROM news');
foreach($query->result_array() as $row){
$searchNewsMap[]=array("slug" => "http://www.why-guy.com/blog/read/".str_replace(" ","-",$row['name'])."/",
"last_mod" => $row['date']."T".$row['time'],
"title" => $row['name']);
}
//build the news map -> search blogs
$query = $this->db->query('SELECT `name`,`date`,`time` FROM news');
foreach($query->result_array() as $row){
$readNewsMap[]=array("slug" => "http://www.why-guy.com/blog/search/".str_replace(" ","-",$row['name'])."/",
"last_mod" => $row['date']."T".$row['time'],
"title" => $row['name']);
}
//build the news map -> alfabet
$alfabet = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","q","r","s","t","u","v","w","x","y","z");
foreach($alfabet as $row){
$newsMap[]=array("slug" => "http://www.why-guy.com/blog/search/".$row."/",
"title" => $row);
}
$alfabet = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","q","r","s","t","u","v","w","x","y","z");
foreach($alfabet as $row){
$projectsMap[]=array("slug" => "/why-guy.com/projects/byname/".$row."/0.html",
"title" => $row);
}
//build the image map -> categories
$imageMap[]=array("slug" => "http://www.why-guy.com/gallery/bycategory/tech/",
"title" => "");
$imageMap[]=array("slug" => "http://www.why-guy.com/gallery/bycategory/nature/",
"title" => "");
$imageMap[]=array("slug" => "http://www.why-guy.com/gallery/bycategory/people/",
"title" => "");
$imageMap[]=array("slug" => "http://www.why-guy.com/gallery/bycategory/other/",
"title" => "");
//build the image map -> galleries
/*
$query = $this->db->query('SELECT `name` FROM images');
foreach($query->result_array() as $row){
$newsMap[]=array("slug" => "http://www.why-guy.com/blog/search/".str_replace(" ","-",$row['name'])."/",
"title" => $row['name']);
}
*/
$data = array("news_map" => $newsMap,
"cat_news_map" => $catNewsMap,
"search_news_map" => $searchNewsMap,
"read_news_map" => $searchNewsMap,
"image_map" => $imageMap,
"page_title" => "sitemap");
//created slug and uri
//add to array
$this->parser->parse('site/map',$data);
}
public function stats(){
$data = array("page_title" => "todays stats",
"hits_today" => $this->iplog_model->countTodaysHits(),
"visits_today"=> $this->iplog_model->countTodaysVisits(),
"all_hits" => $this->iplog_model->countAllHits(),
"all_visits" => $this->iplog_model->countAllVisits());
$this->headerData["page_title"] = "todays stats"; //add title to header array
$this->parser->parse('templates/header',$this->headerData);
$this->parser->parse('site/stats',$data);
$this->parser->parse('templates/footer',$data);
}
/*
* contact form
*/
public function contact(){
$formsubject = date("Y-m-d H:i:s")." | ".
$_SERVER['REMOTE_ADDR']." | why-guy.com/site/contact";
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('name', 'Name', 'trim|required|min_length[3]|max_length[50]');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|callback_email_check');
$this->form_validation->set_rules('comment', 'Comment', 'trim|required|min_length[5]|max_length[120]');
//FAIL form rules are not met
if ($this->form_validation->run() == FALSE){
$data = array("page_title" => "contact me",
"form_subject"=> $formsubject,
"form_button" => "");
$this->headerData["page_title"] = "contact me"; //add title to header array
$this->parser->parse('templates/header',$this->headerData);
$this->parser->parse('site/contact',$data);
$this->parser->parse('templates/footer',$data);
//SUCCES form rules are met
}else{
$name = trim(addslashes($_POST['name']));
$email = trim(addslashes($_POST['email']));
$comment = trim(addslashes($_POST['comment']));
$message = "name: ".$name."\n\n".
"email: ".$email."\n\n".
"comment: ".$comment;
//now insert this into the database
$this->load->library('email');
$this->email->from('noreply@why-guy.com', 'site mail');
$this->email->to('guy@why-guy.com');
//$this->email->cc('another@another-example.com');
//$this->email->bcc('them@their-example.com');
$this->email->subject($formsubject);
$this->email->message($message);
$this->email->send();
$data = array("page_title" => "contact me",
"form_subject"=> $formsubject,
"form_button" => " Thank you, your form is send ");
$this->parser->parse('templates/header',$data);
$this->parser->parse('site/contact',$data);
$this->parser->parse('templates/footer',$data);
}
}
/*
* domain checker used for the contact form (above)
*/
public function email_check($str){
$domainname = explode("@",$str);
if (dns_get_record($domainname['1']) == FALSE){
$this->form_validation->set_message('email_check', 'The {field} field contains a invalid domainname');
return FALSE;
}
else{
return TRUE;
}
}
/*
* show available services
*/
public function services(){
$data = array("page_title" => "available services");
$this->headerData["page_title"] = "contact me"; //add title to header array
$this->parser->parse('templates/header',$this->headerData);
$this->parser->parse('site/services',$data);
$this->parser->parse('templates/footer',$data);
}
}