pragmaMx Support Forum

pragmaMx => Coder und Bastlerecke => Thema gestartet von: Eismann1976 am 18 November 2007, 14:41:02

Titel: Blöcke werden nicht angezeigt
Beitrag von: Eismann1976 am 18 November 2007, 14:41:02
Moin,

ich hab hier gerade so ein kleines externes Script. Das wollte ich als Modul in PMX einbinden. Leider sind alle linken Blöcke leer wenn ich das Modul aufrufe. Die rechten Blöcke werden gleich garnicht angezeigt.

Kann mir da wer einen Tipp geben um das Problem zu lösen?

Hier mal das Modul zum ansehen und anschließened der Code

http://www.winner-team-joiner.de/modules.php?name=Playermaprank

<?php 
if (!eregi("modules.php"$PHP_SELF)) { 
die (
"You can't access this file directly..."); 

$index 0
require_once(
"mainfile.php"); 
$module_name basename(dirname(__FILE__)); 
#get_lang($module_name); 
include("header.php"); 
OpenTable(); 
?>


<?
include("dbinfo.inc.php");

$order=$_GET["order"];
$sort=$_GET["sort"];

if($sort=="DESC") {
$sort="ASC";
} else {
$sort="DESC";
}

if($order=="good") {
$order="(good/total)*100";
} else if($order=="okay") {
$order="(okay/total)*100";
} else if($order=="bad") {
$order="(bad/total)*100";
} else if($order==""){
$order="total";
}
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM `maprank` ORDER BY ".$order." ".$sort." ";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

echo "<b><br><center><font size=+2>Map Bewertungen</center></b><font size=-2><br>";

?>

<BODY BGCOLOR="#002C57" TEXT="#DDDDCA" LINK="#FFFFFF" VLINK="#FFFFFF" ALINK="#FFFFFF" leftmargin=0 rightmargin=0 topmargin=0 bottommargin=0 marginheight=0 marginwidth=0>

<div align="center">
<table border="1" cellspacing="0" cellpadding="2" width="100%">
<tr>
<?
echo "<th align='center'><a href='".$home_site."index.php?order=map_name&sort=".$sort."'><font size=+1>Map Name</font></a></th>
<th align='center'><a href='".$home_site."index.php?order=good&sort=".$sort."'><font size=+1>Gut</font></a></a></th>
<th align='center'><a href='".$home_site."index.php?order=okay&sort=".$sort."'><font size=+1>Okay</font></a></th>
<th align='center'><a href='".$home_site."index.php?order=bad&sort=".$sort."'><font size=+1>Schlecht</font></a></th>
<th align='center'><a href='".$home_site."index.php?order=total&sort=".$sort."'><font size=+1>Votes</font></a></th>
</tr>";
?>

<?
$i=0;
while ($i < $num) {
$map_name=mysql_result($result,$i,"map_name");
$state1=mysql_result($result,$i,"good");
$state2=mysql_result($result,$i,"okay");
$state3=mysql_result($result,$i,"bad");
$total=($state1 + $state2 + $state3);
if ($total==0){
$state1p=0;
}else{
$state1p=round($state1 / $total,2)*100;
}
if ($total==0){
$state2p=0;
}else{
$state2p=round($state2 / $total,2)*100;
}
if ($total==0){
$state3p=0;
}else{
$state3p=round($state3 / $total,2)*100;
}

$color="a0a020";
if (($state1p >= $state2p) & ($state1p > $state3p)){
$color="208020";
}
if (($state3p >= $state2p) & ($state3p > $state1p)){
$color="802020";
}

echo "<tr>
<td align='center'><font color='".$color."'>".$map_name."</font></td>
<td align='center'><font color='a0a0a0'>".$state1p."%</font></td>
<td align='center'><font color='a0a0a0'>".$state2p."%</font></td>
<td align='center'><font color='a0a0a0'>".$state3p."%</font></td>
<td align='center'><font color='a0a0a0'>".$total."</font></td>
</tr>";

++$i;
}
echo "</table>";


?>


<?php 



CloseTable
(); 
include(
"footer.php"); 


?>

Titel: Re: Blöcke werden nicht angezeigt
Beitrag von: m-t am 18 November 2007, 14:43:52
Zitat von: Eismann1976 am 18 November 2007, 14:41:02
Hier mal das Modul zum ansehen

Sorry, dieses Modul ist nicht aktiv!
Titel: Re: Blöcke werden nicht angezeigt
Beitrag von: Eismann1976 am 18 November 2007, 15:02:16
Ups   :red:

Jetzt ^^
Titel: Re: Blöcke werden nicht angezeigt
Beitrag von: m-t am 18 November 2007, 15:17:37
ich würde so spontan mal auf nuke header tippen  :cool:
bau den mal auf pragmamx um, am besten das modul blank_home als vorlage verwenden
Titel: Re: Blöcke werden nicht angezeigt
Beitrag von: JoergK am 18 November 2007, 15:18:10
require_once("mainfile.php");


Kommentier die Zeile mal aus bzw. schmeiss die gleich ganz raus.
Die mainfile.php wird in pragmaMx bereits in der modules.php included.  ;)

EDIT:
Das mit den fehlenden Blöcken liegt daran, dass im Script ne neue Verbindung zu der/einer Datenbank geöffnet wird. Das funzt so nicht in pragmaMx.
Titel: Re: Blöcke werden nicht angezeigt
Beitrag von: Eismann1976 am 18 November 2007, 15:44:30
Beides probiert. Gleiches Problem. Hab nun mal die blank_home genommen. Was könnte da falsch sein ?

<?php // $Id: index.php,v 1.3 2005/08/30 07:10:58 tora60 Exp $
/************************************
 pragmaMx  Content Management System
 Copyright (c) 2005 pragmaMx Dev Team - http://pragmaMx.org
 ***********************************
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.
 ***********************************
 $Source: /home/www/dps3311/home/cvsroot/pragmamx/html/modules/blank_Home/index.php,v $
 $Revision: 1.3 $
 $Author: tora60 $
 $Date: 2005/08/30 07:10:58 $
************************************/

if (!defined("mxMainFileLoaded")) die ("You can't access this file directly...");

$GLOBALS["index"] = 1;
/* if (isset($show)) {
$output = "";
$file = @fopen($show, "r");
if ($file){
while (!feof($file)) {
  $output .= " ".trim(fgets($file, 1024))." ";
}
fclose($file);
}
#$output = strip_tags(trim($output));
$output = trim($output);
}
 */
include("header.php");


include(
"dbinfo.inc.php");

$order=$_GET["order"];
$sort=$_GET["sort"];

if(
$sort=="DESC") {
$sort="ASC";
} else {
$sort="DESC";
}

if(
$order=="good") {
$order="(good/total)*100";
} else if(
$order=="okay") {
$order="(okay/total)*100";
} else if(
$order=="bad") {
$order="(bad/total)*100";
} else if(
$order==""){
$order="total";
}
mysql_connect($host,$username,$password);
@
mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM `maprank` ORDER BY ".$order." ".$sort." ";
$result=mysql_query($query);

$num=mysql_numrows($result); 

mysql_close();

echo 
"<b><br><center><font size=+2>Map Bewertungen</center></b><font size=-2><br>";

?>


<BODY BGCOLOR="#000000" TEXT="#eeeeee" LINK="#99CCFF" VLINK="#99CCFF" ALINK="#99CCFF" leftmargin=0 rightmargin=0 topmargin=0 bottommargin=0 marginheight=0 marginwidth=0>

<div align="center">
<table border="2" cellspacing="2" cellpadding="2" width="100%">
<tr>
<?
echo "<th align='center'><a href='".$home_site."index.php?order=map_name&sort=".$sort."'><font size=+1>Map Name</font></a></th>
<th align='center'><a href='".$home_site."index.php?order=good&sort=".$sort."'><font size=+1>Gut</font></a></a></th>
<th align='center'><a href='".$home_site."index.php?order=okay&sort=".$sort."'><font size=+1>Okay</font></a></th>
<th align='center'><a href='".$home_site."index.php?order=bad&sort=".$sort."'><font size=+1>Schlecht</font></a></th>
<th align='center'><a href='".$home_site."index.php?order=total&sort=".$sort."'><font size=+1>Votes</font></a></th>
</tr>";
?>

<?
$i=0;
while ($i < $num) {
$map_name=mysql_result($result,$i,"map_name");
$state1=mysql_result($result,$i,"good");
$state2=mysql_result($result,$i,"okay");
$state3=mysql_result($result,$i,"bad");
$total=($state1 + $state2 + $state3);
if ($total==0){
$state1p=0;
}else{
$state1p=round($state1 / $total,2)*100;
}
if ($total==0){
$state2p=0;
}else{
$state2p=round($state2 / $total,2)*100;
}
if ($total==0){
$state3p=0;
}else{
$state3p=round($state3 / $total,2)*100;
}

$color="a0a020";
if (($state1p >= $state2p) & ($state1p > $state3p)){
$color="208020";
}
if (($state3p >= $state2p) & ($state3p > $state1p)){
$color="802020";
}

echo "<tr>
<td align='center'><font color='".$color."'>".$map_name."</font></td>
<td align='center'><font color='a0a0a0'>".$state1p."%</font></td>
<td align='center'><font color='a0a0a0'>".$state2p."%</font></td>
<td align='center'><font color='a0a0a0'>".$state3p."%</font></td>
<td align='center'><font color='a0a0a0'>".$total."</font></td>
</tr>";

++$i;
}
echo "</table>";





include("footer.php");

?>
Titel: Re: Blöcke werden nicht angezeigt
Beitrag von: JoergK am 18 November 2007, 16:23:23
Quasi das gleiche, wie im "Original"-Code. Kommentier mal die Verbindung zur DB aus:

...
// include("dbinfo.inc.php");
...
// mysql_connect($host,$username,$password);
// @mysql_select_db($database) or die( "Unable to select database");
...
// mysql_close();
...


Dann würd ich gleich noch diese Änderungen machen, auch wenn sie mit dem Phänomen nix zu tun haben:

...
// $result=mysql_query($query);
$result=sql_query($query);
...
// $num=mysql_numrows($result);
$num=sql_num_rows($result);
...


Und dann schmeiß noch gleich die Zeile mit dem Body-Tag raus, weil der wird ja schon viel früher ausgegeben. ;)
Titel: Re: Blöcke werden nicht angezeigt
Beitrag von: Eismann1976 am 18 November 2007, 17:43:24
So gehts.  :)
Ich wollte zwar eine andere DB ansprechen als die vom PMX, daher ist das nicht ganz das was ich wollte aber ich hab es jetzt einfach geändert und nutze nur eine DB.

Danke
Titel: Re: Blöcke werden nicht angezeigt
Beitrag von: Eismann1976 am 14 Februar 2008, 16:02:50
Moin,

ich brauche nochmal eure Hilfe. Das o.g. Script ist jetzt ein wenig erweitert und bisher kam ich auch immer zum gewünschten Ergebnis. Nun komm ich aber mal wieder nicht weiter.
Wenn man über einen Link fährt soll ein Bild per Mouseover aufgehen. Im Original siehts so aus:

http://www.winner-team-joiner.de/server/modules/maprank2time/

Wie man sieht gehts. Das ist der entsprechende Code:

<?
include("includes/dbinfo.inc.php");

#################################################################
######## server ip:port für die timelimit berechnung ############
#################################################################

$server_ip="85.14.221.195:27015";

#################################################################


$img_width=320;
$img_height=240;
$img_dir="./images";
$img_bgcolor="#202020";
$img_bordercolor="#eeeeee";


$order=$_GET["order"];
$sort=$_GET["sort"];

if($sort=="DESC") {
$sort="ASC";
} else {
$sort="DESC";
}

if($order=="good") {
$order="(good/total)*100";
} else if($order=="okay") {
$order="(okay/total)*100";
} else if($order=="bad") {
$order="(bad/total)*100";
} else if($order=="tl") {
$order="(good/total)-(bad/total)";
} else if($order==""){
$order="total";
}


mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM maprank_data WHERE ip='".$server_ip."'; ";
$result=mysql_query($query);
$row = mysql_fetch_row($result);

$mp_timelimit=$row[1];
$min_votes=$row[2];
$max_time_offset=$row[3];
$min_timelimit=$row[4];
$vote_mode=$row[5];


$query="SELECT * FROM `maprank` ORDER BY ".$order." ".$sort." ";
$result=mysql_query($query);
$num=mysql_numrows($result);

mysql_close();
?>

<BODY BGCOLOR="#000000" TEXT="#eeeeee" LINK="#99CCFF" VLINK="#99CCFF" ALINK="#99CCFF" leftmargin=0 rightmargin=0 topmargin=0 bottommargin=0 marginheight=0 marginwidth=0>
<script type="text/javascript" src="includes/wz_tooltip.js"></script>
<b><br>
<?
echo "<center><font size=+2 color='#eeeeee'>Map Bewertungen: <a href='hlsw://".$server_ip."/'>".$server_ip."</a><font size=-2></center></b>
<br>
<center><b><font size=2 color='#a0a0a0'>Bewertungen werden im Spiel abgegeben<font size=0></b></center>
<br>
<center><b><font size=2 color='#a0a0a0'>Maps mit weniger als ".$min_votes." Votes laufen ".$mp_timelimit." min<font size=0></b></center>
<br>";
?>

<div align="center">
<table border="2" cellspacing="2" cellpadding="2" width="100%">
<tr>
<?
echo "<th style='align=center;background-color=#800000'><a href='".$home_site."index.php?order=map_name&sort=".$sort."'><font size=+1>Map Name</font></a></th>
<th style='align=center;background-color=#800000'><a href='".$home_site."index.php?order=good&sort=".$sort."'><font size=+1>Gut</font></a></a></th>
<th style='align=center;background-color=#800000'><a href='".$home_site."index.php?order=okay&sort=".$sort."'><font size=+1>Okay</font></a></th>
<th style='align=center;background-color=#800000'><a href='".$home_site."index.php?order=bad&sort=".$sort."'><font size=+1>Schlecht</font></a></th>
<th style='align=center;background-color=#800000'><a href='".$home_site."index.php?order=total&sort=".$sort."'><font size=+1>Votes</font></a></th>
<th style='align=center;background-color=#800000'><a href='".$home_site."index.php?order=tl&sort=".$sort."'><font size=+1>Timelimit</font></a></th>
</tr>";

$i=0;
while ($i < $num) {
$map_name=mysql_result($result,$i,"map_name");
$state1=mysql_result($result,$i,"good");
$state2=mysql_result($result,$i,"okay");
$state3=mysql_result($result,$i,"bad");
$total=($state1 + $state2 + $state3);
if ($total==0){
$state1p=0;
}else{
$state1p=round($state1 / $total,2)*100;
}
if ($total==0){
$state2p=0;
}else{
$state2p=round($state2 / $total,2)*100;
}
if ($total==0){
$state3p=0;
}else{
$state3p=round($state3 / $total,2)*100;
}

$color="a0a020";
if (($state1p > $state2p) & ($state1p > $state3p)){
$color="208020";
}
if (($state3p >= $state2p) & ($state3p > $state1p)){
$color="802020";
}

if($vote_mode==1) {
$f_factor=($state1p-$state3p);
} else {
$f_factor=((($state1p*3)+($state2p*2)+$state3p) / 3);
}
$timelimit=round($mp_timelimit+(($f_factor/100)*$max_time_offset));

if($timelimit<10) {
$timelimit=$min_timelimit;
}

if($total<$min_votes) {
$timelimit=$mp_timelimit;
}


if (file_exists($img_dir."/".$map_name.".jpg")) {
    $image=$map_name;
} else {
    $image="noimage";
}

echo "<tr>
<td align='center'><font color='".$color."'>
<a onmouseover=\"Tip('<img src=\'".$img_dir."/../../../../modules/My_eGallery/gallery/cstrike/".$image.".jpg\' width=\'".$img_width."\' height=\'".$img_height."\'><br><table align=\'center\'>".$map_name."</table>',BGCOLOR,'".$img_bgcolor."',BORDERCOLOR,'".$img_bordercolor."',FONTCOLOR,'#eeeeee')\">".$map_name."</a></font></td>
<td align='center'><font color='a0a0a0'>".$state1p."%</font></td>
<td align='center'><font color='a0a0a0'>".$state2p."%</font></td>
<td align='center'><font color='a0a0a0'>".$state3p."%</font></td>
<td align='center'><font color='a0a0a0'>".$total."</font></td>
<td align='center'><font color='a0a0a0'>".$timelimit." min</font></td>
</tr>";
++$i;
}
echo "</table>";

echo "<br><font size=1 color='#a0a0a0'>Plugin Settings:
mp_timelimit ".$mp_timelimit." |
min_votes ".$min_votes." |
max_time_offset ".$max_time_offset." |
min_timelimit ".$min_timelimit." |
vote_mode ".$vote_mode."
<br>";
?>


Wenn ich das jetzt in einen Block einbaue funktionierts nichtmehr.
Oben steht wie üblich:

<?php 

if (eregi("block-maprank.php",$_SERVER['PHP_SELF'])) { Header("Location: index.html"); die(); 



Dann habe ich

include("includes/dbinfo.inc.php");

und

mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");


auskommentiert. Leider funktioniert der Mouseover nun nichtmehr. Kann mir bitte jemand sagen wo ich einen Fehler mache ?