forked from FLEXIcontent/flexicontent-cck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.php
1315 lines (1181 loc) · 52.7 KB
/
script.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
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* @version 1.5 stable $Id: install.php 1789 2013-10-15 02:25:46Z ggppdk $
* @package Joomla
* @subpackage FLEXIcontent
* @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
* @license GNU/GPL v2
*
* FLEXIcontent is a derivative work of the excellent QuickFAQ component
* @copyright (C) 2008 Christoph Lukes
* see www.schlu.net for more information
*
* FLEXIcontent 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' ) or die( 'Restricted access' );
// Joomla version variables
if (!defined('FLEXI_J16GE') || !defined('FLEXI_J30GE')) {
jimport( 'joomla.version' ); $jversion = new JVersion;
}
if (!defined('FLEXI_J16GE')) define('FLEXI_J16GE', version_compare( $jversion->getShortVersion(), '1.6.0', 'ge' ) );
if (!defined('FLEXI_J30GE')) define('FLEXI_J30GE', version_compare( $jversion->getShortVersion(), '3.0.0', 'ge' ) );
class com_flexicontentInstallerScript
{
/*
* $parent is the class calling this method.
* $type is the type of change (install, update or discover_install, not uninstall).
* preflight runs before anything else and while the extracted files are in the uploaded temp folder.
* If preflight returns false, Joomla will abort the update and undo everything already done.
*/
function preflight( $type, $parent ) {
// Make sure that fatal errors are printed
error_reporting(E_ERROR);
ini_set('display_errors',1);
// Try to increment some limits
@set_time_limit( 150 ); // try to set execution time 2.5 minutes
ignore_user_abort( true ); // continue execution if client disconnects
// Try to increment memory limits
$memory_limit = trim( @ini_get( 'memory_limit' ) );
if ( $memory_limit ) {
switch (strtolower(substr($memory_limit, -1)))
{
case 'm': $memory_limit = (int)substr($memory_limit, 0, -1) * 1048576; break;
case 'k': $memory_limit = (int)substr($memory_limit, 0, -1) * 1024; break;
case 'g': $memory_limit = (int)substr($memory_limit, 0, -1) * 1073741824; break;
case 'b':
switch (strtolower(substr($memory_limit, -2, 1)))
{
case 'm': $memory_limit = (int)substr($memory_limit, 0, -2) * 1048576; break;
case 'k': $memory_limit = (int)substr($memory_limit, 0, -2) * 1024; break;
case 'g': $memory_limit = (int)substr($memory_limit, 0, -2) * 1073741824; break;
default : break;
} break;
default: break;
}
if ( $memory_limit < 16000000 ) @ini_set( 'memory_limit', '16M' );
if ( $memory_limit < 32000000 ) @ini_set( 'memory_limit', '32M' );
if ( $memory_limit < 64000000 ) @ini_set( 'memory_limit', '64M' );
}
// first check if PHP v5.3.0 or later is running
$PHP_VERSION_NEEDED = '5.3.0';
if (version_compare(PHP_VERSION, $PHP_VERSION_NEEDED, '<'))
{
// load english language file for 'com_flexicontent' component then override with current language file
JFactory::getLanguage()->load('com_flexicontent', JPATH_ADMINISTRATOR, 'en-GB', true);
JFactory::getLanguage()->load('com_flexicontent', JPATH_ADMINISTRATOR, null, true);
Jerror::raiseWarning(null, JText::sprintf( 'FLEXI_UPGRADE_PHP_VERSION_GE', $PHP_VERSION_NEEDED ));
return false;
}
// Get existing manifest data
$existing_manifest = $this->getExistingManifest();
// Get Joomla version
$jversion = new JVersion();
// File version of new manifest file
$this->release = $parent->get( "manifest" )->version;
// File version of existing manifest file
$this->release_existing = $existing_manifest[ 'version' ];
// Manifest file minimum Joomla version
$this->minimum_joomla_release = $parent->get( "manifest" )->attributes()->version;
// For J2.5 require other minimum
if( version_compare( $jversion->getShortVersion(), '3.0', 'lt' ) )
{
$this->minimum_joomla_release = '2.5.0';
}
?>
<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
<tr>
<td valign="top">
<img src="<?php echo 'components/com_flexicontent/assets/images/logo.png'; ?>" style="width:300px; margin: 0px 48px 0px 0px;" alt="FLEXIcontent Logo" />
</td>
<td valign="top" width="100%">
<span><?php echo JText::_('COM_FLEXICONTENT_DESCRIPTION'); ?></></span><br />
<font class="small">by <a href="http://www.flexicontent.org" target="_blank">Emmanuel Danan</a>,
<font class="small">by <a href="http://www.flexicontent.org" target="_blank">Georgios Papadakis</a>,
<font class="small">by <a href="http://www.flexicontent.org" target="_blank">Berges Yannick</a>,
<br/>
<font class="small">and <a href="http://www.marvelic.co.th" target="_blank">Marvelic Engine Co.,Ltd.</a><br/>
</td>
</tr>
<!--
<tr>
<td valign="top" style="font-weight: bold;">
<?php // echo JText::_('Choose an option to finish the install :'); ?>
</td>
<td valign="top" width="100%" style="font-weight: bold; color: red; font-size: 14px;">
<a href="index.php?option=com_flexicontent&task=finishinstall&action=newinstall" style="font-weight: bold; color: red; font-size: 14px;">
<?php // echo JText::_('New install'); ?>
</a> |
<a href="index.php?option=com_flexicontent&task=finishinstall&action=update" style="font-weight: bold; color: red; font-size: 14px;">
<?php // echo JText::_('Update an existing install'); ?>
</a>
</td>
</tr>
-->
</table>
<?php
echo '
<div class="alert alert-info" style="margin:32px 0px 8px 0px; width:50%;">' .JText::_('Performing prior to installation tasks ... '). '</div>
<ul>
<li>
'.JText::_('COM_FLEXICONTENT_REQUIRED_PHPVER').':
'.JText::_('COM_FLEXICONTENT_MIN').' <span class="badge">' .$PHP_VERSION_NEEDED. '</span>
'.JText::_('COM_FLEXICONTENT_CURRENT').' <span class="badge badge-success">' .PHP_VERSION. '</span>
</li>
';
// Check that current Joomla release is not older than minimum required
if( version_compare( $jversion->getShortVersion(), $this->minimum_joomla_release, 'lt' ) ) {
echo '</ul>';
Jerror::raiseWarning(null, 'Cannot install com_flexicontent in a Joomla release prior to '.$this->minimum_joomla_release);
return false;
} else {
echo '
<li>
'.JText::_('COM_FLEXICONTENT_REQUIRED_JVER').':
'.JText::_('COM_FLEXICONTENT_MIN').' <span class="badge">' .$this->minimum_joomla_release. '</span>
'.JText::_('COM_FLEXICONTENT_CURRENT').' <span class="badge badge-success">' .$jversion->getShortVersion(). '</span>
</li>';
}
// Print message about installing / updating / downgrading FLEXIcontent
$downgrade_allowed = true;
if ($type=='update')
{
if ( !$downgrade_allowed && version_compare( $this->release, $this->release_existing, 'l' ) )
{
$from_to = ''
.JText::_('COM_FLEXICONTENT_FROM'). ' <span class="badge">' .$this->release_existing. '</span> '
.JText::_('COM_FLEXICONTENT_TO'). ' <span class="badge badge-warning">' .$this->release. '</span> ';
// ?? Abort if the component being installed is not newer than the currently installed version
//echo '</ul>';
Jerror::raiseWarning(null, 'Refusing to downgrade installation of com_flexicontent '.$from_to);
return false;
echo '</ul>';
return false; // Returning false here would abort
}
}
echo '
</ul>
';
// Set a flag about FLEXIcontent being installed (1) or upgraded (0)
define('FLEXI_NEW_INSTALL', $type=='install' ? 1 : 0);
}
/*
* $parent is the class calling this method.
* install runs after the database scripts are executed.
* If the extension is new, the install method is run.
* If install returns false, Joomla will abort the install and undo everything already done.
*/
function install( $parent )
{
echo '
<div class="alert alert-info" style="margin:32px 0px 8px 0px; width:50%;">' . JText::_('COM_FLEXICONTENT_INSTALLING')
.' '.JText::_('COM_FLEXICONTENT_VERSION').' <span class="badge badge-info">'.$this->release.'</span>
</div>';
if ( ! $this->do_extra( $parent ) ) return false;
// You can have the backend jump directly to the newly installed component configuration page
// $parent->getParent()->setRedirectURL('index.php?option=com_flexicontent');
}
/*
* $parent is the class calling this method.
* update runs after the database scripts are executed.
* If the extension exists, then the update method is run.
* If this returns false, Joomla will abort the update and undo everything already done.
*/
function update( $parent )
{
echo '<div class="alert alert-info" style="margin:32px 0px 8px 0px; width:50%;">' . JText::_('COM_FLEXICONTENT_UPDATING_INSTALLATION')
.' '.JText::_('COM_FLEXICONTENT_VERSION').': ';
if ( version_compare( $this->release, $this->release_existing, 'ge' ) ) {
echo '
'.JText::_('COM_FLEXICONTENT_FROM').' <span class="badge">'.$this->release_existing.'</span>
'.JText::_('COM_FLEXICONTENT_TO').' <span class="badge badge-info">'.$this->release.'</span>';
} else {
echo '
<span class="badge badge-info">'.JText::_('COM_FLEXICONTENT_DOWNGRADING').'</span>
'.JText::_('COM_FLEXICONTENT_FROM'). ' <span class="badge">' .$this->release_existing. '</span>
'.JText::_('COM_FLEXICONTENT_TO'). ' <span class="badge badge-info">' .$this->release. '</span>';
}
echo '</div>';
if ( ! $this->do_extra( $parent ) ) return false;
// You can have the backend jump directly to the newly updated component configuration page
// $parent->getParent()->setRedirectURL('index.php?option=com_flexicontent');
}
function do_extra( $parent )
{
// init vars
$error = false;
$extensions = array();
// clear a cache
$cache = JFactory::getCache();
$cache->clean( '_system' ); // This might be necessary as installing-uninstalling in same session may result in wrong extension ids, etc
$cache->clean( 'com_flexicontent' );
$cache->clean( 'com_flexicontent_tmpl' );
$cache->clean( 'com_flexicontent_cats' );
$cache->clean( 'com_flexicontent_items' );
$cache->clean( 'com_flexicontent_filters' );
// reseting post installation session variables
$session = JFactory::getSession();
$session->set('flexicontent.postinstall', false);
$session->set('flexicontent.allplgpublish', false);
$session->set('flexicontent.allplgpublish', false);
$session->set('unbounded_noext', false, 'flexicontent');
$session->set('unbounded_badcat', false, 'flexicontent');
$db = JFactory::getDBO();
// Parse XML file to identify additional extensions,
// This code part (for installing additional extensions) originates from Zoo J1.5 Component:
// Original install.php file
// @package Zoo Component
// @author YOOtheme http://www.yootheme.com
// @copyright Copyright (C) 2007 - 2009 YOOtheme GmbH
// @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
$manifest = isset($parent) ? $parent->getParent()->manifest : $this->manifest;
$source = isset($parent) ? $parent->getParent()->getPath('source') : $this->parent->getPath('source');
$additional = $manifest->xpath('additional');
$additional = count($additional) ? reset($additional) : NULL;
if ( is_object($additional) && count( $additional->children() ) ) {
$exts = $additional->children();
foreach ($exts as $ext) {
$extensions[] = array(
'name' => strip_tags( $ext->asXml() ),
'type' => $ext->getName(),
'folder' => $source.'/' . $ext->attributes()->folder,
'ext_name' => ((string) $ext->attributes()->name), // needs to be converted to string
'ext_folder' => ((string) $ext->attributes()->instfolder), // needs to be converted to string
'installer' => new JInstaller(),
'status' => null
);
}
//echo "<pre>"; print_r($extensions); echo "</pre>"; exit;
}
// Install discovered extensions
foreach ($extensions as $i => $extension)
{
$jinstaller = & $extensions[$i]['installer']; // new JInstaller();
// J1.6+ installer requires that we explicit set override/upgrade options
$jinstaller->setOverwrite(true);
$jinstaller->setUpgrade(true);
if ($jinstaller->install($extensions[$i]['folder'])) {
$extensions[$i]['status'] = true;
$ext_manifest = $jinstaller->getManifest();
$ext_manifest_name = $ext_manifest->name;
//if ($ext_manifest_name!=$extensions[$i]['name']) echo $ext_manifest_name." - ".$extensions[$i]['name'] . "<br/>";
// Force existing plugins/modules to use name found in each extension's manifest.xml file
if ( $extensions[$i]['ext_folder'] == 'flexicontent_fields' )
{
$ext_tbl = '#__extensions';
$query = 'UPDATE '.$ext_tbl
//.' SET name = '.$db->Quote($extensions[$i]['name'])
.' SET name = '.$db->Quote($ext_manifest_name)
.' WHERE element = '.$db->Quote($extensions[$i]['ext_name'])
.' AND folder = '.$db->Quote($extensions[$i]['ext_folder'])
.' AND type = '.$db->Quote($extensions[$i]['type'])
;
$db->setQuery($query);
$db->query();
}
} else {
$extensions[$i]['status'] = false;
if ( !FLEXI_NEW_INSTALL ) {
$error = true;
break;
}
}
}
?>
<div class="alert alert-warning" style="margin:24px 0px 12px 0px; width:240px;"><?php echo JText::_('COM_FLEXICONTENT_ADDITIONAL_EXTENSIONS'); ?></div>
<table class="adminlist">
<thead>
<tr>
<th style="text-align:left; width:500px;">
<span class="label"><?php echo JText::_('COM_FLEXICONTENT_EXTENSION'); ?></span>
</th>
<th style="text-align:left">
<span class="label"><?php echo JText::_('COM_FLEXICONTENT_STATUS'); ?></span>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="2"> </td>
</tr>
</tfoot>
<tbody>
<?php foreach ($extensions as $i => $ext) : ?>
<tr class="row<?php echo $i % 2; ?>">
<td class="key" style="font-size:11px;">[<?php echo JText::_($ext['type']); ?>] <?php echo $ext['name']; ?></td>
<td>
<?php
if ($ext['status']===null)
$status_class = 'badge';
else if ($ext['status'])
$status_class = 'badge badge-success';
else
$status_class = 'badge badge-error';
?>
<span class="<?php echo $status_class; ?>">
<?php
if ( $ext['status'] === null ) {
echo JText::_('COM_FLEXICONTENT_SKIPPED');
} else if ($ext['status']) {
echo JText::_('COM_FLEXICONTENT_INSTALLED');
} else {
$msg = JText::_(FLEXI_NEW_INSTALL ? 'Upgrade ERROR (extension removed)' : 'Installation -- FAILED --' ) ."<br/>";
if (FLEXI_NEW_INSTALL) $msg .= "FLEXIcontent may not work properly, please install an older or newer FLEXIcontent package";
echo $msg;
Jerror::raiseWarning(null, '<br/>'.$extensions[$i]['name'] .' '. JText::_($extensions[$i]['type']) .': '. $msg);
}
?>
</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
// Rollback on installation errors, abort() will be called on every additional extension installed above
if ($error) {
for ($i = 0; $i < count($extensions); $i++) {
if ( $extensions[$i]['status'] ) {
$extensions[$i]['installer']->abort('<span style="color:black">'.
$extensions[$i]['name'] .' '. JText::_($extensions[$i]['type']) .' '. JText::_('COM_FLEXICONTENT_INSTALLED') .':</span>'.
' <span class="badge badge-warning">'. JText::_('rolling back').'</span>',
$extensions[$i]['type']
);
//$extensions[$i]['status'] = false;
} /*else if ( $extensions[$i]['status'] === false ) {
$msg = ' <span style="color:red">'. JText::_('-- FAILED --').'</span>';
Jerror::raiseWarning(null, '<span style="color:black">'.$extensions[$i]['name'] .' '. JText::_($extensions[$i]['type']) .' '. JText::_('Install') .':</span>'.$msg);
} else {
$msg = ' <span style="color:darkgray">'. JText::_('Skipped').'</span>';
Jerror::raiseWarning(null, '<span style="color:black">'.$extensions[$i]['name'] .' '. JText::_($extensions[$i]['type']) .' '. JText::_('Install') .':</span>'.$msg);
}*/
}
if (!FLEXI_J16GE) {
$this->parent->abort("<br/>".JText::_('Component installation aborted'), 'component');
} else {
return false; // In J1.6+ , returning false here will cancel (abort) component installation and rollback changes
}
}
// All OK, or acceptable errors
return true;
}
/*
* $parent is the class calling this method.
* $type is the type of change (install, update or discover_install, not uninstall).
* postflight is run after the extension is registered in the database.
*/
function postflight( $type, $parent )
{
$app = JFactory::getApplication();
$db = JFactory::getDBO();
/*
// always create or modify these parameters
$params['my_param0'] = 'Component version ' . $this->release;
$params['my_param1'] = 'Another value';
// define the following parameters only if it is an original install
if ( $type == 'install' ) {
$params['my_param2'] = '4';
$params['my_param3'] = 'Star';
}
$this->setParams( $params );*/
if (FLEXI_J30GE) echo '<link type="text/css" href="components/com_flexicontent/assets/css/j3x.css" rel="stylesheet">';
echo '
<link type="text/css" href="components/com_flexicontent/assets/css/flexicontentbackend.css" rel="stylesheet">
<div class="alert alert-info" style="margin:32px 0px 8px 0px; width:50%;">' .JText::_('Performing after installation tasks ... '). '</div>
';
?>
<table class="adminlist">
<thead>
<tr>
<th style="text-align:left; width:500px;">
<span class="label"><?php echo JText::_('COM_FLEXICONTENT_TASKS'); ?></span>
</th>
<th style="text-align:left">
<span class="label"><?php echo JText::_('COM_FLEXICONTENT_STATUS'); ?></span>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="2"> </td>
</tr>
</tfoot>
<tbody>
<?php
$deprecated_fields = array('hidden'=>'text', 'relateditems'=>'relation', 'relateditems_backlinks'=>'relation_reverse');
// Get DB table information
$query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_fields_item_relations"';
$db->setQuery($query);
$fi_rels_tbl_exists = (boolean) count($db->loadObjectList());
$query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_items_versions"';
$db->setQuery($query);
$fi_vers_tbl_exists = (boolean) count($db->loadObjectList());
$query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_files"';
$db->setQuery($query);
$files_tbl_exists = (boolean) count($db->loadObjectList());
$query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_fields"';
$db->setQuery($query);
$fields_tbl_exists = (boolean) count($db->loadObjectList());
$query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_types"';
$db->setQuery($query);
$types_tbl_exists = (boolean) count($db->loadObjectList());
$query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_items_ext"';
$db->setQuery($query);
$iext_tbl_exists = (boolean) count($db->loadObjectList());
$query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_advsearch_index"';
$db->setQuery($query);
$advsearch_index_tbl_exists = (boolean) count($db->loadObjectList());
$query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_authors_ext"';
$db->setQuery($query);
$authors_ext_tbl_exists = (boolean) count($db->loadObjectList());
$query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_templates"';
$db->setQuery($query);
$templates_tbl_exists = (boolean) count($db->loadObjectList());
$query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_layouts_conf"';
$db->setQuery($query);
$layouts_conf_tbl_exists = (boolean) count($db->loadObjectList());
$query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_items_tmp"';
$db->setQuery($query);
$content_cache_tbl_exists = (boolean) count($db->loadObjectList());
$query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_download_history"';
$db->setQuery($query);
$dl_history_tbl_exists = (boolean) count($db->loadObjectList());
$query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_download_coupons"';
$db->setQuery($query);
$dl_coupons_tbl_exists = (boolean) count($db->loadObjectList());
?>
<?php
// Delete orphan plugin entries
?>
<tr class="row0">
<td class="key" style="font-size:11px;">Delete orphan plugin entries</td>
<td>
<?php
$queries = array();
$queries[] ="DELETE FROM `#__extensions` WHERE folder='flexicontent_fields' AND element IN ('flexisystem', 'flexiadvroute', 'flexisearch', 'flexiadvsearch', 'flexinotify')";
if ( !empty($queries) ) {
foreach ($queries as $query) {
$db->setQuery($query);
if ( !($result = $db->query()) ) {
$result = false;
echo "<span class='badge badge-error'>SQL QUERY failed: ". $query ."</span>";
}
}
$count_rows = $db->getAffectedRows($result);
if ( $count_rows ) {
echo "<span class='badge badge-success'>".$count_rows." effected rows </span>";
} else echo "<span class='badge badge-info'>no changes</span>";
}
else echo "<span class='badge badge-info'>nothing to do</span>";
?>
</td>
</tr>
<?php
// Enable FLEXIcontent system plugins
?>
<tr class="row1">
<td class="key" style="font-size:11px;">Enable FLEXIcontent system plugins</td>
<td>
<?php
$queries = array();
if (FLEXI_J30GE) $queries[] = "UPDATE #__extensions SET enabled=1 WHERE type='plugin' AND (element=".$db->Quote('flexisystem')." OR element=".$db->Quote('flexiadvroute').") AND folder=".$db->Quote('system');
if ( !empty($queries) ) {
foreach ($queries as $query) {
$db->setQuery($query);
if ( !($result = $db->query()) ) {
$result = false;
echo "<span class='badge badge-error'>SQL QUERY failed: ". $query ."</span>";
}
}
$count_rows = $db->getAffectedRows($result);
if ( $count_rows ) {
echo "<span class='badge badge-success'>".$count_rows." effected rows </span>";
} else echo "<span class='badge badge-info'>no changes</span>";
}
else echo "<span class='badge badge-info'>nothing to do</span>";
?>
</td>
</tr>
<?php
// Update DB table flexicontent_fields: Convert deprecated fields types to 'text' field type
?>
<tr class="row0">
<td class="key" style="font-size:11px;">Converting deprecated fields types:
<?php
//echo '<br/><span class="label">' . implode('</span><span class="label">', array_keys($deprecated_fields)) . '</span>';
$msg = array();
$n = 0;
if ($fields_tbl_exists) foreach ($deprecated_fields as $old_type => $new_type)
{
$query = 'UPDATE #__flexicontent_fields'
.' SET field_type = ' .$db->Quote($new_type)
.' WHERE field_type = ' .$db->Quote($old_type);
$db->setQuery($query);
$result = $db->query();
if( !$result ) {
$msg[] = "<span class='badge badge-error'>SQL QUERY failed: ". $query ."</span>";
continue;
}
$count_rows = $db->getAffectedRows($result);
$msg[$n] = '<span class="label label-'.($count_rows ? 'warning' : 'info').'">'.$count_rows.'</span><span class="label">'.$old_type.'</span> ';
$query = 'SELECT *, extension_id AS id '
.' FROM #__extensions'
.' WHERE type="plugin"'
.' AND element='.$db->Quote( $old_type )
.' AND folder='.$db->Quote( 'flexicontent_fields' );
$db->setQuery($query);
$ext = $db->loadAssoc();
if ($ext && $ext['id'] > 0) {
$installer = new JInstaller();
if ( $installer->uninstall($ext['type'], $ext['id'], (int)$ext['client_id']) )
$msg[$n] = "<br/>".$msg[$n].", uninstalling plugin: <span class='badge badge-success'>success</span> <br/>";
else
$msg[$n] = "<br/>".$msg[$n].", uninstalling plugin: <span class='badge badge-error'>failed</span> <br/>";
}
$n++;
}
?>
</td>
<td> <?php echo implode("\n", $msg); ?> </td>
</tr>
<?php
// Upgrade DB tables: ADD new columns
?>
<tr class="row1">
<td class="key" style="font-size:11px;">Upgrading DB tables (adding/dropping columns): </td>
<td>
<?php
$tbls = array();
if ($fi_rels_tbl_exists) $tbls[] = "#__flexicontent_fields_item_relations";
if ($fi_vers_tbl_exists) $tbls[] = "#__flexicontent_items_versions";
if ($files_tbl_exists) $tbls[] = "#__flexicontent_files";
if ($fields_tbl_exists) $tbls[] = "#__flexicontent_fields";
if ($types_tbl_exists) $tbls[] = "#__flexicontent_types";
if ($iext_tbl_exists) $tbls[] = "#__flexicontent_items_ext";
if ($templates_tbl_exists) $tbls[] = "#__flexicontent_templates";
if ($content_cache_tbl_exists) $tbls[] = "#__flexicontent_items_tmp";
if ($advsearch_index_tbl_exists) $tbls[] = "#__flexicontent_advsearch_index";
foreach ($tbls as $tbl) $tbl_fields[$tbl] = $db->getTableColumns($tbl);
$queries = array();
if ( $iext_tbl_exists ) {
$_query = "ALTER TABLE `#__flexicontent_items_ext`";
$_querycols = array();
if (array_key_exists('cnt_state', $tbl_fields['#__flexicontent_items_ext'])) $_querycols[] = " DROP `cnt_state`";
if (array_key_exists('cnt_access', $tbl_fields['#__flexicontent_items_ext'])) $_querycols[] = " DROP `cnt_access`";
if (array_key_exists('cnt_publish_up', $tbl_fields['#__flexicontent_items_ext'])) $_querycols[] = " DROP `cnt_publish_up`";
if (array_key_exists('cnt_publish_down', $tbl_fields['#__flexicontent_items_ext'])) $_querycols[] = " DROP `cnt_publish_down`";
if (array_key_exists('cnt_created_by', $tbl_fields['#__flexicontent_items_ext'])) $_querycols[] = " DROP `cnt_created_by`";
if (!array_key_exists('lang_parent_id', $tbl_fields['#__flexicontent_items_ext'])) $_querycols[] = " ADD `lang_parent_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `type_id`";
if (!empty($_querycols)) $queries[] = $_query . implode(",", $_querycols);
}
if ($fi_rels_tbl_exists && !array_key_exists('suborder', $tbl_fields['#__flexicontent_fields_item_relations'])) {
$queries[] = "ALTER TABLE `#__flexicontent_fields_item_relations` ADD `suborder` INT(11) NOT NULL DEFAULT '1' AFTER `valueorder`";
}
if ($fi_vers_tbl_exists && !array_key_exists('suborder', $tbl_fields['#__flexicontent_items_versions'])) {
$queries[] = "ALTER TABLE `#__flexicontent_items_versions` ADD `suborder` INT(11) NOT NULL DEFAULT '1' AFTER `valueorder`";
}
/*if ($fi_rels_tbl_exists && !array_key_exists('qindex01', $tbl_fields['#__flexicontent_fields_item_relations'])) {
$queries[] = "ALTER TABLE `#__flexicontent_fields_item_relations` ADD `qindex01` MEDIUMTEXT NULL DEFAULT NULL AFTER `value`";
}
if ($fi_rels_tbl_exists && !array_key_exists('qindex02', $tbl_fields['#__flexicontent_fields_item_relations'])) {
$queries[] = "ALTER TABLE `#__flexicontent_fields_item_relations` ADD `qindex02` MEDIUMTEXT NULL DEFAULT NULL AFTER `qindex01`";
}
if ($fi_rels_tbl_exists && !array_key_exists('qindex03', $tbl_fields['#__flexicontent_fields_item_relations'])) {
$queries[] = "ALTER TABLE `#__flexicontent_fields_item_relations` ADD `qindex03` MEDIUMTEXT NULL DEFAULT NULL AFTER `qindex02`";
}
if ($fi_vers_tbl_exists && !array_key_exists('qindex01', $tbl_fields['#__flexicontent_items_versions'])) {
$queries[] = "ALTER TABLE `#__flexicontent_items_versions` ADD `qindex01` MEDIUMTEXT NULL DEFAULT NULL AFTER `value`";
}
if ($fi_vers_tbl_exists && !array_key_exists('qindex02', $tbl_fields['#__flexicontent_items_versions'])) {
$queries[] = "ALTER TABLE `#__flexicontent_items_versions` ADD `qindex02` MEDIUMTEXT NULL DEFAULT NULL AFTER `qindex01`";
}
if ($fi_vers_tbl_exists && !array_key_exists('qindex03', $tbl_fields['#__flexicontent_items_versions'])) {
$queries[] = "ALTER TABLE `#__flexicontent_items_versions` ADD `qindex03` MEDIUMTEXT NULL DEFAULT NULL AFTER `qindex02`";
}*/
// Files TABLE
if ( $files_tbl_exists && !array_key_exists('filename_original', $tbl_fields['#__flexicontent_files'])) {
$queries[] = "ALTER TABLE `#__flexicontent_files` ADD `filename_original` VARCHAR(255) NOT NULL DEFAULT '' AFTER `filename`";
}
if ( $files_tbl_exists && !array_key_exists('description', $tbl_fields['#__flexicontent_files'])) {
$queries[] = "ALTER TABLE `#__flexicontent_files` ADD `description` TEXT NOT NULL DEFAULT '' AFTER `altname`";
}
if ( $files_tbl_exists && !array_key_exists('language', $tbl_fields['#__flexicontent_files'])) {
$queries[] = "ALTER TABLE `#__flexicontent_files` ADD `language` CHAR(7) NOT NULL DEFAULT '*' AFTER `published`";
}
// Fields TABLE
if ( $fields_tbl_exists && !array_key_exists('untranslatable', $tbl_fields['#__flexicontent_fields'])) {
$queries[] = "ALTER TABLE `#__flexicontent_fields` ADD `untranslatable` TINYINT(1) NOT NULL DEFAULT '0' AFTER `isadvsearch`";
}
if ( $fields_tbl_exists && !array_key_exists('isadvfilter', $tbl_fields['#__flexicontent_fields'])) {
$queries[] = "ALTER TABLE `#__flexicontent_fields` ADD `isadvfilter` TINYINT(1) NOT NULL DEFAULT '0' AFTER `isfilter`";
}
if ( $fields_tbl_exists && !array_key_exists('formhidden', $tbl_fields['#__flexicontent_fields'])) {
$queries[] = "ALTER TABLE `#__flexicontent_fields` ADD `formhidden` SMALLINT(8) NOT NULL DEFAULT '0' AFTER `untranslatable`";
}
if ( $fields_tbl_exists && !array_key_exists('valueseditable', $tbl_fields['#__flexicontent_fields'])) {
$queries[] = "ALTER TABLE `#__flexicontent_fields` ADD `valueseditable` SMALLINT(8) NOT NULL DEFAULT '0' AFTER `formhidden`";
}
if ( $fields_tbl_exists && !array_key_exists('edithelp', $tbl_fields['#__flexicontent_fields'])) {
$queries[] = "ALTER TABLE `#__flexicontent_fields` ADD `edithelp` SMALLINT(8) NOT NULL DEFAULT '2' AFTER `formhidden`";
}
if ( $fields_tbl_exists && !array_key_exists('asset_id', $tbl_fields['#__flexicontent_fields']) ) {
$queries[] = "ALTER TABLE `#__flexicontent_fields` ADD `asset_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `id`";
}
// Types TABLE
if ( $types_tbl_exists && !array_key_exists('asset_id', $tbl_fields['#__flexicontent_types']) ) {
$queries[] = "ALTER TABLE `#__flexicontent_types` ADD `asset_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `id`";
}
if ( $types_tbl_exists && !array_key_exists('itemscreatable', $tbl_fields['#__flexicontent_types'])) {
$queries[] = "ALTER TABLE `#__flexicontent_types` ADD `itemscreatable` SMALLINT(8) NOT NULL DEFAULT '0' AFTER `published`";
}
// Templates TABLE
if ( $templates_tbl_exists && !array_key_exists('cfgname', $tbl_fields['#__flexicontent_templates'])) {
$queries[] = "ALTER TABLE `#__flexicontent_templates` ADD `cfgname` varchar(50) NOT NULL default '' AFTER `template`";
}
if ( !empty($queries) ) {
foreach ($queries as $query) {
$db->setQuery($query);
if ( !($result = $db->query()) ) {
$result = false;
echo "<span class='badge badge-error'>SQL QUERY failed: ". $query ."</span>";
}
}
if ( $result !== false ) {
echo "<span class='badge badge-success'>tables altered</span>";
}
}
else echo "<span class='badge badge-info'>nothing to do</span>";
?>
</td>
</tr>
<?php
// Create/Upgrade ADVANCED index DB table: ADD column and indexes
// Because Adding indexes can be heavy to the SQL server (if not done asychronously ??) we truncate table OR drop it and recreate it
?>
<tr class="row0">
<td class="key" style="font-size:11px;">Create/Upgrade advanced search index table: </td>
<td>
<?php
$queries = array();
if ( $advsearch_index_tbl_exists ) {
$db->setQuery("SHOW INDEX FROM #__flexicontent_advsearch_index");
$_indexes = $db->loadObjectList();
foreach ($_indexes as $tbl_index) $tbl_indexes['#__flexicontent_advsearch_index'][$tbl_index->Key_name] = true;
}
if ( !$advsearch_index_tbl_exists || !array_key_exists('sid', $tbl_fields['#__flexicontent_advsearch_index']) ) {
if ( $advsearch_index_tbl_exists) $queries[] = "DROP TABLE `#__flexicontent_advsearch_index`";
$queries[] = "CREATE TABLE `#__flexicontent_advsearch_index` (
`sid` int(11) NOT NULL auto_increment,
`field_id` int(11) NOT NULL, `item_id` int(11) NOT NULL, `extraid` int(11) NOT NULL,
`search_index` longtext NOT NULL, `value_id` varchar(255) NULL,
PRIMARY KEY (`field_id`,`item_id`,`extraid`),
KEY `sid` (`sid`),
KEY `field_id` (`field_id`),
KEY `item_id` (`item_id`),
FULLTEXT `search_index` (`search_index`),
KEY `value_id` (`value_id`)
) ENGINE=MyISAM CHARACTER SET `utf8` COLLATE `utf8_general_ci`";
}
/*
$_add_indexes = array();
if ( $advsearch_index_tbl_exists && !array_key_exists('field_id', $tbl_indexes['#__flexicontent_advsearch_index'])) {
$_add_indexes[] = " ADD KEY ( `field_id` ) ";
}
if ( $advsearch_index_tbl_exists && !array_key_exists('item_id', $tbl_indexes['#__flexicontent_advsearch_index'])) {
$_add_indexes[] = " ADD KEY ( `item_id` ) ";
}
if ( $advsearch_index_tbl_exists && !array_key_exists('search_index', $tbl_indexes['#__flexicontent_advsearch_index'])) {
$_add_indexes[] = " ADD FULLTEXT ( `search_index` ) ";
}
if ( $advsearch_index_tbl_exists && !array_key_exists('value_id', $tbl_indexes['#__flexicontent_advsearch_index'])) {
$_add_indexes[] = " ADD KEY ( `value_id` ) ";
}
if (count($_add_indexes)) {
$db->setQuery('TRUNCATE TABLE #__flexicontent_advsearch_index');
$db->query(); // Truncate table of search index to avoid long-delay on indexing
$queries[] = "ALTER TABLE `#__flexicontent_advsearch_index` ". implode(",", $_add_indexes);
}
*/
if ( !empty($queries) ) {
foreach ($queries as $query) {
$db->setQuery($query);
if ( !($result = $db->query()) ) {
$result = false;
echo "<span class='badge badge-error'>SQL QUERY failed: ". $query ."</span>";
}
}
if ( $result !== false ) {
echo "<span class='badge badge-success'>table altered</span> please re-index your content</span>";
}
}
else echo "<span class='badge badge-info'>nothing to do</span>";
?>
</td>
</tr>
<?php
// Create authors_ext table if it does not exist
?>
<tr class="row1">
<td class="key" style="font-size:11px;">Create/Upgrade authors extended DB table: </td>
<td>
<?php
$queries = array();
if ( !$authors_ext_tbl_exists ) {
$queries[] = "
CREATE TABLE IF NOT EXISTS `#__flexicontent_authors_ext` (
`user_id` int(11) unsigned NOT NULL,
`author_basicparams` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`author_catparams` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM CHARACTER SET `utf8` COLLATE `utf8_general_ci`";
}
if ( !empty($queries) ) {
foreach ($queries as $query) {
$db->setQuery($query);
if ( !($result = $db->query()) ) {
$result = false;
echo "<span class='badge badge-error'>SQL QUERY failed: ". $query ."</span>";
}
}
if ( $result !== false ) {
echo "<span class='badge badge-success'>table created / upgraded</span>";
}
}
else echo "<span class='badge badge-info'>nothing to do</span>";
?>
</td>
</tr>
<?php
// Create content_cache table if it does not exist
?>
<tr class="row0">
<td class="key" style="font-size:11px;">Create/Upgrade content cache DB table: </td>
<td>
<?php
$queries = array();
if ( !$content_cache_tbl_exists ) {
$queries[] = "
CREATE TABLE `#__flexicontent_items_tmp` (
`id` int(10) unsigned NOT NULL,
`title` VARCHAR(255) NOT NULL,
`state` tinyint(3) NOT NULL DEFAULT '0',
`catid` int(10) unsigned NOT NULL DEFAULT '0',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` int(10) unsigned NOT NULL DEFAULT '0',
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified_by` int(10) unsigned NOT NULL DEFAULT '0',
`publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`version` int(10) unsigned NOT NULL DEFAULT '1',
`ordering` int(11) NOT NULL DEFAULT '0',
`access` int(10) unsigned NOT NULL DEFAULT '0',
`hits` int(10) unsigned NOT NULL DEFAULT '0',
`featured` tinyint(3) unsigned NOT NULL DEFAULT '0',
`language` char(7) NOT NULL,
`type_id` int(11) NOT NULL DEFAULT '0',
`lang_parent_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
";
} else {
$_querycols = array();
if (array_key_exists('sectionid', $tbl_fields['#__flexicontent_items_tmp'])) $_querycols[] = " DROP `sectionid`"; // Drop J1.5 sectionid
if (!array_key_exists('type_id', $tbl_fields['#__flexicontent_items_tmp'])) $_querycols[] = " ADD `type_id` INT(11) NOT NULL DEFAULT '0' AFTER `language`";
if (!array_key_exists('lang_parent_id', $tbl_fields['#__flexicontent_items_tmp'])) $_querycols[] = " ADD `lang_parent_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `type_id`";
if (!empty($_querycols)) $queries[] = "ALTER TABLE `#__flexicontent_items_tmp` " . implode(",", $_querycols);
}
if ( !empty($queries) ) {
foreach ($queries as $query) {
$db->setQuery($query);
if ( !($result = $db->query()) ) {
$result = false;
echo "<span class='badge badge-error'>SQL QUERY failed: ". $query ."</span>";
}
}
if ( $result !== false ) {
echo "<span class='badge badge-success'>table created / upgraded</span>";
}
}
else echo "<span class='badge badge-info'>nothing to do</span>";
?>
</td>
</tr>
<?php
// Create/Upgrade DB tables for downloads enhancements
?>
<tr class="row1">
<td class="key" style="font-size:11px;">Create/Upgrade DB tables for downloads enhancements: </td>
<td>
<?php
$queries = array();
if ( !$dl_history_tbl_exists ) {
$queries[] = "
CREATE TABLE `#__flexicontent_download_history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`file_id` int(11) NOT NULL,
`hits` int(11) NOT NULL,
`last_hit_on` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
KEY `file_id` (`file_id`)
) ENGINE=MyISAM CHARACTER SET `utf8` COLLATE `utf8_general_ci`";
}
if ( !$dl_coupons_tbl_exists ) {
$queries[] = "
CREATE TABLE `#__flexicontent_download_coupons` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`file_id` int(11) NOT NULL,
`token` varchar(255) NOT NULL,
`hits` int(11) NOT NULL,
`hits_limit` int(11) NOT NULL,
`expire_on` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
KEY `file_id` (`file_id`),
KEY `token` (`token`)
) ENGINE=MyISAM CHARACTER SET `utf8` COLLATE `utf8_general_ci`";
}
if ( !empty($queries) ) {
foreach ($queries as $query) {
$db->setQuery($query);
if ( !($result = $db->query()) ) {
$result = false;
echo "<span class='badge badge-error'>SQL QUERY failed: ". $query ."</span>";
}
}
if ( $result !== false ) {
echo "<span class='badge badge-success'>table(s) created or upgraded</span>";
}
}
else echo "<span class='badge badge-info'>nothing to do</span>";
?>
</td>
</tr>
<?php
// Create layouts_conf table if it does not exist
?>
<tr class="row0">
<td class="key" style="font-size:11px;">Create/Upgrade layouts configuration DB table: </td>
<td>
<?php
$queries = array();
if ( !$layouts_conf_tbl_exists ) {
$queries[] = "
CREATE TABLE IF NOT EXISTS `#__flexicontent_layouts_conf` (
`template` varchar(50) NOT NULL default '',
`cfgname` varchar(50) NOT NULL default '',
`layout` varchar(20) NOT NULL default '',
`attribs` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`template`,`cfgname`,`layout`)
) ENGINE=MyISAM CHARACTER SET `utf8` COLLATE `utf8_general_ci`";
}
if ( !empty($queries) ) {
foreach ($queries as $query) {
$db->setQuery($query);
if ( !($result = $db->query()) ) {
$result = false;
echo "<span class='badge badge-error'>SQL QUERY failed: ". $query ."</span>";
}
}
if ( $result !== false ) {
echo "<span class='badge badge-success'>table created</span>";
}
}
else echo "<span class='badge badge-info'>nothing to do</span>";
?>
</td>
</tr>
<?php