1+ <?php
2+ $ GLOBALS ['showClass ' ];
3+ $ GLOBALS ['showOther ' ];
4+ $ GLOBALS ['stevilo ' ] = 0 ;
5+ $ GLOBALS ['komentar ' ];
6+ $ GLOBALS ['status ' ]=1 ;
7+ $ GLOBALS ['status_message ' ];
8+ class Config {
9+ function language ($ a ) {
10+ if (file_exists ('languages/ ' .$ a .'.php ' )) {
11+ include ('languages/ ' .$ a .'.php ' );
12+ $ GLOBALS ['language ' ] = $ a ;
13+ }else {
14+ $ GLOBALS ['status_message ' ]="I can't find the selected language. " ;
15+ $ GLOBALS ['ststus ' ]=0 ;
16+ }
17+ }
18+
19+ function showClass ($ a ) {
20+ if ($ GLOBALS ['status ' ]!=0 ) {
21+ $ GLOBALS ['showClass ' ]=$ a ;
22+ }
23+ }
24+
25+ function showOther ($ a ) {
26+ if ($ GLOBALS ['status ' ]!=0 ) {
27+ $ GLOBALS ['showOther ' ]=$ a ;
28+ }
29+ }
30+
31+ function set ($ a ,$ b ,$ c ){
32+ if ($ GLOBALS ['status ' ]!=0 ) {
33+ $ GLOBALS ['stevilo ' ]++;
34+ $ this ->$ a =array ($ b ,$ c ,$ GLOBALS ['stevilo ' ]);
35+ }
36+ }
37+
38+ function toString ($ class ='' ,$ addclass ='' ,$ addnoclass ='' ){
39+ if ($ GLOBALS ['status ' ]!=0 ) {
40+ if ($ GLOBALS ['showClass ' ]=='' or $ GLOBALS ['showOther ' ]=='' ) {
41+ $ GLOBALS ['status_message ' ]=$ GLOBALS [$ GLOBALS ['language ' ]]['showClass/showOther ' ] ;
42+ $ GLOBALS ['status ' ]=0 ;}
43+ $ string .='<?php
44+ ' ; if ($ GLOBALS ['showClass ' ]==1 ) {
45+ $ string .= "class " .$ class ." {
46+ " ;
47+ if (isset ($ GLOBALS ['komentar ' ][0 ])) {
48+ $ string .= '/* ' .$ GLOBALS ['komentar ' ][0 ].'*/
49+ ' ;
50+ }
51+ foreach ($ this as $ k =>$ v ) {
52+ if ($ v ['1 ' ] == '' ) {
53+ $ string .= 'public $ ' .$ k ." = ' " .$ v [0 ]."';
54+ " ;
55+ }else {
56+ $ string .= 'public $ ' .$ k ." = ' " .$ v [0 ]."'; // " .$ v [1 ]."
57+ " ;
58+ }
59+ if ($ GLOBALS ['komentar ' ][$ v [2 ]] != '' ){
60+ $ string .= '
61+ /* ' .$ GLOBALS ['komentar ' ][$ v [2 ]].'*/
62+ ' ;
63+ }
64+ }
65+ if ($ addclass !='' ) {
66+ $ string .='
67+ ' .$ addclass .'' ;}
68+ $ string .="
69+ } " ;$ string .="
70+
71+ " ;}
72+ if ($ GLOBALS ['showOther ' ]==1 ) {
73+ if (isset ($ GLOBALS ['komentar ' ][0 ])) {
74+ $ string .= '/* ' .$ GLOBALS ['komentar ' ][0 ].'*/ ' ;
75+ }
76+ foreach ($ this as $ k =>$ v ) {
77+ if ($ v ['1 ' ] == '' ) {
78+ $ string .= '
79+ $ ' .$ k .' = " ' .$ v [0 ].'"; ' ;
80+ }else {
81+ $ string .= '
82+ $ ' .$ k .' = " ' .$ v [0 ].'"; // ' .$ v [1 ];
83+ if ($ GLOBALS ['komentar ' ][$ v [2 ]] != '' ){
84+ $ string .= '
85+
86+ /* ' .$ GLOBALS ['komentar ' ][$ v [2 ]].'*/ ' ;
87+ }
88+ }
89+
90+ }
91+ }
92+ if ($ addnoclass !='' ) {
93+ $ string .='
94+
95+ ' .$ addnoclass .'' ; }
96+ $ string .="
97+ ?> " ;
98+ return $ string ;
99+ }
100+ }
101+
102+ function comment ($ a ) {
103+ if ($ $ GLOBALS ['status ' ]!=0 ) {
104+ $ GLOBALS ['komentar ' ]['' .$ GLOBALS ['stevilo ' ].'' ] = $ a ;
105+ }
106+ }
107+
108+ function toFile ($ file ,$ data ) {
109+ if ($ GLOBALS ['status ' ]!=0 ) {
110+ $ fd = fopen ($ file , "w " ) or $ statusek =0 ;
111+ if ($ statusek ==0 ) {
112+ $ GLOBALS ['status_message ' ]=$ GLOBALS [$ GLOBALS ['language ' ]]["can't open " ];
113+ $ GLOBALS ['status ' ]=0 ;
114+ }
115+ fwrite ($ fd , $ data );
116+ fclose ($ fd ) ;
117+
118+ $ fd = fopen ($ file , "r " ) or $ statusek2 =0 ;
119+ if ($ statusek2 ==0 ) {
120+ $ GLOBALS ['status_message ' ]=$ GLOBALS [$ GLOBALS ['language ' ]]["can't open " ];
121+ $ GLOBALS ['status ' ]=0 ;
122+ }
123+ $ data2 =fread ($ fd , filesize ($ file ));
124+ if ($ data ==$ data2 ) {
125+ $ GLOBALS ['status_message ' ]=$ GLOBALS [$ GLOBALS ['language ' ]]["ok " ];
126+ $ GLOBALS ['status ' ]=1 ;
127+ }
128+ fclose ($ fd ) ;
129+ }
130+ }
131+
132+ function status () {
133+ return $ GLOBALS ['status ' ];
134+ }
135+
136+ function status_message () {
137+ return $ GLOBALS ['status_message ' ];
138+ }
139+ }
140+ $ config = new Config ;
141+ $ config ->language ('slovenian ' );
142+ $ config ->showClass (1 );
143+ $ config ->showOther (1 );
144+
145+ $ config ->comment ('test ' );
146+ $ config ->set ('display_offline_message ' , 1 ,'' );
147+ $ config ->set ('offline ' , '1 ' ,2 );
148+ $ config ->comment ('testek ' );
149+ $ config ->set ('offline_message ' , 'hej ' ,'nej ' );
150+ $ config ->set ('offline_message2 ' , 'hej ' ,'nej ' );
151+
152+ $ data = $ config ->toString ('Config ' ,'//addclass ' ,'//addnoclass ' );
153+ $ config ->toFile ('config.php ' ,$ data );
154+ echo $ config ->status_message ();
155+
156+
157+ ?>
0 commit comments