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
|
<?php
/** Custom Application Constants
* -----------------------------------------------------------------------------
*
* Constants defined for your current application:
*
* 1. Main constants (Names, Labels, securoty defaults, etc)
*
* 2. Credentials and sub-configuration of main services
*
* 3. Other custom constants
*
* -----------------------------------------------------------------------------
*/
/** Preload environmental file
* Setting up main constants via en envoronment file is HIGHLY RECOMMENDED;
*
* read ini file if exist
*/
if (file_exists("../core/auth/.env")) {
$env = parse_ini_file("../core/auth/.env");
}
## -----------------------------------------------------------------------------
##
## - - - -- -- --- M A I N C O N S T A N T S --- -- -- - - -
## Main constants (names, labels, default roles, security defaults, etc
##
## -----------------------------------------------------------------------------
/** Main default constants / strings / names / etc
* -----------------------------------------------------------------------------
*/
define('SITE_TITLE', 'schoolGov'); // Site Title (the end-users' title)
/** Autoload paths
* -----------------------------------------------------------------------------
*
* CLASSPATHS : array of paths where classes are saved
*
* NOTE:
* if the custom autoloader is used (instead of composer's)
* then you need to defing CLASSPATHS constant-array too;
*
* In most cases you won't need this,
* so comment the next lines out of the code-base
*
* -----------------------------------------------------------------------------
*/
# define('CLASSPATHS', array(
# '/../core/classes/', // core classes
# '/app/controllers/', // controller classes
# '/app/models/', // model classes
# '/app/extends/', // extending core classes
# '/../vendor/' // vendor/dependency classes
# )
# );
/** FileSession Path
* --- -- -- - - -
* if FileSession is selected, a path for session-files is needed
*
* TODO:
* also, the hybrid sessioning (in progress) will need this setting
*
* NOTE:
* DefaultSession is also file-based but to not need a file-path setting
* (php will handle any file-needed actions to the file-system)
*/
# define('FILESESSION_PATH', '../storage/session');
/** Session and cookie names
* --- -- -- - - -
*/
define('SESSION_NAME', 'offticket'); // cookie for session (office ticket)
define('CONNECTION_COOKIE', 'con'); // cookie for connection
define('MAX_SESSION_LIFE', 2*60*60); // maximum session lifetime (2 hours)
/** SECURITY SETTINGS ///////////////////////////////////////////////////////////
* -----------------------------------------------------------------------------
*
* Cross Site Request Forgery
* ---
* Enables a CSRF cookie token to be set. When set to TRUE, token will be
* checked on a submitted form. If you are accepting user data, it is strongly
* recommended CSRF protection be enabled.
* -----------------------------------------------------------------------------
*/
define('CSRF_PROTECTION', false);
define('CSRF_TOKEN_NAME', 'csrf_test_name'); // token name
define('CSRF_COOKIE_NAME', 'csrf_cookie_name'); // cookie name
define('CSRF_EXPIRE', 7200); // The number in seconds the token should expire.
define('CSRF_REGENERATE', TRUE); // Regenerate token on every submission
define('CSRF_EXCLUDE_URIS', array()); // Array of URIs which ignore CSRF checks
## -----------------------------------------------------------------------------
##
## - - - -- -- --- C O N N E C T I O N C R E D E N T I A L S --- -- -- - - -
##
## -----------------------------------------------------------------------------
/** SERVICE PARAMETRES
* -----------------------------------------------------------------------------
*
* Connection parametres and credentials for accssing services
* needed by the application; Such services may be..
*
* - RDBMS
* -- MySQL
* -- PotgresSQL
*
* - Caching services
* -- Redis
* -- MemCached
*
* Edit only the constants needed by the application;
* Comment those you do not need;
*
* /////////////////////////////////////////////////////////////////////////////
*/
/** DATABASE CONNECTION PARAMETRES
* -----------------------------------------------------------------------------
* Production and staging environments may use different databases.
*
* A safe practice is to keep credentials outside plain files like this one
* in environmental variable or other secret file etc.
*
* Uncomment/enable each group of definitions suits your case to define
* the credentials needed for accessing the database
*/
define('DB_NAME', $ini['DB_NAME']);
define('DB_USER', $ini['DB_USER']);
define('DB_PASS', $ini['DB_PASS']);
/** NOTE:
* PDO_HOST can be a hostname/port combination -or- a unix socket
*
* ...examples:
* define('PDO_HOST', 'host=/localhost') ## hostname case
* define('PDO_HOST', 'host=/localhost;port=3456') ## hostname/port case
* define('PDO_HOST', 'unix_socket=/sql/ex123:europe:some-db'); ## unix socket
* define('PDO_HOST', 'unix_socket=/cloudsql/name-123456:europe-west4:name-db-eu');
*/
define('PDO_HOST', $ini['PDO_HOST']);
define('DB_TIMEZONE', "SET time_zone = 'Europe/Athens'");
/** CACHED SERVICES
*
* impemented services:
*
* - File Cache
* - Redis
* - Memcached
*
* NOTE:
* Both Redis and Memcached configurations are given as a template to work on;
* In most cases the default values should do the job -- of course you need to
* read the README file (check the project's root);
* As these caching services are not fully tested you may need to ochestrate
* the services in detail or edit the connection strings into the core classes
* (hosted under the '/core/classes/cacher' folder)
*/
define('FILECACHE_PATH', APP_ROOT.'/../storage/cache/'); // if CACHE_DRIVER is set to 'FileCache'
define('MEDIA_STORAGE_ROOT', APP_ROOT.'/../storage/uploads/'); // Media files root directory
# define('MEMCAHCED_SERVER', '127.0.0.1'); // if CACHE_DRIVER is set to 'MemCached'
/** REDIS SERVICE
* -----------------------------------------------------------------------------
* Most of the times Redis is running on 'localhost' (host = '127.0.0.1')
* When implemented via anom's docker-composer (redis via bridge) then you need
* do declare the hostname as 'redis'
*/
# define('REDIS_HOST', '127.0.0.1'); // if CACHE_DRIVER is set to 'RedisCache'
# if (!defined('REDIS_HOST')) define('REDIS_HOST', 'redis');
#
# if (!defined('REDIS_PORT')) define('REDIS_PORT', 6379);
#
# if (!defined('REDIS_PASS')) define('REDIS_PASS', null);
/** MEMCACHED
* -----------------------------------------------------------------------------
* Memcached looks very much like Redis (plus, both are serving from RAM)
* Usualy Memcashed is running localy so host is 'localhost' ('127.0.0.1')
* If you use the framework's docker-composer implementation then
* the hostname is 'anomemcached'
*/
# if (!defined('MEMCACHE_HOST')) define('MEMCACHE_HOST', 'anomemcached');
/** email setup
* --- -- -- - - -
*/
// SMTP
define('MAIL_MAILER', $env['MAIL_MAILER']);
define('MAIL_HOST', $env['MAIL_HOST']);
define('MAIL_PORT', $env['MAIL_PORT']);
define('MAIL_USERNAME', $env['MAIL_USERNAME']);
define('MAIL_PASSWORD', $env['MAIL_PASSWORD']);
define('MAIL_ENCRYPTION', $env['MAIL_ENCRYPTION']);
// Mailjet
define('MAILJET_APIKEY', $env['MAILJET_APIKEY']); // apikey
define('MAILJET_SECRET', $env['MAILJET_SECRET']); // secret
define('MAILJET_TICKET', $env['MAILJET_TICKET']); // apikey:secret
// sender info
define('MAIL_FROM_NAME', $env['MAIL_FROM_NAME']);
define('NO_REPLY_EMAIL', $env['NO_REPLY_EMAIL']);
define('REPLY_TO_EMAIL', $env['REPLY_TO_EMAIL']);
// default mail service; options so far: [ mailjet | phpmailer ]
define('DEFAULT_MAIL_SERVICE', 'mailjet');
// DEFAULT VALUES //////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// default privileges (for the subscribed user)
// (array of privilege aliases)
// --- -- -- - - -
define('DEFAULT_PRIVILEGES', [
1, // economics, level 1
5 // programming. level 1
]);
// User Roles
// --- -- -- - - -
define('Admin', 1);
define('Secretary', 2);
define('Teacher', 3);
// ACCESS HISTORY //////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// (user-)access types
define('TRACK_LOGIN', 1); // login / logout
define('TRACK_ACCOUNT', 2); // create user / activate account / modidy profile
define('TRACK_REQUESTS', 4); // order / payment / refund etc...
// access type strings
// ---
define('USER_ACCESS_TYPE', [
1 => 'Login',
2 => 'Account',
3 => 'Request'
]);
// ERRORS AND ERROR MESSAGES ///////////////////////////////////////////////////
// -----------------------------------------------------------------------------
define('EMPTY_REQUIRED_FIELDS', 'Δεν έχουν συμπληρωθεί όλα τα υποχρεωτικά πεδία');
// ASSETS: PATHS USED HEAVILY //////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// these paths are used in order to easily find and autoload useful elemets
// JAVASCRIPT LIBRARY PATHS
// -----------------------------------------------------------------------------
define('JS_DIR', '/content/'); // <base> path to contruct link
// CSS ASSET PATHS
// -----------------------------------------------------------------------------
define('CSS_DIR', '/content/css/'); // <base> path to contruct link
define('CSS_FILES', array( // path after <base> to the actual file
'main' => 'main.min.css',
'filter' => 'filter.css',
'overides' => 'overides.css',
)
);
// Mesagges ////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// 404
// ---
define('PAGE_404_TITLE', '404: Not Found');
// registration
// ---
define('REGISTRATION_SUCCESS', "<h3>Επιτυχής Εγγραφή</h3>
<p>
Παρακαλώ ελέγξτε το email σας και ακολουθήστε το σύνδεσμο ενεργοποίησης
που σας 'εχει αποσταλεί, ώστε να έχετε πρόσβαση σε επιπλέον περιεχόμενο του site
</p>"
);
define ('REGISTRATION_USER_EXISTS', "<h3>Αποτυχία Εγγραφής</h3>
<p>
Υπάρχει ήδη χρήστης με αυτό το email. Αν δεν θυμάστε το password
μπορείτε να κάνετε επαναφορά του ακολουθώντας
<a href='/reset-password'>αυτό το σύνδεσμο</a>.
</p>"
);
// activation
// ---
define('ACCOUNT_ACTIVATED_TITLE', 'Ο λογαριασμός σας έχει ενεργοποιηθεί');
define('ACCOUNT_ACTIVATED_MESSAGE', 'Τώρα μπορείτε να
<a href="/login">συνδεθείτε στο σύστημα</a>.');
define('NOT_VALID_ACTIVATION_TITLE', 'Σφάλμα!');
define('NOT_VALID_ACTIVATION_MESSAGE', 'Ο λογαριασμός δεν έχει ενεργοποιηθεί.
Ξαναδοκιμάστε αργότερα κι αν το σφάλμα επιμείνει, επικοινωνήστε με την υπεύθυνη του προγράμμαρος.');
define ('PETITION_TYPE', [
1 => 'common',
2 => 'penalty'
]);
// forms
// --- -- -- - - -
// registration/activation form (from invitation)
// ---
define('REGISTRATION_FORM', [
'defaults' => [
'outer_class' => 'col-12',
'inner_class' => 'form-control',
'type' => 'text',
'source' => '\app\controllers\User::current'
],
'form' => [
[
'name' => 'first_name',
'label' => 'Όνομα',
'value' => 'auto',
'attributes' => ['required']
],
[
'name' => 'last_name',
'label' => 'Επίθετο',
'value' => 'auto',
'attributes' => ['required']
],
[
'name' => 'email',
'label' => 'Email',
'type' => 'email',
'value' => 'auto',
'attributes' => ['required']
],
[
'name' => 'father_name',
'label' => 'Πατρώνυμο',
'value' => 'auto',
'attributes' => ['required']
],
[
'name' => 'registration_number',
'label' => 'Αριθμός μητρώου',
'class' => 'col-8',
'value' => 'auto',
'attributes' => ['required']
],
[
'name' => 'sector',
'label' => 'Κλάδος / Ειδικότητα',
'value' => 'auto',
'type' => 'select',
'attributes' => ['required'],
'options' => [
'ΠΕ01 ΘΕΟΛΟΓΟΙ',
'ΠΕ02 ΦΙΛΟΛΟΓΟΙ',
'ΠΕ02.50 ΦΙΛΟΛΟΓΟΙ ΕΙΔΙΚΗΣ ΑΓΩΓΗΣ',
'ΠΕ03 ΜΑΘΗΜΑΤΙΚΟΙ',
'ΠΕ03.50 ΜΑΘΗΜΑΤΙΚΟΙ ΕΙΔΙΚΗΣ ΑΓΩΓΗΣ',
'ΠΕ04.01 ΦΥΣΙΚΟΙ',
'ΠΕ04.01.50 ΦΥΣΙΚΟΙ ΕΙΔΙΚΗΣ ΑΓΩΓΗΣ',
'ΠΕ04.02 ΧΗΜΙΚΟΙ',
'ΠΕ04.04 ΒΙΟΛΟΓΟΙ',
'ΠΕ05 ΓΑΛΛΙΚΗΣ ΦΙΛΟΛΟΓΙΑΣ',
'ΠΕ06 ΑΓΓΛΙΚΗΣ ΦΙΛΟΛΟΓΙΑΣ',
'ΠΕ07 ΓΕΡΜΑΝΙΚΗΣ ΦΙΛΟΛΟΓΙΑΣ',
'ΠΕ08 ΚΑΛΛΙΤΕΧΝΙΚΩΝ',
'ΠΕ11 ΦΥΣΙΚΗΣ ΑΓΩΓΗΣ',
'ΠΕ23-ΣΔΕΥ ΨΥΧΟΛΟΓΟΙ',
'ΠΕ30-ΣΔΕΥ ΚΟΙΝΩΝΙΚΟΙ ΛΕΙΤΟΥΡΓΟΙ',
'ΠΕ78 ΚΟΙΝΩΝΙΚΩΝ ΕΠΙΣΤΗΜΩΝ',
'ΠΕ79.01 ΜΟΥΣΙΚΗΣ ΕΠΙΣΤΗΜΗΣ',
'ΠΕ80 ΟΙΚΟΝΟΜΙΑΣ',
'ΠΕ81 ΠΟΛ.ΜΗΧΑΝΙΚΩΝ-ΑΡΧΙΤΕΚΤΟΝΩΝ',
'ΠΕ82 ΜΗΧΑΝΟΛΟΓΩΝ',
'ΠΕ86 ΠΛΗΡΟΦΟΡΙΚΗΣ',
'ΠΕ88.01 ΓΕΩΠΟΝΟΙ'
]
],
[
'name' => 'belonging_school',
'label' => 'Σχολείο τοποθέτησης',
'value' => 'auto',
'attributes' => ['required']
],
// [ // working school = (obviously) is the current school
// 'name' => 'working_school',
// 'label' => 'Σχολείο εργασίας',
// 'attributes' => ['required']
// ],
[
'name' => 'position',
'label' => 'Θέση',
'type' => 'select',
'value' => 'auto',
'attributes' => ['required'],
'options' => []
],
[
'name' => 'phone',
'label' => 'Τηλέφωνο',
'class' => 'col-8',
'value' => 'auto',
'attributes' => ['required']
],
[
'name' => 'password',
'label' => 'Κωδικός πρόσβασης',
'type' => 'password',
'class' => 'col-8',
'attributes' => ['required']
],
[
'name' => 'confirm_password',
'label' => 'Επαλήθευση κωδικού πρόσβασης',
'type' => 'password',
'class' => 'col-8',
'attributes' => ['required']
]
]
]);
// common requesy form (for any application)
// ---
define('COMMON_REQUEST_FORM', [
'defaults' => [
'outer_class' => 'col-12',
'inner_class' => 'form-control',
'type' => 'text',
'source' => '\app\controllers\User::current'
],
'form' => [
[
'name' => 'subject',
'label' => 'Θέμα (χαρακτηριστικός τίτλος για αναφορά)',
'attributes' => ['required']
],
[
'name' => 'first_name',
'label' => 'Όνομα',
'attributes' => ['auto']
],
[
'name' => 'last_name',
'label' => 'Επίθετο',
'attributes' => ['auto']
],
[
'name' => 'email',
'label' => 'e-mail',
'type' => 'email',
'attributes' => ['auto']
],
[
'name' => 'father_name',
'label' => 'Πατρώνυμο',
'attributes' => ['auto']
],
[
'name' => 'registration_number',
'label' => 'Αριθμός μητρώου',
'class' => 'col-5',
'attributes' => ['auto']
],
[
'name' => 'sector',
'label' => 'Κλάδος / Ειδικότητα',
'attributes' => ['auto']
],
[
'name' => 'belonging_school',
'label' => 'Σχολείο τοποθέτησης',
'attributes' => ['required']
],
[
'name' => 'working_school',
'label' => 'Σχολείο εργασίας',
'attributes' => ['required']
],
[
'name' => 'position',
'label' => 'Θέση',
'type' => 'select',
'source' => 'positions',
'attributes' => ['required']
],
[
'name' => 'phone',
'label' => 'Τηλέφωνο',
'attributes' => ['required']
],
[
'name' => 'request',
'label' => 'Αίτημα (πχ, Παρακαλώ να μου χορηγήσετε ...)',
'type' => 'textarea',
'attributes' => ['required']
],
[
'name' => 'date',
'label' => 'Ημερομηνία αίτησης',
'type' => 'date',
'attributes' => ['required']
]
]
]);
// penalty form
// ---
define('PENALTY_FORM', [
'defaults' => [
'outer_class' => 'col-12',
'inner_class' => 'form-control',
'type' => 'text',
'source' => 'user'
],
'form' => [
[
'name' => 'subject',
'label' => 'Θέμα (χαρακτηριστικός τίτλος για αναφορά)',
'attributes' => ['required']
],
[
'label' => '',
'type' => 'label'
],
[
'label' => 'Πειθαρχική υπόθεση',
'type' => 'label'
],
[
'name' => 'of_article',
'label' => 'του/της/των...',
'type' => 'select',
'options' => [
'του μαθητή',
'της μαθήτριας',
'των μαθητών',
'των μαθητριών'
],
'class' => 'col-md-4',
'attributes' => ['required']
],
[
'name' => 'student_names',
'label' => '(ονοματεπώνυ-μο/μα, πτώση γενική)',
'type' => 'textarea',
'class' => 'col-md-8',
'attributes' => ['required']
],
[
'name' => 'of_department',
'label' => 'του τμήματος...',
'class' => 'col-md-4',
'attributes' => ['required']
],
[
'name' => 'date',
'label' => 'Ημερομηνία',
'type' => 'date',
'class' => 'col-md-4',
'attributes' => ['required']
],
[
'name' => 'time',
'label' => 'Ώρα',
'class' => 'col-md-4',
'attributes' => ['required']
],
[
'name' => 'place',
'label' => 'Τόπος',
'type' => 'select',
'options' => [
'Γραφείο Διευθηντή',
'Γραφείο Καθηγητών'
],
'attributes' => ['required']
],
[
'name' => 'rapporteur',
'label' => 'εισηγητής',
'type' => 'select',
'source' => '\app\extends\Cache_service::all_users',
'attributes' => ['required']
],
[
'name' => 'charge',
'label' => 'Περιγραφή συμβάντος:',
'type' => 'textarea',
'attributes' => ['required']
],
[
'name' => 'apology',
'label' => 'Απολογία: (μαθητή/-των)', // + of_student
'type' => 'textarea',
'attributes' => []
],
[
'name' => 'decision_reasoning',
'label' => 'Αιτιολογία απόφασης (πχ. Επειδή...)',
'type' => 'textarea',
'attributes' => []
],
[
'label' => 'Το Πειθαρχικό Συμβούλιο',
'type' => 'label'
],
[
'name' => 'decision',
'label' => 'Αποφασίζει',
'type' => 'select',
'options' => [
'προφορική επίπληξη',
'ωριαία αποβολή',
'ημερήσια αποβολή'
],
'attributes' => []
],
[
'name' => 'decision_more',
'label' => '(μη τυποποιημένο κείμενο απόφασης)',
'attributes' => []
],
[
'name' => 'president',
'label' => 'Πρόεδρος συνεδρίασης',
'type' => 'select',
'source' => '\app\extends\Cache_service::all_users',
'attributes' => ['required']
],
[
'name' => 'members',
'label' => 'Μέλη',
'type' => 'select',
'attributes' => ['required', 'multiple'],
'source' => '\app\extends\Cache_service::all_users'
]
]
]);
|