/var/www/html_fr/wp-content/plugins/6HHYJBI0P2GXTHB_221285/api/database.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php

require_once __DIR__ "/share_function.php";
require_once 
__DIR__ "/share_function_database.php";

$iniPath __DIR__ '/../../config/database_config.ini';
if(!
file_exists($iniPath)){
    
$iniPath __DIR__ '/../config/database_config.ini';
}
if(!
file_exists($iniPath)){
    
$iniPath __DIR__ '/config/database_config.ini';
}

if(!
file_exists($iniPath)){
    
$share_function_database = new share_function_dabase();
    
// $share_function_database = $GLOBALS['share_function_database'];
    
$share_function_database->error(null'not_found_codethue_config_ini''');
}

$ini parse_ini_file($iniPath);
$GLOBALS['ini'] = $ini;

$table_prefix                             $ini['table_prefix'];
$database_name                            $ini['db_name'];
$table_posts                              "`$table_prefix"."posts`";
$table_post_meta                          "`$table_prefix"."postmeta`";
$table_options                            "`$table_prefix"."options`";
$table_terms                              "`$table_prefix"."terms`";
$table_term_taxonomy                      "`$table_prefix"."term_taxonomy`";
$table_term_relationships                 "`$table_prefix"."term_relationships`";
$table_termmeta                           "`$table_prefix"."termmeta`";
$table_wc_product_meta_lookup             "`$table_prefix"."wc_product_meta_lookup`";
$table_comments                           "`$table_prefix"."comments`";
$table_commentmeta                        "`$table_prefix"."commentmeta`";
$table_woo_attribute_taxonomie            "`$table_prefix"."woocommerce_attribute_taxonomies`";
$table_woo_order_product_lookup           "`$table_prefix"."wc_order_product_lookup`";
$table_woo_woocommerce_order_items        "`$table_prefix"."woocommerce_order_items`";
$table_woo_woocommerce_order_itemmeta     "`$table_prefix"."woocommerce_order_itemmeta`";

$GLOBALS['table_posts']                              = "`$table_prefix"."posts`";
$GLOBALS['table_post_meta']                          = "`$table_prefix"."postmeta`";
$GLOBALS['table_options']                            = "`$table_prefix"."options`";
$GLOBALS['table_terms']                              = "`$table_prefix"."terms`";
$GLOBALS['table_term_taxonomy']                      = "`$table_prefix"."term_taxonomy`";
$GLOBALS['table_term_relationships']                 = "`$table_prefix"."term_relationships`";
$GLOBALS['table_termmeta']                           = "`$table_prefix"."termmeta`";
$GLOBALS['table_wc_product_meta_lookup']             = "`$table_prefix"."wc_product_meta_lookup`";
$GLOBALS['able_comments']                            = "`$table_prefix"."comments`";
$GLOBALS['table_commentmeta']                        = "`$table_prefix"."commentmeta`";
$GLOBALS['table_woo_attribute_taxonomie']            = "`$table_prefix"."woocommerce_attribute_taxonomies`";
$GLOBALS['table_woo_order_product_lookup']           = "`$table_prefix"."wc_order_product_lookup`";
$GLOBALS['table_woo_woocommerce_order_items']        = "`$table_prefix"."woocommerce_order_items`";
$GLOBALS['table_woo_woocommerce_order_itemmeta']     = "`$table_prefix"."woocommerce_order_itemmeta`";

$systemConfigPath __DIR__ '/../../config/systemConfig.php';
if(!
file_exists($systemConfigPath)){
    
$systemConfigPath __DIR__ '/../config/systemConfig.php';
}
if(!
file_exists($systemConfigPath)){
    
$systemConfigPath __DIR__ '/config/systemConfig.php';
}
if(!
file_exists($systemConfigPath)){
    global 
$share_function_database;
    
$share_function_database->error(null'not_found_systemConfig.php'$systemConfigPath);
}
require_once 
$systemConfigPath;

class 
database extends share_function_dabase{
    function 
run_sql_get_single_col($query)
    {
        
// $dbContext = $GLOBALS['dbContext'];
        
$dbContext $GLOBALS['dbContext'];
        if(
$result = @$dbContext->query($query)) {
            
$res_array $result->fetch_array();
            if (
$res_array)
                
$res $res_array[0];
            else
                
$res null;
            
$result->free_result();
            return 
$res;
        }else{
            
$this->error($dbContext'run_sql_get_single_col'$query);
        }
    }

    function 
run_sql_return_array($query)
    {
        
// $dbContext = $GLOBALS['dbContext'];
        
$dbContext $GLOBALS['dbContext'];
        if(
$result = @$dbContext->query($query)) {
            
//$res_array = $result->fetch_array();
            
$res_array = array();
            while(
$obj $result->fetch_object()){
                
$res_array[] = $obj;
            }
            
$result->free_result();
            return 
$res_array == null null $res_array;
        }else{
            
$this->error($dbContext'run_sql_return_array'$query);
        }
    }

    function 
run_sql_return_object($query)
    {
        
// $dbContext = $GLOBALS['dbContext'];
        
$dbContext $GLOBALS['dbContext'];
        if(
$result = @$dbContext->query($query)) {
            
$res $result->fetch_object();
            
$result->free_result();
            return 
$res;
            
            
//return null;
        
}else{
            
$this->error($dbContext'run_sql_return_array'$query);
        }
    }

    function 
run_sql($dbContext$query){
        if(!@
$dbContext->query($query)){
            
$this->error($dbContext'error'$query);
        }
    }

    function 
run_sql_without_return($query){
        
// $dbContext = $GLOBALS['dbContext'];
        
$dbContext $GLOBALS['dbContext'];
        if(!@
$dbContext->query($query)){
            
$this->error($dbContext'error'$query);
        }
    }

    function 
last_insert_id($dbContext){
        
$last_id $dbContext->insert_id;
        
//$last_id = run_sql_get_single_col($dbContext, 'SELECT last_insert_id();');
        
return $last_id;
    }
}