File: /home/harmonyg/www/classes/ACore.php
<?php
abstract class ACore {
protected $db;
public function __construct() {
global $mysqli;
$mysqli = new mysqli(HOST, USER, PASSWORD, DB);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result = mysqli_query($mysqli,"SET NAMES 'UTF8'");
// $this->db = mysql_connect(HOST, USER, PASSWORD);
// if(!$this->db) {
// exit("DB connection error ".mysql_error());
// }
// if(!mysql_select_db(DB,$this->db)) {
// exit("DB does not exist ".mysql_error());
// }
// mysql_query("SET NAMES 'UTF8'");
}
public function is_mobile() {
return false;
}
public function get_header() {
if(preg_match('/(?i)msie [1-8]/',$_SERVER['HTTP_USER_AGENT']))
{
include "headerIE8.php";
}
else
{
if ( (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') || strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') || strpos($_SERVER['HTTP_USER_AGENT'], 'Trident')) && !strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') )
{
include "headerIE.php";
}
else
{
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') )
{
//if(isset($_SERVER["HTTP_USER_AGENT"])){
// $user_agents = array("midp", "j2me", "avantg", "docomo", "novarra", "palmos", "palmsource", "240x320", "opwv", "chtml", "pda", "windows\ ce", "mmp\/", "blackberry", "mib\/", "symbian", "wireless", "nokia", "hand", "mobi", "phone", "cdm", "up\.b", "audio", "SIE\-", "SEC\-", "samsung", "HTC", "mot\-", "mitsu", "sagem", "sony", "alcatel", "lg", "erics", "vx", "NEC", "philips", "mmm", "xx", "panasonic", "sharp", "wap", "sch", "rover", "pocket", "benq", "java", "pt", "pg", "vox", "amoi", "bird", "compal", "kg", "voda", "sany", "kdd", "dbt", "sendo", "sgh", "gradi", "jb", "\d\d\di", "moto");
// foreach($user_agents as $user_string){
// if(preg_match("/".$user_string."/i",$_SERVER["HTTP_USER_AGENT"])) {
$mobile_agents = '!(tablet|pad|mobile|phone|symbian|android|ipod|ios|blackberry|webos)!i';
if (preg_match($mobile_agents, $_SERVER['HTTP_USER_AGENT'])) {
// Mobile!
include "header1.php";
}
else
{
include "header.php";
}
// }
// }
//}
//else
//{
// include "header1.php";
//}
}
else
{
include "header1.php";
}
}
}
}
public function get_widget() {
// ending of main block
//echo '</div><!-- #post-## -->
//</div><!-- #content -->
//</div><!-- #container -->
// ';
include "widget.php";
}
public function get_footer() {
include "footer.php";
}
public function get_menu() {
$row = $this->menu_array();
echo '<DIV id="access" role="navigation">
<DIV class="skip-link screen-reader-text"><A title="Skip to content" href="http://www.harmonygardens.ie/#content">Skip to content</A></DIV>
<DIV id="accessfix" role="navigation"></DIV><DIV class="menu-header">
<UL class="menu" id="menu-main-menu">
';
//<LI class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item home" id="Home"><A href="?option=main">Home</A></LI>
$i = 1;
foreach($row as $item) {
$row1 = $this->submenu_array($item['id_menu']);
if($i != count($row)) {
if(!($row1)) printf("<LI class='menu-item' id='%s'><A href='?option=menu&id_menu=%s'>%s</A>
",$item['menu_name'],$item['id_menu'],$item['menu_name']);
else printf("<LI class='menu-item' id='%s'><A href='#'>%s</A>
",$item['menu_name'],$item['menu_name']);
}
else
{
printf("<LI class='menu-item contact' id='contact'><A href='?option=menu&id_menu=%s'>%s</A>
",$item['id_menu'],$item['menu_name']);
}
if(($row1)) {
echo ' <UL class="sub-menu">
';
foreach($row1 as $item1) {
printf("<LI class='menu-item' id='%s'><A href='?option=submenu&id_submenu=%s'>%s</A></LI>
",$item1['submenu_name'],$item1['id_submenu'],$item1['submenu_name']);
}
echo '
</UL>
';
}
echo '
</LI>';
$i++;
}
echo '<DIV id="accessfix1" role="navigation"></DIV></DIV></DIV><!-- #access -->
</DIV> <!-- #header -->
';
// header's part before main block input
//echo ' <div id="container">
// <div id="content" role="main">
// <div id="post-467" class="post-467 page type-page status-publish hentry">';
}
protected function menu_array() {
global $mysqli;
//$query = "SELECT id_menu, menu_name, menu_level, menu_content, project_id FROM menu";
$query = "SELECT id_menu, menu_name FROM menu WHERE ((menu_name <> '') AND (menu_name IS NOT NULL))";
$result = $mysqli->query($query);
if(!$result) {
exit($mysqli->error);
}
// $result = mysql_query($query);
// if(!$result) {
// exit(mysql_error());
// }
$row = array();
for($i = 0;$i < mysqli_num_rows($result); $i++) {
$row[] = $result->fetch_assoc();
// $row[] = mysql_fetch_array($result, MYSQL_ASSOC);
}
return $row;
}
protected function submenu_array($menu_id) {
global $mysqli;
//$query = "SELECT id_menu, menu_name, menu_level, menu_content, project_id FROM menu";
$query = "SELECT id_submenu, submenu_name FROM submenu WHERE id_menu='$menu_id'";
//$result = mysql_query($query);
$result = $mysqli->query($query);
if(!$result) {
exit($mysqli->error);
}
// $result = mysql_query($query);
// if(!$result) {
// exit(mysql_error());
// }
$row = array();
for($i = 0;$i < mysqli_num_rows($result); $i++) {
$row[] = $result->fetch_assoc();
// $row[] = mysql_fetch_array($result, MYSQL_ASSOC);
}
return $row;
}
public function get_body() {
if($_POST) {
$this->obr();
}
$this->get_header();
$this->get_menu();
$this->get_content();
$this->get_widget();
$this->get_footer();
}
abstract function get_content();
}
?>