File tree 6 files changed +157
-0
lines changed
6 files changed +157
-0
lines changed Original file line number Diff line number Diff line change 7
7
key.js
8
8
__DB.sql
9
9
\! _mysql * .bat
10
+ /* .csv
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Encodes numbers to string and back.
4
+ *
5
+ * Strings are constructed from basic ANSI letters and numbers that should be readable
6
+ * and should not be familiar with each other (e.g. both "I" and "l" will not be used).
7
+ *
8
+ * Test:
9
+ * $encoder = new NumericEncoder();
10
+ * echo "\n".$encoder->encode(32);
11
+ * echo "\n".$encoder->decode($encoder->encode(32));
12
+ *
13
+ * @author Maciej Nux Jaros
14
+ */
15
+ class NumericEncoder
16
+ {
17
+ //private $str = '0123456789abcdef'; // hex
18
+ private $ str = 'wehk7rt8xc3vbn4myupad9 ' ;
19
+ private $ strlen = 0 ;
20
+
21
+ public function __construct ()
22
+ {
23
+ $ this ->strlen = strlen ($ this ->str );
24
+ }
25
+
26
+ public function encode ($ number )
27
+ {
28
+ $ strlen = $ this ->strlen ;
29
+ $ strnum = '' ;
30
+ do
31
+ {
32
+ $ remainder = $ number % $ strlen ;
33
+ $ strnum .= $ this ->str [$ remainder ];
34
+ $ number = ($ number - $ remainder ) / $ strlen ;
35
+ }
36
+ while ($ number > 0 );
37
+ return $ strnum ;
38
+ }
39
+ public function decode ($ text )
40
+ {
41
+ $ strlen = $ this ->strlen ;
42
+ $ number = 0 ;
43
+ for ($ i =strlen ($ text )-1 ; $ i >= 0 ; $ i --)
44
+ {
45
+ $ index = strpos ($ this ->str , $ text [$ i ]);
46
+ $ number = ($ number + $ index ) * $ strlen ;
47
+ }
48
+ return $ number / $ strlen ;
49
+ }
50
+ }
Original file line number Diff line number Diff line change
1
+ <?
2
+ /* @var $pv_menuItem MenuItem */
3
+ $ pv_menuItem ->title = 'Eksport danych ' ;
4
+ $ pv_menuItem ->order = 3 ;
5
+ $ pv_menuItem ->users = AUTH_GROUP_OPS ;
6
+
7
+ $ pv_menuItem ->addSubItem ('invitations ' ,'Zaproszenia ' );
8
+ $ pv_menuItem ->addSubItem ('survey ' ,'Ankiety ' );
9
+ ?>
Original file line number Diff line number Diff line change
1
+ <?
2
+ if ( !defined ('NOT_HACKING_RILI ' ) )
3
+ {
4
+ die ("No hacking allowded ;). " );
5
+ }
6
+
7
+ require_once ('./inc/numericEncoder.php ' );
8
+ require_once ('./inc/db/personal.php ' );
9
+ $ dbPersonal = new dbPersonal ();
10
+
11
+ $ tplData = array ();
12
+ $ tplData ['file ' ] = 'invites.csv ' ;
13
+
14
+ // get
15
+ $ dbPersonal ->pf_getRecords ($ rows , array (
16
+ 'profile_id ' => array ('IS NOT ' , 'NULL ' ),
17
+ 'draw_id ' => array ('IS NOT ' , 'NULL ' ),
18
+ 'row_state ' => 0 ,
19
+ ), array (
20
+ 'id ' ,
21
+ 'pesel ' ,
22
+ 'name ' ,
23
+ 'surname ' ,
24
+ 'city ' ,
25
+ 'street ' ,
26
+ 'building_no ' ,
27
+ 'flat_no ' ,
28
+ 'zip_code ' ,
29
+ ));
30
+
31
+ //
32
+ // create file
33
+ $ fp = fopen ($ tplData ['file ' ], 'w ' );
34
+ // header
35
+ fputcsv ($ fp , array (
36
+ 'kod ' ,
37
+ 'pesel ' ,
38
+ 'imię ' ,
39
+ 'naziwsko ' ,
40
+ 'miasto ' ,
41
+ 'ulica ' ,
42
+ 'nr budynku ' ,
43
+ 'nr lokalu ' ,
44
+ 'kod pocztowy ' ,
45
+ ));
46
+ // rows
47
+ $ encoder = new NumericEncoder ();
48
+ foreach ($ rows as $ row ) {
49
+ $ row ['id ' ] = 1000 * $ row ['id ' ] + intval (substr ($ row ['pesel ' ], 0 , 3 ));
50
+ unset($ row ['pesel ' ]);
51
+ fputcsv ($ fp , $ row );
52
+ }
53
+ fclose ($ fp );
54
+
55
+ // tpl
56
+ $ tplData ['count ' ] = count ($ rows );
57
+
58
+ // prepare data for render
59
+ $ pv_controller ->tpl ->data = $ tplData ;
60
+ $ pv_controller ->tpl ->file = 'controller.invitations.tpl.php ' ;
61
+ ?>
Original file line number Diff line number Diff line change
1
+ <h3>Dane wylosowanych (<?= $ tplData ['count ' ]?> )</h3>
2
+
3
+ Wygnerowane dane do pliku <a href="<?= $ tplData ['file ' ]?> "><?= $ tplData ['file ' ]?> </a>.
4
+ <?php
5
+ /*
6
+ ModuleTemplate::printArray($tplData['personal'], array(
7
+ 'region' => 'dzielnica',
8
+ 'people' => 'l. osób',
9
+ ));
10
+ */
11
+ ?>
12
+
Original file line number Diff line number Diff line change
1
+ <?
2
+ /* @var $pv_controller ModuleController */
3
+
4
+ require_once ('./inc/dbConnect.php ' );
5
+
6
+ //
7
+ // Crunch data
8
+ //
9
+ switch ($ pv_controller ->action )
10
+ {
11
+ default :
12
+ case 'invitations ' :
13
+ include $ pv_controller ->moduleDir .'/controller.invitations.php ' ;
14
+ break ;
15
+ case 'survey ' :
16
+ include $ pv_controller ->moduleDir .'/controller.survey.php ' ;
17
+ break ;
18
+ }
19
+
20
+ //
21
+ // Render prepared template
22
+ //
23
+ $ pv_controller ->tpl ->render ();
24
+ ?>
You can’t perform that action at this time.
0 commit comments