3 * brisk - dbase_file.phh
5 * Copyright (C) 2006-2011 Matteo Nastasi
6 * mailto: nastasi@alternativeoutput.it
7 * matteo.nastasi@milug.org
8 * web: http://www.alternativeoutput.it
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details. You should have received a
19 * copy of the GNU General Public License along with this program; if
20 * not, write to the Free Software Foundation, Inc, 59 Temple Place -
21 * Suite 330, Boston, MA 02111-1307, USA.
25 require_once("${G_base}Obj/dbase_base.phh");
27 define(BRISK_AUTH_CONF, "brisk_auth.conf.pho");
36 log_main("BriskDB create:start");
38 log_main("BriskDB create:end");
41 static function &create()
50 GLOBAL $DOCUMENT_ROOT;
52 if (file_exists("$DOCUMENT_ROOT/Etc/".BRISK_AUTH_CONF)) {
53 require("$DOCUMENT_ROOT/Etc/".BRISK_AUTH_CONF);
56 $this->item = array( new LoginDBItem(1, "uno", md5("one"), "pippo@pluto.com", USER_FLAG_TY_SUPER),
57 new LoginDBItem(2, "due", md5("two"), "pippo@pluto.com", USER_FLAG_TY_NORM),
58 new LoginDBItem(3, "a_b", md5("abb"), "pippo@pluto.com", USER_FLAG_TY_NORM),
59 new LoginDBItem(4, "tre", md5("three"), "pippo@pluto.com", USER_FLAG_TY_NORM) );
61 $this->item_n = count($this->item);
66 return ($this->item_n);
69 function login_exists($login)
71 log_main("login_exists: ".$login);
73 /* check the existence of the nick in the BriskDB */
74 for ($i = 0 ; $i < $this->item_n ; $i++) {
75 if (strcasecmp($this->item[$i]->login, $login) == 0) {
76 log_main("login[".$i."]: ".$this->item[$i]->login);
83 function getlogin_byidx($idx)
85 if ($idx >= $this->item_n)
87 return ($this->item[$idx]->login);
90 function &getitem_bylogin($login, &$id)
94 log_main("login_exists: ".$login);
96 /* check the existence of the nick in the BriskDB */
97 for ($i = 0 ; $i < $this->item_n ; $i++) {
98 if (strcasecmp($this->item[$i]->login, $login) == 0) {
99 log_main("login[".$i."]: ".$this->item[$i]->login);
100 $ret = &$this->item[$i];
109 function getmail($login)
113 /* check the existence of the nick in the BriskDB */
114 for ($i = 0 ; $i < $this->item_n ; $i++) {
115 if (strcasecmp($this->item[$i]->login, $login) == 0) {
116 log_main("login[".$i."]: ".$this->item[$i]->login);
117 return ($this->item[$i]->email);
123 function gettype($login)
127 /* check the existence of the nick in the BriskDB */
128 for ($i = 0 ; $i < $this->item_n ; $i++) {
129 if (strcasecmp($this->item[$i]->login, $login) == 0) {
130 log_main("login[".$i."]: ".$this->item[$i]->login);
131 return ($this->item[$i]->type);
137 function &login_verify($login, $pass)
143 log_main("login_verify: ".$login);
145 /* check the existence of the nick in the BriskDB */
146 for ($i = 0 ; $i < $this->item_n ; $i++) {
147 log_main("login_verify: LOOP");
148 if (strcasecmp($this->item[$i]->login, $login) == 0) {
149 log_main("login[".$i."]: ".$this->item[$i]->login);
151 /* if it exists check for a valid challenge */
152 if (($a_sem = Challenges::lock_data()) != FALSE) {
154 if (($chals = &Challenges::load_data()) != FALSE) {
155 for ($e = 0 ; $e < $chals->item_n ; $e++) {
157 log_main("challenge[".$i."]: ".$chals->item[$e]->login);
158 if (strcmp($login, $chals->item[$e]->login) == 0) {
159 log_main("login_verify [".$pass."] with [".md5($chals->item[$e]->token.$this->item[$i]->pass)."]");
161 if (strcmp($pass , md5($chals->item[$e]->token.$this->item[$i]->pass)) == 0) {
162 log_main("login_verify SUCCESS for ".$login);
165 $ret = &$this->item[$i];
169 } // end for ($e = 0 ...
172 if ($chals->ismod()) {
173 Challenges::save_data(&$chals);
176 Challenges::unlock_data($a_sem);
179 } // if (strcasecmp($this->item[$i]->login, ...
185 function bin5_points_save($date, $ttok, $tidx, $codes, $pts)
189 } // End class BriskDB