register_tag( "loremipsum", function($ste, $params, $sub) { $repeats = empty($params["repeat"]) ? 1 : $params["repeat"] + 0; return implode("\n\n", array_repeat("

Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

\n\n

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.

\n\n

Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

\n\n

Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

\n\n

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis.

\n\n

At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.

\n\n

Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

", $repeats)); } ); /* start session and check auth. */ session_start(); $user = NULL; if(isset($_SESSION["r7r_repo_login_name"])) { try { $user = User::by_name($_SESSION["r7r_repo_login_name"]); } catch(DoesNotExistError $e) { unset($_SESSION["r7r_repo_login_name"]); } } /* url handlers */ $url_handlers = array( "_prelude" => function(&$data, $url_now, &$url_next) { global $ste, $settings, $user; if(@$settings["setup_finished"]) $ste->vars["repo"] = array( "name" => $settings["repo_name"], "description" => $settings["repo_description"], "baseurl" => $settings["repo_baseurl"], "public" => ($settings["repo_mode"] == "public") ); if($user === NULL) $ste->vars["user"] = array( "logged_in" => False, "admin" => False ); else $ste->vars["user"] = array( "logged_in" => True, "name" => $user->name, "admin" => $user->isadmin ); }, "_notfound" => url_action_simple(function($data) { header("HTTP/1.1 404 Not Found"); header("Content-Type: text/plain"); echo "404 Not Found\nThe resource \"{$_SERVER["REQUEST_URI"]}\" could not be found.\n"; }), "_index" => url_action_alias(array("index")), "index" => function(&$data, $url_now, &$url_next) { global $ste; $url_next = array(); $ste->vars["menu"] = "home"; $latest = Package::latest(); $ste->vars["latest_pkgs"] = array_map(function($pkg) { return array( "name" => $pkg->get_name(), "version" => $pkg->txtversion, "description" => $pkg->description, "last_update" => $pkg->lastversion ); }, $latest); echo $ste->exectemplate("home.html"); }, "setup" => function(&$data, $url_now, &$url_next) { global $settings, $ste; /* If initial setup was already finished, nobody should be allowed to access this. */ if(@$settings["setup_finished"]) throw new NotFoundError(); $url_next = array(); /* Test file permissions */ $permissions_missing = array_filter(array("/packages", "/packagelist", "/repometa"), function($f) { return !@is_writable(dirname(__FILE__) . "/..$f"); }); if(!empty($permissions_missing)) $ste->vars["error"] = "No writing permissions on these files/directories: \"" . implode("\", \"", $permissions_missing) . "\""; else { /* Check input */ if(!empty($_POST["send_data"])) { if(empty($_POST["admin_name"]) or empty($_POST["admin_password"]) or empty($_POST["repo_name"]) or empty($_POST["repo_description"]) or empty($_POST["repo_baseurl"]) or (($_POST["repo_mode"] != "public") and ($_POST["repo_mode"] != "private"))) $ste->vars["error"] = "Form not filled out completely"; else { /* Insert data */ $admin = User::create($_POST["admin_name"]); $admin->pwhash = PasswordHash::create($_POST["admin_password"]); $admin->isadmin = True; $admin->save(); $settings["repo_name"] = $_POST["repo_name"]; $settings["repo_description"] = $_POST["repo_description"]; $settings["repo_baseurl"] = $_POST["repo_baseurl"]; $settings["repo_mode"] = $_POST["repo_mode"]; update_repometa(); $settings["setup_finished"] = True; $url_next = array("index"); return; } } } $ste->vars["baseurl_predicted"] = self_url(); echo $ste->exectemplate("setup.html"); } ); /* bootstrapping... */ $urlpath = explode("/", $_GET["action"]); $rel_path_to_root = implode("/", array_merge(array("."), array_repeat("..", count($urlpath) - 1))); $GLOBALS["rel_path_to_root"] = $rel_path_to_root; $data = array("rel_path_to_root" => $rel_path_to_root); $ste->vars["rel_path_to_root"] = $rel_path_to_root; /* Enforce setup */ if(!@$settings["setup_finished"]) $urlpath = array("setup"); /*try {*/ url_process($urlpath, $url_handlers, $data); /*} catch(Exception $e) { header("HTTP/1.1 500 Internal Server Error"); header("Content-Type: text/plain"); echo "Internal Server Error\nReason: " . get_class($e) . "(" . $e->getMessage() . ") thrown.\n"; }*/ /* save settings */ $settings->save(); ?>