name = safe_post("name"); $this->tmp_name = $_FILES["file"]["tmp_name"]; } } public function output() { output_head("extensions", "baretorrent - extensions"); echo '
Name: ' . html::text("name") . '
File: ' . html::file("file") . '
' . html::submit("add") . '
'; } public function go() { try { db()->begin(); $id = $this->add_to_database(); $this->add_wiki(); db()->commit(); header("Location: index.html?id=$id"); return true; } catch(internal_7z_error $e) { echo "internal 7z error"; } catch(bad_7z_file $e) { echo "bad 7z file"; } catch(bad_guid $e) { echo "bad guid"; } catch(extension_already_exists $e) { echo "an extension with the name " . "'" . $e->extension()->name() . "' " . "already exists"; } catch(guid_already_exists $e) { echo "guid '" . $e->extension()->guid() . "' " . "already exists for extension " . "'" . $e->extension()->name() . "'"; } catch(wiki_login_failed $e) { echo "wiki login failed"; } catch(wiki_edit_token_failed $e) { echo "wiki edit token failed"; } catch(wiki_edit_failed $e) { echo "wiki edit failed"; } return false; } private function add_to_database() { return add_extension($this->name, $this->tmp_name); } private function add_wiki() { wiki::save($this->name . "/", $this->name); } } set_this_link("ext"); $a = new extension_adder(); if (isset($_POST["submit"])) { if ($a->go()) exit; } $a->output(); ?>