git.iko.soy/ilyakooo0.github.io
on 4749638 help sign in
122 lines 4.2 kB history raw
1<?php
3session_start();
5// File locations.
6$settings_file = "../config.php";
7$htaccess_file = "../.htaccess";
8$phpass_file = '../dropplets/includes/phpass.php';
10// Get existing settings.
11if (file_exists($settings_file)) {
12 include($settings_file);
14if (file_exists($phpass_file))
16 include($phpass_file);
17 $hasher = new PasswordHash(8,FALSE);
19function settings_format($name, $value) {
20 return sprintf("\$%s = \"%s\";", $name, $value);
23/*-----------------------------------------------------------------------------------*/
24/* Save Submitted Settings
25/*-----------------------------------------------------------------------------------*/
27// Should allow this only on first install or after the user is authenticated
28// but this doesn't quite work. So back to default.
29if ($_POST["submit"] == "submit" && (!file_exists($settings_file) || isset($_SESSION['user'])))
31 // Get submitted setup values.
32 if (isset($_POST["blog_email"])) {
33 $blog_email = $_POST["blog_email"];
34 }
35 if (isset($_POST["blog_twitter"])) {
36 $blog_twitter = $_POST["blog_twitter"];
37 }
38 if (isset($_POST["blog_url"])) {
39 $blog_url = $_POST["blog_url"];
40 }
41 if (isset($_POST["blog_title"])) {
42 $blog_title = $_POST["blog_title"];
43 }
44 if (isset($_POST["meta_description"])) {
45 $meta_description = $_POST["meta_description"];
46 }
47 if (isset($_POST["intro_title"])) {
48 $intro_title = $_POST["intro_title"];
49 }
50 if (isset($_POST["intro_text"])) {
51 $intro_text = $_POST["intro_text"];
52 }
53 if (isset($_POST["template"])) {
54 $template = $_POST["template"];
55 }
57 // There must always be a $password, but it can be changed optionally in the
58 // settings, so you might not always get it in $_POST.
59 if (!isset($password) || !empty($_POST["password"])) {
60 $password = $hasher->HashPassword($_POST["password"]);
61 }
63 if(!isset($header_inject)) {
64 $header_inject = "";
65 }
67 if(isset($_POST["header_inject"])) {
68 $header_inject = addslashes($_POST["header_inject"]);
69 }
71 if(!isset($footer_inject)) {
72 $footer_inject = "";
73 }
75 if(isset($_POST["footer_inject"])) {
76 $footer_inject = addslashes($_POST["footer_inject"]);
77 }
79 // Get subdirectory
80 $dir .= str_replace('dropplets/save.php', '', $_SERVER["REQUEST_URI"]);
82 // Output submitted setup values.
83 $config[] = "<?php";
84 $config[] = settings_format("blog_email", $blog_email);
85 $config[] = settings_format("blog_twitter", $blog_twitter);
86 $config[] = settings_format("blog_url", $blog_url);
87 $config[] = settings_format("blog_title", $blog_title);
88 $config[] = settings_format("meta_description", $meta_description);
89 $config[] = settings_format("intro_title", $intro_title);
90 $config[] = settings_format("intro_text", $intro_text);
91 $config[] = "\$password = '".$password."';";
92 $config[] = settings_format("header_inject", $header_inject);
93 $config[] = settings_format("footer_inject", $footer_inject);
94 $config[] = settings_format("template", $template);
96 // Create the settings file.
97 file_put_contents($settings_file, implode("\n", $config));
99 // Generate the .htaccess file on initial setup only.
100 if (!file_exists($htaccess_file)) {
102 // Parameters for the htaccess file.
103 $htaccess[] = "# Pretty Permalinks";
104 $htaccess[] = "RewriteRule ^(images)($|/) - [L]";
105 $htaccess[] = "RewriteCond %{REQUEST_URI} !^action=logout [NC]";
106 $htaccess[] = "RewriteCond %{REQUEST_URI} !^action=login [NC]";
107 $htaccess[] = "Options +FollowSymLinks -MultiViews";
108 $htaccess[] = "RewriteEngine on";
109 $htaccess[] = "RewriteBase " . $dir;
110 $htaccess[] = "RewriteCond %{REQUEST_URI} !index\.php";
111 $htaccess[] = "RewriteCond %{REQUEST_FILENAME} !-f";
112 $htaccess[] = "RewriteRule ^(.*)$ index.php?filename=$1 [NC,QSA,L]";
114 // Generate the .htaccess file.
115 file_put_contents($htaccess_file, implode("\n", $htaccess));
116 }
118 // Redirect
119 header("Location: " . $blog_url);
122?>