+<?php
+
+abstract class cms {
+ private $config_file = '/etc/dylanstestserver.ini';
+ protected $db;
+
+ public function __construct() {
+ $config = parse_ini_file($this->config_file);
+ $this->db = new mysqli(
+ $config['domain'],
+ $config['user'],
+ $config['password'],
+ $config['database']);
+ if (mysqli_connect_errno()) {
+ echo "Problem connecting to database: ";
+ echo mysqli_connect_error();
+ exit();
+ }
+ ob_start();
+ }
+
+ public static function determine_type() {
+ if (isset($_GET['page']) && is_numeric($_GET['page'])) {
+ return 'page';
+ } else if (isset($_GET['note'])) {
+ return 'note';
+ } else if ($_SERVER['REQUEST_URI'] == '/') {
+ return 'index';
+ } else if (isset($_GET['project'])) {
+ return 'project';
+ }
+ }
+
+ public function query() {
+ $args = func_get_args();
+ $statement = $this->db->prepare($args[0]);
+ $args = array_slice($args, 1);
+ call_user_func_array(array($statement, 'bind_param'), &$args);
+ $statement->execute();
+ $return = array();
+ $statement->store_result();
+ $row = array();
+ $data = $statement->result_metadata();
+ $fields = array();
+ $fields[0] = &$statement;
+ while($field = $data->fetch_field()) {
+ $fields[] = &$row[$field->name];
+ }
+ call_user_func_array("mysqli_stmt_bind_result", $fields);
+ $i = 0;
+ while ($statement->fetch()) {
+ foreach ($row as $key1=>$value1) $return[$i][$key1] = $value1;
+ $i++;
+ }
+ $statement->free_result();
+ return $return;
+ }
+
+ public function display_head($title = "dylanstestserver",
+ $home_link = "/") {
+ $scripts = "";
+ $stylesheets = "<link href=\"/includes/style.css\" rel=\"stylesheet\" type=\"text/css\">";
+ if (cms::determine_type() == "index") {
+ $scripts = "<script type=\"text/javascript\" src=\"/includes/all.js\">";
+ $home_link = "http://validator.w3.org/unicorn/check?ucn_uri=dylanstestserver.com&ucn_task=conformance#";
+ }
+ echo <<<END_OF_HEAD
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">