This repository has been archived by the owner on Dec 1, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
/
preferences.php
699 lines (610 loc) · 17.4 KB
/
preferences.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
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Preferences extends Admin_Controller
{
function __construct()
{
parent::__construct();
// preferences are settable only by admins!
$this->tank_auth->is_admin() or redirect('admin');
// set controller title
$this->viewdata['controller_title'] = '<a href="'.site_url("admin/preferences").'">' . _("Preferences") . '</a>';
}
/*
* Just redirects to general
*
* @author Woxxy
*/
function index()
{
redirect('/admin/preferences/general');
}
/*
* _submit is a private function that submits to the "preferences" table.
* entries that don't exist are created. the preferences table could get very large
* but it's not really an issue as long as the variables are kept all different.
*
* @author Woxxy
*/
function _submit($post, $form)
{
// Support Checkbox Listing
$former = array();
foreach ($form as $key => $item)
{
if (isset($item[1]['value']) && is_array($item[1]['value'])) {
foreach ($item[1]['value'] as $key => $item2) {
$former[] = array('1', $item2);
}
}
else
$former[] = $form[$key];
}
foreach ($former as $key => $item)
{
if (isset($post[$item[1]['name']]))
$value = $post[$item[1]['name']];
else
$value = NULL;
$this->db->from('preferences');
$this->db->where(array('name' => $item[1]['name']));
if ($this->db->count_all_results() == 1)
{
$this->db->update('preferences', array('value' => $value), array('name' => $item[1]['name']));
}
else
{
$this->db->insert('preferences', array('name' => $item[1]['name'], 'value' => $value));
}
}
$CI = & get_instance();
$array = $CI->db->get('preferences')->result_array();
$result = array();
foreach ($array as $item)
{
$result[$item['name']] = $item['value'];
}
$CI->fs_options = $result;
flash_notice('notice', _('Updated settings.'));
}
/*
* Generic info influcencing all of FoOlSlide
*
* @author Woxxy
*/
function general()
{
$this->viewdata["function_title"] = _("General");
$form = array();
// build the array for the form
$form[] = array(
_('Slide Title'),
array(
'type' => 'input',
'name' => 'fs_gen_site_title',
'id' => 'site_title',
'maxlength' => '200',
'placeholder' => _('FoOlSlide'),
'preferences' => 'fs_gen',
'help' => _('Sets the title of your FoOlSlide. This appears in the title of every page.')
)
);
$form[] = array(
_('Back URL'),
array(
'type' => 'input',
'name' => 'fs_gen_back_url',
'id' => 'back_url',
'maxlength' => '200',
'placeholder' => 'http://',
'preferences' => 'fs_gen',
'help' => _('A small URL linked to another page. This is located next to the title at the top of every page.')
)
);
$form[] = array(
_('Default Team'),
array(
'type' => 'input',
'name' => 'fs_gen_default_team',
'id' => 'default_team',
'maxlength' => '200',
'placeholder' => 'Anonymous',
'preferences' => 'fs_gen',
'help' => _('Sets the default team used for widgets and releases.')
)
);
$form[] = array(
_('Default release language'),
array(
'type' => 'language',
'name' => 'fs_gen_default_lang',
'preferences' => 'fs_gen',
'help' => _('Changes the default release language for all future releases.')
)
);
$form[] = array(
_('Default Software Language'),
array(
'type' => 'dropdowner',
'name' => 'fs_gen_lang',
'values' =>
array(
'' => 'English',
'ar_SA.utf8' => 'Arab',
'cs_CZ.utf8' => 'Czech',
'fr_FR.utf8' => 'French',
'de_DE.utf8' => 'German',
'hr_HR.utf8' => 'Croatian',
'it_IT.utf8' => 'Italian',
'id_ID.utf8' => 'Indonesian',
'ja_JP.utf8' => 'Japanese',
'hu_HU.utf8' => 'Hungarian',
'pl_PL.utf8' => 'Polish',
'pt_PT.utf8' => 'Portuguese',
'pt_BR.utf8' => 'Portuguese (Brazil)',
'ru_RU.utf8' => 'Russian',
'sl_SL.utf8' => 'Slovenian',
'es_ES.utf8' => 'Spanish',
'th_TH.utf8' => 'Thai',
'tr_TR.utf8' => 'Turkish'
),
'preferences' => 'fs_gen',
'help' => _('Changes the software language of FoOlSlide. Please contribute by translating this software on our <a href="https://www.transifex.net/projects/p/foolslide/resource/defaultpot/">Transifex project</a>.')
)
);
if ($post = $this->input->post())
{
$this->_submit($post, $form);
redirect('admin/preferences/general');
}
// create a form
$table = tabler($form, FALSE);
$data['form_title'] = _('General');
$data['table'] = $table;
// print out
$this->viewdata["main_content_view"] = $this->load->view("admin/preferences/general.php", $data, TRUE);
$this->load->view("admin/default.php", $this->viewdata);
}
/*
* Allows setting basic variables for theme.
* Does not yet allow adding more variables from current theme.
*
* @author Woxxy
*/
function theme()
{
$this->viewdata["function_title"] = _("Theme");
$form = array();
$form[] = array(
_('Select Theme'),
array(
'type' => 'themes',
'name' => 'fs_theme_dir',
'placeholder' => '',
'preferences' => 'fs_gen'
)
);
$form[] = array(
_('Pre-Header Text'),
array(
'type' => 'textarea',
'name' => 'fs_theme_preheader_text',
'placeholder' => '',
'preferences' => 'fs_gen',
'help' => _("This will insert HTML code above before the header navigation block.")
)
);
$form[] = array(
_('Header Text'),
array(
'type' => 'textarea',
'name' => 'fs_theme_header_text',
'placeholder' => '',
'preferences' => 'fs_gen',
'help' => _("Inserts the text above in the header where the nagivation linkes are located.")
)
);
$form[] = array(
_('Header Code'),
array(
'type' => 'textarea',
'name' => 'fs_theme_header_code',
'placeholder' => '',
'preferences' => 'fs_gen',
'help' => _("This will insert the HTML code above inside the <HEAD>.")
)
);
$form[] = array(
_('Footer Text'),
array(
'type' => 'textarea',
'name' => 'fs_gen_footer_text',
'placeholder' => '',
'preferences' => 'fs_gen',
'help' => _('Inserts the text above in the footer such as disclaimers. (Note: If the content uploaded does not belong to you, do not write things like "All Rights Reserived©" above. However, if you\'re releasing your own works, please consider using <a href="http://creativecommons.org/">Creative Commons Licenses</a> to protect them.)')
)
);
$form[] = array(
_('Footer Code'),
array(
'type' => 'textarea',
'name' => 'fs_theme_footer_code',
'placeholder' => '',
'preferences' => 'fs_gen',
'help' => _("This will insert the HTML code above after the <BODY>.")
)
);
if ($post = $this->input->post())
{
$this->_submit($post, $form);
redirect('admin/preferences/theme');
}
// create the form
$table = tabler($form, FALSE);
$data['form_title'] = _('Theme');
$data['table'] = $table;
// print out
$this->viewdata["main_content_view"] = $this->load->view("admin/preferences/general.php", $data, TRUE);
$this->load->view("admin/default.php", $this->viewdata);
}
/*
* Code boxes to add the ads' code, supporting top and bottom ads
*
* @author Woxxy
*/
function advertising()
{
$this->viewdata["function_title"] = _("Advertising");
$form = array();
$form[] = array(
_('Top banner'),
array(
'type' => 'textarea',
'name' => 'fs_ads_top_banner',
'help' => _('Insert the HTML code provided by your advertiser above.'),
'preferences' => 'fs_ads'
)
);
$form[] = array(
_('Top Banner Options'),
array(
'type' => 'checkbox',
'name' => 'fs_ads_top_options',
'value' => array(
array(
'type' => 'checkbox',
'name' => 'fs_ads_top_banner_active',
'placeholder' => '',
'preferences' => 'fs_ads',
'text' => _('Enable')
),
array(
'name' => 'fs_ads_top_banner_reload',
'placeholder' => '',
'preferences' => 'fs_ads',
'text' => _('Reload on Every Pageview')
)
),
'help' => _('')
)
);
$form[] = array(
_('Bottom banner'),
array(
'type' => 'textarea',
'name' => 'fs_ads_bottom_banner',
'help' => _('Insert the HTML code provided by your advertiser above.'),
'preferences' => 'fs_ads'
)
);
$form[] = array(
_('Bottom Banner Options'),
array(
'type' => 'checkbox',
'name' => 'fs_ads_bottom_options',
'value' => array(
array(
'type' => 'checkbox',
'name' => 'fs_ads_bottom_banner_active',
'placeholder' => '',
'preferences' => 'fs_ads',
'text' => _('Enable')
),
array(
'name' => 'fs_ads_bottom_banner_reload',
'placeholder' => '',
'preferences' => 'fs_ads',
'text' => _('Reload on Every Pageview')
)
),
'help' => _('')
)
);
if ($post = $this->input->post())
{
$this->_submit($post, $form);
// this code is necessary to keep the ad well centered inside iframes
$ad_before = '<!DOCTYPE html>
<html>
<head>
<title>FoOlSlide ads</title>
<style>body{margin:0; padding:0; overflow:hidden;}</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>';
$ad_after = '</body>
</html>';
// available ads
$ads = array('fs_ads_top_banner' => 'ads_top.html', 'fs_ads_bottom_banner' => 'ads_bottom.html');
// write an HTML file, so calling it will use less processor power than calling the database via Codeigniter
// this recreates the files every time one saves
foreach ($ads as $ad => $adfile)
{
if (!write_file('./content/ads/' . $adfile, $ad_before . $this->input->post($ad) . $ad_after))
{
log_message('error', 'preferences.php/advertising: couldn\'t update HTML files');
flash_notice('error', _('Couldn\'t save the advertising code in the HTML'));
}
}
redirect('admin/preferences/advertising');
}
// create the form
$table = tabler($form, FALSE);
$data['form_title'] = _('Advertising');
$data['table'] = $table;
// print out
$this->viewdata["main_content_view"] = $this->load->view("admin/preferences/general.php", $data, TRUE);
$this->load->view("admin/default.php", $this->viewdata);
}
function registration()
{
$this->viewdata["function_title"] = _("Registration");
$form = array();
$form[] = array(
_('Settings'),
array(
'type' => 'checkbox',
'name' => 'fs_reg_options',
'value' => array(
array(
'name' => 'fs_reg_disabled',
'id' => 'disable_reg',
'preferences' => 'fs_reg',
'text' => _('Disable New User Registrations')
),
array(
'name' => 'fs_reg_email_disabled',
'id' => 'disable_reg',
'preferences' => 'fs_reg',
'text' => _('Disable Email Activation')
)
),
'help' => _('Modify the settings for the registration system.')
)
);
$form[] = array(
_('reCaptcha™ Public Key'),
array(
'type' => 'input',
'name' => 'fs_reg_recaptcha_public',
'id' => 'captcha_public',
'maxlength' => '200',
'preferences' => 'fs_reg',
'help' => _('Insert the public key provided by reCAPTCHA™.')
)
);
$form[] = array(
_('reCaptcha™ Secret Key'),
array(
'type' => 'input',
'name' => 'fs_reg_recaptcha_secret',
'preferences' => 'fs_reg',
'help' => _('Insert the private key provided by reCAPTCHA™.')
)
);
if ($post = $this->input->post())
{
$this->_submit($post, $form);
redirect('admin/preferences/registration');
}
// prepare form
$table = tabler($form, FALSE);
$data['form_title'] = _('Registration');
$data['form_description'] = _('In order to use reCAPTCHA™ you need to sign up for the service at <a href="http://www.google.com/recaptcha">reCAPTCHA™</a>, which will provide you with a public and a private key.');
$data['table'] = $table;
// print out
$this->viewdata["main_content_view"] = $this->load->view("admin/preferences/general.php", $data, TRUE);
$this->load->view("admin/default.php", $this->viewdata);
}
/*
* Reader configuration
*
* @author Woxxy
*/
function reader()
{
$this->viewdata["function_title"] = _("Reading");
$form = array();
$form[] = array(
_('Settings'),
array(
'type' => 'checkbox',
'name' => 'fs_dl_options',
'value' => array(
array(
'name' => 'fs_dl_enabled',
'preferences' => 'fs_dl',
'text' => _('Enable Direct Downloads')
),
array(
'name' => 'fs_dl_volume_enabled',
'preferences' => 'fs_dl',
'text' => _('Enable Volume Downloads'),
)
),
'help' => _('Note: Direct downloads usually increase bandwidth usage by one-third. The issue is whether you have enough space to keep both images and ZIP archives. FoOlSlide tries to avoid this problem by using on-the-fly ZIP compression and caching.')
)
);
$form[] = array(
_('Maximum Direct Download Cache in Megabyte'),
array(
'type' => 'input',
'name' => 'fs_dl_archive_max',
'id' => 'max_dl',
'preferences' => 'fs_dl',
'help' => _('Once this limit has been reached, ZIP archives that have not been downloaded recently will be removed. If a very large number is set, the ZIP archives will be cached indefinitely.')
)
);
if ($post = $this->input->post())
{
$this->_submit($post, $form);
redirect('admin/preferences/reader');
}
// create form
$table = tabler($form, FALSE);
$data['form_title'] = _('Reading');
$data['table'] = $table;
// print out
$this->viewdata["main_content_view"] = $this->load->view("admin/preferences/general.php", $data, TRUE);
$this->load->view("admin/default.php", $this->viewdata);
}
/*
* Generic info influcencing all of FoOlSlide
*
* @author Woxxy
*/
function slideshow()
{
$this->viewdata["function_title"] = _("Slideshow");
$form = array();
// build the array for the form
$form[] = array(
_('1st Image URL'),
array(
'type' => 'input',
'name' => 'fs_slsh_src_1',
'placeholder' => _('Activate by inserting an URL'),
'preferences' => 'fs_gen',
'help' => _('Image URL (don\'t forget "http://"). Suggested size: 690px width, 280px height')
)
);
$form[] = array(
_('1st URL'),
array(
'type' => 'input',
'name' => 'fs_slsh_url_1',
'placeholder' => _('Not required'),
'preferences' => 'fs_gen',
'help' => _('Link URL (don\'t forget "http://")')
)
);
$form[] = array(
_('1st Display text'),
array(
'type' => 'textarea',
'name' => 'fs_slsh_text_1',
'preferences' => 'fs_gen',
'help' => _('Text that appears on bottom of the image. HTML accepted')
)
);
$form[] = array(
_('2nd Image URL'),
array(
'type' => 'input',
'name' => 'fs_slsh_src_2',
'placeholder' => _('Activate by inserting an URL'),
'preferences' => 'fs_gen',
'help' => _('Image URL (don\'t forget "http://"). Suggested size: 690px width, 280px height')
)
);
$form[] = array(
_('2nd URL'),
array(
'type' => 'input',
'name' => 'fs_slsh_url_2',
'placeholder' => _('Not required'),
'preferences' => 'fs_gen',
'help' => _('Link URL (don\'t forget "http://")')
)
);
$form[] = array(
_('2nd Display text'),
array(
'type' => 'textarea',
'name' => 'fs_slsh_text_2',
'preferences' => 'fs_gen',
'help' => _('Text that appears on bottom of the image. HTML accepted')
)
);
$form[] = array(
_('3rd Image URL'),
array(
'type' => 'input',
'name' => 'fs_slsh_src_3',
'placeholder' => _('Activate by inserting an URL'),
'preferences' => 'fs_gen',
'help' => _('Image URL (don\'t forget "http://"). Suggested size: 690px width, 280px height')
)
);
$form[] = array(
_('3rd URL'),
array(
'type' => 'input',
'name' => 'fs_slsh_url_3',
'placeholder' => _('Not required'),
'preferences' => 'fs_gen',
'help' => _('Link URL (don\'t forget "http://")')
)
);
$form[] = array(
_('3rd Display text'),
array(
'type' => 'textarea',
'name' => 'fs_slsh_text_3',
'preferences' => 'fs_gen',
'help' => _('Text that appears on bottom of the image. HTML accepted')
)
);
$form[] = array(
_('4th Image URL'),
array(
'type' => 'input',
'name' => 'fs_slsh_src_4',
'placeholder' => _('Activate by inserting an URL'),
'preferences' => 'fs_gen',
'help' => _('Image URL (don\'t forget "http://"). Suggested size: 690px width, 280px height')
)
);
$form[] = array(
_('4th URL'),
array(
'type' => 'input',
'name' => 'fs_slsh_url_4',
'placeholder' => _('Not required'),
'preferences' => 'fs_gen',
'help' => _('Link URL (don\'t forget "http://")')
)
);
$form[] = array(
_('4th Display text'),
array(
'type' => 'textarea',
'name' => 'fs_slsh_text_4',
'preferences' => 'fs_gen',
'help' => _('Text that appears on bottom of the image. HTML accepted')
)
);
if ($post = $this->input->post())
{
$this->_submit($post, $form);
redirect('admin/preferences/slideshow');
}
// create a form
$table = tabler($form, FALSE);
$data['table'] = $table;
// print out
$this->viewdata["main_content_view"] = $this->load->view("admin/preferences/general.php", $data, TRUE);
$this->load->view("admin/default.php", $this->viewdata);
}
}