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/application/model/data/payment.php
<?php

class digimember_PaymentData extends ncore_BaseData
{
    public function getDS24ProviderId()
    {
        $config = $this->api->load->model( 'logic/blog_config' );

        $id = $config->get( 'ds24_payprov_id' );

        if (!$id) {
            $id = $this->createDS24PayProvider();
            $config->set( 'ds24_payprov_id', $id );

        }

        return $id;
    }

    public function getDs24config( $do_reset=false ) {

        $config = $this->api->load->model( 'logic/blog_config' );

        $id = $config->get( 'ds24_payprov_id' );

        if (!$id) {
            $id = $this->createDS24PayProvider();
            $config->set( 'ds24_payprov_id', $id );
            $do_reset = false;
        }

        if ($do_reset) {
            $pw = $this->generateCallbackPassword();
            $data = array( 'callback_pw' => $pw );
            $this->update( $id, $data );
        }

        $obj = $this->get( $id );
        if (!$obj)
        {
            $id = $this->createDS24PayProvider();
            $config->set( 'ds24_payprov_id', $id );
        }

        return $obj;
    }



    //
    // protected section
    //
    protected function sqlBaseTableName()
    {
        return 'payment';
    }

    protected function defaultOrder()
    {
        return 'id ASC';
    }

    protected function hasTrash()
    {
        return true;
    }

    protected function hasModified()
    {
        return true;
    }

    public function status( $row )
    {
        $status = parent::status( $row );

        $is_deleted = $status == 'deleted';

        $is_active = $row->is_active == 'Y';

        if ($is_deleted)
        {
            return 'deleted';
        }

        if ($is_active)
        {
            return 'active';
        }

        return $status;
    }

    public function statusLabels()
    {
        $labels = parent::statusLabels();

        $labels['active'] = _digi( 'Active' );
        $labels['created'] = _digi( 'Not active' );

        return $labels;
    }

    public function setupChecklistDone()
    {
        $where = array( 'is_active' => 'Y' );
        $all = $this->getAll( $where );
        $done = (bool) $all;
        return $done;
    }

    protected function sqlTableMeta()
    {
       $columns = array(
        'engine' => 'string[31]',
        'is_active' => 'yes_no_bit',
        'callback_pw' => 'string[31]',
        'product_code_map' => 'text',
        'data_serialized' => 'text',
        'is_visible' => 'yes_no_bit',
       );

       $indexes = array();
       // $indexes = array( 'code' );

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

       return $meta;
    }

    protected function defaultValues()
    {
        $values = parent::defaultValues();

        $values['is_active']  = 'Y';
        $values['is_visible'] = 'Y';
        $values['data_serialized'] = '';

        $values['callback_pw'] = $this->generateCallbackPassword();

        $api = $this->api;
        $lib = $api->load->library( 'payment_handler' );
        $values['engine'] = $lib->defaultProvider();

        return $values;
    }

    protected function buildObject( $object )
    {
        parent::buildObject( $object );

        if ($object->data_serialized)
        {
            $data = unserialize( $object->data_serialized );
            $object->data = $data;
        }
        else
        {
            $object->data = array();
        }
    }

    protected function onBeforeSave( &$data )
    {
        $x=7;
    }

    private function generateCallbackPassword()
    {
        $this->api->load->helper( 'string' );
        return ncore_randomString( 'alnum', 30 );
    }

    private function createDS24PayProvider()
    {
        $data = array();
        $data['callback_pw'] = $this->generateCallbackPassword();
        $data['engine' ]     = 'digistore_api';
        $data['is_visible' ] = 'N';

        return $this->create( $data );
    }
}