X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;ds=sidebyside;f=index.php;h=424f8504ab4d03fb8543098316d628ee6cafa134;hb=ed22b7f1393fb7102beb9bbfad22864c2d4acb7a;hp=3f64a27ddede8d88af26808b788ebc95b0b9b0c6;hpb=0a144953e57bf457df61e58a3f94b0178c1f9707;p=dylansserver.git diff --git a/index.php b/index.php index 3f64a27..424f850 100644 --- a/index.php +++ b/index.php @@ -1,84 +1,88 @@ config_file, true); $this->db = new mysqli( - $config[database]['domain'], - $config[database]['user'], - $config[database]['password'], + $config[database]['domain'], + $config[database]['user'], + $config[database]['password'], $config[database]['database']); - if (mysqli_connect_errno()) { - echo "Problem connecting to database: "; - echo mysqli_connect_error(); - exit(); - } - $this->recaptcha_publickey = $config[recaptcha]['publickey']; - $this->recaptcha_privatekey = $config[recaptcha]['privatekey']; - ob_start(); + if (mysqli_connect_errno()) { + echo "Problem connecting to database: "; + echo mysqli_connect_error(); + exit(); + } + $this->recaptcha_publickey = $config['recaptcha']['publickey']; + $this->recaptcha_privatekey = $config['recaptcha']['privatekey']; + $this->title = $config['site']['default_title']; + $this->home_link = $config['site']['home_link']; + ob_start(); } public static function determine_type() { if (isset($_GET['page']) && is_numeric($_GET['page'])) { - return 'page'; - } else if (isset($_GET['year'])) { - return 'archive'; - } else if (isset($_GET['note'])) { - return 'note'; - } else if ($_SERVER['REQUEST_URI'] == '/') { + return 'page'; + } else if (isset($_GET['year'])) { + return 'archive'; + } else if (isset($_GET['note'])) { + return 'note'; + } else if ($_SERVER['REQUEST_URI'] == '/') { return 'index'; - } else if (isset($_GET['project'])) { + } else if (isset($_GET['project'])) { return 'project'; - } else if (isset($_GET['challenge'])) { + } else if (isset($_GET['challenge'])) { return 'captcha'; - } - + } } 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 $key=>$value) $return[$i][$key] = $value; - $i++; - } - $statement->free_result(); - return $return; - } + $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 $key=>$value) $return[$i][$key] = $value; + $i++; + } + $statement->free_result(); + return $return; + } public function display_head($title = "dylanstestserver", - $home_link = "/") { + $home_link = "/") { $scripts = ""; - $stylesheets = ""; - if (cms::determine_type() == "index") { - $scripts = ""; - $home_link = "http://validator.w3.org/unicorn/check?ucn_uri=dylanstestserver.com&ucn_task=conformance#"; - } else if ($this->determine_type() == 'note') { - $scripts = ""; - $scripts .= ""; - $scripts .= ""; - $scripts .= ""; - } - echo <<"; + if (cms::determine_type() == "index") { + $scripts = ""; + $home_link = "http://validator.w3.org/unicorn/check?ucn_uri=dylanstestserver.com&ucn_task=conformance#"; + } else if ($this->determine_type() == 'note') { + $scripts = ""; + $scripts .= ""; + $scripts .= ""; + $scripts .= ""; + } + echo << @@ -88,7 +92,7 @@ abstract class cms { "HTML Tidy for Linux (vers 25 March 2009), see www.w3.org"> - $title + $this->title $stylesheets $scripts @@ -97,7 +101,7 @@ abstract class cms { - + @@ -111,36 +115,36 @@ END_OF_HEAD; dylan@psu.edu - + END_OF_CONTACT; } public function display_close($show_contact = true) { if ($show_contact) { - $this->display_contact(); - } + $this->display_contact(); + } echo << - +