HEX
Server: Apache/2.4.25
System: Linux ion14 4.9.0-8-amd64 #1 SMP Debian 4.9.144-3.1 (2019-02-19) x86_64
User: (10087)
PHP: 7.4.30
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,system, exec, shell_exec, passthru, popen, proc_open
Upload Files
File: /home/www/web115/wordpress/wp-content/plugins/digimember/system/model/data/session_store.php
<?php

final class ncore_SessionStoreData extends ncore_BaseData
{
    public function cronDaily()
    {
        $table = $this->sqlTableName();

        $now = ncore_dbDate();

        $sql = "DELETE FROM $table
                WHERE expire < '$now'";

        $this->db()->query($sql);
    }

    public function dataType()
    {
        return NCORE_MODEL_DATA_TYPE_SESSION;
    }

    function store( $session_key, $session_data, $lifetime_hours=24 )
    {
        $table = $this->sqlTableName();
        $session_key    = ncore_washText( $session_key );
        $lifetime_hours = intval( $lifetime_hours );

        if (!$session_data)
        {
            $sql = "DELETE FROM $table
                    WHERE name = '$session_key'";
            $this->db()->query( $sql );
            return;
        }

        $expire = ncore_dbDate( time() + $lifetime_hours * 3600 );

        $session_data_serialized = serialize( $session_data );
        $session_data_esc = $this->db()->escape( $session_data_serialized );
        $sql = "UPDATE $table
                SET data_serialized = \"$session_data_esc\",
                    expire          = '$expire'
                WHERE name = '$session_key'";
        $this->db()->query( $sql );
        $modified = $this->db()->modified();

        if (!$modified) {

            $are_same_data_stored = (bool) $this->retrieve( $session_key, 0 );
            if (!$are_same_data_stored) {
                $data = array();
                $data[ 'name' ] = $session_key;
                $data[ 'data_serialized' ] = $session_data_serialized;
                $data[ 'expire' ] = $expire;
                $this->create( $data );
            }
        }
    }

    function retrieve( $session_key, $lifetime_hours=24)
    {
        $table = $this->sqlTableName();
        $session_key    = ncore_washText( $session_key );
        $lifetime_hours = intval( $lifetime_hours );

        $sql = "SELECT data_serialized,
                       expire
                FROM $table
                WHERE name = '$session_key'
                LIMIT 0,1";

        $rows = $this->db()->query( $sql );

        if (!$rows) {
            return array();
        }

        $row = $rows[0];

        $must_udpate_timestamp = $row->expire < ncore_dbDate( time() + 3600 * $lifetime_hours / 2 );
        if ($must_udpate_timestamp) {
            $expire = ncore_dbDate( time() + 3600 * $lifetime_hours );
            $sql = "UPDATE $table
                    SET expire = '$expire'
                    WHERE name= '$session_key'";
            $this->db()->query( $sql );
        }

        $data = unserialize( $row->data_serialized );

        return $data;
    }


    //
    // protected
    //
    protected function sqlBaseTableName()
    {
        return 'session_store';
    }

    protected function sqlTableMeta()
    {
       $columns = array(
            'name'            => 'string[47]',
            'data_serialized' => 'text',
            'expire'          => 'lock_date',
       );

       $indexes = array( 'name', 'expire' );

       $meta = array(
        'columns' => $columns,
        'indexes' => $indexes,
       );

       return $meta;
    }

    protected function isUniqueInBlog() {

        return true;
    }

}