|
 |
Problem mit WebSpell Template & Livestats |
|
|
| Problem mit WebSpell Template & Livestats |
 |
Hi Kellerkind
Ich hoff mal, Du hast Webspell noch nicht zu weit weggelegt...
Ich hab gestern mal meine Serverbox gepimpt, funktioniert auch prima. Dazu hab ich noch das Template Server (templates/server.html) gepimpt.
Nur ist da alles hardgecoded --> dies würde ich gern durch Benutzung der Variablen von Livestats ersetzen.
Also Dinge wie: IP Adresse, Playeranzahl/anzeige, Status, etc.
Da das Template in HTML ist und offensichtlich keine PHP Befehle ausführen möchte, habe ich kurzerhand alle Templates in *.php umbenannt und in der _functions.php die Dateiendung geändert:
Code angehängt. Klicke hier zum Ein-/Ausblenden
| code: |
1:
2:
3:
4:
5:
|
function gettemplate($template,$endung="php") {
$templatefolder = "templates";
return str_replace("\"","\\\"",implode("",file($templatefolder."/".$template.".".$endung)));
}
|
|
Schreibe ich nun in mein neues PHP Template ein simples <?php echo "Hello World!";?>, zeigt er dieses jedoch nicht an
(In der Serverbox geht es aber).
So kann ich auch keine Variablen mit include("livestats/stats_cod5_0815.php"); einlesen.
Wo hab ich da eine fiese Falle von Webspell übersehen? Kann doch nicht wahr sein.
Der soll ja keine WebSpell interne Var übergeben wie beim TS Viewer, nur eine externe...
ToM
__________________

|
|
|
|
|
Kelli
... sehr viel alleine
 
Dabei seit: 09.11.2006
Beiträge: 2.504

|
|
| RE: Problem mit WebSpell Template & Livestats |
 |
Das geht so nicht.
Code angehängt. Klicke hier zum Ein-/Ausblenden
| code: |
1:
2:
3:
|
implode("",file($templatefolder."/".$template.".".$endung)));
|
|
implode liest den Inhalt des templates als text ein.
Nix was in dem Template steht wird jemals ausgeführt.
Wenn musst du die Variablen schon vorher mit Leben füllen, also in der Datei die das template aufruft und ausgibt.
Wenn ich das richtig sehe ist das die server.php
Code angehängt. Klicke hier zum Ein-/Ausblenden
| code: |
1:
2:
3:
4:
5:
6:
7:
8:
|
if(!checkenv('disable_functions','fsockopen')) {
if(!fsockopen("udp://".$ip,$port,$strErrNo,$strErrStr,30)) $status= "<i>timeout</i>";
else $status = "<b>online</b>";
} else $status = "<i>Not supported by server</i>";
fclose($connection);
|
|
Da sollte man statt des einfachen online / nicht online auch alternativ den status abfragen können
http://de.php.net/fsockopen
http://www.shooter-szene.de/PNphpBB2-pri...-start-20.phtml
Sieht mir aber schon wieder nach einen unglaublichen Hack aus (und ist schlecht für die Ladezeit der Seite)
__________________ „ Allah ist Groß, und wir sind armselige Tröpfe mit unseren ganzen Wissenschaften Herrlichkeit.“
Dieser Beitrag wurde 420 mal editiert, zum letzten Mal von der Bundesregierung Niemand: Heute, 11:42.
https://kkde.de/scum/
|
|
|
|
|
|
|
| RE: Problem mit WebSpell Template & Livestats |
 |
Original von Kellerkind
Das geht so nicht.
Code angehängt. Klicke hier zum Ein-/Ausblenden
| code: |
1:
2:
3:
|
implode("",file($templatefolder."/".$template.".".$endung)));
|
|
implode liest den Inhalt des templates als text ein.
Nix was in dem Template steht wird jemals ausgeführt.
Danke, das erklärt so einiges. Kostete viele Zigaretten & Kaffee
Original von Kellerkind
Wenn musst du die Variablen schon vorher mit Leben füllen, also in der Datei die das template aufruft und ausgibt.
Könnte ich auch da einfach die Livestats includen, da das ja sowieso connected?
Code angehängt. Klicke hier zum Ein-/Ausblenden
| code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
|
$server_ip = "udp://" . $server_ip;
$serverip = substr($server_ip, 6);
$connect = fsockopen($server_ip, $server_port, $errno, $errstr, 30);
if ($connect) {
socket_set_timeout ($connect, 1, 000000);
$send = "ÿÿÿÿ" . chr (0x02) . "getstatus";
$debug1 = fputs($connect, $send);
$debug2 = fwrite ($connect, $send);
$output = fread ($connect, 1);
if (! empty ($output)) {
do {
$status_pre = socket_get_status ($connect);
$output = $output . fread ($connect, 1);
$status_post = socket_get_status ($connect);
} while ($status_pre['unread_bytes'] != $status_post['unread_bytes']);
};
fclose($connect);
$output = explode ("\\", $output);
$max_index = array_search ("sv_maxclients", $output);$max_clients = $output[$max_index+1];
$max_index = array_search ("sv_privateClients", $output);$privat = $output[$max_index+1];
$max_index = array_search ("mapname", $output);$mapname = $output[$max_index+1];
$max_index = array_search ("sv_hostname", $output);$hostname = $output[$max_index+1];
$max_index = array_search ("g_gametype", $output);$gametype = $output[$max_index+1];
$max_index = array_search ("sv_punkbuster", $output);$punkbuster = $output[$max_index+1];
$max_index = array_search ("sv_pure", $output);$pure = $output[$max_index+1];
$max_index = array_search ("sv_voice", $output);$voice = $output[$max_index+1];
$max_index = array_search ("g_antilag", $output);$alag = $output[$max_index+1];
$max_index = array_search ("pswrd", $output);$passwort = $output[$max_index+1];
$max_index = array_search ("_Location", $output);$Standort = $output[$max_index+1];
$max_index = array_search ("_Admin", $output);$admin = $output[$max_index+1];
$max_index = array_search ("_Website", $output);$Web = $output[$max_index+1];
$max_index = array_search ("_Host", $output);$Host = $output[$max_index+1];
$max_index = array_search ("_Email", $output);$EMail = $output[$max_index+1];
$max_index = array_search ("_IRC", $output);$IRC = $output[$max_index+1];
$max_index = array_search ("_ICQ", $output);$ICQ = $output[$max_index+1];
$max_index = array_search ("gamename", $output);$gamename = $output[$max_index+1];
$max_index = array_search ("shortversion", $output);$Version = $output[$max_index+1];
$max_index = array_search ("_Mod", $output);$Mod = $output[$max_index+1];
$max_index = array_search ("sv_maxPing", $output);$maxPing = $output[$max_index+1];
$max_index = array_search ("sv_minPing", $output);$minPing = $output[$max_index+1];
$max_index = array_search ("fs_game", $output);$fsgame = $output[$max_index+1];
if ($Maps[$mapname] || "") {$mapnamelong = $Maps[$mapname];}
if ($mapnamelong == "") {$mapnamelong = $mapname;}
if ($fsgame == "_Admin") {$fsgame = "";}
if ($Host == "_Admin") {$Host = "";}
if ($Host == "Admin") {$Host = "";}
if ($Mod == "_Admin") {$Mod = "";}
if ($Mod == "Admin") {$Mod = "";}
if ($IRC == "_Admin") {$IRC = "";}
if ($IRC == "#") {$IRC = "-";}
if ($ICQ == "_Admin") {$ICQ = "-";}
if ($ICQ == "Admin") {$ICQ = "-";}
if ($maxPing == "_Admin") {$maxPing = "-";}
if ($Web == "_Admin") {$Web = "-";}
if ($minPing == "_Admin") {$minPing = "-";}
if ($gamename == "Call of Duty") {$GameIcon_small = "cod";$GameIcon_big = "cod_font";$gamename_short = "CoD";}
if ($gamename == "CoD:United Offensive") {$GameIcon_small = "coduo";$GameIcon_big = "coduo_font";$gamename_short = "CoD UO";}
if ($gamename == "Call of Duty 2") {$GameIcon_small = "cod2";$GameIcon_big = "cod2_font";$gamename_short = "CoD 2";}
if ($gamename == "Call of Duty 4") {$GameIcon_small = "cod4";$GameIcon_big = "cod4_font";$gamename_short = "CoD 4 MW";}
if ($gamename == "Call of Duty: World at War") {$GameIcon_small = "codww";$GameIcon_big = "codww_font";$gamename_short = "CoD WW";}
if ($gametype == "re") {$gametype = "Retrieval";$gametype_short = "RE";}
if ($gametype == "dm") {$gametype = "Deathmatch";$gametype_short = "DM";}
if ($gametype == "sd") {$gametype = "Suchen and Zerstören";$gametype_short = "SD";}
if ($gametype == "tdm") {$gametype = "Team Deathmatch";$gametype_short = "TDM";}
if ($gametype == "war") {$gametype = "Team Deathmatch";$gametype_short = "TDM";}
if ($gametype == "bel") {$gametype = "Hinter feindl. Linien";$gametype_short = "BEL";}
if ($gametype == "hq") {$gametype = "Hauptquartier";$gametype_short = "HQ";}
if ($gametype == "dom") {$gametype = "Domination";$gametype_short = "DOM";}
if ($gametype == "ctf") {$gametype = "Capture the Flag";$gametype_short = "CTF";}
if ($gametype == "bas") {$gametype = "Base Assault";$gametype_short = "BAS";}
if ($gametype == "koth") {$gametype = "King of the Hill";$gametype_short = "HQ";}
if ($gametype == "sab") {$gametype = "Sabotage";$gametype_short = "SAB";}
if ($gametype == "twar") {$gametype = "Krieg";$gametype_short = "TWAR";}
if ($gametype == "ctfb") {$gametype = "Capture the Flag back";$gametype_short = "CTFB";}
if ($gametype == "ch") {$gametype = "Capture and hold";$gametype_short = "CH";}
if ($gametype == "htf") {$gametype = "Hold the Flag";$gametype_short = "HTF";}
if ($gametype == "vip") {$gametype = "V.I.P.";$gametype_short = "VIP";}
if ($gametype == "wrz") {$gametype = "Warzone";$gametype_short = "WRZ";}
$last_value = count($output) - 1;
$players_string = $output[$last_value];
$players_string = explode("\n", $players_string);
for ($i = 1; $i != count($players_string); $i++) {
$split = explode(" ", $players_string[$i], 3);
$playerlist[$i-1]['score'] = $split[0];
$playerlist[$i-1]['ping'] = $split[1];
$playerlist[$i-1]['player'] = $split[2];
}
function cmp ($a, $b) {
if ($a["score"] > $b["score"]) {
return -1;
}
if ($a["score"] < $b["score"]) {
return 1;
}
if ($a["score"] == $b["score"]) {
return 0;
}
}
@usort($playerlist, "cmp");
$players = count($playerlist) - 1;
}
|
|
Was ich grad nicht verstehe: Wie zum Henker bring ich die Variablen dann in das Template rein? Irgendwelche Vars sind da ja schon drin: bgcolor="$bg1", die scheinen ja auch aus der server.php zu kommen?
Code angehängt. Klicke hier zum Ein-/Ausblenden
| code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
|
if(mysql_num_rows($ergebnis)) {
$i=1;
while($ds=mysql_fetch_array($ergebnis)) {
if($i%2) {
$bg1=BG_1;
$bg2=BG_2;
$bg3=BG_3;
$bg4=BG_4;
}
else {
$bg1=BG_3;
$bg2=BG_4;
$bg3=BG_1;
$bg4=BG_2;
}
|
|
Da hab ich grad noch eine Denkblockade.
Original von Kellerkind
Sieht mir aber schon wieder nach einen unglaublichen Hack aus (und ist schlecht für die Ladezeit der Seite)
[blöde_frage]Kann man nicht die Funktion so umschreiben, das ers nicht mehr nur als Textfile liest?[/blöde_frage]
ToM
__________________

|
|
|
|
|
|
|
Cool, danke!
Werd ich heut Abend mal versuchen, die Welt zu begrüssen
Wenns funktioniert, kann ich die Vars von Livestats rüberschaufeln, dazu noch eine kleine Frage:
Wenn ich Livestats in der server.php include, gibt er mir auf der Serverseite auch den Inhalt der Navbox aus,
da in der stats.php auch eine Ausgabe existiert.
Welchen Befehl anstelle include muss ich benutzen, um nur die Vars einzulesen? Könnte das require_once sein?
Oder muss der Teil mit der Connection & Definition der Vars auch in die server.php rein?
Ich hab in der Zwischenzeit die Livestats mal für alle CoD Spiele erweitert, auf meine Navbox zugeschnitten. Mehr Variablen eingebaut, da ich dann auf der grossen Übersichtsseite per Var auch ein Mappic einbauen könnte, und und und
ToM
P2P Messenger passt, oder TS2, das haste ja auch
__________________

|
|
|
|
|
|
|
Sooo, bin ziemlich weit gekommen (DANKE Kelly!), hab aber noch 2 kleine Stolpersteine:
Irgendwo hab ich einen Tipp / Denkfehler /Schleife drin, denn mir zeigt es das Template server_footer.php und dadurch die komplette rechte NavBox nicht mehr an.
(Dadurch auch keine Wiederholung des Templates für weitere Server.)
Hab zwar seit Stunden gesucht wie ein blöder, aber ich seh den Wald vor lauter Bäumen nicht mehr. Ich häng die Datei mal an, da zu lang.
In die server.php muss ich noch einen Code reinbringen, der mir abfragt, ob $mapname.jpg existiert und wenn nicht, das Bild unknown.jpg stattdessen ersetzt.
In dem Original ist es so gelöst, kann ich aber im Template mangels PHP nicht machen:
<img src="livestats/bilder/small/<?=$mappic_folder?>/<?=(file_exists("livestats/
bilder/small/$mappic_folder/$mapname.jpg") ? $mapname.".jpg" : "unknown.jpg")?>" alt="<?=(file_exists("livestats/bilder/small/$mappic_folder/$mapname.jpg") ? $x[mapname].".jpg" : "unknown.gif")?>" style="border: 0px solid #000000; width:130px; height:90px;">
Eine simple Abfrage wär mir lieber, da könnt ich das andere Script auch damit ausstatten, würde dieses ellenlange Teil durch Vars ersetzen.
Ich hab grad keinerlei Ideen mehr für if Statements und viele Sonderzeichen, Hirn leer
Warum auch immer der include der Funktionen nicht funktioniert hat, weiss ich nicht, mit dem Map Array funktioniert es prima:
Code angehängt. Klicke hier zum Ein-/Ausblenden
| code: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
|
// Maps für CoD 4 MW
if ($gamename_short == "CoD 4 MW") {
include ("livestats/maps_cod4.php");
if ($Maps[$mapname] || "") {
$mapnamelong = $Maps[$mapname];
}
if ($mapnamelong == "") {
$mapnamelong = $mapname;
}
}
// Maps für CoD WW
else if ($gamename_short == "CoD WW") {
include ("livestats/maps_codww.php");
if ($Maps[$mapname] || "") {
$mapnamelong = $Maps[$mapname];
}
if ($mapnamelong == "") {
$mapnamelong = $mapname;
}
}
|
|
ToM
__________________

|
|
|
|
|
|
|
|
 |
Impressum ||Datenschutzerklärung
|