Browse the code
| Revision log Information on the revision | |
|---|---|
| Revision: | 276 (differences) |
| Author: | xbright |
| Log message: |
Show private projects in a profile only if the user is the current visitor |
| Change revision: | |
0
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
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
<?php # This file is a part of CodingTeam. See <http://www.codingteam.net>. # Copyright (C) 2007-2009 CodingTeam (See AUTHORS and THANKS for details) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, version 3 only. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. class View { private $session, $db, $page, $error, $langlist, $lang; public $metatags, $maincontent; function __construct($session, $db, $page, $error, $langlist, $lang) { // Variables $this->ct_session = $session; $this->ct_db = $db; $this->page = $page; $this->error = $error; $this->langlist = $langlist; $this->lang = $lang; // Meta tags $this->metatags = array('title' => i18n('Password recovering')); // Exit if logged if ($this->ct_session->isLogged()) $this->error->displayError(i18n('You cannot recover your password '. 'when you are logged.'), 0); } function showFeed() { } function treatForms() { $this->form_error = 0; $this->form_info = 0; // Clean POST values foreach ($_POST as $key => $value) if (!is_scalar($value)) exit('Error.'); if (count($_POST) == 1) { $email = $this->ct_db->cleanentry($_POST['mail'], TRUE); $user = getUser($email, $this->ct_db, 'email'); if ($user) { $key = $user->getKeyid(); $text = i18n('This is your personnal key (42 characters) for '. 'the second step of password recovering:'."\n". '%(key)s', array('key' => $key)); $mail = sendmail(i18n('Recovering password: your key'), $text, $user->getEmail(), $this->ct_db); if (!$mail) $this->form_error = i18n('Mail cannot be sended!'); else $this->form_info = i18n('Please check your mails.'); } else $this->form_error = i18n('No user found with this email.'); } elseif (count($_POST) == 3) { $key = $this->ct_db->cleanentry($_POST['key'], TRUE); $password0 = $this->ct_db->cleanentry($_POST['password0'], TRUE); $password1 = $this->ct_db->cleanentry($_POST['password1'], TRUE); if (strlen($key) != 42) $this->form_error = i18n('Key length is wrong!'); if ($password0 != $password1) $this->form_error = i18n('Please confirm your password!'); if (!$this->form_error) { $user = getUser($key, $this->ct_db, 'keyid'); $classadm = getClass('project.admins', $this->ct_db); $classprj = getClass('projects.projects', $this->ct_db); if ($user) { $escn = escapeshellarg($user->getNickname()); $escp = escapeshellarg($password0); exec(escapeshellcmd('htpasswd -nbm '.$escn.' '.$escp), $output); $line = explode(':', $output[0]); $user->setApache_password($line[1]); foreach (array('projects', 'projects_admins') as $type) { $projects = $classadm->getAdmins($user->getId(), 'user', $type); foreach ($projects as $project) { if (isset($project['projectid'])) $id = $project['projectid']; else $id = $project['id']; $classprj->load($id); $dbname = $classprj->getDbname(); $classsvnadm = getClass('project.svnadmin', $dbname); $classsvnadm->deleteUser($user->getNickname()); $classsvnadm->addUser($user->getNickname(), $line[1]); $classprj->unload(); } } $user->setPassword(md5($password0)); $this->ct_session->login($user->getNickname(), $password0, 0); Header('Location: '.CT_BASEURL.'index'); } else $this->form_error = i18n('No user found with this key.'); } } } function constructView() { $construct = array(); $construct['__tpl__'] = 'password.tpl'; $construct['form_error'] = $this->form_error; $construct['form_info'] = $this->form_info; return $construct; } } ?>

CodingTeam