public static function Log($action, $user, $ip, $comment = '') { if (UL_LOG == false) { return true; } $now = ulUtils::nowstring(); $stmt = ulPdoDb::Prepare('log', 'INSERT INTO ul_log (timestamp, action, comment, user, ip) VALUES (?, ?, ?, ?, ?)'); return ulPdoDb::BindExec($stmt, NULL, array(&$now, 'str', &$action, 'str', &$comment, 'str', &$user, 'str', &$ip, 'str')); }
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 function gc() { $now = ulUtils::nowstring(); // Delete old sessions $stmt = ulPdoDb::Prepare('session', 'DELETE FROM ul_sessions WHERE session_expires<=?'); ulPdoDb::BindExec($stmt, NULL, array(&$now, 'str')); return true; }
function CreateLogin($username, $password, $profile) { // Create password hash with a new salt $hashed_password = ulPassword::Hash($password, UL_PWD_FUNC); $now = ulUtils::nowstring(); $past = date_format(date_create('1000 years ago'), UL_DATETIME_FORMAT); $stmt = ulPdoDb::Prepare('update', 'INSERT INTO ul_logins (username, password, date_created, last_login, block_expires) VALUES (?, ?, ?, ?, ?)'); if (!ulPdoDb::BindExec($stmt, NULL, array(&$username, 'str', &$hashed_password, 'str', &$now, 'str', &$now, 'str', &$past, 'str'))) { if (ulPdoDb::ErrorCode() == '23000') { // Probably, the user already exists return ulLoginBackend::ALREADY_EXISTS; } else { // No, it wasn't a duplicate user... let's fail miserably. return ulLoginBackend::BACKEND_ERROR; } } return true; }