Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
filips123 committed Jan 21, 2016
1 parent a751132 commit 125a6ba
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 6 deletions.
18 changes: 18 additions & 0 deletions languages/config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
class Config {
public $display_offline_message = '1';
public $offline = '1'; //2
public $offline_message = 'hej'; //nej
public $offline_message2 = 'hej'; //nej

//addclass
}


$display_offline_message = "1";
$offline = "1"; //2
$offline_message = "hej"; //nej
$offline_message2 = "hej"; //nej

//addnoclass
?>
157 changes: 157 additions & 0 deletions languages/config/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?php
$GLOBALS['showClass'];
$GLOBALS['showOther'];
$GLOBALS['stevilo'] = 0;
$GLOBALS['komentar'];
$GLOBALS['status']=1;
$GLOBALS['status_message'];
class Config {
function language($a) {
if(file_exists('languages/'.$a.'.php')) {
include('languages/'.$a.'.php');
$GLOBALS['language'] = $a;
}else {
$GLOBALS['status_message']="I can't find the selected language.";
$GLOBALS['ststus']=0;
}
}

function showClass ($a) {
if($GLOBALS['status']!=0) {
$GLOBALS['showClass']=$a;
}
}

function showOther ($a) {
if($GLOBALS['status']!=0) {
$GLOBALS['showOther']=$a;
}
}

function set($a,$b,$c){
if($GLOBALS['status']!=0) {
$GLOBALS['stevilo']++;
$this->$a=array($b,$c,$GLOBALS['stevilo']);
}
}

function toString($class='',$addclass='',$addnoclass=''){
if($GLOBALS['status']!=0) {
if($GLOBALS['showClass']==''or $GLOBALS['showOther']=='') {
$GLOBALS['status_message']=$GLOBALS[$GLOBALS['language']]['showClass/showOther'] ;
$GLOBALS['status']=0;}
$string .='<?php
'; if($GLOBALS['showClass']==1) {
$string .= "class ".$class." {
";
if (isset($GLOBALS['komentar'][0])) {
$string .= '/*'.$GLOBALS['komentar'][0].'*/
';
}
foreach ($this as $k=>$v) {
if($v['1'] == '') {
$string .= 'public $'.$k." = '".$v[0]."';
";
}else{
$string .= 'public $'.$k." = '".$v[0]."'; //".$v[1]."
";
}
if($GLOBALS['komentar'][$v[2]] != ''){
$string .= '
/*'.$GLOBALS['komentar'][$v[2]].'*/
';
}
}
if($addclass!='') {
$string .='
'.$addclass.'';}
$string .="
}";$string .="
";}
if($GLOBALS['showOther']==1) {
if (isset($GLOBALS['komentar'][0])) {
$string .= '/*'.$GLOBALS['komentar'][0].'*/';
}
foreach ($this as $k=>$v) {
if($v['1'] == '') {
$string .= '
$'.$k.' = "'.$v[0].'"; ';
}else{
$string .= '
$'.$k.' = "'.$v[0].'"; //'.$v[1];
if($GLOBALS['komentar'][$v[2]] != ''){
$string .= '
/*'.$GLOBALS['komentar'][$v[2]].'*/';
}
}

}
}
if($addnoclass!='') {
$string .='
'.$addnoclass.''; }
$string .="
?>";
return $string;
}
}

function comment($a) {
if($$GLOBALS['status']!=0) {
$GLOBALS['komentar'][''.$GLOBALS['stevilo'].''] = $a;
}
}

function toFile($file,$data) {
if($GLOBALS['status']!=0) {
$fd = fopen ($file , "w") or $statusek=0;
if($statusek==0) {
$GLOBALS['status_message']=$GLOBALS[$GLOBALS['language']]["can't open"];
$GLOBALS['status']=0;
}
fwrite($fd, $data);
fclose($fd) ;

$fd = fopen ($file , "r") or $statusek2=0;
if($statusek2==0) {
$GLOBALS['status_message']=$GLOBALS[$GLOBALS['language']]["can't open"];
$GLOBALS['status']=0;
}
$data2=fread ($fd , filesize ($file));
if($data==$data2) {
$GLOBALS['status_message']=$GLOBALS[$GLOBALS['language']]["ok"];
$GLOBALS['status']=1;
}
fclose($fd) ;
}
}

function status() {
return $GLOBALS['status'];
}

function status_message() {
return $GLOBALS['status_message'];
}
}
$config = new Config;
$config->language('slovenian');
$config->showClass(1);
$config->showOther(1);

$config->comment('test');
$config->set('display_offline_message', 1,'');
$config->set('offline', '1',2);
$config->comment('testek');
$config->set('offline_message', 'hej','nej');
$config->set('offline_message2', 'hej','nej');

$data = $config->toString('Config','//addclass','//addnoclass');
$config->toFile('config.php',$data);
echo $config->status_message();


?>
5 changes: 5 additions & 0 deletions languages/config/languages/english.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
$GLOBALS['english']["can't open"] = 'Write successfully';
$GLOBALS['english']["ok"] = "I can't open $file";
$GLOBALS['english']["showClass/showOther"] = "I can't find the settings showClass and showOther";
?>
5 changes: 5 additions & 0 deletions languages/config/languages/slovenian.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
$GLOBALS['slovenian']["can't open"] = "Ne morem odpreti $file";
$GLOBALS['slovenian']["ok"] = 'Zapisovanje uspešno';
$GLOBALS['slovenian']["showClass/showOther"] = 'Ne najdem navtavitev showConfig on showOther';
?>
3 changes: 3 additions & 0 deletions languages/config/poglej.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
include("config.php");
echo $offline;
63 changes: 57 additions & 6 deletions php-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,43 @@
$GLOBALS['showOther'];
$GLOBALS['stevilo'] = 0;
$GLOBALS['komentar'];
$GLOBALS['status']=1;
$GLOBALS['status_message'];
class Config {
function language($a) {
if(file_exists('languages/'.$a.'.php')) {
include('languages/'.$a.'.php');
$GLOBALS['language'] = $a;
}else {
die("I can't find the selected language.");
$GLOBALS['status_message']="I can't find the selected language.";
$GLOBALS['ststus']=0;
}
}

function showClass ($a) {
if($GLOBALS['status']!=0) {
$GLOBALS['showClass']=$a;
}
}

function showOther ($a) {
if($GLOBALS['status']!=0) {
$GLOBALS['showOther']=$a;
}
}

function set($a,$b,$c){
if($GLOBALS['status']!=0) {
$GLOBALS['stevilo']++;
$this->$a=array($b,$c,$GLOBALS['stevilo']);
}
}

function toString($class='',$addclass='',$addnoclass=''){
if($GLOBALS['showClass']==''or $GLOBALS['showOther']=='') {die ($GLOBALS[$GLOBALS['language']]['showClass/showOther']) ;}
if($GLOBALS['status']!=0) {
if($GLOBALS['showClass']==''or $GLOBALS['showOther']=='') {
$GLOBALS['status_message']=$GLOBALS[$GLOBALS['language']]['showClass/showOther'] ;
$GLOBALS['status']=0;}
$string .='<?php
'; if($GLOBALS['showClass']==1) {
$string .= "class ".$class." {
Expand Down Expand Up @@ -85,22 +97,61 @@ function toString($class='',$addclass='',$addnoclass=''){
?>";
return $string;
}
}

function comment($a) {
if($$GLOBALS['status']!=0) {
$GLOBALS['komentar'][''.$GLOBALS['stevilo'].''] = $a;
}
}

function toFile($file,$data) {
$fd = fopen ($file , "w") or die ($GLOBALS[$GLOBALS['language']]["can't open"]) ;
if($GLOBALS['status']!=0) {
$fd = fopen ($file , "w") or $statusek=0;
if($statusek==0) {
$GLOBALS['status_message']=$GLOBALS[$GLOBALS['language']]["can't open"];
$GLOBALS['status']=0;
}
fwrite($fd, $data);
fclose($fd) ;

$fd = fopen ($file , "r") or die ($GLOBALS[$GLOBALS['language']]["can't open"]) ;
$fd = fopen ($file , "r") or $statusek2=0;
if($statusek2==0) {
$GLOBALS['status_message']=$GLOBALS[$GLOBALS['language']]["can't open"];
$GLOBALS['status']=0;
}
$data2=fread ($fd , filesize ($file));
if($data==$data2) {
die($GLOBALS[$GLOBALS['language']]["ok"]);
$GLOBALS['status_message']=$GLOBALS[$GLOBALS['language']]["ok"];
$GLOBALS['status']=1;
}
fclose($fd) ;
}
}

function status() {
return $GLOBALS['status'];
}

function status_message() {
return $GLOBALS['status_message'];
}
}
?>
$config = new Config;
$config->language('slovenian');
$config->showClass(1);
$config->showOther(1);

$config->comment('test');
$config->set('display_offline_message', 1,'');
$config->set('offline', '1',2);
$config->comment('testek');
$config->set('offline_message', 'hej','nej');
$config->set('offline_message2', 'hej','nej');

$data = $config->toString('Config','//addclass','//addnoclass');
$config->toFile('config.php',$data);
echo $config->status_message();


?>

0 comments on commit 125a6ba

Please sign in to comment.