<?php
/**
 * @package embed-sharepoint-onedrive-documents
 * @author miniOrange
 * @link https://plugins.miniorange.com
 */


namespace MoSharePointObjectSync\Wrappers;

use wpdb;
class configDbWrapper
{
    private static $instance;
    public static function get_wrapper()
    {
        if (isset(self::$instance)) {
            goto gV;
        }
        $pj = __CLASS__;
        self::$instance = new $pj();
        gV:
        return self::$instance;
    }
    public static function mo_sps_create_application_config_table()
    {
        global $wpdb;
        $ar = $wpdb->get_charset_collate();
        $dq = $wpdb->prefix . "\x6d\157\137\x73\x70\x73\137\x61\160\x70\154\151\x63\x61\x74\x69\x6f\156\x5f\x63\x6f\x6e\146\151\x67";
        if (!self::mo_sps_table_exists($dq)) {
            goto B2;
        }
        return;
        B2:
        $eW = "\103\x52\105\x41\x54\x45\40\x54\101\x42\114\105\x20{$dq}\40\50\15\xa\x20\x20\x20\x20\40\x20\x20\40\x20\x20\40\x20\x69\x64\x20\155\x65\x64\x69\x75\x6d\151\x6e\164\x28\x39\51\x20\x4e\117\x54\40\116\125\114\114\40\x41\x55\x54\117\137\x49\116\103\x52\x45\x4d\105\116\124\x2c\15\xa\40\x20\40\x20\x20\40\x20\x20\x20\x20\x20\x20\x61\x70\160\x5f\x63\x6f\x6e\x66\x69\x67\40\154\157\x6e\147\x74\145\x78\164\x20\x4e\x4f\x54\40\116\125\x4c\x4c\54\xd\xa\40\x20\x20\40\40\40\x20\40\40\x20\40\x20\120\122\111\x4d\101\122\x59\40\113\105\131\x20\151\144\x20\x28\151\x64\51\xd\xa\40\x20\40\40\40\x20\x20\x20\51\40{$ar}\x3b";
        require_once ABSPATH . "\x77\x70\x2d\x61\144\x6d\151\x6e\57\151\156\143\x6c\165\x64\x65\163\57\x75\x70\x67\x72\x61\144\x65\x2e\x70\150\160";
        dbDelta($eW);
    }
    public static function mo_sps_update_application_config_table_row($KY, $Uw)
    {
        global $wpdb;
        $ei = $wpdb->prefix . "\x6d\157\x5f\163\160\163\137\141\x70\x70\154\x69\x63\x61\164\151\x6f\x6e\x5f\x63\157\x6e\146\x69\147";
        $Ya = array("\45\x73");
        $RV = self::mo_sps_get_application_config_row_id($Uw);
        if ($RV) {
            goto lF;
        }
        $wpdb->insert($ei, $KY, $Ya);
        goto qY;
        lF:
        $wpdb->update($ei, $KY, array("\x69\144" => $RV), $Ya);
        qY:
    }
    public static function mo_sps_table_exists($ei)
    {
        global $wpdb;
        $wK = $wpdb->get_results($wpdb->prepare("\x53\110\117\x57\40\124\x41\102\x4c\105\123\x20\114\111\113\x45\x20\x25\x73", $ei), ARRAY_A);
        return !empty($wK);
    }
    public static function mo_sps_get_new_id()
    {
        global $wpdb;
        $ei = $wpdb->prefix . "\155\x6f\x5f\163\160\x73\x5f\141\160\x70\154\151\x63\x61\164\151\157\x6e\x5f\143\157\156\x66\x69\x67";
        if (self::mo_sps_table_exists($ei)) {
            goto Vt;
        }
        return 0;
        Vt:
        $S0 = $wpdb->dbname;
        $wK = $wpdb->get_results($wpdb->prepare("\123\105\114\105\x43\x54\x20\140\101\125\124\x4f\x5f\x49\116\103\x52\105\x4d\x45\x4e\124\x60\x20\x46\x52\117\115\40\x20\111\116\106\x4f\x52\115\x41\x54\x49\117\116\137\x53\103\x48\105\115\101\56\124\x41\102\114\x45\x53\x20\x57\x48\x45\122\x45\x20\124\x41\x42\x4c\x45\x5f\123\103\x48\x45\x4d\101\40\75\40\45\x73\40\x41\116\x44\x20\x54\x41\x42\x4c\105\x5f\116\x41\115\105\x20\x3d\x20\45\x73", $S0, $ei), ARRAY_A);
        $Ec = $wK[0]["\x41\x55\124\117\x5f\111\116\x43\122\x45\115\x45\x4e\x54"];
        return $Ec;
    }
    public static function mo_sps_delete_row($Uw)
    {
        global $wpdb;
        $wpdb->delete($wpdb->prefix . "\155\x6f\137\163\160\x73\x5f\x61\160\160\x6c\151\x63\x61\x74\x69\157\x6e\137\x63\x6f\156\x66\151\x67", array("\x69\144" => $Uw));
    }
    public static function mo_sps_get_application_config_row_id($Uw)
    {
        global $wpdb;
        $ei = $wpdb->prefix . "\155\157\137\x73\x70\163\137\141\x70\160\x6c\151\143\141\x74\x69\x6f\x6e\x5f\143\157\x6e\146\151\x67";
        $wK = $wpdb->get_results($wpdb->prepare("\123\x45\114\105\x43\124\x20\x69\x64\x20\x46\x52\x4f\x4d\x20\45\x35\163\x20\x77\x68\145\x72\145\x20\x69\x64\x20\75\x20\x25\x73", $ei, $Uw));
        if (!empty($wK)) {
            goto QT;
        }
        return false;
        QT:
        return $wK[0]->id;
    }
    public static function mo_sps_get_application_config_table_row($Uw)
    {
        global $wpdb;
        $ei = $wpdb->prefix . "\155\157\137\x73\x70\x73\x5f\141\160\x70\x6c\x69\x63\141\164\x69\157\156\137\x63\157\x6e\146\151\147";
        $wK = $wpdb->get_results($wpdb->prepare("\x53\x45\114\x45\x43\x54\40\52\40\x46\122\x4f\x4d\40\45\65\163\x20\x77\x68\x65\x72\145\40\x69\x64\40\x3d\x20\x25\163", $ei, $Uw), ARRAY_A);
        if (!empty($wK)) {
            goto v8;
        }
        return array();
        v8:
        return $wK[0];
    }
    public static function mo_sps_get_application_config_table_rows_by_key($cD, $Uw, $Cg = "\x2a")
    {
        global $wpdb;
        $ei = $wpdb->prefix . "\155\x6f\137\x73\x70\163\137\141\x70\160\154\151\x63\141\x74\x69\x6f\156\137\143\x6f\156\146\151\147";
        $wK = $wpdb->get_results($wpdb->prepare("\123\105\x4c\105\x43\124\x20\40\45\x35\x73\40\106\122\117\115\40\x25\x35\x73\x20\x77\x68\x65\162\145\40\x25\x35\163\x20\75\40\45\x73", $Cg, $ei, $cD, $Uw), ARRAY_A);
        if (!empty($wK)) {
            goto XH;
        }
        return array();
        XH:
        return $wK;
    }
    public static function mo_sps_get_all_apllication_config()
    {
        global $wpdb;
        $ei = $wpdb->prefix . "\x6d\157\137\163\x70\x73\x5f\141\x70\160\x6c\x69\x63\141\x74\151\157\x6e\x5f\143\157\x6e\x66\151\x67";
        if (self::mo_sps_table_exists($ei)) {
            goto dW;
        }
        return array();
        dW:
        $wK = $wpdb->get_results($wpdb->prepare("\123\105\x4c\x45\103\x54\x20\151\144\x2c\x20\141\x70\x70\137\143\x6f\x6e\146\x69\147\x20\x66\x72\x6f\x6d\x20\45\x35\x73", $ei), ARRAY_A);
        return $wK;
    }
}
