Browse Source

Started to rebuild the app

* Install.php page started
* Will use RainTPL for templates handling
Phyks (Lucas Verney) 6 years ago
parent
commit
02ebd593c4
14 changed files with 1205 additions and 0 deletions
  1. 0
    0
      .gitignore
  2. 0
    0
      README.md
  3. 1
    0
      TODO
  4. 0
    0
      humans.txt
  5. 10
    0
      inc/config.php.sample
  6. 4
    0
      inc/header.php
  7. 1043
    0
      inc/rain.tpl.class.php
  8. 2
    0
      index.php
  9. 78
    0
      install.php
  10. 2
    0
      robots.txt
  11. 9
    0
      tpl/css/style.css
  12. 2
    0
      tpl/footer.html
  13. 9
    0
      tpl/header.html
  14. 45
    0
      tpl/index.html

+ 0
- 0
.gitignore View File


+ 0
- 0
README.md View File


+ 1
- 0
TODO View File

@@ -0,0 +1 @@
1
+* i18n

+ 0
- 0
humans.txt View File


+ 10
- 0
inc/config.php.sample View File

@@ -0,0 +1,10 @@
1
+<?php
2
+    define('VERSION_NUMBER', '2.0');
3
+
4
+    define('MYSQL_HOST', 'localhost');
5
+    define('MYSQL_LOGIN', '');
6
+    define('MYSQL_PASSWORD', '');
7
+    define('MYSQL_BDD', '');
8
+    define('MYSQL_PREFIX', '');
9
+
10
+    define('TITLE', 'Bouffe@Ulm');

+ 4
- 0
inc/header.php View File

@@ -0,0 +1,4 @@
1
+<?php
2
+    if(!file_exists('config.php')) header('location: install.php');
3
+
4
+    require_once('config.php');

+ 1043
- 0
inc/rain.tpl.class.php
File diff suppressed because it is too large
View File


+ 2
- 0
index.php View File

@@ -0,0 +1,2 @@
1
+<?php
2
+    require_once('inc/header.php');

+ 78
- 0
install.php View File

@@ -0,0 +1,78 @@
1
+<?php
2
+    if(file_exists('inc/config.php')) exit("Your Bouffe@Ulm instance is already configured. You should either delete inc/config.php to access this page or delete the install.php for security reasons if you are ok with the configuration.");
3
+
4
+    if(!function_exists("file_get_contents") && !function_exists("file_put_contents")) {
5
+        $error = "Functions <em>file_get_contents</em> and <em>file_put_contents</em> seems to not be available on your PHP installation. You should enable them first.";
6
+        $block_form = true;
7
+    }
8
+
9
+    if(!empty($_POST['mysql_host']) && !empty($_POST['mysql_login']) && !empty($_POST['mysql_db'])) {
10
+        $mysql_host = $_POST['mysql_host'];
11
+        $mysql_login = $_POST['mysql_login'];
12
+        $mysql_db = $_POST['mysql_login'];
13
+        $mysql_password = $_POST['mysql_password'];
14
+        $mysql_prefix = $_POST['mysql_prefix'];
15
+        $instance_title = (!empty($_POST['instance_title'])) ? $_POST['instance_title'] : 'Bouffe@Ulm';
16
+
17
+        try {
18
+            $db = new PDO("mysql:host=".$mysql_host.";dbname=".$mysql_db, $mysql_login, $mysql_password);
19
+        }
20
+        catch (PDOException $e) {
21
+            $error = 'Unable to connect to database, check your credentials.';
22
+        }
23
+
24
+        if(empty($error)) {
25
+            $config = "
26
+                define('VERSION_NUMBER', '2.0');
27
+
28
+                define('MYSQL_HOST', '".$mysql_host."');
29
+                define('MYSQL_LOGIN', '".$mysql_login."');
30
+                define('MYSQL_PASSWORD', '".$mysql_password."');
31
+                define('MYSQL_DB', '".$mysql_db."');
32
+                define('MYSQL_PREFIX', '".$mysql_prefix."');
33
+
34
+                define('INSTANCE_TITLE', '".$instance_title."');";
35
+            file_put_contents("inc/config.php", $config);
36
+        }
37
+    }
38
+?>
39
+<!DOCTYPE html>
40
+<html lang="fr">
41
+    <head>
42
+        <meta charset="utf-8">
43
+        <title>Bouffe@Ulm - Installation</title>
44
+        <link rel="stylesheet" media="screen" type="text/css" href="tpl/css/style.css" />
45
+    </head>
46
+    <body>
47
+        <h1>Bouffe@Ulm - Installation</h1>
48
+
49
+        <?php
50
+            if(!empty($error)) {
51
+                echo '<p class="error">'.$error.'</p>';
52
+            }
53
+        ?>
54
+
55
+        <p>This small form will guide you through the installation of Bouffe@Ulm.</p>
56
+
57
+        <form action="install.php" method="post">
58
+            <fieldset>
59
+                <legend>Database</legend>
60
+                <p><label for="mysql_host">MySQL host : </label><input type="text" name="mysql_host" id="mysql_host" value="<?php echo (!empty($_POST['mysql_host'])) ? htmlspecialchars($_POST['mysql_host']) : 'localhost';?>"/></p>
61
+
62
+                <p><label for="mysql_login">MySQL login : </label><input type="text" name="mysql_login" id="mysql_login" value="<?php echo (!empty($_POST['mysql_login'])) ? htmlspecialchars($_POST['mysql_login']) : '';?>"/></p>
63
+                <p><label for="mysql_password">MySQL password : </label><input type="password" name="mysql_password" id="mysql_password"/></p>
64
+                <p>
65
+                <label for="mysql_db">Name of the MySQL database to use : </label><input type="text" name="mysql_db" id="mysql_db" value="<?php echo (!empty($_POST['mysql_db'])) ? htmlspecialchars($_POST['mysql_db']) : 'Bouffe@Ulm';?>"/><br/>
66
+                    <em>Note :</em> You <em>must</em> create this database first.
67
+                </p>
68
+                <p><label for="mysql_prefix">Prefix for the created tables : </label><input type="text" name="mysql_prefix" id="mysql_prefix" value="<?php echo (!empty($_POST['mysql_prefix'])) ? htmlspecialchars($_POST['mysql_prefix']) : 'bouffeatulm_';?>"/></p>
69
+            </fieldset>
70
+            <fieldset>
71
+                <legend>General options</legend>
72
+                <p><label for="instance_title">Title to display in pages : </label><input type="text" name="instance_title" id="instance_title" value="Bouffe@Ulm"/></p>
73
+            </fieldset>
74
+
75
+            <p><input <?php echo (!empty($block_form)) ? 'disabled ' : '';?>type="submit" class="center"></p>
76
+        </form>
77
+    </body>
78
+</html>

+ 2
- 0
robots.txt View File

@@ -0,0 +1,2 @@
1
+User-agent: *
2
+Disallow: /

+ 9
- 0
tpl/css/style.css View File

@@ -0,0 +1,9 @@
1
+.center {
2
+    text-align: center;
3
+}
4
+
5
+.error {
6
+    font-size: 1.5em;
7
+    color: red;
8
+    font-weight: bold;
9
+}

+ 2
- 0
tpl/footer.html View File

@@ -0,0 +1,2 @@
1
+    </body>
2
+</html>

+ 9
- 0
tpl/header.html View File

@@ -0,0 +1,9 @@
1
+<!DOCTYPE html>
2
+<html lang="fr">
3
+<head>
4
+<meta charset="utf-8">
5
+<title>Bouffe@Ulm</title>
6
+<link rel="stylesheet" media="screen" type="text/css" href="misc/style.css" />
7
+<link rel="icon" href="favicon.ico" />
8
+</head>
9
+<body>

+ 45
- 0
tpl/index.html View File

@@ -0,0 +1,45 @@
1
+{include="header"}
2
+
3
+<h1>{$title}</h1>
4
+
5
+{$notice}
6
+
7
+<div id="menu">
8
+    <ul>
9
+        <li><a href="modif.php">Ajouter une dépense</a></li>
10
+        <li><a href="modif_password.php">Modifier le mot de passe</a></li>
11
+        <li><a href="rbmt.php">Consulter les remboursements</a></li>
12
+    </ul>
13
+    {if condition="$admin"}
14
+    <ul>
15
+        <li><a href="rbmt_admin.php">Gérer les rembourements</a></li>
16
+        <li><a href="copains.php">Modifier les copains</a></li>
17
+        <li><a href="modif_annonce.php">Modifier l'annonce d'accueil</a></li>
18
+        <li><a href="connexion.php?deco=1">Déconnexion</a></li>
19
+    </ul>
20
+    {/if}
21
+</div>
22
+<div id="quick_summary">
23
+    <h2>Qui doit quoi ?</h2>
24
+    <p>Lire <em>ligne</em> doit <em>case</em>€ à <em>colonne</em>. Les liens permettent de confirmer le paiement des dettes.</p>
25
+    <table>
26
+        <tr>
27
+            <th>Doit\À</th>
28
+        </tr>
29
+    </table>
30
+</div>
31
+<div id="detailed_summary">
32
+    <h2>Dépenses détaillées du mois actuel</h2>
33
+
34
+    <table>
35
+        <tr>
36
+            <th>Date</th>
37
+            <th>Payé par</th>
38
+            <th>Participants</th>
39
+            <th>Montant</th>
40
+            <th>Menu</th>
41
+            <th>Modifier</th>
42
+            <th>Supprimer</th>
43
+        </tr>
44
+    </table>
45
+</div>