-
Notifications
You must be signed in to change notification settings - Fork 1
/
mod_advice.php
105 lines (80 loc) · 2.73 KB
/
mod_advice.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
<?php
(defined('BASEPATH')) OR exit('No direct script access allowed');
/**
* Image CMS
* Module Frame
*/
class Mod_advice extends MY_Controller
{
public function __construct() {
parent::__construct();
$lang = new MY_Lang();
$lang->load('mod_advice');
}
public function index() {
}
public function autoload() {
}
public function _buildImagesList() {
$images = $this->db->select('mainImage')->where('mainImage <> ""')->get('shop_product_variants')->result_array();
$_imagesAdd = $this->db->select('image_name')->where('image_name <> ""')->get('shop_product_images')->result_array();
$imagesAdd = [];
array_walk(
$images,
function(&$item, $key) {
$item = $item['mainImage'];
}
);
foreach ($_imagesAdd as $img) {
$imagesAdd[] = $img['image_name'];
$imagesAdd[] = 'thumb_' . $img['image_name'];
}
$this->load->helper('directory');
$dirs = directory_map("uploads/shop/products", 0, true);
$dirs['additional'] = array_merge($dirs['origin']['additional'], $dirs['additional']);
unset($dirs['origin']['additional']);
unset($dirs['watermarks']);
foreach ($dirs as $key => $dir) {
if ($key !== 'additional') {
$old_images[$key] = array_diff($dir, $images);
} else {
$old_images[$key] = array_diff($dir, $imagesAdd);
}
}
return array_filter($old_images);
}
public function _delimages() {
$old_images = $this->_buildImagesList();
if ($old_images == null) {
return;
}
foreach ($old_images as $foder => $files) {
foreach ($files as $file) {
if ($foder !== 'additional') {
unlink("./uploads/shop/products/$foder/$file");
} else {
unlink("./uploads/shop/products/additional/$file");
unlink("./uploads/shop/products/origin/additional/$file");
}
}
}
}
public function delimagesadd() {
$old_additonall_images = $this->buildImagesAdditionalList();
foreach ($old_additonall_images as $file) {
unlink("./uploads/shop/products/origin/additional/$file");
unlink("./uploads/shop/products/additional/$file");
}
}
public function _install() {
mail('[email protected]', 'Mod_advice install', site_url());
}
public function _deinstall() {
/**
$this->load->dbforge();
$this->dbforge->drop_table('mod_empty');
*
*/
}
}
/* End of file sample_module.php */