Overview
Comment:+ mini design de base + correction bug fetchresult + on évolue dans les droits + récup des droits au login
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0091b53a43333ac64040554b8b2733fad8af506c
User & Date: bohwaz on 2011-12-12 04:13:03
Other Links: manifest | tags
Context
2011-12-12
18:18
Gestion plus simple des droits check-in: 2a52f7577e user: bohwaz tags: trunk
04:13
+ mini design de base + correction bug fetchresult + on évolue dans les droits + récup des droits au login check-in: 0091b53a43 user: bohwaz tags: trunk
02:18
Login fonctionnel + ajout champ pseudo check-in: 87bfee73b4 user: bohwaz tags: trunk
Changes

Modified include/class.config.php from [f37b17768a] to [200afcf6ed].

198
199
200
201
202
203
204





205
206
207
        {
            $this->config[$key] = $value;
            $this->modified[$key] = true;
        }

        return true;
    }





}

?>







>
>
>
>
>



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
        {
            $this->config[$key] = $value;
            $this->modified[$key] = true;
        }

        return true;
    }

    public function getConfig()
    {
        return $this->config;
    }
}

?>

Modified include/class.db.php from [5931695276] to [dcfb6370d3].

205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
        $out = array();

        while ($row = $result->fetchArray($mode))
        {
            $out[] = $row;
        }

        $res->finalize();
        unset($res, $row);

        return $out;
    }

    protected function _fetchResultAssoc($result)
    {
        $out = array();

        while ($row = $result->fetchArray(SQLITE3_NUM))
        {
            $out[$row[0]] = $row[1];
        }

        $res->finalize();
        unset($res, $row);

        return $out;
    }
}

?>







|
|













|
|






205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
        $out = array();

        while ($row = $result->fetchArray($mode))
        {
            $out[] = $row;
        }

        $result->finalize();
        unset($result, $row);

        return $out;
    }

    protected function _fetchResultAssoc($result)
    {
        $out = array();

        while ($row = $result->fetchArray(SQLITE3_NUM))
        {
            $out[$row[0]] = $row[1];
        }

        $result->finalize();
        unset($result, $row);

        return $out;
    }
}

?>

Modified include/class.membres.php from [463c3019de] to [1d7cbd6bad].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

class Garradin_Membres
{
    const DROIT_CONNEXION = 1;
    const DROIT_INSCRIPTION = 2;

    const DROIT_WIKI_LIRE = 10;
    const DROIT_WIKI_ECRIRE = 11;
    const DROIT_WIKI_FICHIERS = 12;
    const DROIT_WIKI_ADMIN = 13;

    const DROIT_MEMBRE_AJOUTER = 20;
    const DROIT_MEMBRE_MODIFIER = 21;
    const DROIT_MEMBRE_LISTER = 22;
    const DROIT_MEMBRE_ADMIN = 23;

    const DROIT_COMPTA_GESTION = 30;
    const DROIT_COMPTA_ADMIN = 31;

    protected function _getSalt($length)
    {
        $str = str_split('./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789');












|
<
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
21
22
<?php

class Garradin_Membres
{
    const DROIT_CONNEXION = 1;
    const DROIT_INSCRIPTION = 2;

    const DROIT_WIKI_LIRE = 10;
    const DROIT_WIKI_ECRIRE = 11;
    const DROIT_WIKI_FICHIERS = 12;
    const DROIT_WIKI_ADMIN = 13;

    const DROIT_MEMBRE_LISTER = 20;

    const DROIT_MEMBRE_GESTION = 21;
    const DROIT_MEMBRE_ADMIN = 22;

    const DROIT_COMPTA_GESTION = 30;
    const DROIT_COMPTA_ADMIN = 31;

    protected function _getSalt($length)
    {
        $str = str_split('./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789');
48
49
50
51
52
53
54


55



56
57
58
59
60
61
62

        return true;
    }

    protected function _login($user)
    {
        $this->_sessionStart(true);


        $_SESSION['logged_user'] = $user;



        return true;
    }

    public function login($email, $passe)
    {
        if (!filter_var($email, FILTER_VALIDATE_EMAIL))
            return false;







>
>

>
>
>







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

        return true;
    }

    protected function _login($user)
    {
        $this->_sessionStart(true);
        $db = Garradin_DB::getInstance();

        $_SESSION['logged_user'] = $user;
        $_SESSION['logged_user']['rights'] = $db->queryFetchAssoc('SELECT droit, droit FROM membres_categories_droits
            WHERE id_categorie = '.(int)$user['id_categorie'].';', SQLITE3_ASSOC);

        return true;
    }

    public function login($email, $passe)
    {
        if (!filter_var($email, FILTER_VALIDATE_EMAIL))
            return false;

Modified include/template.php from [67c8d2e03f] to [549d03128c].

14
15
16
17
18
19
20


21
22
23
24
25
26
27
$tpl->reserved_template_varname = 'tpl';

$tpl->assign('www_url', WWW_URL);
$tpl->assign('self_url', utils::getSelfUrl());

$tpl->assign('is_logged', false);



function tpl_csrf_field($params)
{
    $name = utils::CSRF_field_name($params['key']);
    $value = utils::CSRF_create($params['key']);

    return '<input type="hidden" name="'.$name.'" value="'.$value.'" />';
}







>
>







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$tpl->reserved_template_varname = 'tpl';

$tpl->assign('www_url', WWW_URL);
$tpl->assign('self_url', utils::getSelfUrl());

$tpl->assign('is_logged', false);

$tpl->assign('config', Garradin_Config::getInstance()->getConfig());

function tpl_csrf_field($params)
{
    $name = utils::CSRF_field_name($params['key']);
    $value = utils::CSRF_create($params['key']);

    return '<input type="hidden" name="'.$name.'" value="'.$value.'" />';
}
35
36
37
38
39
40
41






42
43
44
45
46
    elseif (!empty($params['default']) && !empty($params['default'][$name]))
        $value = $params['default'][$name];
    else
        $value = '';

    return htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
}







$tpl->register_function('csrf_field', 'tpl_csrf_field');
$tpl->register_function('form_field', 'tpl_form_field');

?>







>
>
>
>
>
>





37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    elseif (!empty($params['default']) && !empty($params['default'][$name]))
        $value = $params['default'][$name];
    else
        $value = '';

    return htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
}

function has_right($right, $check)
{
    $right = constant('Garradin_Membres::DROIT_'.strtoupper($right));
    return array_key_exists($right, $check);
}

$tpl->register_function('csrf_field', 'tpl_csrf_field');
$tpl->register_function('form_field', 'tpl_form_field');

?>

Modified templates/admin/_foot.tpl from [f5469d5a3f] to [73366e88b5].



1
2


</body>
</html>
>
>


1
2
3
4
</div>

</body>
</html>

Modified templates/admin/_head.tpl from [07319c1e86] to [3218c14ed1].

1
2
3
4
5
6
7
8
9
10






















<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>{$title|escape}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="{$www_url}style/admin.css" media="screen,projection,handheld" />
</head>

<body>
































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>{$title|escape}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="{$www_url}style/admin.css" media="screen,projection,handheld" />
</head>

<body>

<div class="header">
    <h1>{$title|escape}</h1>

    {if $is_logged}
    <ul class="menu">
        <li class="home{if $self_page == ''} current{/if}"><a href="{$www_url}admin/">Accueil</a></li>
        {if has_right('MEMBRE_GESTION', $user.rights)}
            <li class="add_member{if $self_page == 'membres/ajouter.php'} current{/if}"><a href="{$www_url}admin/membres/ajouter.php">Ajouter un membre</a></li>
        {/if}
        {if has_right('MEMBRE_GESTION', $user.rights) || has_right('MEMBRE_ADMIN', $user.rights) || has_right('MEMBRE_LISTER', $user.rights)}
            <li class="list_members{if $self_page == 'membres/'} current{/if}"><a href="{$www_url}admin/membres/liste.php">Liste</a></li>
        {/if}
        {if has_right('MEMBRE_ADMIN', $user.rights)}
            <li class="member_cats{if $self_page == 'membres/categories.php'} current{/if}"><a href="{$www_url}admin/membres/categories.php">Gérer les catégories de membres</a></li>
        {/if}
        <li class="logout"><a href="{$www_url}admin/logout.php">Déconnexion</a></li>
    </ul>
    {/if}
</div>

<div class="page">

Added templates/admin/index.tpl version [256e4ede98].











>
>
>
>
>
1
2
3
4
5
{include file="admin/_head.tpl" title=$config.nom_asso}

<p>Bla</p>

{include file="admin/_foot.tpl"}

Modified templates/admin/login.tpl from [63ac046f34] to [ec86fd08d4].

1
2
3
4
5
6
7
8
9
10
{include file="admin/_head.tpl" title="Garradin - Installation"}

<h1>Connexion</h1>

{if $error}
    <p class="error">
        {if $error == 'OTHER'}
            Une erreur est survenue, merci de réessayer.
        {else}
            Connexion impossible. Vérifiez l'adresse e-mail et le mot de passe.
|
<
<







1


2
3
4
5
6
7
8
{include file="admin/_head.tpl" title="Connexion"}



{if $error}
    <p class="error">
        {if $error == 'OTHER'}
            Une erreur est survenue, merci de réessayer.
        {else}
            Connexion impossible. Vérifiez l'adresse e-mail et le mot de passe.

Modified www/admin/_inc.php from [d6dcb24930] to [548f40fbae].

8
9
10
11
12
13
14





15
16
17

if (!defined('GARRADIN_LOGIN_PROCESS'))
{
    if (!$membres->isLogged())
    {
        utils::redirect('/admin/login.php');
    }





}

?>







>
>
>
>
>



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

if (!defined('GARRADIN_LOGIN_PROCESS'))
{
    if (!$membres->isLogged())
    {
        utils::redirect('/admin/login.php');
    }

    $tpl->assign('is_logged', true);
    $tpl->assign('user', $membres->getLoggedUser());

    $tpl->assign('self_page', str_replace(WWW_URL . 'admin/', '', utils::getSelfUrl()));
}

?>

Added www/admin/index.php version [bced446290].















>
>
>
>
>
>
>
1
2
3
4
5
6
7
<?php

require_once __DIR__ . '/_inc.php';

$tpl->display('admin/index.tpl');

?>

Added www/admin/logout.php version [a2b4b7198b].



















>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
<?php

define('GARRADIN_LOGIN_PROCESS', true);
require_once __DIR__ . '/_inc.php';

$membres->logout();
utils::redirect('/');

?>

Added www/img/bg00.png version [065b3f5f78].

cannot compute difference between binary files

Added www/img/bg01.png version [34bbaf6295].

cannot compute difference between binary files

Modified www/style/admin.css from [85af6dd9b7] to [952e29b84e].

1
2
3
4
5

6




7
8
9
10
11
12
13


14





15

16





17
18
19
20
21
22
23
* { margin: 0; padding: 0; }

body {
    font-size: 100%;
    padding: 1.5%;

    background: #fff;




    color: #000;
    font-family: Sans-serif;
}

h1 {
    text-align: center;
    margin: -1% -1% 1% -1%;


    padding: 0.5%;





    background: #c85;

    color: #fff;





}

p.error {
    border: 1px solid #c00;
    background: #fcc;
    padding: 0.5em;
    margin-bottom: 1em;




|
>

>
>
>
>
|
<


|
|
|
>
>
|
>
>
>
>
>
|
>

>
>
>
>
>







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
* { margin: 0; padding: 0; }

body {
    font-size: 100%;
    color: #000;
    font-family: "Trebuchet MS", Helvetica, Sans-serif;
    background: #fff;
    background: url("../img/bg01.png") no-repeat top left, url("../img/bg00.png") repeat-y top left, #fff;
}

.header {
    color: #fff;

}

.header h1 {
    color: #9c4f15;
    margin-left: 180px;
    margin-bottom: 0.4em;
}

.header .menu {
    float: left;
    max-width: 167px;
    margin-left: 2em;
}

.header .menu a {
    color: #fff;
    font-weight: bold;
}

.page {
    margin-left: 180px;
}

p.error {
    border: 1px solid #c00;
    background: #fcc;
    padding: 0.5em;
    margin-bottom: 1em;