YourWBB


yourWBB » WoltLab Burning Board Generation 2 * » Alles von und für das WBB 2.1.x » [WBB 2.1.x] Allg. Fragen und Probleme » PHP syntax in einer TPL » Hallo Gast [Anmelden|Registrieren]
Letzter Beitrag | Erster ungelesener Beitrag 1.100 Views | | Thema zu Favoriten hinzufügen

Neues Thema erstellen Antwort erstellen

Dieses Thema wurde als unerledigt markiert. Thread unerledigt

Zum Ende der Seite springen PHP syntax in einer TPL
Autor
Beitrag « Vorheriges Thema | Nächstes Thema »
Predator01
Mitglied


Dabei seit: 09.12.05
Beiträge: 5

 PHP syntax in einer TPL Antworten Zitieren Editieren Melden       UP

Hallo und Giten Morgen

Mal eine Frage ob mir mal einer Sagen Könnte wie es machen kan, php in einer tpl zuzulassen.

Wie Folgt.

Ich habe eine php ( extrenes script) das ich mal als Styndalone Gemacht hatte.

Jetzt Möchte ich Dieses Gerne in mein wbb einbauen.

Also Ich folgende php Datei

php:
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:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:


<?php

if(!$_GET["ip"]) {
    echo "IP is missing!<br>&ip=...";
    die;
}

if(!$_GET["port"]) {
    $ipport explode(':'$_GET['ip']);
    if(!$ipport[1] && strpos($ipport[0], '.')) {
        echo "PORT is missing!<br>&port=...";
        die;
    } else { $port $ipport[1]; }
    if(!$ipport[0] || !strpos($ipport[0], '.')) {
        echo "IP is missing!<br>&ip=...";
        die;
    } else { $ip $ipport[0]; }
} else {
    $port $_GET['port'];
    $ip $_GET['ip'];
}


  require("hlquery_funcs.inc");
  require("binary_funcs.inc"); 

  $info Source_A2S_Info($ip$port);
  $info['address'] = $ip ":" $port;
  $challenge Source_A2S_GetChallenge($ip$port);
  $rules Source_A2S_Rules($ip$port$challenge);
  
  $mpg "http://maps.#########"; 
  
  $info Format_Info_Array($info$rules$mpg);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Status of <?php echo $info['hostname']; ?></TITLE>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<META HTTP-EQUIV=Refresh CONTENT="180">
<style type="text/css">
<!--
body table {
 font-family:Arial,Verdana,Helvetica;
 font-size:10px;
 text-decoration:none;
}
a {text-decoration:none;}
-->
</style>
</HEAD>
<body  topmargin="0" leftmargin="0" bgcolor="#<?php echo $_GET['bg']; ?>" 
    text="#<?php echo $_GET['text']; ?>" 
    vlink="#<?php echo $_GET['text']; ?>" 
    alink="#<?php echo $_GET['text']; ?>" 
    link="#<?php echo $_GET['text']; ?>" 
    background="<?php echo $_GET['img']; ?>" >

<?php
  echo "<center>\n"
      ."<TABLE width=\"132\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";

if ($_GET['pic']) {
    echo "<tr><td colspan=\"2\" align=\"center\"></td></tr>\n"
        ."<TR><TD colspan=\"2\" width=\"100%\" align=\"center\">\n";
    echo $info['img']."\n";
    echo "</TD></TR>\n";
}
?>
<TABLE  topmargin="0" leftmargin="0" cellspacing=1 cellpadding=5 border=0 width=100% align=center>
<TR><td nowrap>©</td><TD nowrap><table width=100%><tr><td align=left class=td-dark><?php echo $info['hostname']; ?></td><td align=right>&nbsp;</td></tr></table></TD><TD><a href="hlsw://<?php echo $info['address']; ?>"><?php echo $info['address']; ?></a></TD><TD nowrap><?php echo $info['short_descr']; ?></TD><TD><?php echo $info['map']?></TD><TD><?php echo $info['players']; ?>&nbsp;/&nbsp;<?php echo $info['max']; ?></TD></table>
<?php
if ($_GET['top']) {
    $top=$_GET['top'];
    $dbhost="";  //mysql host address
    $dbname=""// database name
    $dbpass=""// database password
    $dbuname=""//mysql user name
    @mysql_connect($dbhost$dbuname$dbpass) or die ("Unable to connect to mysql server");
    @mysql_select_db($dbname) or die ("Unable to select database");
    $sql 'SELECT lastName, skill, game FROM hlstats_Players where game="css" AND hideranking=0 ORDER BY skill DESC limit 10';
    $result mysql_query("SELECT lastName, skill FROM hlstats_Players where game='".$info['game']."' AND hideranking=0 ORDER BY skill DESC limit $top");
    if($result) {
            echo "<table width=\"132\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n"
                ."<tr><td colspan=\"2\" align=\"center\">Top $top</td></tr>\n"
                ."<tr><td width=\"102\" align=\"left\"><b><u>Name</b></u></font></td><td width=\"30\" align=\"right\"><b><u>Skill</b></u></td></tr>\n";
                $i=0;
            while ($i!=($_GET['top']) && $data mysql_fetch_object($result)) {
                echo "<TR><TD ALIGN=\"left\">";
                $show_length 17;  //Set to however many characters you would like to show in players name
                if(strlen($data->lastName)>$show_length){
                    $data->lastName substr($data->lastName0$show_length);
                    $data->lastName .= "..";
                }
                echo htmlentities($data->lastName);
                echo "</TD><td align=\"right\">$data->skill</td></TR>\n";
                $i++;
            }
            mysql_close();
            echo "</table>";
    }
}
if ($_GET["ppl"]) {
    $players Source_A2S_Player($ip$port$challenge); // already challenged for rules above
    if ($players) {
        echo "<table width=\"132\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n"
            ."<tr><td colspan=\"2\" align=\"center\"><b>Spieler</b></td></tr>\n"
            ."<tr><td width=\"102\" align=\"left\"><b><u>Name</b></u></font></td><td width=\"30\" align=\"right\"><b><u>Frags</b></u></td></tr>\n";
        foreach($players as $name=>$value) {
            echo "<TR bgcolor=\"".$_GET['bg']."\">"
                ."<TD align=\"left\">";
            $show_length 17;  //Set to however many characters you would like to show in players name
            if(strlen($value['name'])>$show_length){
                $value['name'] = substr($value['name'], 0$show_length);
                $value['name'] .= "..";
            }
            echo htmlentities($value["name"])."</TD><TD align=\"right\">&nbsp;".$value["frags"]."</TD></TR>\n";
        }
    echo "</table>";
    }
}
?>
</BODY>
</HTML>




So :

Jetzt wolte Ich dort ein Template rein machen.

Ich habe Also am Stat´rt der Seite folgendes Gesetzt:

php:
1:
2:
3:
4:
5:
6:
7:
8:

<?

require("./global.php");

eval("\$tpl->output(\"".$tpl->get("stats_header")."\");");
?>



und ans Ende dieses:

php:
1:
2:
3:
4:
5:
6:
7:


<?
eval("\$tpl->output(\"".$tpl->get("stats_footer")."\");");
?>




Klappt alles Wunderbar und Ich habe die Seite also nun im wbb drin.


Wen ich aber nun an der Stelle die was auslesen soll ein Template machen Möchte, habe ich einen Fehler,

Ich habe den Bereich den er aus der PHP als Template anzeigen soll so Verändert.

Also Diesen Bereich:

php:
1:
2:
3:
4:
5:

<TABLE  topmargin="0" leftmargin="0" cellspacing=1 cellpadding=5 border=0 width=100% align=center>
<TR><td nowrap>©</td><TD nowrap><table width=100%><tr><td align=left class=td-dark><?php echo $info['hostname']; ?></td><td align=right>&nbsp;</td></tr></table></TD><TD><a href="hlsw://<?php echo $info['address']; ?>"><?php echo $info['address']; ?></a></TD><TD nowrap><?php echo $info['short_descr']; ?></TD><TD><?php echo $info['map']?></TD><TD><?php echo $info['players']; ?>&nbsp;/&nbsp;<?php echo $info['max']; ?></TD></table>



In Diesem

php:
1:
2:
3:
4:
5:

<?php
eval("\$tpl->output(\"".$tpl->get("serverlist3")."\");");
?>


Dan habe ich ein Template erstellt mit namen serverlist3

In Dieses Template habe ich nun Folgendes Rein Gemacht:

php:
1:
2:
3:
4:

<TABLE  topmargin="0" leftmargin="0" cellspacing=1 cellpadding=5 border=0 width=100% align=center>
<TR><td nowrap>©</td><TD nowrap><table width=100%><tr><td align=left class=td-dark><?php echo $info['hostname']; ?></td><td align=right>&nbsp;</td></tr></table></TD><TD><a href="hlsw://<?php echo $info['address']; ?>"><?php echo $info['address']; ?></a></TD><TD nowrap><?php echo $info['short_descr']; ?></TD><TD><?php echo $info['map']?></TD><TD><?php echo $info['players']; ?>&nbsp;/&nbsp;<?php echo $info['max']; ?></TD></table>



So nun habe ich das Problem, das in dem Template php Variablen drin sind. Wie zb:

code:
1:
2:
3:
<?php echo $info['players']; ?>


Daruch Zeigt er mir Fehler an,

nun meine Frage, wie kann ich es Machen das er Diese Variablen in dem Template Anzeigt.

Danke für eine Antwort und Hilfe

Grüsse Monty

Dieser Beitrag wurde 2 mal editiert, zum letzten Mal von Predator01: 14.12.05 10:21.

14.12.05 06:11 Predator01 ist offline E-Mail Finden Als Freund hinzufügen
Baumstruktur | Brettstruktur
Gehe zu:

Neues Thema erstellen Antwort erstellen

yourWBB » WoltLab Burning Board Generation 2 * » Alles von und für das WBB 2.1.x » [WBB 2.1.x] Allg. Fragen und Probleme » PHP syntax in einer TPL