-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathscript.php
More file actions
executable file
·176 lines (154 loc) · 3.27 KB
/
Copy pathscript.php
File metadata and controls
executable file
·176 lines (154 loc) · 3.27 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
/**
* JUNewsUltra Pro for Joomla!
*
* @package JUNewsUltra Pro
*
* @copyright Copyright (C) 2007-2025 Denys Nosov. All rights reserved.
* @license GNU/GPL - https://gnu.org/copyleft/gpl.html
*
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;
/**
* Installation class to perform additional changes during install/uninstall/update
*
* @since 6.0
* @package JUNewsUltra Pro
*/
class Pkg_JUNewsUltraInstallerScript
{
/**
* @since 6.0
* @var
*/
protected $message;
/**
* @since 6.0
* @var
*/
protected $status;
/**
* @since 6.0
* @var
*/
protected $sourcePath;
/**
* @param $type
* @param $parent
*
* @return bool
*
* @throws \Exception
* @since 6.0
*/
public function preflight(): bool
{
$app = Factory::getApplication();
if(version_compare(JVERSION, '4.0.0', 'lt'))
{
$app->enqueueMessage('Update for Joomla! 4.x+', 'error');
return false;
}
Folder::create(JPATH_SITE . '/img');
Folder::create(JPATH_SITE . '/images/mod_junewsultra');
if(!is_dir(JPATH_SITE . '/img/'))
{
$app->enqueueMessage('Error creating folder \'img\'. Please manually create the folder \'img\' in the root of the site where you installed Joomla!');
}
$cache = Factory::getCache('mod_junewsultra');
$cache->clean();
return true;
}
/**
* @param $type
* @param $parent
*
* @return bool
*
* @since 6.0
*/
public function postflight($type, $parent): bool
{
File::copy(JPATH_SITE . '/media/mod_junewsultra/notfoundimage.png', JPATH_SITE . '/images/mod_junewsultra/notfoundimage.png');
$path = JPATH_SITE . '/modules/mod_junewsultra/';
$files = [
$path . 'helper/com_k2.php',
$path . 'fields/upload.php',
$path . 'fields/head.php',
$path . 'fields/jumultithumbradio.php',
$path . 'fields/colorpicker.php',
$path . 'fields/imagesetting.php',
$path . 'fields/juradio30.php',
$path . 'fields/toggler25.php',
$path . 'fields/toggler.php',
$path . 'fields/toggler30.php',
$path . 'fields/donate.php',
$path . 'fields/article.php',
$path . 'fields/uploadimg.php',
$path . 'fields/template.php',
$path . 'fields/edittemplate.php',
$path . 'tmpl/default/images/bg.jpg',
$path . 'tmpl/default/images/rating_star.png_',
$path . 'tmpl/default/images/rating_star_blank.png_',
$path . 'img/.htaccess',
$path . 'img/config.php',
$path . 'img/img.php',
$path . 'img/imgsetting.php',
$path . 'img/phpThumb.config.php',
$path . 'img.php'
];
$folders = [
$path . 'img',
$path . 'lib/phpthumb',
$path . 'assets'
];
foreach($files as $file)
{
if(file_exists($file))
{
File::delete($file);
}
}
foreach($folders as $folder)
{
if(is_dir($folder))
{
$this->unlinkRecursive($folder);
}
}
return true;
}
/**
* @param $dir
* @param $deleteRootToo
*
*
* @since version
*/
private function unlinkRecursive($dir, $deleteRootToo = 1): void
{
if(!$dh = opendir($dir))
{
return;
}
while(($obj = readdir($dh)) !== false)
{
if($obj === '.' || $obj === '..')
{
continue;
}
if(!unlink($dir . '/' . $obj))
{
$this->unlinkRecursive($dir . '/' . $obj, true);
}
}
closedir($dh);
if($deleteRootToo)
{
rmdir($dir);
}
}
}