// global
/* zu �ndern */
$modus = "web"; // | "web" -> entscheidet gewisse dinge
$seite = "fxsp";
$add = "";
$relPfad = "/".$seite."/".$add."design/";
$relPfad = "/".$add."design/";
if (strcmp("web",$modus) == 0) {
//web modus
// zum �ndern: vorderer Teil
$pfad = "/www/doc/".$seite."/".$add;
$pfad = "/home/www/web5/html";
// db
$pwdb = "FBBxvsGA";
$dbUserName = "web5";
$dbName = "usr_web5_1";
} else {
// pfade
$pfad = "c:/ali/www/".$seite."/";
}
//echo $GLOBALS[$modus].'
';
// functions
function magicms_connectDB() {
if (strcmp("web",$GLOBALS["modus"]) == 0) {
//echo $GLOBALS[modus].'
';
// db
$con = mysql_connect("localhost",$GLOBALS["dbUserName"],$GLOBALS["pwdb"]);
$db = mysql_select_db("usr_web5_1");
//echo $con.'
';
if ($e = mysql_error()) {
echo 'error: '.$e.'
';
} else {
return $con;
}
} else {
// db
$con = mysql_connect("localhost");
$db = mysql_select_db($GLOBALS["seite"]);
if ($e = mysql_error()) {
echo 'error: '.$e.'
';
} else {
return $con;
}
}
}
// functions andere
function getSite($r) {
//echo $r.'
';
if (preg_match('|/admin/z?|',$r)) {
$site = "admin/";
} else if(preg_match('|/1ed/?|',$r)) {
$site = "1ed/";
} else if(preg_match('|/programme/?|',$r)) {
$site = "programme/";
} else if(preg_match('|/hochzeit/?|',$r)) {
$site = "hochzeit/";
} else if(preg_match('|/game/?|',$r)) {
$site = "game/";
} else if(preg_match('|/3ea/?|',$r)) {
$site = "3ea/";
} else if(preg_match('|/3ec/?|',$r)) {
$site = "3ec/";
} else if(preg_match('|/noah/?|',$r)) {
$site = "noah/";
} else if(preg_match('|/falkenhorst/?|',$r)) {
$site = "falkenhorst/";
} else if(preg_match('|/uwr/?|',$r)) {
$site = "uwr/";
} else if(preg_match('|/bildergalerie/?|',$r)) {
$site = "bildergalerie/";
} else if(preg_match('|/sektherwil/?|',$r)) {
$site = "sektherwil/";
} else if(preg_match('|/fahela/?|',$r)) {
$site = "fahela/";
} else if(preg_match('|/dok/?|',$r)) {
$site = "dok/";
} else if(preg_match('|/geo/?|',$r)) {
$site = "geo/";
} else if(preg_match('|/winterlager/?|',$r)) {
$site = "winterlager2013/";
} else if(preg_match('|/schule/?|',$r)) {
$site = "schule/";
} else if(preg_match('|/bauk/?|',$r)) {
$site = "bauk/";
} else if(preg_match('|/bv/?|',$r)) {
$site = "bv/";
} else if(preg_match('|/klasseEa/?|',$r)) {
$site = "klasseEa/";
} else if(preg_match('|/zgraggen/?|',$r)) {
$site = "zgraggen/";
} else if(preg_match('|/yetivillage2013/?|',$r)) {
$site = "yetivillage2013/";
} else if(preg_match('|/programmieren2/?|',$r)) {
$site = "programmieren2/";
} else if(preg_match('|/iglubauer/?|',$r)) {
$site = "iglubauer/";
} else if(preg_match('|/rebekka_chris/?|',$r)) {
$site = "rebekka_chris/";
} else if(preg_match('|/modernArt/?|',$r)) {
$site = "modernArt/";
} else if(preg_match('|/allerlei/?|',$r)) {
$site = "allerlei/";
} else if(preg_match('|/kalender2/?|',$r)) {
$site = "kalender2/";
} else if(preg_match('|/kalender/?|',$r)) {
$site = "kalender/";
} else if(preg_match('|/programmieren_15-16/?|',$r)) {
$site = "programmieren_15-16/";
} else if(preg_match('|/klasse-ea-2016/?|',$r)) {
$site = "klasse-ea-2016/";
} else if(preg_match('|/hw-therwil/?|',$r)) {
$site = "hw-therwil/";
} else if(preg_match('|/geburtstag/?|',$r)) {
$site = "geburtstag/";
} else {
$site = "/";
}
//echo $site.'
';
return $site;
}
function addSnippets($designArray, &$textKomplett) {
$pattern = '/\[\[(\w+)\]\]/m';
// $replace = '[[[[$1]]]]';
$replace = '?>[[$1]]';
// $textKomplett = preg_replace($pattern, $replace, $textKomplett);
$pattern = '/\[\[(\w+)\]\]/me';
$replace = '$designArray["$1"]->code;';
$textKomplett = preg_replace($pattern, $replace, $textKomplett);
}
function writeFile($name, $text) {
//$text = doGlobals($text);
if (strcmp("web",$GLOBALS["modus"]) == 0) {
//$text = stripslashes($text);
}
$handle = fopen($name, "w");
fputs($handle,$text);
chmod($name,0777);
chown($name,30);
fclose($handle);
}
function writeFileMode($name, $text, $mode) {
//$text = doGlobals($text);
$handle = fopen($name, $mode);
fputs($handle,$text);
fclose($handle);
}
// verbesserung1 vom 21. 9. 05
// problem: php code kann nicht interpretiert werden, da alles nach der auswertung direkt ausgegeben wird
// losung: code in $code sammeln und in ein File schreiben
function echoPHP3($text, &$code, &$level, &$sammelCode) {
// echo memory_get_usage().'
';
$beginnCode = strpos($text,"");
$endeCode = strpos($text,"?>");
$beginnSnippet = strpos($text,"[[");
$endeSnippet = strpos($text,"]]");
$array["beginnCode"] = $beginnCode;
$array["endeCode"] = $endeCode;
$array["beginnSnippet"] = $beginnSnippet;
$array["endeSnippet"] = $endeSnippet;
natsort($array);
/*
reset($array);
echo current($array).', key: '.key($array).'
';
next($array);
echo current($array).', key: '.key($array).'
';
next($array);
echo current($array).', key: '.key($array).'
';
next($array);
echo current($array).', key: '.key($array).'
';
*/
reset($array);
for ($i=0; $i 0) {
//echo 'beginnCode if
';
$level++;
$sammelCode .= substr($text, 0, (current($array)))."";
$text = substr($text, (current($array)+2), (strlen($text)-(current($array)+2)));
echoPHP3($text,$code,$level,$sammelCode);
} else {
//echo 'beginnCode else
';
//echo substr($text, 0, current($array));
$code .= substr($text, 0, current($array))."";
$level++;
$text = substr($text, (current($array)+2), (strlen($text)-(current($array)+2)));
echoPHP3($text,$code,$level,$sammelCode);
}
} else if (strcmp(key($array), "endeCode") == 0) {
if ($level > 0) {
//echo 'endeCode if
';
$level--;
$sammelCode .= substr($text, 0, (current($array)));
if ($level == 0) {
//eval($sammelCode);
$code .= $sammelCode."?>";
$sammelCode = "";
} else {
$code .= $sammelCode."?>";
$sammelCode = "";
}
$text = substr($text, (current($array)+2), (strlen($text)-(current($array)+2)));
echoPHP3($text,$code,$level,$sammelCode);
} else {
//echo 'endeCode else
';
}
} else if (strcmp(key($array), "beginnSnippet") == 0) {
if ($level > 0) {
//echo 'beginnSnippet if
';
$sammelCode .= substr($text, 0, (current($array)))."?>";
$text = substr($text, (current($array)+2), (strlen($text)-(current($array)+2)));
echoPHP3($text,$code,$level,$sammelCode);
} else {
//echo 'beginnSnippet else
';
//echo substr($text, 0, current($array));
$code .= substr($text, 0, current($array));
$text = substr($text, (current($array)+2), (strlen($text)-(current($array)+2)));
echoPHP3($text,$code,$level,$sammelCode);
}
} else if (strcmp(key($array), "endeSnippet") == 0) {
if ($level > 0) {
//echo 'endeSnippet if
';
//$sammelCode .= "echo '".substr($text, 0, (current($array)))."';";
$sammelCode .= substr($text, 0, (current($array)))."";
$text = substr($text, (current($array)+2), (strlen($text)-(current($array)+2)));
echoPHP3($text,$code,$level,$sammelCode);
} else {
//echo 'endeSnippet else
';
//echo substr($text, 0, current($array));
$code .= substr($text, 0, current($array));
$text = substr($text, (current($array)+2), (strlen($text)-(current($array)+2)));
echoPHP3($text,$code,$level,$sammelCode);
}
} else {
//echo 'else else
';
}
}
?>