-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremotes.php
301 lines (255 loc) · 6.53 KB
/
remotes.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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<html>
<head>
<title>First steps of symlinked Joomla installation</title>
</head>
<body>
<h2>First steps of symlinked Joomla installation - results</h2>
<?php
// Collect submission form data
$target = $_POST['target'];
$images = (int) $_POST['images'];
$sourceLink = $images == 0;
$folder = $images == 1;
$both = $images == 2;
echo '<h3>Removing (not yet deleting) unneeded code if exists</h3>';
echo '<p>Removed code will be located in directories removed and removed/administrator which you can delete or compress later.</p>';
if (!file_exists('removed')) {mkdir ('removed');}
if (!file_exists('removed/administrator')) {mkdir ('removed/administrator');}
// Lists of symlinks to be created
$links = array(
'components',
'language',
'layouts',
'libraries',
'media',
'modules',
'plugins',
'templates'
);
$adminlinks = array(
'administrator/components',
'administrator/help',
'administrator/language',
'administrator/modules',
'administrator/templates'
);
foreach ($links as $dir)
{
if (file_exists($dir) && !is_link($dir))
{
//$dest = $dir . '_remove';
if (file_exists('removed/' . $dir))
{
$dest = $dir . '_remove';
}
else
{
$dest = 'removed/' . $dir;
}
$move = rename($dir, $dest);
$result = $move ? $dir . ' moved to ' . $dest : $dir . ' - failed to move, try to do it manually';
echo $result;
}
else
{
echo $dir . ' - nothing to move.';
}
/*
if (rename($dir, $dest) === true)
{
echo $dir . ' moved to ' . $dest;
}
else
{
echo 'Failed to move ' . $dir . ', try to do it manually';
}
*/
echo '<br />';
}
echo '<br />';
foreach ($adminlinks as $dir)
{
if (file_exists($dir) && !is_link($dir))
{
//$dest = $dir . '_remove';
if (file_exists('removed/' . $dir))
{
$dest = $dir . '_remove';
}
else
{
$dest = 'removed/' . $dir;
}
$move = rename($dir, $dest);
$result = $move ? $dir . ' moved to ' . $dest : $dir . ' - failed to move, try to do it manually';
echo $result;
}
else
{
echo $dir . ' - nothing to move.';
}
/*
if (rename($dir, $dest) === true)
{
echo 'Moved ' . $dir . ' to removed' . $dir;
}
else
{
echo 'Failed to move ' . $dir;
}
*/
echo '<br />';
}
echo '<h3>Site symlinks</h3>';
// Create site symlinks and then display them with corresponding remote directories
foreach ($links as $link)
{
if(!file_exists($link) && !is_link($link))
{
$s = symlink($target . $link , $link);
if (!$s)
{
echo 'Symlink creation failed: ' . $link . ' -> ' . $target . $link;
}
else
{
echo $link . ' -> ' . $target . $link;
}
echo '<br />';
}
}
echo '<h3>Admin symlinks</h3>';
// Create admin symlinks and then display them with corresponding remote directories
foreach ($adminlinks as $adminlink)
{
if(!file_exists($adminlink) && !is_link($adminlink))
{
$s = symlink($target . $adminlink , $adminlink);
if (!$s)
{
echo 'Symlink creation failed: ' . $adminlink . ' -> ' . $target . $adminlink;
}
else
{
echo $adminlink . ' -> ' . $target . $adminlink;
}
}
echo '<br />';
}
echo '<h3>Images folder</h3>';
if ($folder || $both)
{
if (!file_exists('images'))
{
$rename = 'images';
$result = 'Folder images created - images-dist renamed to images';
}
else
{
$rename = 'images-unused';
$result = 'Folder images exists, therefore images-dist renamed to images-unused';
}
$move = rename('images-dist', $rename);
if($move)
{
echo $result;
}
else
{
echo 'Failed to rename images-dist folder to ' . $rename;
}
if ($both)
{
$no = '';
$s = symlink($target . 'images' , 'images/remote');
if (!$s)
{
$no = 'no ';
}
echo ' and ' . $no . 'symlink is created inside this image folder';
}
echo '<br />';
}
if ($sourceLink)
{
if (!file_exists('images'))
{
$s = symlink($target . 'images' , 'images');
if (!$s)
{
$creation = 'Images symlink not created, ';
}
else
{
$creation = 'Images symlink created, ';
rename('images-dist', 'images-unused');
if (rename('images-dist', 'images-unused'))
{
$creation .= 'images-dist folder renamed to images-unused.';
}
else
{
$creation .= 'images-dist folder is not renamed to images-unused.';
}
}
}
else
{
rename('images', 'images-unused');
if (rename('images', 'images-unused'))
{
$renamed = ', so renamed it as images-unused ';
}
else
{
$renamed = ' but renaming it as images-unused failed.';
}
$s = symlink($target . 'images' , 'images');
if (!$s)
{
$creation = ', no symlink is created instead of folder';
}
else
{
$creation = ', created needed symlink instead';
}
echo 'Folder images already existsed' . $renamed . $creation;
echo '<br />';
}
}
$old = rename('index.php','index.php.old');
if (rename('index.php','index.php.old'))
{
echo 'Initial index.php renamed to index.php.old';
}
else
{
echo 'Failed to rename initial index.php - you should do it manually or even remove it';
}
if ($old && file_exists('index.php.old'))
{
rename('index.php.dist', 'index.php');
if (rename('index.php.dist','index.php'))
{
echo 'index.php.dist renamed to index.php - this is an original Joomla index file.';
}
else
{
echo 'Failed to rename index.php.dist - you should rename it manually to index.php as this is ann original Joomla index file';
}
}
?>
<hr />
<h2>Further steps</h2>
<h3>Case 1 - configuration.php (existing site database)</h3>
<p>Variant 1 - if you are just converting your existing (traditional full code) Joomla site to the symlinked one then you have configuration.php in its place and there's no need to touch it. </p>
<p>Variant 2 - if this is intended to be a new directory location with existing and usable Joomla database then, as a first thing you should upload the configuration.php file with all needed database and admin credentials. Then the installer considers the site as installed and will not change anything in database.</p>
<p>When your configuration.php is ready <a href="index.php">go ahead</a>. You just have to remove the installation directory, via website (installation finished page) or file manager / ftp.</p>
<h3>Case 2 - completely new site</h3>
<p>If your site would be completely new, open the site url and install your site like any other Joomla site.</p>
<a href="index.php">Open your site URL and proceed / finish installation</a>
<p>After that remove or rename this remotes.php.</br>
You can also remove / rename image-unused folder if you don't use it.</p>
<p>It's strongly recommended to remove or compress the folder removed if it contains anything. Otherwise there will no space saved and inodes decreased, neither. </p>
</body>
</html>