public static function Clean()
 {
     // We have found a nonce, invalidate it
     $now = ulUtils::nowstring();
     $stmt = ulPdoDb::Prepare('session', 'DELETE FROM ul_nonces WHERE nonce_expires<?');
     if (!ulPdoDb::BindExec($stmt, NULL, array(&$now, 'str'))) {
         ul_db_fail();
         return false;
     }
     return true;
 }
 public static function IpBlocked($ip)
 {
     $block_expires = NULL;
     $stmt = ulPdoDb::Prepare('log', 'SELECT block_expires FROM ul_blocked_ips WHERE ip=?');
     if (!ulPdoDb::BindExec($stmt, array(&$block_expires, 'str'), array(&$ip, 'str'))) {
         ul_db_fail();
         return false;
     }
     if (ulPdoDb::Fetch($stmt)) {
         $block_expires = new DateTime($block_expires);
         if ($block_expires <= date_create('now')) {
             self::SetBlock($ip, 0);
         }
     } else {
         $block_expires = new DateTime('1000 years ago');
     }
     return $block_expires;
 }
Example #3
0
 public static function TableExists($dbuser, $table_name)
 {
     self::Connect($dbuser);
     // Add compatible syntax for sqlite
     $query = self::$dbcon->getAttribute(PDO::ATTR_DRIVER_NAME) === 'sqlite' ? 'SELECT name FROM sqlite_master WHERE type = "table" AND name = ?' : 'SHOW TABLES LIKE ?';
     $stmt = ulPdoDb::Prepare($dbuser, $query);
     if (false === $stmt) {
         ul_db_fail();
     }
     if (!ulPdoDb::BindExec($stmt, NULL, array(&$table_name, 'str'))) {
         return false;
     }
     if (!ulPdoDb::Fetch($stmt)) {
         return false;
     }
     return true;
 }
 public function write($id, $data)
 {
     if ($this->Lock($id) != true) {
         return false;
     }
     $stmt = ulPdoDb::Prepare('session', 'UPDATE ul_sessions SET data=? WHERE id=?');
     if (!ulPdoDb::BindExec($stmt, NULL, array(&$data, 'lob', &$id, 'str'))) {
         ul_db_fail('Session management error.');
         return false;
     }
 }
 protected function UserBlockExpires($uid, &$flagged)
 {
     $expires = NULL;
     $flagged = false;
     $stmt = ulPdoDb::Prepare('auth', 'SELECT block_expires FROM ul_logins WHERE id=?');
     if (!ulPdoDb::BindExec($stmt, array(&$expires, 'str'), array(&$uid, 'int'))) {
         ul_db_fail();
         return ulLoginBackend::BACKEND_ERROR;
     }
     if (!ulPdoDb::Fetch($stmt)) {
         return ulLoginBackend::NO_SUCH_USER;
     }
     return new DateTime($expires);
 }