HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //opt/proundcontra.mosmuc.de/queryMgr.php
<?php
class QueryMgr
{
    public function __construct()
    {
        $this->userCache = array();
    }

    /*
     * Get User Object
     */
    public function getUser($query, $forceNoCache = false)
    {
        global $sDB, $sStatistics;
        $userId = 0;
        $user   = new User();
        parse_str($query);

        if (@$userName) {
            $res = $sDB->execUsers("
                SELECT `userId`
                FROM `users`
                WHERE `userName` = '".mysqli_real_escape_string($sDB->getLink(), $userName)."'
                LIMIT 1;
            ");
            if (mysqli_num_rows($res)) {
                $row    = mysqli_fetch_object($res);
                $userId = $row->userId;
            }
        }
        if (@$userEmail) {
            $res = $sDB->execUsers("
                SELECT `userId`
                FROM `users`
                WHERE `email` = '".mysqli_real_escape_string($sDB->getLink(), $userEmail)."'
                LIMIT 1;
            ");
            if (mysqli_num_rows($res)) {
                $row    = mysqli_fetch_object($res);
                $userId = $row->userId;
            }
        }

        if ($userId) {
            // Check cache
            foreach ($this->userCache as $k => $v) {
                if ($v->getUserId() == $userId) {
                    $sStatistics->queryCacheHit();
                    return $v;
                }
            }
            // Not in cache, load from DB
            if ($user->load($userId)) {
                array_push($this->userCache, $user);
                $sStatistics->queryCacheMiss();
                return $user;
            }
        }
        return false;
    }

    /*
     * Get Current User
     * returns a user object which is either the currently logged-in user or a blank user
     */
    public function getCurrentUser()
    {
        global $sSession, $sDB;
        $user    = new User();
        $user_id = $sSession->getVal('userId');

        if ($user_id && $user_id != 0 && $user_id != "") {
            if ($sSession->getVal('stayLoggedIn') || $sSession->getVal('lastAction') > (time() - 3600)) {
                $user->load($user_id);
                if ($user->isLoggedIn() && $sSession->getVal('lastAction') < (time() - 600) && !$sSession->getVal('admin_su')) {
                    $sDB->execUsers("
                        UPDATE `users`
                        SET `user_last_action` = '".time()."'
                        WHERE `userId` = '".mysqli_real_escape_string($sDB->getLink(), $user_id)."'
                        LIMIT 1;
                    ");
                    $sSession->setVal('lastAction', time());
                } else if ($sSession->getVal('admin_su')) {
                    $sSession->setVal('lastAction', time());
                }
            } else {
                $sSession->setVal('user_id', 0);
            }
        }

        return $user;
    }

    /*
     * Get Username by user_id
     */
    public function getUsernameById($userId)
    {
        global $sDB, $sTemplate;
        if ($userId == 0) {
            return $sTemplate->getString("USERNAME_ANON");
        }

        $res = $sDB->execUsers("
            SELECT `userName`
            FROM `users`
            WHERE `userId` = '".mysqli_real_escape_string($sDB->getLink(), $userId)."'
            LIMIT 1;
        ");
        if (mysqli_num_rows($res) == 1) {
            $row = mysqli_fetch_object($res);
            return $row->userName;
        }
        return "";
    }

    public function getArgumentById($argumentId)
    {
        global $sDB;

        $res = $sDB->exec("
            SELECT *
            FROM `arguments`
            WHERE `argumentId` = '".i($argumentId)."'
            LIMIT 1;
        ");
        while ($row = mysqli_fetch_object($res)) {
            $a = new Argument($argumentId, $row);
            return $a;
        }

        return false;
    }

    public function getAuthorById($questionId, $argumentId)
    {
        global $sDB;

        if ($argumentId) {
            $res = $sDB->exec("
                SELECT `userId`
                FROM `arguments`
                WHERE `questionId` = '".i($questionId)."' 
                  AND `argumentId` = '".i($argumentId)."'
                LIMIT 1;
            ");
        } else {
            $res = $sDB->exec("
                SELECT `userId`
                FROM `questions`
                WHERE `questionId` = '".i($questionId)."'
                LIMIT 1;
            ");
        }

        while ($row = mysqli_fetch_object($res)) {
            return $row->userId;
        }

        return -1;
    }

    public function getCurrentTags()
    {
        global $sRequest;

        $tags = $sRequest->getString("tags");
        $tags = explode("-", $tags);

        return $tags;
    }

    public function getQuestionById($questionId)
    {
        global $sDB;

        $res = $sDB->exec("
            SELECT *
            FROM `questions`
            WHERE `questionId` = '".i($questionId)."'
            LIMIT 1;
        ");
        while ($row = mysqli_fetch_object($res)) {
            $q = new Question($questionId, $row);
            return $q;
        }

        return false;
    }

    private $userCache;
}
?>