|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
(defined('BASEPATH')) OR exit('No direct script access allowed'); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Helper controller for maintenance |
|
7
|
|
|
*/ |
|
8
|
|
|
class Cli extends \MY_Controller |
|
9
|
|
|
{ |
|
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
public function __construct() { |
|
12
|
|
|
|
|
13
|
|
|
if (PHP_SAPI !== 'cli') { |
|
14
|
|
|
$this->core->error_404(); |
|
15
|
|
|
} |
|
16
|
|
|
parent::__construct(); |
|
17
|
|
|
$this->load->helper('cli'); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* |
|
22
|
|
|
* @param string $name |
|
23
|
|
|
* @param string $email |
|
24
|
|
|
* @param string $password |
|
25
|
|
|
* < php index.php exchange cli create_admin > |
|
|
|
|
|
|
26
|
|
|
*/ |
|
27
|
|
|
public function create_admin($name = null, $email = null, $password = null) { |
|
28
|
|
|
|
|
29
|
|
|
// This is defaults. Order must be like in function arguments |
|
30
|
|
|
$argumentsDefaults = [ |
|
31
|
|
|
'admin', |
|
32
|
|
|
'[email protected]', |
|
33
|
|
|
'admin', |
|
34
|
|
|
]; |
|
35
|
|
|
$argumentsValues = func_get_args(); |
|
36
|
|
|
$data = []; |
|
37
|
|
|
|
|
38
|
|
|
foreach ($argumentsDefaults as $i => $value) { |
|
39
|
|
|
$data[$i] = $argumentsValues[$i] ?: $argumentsDefaults[$i]; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$res = $this->dx_auth->register($data[0], $data[2], $data[1], '', '', ''); |
|
43
|
|
|
|
|
44
|
|
|
$this->db->update('users', ['role_id' => 1], ['email' => $data[1]], 1); |
|
45
|
|
|
|
|
46
|
|
|
_outputLine($res ? 'Created' : 'Error'); |
|
47
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Truncates data for 1C import |
|
52
|
|
|
* < php index.php exchange cli truncate > |
|
53
|
|
|
*/ |
|
54
|
|
|
public function truncate() { |
|
55
|
|
|
|
|
56
|
|
|
// if (true != _confirm('Really truncate data for import', true)) { |
|
57
|
|
|
// _outputLine('Canceled'); |
|
58
|
|
|
// return; |
|
59
|
|
|
// } |
|
60
|
|
|
|
|
61
|
|
|
$this->db->truncate('shop_category'); |
|
62
|
|
|
$this->db->truncate('shop_category_i18n'); |
|
63
|
|
|
|
|
64
|
|
|
$this->db->truncate('shop_brands'); |
|
65
|
|
|
$this->db->truncate('shop_brands_i18n'); |
|
66
|
|
|
|
|
67
|
|
|
$this->db->truncate('shop_products'); |
|
68
|
|
|
$this->db->truncate('shop_products_i18n'); |
|
69
|
|
|
$this->db->truncate('shop_product_variants'); |
|
70
|
|
|
$this->db->truncate('shop_product_variants_i18n'); |
|
71
|
|
|
$this->db->truncate('shop_product_categories'); |
|
72
|
|
|
|
|
73
|
|
|
$this->db->truncate('shop_product_properties'); |
|
74
|
|
|
$this->db->truncate('shop_product_properties_i18n'); |
|
75
|
|
|
$this->db->truncate('shop_product_properties_categories'); |
|
76
|
|
|
$this->db->truncate('shop_product_properties_data'); |
|
77
|
|
|
$this->db->truncate('shop_product_properties_data_i18n'); |
|
78
|
|
|
$this->db->truncate('shop_product_images'); |
|
79
|
|
|
|
|
80
|
|
|
$this->db->truncate('shop_orders'); |
|
81
|
|
|
$this->db->truncate('shop_orders_products'); |
|
82
|
|
|
|
|
83
|
|
|
_outputLine('Data truncated!'); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
} |