Objet : devel-adl
Archives de la liste
- From: svn AT agendadulibre.org
- To: devel AT agendadulibre.org
- Subject: [Devel] r274 - branches/dui
- Date: Sun, 20 May 2007 10:40:21 +0200 (CEST)
- List-archive: <http://lolut.utbm.info/pipermail/devel>
- List-id: Developpement de l'Agenda du Libre <devel.agendadulibre.org>
Author: ldayot
Date: Sun May 20 10:40:18 2007
New Revision: 274
Log:
Deplacement de l'identification pour la moderation vers sessions.inc.php.
Evite repetition du code dans differents scripts qui reclament cette
identification de moderateur.
Modified:
branches/dui/moderate.php
branches/dui/session.inc.php
branches/dui/upgrade.php
Modified: branches/dui/moderate.php
==============================================================================
--- branches/dui/moderate.php (original)
+++ branches/dui/moderate.php Sun May 20 10:40:18 2007
@@ -22,25 +22,11 @@
include("bd.inc.php");
include("funcs.inc.php");
-include("session.inc.php");
include("diff.inc.php");
$db = new db();
+include("session.inc.php");
-function user_find_login ($db, $userid)
-{
- $sql = "SELECT login FROM users WHERE id=" . $db->quote_smart($userid);
- $ret = $db->query ($sql);
- if ($ret == FALSE)
- {
- error ("La requ�te <i>" . $sql . "</i> a �chou�");
- return -1;
- }
-
- $row = $db->fetchObject ($ret);
-
- return $row->login;
-}
function save_event ($db, $id, $title, $start, $end, $description, $city,
$region, $locality, $url, $contact, $submitter, $tags,
$userid)
@@ -224,67 +210,6 @@
return 0;
}
-/*
- * Returns a positive ID if user identified, -1 otherwise
- */
-function user_identify ($db, $login, $password)
-{
- $sql = "SELECT id FROM users WHERE login=" . $db->quote_smart($login) . "
AND password=" . $db->quote_smart(md5($password));
- $ret = $db->query ($sql);
- if ($ret == FALSE)
- {
- error ("Erreur lors de la requ�te <i>" . $sql . "</i>");
- return -1;
- }
-
- if ($db->numRows ($ret) != 1)
- {
- return -1;
- }
-
- $row = $db->fetchObject($ret);
-
- return $row->id;
-}
-
-
-$session = new session();
-
-if (! $session->exists("agenda_libre_id"))
-{
- if (! isset($_POST['__user_identify']))
- {
- put_header("Mod�ration");
-
- echo "<h2>Identification</h2>";
- echo "<table align=\"center\">";
- echo "<form method=\"post\">\n";
- echo "<tr><td>Login:</td><td><input type=\"text\"
name=\"__user_login\" size=\"20\"/></td></tr>";
- echo "<tr><td>Mot de passe:</td><td><input type=\"password\"
name=\"__user_password\" size=\"20\"/></td></tr>";
- echo "<tr><td></td><td><input type=\"submit\" name=\"__user_identify\"
value=\"Identifier\"></td></tr>";
- echo "</form>";
- echo "</table>";
-
- put_footer();
- exit;
- }
- else
- {
- if (($ret = user_identify ($db, $_POST['__user_login'],
$_POST['__user_password'])) > 0)
- {
- $session->set("agenda_libre_id", $ret);
- }
- else
- {
- put_header("Mod�ration");
- echo "Mauvais login/pass";
- put_footer();
- exit;
- }
- }
-}
-
-
put_header("Mod�ration");
/*
Modified: branches/dui/session.inc.php
==============================================================================
--- branches/dui/session.inc.php (original)
+++ branches/dui/session.inc.php Sun May 20 10:40:18 2007
@@ -58,4 +58,79 @@
session_destroy();
}
}
+
+function user_find_login ($db, $userid)
+{
+ $sql = "SELECT login FROM users WHERE id=" . $db->quote_smart($userid);
+ $ret = $db->query ($sql);
+ if ($ret == FALSE)
+ {
+ error ("La requ�te <i>" . $sql . "</i> a �chou�");
+ return -1;
+ }
+
+ $row = $db->fetchObject ($ret);
+
+ return $row->login;
+}
+
+/*
+ * Returns a positive ID if user identified, -1 otherwise
+ */
+function user_identify ($db, $login, $password)
+{
+ $sql = "SELECT id FROM users WHERE login=" . $db->quote_smart($login) . "
AND password=" . $db->quote_smart(md5($password));
+ $ret = $db->query ($sql);
+ if ($ret == FALSE)
+ {
+ error ("Erreur lors de la requ�te <i>" . $sql . "</i>");
+ return -1;
+ }
+
+ if ($db->numRows ($ret) != 1)
+ {
+ return -1;
+ }
+
+ $row = $db->fetchObject($ret);
+
+ return $row->id;
+}
+
+$session = new session();
+
+if (! $session->exists("agenda_libre_id"))
+{
+ if (! isset($_POST['__user_identify']))
+ {
+ put_header("Mod�ration");
+
+ echo "<h2>Identification</h2>";
+ echo "<table align=\"center\">";
+ echo "<form method=\"post\">\n";
+ echo "<tr><td>Login:</td><td><input type=\"text\"
name=\"__user_login\" size=\"20\"/></td></tr>";
+ echo "<tr><td>Mot de passe:</td><td><input type=\"password\"
name=\"__user_password\" size=\"20\"/></td></tr>";
+ echo "<tr><td></td><td><input type=\"submit\" name=\"__user_identify\"
value=\"Identifier\"></td></tr>";
+ echo "</form>";
+ echo "</table>";
+
+ put_footer();
+ exit;
+ }
+ else
+ {
+ if (($ret = user_identify ($db, $_POST['__user_login'],
$_POST['__user_password'])) > 0)
+ {
+ $session->set("agenda_libre_id", $ret);
+ }
+ else
+ {
+ put_header("Upgrade");
+ echo "Mauvais login/pass";
+ put_footer();
+ exit;
+ }
+ }
+}
+
?>
Modified: branches/dui/upgrade.php
==============================================================================
--- branches/dui/upgrade.php (original)
+++ branches/dui/upgrade.php Sun May 20 10:40:18 2007
@@ -18,88 +18,16 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
- */
+ *
+ * $Id: top.inc.php,v 1.51 2007/03/10 16:22:12 ldayot Exp $
+*/
include("bd.inc.php");
include("funcs.inc.php");
-include("session.inc.php");
include("diff.inc.php");
$db = new db();
-
-function user_find_login ($db, $userid)
-{
- $sql = "SELECT login FROM users WHERE id=" . $db->quote_smart($userid);
- $ret = $db->query ($sql);
- if ($ret == FALSE)
- {
- error ("La requ�te <i>" . $sql . "</i> a �chou�");
- return -1;
- }
-
- $row = $db->fetchObject ($ret);
-
- return $row->login;
-}
-
-/*
- * Returns a positive ID if user identified, -1 otherwise
- */
-function user_identify ($db, $login, $password)
-{
- $sql = "SELECT id FROM users WHERE login=" . $db->quote_smart($login) . "
AND password=" . $db->quote_smart(md5($password));
- $ret = $db->query ($sql);
- if ($ret == FALSE)
- {
- error ("Erreur lors de la requ�te <i>" . $sql . "</i>");
- return -1;
- }
-
- if ($db->numRows ($ret) != 1)
- {
- return -1;
- }
-
- $row = $db->fetchObject($ret);
-
- return $row->id;
-}
-
-$session = new session();
-
-if (! $session->exists("agenda_libre_id"))
-{
- if (! isset($_POST['__user_identify']))
- {
- put_header("Mod�ration");
-
- echo "<h2>Identification</h2>";
- echo "<table align=\"center\">";
- echo "<form method=\"post\">\n";
- echo "<tr><td>Login:</td><td><input type=\"text\"
name=\"__user_login\" size=\"20\"/></td></tr>";
- echo "<tr><td>Mot de passe:</td><td><input type=\"password\"
name=\"__user_password\" size=\"20\"/></td></tr>";
- echo "<tr><td></td><td><input type=\"submit\" name=\"__user_identify\"
value=\"Identifier\"></td></tr>";
- echo "</form>";
- echo "</table>";
-
- put_footer();
- exit;
- }
- else
- {
- if (($ret = user_identify ($db, $_POST['__user_login'],
$_POST['__user_password'])) > 0)
- {
- $session->set("agenda_libre_id", $ret);
- }
- else
- {
- put_header("Upgrade");
- echo "Mauvais login/pass";
- put_footer();
- exit;
- }
- }
-}
+include("session.inc.php");
put_header("Upgrade");
- [Devel] r274 - branches/dui, svn, 20/05/2007
Archives gérées par MHonArc 2.6.16.