KXStudio Website https://kx.studio/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

install.php.bak 31KB

9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. <?php
  2. header("Content-type: text/html; charset=UTF-8");
  3. define('DEBUG', true);
  4. define('JAVASCRIPT', false);
  5. define('ADMIN', false);
  6. define('AJAX', false);
  7. define('XML_RPC', false);
  8. define('TRACKBACK', false);
  9. define('UPGRADING', false);
  10. define('INSTALLING', true);
  11. define('TESTER', isset($_SERVER['HTTP_USER_AGENT']) and $_SERVER['HTTP_USER_AGENT'] == "tester.rb");
  12. define('MAIN_DIR', dirname(__FILE__));
  13. define('INCLUDES_DIR', MAIN_DIR."/includes");
  14. define('USE_ZLIB', false);
  15. # Make sure E_STRICT is on so Chyrp remains errorless.
  16. error_reporting(E_ALL | E_STRICT);
  17. ini_set('display_errors', true);
  18. ob_start();
  19. if (version_compare(PHP_VERSION, "5.2.0", "<"))
  20. exit("Chyrp requires PHP 5.2.0 or greater. Installation cannot continue.");
  21. require_once INCLUDES_DIR."/helpers.php";
  22. require_once INCLUDES_DIR."/lib/gettext/gettext.php";
  23. require_once INCLUDES_DIR."/lib/gettext/streams.php";
  24. require_once INCLUDES_DIR."/lib/YAML.php";
  25. require_once INCLUDES_DIR."/lib/PasswordHash.php";
  26. require_once INCLUDES_DIR."/class/Config.php";
  27. require_once INCLUDES_DIR."/class/SQL.php";
  28. require_once INCLUDES_DIR."/class/Model.php";
  29. require_once INCLUDES_DIR."/model/User.php";
  30. # Prepare the Config interface.
  31. $config = Config::current();
  32. # Atlantic/Reykjavik is 0 offset. Set it so the timezones() function is
  33. # always accurate, even if the server has its own timezone settings.
  34. $default_timezone = oneof(ini_get("date.timezone"), "Atlantic/Reykjavik");
  35. set_timezone($default_timezone);
  36. # Sanitize all input depending on magic_quotes_gpc's enabled status.
  37. sanitize_input($_GET);
  38. sanitize_input($_POST);
  39. sanitize_input($_COOKIE);
  40. sanitize_input($_REQUEST);
  41. $url = "http://".$_SERVER['HTTP_HOST'].str_replace("/install.php", "", $_SERVER['REQUEST_URI']);
  42. $index = (parse_url($url, PHP_URL_PATH)) ? "/".trim(parse_url($url, PHP_URL_PATH), "/")."/" : "/" ;
  43. $htaccess = "<IfModule mod_rewrite.c>\nRewriteEngine On\nRewriteBase {$index}\nRewriteCond %{REQUEST_FILENAME} !-f\n".
  44. "RewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule ^.+$ index.php [L]\n</IfModule>";
  45. $path = preg_quote($index, "/");
  46. $htaccess_has_chyrp = (file_exists(MAIN_DIR."/.htaccess") and
  47. preg_match("/<IfModule mod_rewrite\.c>\n([\s]*)RewriteEngine On\n([\s]*)RewriteBase {$path}\n".
  48. "([\s]*)RewriteCond %\{REQUEST_FILENAME\} !-f\n([\s]*)RewriteCond %\{REQUEST_FILENAME\}".
  49. " !-d\n([\s]*)RewriteRule \^\.\+\\$ index\.php \[L\]\n([\s]*)<\/IfModule>/",
  50. file_get_contents(MAIN_DIR."/.htaccess")));
  51. $errors = array();
  52. $installed = false;
  53. if (file_exists(INCLUDES_DIR."/config.yaml.php") and file_exists(MAIN_DIR."/.htaccess")) {
  54. $sql = SQL::current(true);
  55. if ($sql->connect(true) and !empty($config->url) and $sql->count("users"))
  56. error(__("Already Installed"), __("Chyrp is already correctly installed and configured."));
  57. }
  58. if ((!is_writable(MAIN_DIR) and !file_exists(MAIN_DIR."/.htaccess")) or
  59. (file_exists(MAIN_DIR."/.htaccess") and !is_writable(MAIN_DIR."/.htaccess") and !$htaccess_has_chyrp))
  60. $errors[] = _f("STOP! Before you go any further, you must create a .htaccess file in Chyrp's install directory and put this in it:\n<pre>%s</pre>", array(fix($htaccess)));
  61. if (!is_writable(INCLUDES_DIR))
  62. $errors[] = __("Chyrp's includes directory is not writable by the server. In order for the installer to generate your configuration files, please CHMOD or CHOWN it so that Chyrp can write to it.");
  63. if (!empty($_POST)) {
  64. if ($_POST['adapter'] == "sqlite" and !@is_writable(dirname($_POST['database'])))
  65. $errors[] = __("SQLite database file could not be created. Please make sure your server has write permissions to the location for the database.");
  66. else {
  67. $sql = SQL::current(array("host" => $_POST['host'],
  68. "username" => $_POST['username'],
  69. "password" => $_POST['password'],
  70. "database" => $_POST['database'],
  71. "prefix" => $_POST['prefix'],
  72. "adapter" => $_POST['adapter']));
  73. if (!$sql->connect(true))
  74. $errors[] = _f("Could not connect to the specified database:\n<pre>%s</pre>", array($sql->error));
  75. elseif ($_POST['adapter'] == "pgsql") {
  76. new Query($sql, "CREATE FUNCTION year(timestamp) RETURNS double precision AS 'select extract(year from $1);' LANGUAGE SQL IMMUTABLE RETURNS NULL ON NULL INPUT");
  77. new Query($sql, "CREATE FUNCTION month(timestamp) RETURNS double precision AS 'select extract(month from $1);' LANGUAGE SQL IMMUTABLE RETURNS NULL ON NULL INPUT");
  78. new Query($sql, "CREATE FUNCTION day(timestamp) RETURNS double precision AS 'select extract(day from $1);' LANGUAGE SQL IMMUTABLE RETURNS NULL ON NULL INPUT");
  79. new Query($sql, "CREATE FUNCTION hour(timestamp) RETURNS double precision AS 'select extract(hour from $1);' LANGUAGE SQL IMMUTABLE RETURNS NULL ON NULL INPUT");
  80. new Query($sql, "CREATE FUNCTION minute(timestamp) RETURNS double precision AS 'select extract(minute from $1);' LANGUAGE SQL IMMUTABLE RETURNS NULL ON NULL INPUT");
  81. new Query($sql, "CREATE FUNCTION second(timestamp) RETURNS double precision AS 'select extract(second from $1);' LANGUAGE SQL IMMUTABLE RETURNS NULL ON NULL INPUT");
  82. }
  83. }
  84. if (empty($_POST['name']))
  85. $errors[] = __("Please enter a name for your website.");
  86. if (!isset($_POST['timezone']))
  87. $errors[] = __("Time zone cannot be blank.");
  88. if (empty($_POST['login']))
  89. $errors[] = __("Please enter a username for your account.");
  90. if (empty($_POST['password_1']))
  91. $errors[] = __("Password cannot be blank.");
  92. if ($_POST['password_1'] != $_POST['password_2'])
  93. $errors[] = __("Passwords do not match.");
  94. if (empty($_POST['email']))
  95. $errors[] = __("E-Mail address cannot be blank.");
  96. if (empty($errors)) {
  97. if (!$htaccess_has_chyrp)
  98. if (!file_exists(MAIN_DIR."/.htaccess")) {
  99. if (!@file_put_contents(MAIN_DIR."/.htaccess", $htaccess))
  100. $errors[] = _f("Could not generate .htaccess file. Clean URLs will not be available unless you create it and put this in it:\n<pre>%s</pre>", array(fix($htaccess)));
  101. } elseif (!@file_put_contents(MAIN_DIR."/.htaccess", "\n\n".$htaccess, FILE_APPEND)) {
  102. $errors[] = _f("Could not generate .htaccess file. Clean URLs will not be available unless you create it and put this in it:\n<pre>%s</pre>", array(fix($htaccess)));
  103. }
  104. $config->set("sql", array());
  105. $config->set("name", $_POST['name']);
  106. $config->set("description", $_POST['description']);
  107. $config->set("url", $url);
  108. $config->set("chyrp_url", $url);
  109. $config->set("feed_url", "");
  110. $config->set("email", $_POST['email']);
  111. $config->set("locale", "en_US");
  112. $config->set("theme", "stardust");
  113. $config->set("posts_per_page", 5);
  114. $config->set("feed_items", 20);
  115. $config->set("clean_urls", false);
  116. $config->set("post_url", "(year)/(month)/(day)/(url)/");
  117. $config->set("timezone", $_POST['timezone']);
  118. $config->set("can_register", true);
  119. $config->set("default_group", 0);
  120. $config->set("guest_group", 0);
  121. $config->set("enable_trackbacking", true);
  122. $config->set("send_pingbacks", false);
  123. $config->set("enable_xmlrpc", true);
  124. $config->set("enable_ajax", true);
  125. $config->set("uploads_path", "/uploads/");
  126. $config->set("enabled_modules", array());
  127. $config->set("enabled_feathers", array("text"));
  128. $config->set("routes", array());
  129. $config->set("secure_hashkey", md5(random(32, true)));
  130. foreach (array("host", "username", "password", "database", "prefix", "adapter") as $field)
  131. $sql->set($field, $_POST[$field], true);
  132. if ($sql->adapter == "mysql" and class_exists("MySQLi"))
  133. $sql->method = "mysqli";
  134. elseif ($sql->adapter == "mysql" and function_exists("mysql_connect"))
  135. $sql->method = "mysql";
  136. elseif ($sql->adapter == "sqlite" and in_array("sqlite", PDO::getAvailableDrivers()))
  137. $sql->method = "pdo";
  138. $sql->connect();
  139. # Posts table
  140. $sql->query("CREATE TABLE IF NOT EXISTS __posts (
  141. id INTEGER PRIMARY KEY AUTO_INCREMENT,
  142. feather VARCHAR(32) DEFAULT '',
  143. clean VARCHAR(128) DEFAULT '',
  144. url VARCHAR(128) DEFAULT '',
  145. pinned BOOLEAN DEFAULT FALSE,
  146. status VARCHAR(32) DEFAULT 'public',
  147. user_id INTEGER DEFAULT 0,
  148. created_at DATETIME DEFAULT NULL,
  149. updated_at DATETIME DEFAULT NULL
  150. ) DEFAULT CHARSET=utf8");
  151. # Post attributes table.
  152. $sql->query("CREATE TABLE IF NOT EXISTS __post_attributes (
  153. post_id INTEGER NOT NULL ,
  154. name VARCHAR(100) DEFAULT '',
  155. value LONGTEXT,
  156. PRIMARY KEY (post_id, name)
  157. ) DEFAULT CHARSET=utf8");
  158. # Pages table
  159. $sql->query("CREATE TABLE IF NOT EXISTS __pages (
  160. id INTEGER PRIMARY KEY AUTO_INCREMENT,
  161. title VARCHAR(250) DEFAULT '',
  162. body LONGTEXT,
  163. show_in_list BOOLEAN DEFAULT '1',
  164. list_order INTEGER DEFAULT 0,
  165. clean VARCHAR(128) DEFAULT '',
  166. url VARCHAR(128) DEFAULT '',
  167. user_id INTEGER DEFAULT 0,
  168. parent_id INTEGER DEFAULT 0,
  169. created_at DATETIME DEFAULT NULL,
  170. updated_at DATETIME DEFAULT NULL
  171. ) DEFAULT CHARSET=utf8");
  172. # Users table
  173. $sql->query("CREATE TABLE IF NOT EXISTS __users (
  174. id INTEGER PRIMARY KEY AUTO_INCREMENT,
  175. login VARCHAR(64) DEFAULT '',
  176. password VARCHAR(60) DEFAULT '',
  177. full_name VARCHAR(250) DEFAULT '',
  178. email VARCHAR(128) DEFAULT '',
  179. website VARCHAR(128) DEFAULT '',
  180. group_id INTEGER DEFAULT 0,
  181. joined_at DATETIME DEFAULT NULL,
  182. UNIQUE (login)
  183. ) DEFAULT CHARSET=utf8");
  184. # Groups table
  185. $sql->query("CREATE TABLE IF NOT EXISTS __groups (
  186. id INTEGER PRIMARY KEY AUTO_INCREMENT,
  187. name VARCHAR(100) DEFAULT '',
  188. UNIQUE (name)
  189. ) DEFAULT CHARSET=utf8");
  190. # Permissions table
  191. $sql->query("CREATE TABLE IF NOT EXISTS __permissions (
  192. id VARCHAR(100) DEFAULT '',
  193. name VARCHAR(100) DEFAULT '',
  194. group_id INTEGER DEFAULT 0,
  195. PRIMARY KEY (id, group_id)
  196. ) DEFAULT CHARSET=utf8");
  197. # Sessions table
  198. $sql->query("CREATE TABLE IF NOT EXISTS __sessions (
  199. id VARCHAR(40) DEFAULT '',
  200. data LONGTEXT,
  201. user_id INTEGER DEFAULT 0,
  202. created_at DATETIME DEFAULT NULL,
  203. updated_at DATETIME DEFAULT NULL,
  204. PRIMARY KEY (id)
  205. ) DEFAULT CHARSET=utf8");
  206. # This is to let the gettext scanner add these strings to the .pot file.
  207. # They are translated on display via Twig.
  208. # We don't want translated strings in the database.
  209. /* $translations = array(__("Change Settings"),
  210. __("Toggle Extensions"),
  211. __("View Site"),
  212. __("View Private Posts"),
  213. __("View Drafts"),
  214. __("View Own Drafts"),
  215. __("Add Posts"),
  216. __("Add Drafts"),
  217. __("Edit Posts"),
  218. __("Edit Drafts"),
  219. __("Edit Own Posts"),
  220. __("Edit Own Drafts"),
  221. __("Delete Posts"),
  222. __("Delete Drafts"),
  223. __("Delete Own Posts"),
  224. __("Delete Own Drafts"),
  225. __("Add Pages"),
  226. __("Edit Pages"),
  227. __("Delete Pages"),
  228. __("Add Users"),
  229. __("Edit Users"),
  230. __("Delete Users"),
  231. __("Add Groups"),
  232. __("Edit Groups"),
  233. __("Delete Groups")); */
  234. $names = array("change_settings" => "Change Settings",
  235. "toggle_extensions" => "Toggle Extensions",
  236. "view_site" => "View Site",
  237. "view_private" => "View Private Posts",
  238. "view_draft" => "View Drafts",
  239. "view_own_draft" => "View Own Drafts",
  240. "add_post" => "Add Posts",
  241. "add_draft" => "Add Drafts",
  242. "edit_post" => "Edit Posts",
  243. "edit_draft" => "Edit Drafts",
  244. "edit_own_post" => "Edit Own Posts",
  245. "edit_own_draft" => "Edit Own Drafts",
  246. "delete_post" => "Delete Posts",
  247. "delete_draft" => "Delete Drafts",
  248. "delete_own_post" => "Delete Own Posts",
  249. "delete_own_draft" => "Delete Own Drafts",
  250. "add_page" => "Add Pages",
  251. "edit_page" => "Edit Pages",
  252. "delete_page" => "Delete Pages",
  253. "add_user" => "Add Users",
  254. "edit_user" => "Edit Users",
  255. "delete_user" => "Delete Users",
  256. "add_group" => "Add Groups",
  257. "edit_group" => "Edit Groups",
  258. "delete_group" => "Delete Groups");
  259. foreach ($names as $id => $name)
  260. $sql->replace("permissions",
  261. array("id", "group_id"),
  262. array("id" => $id,
  263. "name" => $name,
  264. "group_id" => 0));
  265. $groups = array("admin" => array_keys($names),
  266. "member" => array("view_site"),
  267. "friend" => array("view_site", "view_private"),
  268. "banned" => array(),
  269. "guest" => array("view_site"));
  270. # Insert the default groups (see above)
  271. $group_id = array();
  272. foreach($groups as $name => $permissions) {
  273. $sql->replace("groups", "name", array("name" => ucfirst($name)));
  274. $group_id[$name] = $sql->latest("groups");
  275. foreach ($permissions as $permission)
  276. $sql->replace("permissions",
  277. array("id", "group_id"),
  278. array("id" => $permission,
  279. "name" => $names[$permission],
  280. "group_id" => $group_id[$name]));
  281. }
  282. $config->set("default_group", $group_id["member"]);
  283. $config->set("guest_group", $group_id["guest"]);
  284. if (!$sql->select("users", "id", array("login" => $_POST['login']))->fetchColumn())
  285. $sql->insert("users",
  286. array("login" => $_POST['login'],
  287. "password" => User::hashPassword($_POST['password_1']),
  288. "email" => $_POST['email'],
  289. "website" => $config->url,
  290. "group_id" => $group_id["admin"],
  291. "joined_at" => datetime()));
  292. $installed = true;
  293. }
  294. }
  295. function value_fallback($index, $fallback = "") {
  296. echo (isset($_POST[$index])) ? $_POST[$index] : $fallback ;
  297. }
  298. ?>
  299. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  300. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  301. <html xmlns="http://www.w3.org/1999/xhtml">
  302. <head>
  303. <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  304. <title>Chyrp Installer</title>
  305. <style type="text/css" media="screen">
  306. html, body, ul, ol, li,
  307. h1, h2, h3, h4, h5, h6,
  308. form, fieldset, a, p {
  309. margin: 0;
  310. padding: 0;
  311. border: 0;
  312. }
  313. html {
  314. font-size: 62.5%;
  315. }
  316. body {
  317. font: 1.25em/1.5em normal Verdana, Helvetica, Arial, sans-serif;
  318. color: #626262;
  319. background: #e8e8e8;
  320. padding: 0 0 5em;
  321. }
  322. h2 {
  323. font-size: 1.25em;
  324. font-weight: bold;
  325. }
  326. input[type="password"], input[type="text"], textarea, select {
  327. font-size: 1.25em;
  328. width: 23.3em;
  329. padding: .3em;
  330. border: .1em solid #ddd;
  331. }
  332. textarea {
  333. width: 97.75%;
  334. }
  335. select {
  336. width: 100%;
  337. }
  338. form hr {
  339. border: 0;
  340. padding-bottom: 1em;
  341. margin-bottom: 4em;
  342. border-bottom: .1em dashed #ddd;
  343. }
  344. form p {
  345. padding-bottom: 1em;
  346. }
  347. .sub {
  348. font-size: .8em;
  349. color: #777;
  350. font-weight: normal;
  351. }
  352. .sub.inline {
  353. float: left;
  354. margin-top: -1.5em !important;
  355. }
  356. .error {
  357. padding: .6em .8em .5em 2.75em;
  358. border-bottom: .1em solid #FBC2C4;
  359. color: #D12F19;
  360. background: #FBE3E4 url('./admin/themes/default/images/icons/failure.png') no-repeat .7em center;
  361. }
  362. .error.last {
  363. margin: 0 0 1em 0;
  364. }
  365. .window {
  366. width: 30em;
  367. background: #fff;
  368. padding: 2em;
  369. margin: 5em auto 0;
  370. -webkit-border-radius: 2em;
  371. -moz-border-radius: 2em;
  372. }
  373. h1 {
  374. color: #ccc;
  375. font-size: 3em;
  376. margin: .25em 0 .5em;
  377. text-align: center;
  378. }
  379. code {
  380. color: #06B;
  381. font-family: Monaco, monospace;
  382. }
  383. label {
  384. display: block;
  385. font-weight: bold;
  386. border-bottom: .1em dotted #ddd;
  387. margin-bottom: .2em;
  388. }
  389. .footer {
  390. color: #777;
  391. margin-top: 1em;
  392. font-size: .9em;
  393. text-align: center;
  394. }
  395. .error {
  396. color: #F22;
  397. }
  398. a:link, a:visited {
  399. color: #6B0;
  400. }
  401. a.big,
  402. button {
  403. background: #eee;
  404. margin-top: 2em;
  405. display: block;
  406. text-align: left;
  407. padding: .75em 1em;
  408. color: #777;
  409. text-shadow: #fff .1em .1em 0;
  410. font: 1em normal "Lucida Grande", Verdana, Helvetica, Arial, sans-serif;
  411. text-decoration: none;
  412. border: 0;
  413. cursor: pointer;
  414. -webkit-border-radius: .5em;
  415. -moz-border-radius: .5em;
  416. }
  417. button {
  418. width: 100%;
  419. }
  420. a.big:hover,
  421. button:hover {
  422. background: #f5f5f5;
  423. }
  424. a.big:active,
  425. button:active {
  426. background: #e0e0e0;
  427. }
  428. strong {
  429. font-weight: normal;
  430. color: #f00;
  431. }
  432. ol {
  433. margin: 0 0 2em 2em;
  434. }
  435. p {
  436. margin-bottom: 1em;
  437. }
  438. .center {
  439. text-align: center;
  440. }
  441. </style>
  442. <script src="includes/lib/jquery.js" type="text/javascript" charset="utf-8"></script>
  443. <script src="includes/lib/plugins.js" type="text/javascript" charset="utf-8"></script>
  444. <script type="text/javascript">
  445. $(function(){
  446. $("#adapter").change(function(){
  447. if ($(this).val() == "sqlite") {
  448. $(document.createElement("span"))
  449. .addClass("sub")
  450. .css("display", "none")
  451. .text("<?php echo __("(full path)"); ?>")
  452. .appendTo("#database_field label")
  453. .animate({ opacity: "show" })
  454. $("#host_field, #username_field, #password_field, #prefix_field")
  455. .children()
  456. .val("")
  457. .closest("div")
  458. .animate({ height: "hide", opacity: "hide" })
  459. } else {
  460. $("#database_field label .sub")
  461. .animate({ opacity: "hide" },
  462. function(){ $(this).remove() })
  463. $("#host_field, #username_field, #password_field, #prefix_field")
  464. .parent()
  465. .animate({ height: "show", opacity: "show" })
  466. }
  467. })
  468. })
  469. </script>
  470. </head>
  471. <body>
  472. <?php foreach ($errors as $error): ?>
  473. <div class="error<?php if ($index + 1 == count($errors)) echo " last"; ?>"><?php echo $error; ?></div>
  474. <?php endforeach; ?>
  475. <div class="window">
  476. <?php if (!$installed): ?>
  477. <form action="install.php" method="post" accept-charset="utf-8">
  478. <h1><?php echo __("Database Setup"); ?></h1>
  479. <p id="adapter_field">
  480. <label for="adapter"><?php echo __("Adapter"); ?></label>
  481. <select name="adapter" id="adapter">
  482. <?php if ((class_exists("PDO") and in_array("mysql", PDO::getAvailableDrivers())) or
  483. class_exists("MySQLi") or function_exists("mysql_query")): ?>
  484. <option value="mysql"<?php selected("mysql", fallback($_POST['adapter'], "mysql")); ?>>MySQL</option>
  485. <?php endif; ?>
  486. <?php if (class_exists("PDO") and in_array("sqlite", PDO::getAvailableDrivers())): ?>
  487. <option value="sqlite"<?php selected("sqlite", fallback($_POST['adapter'], "mysql")); ?>>SQLite 3</option>
  488. <?php endif; ?>
  489. <?php if (class_exists("PDO") and in_array("pgsql", PDO::getAvailableDrivers())): ?>
  490. <option value="pgsql"<?php selected("pgsql", oneof(@$_POST['adapter'], "mysql")); ?>>PostgreSQL</option>
  491. <?php endif; ?>
  492. </select>
  493. </p>
  494. <div<?php echo (isset($_POST['adapter']) and $_POST['adapter'] == "sqlite") ? ' style="display: none"' : "" ; ?>>
  495. <p id="host_field">
  496. <label for="host"><?php echo __("Host"); ?> <span class="sub"><?php echo __("(usually ok as \"localhost\")"); ?></span></label>
  497. <input type="text" name="host" value="<?php value_fallback("host", ((isset($_ENV['DATABASE_SERVER'])) ? $_ENV['DATABASE_SERVER'] : "localhost")); ?>" id="host" />
  498. </p>
  499. </div>
  500. <div<?php echo (isset($_POST['adapter']) and $_POST['adapter'] == "sqlite") ? ' style="display: none"' : "" ; ?>>
  501. <p id="username_field">
  502. <label for="username"><?php echo __("Username"); ?></label>
  503. <input type="text" name="username" value="<?php value_fallback("username"); ?>" id="username" />
  504. </p>
  505. </div>
  506. <div<?php echo (isset($_POST['adapter']) and $_POST['adapter'] == "sqlite") ? ' style="display: none"' : "" ; ?>>
  507. <p id="password_field">
  508. <label for="password"><?php echo __("Password"); ?></label>
  509. <input type="password" name="password" value="<?php value_fallback("password"); ?>" id="password" />
  510. </p>
  511. </div>
  512. <p id="database_field">
  513. <label for="database"><?php echo __("Database"); ?> <?php echo (isset($_POST['adapter']) and $_POST['adapter'] == "sqlite") ? '<span class="sub">'.__("(full path)").'</span>' : "" ; ?></label>
  514. <input type="text" name="database" value="<?php value_fallback("database"); ?>" id="database" />
  515. </p>
  516. <div<?php echo (isset($_POST['adapter']) and $_POST['adapter'] == "sqlite") ? ' style="display: none"' : "" ; ?>>
  517. <p id="prefix_field">
  518. <label for="prefix"><?php echo __("Table Prefix"); ?> <span class="sub"><?php echo __("(optional)"); ?></span></label>
  519. <input type="text" name="prefix" value="<?php value_fallback("prefix"); ?>" id="prefix" />
  520. </p>
  521. </div>
  522. <hr />
  523. <h1><?php echo __("Website Setup"); ?></h1>
  524. <p id="name_field">
  525. <label for="name"><?php echo __("Site Name"); ?></label>
  526. <input type="text" name="name" value="<?php value_fallback("name", __("My Awesome Site")); ?>" id="name" />
  527. </p>
  528. <p id="description_field">
  529. <label for="description"><?php echo __("Description"); ?></label>
  530. <textarea name="description" rows="2" cols="40"><?php value_fallback("description"); ?></textarea>
  531. </p>
  532. <p id="timezone_field">
  533. <label for="timezone"><?php echo __("What time is it?"); ?></label>
  534. <select name="timezone" id="timezone">
  535. <?php foreach (timezones() as $zone): ?>
  536. <option value="<?php echo $zone["name"]; ?>"<?php selected($zone["name"], oneof(@$_POST['timezone'], $default_timezone)); ?>>
  537. <?php echo strftime("%I:%M %p on %B %d, %Y", $zone["now"]); ?> &mdash;
  538. <?php echo str_replace(array("_", "St "), array(" ", "St. "), $zone["name"]); ?>
  539. </option>
  540. <?php endforeach; ?>
  541. </select>
  542. </p>
  543. <hr />
  544. <h1><?php echo __("Admin Account"); ?></h1>
  545. <p id="login_field">
  546. <label for="login"><?php echo __("Username"); ?></label>
  547. <input type="text" name="login" value="<?php value_fallback("login", "Admin"); ?>" id="login" />
  548. </p>
  549. <p id="password_1_field">
  550. <label for="password_1"><?php echo __("Password"); ?></label>
  551. <input type="password" name="password_1" value="<?php value_fallback("password_1"); ?>" id="password_1" />
  552. </p>
  553. <p id="password_2_field">
  554. <label for="password_2"><?php echo __("Password"); ?> <span class="sub"><?php echo __("(again)"); ?></span></label>
  555. <input type="password" name="password_2" value="<?php value_fallback("password_2"); ?>" id="password_2" />
  556. </p>
  557. <p id="email_field">
  558. <label for="email"><?php echo __("E-Mail Address"); ?></label>
  559. <input type="text" name="email" value="<?php value_fallback("email"); ?>" id="email" />
  560. </p>
  561. <button type="submit"><?php echo __("Install! &rarr;"); ?></button>
  562. </form>
  563. <?php else: ?>
  564. <h1><?php echo __("Done!"); ?></h1>
  565. <p>
  566. <?php echo __("Chyrp has been successfully installed."); ?>
  567. </p>
  568. <h2><?php echo __("So, what now?"); ?></h2>
  569. <ol>
  570. <li><?php echo __("<strong>Delete install.php</strong>, you won't need it anymore."); ?></li>
  571. <?php if (!is_writable(INCLUDES_DIR."/caches")): ?>
  572. <li><?php echo __("CHMOD <code>/includes/caches</code> to 777."); ?></li>
  573. <?php endif; ?>
  574. <li><a href="http://chyrp.net/extend/type/translation"><?php echo __("Look for a translation for your language."); ?></a></li>
  575. <li><a href="http://chyrp.net/extend/type/module"><?php echo __("Install some Modules."); ?></a></li>
  576. <li><a href="http://chyrp.net/extend/type/feather"><?php echo __("Find some Feathers you want."); ?></a></li>
  577. <li><a href="README.markdown"><?php echo __("Read &#8220;Getting Started&#8221;"); ?></a></li>
  578. </ol>
  579. <a class="big" href="<?php echo $config->chyrp_url; ?>"><?php echo __("Take me to my site! &rarr;"); ?></a>
  580. <?php endif; ?>
  581. </div>
  582. </body>
  583. </html>