Skip to content

Commit 125a6ba

Browse files
committed
Initial commit
1 parent a751132 commit 125a6ba

File tree

6 files changed

+245
-6
lines changed

6 files changed

+245
-6
lines changed

languages/config/config.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
class Config {
3+
public $display_offline_message = '1';
4+
public $offline = '1'; //2
5+
public $offline_message = 'hej'; //nej
6+
public $offline_message2 = 'hej'; //nej
7+
8+
//addclass
9+
}
10+
11+
12+
$display_offline_message = "1";
13+
$offline = "1"; //2
14+
$offline_message = "hej"; //nej
15+
$offline_message2 = "hej"; //nej
16+
17+
//addnoclass
18+
?>

languages/config/index.php

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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+
?>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
$GLOBALS['english']["can't open"] = 'Write successfully';
3+
$GLOBALS['english']["ok"] = "I can't open $file";
4+
$GLOBALS['english']["showClass/showOther"] = "I can't find the settings showClass and showOther";
5+
?>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
$GLOBALS['slovenian']["can't open"] = "Ne morem odpreti $file";
3+
$GLOBALS['slovenian']["ok"] = 'Zapisovanje uspešno';
4+
$GLOBALS['slovenian']["showClass/showOther"] = 'Ne najdem navtavitev showConfig on showOther';
5+
?>

languages/config/poglej.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
include("config.php");
3+
echo $offline;

php-config.php

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,43 @@
33
$GLOBALS['showOther'];
44
$GLOBALS['stevilo'] = 0;
55
$GLOBALS['komentar'];
6+
$GLOBALS['status']=1;
7+
$GLOBALS['status_message'];
68
class Config {
79
function language($a) {
810
if(file_exists('languages/'.$a.'.php')) {
911
include('languages/'.$a.'.php');
1012
$GLOBALS['language'] = $a;
1113
}else {
12-
die("I can't find the selected language.");
14+
$GLOBALS['status_message']="I can't find the selected language.";
15+
$GLOBALS['ststus']=0;
1316
}
1417
}
1518

1619
function showClass ($a) {
20+
if($GLOBALS['status']!=0) {
1721
$GLOBALS['showClass']=$a;
22+
}
1823
}
1924

2025
function showOther ($a) {
26+
if($GLOBALS['status']!=0) {
2127
$GLOBALS['showOther']=$a;
28+
}
2229
}
2330

2431
function set($a,$b,$c){
32+
if($GLOBALS['status']!=0) {
2533
$GLOBALS['stevilo']++;
2634
$this->$a=array($b,$c,$GLOBALS['stevilo']);
35+
}
2736
}
2837

2938
function toString($class='',$addclass='',$addnoclass=''){
30-
if($GLOBALS['showClass']==''or $GLOBALS['showOther']=='') {die ($GLOBALS[$GLOBALS['language']]['showClass/showOther']) ;}
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;}
3143
$string .='<?php
3244
'; if($GLOBALS['showClass']==1) {
3345
$string .= "class ".$class." {
@@ -85,22 +97,61 @@ function toString($class='',$addclass='',$addnoclass=''){
8597
?>";
8698
return $string;
8799
}
100+
}
88101

89102
function comment($a) {
103+
if($$GLOBALS['status']!=0) {
90104
$GLOBALS['komentar'][''.$GLOBALS['stevilo'].''] = $a;
105+
}
91106
}
92107

93108
function toFile($file,$data) {
94-
$fd = fopen ($file , "w") or die ($GLOBALS[$GLOBALS['language']]["can't open"]) ;
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+
}
95115
fwrite($fd, $data);
96116
fclose($fd) ;
97117

98-
$fd = fopen ($file , "r") or die ($GLOBALS[$GLOBALS['language']]["can't open"]) ;
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+
}
99123
$data2=fread ($fd , filesize ($file));
100124
if($data==$data2) {
101-
die($GLOBALS[$GLOBALS['language']]["ok"]);
125+
$GLOBALS['status_message']=$GLOBALS[$GLOBALS['language']]["ok"];
126+
$GLOBALS['status']=1;
102127
}
103128
fclose($fd) ;
129+
}
130+
}
131+
132+
function status() {
133+
return $GLOBALS['status'];
134+
}
135+
136+
function status_message() {
137+
return $GLOBALS['status_message'];
104138
}
105139
}
106-
?>
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

Comments
 (0)