librefm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Librefm-commits] [1627] convert auth.php to adodb


From: Clint Adams
Subject: [Librefm-commits] [1627] convert auth.php to adodb
Date: Fri, 15 May 2009 16:35:13 +0000

Revision: 1627
          http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1627
Author:   clint
Date:     2009-05-15 16:35:13 +0000 (Fri, 15 May 2009)
Log Message:
-----------
convert auth.php to adodb

Modified Paths:
--------------
    trunk/nixtape/auth.php

Modified: trunk/nixtape/auth.php
===================================================================
--- trunk/nixtape/auth.php      2009-05-15 16:30:56 UTC (rev 1626)
+++ trunk/nixtape/auth.php      2009-05-15 16:35:13 UTC (rev 1627)
@@ -19,21 +19,27 @@
 
 */
 
-require_once('database.php');
+require_once('database2.php');
 require_once('data/User.php');
 session_start();
 if(isset($_COOKIE['session_id'])) {
-       $res = $mdb2->query('SELECT username FROM Scrobble_Sessions WHERE '
-               . 'sessionid = ' . $mdb2->quote($_COOKIE['session_id'], 'text')
-               . ' AND expires > ' . $mdb2->quote(time(), 'integer'));
-       if(PEAR::isError ($res) || !$res->numRows()) {
+       $err = 0;
+       $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+       try {
+               $row = $adodb->GetRow('SELECT username FROM Scrobble_Sessions 
WHERE '
+                               . 'sessionid = ' . 
$adodb->qstr($_COOKIE['session_id'])
+                               . ' AND expires > ' . (int)(time()));
+       }
+       catch (exception $e) {
+               $err = 1;
+       }
+       if($err || !$row) {
                // Session is invalid
                setcookie('session_id', '', time() - 3600);
                session_unset();
                session_destroy();
        } else {
                $logged_in = true;
-               $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
                $this_user = new User($row['username']);
        }
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]