aboutsummaryrefslogtreecommitdiff
path: root/app/class/application.php
blob: 2872695e89a3af774dabcaa3ea875373d4dac16d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php

class Application
{
    public function __construct() {
        
    }

    public function wakeup()
    {
        if(isset($_POST['configinit'])) {
            Config::createconfig($_POST['configinit']);
            if(!Config::savejson()) {
                echo 'Cant write config file';
                exit;
            } else{
                header('Location: ./');
                exit;
            }
        } else {
            if(Config::readconfig()) {
                if(!Config::checkcmspath() || empty(Config::admin()) || empty(Config::arttable())) {
                    echo '<ul>';
                    if(!Config::checkcmspath()) {
                        echo '<li>Wrong path</li>';
                    } 
                    if(empty(Config::admin())) {
                        echo '<li>Wrong admin password</li>';
                    } 
                    if(empty(Config::arttable())) {
                        echo '<li>Unset table name</li>';
                    }
                    echo '</ul>';
                    $this->configform();
                    exit;
                }
            } else {
                echo 'Missing config file';
                $this->configform();
                exit;
            }
        }
    }

    public function configform()
    {
        ?>
        <h1>Configuration</h1>
        <form action="" method="post">
        <div>
        <h2>
        <label for="cmspath">Path to W-CMS</label>
        </h2>
        <input type="text" name="configinit[cmspath]"  value="<?= Config::cmspath() ?>" id="cmspath">
        <p><i>Leave it empty if W-CMS is in your root folder, otherwise, indicate the subfolder(s) in witch you installed the CMS</i></p>
        </div>
        <div>
        <div>
        <h2>
        <label for="admin">Admin Password</label>
        </h2>
        <input type="password" name="configinit[admin]" value="<?= Config::admin() ?>" id="admin" minlength="4" maxlength="64">
        <p><i>The main password for administration, you can change it later.</i></p>
        </div>
        <h2>
        <label for="arttable">Name of your database table</label>
        </h2>
        <input type="text" name="configinit[arttable]"  value="<?= Config::arttable() ?>" id="arttable">
        <p><i>Set the name of the first folder that is going to store all your work</i></p>
        </div>
        <input type="submit" value="set">
        </form>

        <?php
    }
}













?>