family-connections /admin/config.php

Language PHP Lines 1500
MD5 Hash d04531a037bfc0b4a9f3b087682e01ea Estimated Cost $32,517 (why?)
Repository https://bitbucket.org/ryanhowdy/family-connections.git View Raw File View Project SPDX
   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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
<?php
/**
 * Configuration
 * 
 * PHP versions 4 and 5
 *
 * @category  FCMS
 * @package   FamilyConnections
 * @author    Ryan Haudenschilt <r.haudenschilt@gmail.com> 
 * @copyright 2010 Haudenschilt LLC
 * @license   http://www.gnu.org/licenses/gpl-2.0.html GPLv2
 * @link      http://www.familycms.com/wiki/
 */
session_start();

define('URL_PREFIX', '../');
define('GALLERY_PREFIX', '../gallery/');

require URL_PREFIX.'fcms.php';

init('admin/');

$fcmsUser->id = (int)$_SESSION['login_id'];

$TMPL = array(
    'sitename'      => getSiteName(),
    'nav-link'      => getAdminNavLinks(),
    'pagetitle'     => T_('Administration: Configuration'),
    'path'          => URL_PREFIX,
    'displayname'   => $fcmsUser->displayName,
    'version'       => getCurrentVersion(),
    'year'          => date('Y')
);

control();
exit();

/**
 * control 
 * 
 * The controlling structure for this script.
 * 
 * @return void
 */
function control ()
{
    global $fcmsUser;

    if (checkAccess($fcmsUser->id) > 2)
    {
        displayInvalidAccessLevel();
        return;
    }
    elseif (isset($_GET['view']))
    {
        $view = $_GET['view'];

        if ($view == 'general')
        {
            if (isset($_POST['submit-sitename']))
            {
                displayGeneralFormSubmit();
            }
            else
            {
                displayGeneralForm();
            }
        }
        elseif ($view == 'defaults')
        {
            if (isset($_POST['submit-defaults']))
            {
                displayDefaultsFormSubmit();
            }
            else
            {
                displayDefaultsForm();
            }
        }
        elseif ($view == 'plugins')
        {
            if (isset($_POST['submit-plugins']))
            {
                displayPluginsFormSubmit();
            }
            else
            {
                displayPluginsForm();
            }
        }
        elseif ($view == 'navigation')
        {
            if (isset($_POST['submit-navigation']))
            {
                displayNavigationFormSubmit();
            }
            else
            {
                displayNavigationForm();
            }
        }
        // TODO move out of here
        elseif ($view == 'gallery')
        {
            if (isset($_POST['submit-gallery']))
            {
                displayPhotoGalleryFormSubmit();
            }
            else
            {
                displayPhotoGalleryForm();
            }
        }
        else
        {
            displayGeneralForm();
        }
    }
    elseif (isset($_POST['submit-ajax-navigation']))
    {
        displayNavigationFormSubmit(true);
    }
    else
    {
        displayGeneralForm();
    }
}

/**
 * displayHeader 
 * 
 * @return void
 */
function displayHeader ()
{
    global $fcmsUser, $TMPL;

    $TMPL['javascript'] = '
<script src="'.URL_PREFIX.'ui/js/prototype.js" type="text/javascript"></script>
<script src="'.URL_PREFIX.'ui/js/scriptaculous.js" type="text/javascript"></script>
<script src="'.URL_PREFIX.'ui/js/admin.js" type="text/javascript"></script>
<script src="'.URL_PREFIX.'ui/js/livevalidation.js" type="text/javascript"></script>';

    include_once URL_PREFIX.'ui/admin/header.php';

    $general    = '';
    $defaults   = '';
    $plugins    = '';
    $navigation = '';
    $gallery    = '';

    if (!isset($_GET['view']))
    {
        $general = 'active';
    }
    else
    {
        switch ($_GET['view'])
        {
            case 'general':
            default:
                $general = 'active';
                break;
            case 'defaults':
                $defaults = 'active';
                break;
            case 'plugins':
                $plugins = 'active';
                break;
            case 'navigation':
                $navigation = 'active';
                break;
            case 'gallery':
                $gallery = 'active';
                break;
        }
    }

    echo '
        <div id="config" style="position:relative;">

            <ul class="tabs">
                <li class="'.$general.'"><a href="?view=general">'.T_('General').'</a></li>
                <li class="'.$defaults.'"><a href="?view=defaults">'.T_('Defaults').'</a></li>
                <li class="'.$plugins.'"><a href="?view=plugins">'.T_('Plugins').'</a></li>
                <li class="'.$navigation.'"><a href="?view=navigation">'.T_('Navigation').'</a></li>
                <li class="'.$gallery.'"><a href="?view=gallery">'.T_('Photo Gallery').'</a></li>
            </ul>';
}

/**
 * displayFooter 
 * 
 * @return void
 */
function displayFooter ()
{
    global $fcmsUser, $TMPL;

    echo '
        </div><!--/config-->';

    include_once URL_PREFIX.'ui/admin/footer.php';
}

/**
 * displayInvalidAccessLevel 
 * 
 * @return void
 */
function displayInvalidAccessLevel ()
{
    displayHeader();

    echo '
            <p class="error-alert">
                <b>'.T_('You do not have access to view this page.').'</b><br/>
                '.T_('This page requires an access level 1 (Admin).').' 
                <a href="../contact.php">'.T_('Please contact your website\'s administrator if you feel you should have access to this page.').'</a>
            </p>';

    displayFooter();
}

/**
 * displayGeneralForm 
 * 
 * @return void
 */
function displayGeneralForm ()
{
    displayHeader();

    $sql = "SELECT `name`, `value`
            FROM `fcms_config`";

    $result = mysql_query($sql);
    if (!$result)
    {
        displaySqlError($sql, mysql_error());
        displayFooter();
        return;
    }

    $row = array();

    while ($r = mysql_fetch_assoc($result))
    {
        $row[$r['name']] = $r['value'];
    }
    
    // Activate Options
    $activateList = array (
        '0' => T_('Admin Activation'),
        '1' => T_('Auto Activation')
    );

    $activateOptions = buildHtmlSelectOptions($activateList, $row['auto_activate']);
    
    // Register Options
    $registerList = array (
        '0' => T_('Off'),
        '1' => T_('On')
    );

    $registerOptions = buildHtmlSelectOptions($registerList, $row['registration']);

    // Start of week
    $startSun = ($row['start_week'] == 0) ? 'checked' : '';;
    $startMon = ($row['start_week'] == 1) ? 'checked' : '';
    $startTue = ($row['start_week'] == 2) ? 'checked' : '';
    $startWed = ($row['start_week'] == 3) ? 'checked' : '';
    $startThr = ($row['start_week'] == 4) ? 'checked' : '';
    $startFri = ($row['start_week'] == 5) ? 'checked' : '';
    $startSat = ($row['start_week'] == 6) ? 'checked' : '';

    // Site Off Options
    // TODO - config table or file?
    $siteOffYes = '';
    $siteOffNo  = '';
    if ($row['site_off'] == 1)
    {
        $siteOffYes = 'checked';
    }
    else
    {
        $siteOffNo = 'checked';
    }

    // Debug
    $debugList = array(
        '0' => T_('Off'),
        '1' => T_('On')
    );

    $debugOptions = buildHtmlSelectOptions($debugList, $row['debug']);

    $message = '';

    if (isset($_SESSION['success']))
    {
        $message  = '<div class="alert-message success">';
        $message .= '<a class="close" href="#" onclick="$(this).up(\'div\').hide(); return false;">&times;</a>';
        $message .= T_('Changes Updated Successfully').'</div>';

        unset($_SESSION['success']);
    }

    echo '
        <form action="config.php?view=general" method="post">
        <fieldset>
            <legend>'.T_('General Configuration').'</legend>
            '.$message.'
            <div class="clearfix">
                <label for="sitename">'.T_('Site Name').'</label>
                <div class="input">
                    <input class="xlarge span8" id="sitename" name="sitename" type="text" value="'.cleanOutput($row['sitename']).'">
                </div>
            </div>
            <div class="clearfix">
                <label for="contact">'.T_('Contact Email').'</label>
                <div class="input">
                    <input class="xlarge span8" id="contact" name="contact" type="text" value="'.cleanOutput($row['contact']).'">
                </div>
                <script type="text/javascript">
                    var email = new LiveValidation(\'contact\', {onlyOnSubmit: true});
                    email.add(Validate.Email, {failureMessage: "'.T_('That\'s not a valid email address is it?').'"});
                    email.add(Validate.Length, {minimum: 10});
                </script>
            </div>
            <div class="clearfix">
                <label for="registration">'.T_('Registration').'</label>
                <div class="input">
                    <select id="registration" name="registration">
                        '.$registerOptions.'
                    </select>
                </div>
            </div>
            <div class="clearfix">
                <label for="activation">'.T_('Account Activation').'</label>
                <div class="input">
                    <select id="activation" name="activation">
                        '.$activateOptions.'
                    </select>
                </div>
            </div>
            <div class="clearfix">
                <label>'.T_('Start of the Week').'</label>
                <div class="input">
                    <ul class="inputs-list">
                        <li>
                            <label>
                                <input type="radio" '.$startSun.' id="start_sun" name="start_week" value="0">
                                <span>'.T_('Sunday').'</span>
                            </label>
                        </li>
                        <li>
                            <label>
                                <input type="radio" '.$startMon.' id="start_mon" name="start_week" value="1">
                                <span>'.T_('Monday').'</span>
                            </label>
                        </li>
                        <li>
                            <label>
                                <input type="radio" '.$startTue.' id="start_tue" name="start_week" value="2">
                                <span>'.T_('Tuesday').'</span>
                            </label>
                        </li>
                        <li>
                            <label>
                                <input type="radio" '.$startWed.' id="start_wed" name="start_week" value="3">
                                <span>'.T_('Wednesday').'</span>
                            </label>
                        </li>
                        <li>
                            <label>
                                <input type="radio" '.$startThr.' id="start_thr" name="start_week" value="4">
                                <span>'.T_('Thursday').'</span>
                            </label>
                        </li>
                        <li>
                            <label>
                                <input type="radio" '.$startFri.' id="start_fri" name="start_week" value="5">
                                <span>'.T_('Friday').'</span>
                            </label>
                        </li>
                        <li>
                            <label>
                                <input type="radio" '.$startSat.' id="start_sat" name="start_week" value="6">
                                <span>'.T_('Saturday').'</span>
                            </label>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="clearfix">
                <label>'.T_('Turn Off Site?').'</label>
                <div class="input">
                    <ul class="inputs-list">
                        <li>
                            <label>
                                <input type="radio" '.$siteOffYes.' id="site_off_yes" name="site_off" value="yes">
                                <span>'.T_('Yes, turn the site off, so no one can access it.').'</span>
                            </label>
                        </li>
                        <li>
                            <label>
                                <input type="radio" '.$siteOffNo.' id="site_off_no" name="site_off" value="no">
                                <span>'.T_('No, keep the site on and running.').'</span>
                            </label>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="clearfix">
                <label for="debug">'.T_('Debug').'</label>
                <div class="input">
                    <select id="debug" name="debug">
                        '.$debugOptions.'
                    </select>
                </div>
            </div>
            <div class="actions">
                <input type="submit" class="btn primary" id="submit-sitename" name="submit-sitename" value="'.T_('Save').'">
            </div>
        </fieldset>
        </form>';

    displayFooter();
}

/**
 * displayGeneralFormSubmit 
 * 
 * @return void
 */
function displayGeneralFormSubmit ()
{
    if (isset($_POST['sitename']))
    {
        $sitename = strip_tags($_POST['sitename']);
        $sitename = escape_string($sitename);

        $sql = "UPDATE `fcms_config` 
                SET `value` = '$sitename'
                WHERE `name` = 'sitename'";
        if (!mysql_query($sql))
        {
            displayHeader();
            displaySqlError($sql, mysql_error());
            displayFooter();
            return;
        }
    }

    if (isset($_POST['contact']))
    {
        $contact = strip_tags($_POST['contact']);
        $contact = escape_string($contact);

        $sql = "UPDATE `fcms_config` 
                SET `value` = '$contact'
                WHERE `name` = 'contact'";
        if (!mysql_query($sql))
        {
            displayHeader();
            displaySqlError($sql, mysql_error());
            displayFooter();
            return;
        }
    }

    if (isset($_POST['activation']))
    {
        $sql = "UPDATE `fcms_config` 
                SET `value` = '".escape_string($_POST['activation'])."'
                WHERE `name` = 'auto_activate'";
        if (!mysql_query($sql))
        {
            displayHeader();
            displaySqlError($sql, mysql_error());
            displayFooter();
            return;
        }
    }

    if (isset($_POST['registration']))
    {
        $sql = "UPDATE `fcms_config` 
                SET `value` = '".escape_string($_POST['registration'])."'
                WHERE `name` = 'registration'";
        if (!mysql_query($sql))
        {
            displayHeader();
            displaySqlError($sql, mysql_error());
            displayFooter();
            return;
        }
    }

    if (isset($_POST['start_week']))
    {
        $sql = "UPDATE `fcms_config` 
                SET `value` = '".(int)$_POST['start_week']."'
                WHERE `name` = 'start_week'";

        if (!mysql_query($sql))
        {
            displayHeader();
            displaySqlError($sql, mysql_error());
            displayFooter();
            return;
        }
    }

    if (isset($_POST['site_off']))
    {
        $val = $_POST['site_off'] == 'yes' ? '1' : '0';

        $sql = "UPDATE `fcms_config` 
                SET `value` = '".($_POST['site_off'] == 'yes' ? '1' : '0')."'
                WHERE `name` = 'site_off'";

        if (!mysql_query($sql))
        {
            displayHeader();
            displaySqlError($sql, mysql_error());
            displayFooter();
            return;
        }
    }

    if (isset($_POST['debug']))
    {
        $sql = "UPDATE `fcms_config` 
                SET `value` = '".escape_string($_POST['debug'])."'
                WHERE `name` = 'debug'";
        if (!mysql_query($sql))
        {
            displayHeader();
            displaySqlError($sql, mysql_error());
            displayFooter();
            return;
        }
    }

    $_SESSION['success'] = 1;

    header("Location: config.php?view=general");
}

/**
 * displayDefaultsForm
 * 
 * @return void
 */
function displayDefaultsForm ()
{
    displayHeader();

    // Defaults Config
    $sql = "DESCRIBE `fcms_user_settings`";

    $result = mysql_query($sql);
    if (!$result)
    {
        displaySqlError($sql, mysql_error());
        displayFooter();
        return;
    }

    while ($drow = mysql_fetch_assoc($result))
    {
        if ($drow['Field'] == 'theme')
        {
            $default_theme = $drow['Default'];
        }
        if ($drow['Field'] == 'displayname')
        {
            $default_displayname = $drow['Default'];
        }
        if ($drow['Field'] == 'frontpage')
        {
            $default_frontpage = $drow['Default'];
        }
        if ($drow['Field'] == 'timezone')
        {
            $default_tz = $drow['Default'];
        }
        if ($drow['Field'] == 'dst')
        {
            $default_dst = $drow['Default'];
        }
        if ($drow['Field'] == 'boardsort')
        {
            $default_boardsort = $drow['Default'];
        }
    }

    // Themes
    $themes        = getThemeList();
    $theme_options = '';

    foreach($themes as $file)
    {
        $theme_options .= '<option value="'.$file.'"';

        if ($default_theme == $file)
        {
            $theme_options .= ' selected="selected"';
        }

        $theme_options .= ">$file</option>";
    }

    // Display Name
    $displayname_list = array(
        "1" => T_('First Name'),
        "2" => T_('First & Last Name'),
        "3" => T_('Username')
    );

    $displayname_options = buildHtmlSelectOptions($displayname_list, $default_displayname);

    // Frontpage
    $frontpage_list = array(
        "1" => T_('All (by date)'),
        "2" => T_('Last 5 (by plugin)')
    );

    $frontpage_options = buildHtmlSelectOptions($frontpage_list, $default_frontpage);

    // Timezone
    $tz_list = array(
        "-12 hours"            => T_('(GMT -12:00) Eniwetok, Kwajalein'),
        "-11 hours"            => T_('(GMT -11:00) Midway Island, Samoa'),
        "-10 hours"            => T_('(GMT -10:00) Hawaii'),
        "-9 hours"             => T_('(GMT -9:00) Alaska'),
        "-8 hours"             => T_('(GMT -8:00) Pacific Time (US & Canada)'),
        "-7 hours"             => T_('(GMT -7:00) Mountain Time (US & Canada)'),
        "-6 hours"             => T_('(GMT -6:00) Central Time (US & Canada), Mexico City'),
        "-5 hours"             => T_('(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima'),
        "-4 hours"             => T_('(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz'),
        "-3 hours -30 minutes" => T_('(GMT -3:30) Newfoundland'),
        "-3 hours"             => T_('(GMT -3:00) Brazil, Buenos Aires, Georgetown'),
        "-2 hours"             => T_('(GMT -2:00) Mid-Atlantic'),
        "-1 hours"             => T_('(GMT -1:00) Azores, Cape Verde Islands'),
        "-0 hours"             => T_('(GMT) Western Europe Time, London, Lisbon, Casablanca'),
        "+1 hours"             => T_('(GMT +1:00) Brussels, Copenhagen, Madrid, Paris'),
        "+2 hours"             => T_('(GMT +2:00) Kaliningrad, South Africa'),
        "+3 hours"             => T_('(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburgh'),
        "+3 hours 30 minutes"  => T_('(GMT +3:30) Tehran'),
        "+4 hours"             => T_('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi'),
        "+4 hours 30 minutes"  => T_('(GMT +4:30) Kabul'),
        "+5 hours"             => T_('(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent'),
        "+5 hours 30 minutes"  => T_('(GMT +5:30) Bombay, Calcutta, Madras, New Delhi'),
        "+6 hours"             => T_('(GMT +6:00) Almaty, Dhaka, Colombo'),
        "+7 hours"             => T_('(GMT +7:00) Bangkok, Hanoi, Jakarta'),
        "+8 hours"             => T_('(GMT +8:00) Beijing, Perth, Singapore, Hong Kong'),
        "+9 hours"             => T_('(GMT +9:00) Tokyo, Seoul, Osaka, Spporo, Yakutsk'),
        "+9 hours 30 minutes"  => T_('(GMT +9:30) Adeliaide, Darwin'),
        "+10 hours"            => T_('(GMT +10:00) Eastern Australia, Guam, Vladivostok'),
        "+11 hours"            => T_('(GMT +11:00) Magadan, Solomon Islands, New Caledonia'),
        "+12 hours"            => T_('(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka')
    );

    $tz_options = buildHtmlSelectOptions($tz_list, $default_tz);

    // DST
    $dst_list = array(
        1 => T_('On'),
        0 => T_('Off')
    );
    $dst_options = buildHtmlSelectOptions($dst_list, $default_dst);

    // Board Sort
    $boardsort_list = array(
        "ASC" => T_('New Messages at Bottom'),
        "DESC" => T_('New Messages at Top')
    );

    $boardsort_options = buildHtmlSelectOptions($boardsort_list, $default_boardsort);
    
    $message = '';

    if (isset($_SESSION['success']))
    {
        $message  = '<div class="alert-message success">';
        $message .= '<a class="close" href="#" onclick="$(this).up(\'div\').hide(); return false;">&times;</a>';
        $message .= T_('Changes Updated Successfully').'</div>';

        unset($_SESSION['success']);
    }

    echo '
        <form action="config.php?view=defaults" method="post">
        '.$message.'
        <fieldset>
            <legend>'.T_('New Member Default Settings').'</legend>
            <div class="clearfix">
                <label for="theme">'.T_('Theme').'</label>
                <div class="input">
                    <select name="theme" id="theme">
                        '.$theme_options.'
                    </select>
                </div>
            </div>
            <div class="clearfix">
                <label for="displayname">'.T_('Display Name').'</label>
                <div class="input">
                    <select name="displayname" id="displayname" title="'.T_('How do you want your name to display?').'">
                        '.$displayname_options.'
                    </select>
                </div>
            </div>
            <div class="clearfix">
                <label for="frontpage">'.T_('Front Page').'</label>
                <div class="input">
                    <select name="frontpage" id="frontpage" title="'.T_('How do you want the latest information to display on the homepage?').'">
                        '.$frontpage_options.'
                    </select>
                </div>
            </div>
            <div class="clearfix">
                <label for="timezone">'.T_('Time Zone').'</label>
                <div class="input">
                    <select class="span8" name="timezone" id="timezone" title="'.T_('What time zone do you live in?').'">
                        '.$tz_options.'
                    </select>
                </div>
            </div>
            <div class="clearfix">
                <label for="dst">'.T_('Daylight Savings Time').'</label>
                <div class="input">
                    <select name="dst" id="dst">
                        '.$dst_options.'
                    </select>
                </div>
            </div>
            <div class="clearfix">
                <label for="boardsort">'.T_('Sort Messages').'</label>
                <div class="input">
                    <select name="boardsort" id="boardsort" title="'.T_('How do you want messages to display on the Message Board?').'">
                        '.$boardsort_options.'
                    </select>
                </div>
            </div>
            <div class="clearfix">
                <label>&nbsp;</label>
                <div class="input">
                    <ul class="inputs-list">
                        <li>
                            <label>
                                <input type="checkbox" name="changeAll" id="changeAll"/> 
                                <span>'.T_('Update existing users?').'</span>
                            </label>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="actions">
                <input type="submit" id="submit-defaults" name="submit-defaults" class="btn primary" value="'.T_('Save').'"/> &nbsp;
            </div>
        </fieldset>
        </form>';

    displayFooter();
}

/**
 * displayDefaultsFormSubmit 
 * 
 * @return void
 */
function displayDefaultsFormSubmit ()
{
    $theme = basename($_POST['theme']);
    $theme = escape_string($theme);

    $sql = "ALTER TABLE `fcms_user_settings` 
            ALTER `theme` SET DEFAULT '$theme'";
    if (!mysql_query($sql))
    {
        displayHeader();
        displaySqlError($sql, mysql_error());
        displayFooter();
        return;
    }

    $sql = "ALTER TABLE `fcms_user_settings` 
            ALTER `displayname` 
            SET DEFAULT '".escape_string($_POST['displayname'])."'";
    if (!mysql_query($sql))
    {
        displayHeader();
        displaySqlError($sql, mysql_error());
        displayFooter();
        return;
    }

    $sql = "ALTER TABLE `fcms_user_settings` 
            ALTER `frontpage` 
            SET DEFAULT '".escape_string($_POST['frontpage'])."'";
    if (!mysql_query($sql))
    {
        displayHeader();
        displaySqlError($sql, mysql_error());
        displayFooter();
        return;
    }

    $sql = "ALTER TABLE `fcms_user_settings` 
            ALTER `timezone` 
            SET DEFAULT '".escape_string($_POST['timezone'])."'";
    if (!mysql_query($sql))
    {
        displayHeader();
        displaySqlError($sql, mysql_error());
        displayFooter();
        return;
    }

    $sql = "ALTER TABLE `fcms_user_settings` ALTER `dst`
            SET DEFAULT '".escape_string($_POST['dst'])."'";

    if (!mysql_query($sql))
    {
        displayHeader();
        displaySqlError($sql, mysql_error());
        displayFooter();
        return;
    }

    $sql = "ALTER TABLE `fcms_user_settings` 
            ALTER `boardsort` 
            SET DEFAULT '".escape_string($_POST['boardsort'])."'";
    if (!mysql_query($sql))
    {
        displayHeader();
        displaySqlError($sql, mysql_error());
        displayFooter();
        return;
    }

    // Update existing users
    if (isset($_POST['changeAll']))
    {
        $avatar = isset($upfile) ? $upfile : 'no_avatar.jpg';
        $theme  = basename($_POST['theme']);
        $theme  = escape_string($theme);

        $sql = "UPDATE `fcms_user_settings` 
                SET `theme` = '$theme',
                    `displayname`  = '".escape_string($_POST['displayname'])."', 
                    `frontpage`    = '".escape_string($_POST['frontpage'])."', 
                    `timezone`     = '".escape_string($_POST['timezone'])."',
                    `dst`          = '".escape_string($_POST['dst'])."',
                    `boardsort`    = '".escape_string($_POST['boardsort'])."'";
        if (!mysql_query($sql))
        {
            displayHeader();
            displaySqlError($sql, mysql_error());
            displayFooter();
            return;
        }
    }

    $_SESSION['success'] = 1;

    header("Location: config.php?view=defaults");
}

/**
 * displayPluginsForm
 * 
 * @return void
 */
function displayPluginsForm ()
{
    displayHeader();

    // Get Plugin Data
    $plugins = array();

    $sql = "SELECT `id`, `link`, `col`, `order`, `req`
            FROM `fcms_navigation` 
            WHERE `col` = 3 
            OR `col` = 4
            ORDER BY `order`";

    $result = mysql_query($sql);
    if (!$result)
    {
        displaySqlError($sql, mysql_error());
        displayFooter();
        return;
    }

    while ($r = mysql_fetch_assoc($result))
    {
        $plugins[getPluginName($r['link'])] = $r;
    }

    ksort($plugins);

    $message = '';

    if (isset($_SESSION['success']))
    {
        $message  = '<div class="alert-message success">';
        $message .= '<a class="close" href="#" onclick="$(this).up(\'div\').hide(); return false;">&times;</a>';
        $message .= T_('Changes Updated Successfully').'</div>';

        unset($_SESSION['success']);
    }

    echo '
            <h2>'.T_('Plugins').'</h2>
            '.$message.'
            <form action="config.php?view=plugins" method="post">
                <table class="bordered-table zebra-striped">
                    <thead>
                        <tr><th class="check">'.T_('Enabled').'</th><th>'.T_('Name').'</th><th>'.T_('Description').'</th></tr>
                    </thead>
                    <tbody>';

    foreach ($plugins AS $name => $plugin)
    {
        $checked  = $plugin['order'] == 0 ? '' : ' checked="checked"';
        $disabled = $plugin['req']   == 0 ? '' : ' disabled="disabled"';

        echo '
                        <tr>
                            <td class="check"><input type="checkbox" id="'.$plugin['link'].'" name="'.$plugin['link'].'" '.$checked.$disabled.'/></td>
                            <td><b>'.$name.'</b></td>
                            <td>'.getPluginDescription($plugin['link']).'</td>
                        </tr>';
    }

    echo '
                    </tbody>
                </table>
                <p><input type="submit" class="btn primary" id="submit-plugins" name="submit-plugins" value="'.T_('Save').'"/></p>
            </form>';

    displayFooter();
}

/**
 * displayPluginsFormSubmit
 * 
 * @return void
 */
function displayPluginsFormSubmit ()
{
    $on  = array();
    $off = array();

    // Get Plugin Data
    $sql = "SELECT `id`, `link`, `col`, `order`, `req`
            FROM `fcms_navigation` 
            WHERE (
                `col` = 3 
                OR `col` = 4
            )
            AND `req` = 0
            ORDER BY `order`";

    $result = mysql_query($sql);
    if (!$result)
    {
        displaySqlError($sql, mysql_error());
        displayFooter();
        return;
    }

    while ($r = mysql_fetch_assoc($result))
    {
        // Turn on
        if (isset($_POST[$r['link']]))
        {
            if ($r['order'] == 0)
            {
                $on[] = $r;
            }
        }
        // Turn off
        else
        {
            $off[] = $r['id'];
        }
    }

    // Turn off all that need turned off
    if (count($off) > 0)
    {
        $offIds = implode(',', $off);

        $sql = "UPDATE `fcms_navigation` 
                SET `order` = 0 
                WHERE `id` IN ($offIds)";
        if (!mysql_query($sql))
        {
            displayHeader();
            displaySqlError($sql, mysql_error());
            displayFooter();
            return;
        }
    }

    // Turn on all that need turned on
    $communicateOrder = getNextNavigationOrder(3);
    $shareOrder       = getNextNavigationOrder(4);

    foreach ($on as $plugin)
    {
        if ($plugin['col'] == 3)
        {
            $order = $communicateOrder;
            $communicateOrder++;
        }
        elseif ($plugin['col'] == 4)
        {
            $order = $shareOrder;
            $shareOrder++;
        }

        $id = (int)$plugin['id'];

        $sql = "UPDATE `fcms_navigation` 
                SET `order` = '$order' 
                WHERE `id` = '$id'";
        if (!mysql_query($sql))
        {
            displayHeader();
            displaySqlError($sql, mysql_error());
            displayFooter();
            return;
        }
    }

    $_SESSION['success'] = 1;

    header("Location: config.php?view=plugins");
}

/**
 * displayNavigationForm 
 * 
 * @return void
 */
function displayNavigationForm ()
{
    displayHeader();

    // Get Plugin Data
    $communicateNavj  = array();
    $shareNav = array();

    $sql = "SELECT `id`, `link`, `col`, `order`, `req`
            FROM `fcms_navigation` 
            WHERE `col` = 3 
            OR `col` = 4
            AND `order` > 0
            ORDER BY `order`";

    $result = mysql_query($sql);
    if (!$result)
    {
        displaySqlError($sql, mysql_error());
        displayFooter();
        return;
    }

    while ($r = mysql_fetch_assoc($result))
    {
        if ($r['col'] == 3)
        {
            $communicateNav[] = $r;
        }
        else
        {
            $shareNav[] = $r;
        }
    }

    $message = '';

    if (isset($_SESSION['success']))
    {
        $message  = '<div class="alert-message success">';
        $message .= '<a class="close" href="#" onclick="$(this).up(\'div\').hide(); return false;">&times;</a>';
        $message .= T_('Changes Updated Successfully').'</div>';

        unset($_SESSION['success']);
    }

    echo '
            <h2 id="navigation-heading">'.T_('Navigation').'</h2>
            '.$message.'
            <form action="config.php?view=navigation" method="post">

                <div class="row">

                    <div class="span8">
                        <h3>'.T_('Communicate').'</h3>
                        <ol id="com_order" class="unstyled">';

    $communicateTotal = count($communicateNav);

    $i = 1;
    foreach ($communicateNav as $r)
    {
        echo '
                            <li id="com_'.$r['id'].'">
                                <span class="order">'.getOrderSelectBox('com', $r['id'], $communicateTotal, $r['order'], $i).'</span>
                                <b>'.getPluginName($r['link']).'</b>
                            </li>';
        $i++;
    }

    echo '
                        </ol>
                    </div><!-- /span8 -->

                    <div class="span8">
                        <h3>'.T_('Share').'</h3>
                        <ol id="share_order" class="unstyled">';

    $shareTotal = count($shareNav);

    $i = 1;
    foreach ($shareNav as $r)
    {
        echo '
                            <li id="share_'.$r['id'].'">
                                <span class="order">'.getOrderSelectBox('share', $r['id'], $shareTotal, $r['order'], $i).'</span>
                                <b>'.getPluginName($r['link']).'</b>
                            </li>';
        $i++;
    }

    echo '
                        </ol>
                    </div><!-- /span8 -->

                </div><!-- /row -->

                <p><input type="submit" class="btn primary" id="submit-navigation" name="submit-navigation" value="'.T_('Save').'"/></p>
            </form>

            <script type="text/javascript">
            $("submit-navigation").hide();
            $$(".order").each(function(item) {
                item.hide();
                item.up("li").addClassName("sortable");
            });
            Sortable.create("com_order", {
                onUpdate: function() {
                    new Ajax.Request("config.php", {
                        method: "post",
                        onSuccess: function(response) {
                            if (response.responseText !== "success") {
                                insertAlertMessage("error", "navigation-heading", "'.T_('An error occurred. Changes could not be saved.').'");
                            } else {
                                insertAlertMessage("success inline-alert", "navigation-heading", "'.T_('Changes Saved').'");
                            }
                        },
                        onFailure: function(response) {
                            insertAlertMessage("error", "navigation-heading", "'.T_('An error occurred. Changes could not be saved.').'");
                        },
                        parameters: { 
                            "submit-ajax-navigation": "1",
                            data: Sortable.serialize("com_order")
                        }
                    });
                }
            });
            Sortable.create("share_order", {
                onUpdate: function() {
                    new Ajax.Request("config.php", {
                        method: "post",
                        onSuccess: function(response) {
                            if (response.responseText !== "success") {
                                insertAlertMessage("error", "navigation-heading", "'.T_('An error occurred. Changes could not be saved.').'");
                            } else {
                                insertAlertMessage("success inline-alert", "navigation-heading", "'.T_('Changes Saved').'");
                            }
                        },
                        onFailure: function(response) {
                            insertAlertMessage("error", "navigation-heading", "'.T_('An error occurred. Changes could not be saved.').'");
                        },
                        parameters: { 
                            "submit-ajax-navigation": "1",
                            data: Sortable.serialize("share_order")
                        }
                    });
                }
            });
            </script>';

    displayFooter();
}

/**
 * displayNavigationFormSubmit 
 * 
 * Handles the submit form for both ajax and regular form.
 * 
 * @param boolean $ajax 
 * 
 * @return void
 */
function displayNavigationFormSubmit ($ajax = false)
{
    $communicateOrder = array();
    $shareOrder       = array();

    // Fix the data (Ajax)
    if (isset($_POST['data']))
    {
        parse_str($_POST['data']);

        if (isset($share_order))
        {
            $shareOrder = $share_order;
        }

        if (isset($com_order))
        {
            $communicateOrder = $com_order;
        }
    }
    // Fix the data (Form)
    else
    {
        // Communciate
        $i = 1;
        while (isset($_POST['com-order_'.$i]))
        {
            $arr   = explode(':', $_POST['com-order_'.$i]);
            $id    = $arr[0];
            $order = $arr[1];

            if (isset($communicateOrder[$order]))
            {
                displayHeader();

                echo '
                    <div class="alert-message block-message error">
                        <p><b>'.T_('Can\'t have two items with the same order.').'</b></p>
                        <div class="alert-actions">
                            <a class="btn" href="config.php?view=navigation">'.T_('Please try again').'</a>
                        </div>
                    </div>';

                displayFooter();
                return;
            }
            $communicateOrder[$order] = $id;

            $i++;
        }

        // Share
        $i = 1;
        while (isset($_POST['share-order_'.$i]))
        {
            $arr   = explode(':', $_POST['share-order_'.$i]);
            $id    = $arr[0];
            $order = $arr[1];

            if (isset($shareOrder[$order]))
            {
                displayHeader();
                echo '
                    <div class="alert-message block-message error">
                        <p><b>'.T_('Can\'t have two items with the same order.').'</b></p>
                        <div class="alert-actions">
                            <a class="btn" href="config.php?view=navigation">'.T_('Please try again').'</a>
                        </div>
                    </div>';
                displayFooter();
                return;
            }
            $shareOrder[$order] = $id;

            $i++;
        }
    }

    // Update the order of Share column
    foreach ($shareOrder as $order => $id)
    {
        $id    = (int)$id;
        $order = (int)$order;

        if ($ajax)
        {
            $order++;
        }

        $sql = "UPDATE `fcms_navigation` 
                SET `order` = '$order' 
                WHERE `id` = '$id'";
        if (!mysql_query($sql))
        {
            if ($ajax)
            {
                echo 'error';
                exit();
            }
            displayHeader();
            displaySqlError($sql, mysql_error());
            displayFooter();
            return;
        }
    }

    // Update the order of Communication column
    foreach ($communicateOrder as $order => $id)
    {
        $id    = (int)$id;
        $order = (int)$order;

        if ($ajax)
        {
            $order++;
        }

        $sql = "UPDATE `fcms_navigation` 
                SET `order` = '$order' 
                WHERE `id` = '$id'";
        if (!mysql_query($sql))
        {
            if ($ajax)
            {
                echo 'error';
                exit();
            }
            displayHeader();
            displaySqlError($sql, mysql_error());
            displayFooter();
            return;
        }
    }

    if ($ajax)
    {
        echo 'success';
        exit();
    }

    $_SESSION['success'] = 1;

    header("Location: config.php?view=navigation");
}

/**
 * displayPhotoGalleryForm 
 * 
 * @return void
 */
function displayPhotoGalleryForm ()
{
    displayHeader();

    $sql = "SELECT `name`, `value`
            FROM `fcms_config`";

    $result = mysql_query($sql);
    if (!$result)
    {
        displaySqlError($sql, mysql_error());
        displayFooter();
        return;
    }


    $row = array();
    while ($r = mysql_fetch_assoc($result))
    {
        $row[$r['name']] = $r['value'];
    }
    
    $full_size_list = array(
        "0" => T_('Off (2 photos)'),
        "1" => T_('On (3 photos)')
    );

    $full_size_options = buildHtmlSelectOptions($full_size_list, $row['full_size_photos']);

    if (defined('UPLOADS'))
    {
        $protected = '<span class="label success">'.T_('Protected').'</span>';
    }
    else
    {
        $protected  = '<span class="label warning">'.T_('Un-protected').'</span><br/><br/>';
        $protected .= '<p><b>'.T_('Your photos can be viewed from non-authorized users.').'</b></p>';
        $protected .= '<p>'.T_('In order to protect your photos so only logged in users can view them, please refer to the help document below.').'</p>';
        $protected .= '<p><a href="'.URL_PREFIX.'help.php?topic=admin#adm-protect-photos">'.T_('Help Me Protect My Photos').'</a></p>';
    }
    
    $message = '';

    if (isset($_SESSION['success']))
    {
        $message  = '<div class="alert-message success">';
        $message .= '<a class="close" href="#" onclick="$(this).up(\'div\').hide(); return false;">&times;</a>';
        $message .= T_('Changes Updated Successfully').'</div>';

        unset($_SESSION['success']);
    }

    echo '
        <form action="config.php?view=gallery" method="post">
        <fieldset>
            <legend>'.T_('Photo Gallery').'</legend>
            '.$message.'
            <div class="clearfix">
                <label for="full_size_photos">'.T_('Full Size Photos').'</label>
                <div class="input">
                    <select name="full_size_photos">
                        '.$full_size_options.'
                    </select><br/><br/>
                    <span class="help-block">
                        '.T_('By default, Full Sized Photos is turned off to save on storage space and bandwidth.  Turning this feature on can eat up significant space and bandwith.').'
                    </span>
                </div>
            </div>
            <div class="clearfix">
                <label for="protected">'.T_('Protected Photos').'</label>
                <div class="input">
                    '.$protected.'
                </div>
            </div>
            <div class="actions"><input type="submit" class="btn primary" id="submit-gallery" name="submit-gallery" value="'.T_('Save').'"/></div>
            </div>
        </fieldset>
        </form>';

    displayFooter();
}

/**
 * displayPhotoGalleryFormSubmit 
 * 
 * @return void
 */
function displayPhotoGalleryFormSubmit ()
{
    $sql = "UPDATE `fcms_config` 
            SET `value` = '".escape_string($_POST['full_size_photos'])."'
            WHERE `name` = 'full_size_photos'";
    if (!mysql_query($sql))
    {
        displayHeader();
        displaySqlError($sql, mysql_error());
        displayFooter();
        return;
    }

    $_SESSION['success'] = 1;

    header("Location: config.php?view=gallery");
}

/**
 * getOrderSelectBox 
 * 
 * @param int $name     The name of the select box (comm|share)
 * @param int $id       The order number of the spot we are talking about
 * @param int $total    The total number of options for the select box
 * @param int $selected Which order is currently selected
 * @param int $number   The number of select box on screen.
 * 
 * @return void
 */
function getOrderSelectBox ($name, $id, $total, $selected, $number)
{
    $order_options = '<select class="span1" name="'.$name.'-order_'.$number.'">';

    for ($i = 1; $i <= $total; $i++)
    {
        $order_options .= '<option value="'.$id.':'.$i.'"';

        if ($i == $selected)
        {
            $order_options .= ' selected="selected"';
        }

        $order_options .= '>'.$i.'</option>';
    }

    $order_options .= '</select>';

    return $order_options;
}
Back to Top