This repository has been archived by the owner on May 11, 2018. It is now read-only.
/
spinstall.php
565 lines (497 loc) · 26.4 KB
/
spinstall.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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
<?php
/**
* @package: SobiPro Component for Joomla!
*
* @author
* Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
* Email: sobi[at]sigsiu.net
* Url: https://www.Sigsiu.NET
*
* @copyright Copyright (C) 2006 - 2018 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
* @license GNU/GPL Version 3
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3
* as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
* See http://www.gnu.org/licenses/gpl.html and https://www.sigsiu.net/licenses.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*/
defined( '_JEXEC' ) || exit( 'Restricted access' );
define( 'SOBI_FRAMEWORK_VERSION', '1.0.6' );
class com_sobiproInstallerScript
{
/**
* Called before any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install|update)
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
// public function preflight( $route, JAdapterInstance $adapter )
public function preflight( $route, $adapter )
{
if ( $adapter instanceof JInstallerAdapterComponent ) {
$this->installPlugins( $adapter->getParent()->get( 'paths' ) );
}
elseif ( $adapter instanceof JInstallerComponent ) {
$this->installPlugins( $adapter->getParent->get( '_paths' ) );
}
if ( $route != 'uninstall' ) {
// Installing component manifest file version
$this->release = $adapter->getManifest()->version;
// Show the essential information at the install/update back-end
echo '<h2>Installing SobiPro version ' . $this->release . ' ...</h2>';
}
}
/**
* Called after any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install|update)
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function postflight( $route, JAdapterInstance $adapter )
{
// echo '<p>' . JText::_( 'COM_HELLOWORLD_POSTFLIGHT_' . $route . '_TEXT' ) . '</p>';
//
}
/**
* Called on update
*
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function update( JAdapterInstance $adapter )
// public function update( $parent )
{
if ( file_exists( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'usr', 'locale' ] ) ) ) {
JFolder::delete( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'usr', 'locale' ] ) );
}
if ( file_exists( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'services', 'installers', 'schemas', 'application.xsd' ] ) ) ) {
JFolder::delete( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'services', 'installers', 'schemas', 'application.xsd' ] ) );
}
// try {
// if ( file_exists( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'media' ] ) ) ) {
// JFolder::delete( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'media' ] ) );
// }
// }
// catch ( Exception $x ) {
// }
if ( !( file_exists( implode( '/', [ JPATH_ROOT, 'images', 'sobipro', 'categories' ] ) ) ) ) {
JFolder::create( implode( '/', [ JPATH_ROOT, 'images', 'sobipro', 'categories' ] ) );
}
// copy category images from media to images folder
$srcpath = JPATH_ROOT . '/media/sobipro/icons';
if ( file_exists( $srcpath ) ) {
$files = scandir( $srcpath );
$dest = JPATH_ROOT . '/images/sobipro/categories';
if ( count( $files ) ) {
foreach ( $files as $file ) {
if ( $file != '.' && $file != '..' && $file != 'Mime' ) {
if ( is_dir( $srcpath . '/' . $file ) ) {
JFolder::copy( $srcpath . '/' . $file, $dest . '/' . $file, '', true );
}
elseif ( !( file_exists( $dest . '/' . $file ) ) ) {
JFile::copy( $srcpath . '/' . $file, $dest . '/' . $file );
}
}
}
}
}
// copy category images from media to images folder
$srcpath = JPATH_ROOT . '/media/sobipro/images';
if ( file_exists( $srcpath ) ) {
$files = scandir( $srcpath );
if ( $files != 'clustermarker' ) {
$dest = JPATH_ROOT . '/images/sobipro/categories';
if ( count( $files ) ) {
foreach ( $files as $file ) {
if ( $file != '.' && $file != '..' && $file != 'clustermarker' ) {
if ( is_dir( $srcpath . '/' . $file ) ) {
JFolder::copy( $srcpath . '/' . $file, $dest . '/' . $file, '', true );
}
elseif ( !( file_exists( $dest . '/' . $file ) ) ) {
JFile::copy( $srcpath . '/' . $file, $dest . '/' . $file );
}
}
}
}
}
}
$dest = JPATH_ROOT . '/images/sobipro/categories/image.png';
if ( !( file_exists( $dest ) ) && file_exists( JPATH_ROOT . '/components/com_sobipro/tmp/install/image.png' ) ) {
JFile::move( JPATH_ROOT . '/components/com_sobipro/tmp/install/image.png', JPATH_ROOT . '/images/sobipro/categories/image.png' );
}
$db = JFactory::getDBO();
$db->setQuery( 'CREATE TABLE IF NOT EXISTS `#__sobipro_view_cache` (`cid` INT(11) NOT NULL AUTO_INCREMENT, `section` INT(11) NOT NULL, `sid` INT(11) NOT NULL, `fileName` VARCHAR(100) NOT NULL, `task` VARCHAR(100) NOT NULL, `site` INT(11) NOT NULL, `request` VARCHAR(190) NOT NULL, `language` VARCHAR(15) NOT NULL, `template` VARCHAR(150) NOT NULL, `configFile` TEXT NOT NULL, `userGroups` VARCHAR(190) NOT NULL, `created` DATETIME NOT NULL, PRIMARY KEY (`cid`), KEY `sid` (`sid`), KEY `section` (`section`), KEY `language` (`language`), KEY `task` (`task`), KEY `request` (`request`), KEY `site` (`site`), KEY `userGroups` (`userGroups`)) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;' );
$db->execute();
$db->setQuery( 'CREATE TABLE IF NOT EXISTS `#__sobipro_view_cache_relation` (`cid` INT(11) NOT NULL, `sid` INT(11) NOT NULL, PRIMARY KEY (`cid`, `sid`)) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;' );
$db->execute();
$db->setQuery( 'CREATE TABLE IF NOT EXISTS `#__sobipro_user_group` (`description` TEXT, `gid` INT(11) NOT NULL AUTO_INCREMENT, `enabled` INT(11) NOT NULL, `pid` INT(11) NOT NULL, `groupName` VARCHAR(150) NOT NULL, PRIMARY KEY (`gid`)) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci AUTO_INCREMENT = 5000;' );
$db->execute();
$db->setQuery( 'CREATE TABLE IF NOT EXISTS `#__sobipro_counter` (`sid` INT(11) NOT NULL, `counter` INT(11) NOT NULL, `lastUpdate` DATETIME NOT NULL, PRIMARY KEY (`sid`)) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;' );
$db->execute();
$db->setQuery( 'CREATE TABLE IF NOT EXISTS `#__sobipro_history` (`revision` VARCHAR(150) NOT NULL, `changedAt` DATETIME NOT NULL, `uid` INT(11) NOT NULL, `userName` VARCHAR(150) NOT NULL, `userEmail` VARCHAR(150) NOT NULL, `changeAction` VARCHAR(150) NOT NULL, `site` ENUM (\'site\', \'adm\') NOT NULL, `sid` INT(11) NOT NULL, `changes` TEXT NOT NULL, `params` TEXT NOT NULL, `reason` TEXT NOT NULL, `language` VARCHAR(50) NOT NULL, PRIMARY KEY (`revision`)) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;' );
$db->execute();
//1.1
$db->setQuery( "UPDATE #__sobipro_field_option_selected SET `optValue` = REPLACE (`optValue`, '_', '-')" );
$db->execute();
$db->setQuery( "UPDATE #__sobipro_field_option SET `optValue` = REPLACE (`optValue`, '_', '-')" );
$db->execute();
$db->setQuery( "UPDATE #__sobipro_language SET `sKey` = REPLACE( `sKey` , '_', '-' ) WHERE `oType` = 'field_option'" );
$db->execute();
// Table __sobipro_permissions
$db->setQuery( "UPDATE #__sobipro_permissions SET value = '*' WHERE pid = 18;" );
$db->execute();
try {
$db->setQuery( 'DELETE FROM `#__sobipro_permissions` WHERE `pid` = 5;' );
$db->execute();
}
catch ( Exception $x ) {
}
$db->setQuery( "INSERT IGNORE INTO `#__sobipro_permissions` (`pid`, `subject`, `action`, `value`, `site`, `published`) VALUES (86, 'entry', '*', '*', 'adm', 1), (87, 'category', '*', '*', 'adm', 1), (88, 'section', '*', '*', 'adm', 1), (89, 'section', 'access', '*', 'adm', 1), (90, 'section', 'configure', '*', 'adm', 1), (91, 'section', 'delete', '*', 'adm', 0), (92, 'category', 'edit', '*', 'adm', 1), (93, 'category', 'add', '*', 'adm', 1), (94, 'category', 'delete', '*', 'adm', 1), (95, 'entry', 'edit', '*', 'adm', 1), (96, 'entry', 'add', '*', 'adm', 1), (97, 'entry', 'delete', '*', 'adm', 1), (98, 'entry', 'approve', '*', 'adm', 1), (99, 'entry', 'publish', '*', 'adm', 1);
"
);
$db->execute();
$db->setQuery( 'SHOW INDEX FROM #__sobipro_permissions' );
$cols = $db->loadAssocList();
$skip = false;
foreach ( $cols as $col ) {
if ( $col[ 'Key_name' ] == 'uniquePermission' ) {
$skip = true;
continue;
}
}
if ( !( $skip ) ) {
$db->setQuery( 'ALTER TABLE `#__sobipro_permissions` ADD UNIQUE `uniquePermission` ( `subject` , `action` , `value` , `site` );' );
$db->execute();
}
$db->setQuery( "INSERT IGNORE INTO `#__sobipro_permissions` (`pid`, `subject`, `action`, `value`, `site`, `published`) VALUES (NULL, 'section', 'search', '*', 'front', 1), (NULL, 'entry', 'delete', 'own', 'front', 1),(NULL, 'entry', 'delete', '*', 'front', 1), (NULL, 'entry', 'manage', 'own', 'front', 1), (NULL, 'entry', 'access', 'expired_own', 'front', 1), (NULL, 'entry', 'access', 'expired_any', 'front', 1);;;" );
$db->execute();
// $db->setQuery( 'SELECT pid FROM `#__sobipro_permissions` WHERE subject = "section" AND action = "search";' );
// $pid = $db->loadResult();
//
// $db->setQuery( 'SELECT rid FROM #__sobipro_permissions_rules' );
// $rids = $db->loadRowList();
// if ( count( $rids ) ) {
// $insert = array();
// foreach ( $rids as $rid ) {
//
// }
// }
try {
$db->setQuery( 'ALTER TABLE #__sobipro_field_data CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci' );
$db->execute();
$db->setQuery( 'ALTER TABLE #__sobipro_language CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci' );
$db->execute();
}
catch ( Exception $x ) {
}
try {
$db->setQuery( 'ALTER TABLE #__sobipro_language CHANGE `sValue` `sValue` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL;' );
$db->execute();
$db->setQuery( 'ALTER TABLE #__sobipro_language CHANGE `params` `params` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL;' );
$db->execute();
$db->setQuery( 'ALTER TABLE #__sobipro_language CHANGE `options` `options` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL;' );
$db->execute();
$db->setQuery( 'ALTER TABLE #__sobipro_language CHANGE `explanation` `explanation` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL;' );
$db->execute();
}
catch ( Exception $x ) {
}
try {
$db->setQuery( 'ALTER TABLE #__sobipro_field_data CHANGE `baseData` `baseData` LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL;' );
}
catch ( Exception $x ) {
}
// Table __sobipro_field_data
try {
$db->setQuery( 'SHOW INDEX FROM #__sobipro_field_data' );
$cols = $db->loadAssocList();
$skip = false;
foreach ( $cols as $col ) {
if ( $col[ 'Key_name' ] == 'baseData' ) {
$skip = true;
continue;
}
}
if ( !( $skip ) ) {
try {
$db->setQuery( 'ALTER TABLE #__sobipro_field_data ENGINE = MYISAM;' );
$db->execute();
}
catch ( Exception $x ) {
}
try {
$db->setQuery( 'ALTER TABLE `#__sobipro_field_data` ADD FULLTEXT `baseData` (`baseData`);' );
$db->execute();
}
catch ( Exception $x ) {
}
}
}
catch ( Exception $x ) {
}
// Table __sobipro_language
$db->setQuery( 'SHOW INDEX FROM #__sobipro_language' );
$cols = $db->loadAssocList();
$skip = false;
foreach ( $cols as $col ) {
if ( $col[ 'Key_name' ] == 'sValue' ) {
$skip = true;
continue;
}
}
if ( !( $skip ) ) {
try {
$db->setQuery( 'ALTER TABLE #__sobipro_language ENGINE = MYISAM;' );
$db->execute();
}
catch ( Exception $x ) {
}
try {
$db->setQuery( 'ALTER TABLE `#__sobipro_language` ADD FULLTEXT `sValue` (`sValue`);' );
$db->execute();
}
catch ( Exception $x ) {
}
}
$db->setQuery( "INSERT IGNORE INTO `#__sobipro_language` (`sKey`, `sValue`, `section`, `language`, `oType`, `fid`, `id`, `params`, `options`, `explanation`) VALUES ('rejection-of-a-new-entry', 'Entry {entry.name} has been rejected as it does not comply with the rules.\n\n<br/>Rejected by {user.name}\n<br/>at {date%d F Y H:i:s}\n', 0, 'en-GB', 'rejections-templates', 0, 1, '', '', ''), ('rejection-of-changes', 'Changes in {entry.name} discarded as these changes violating rules.\n\n<br/>Rejected by {user.name}\n<br/>at {date%d F Y H:i:s}\n', 0, 'en-GB', 'rejections-templates', 0, 1, '', '', '');" );
$db->execute();
// Table __sobipro_history
$db->setQuery( 'SHOW INDEX FROM #__sobipro_history' );
$cols = $db->loadAssocList();
$skip = false;
foreach ( $cols as $col ) {
if ( $col[ 'Key_name' ] == 'changeAction' ) {
$skip = true;
continue;
}
}
if ( !( $skip ) ) {
try {
$db->setQuery( 'ALTER TABLE #__sobipro_history CHANGE `change` `changeAction` VARCHAR(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;' );
$db->execute();
}
catch ( Exception $x ) {
}
}
// Table __sobipro_category
$db->setQuery( 'SHOW INDEX FROM #__sobipro_category' );
$cols = $db->loadAssocList();
$skip = false;
foreach ( $cols as $col ) {
if ( $col[ 'Key_name' ] == 'allFields' ) {
$skip = true;
continue;
}
}
if ( !( $skip ) ) {
try {
$db->setQuery( 'ALTER TABLE `#__sobipro_category` ADD `allFields` TINYINT(2) NOT NULL AFTER `showIcon`, ADD `entryFields` TEXT NOT NULL AFTER `allFields`;' );
$db->execute();
$db->setQuery( 'UPDATE `#__sobipro_category` SET `allFields` = 1' );
$db->execute();
}
catch ( Exception $x ) {
}
}
//Table __sobipro_registry
$db->setQuery( "INSERT IGNORE INTO `#__sobipro_registry` (`section`, `key`, `value`, `params`, `description`, `options`) VALUES ('rejections-templates', 'rejection-of-a-new-entry', 'Rejection of a new entry', 'YTo0OntzOjE3OiJ0cmlnZ2VyLnVucHVibGlzaCI7YjoxO3M6MTc6InRyaWdnZXIudW5hcHByb3ZlIjtiOjA7czo5OiJ1bnB1Ymxpc2giO2I6MTtzOjc6ImRpc2NhcmQiO2I6MDt9', '', ''), ('rejections-templates', 'rejection-of-changes', 'Rejection of changes', 'YTo0OntzOjE3OiJ0cmlnZ2VyLnVucHVibGlzaCI7YjowO3M6MTc6InRyaWdnZXIudW5hcHByb3ZlIjtiOjE7czo5OiJ1bnB1Ymxpc2giO2I6MDtzOjc6ImRpc2NhcmQiO2I6MTt9', '', '');" );
$db->execute();
$db->setQuery( "UPDATE `#__sobipro_registry` SET `params` = 'L15bXHdcLi1dK0BbXHdcLi1dK1wuW2EtekEtWl17MiwyNH0kLw==' WHERE `key` = 'email' " );
$db->execute();
$db->setQuery( "INSERT IGNORE INTO `#__sobipro_field_types` (`tid`, `fType`, `tGroup`, `fPos`) VALUES ('category', 'Category', 'special', 11);" );
$db->execute();
$db->setQuery( "INSERT IGNORE INTO `#__sobipro_field_types` (`tid`, `fType`, `tGroup`, `fPos`) VALUES ('info', 'Information', 'free_single_simple_data', 6);" );
$db->execute();
$db->setQuery( "INSERT IGNORE INTO `#__sobipro_field_types` (`tid`, `fType`, `tGroup`, `fPos`) VALUES ('button', 'Button', 'special', 5);" );
$db->execute();
$db->setQuery( 'CREATE TABLE IF NOT EXISTS `#__sobipro_field_url_clicks` (`date` DATETIME NOT NULL, `uid` INT(11) NOT NULL, `sid` INT(11) NOT NULL, `fid` VARCHAR(50) NOT NULL, `ip` VARCHAR(15) NOT NULL, `section` INT(11) NOT NULL, `browserData` TEXT NOT NULL, `osData` TEXT NOT NULL, `humanity` INT(3) NOT NULL, PRIMARY KEY (`date`, `sid`, `fid`, `ip`, `section`)) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;' );
$db->execute();
$db->setQuery( "INSERT IGNORE INTO `#__sobipro_plugins` (`pid`, `name`, `version`, `description`, `author`, `authorURL`, `authorMail`, `enabled`, `type`, `depend`) VALUES ('category', 'Category', '1.4', NULL, 'Sigsiu.NET GmbH', 'https://www.sigsiu.net/', 'sobi@sigsiu.net', 1, 'field', '');" );
$db->execute();
$db->setQuery( "INSERT IGNORE INTO `#__sobipro_plugins` (`pid`, `name`, `version`, `description`, `author`, `authorURL`, `authorMail`, `enabled`, `type`, `depend`) VALUES ('info', 'Information', '1.4', NULL, 'Sigsiu.NET GmbH', 'https://www.sigsiu.net/', 'sobi@sigsiu.net', 1, 'field', '');" );
$db->execute();
$db->setQuery( "INSERT IGNORE INTO `#__sobipro_plugins` (`pid`, `name`, `version`, `description`, `author`, `authorURL`, `authorMail`, `enabled`, `type`, `depend`) VALUES ('button', 'Button', '1.4', NULL, 'Sigsiu.NET GmbH', 'https://www.sigsiu.net/', 'sobi@sigsiu.net', 1, 'field', '');" );
$db->execute();
$db->setQuery( "CREATE TABLE IF NOT EXISTS `#__sobipro_crawler` ( `url` VARCHAR(190) NOT NULL,`crid` INT(11) NOT NULL AUTO_INCREMENT,`state` TINYINT(1) NOT NULL, PRIMARY KEY (`crid`), UNIQUE KEY `url` (`url`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_unicode_ci;" );
$db->execute();
// Table __sobipro_config
//removed in 1.4.6
// $db->setQuery( "INSERT IGNORE INTO `#__sobipro_config` ( `sKey` , `sValue` , `section` , `critical` , `cSection` ) VALUES ( 'engb_preload', '1', '0', NULL , 'lang' )" );
// $db->execute();
//1.4.6 (set it for section 1 if it does not exist)
$db->setQuery( "INSERT IGNORE INTO `#__sobipro_config` ( `sKey` , `sValue` , `section` , `critical` , `cSection` ) VALUES ( ' icon_fonts_load', '1', 1 , NULL , 'template' )" );
$db->execute();
try {
$db->setQuery( 'DELETE FROM `#__sobipro_config` WHERE `sKey` = "xml_raw" AND `section` = 0;' );
$db->execute();
}
catch ( Exception $x ) {
}
try {
$db->setQuery( 'DELETE FROM `#__sobipro_config` WHERE `sKey` = "field_types_for_ordering"' );
$db->execute();
}
catch ( Exception $x ) {
}
// 1.4.7.3
try {
$db->setQuery( 'ALTER TABLE `#__sobipro_field` CHANGE `notice` `notice` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;' );
$db->execute();
}
catch ( Exception $x ) {
}
JFile::move( JPATH_ROOT . '/components/com_sobipro/etc/repos/sobipro_core/repository.1.4.xml', JPATH_ROOT . '/components/com_sobipro/etc/repos/sobipro_core/repository.xml' );
$this->installFramework();
echo '<div class="alert alert-info" style="margin-top: 20px;"><h3>Thank you for updating SobiPro!</h3><p>SobiPro is checking your system now, please see if there are errors or warnings. If the system check reports errors, your SobiPro installation will probably not work. If you see warnings, some functionality of SobiPro can be disturbed or malfunction. In these cases you should take a look to the <a href="https://www.sigsiu.net/sobipro/requirements"><strong>Requirements for SobiPro</strong></a> page on our website.</p>
<p>You can install languages directly from our <a href="index.php?option=com_sobipro&task=extensions.browse"><strong>Repository</strong></a> or download them from our <a href="https://www.sigsiu.net/center/languages"><strong>website</strong></a> and install it in the <a href="index.php?option=com_sobipro&task=extensions.installed"><strong>SobiPro Application Manager</strong></a>.</p></div>';
echo '<iframe src="index.php?option=com_sobipro&task=requirements&init=1&tmpl=component" style="border: 1px solid #e0e0e0; border-radius: 5px; height: 900px; min-width: 1000px; width: 99%; margin-bottom: 50px; padding-left: 10px; padding-top: 10px;"></iframe>';
return true;
}
/**
* Called on installation
*
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function install( JAdapterInstance $adapter )
// public function install( $parent )
{
if ( !( file_exists( implode( '/', [ JPATH_ROOT, 'images', 'sobipro' ] ) ) ) ) {
JFolder::create( implode( '/', [ JPATH_ROOT, 'images', 'sobipro' ] ) );
}
if ( !( file_exists( implode( '/', [ JPATH_ROOT, 'images', 'sobipro', 'categories' ] ) ) ) ) {
JFolder::create( implode( '/', [ JPATH_ROOT, 'images', 'sobipro', 'categories' ] ) );
if ( file_exists( JPATH_ROOT . '/components/com_sobipro/tmp/install/image.png' ) ) {
JFile::move( JPATH_ROOT . '/components/com_sobipro/tmp/install/image.png', JPATH_ROOT . '/images/sobipro/categories/image.png' );
}
}
if ( file_exists( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'tmp', 'SampleData', 'entries' ] ) ) ) {
JFolder::move(
implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'tmp', 'SampleData', 'entries' ] ),
implode( '/', [ JPATH_ROOT, 'images', 'sobipro', 'entries' ] )
);
}
if ( file_exists( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'usr', 'locale' ] ) ) ) {
JFolder::delete( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'usr', 'locale' ] ) );
}
if ( file_exists( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'services', 'installers', 'schemas', 'application.xsd' ] ) ) ) {
JFolder::delete( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'services', 'installers', 'schemas', 'application.xsd' ] ) );
}
// if ( file_exists( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'media' ] ) ) ) {
// JFolder::delete( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'media' ] ) );
// }
JFile::move( JPATH_ROOT . '/components/com_sobipro/etc/repos/sobipro_core/repository.1.4.xml', JPATH_ROOT . '/components/com_sobipro/etc/repos/sobipro_core/repository.xml' );
$db = JFactory::getDBO();
$db->setQuery( 'SHOW COLUMNS FROM #__sobipro_field_data' );
$cols = $db->loadAssocList( 'Field' );
if ( !( isset( $cols[ 'editLimit' ] ) ) ) {
$db->setQuery( 'ALTER TABLE `#__sobipro_field_data` ADD `editLimit` INT( 11 );' );
$db->execute();
}
$this->installFramework();
echo '<div class="alert alert-info" style="margin-top: 20px;"><h3>Welcome to SobiPro!</h3><p>SobiPro is checking your system now, please see if there are errors or warnings. If the system check reports errors, your SobiPro installation will probably not work. If you see warnings, some functionality of SobiPro can be disturbed or malfunction. In these cases you should take a look to the <a href="https://www.sigsiu.net/sobipro/requirements"><strong>Requirements for SobiPro</strong></a> page on our website.</p>
<p>You can install languages directly from our <a href="index.php?option=com_sobipro&task=extensions.browse"><strong>Repository</strong></a> or download them from our <a href="https://www.sigsiu.net/center/languages"><strong>website</strong></a> and install it in the <a href="index.php?option=com_sobipro&task=extensions.installed"><strong>SobiPro Application Manager</strong></a>.</p></div>';
echo '<iframe src="index.php?option=com_sobipro&task=requirements&init=1&tmpl=component" style="border: 1px solid #e0e0e0; border-radius: 5px; height: 900px; min-width: 1000px; width: 99%; margin-bottom: 50px; padding-left: 10px; padding-top: 10px;"></iframe>';
return true;
}
protected function installPlugins( $source )
{
$source = $source[ 'source' ];
$plugins = [ 'Header' ];
$path = $source . '/Plugins';
$installer = new JInstaller;
$db = JFactory::getDBO();
foreach ( $plugins as $plugin ) {
$dir = $path . '/' . $plugin;
$installer->install( $dir );
$db->setQuery( "UPDATE #__extensions SET enabled = '1' WHERE element = 'sp{$plugin}';" );
$db->execute();
}
}
/**
* Called on uninstallation
*
* @param JAdapterInstance $adapter The object responsible for running this script
*/
public function uninstall( JAdapterInstance $adapter )
// public function uninstall( $parent )
{
echo '<h2>Un-Installing SobiPro ...</h2>';
$db = JFactory::getDBO();
$query = "show tables like '" . $db->getPrefix() . "sobipro_%'";
$db->setQuery( $query );
$tables = $db->loadColumn();
foreach ( $tables as $table ) {
$db->setQuery( "DROP TABLE {$table};" );
$db->execute();
}
JFolder::delete( implode( '/', [ JPATH_ROOT, 'images', 'sobipro' ] ) );
echo '<p style="margin-bottom: 50px;"><strong>Done! All SobiPro files and database tables have been removed from your system.</strong></p>';
}
protected function installFramework()
{
//Sobi Framework installation
$libpath = JPATH_ROOT . '/libraries/sobi';
if ( !( file_exists( $libpath ) ) ) {
JFolder::create( $libpath );
}
else {
$files = scandir( $libpath );
if ( count( $files ) ) {
foreach ( $files as $file ) {
if ( strstr( $file, '.tar.gz' ) || strstr( $file, '.php' ) ) {
JFile::delete( $libpath . '/' . $file );
}
}
}
}
$src = JPATH_ROOT . '/components/com_sobipro/Sobi.phar.tar.gz';
$framework = $libpath . "/Sobi-" . SOBI_FRAMEWORK_VERSION . ".phar.tar.gz";
if ( file_exists( $src ) ) {
JFile::copy( $src, $framework );
JFile::delete( $src );
}
else {
echo "<p style=\"font-size: 15px;color: #d70303;\">Framework file " . $src . " does not exist.</p>";
return false;
}
// I am guessing that this was what cached the PHAR file. Let's see...
if ( function_exists( 'opcache_reset' ) ) {
opcache_reset();
}
$fwPackage = JPATH_ROOT . '/components/com_sobipro/Sobi-Framework.zip';
@include_once 'phar://' . $framework . '/Framework.php';
if ( !( class_exists( '\\Sobi\\Framework' ) ) ) {
if ( file_exists( $fwPackage ) ) {
echo '<p style="font-size: 15px">It seems your server does not support PHAR, or PHAR is not usable.</p>';
try {
$arch = new Joomla\Archive\Zip();
$arch->extract( $fwPackage, $libpath );
echo '<p style="font-size: 15px">Unpacked the Sobi Framework. Nevertheless, you should consider to install PHAR on your server.</p>';
if ( file_exists( $framework ) ) {
JFile::delete( $framework );
}
}
catch ( Exception $x ) {
echo '<p style="font-size: 17px;color: #d70303;">Failed to unpack the Sobi Framework.<br/>Please install the Sobi Framework manually as described in <a href="https://www.sigsiu.net/center/sobipro-component/154-sobi-framework" style="text-decoration: underline; color: #d70303;">Install the Sobi Framework manually</a>.</p>';
}
JFile::delete( $fwPackage );
}
else {
echo '<p style="font-size: 15px;color: #d70303;">It seems your server does not support PHAR, or PHAR is not usable.<br/>Please install the Sobi Framework manually as described in <a href="https://www.sigsiu.net/center/sobipro-component/154-sobi-framework" style="text-decoration: underline; color: #d70303;">Install the Sobi Framework manually</a>.</p>';
}
}
else {
if ( file_exists( $fwPackage ) ) {
JFile::delete( $fwPackage );
}
}
}
}