X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=index.php;h=e58f7372827636c539df32504df2a1c2b96925a0;hb=2cf7880d4afdde09707d4fc62e82597d6bfea7a0;hp=dbff9a520ec50ec5799ef37495a4be30c61dc56e;hpb=0d5b65dd317eda7cd09d208c634067c4a9acb6fd;p=dylansserver.git diff --git a/index.php b/index.php index dbff9a5..e58f737 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,83 @@ +config_file, true); + $this->db = new mysqli( + $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']; + $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 'index'; + } else if (isset($_GET['project'])) { + return 'project'; + } else if (isset($_GET['rss'])) { + return 'rss'; + } 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; + } + + public function display_head($title = "dylansserver", + $home_link = "/") { + $scripts = $this->scripts; + $stylesheets = ""; + $home_link = "http://validator.w3.org/unicorn/check?ucn_uri=dylansserver.com&ucn_task=conformance#"; + echo << @@ -7,66 +87,60 @@ "HTML Tidy for Linux (vers 25 March 2009), see www.w3.org"> - dylanstestserver - - - + $this->title + + $stylesheets + $scripts - + - - + - - - - - - - my projects: - - - repthis.info +END_OF_HEAD; + } - youtube_backup + public function display_contact() { + echo <<dylan@psu.edu + +END_OF_CONTACT; + } - i_like_pandora + public function display_close($show_contact = true) { + if ($show_contact) { + $this->display_contact(); + } + echo << + + + + + +END_OF_CLOSE; + ob_flush(); + } - foxy-addons/peepshow +} - drawcss - readoo +class index extends cms { + public function display() { + $this->scripts = ""; + $this->display_head(); + $this->display_exhibits(); + echo ""; + $this->list_projects(); + echo << things i've done for others: @@ -89,23 +163,602 @@ git://dylanstestserver.com + "git">git://dylansserver.com some notes: here + "/notes/">here [rss] - dylan@psu.edu - - - - -