Overview
Comment:Amélioration de la gestion des configurations en sous-répertoire ou en alias (normalement)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ca9198db3f3251e4626532764d084f81d516e376
User & Date: bohwaz on 2019-12-03 17:48:39
Other Links: manifest | tags
Context
2019-12-03
22:57
Version 0.9.5 stable, et identifiant de cache différent pour chaque association check-in: abca58dc4e user: bohwaz tags: trunk, stable, 0.9.5
17:48
Amélioration de la gestion des configurations en sous-répertoire ou en alias (normalement) check-in: ca9198db3f user: bohwaz tags: trunk
17:46
Limiter les appels directs à _route.php check-in: 681b1f235f user: bohwaz tags: trunk
Changes

Modified src/VERSION from [19e7436639] to [72f19f670a].

1


1
-
+
0.9.4
0.9.5

Modified src/include/init.php from [c0092409a6] to [cef1ad8e13].

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

91
92
93
94
95
96
97
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128


129
130








131
132
133
134
135
136
137
138
139
140
141
142
143




144
145
146
147
148
149
150
151







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







+
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+




-
-
-
-
+







// Configuration par défaut, si les constantes ne sont pas définies dans config.local.php
// (fallback)
if (!defined('Garradin\ROOT'))
{
    define('Garradin\ROOT', dirname(__DIR__));
}


/**
 * Auto-chargement des dépendances
 */
class Loader
{
    /**
     * Liste des classes déjà chargées
     * @var array
     */
    static protected $loaded = [];

    /**
     * Inclure un fichier de classe depuis le nom de la classe
     * @param  string $classname
     * @return void
     */
    static public function load($classname)
    {
        $classname = ltrim($classname, '\\');

        if (array_key_exists($classname, self::$loaded))
        {
            return true;
        }

        // Plugins
        if (substr($classname, 0, 16) == 'Garradin\\Plugin\\')
        {
            $classname = substr($classname, 16);
            $plugin_name = substr($classname, 0, strpos($classname, '\\'));
            $filename = str_replace('\\', '/', substr($classname, strpos($classname, '\\')+1));

            $path = Plugin::getPath(strtolower($plugin_name)) . '/lib/' . $filename . '.php';
        }
        else
        {
            // PSR-0 autoload
            $filename = str_replace('\\', '/', $classname);
            $path = ROOT . '/include/lib/' . $filename . '.php';
        }

        if (!file_exists($path))
        {
            throw new \Exception('File '.$path.' doesn\'t exists');
        }

        self::$loaded[$classname] = true;

        require $path;
    }
}

\spl_autoload_register(['Garradin\Loader', 'load'], true);

if (!defined('Garradin\DATA_ROOT'))
{
    define('Garradin\DATA_ROOT', ROOT);
}

if (!defined('Garradin\WWW_URI'))
{
    $uri = \KD2\HTTP::getRootURI(ROOT);
    // Automagic URL discover
    $path = str_replace(ROOT . '/www', '', getcwd());

    if ($uri == '/www/') {
    $path = str_replace($path, '', dirname($_SERVER['SCRIPT_NAME']));
    $path = (!empty($path[0]) && $path[0] != '/') ? '/' . $path : $path;
    $path = (substr($path, -1) != '/') ? $path . '/' : $path;

    // Pour installations sans vhost
    $path = str_replace('/www', '', $path);

    define('Garradin\WWW_URI', $path);
        $uri = '/';
    }
    else {
        readfile(ROOT . '/sous-domaine.html');
        exit;
    }

    define('Garradin\WWW_URI', $uri);
    unset($uri);
}

if (!defined('Garradin\WWW_URL'))
{
    $host = isset($_SERVER['HTTP_HOST']) 
        ? $_SERVER['HTTP_HOST'] 
        : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost');
    define('Garradin\WWW_URL', 'http' . (!empty($_SERVER['HTTPS']) ? 's' : '') . '://' . $host . WWW_URI);
    define('Garradin\WWW_URL', \KD2\HTTP::getScheme() . '://' . \KD2\HTTP::getHost() . WWW_URI);
}

static $default_config = [
    'CACHE_ROOT'            => DATA_ROOT . '/cache',
    'DB_FILE'               => DATA_ROOT . '/association.sqlite',
    'DB_SCHEMA'             => ROOT . '/include/data/schema.sql',
    'PLUGINS_ROOT'          => DATA_ROOT . '/plugins',
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
202
203
204
205
206
207
208






















































209
210
211
212
213
214
215







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







    }
    else
    {
        ini_set('date.timezone', 'Europe/Paris');
    }
}

/**
 * Auto-chargement des dépendances
 */
class Loader
{
    /**
     * Liste des classes déjà chargées
     * @var array
     */
    static protected $loaded = [];

    /**
     * Inclure un fichier de classe depuis le nom de la classe
     * @param  string $classname
     * @return void
     */
    static public function load($classname)
    {
        $classname = ltrim($classname, '\\');

        if (array_key_exists($classname, self::$loaded))
        {
            return true;
        }

        // Plugins
        if (substr($classname, 0, 16) == 'Garradin\\Plugin\\')
        {
            $classname = substr($classname, 16);
            $plugin_name = substr($classname, 0, strpos($classname, '\\'));
            $filename = str_replace('\\', '/', substr($classname, strpos($classname, '\\')+1));

            $path = Plugin::getPath(strtolower($plugin_name)) . '/lib/' . $filename . '.php';
        }
        else
        {
            // PSR-0 autoload
            $filename = str_replace('\\', '/', $classname);
            $path = ROOT . '/include/lib/' . $filename . '.php';
        }

        if (!file_exists($path))
        {
            throw new \Exception('File '.$path.' doesn\'t exists');
        }

        self::$loaded[$classname] = true;

        require $path;
    }
}

\spl_autoload_register(['Garradin\Loader', 'load'], true);

/*
 * Gestion des erreurs et exceptions
 */

class UserException extends \LogicException
{
}

Deleted src/index.html version [bf3217f86f].

1
2
3
4
5
6
7
8
9
10










-
-
-
-
-
-
-
-
-
-
<!DOCTYPE html>
<meta charset="utf-8" />
<h1>Erreur</h1>
<p>Garradin n'est pas installé sur un sous-domaine dédié.</p>
<p>Ce mode de fonctionnement n'est pas supporté officiellement.</p>
<h3>Installation conseillée</h3>
<p>Merci de positionner un sous-domaine dédié (vhost) sur le répertoire www/</p>
<p>Voir <a href="https://fossil.kd2.org/garradin/wiki?name=Installation">la documentation</a>.</p>
<h3>Fonctionnement en sous-répertoire, sans vhost (non conseillé)</h3>
<p>Voir la <a href="https://fossil.kd2.org/garradin/wiki?name=Installation%20sans%20vhost">documentation</a> dédiée pour configurer Garradin</p>

Added src/index.php version [3633bc3928].







1
2
3
4
5
6
+
+
+
+
+
+
<?php

// Supprimer ce fichier

readfile(__DIR__ . '/sous-domaine.html');
exit;

Added src/sous-domaine.html version [01c1184ede].














1
2
3
4
5
6
7
8
9
10
11
12
13
+
+
+
+
+
+
+
+
+
+
+
+
+
<!DOCTYPE html>
<meta charset="utf-8" />
<h1>Erreur</h1>
<p>Garradin n'est pas installé sur un sous-domaine dédié.</p>
<p>Ce mode de fonctionnement n'est pas supporté officiellement.</p>

<h3>Installation conseillée</h3>
<p>Le mode conseillé est de positionner un sous-domaine dédié (<em>virtual host</em> ou <em>vhost</em>) sur le répertoire www/</p>
<p>Voir <a href="https://fossil.kd2.org/garradin/wiki?name=Installation">la documentation</a>.</p>

<h3>Installation dans un sous-répertoire, sans <em>virtual host</em> (non conseillé)</h3>

<p>Voir la <a href="https://fossil.kd2.org/garradin/wiki?name=Installation%20sans%20vhost">documentation</a> dédiée pour configurer Garradin correctement et faire disparaître ce message d'erreur.</p>