Counter auf eigener php-Seite

Hallo,

ich habe mir im IPS-WebFront eine eigene Seite für eine Fernbedienung meines Receivers erstellt. Hat alles bestens funktioniert, bis ich auf die Idee kam, für die Lautstärke mit einem selbstgebauten Counter die Klicks für Volume-Plus und Volume-Minus zu zählen. Das Script seht Ihr auszugsweise hier.

 <td width="14%" align="center"><a href="countminus.php?action=setWinLirc&id=52894"><img src="button/volumeminus.png" border="0"></a></td>
	<td width="17%" align="left"><font size="6"><font color="#f4bf23"><font face="Texas LED">
<?php
  $datei = fopen("counter.txt","r+");
  $counterstand = fgets($datei, 10);
  echo "$counterstand dB";
	?>
</td>
    <td width="14%" align="center"><a href="countplus.php?action=setWinLirc&id=39550"><img src="button/volumeplus.png" border="0"></a></td>

Im Browser sieht das wie in der beigefügten Grafik aus.

Ohne die Counterfunktionalität (also nur <a href=?action=setWinLirc&id=52894…) funktioniert alles wunderbar, die entsprechenden Buttons lösen die dazugehörigen Schaltbefehle aus. Sowie ich die Counterfunktionalität, wie im Scrip beschrieben, eingefügt habe, werden nur noch die Dezibel hoch und runter gezählt, die setWinLirc-Action jedoch nicht durchgeführt. Das sieht zwar verdammt gut aus, hilft aber nicht beim „Fernbedienen“:wink:
Ich vermute, dass ich irgendeinen Denk- oder Formatierungsfehler drin habe. Meine html- und php-Kenntnisse entwickeln sich nämlich erst, seit dem ich mich mit IPS beschäftige und sind daher ziemlich rudimentär. Vielleicht kann mir jemand helfen.

Danke
poronneb

countminus.txt (300 Bytes)

Aufjeden Fall, solltest Du die Datei auch wieder schliessen.

fclose(…);

Alle HTML-Tags sollten auch wieder geschlossen werden:

<td width="14%" align="center"><a href="countminus.php?action=setWinLirc&id=52894"><img src="button/volumeminus.png" border="0"></a></td>
    <td width="17%" align="left"><font size="6"><font color="#f4bf23"><font face="Texas LED">
<?php
  $datei = fopen("counter.txt","r+");
  $counterstand = fgets($datei, 10);
  echo "$counterstand dB";
// RWN; 02.01.2010
 fclose($datei);
    ?>
</font></font></font>
</td>
    <td width="14%" align="center"><a href="countplus.php?action=setWinLirc&id=39550"><img src="button/volumeplus.png" border="0"></a></td>

Danke für die Tipps. Ich habe alles so nachgetragen, wie Ihr empfohlen habt. Leider ändert sich nichts. Der counter zählt, aber die action bleibt aus. Vielleicht fällt Euch ja noch was ein. Ich bin jedenfalls mit meinem Latein am Ende.
Danke
poronneb

Alles wird gut!! Bin von selbst drauf gekommen. Mit meinen auszugsweisen Angaben zum Script (siehe oben) war das nicht zu lösen. Deshalb hier noch einmal das ganze Script:

<?php
    if(isset($_GET['action']) && $_GET['action'] == "setWinLirc" && isset($_GET['id']))
    {
        IPS_RunScript((int)$_GET['id']);
    }
?>

<html>

<style type="text/css">@import "webfront.css";</style>
<style type="text/css">@import "css/web_individuell.css";</style>

<body style="width: 800px; height:700px; background-image:url(css/images/box_bg.png); background-repeat:repeat-x;"> </body>
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="ma">
  <tr>
    <td width="15%" align="center"> </td>
    <td width="70%" align="center" style="font-weight: bold; color: #FF9933; text-align:center;"><h1>Onkyo
      TX-SR 605</h1></td>
    <td width="15%" align="center"> </td>
  </tr>
</table>

<table cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td width="34%" align="center" style="font-weight: bold; color: #FF9933;">Eingangsquellen</td>
    <td width="33%" align="center" style="font-weight: bold; color: #FF9933;">Volume</td>
    <td width="33%" align="center" style="font-weight: bold; color: #FF9933;">Setting</td>
  </tr>
</table>
<table cellpadding="0" cellspacing="0" width="100%" class="ma">
  <tr>
     <td width="14%" align="center"><a href="?action=setWinLirc&id=53991"><img src="button/ps3_shine.png" border="0"></a></td>
    <td width="14%" align="center"><a href="?action=setWinLirc&id=43369"><img src="button/edision.png" border="0"></a></td>
    <td width="14%" align="center"><a href="countminus.php?action=setWinLirc&id=52894"><img src="button/volumeminus.png" border="0"></a></td>
	<td width="17%" align="left"><font size="6"><font color="#f4bf23"><font face="Texas LED">
<?php
  $datei = fopen("counter.txt","r+");
  $counterstand = fgets($datei, 10);
  echo "$counterstand dB";
	?>
	</font></font></font>
</td>
    <td width="14%" align="center"><a href="countplus.php?action=setWinLirc&id=39550"><img src="button/volumeplus.png" border="0"></a></td>
    <td width="14%" align="center"><a href="?action=setWinLirc&id=21810"><img src="button/setup.png" border="0"></a></td>
    <td width="14%" align="center"><a href="?action=setWinLirc&id=50082"><img src="button/exit.png" border="0"></a></td>
  </tr>
</table>

<table cellpadding="0" cellspacing="0" width="100%" class="ma">
  <tr>
    <td width="16%" align="center" class="nobg"> </td>
    <td width="17%" align="center" class="nobg"><a href="?action=setWinLirc&id=24406"><img src="button/up.png" border="0"></a></td>
    <td width="16,5%" align="center" class="nobg"> </td>
    <td width="16,5%" style="text-align:right" class="nobg"><a href="?action=setWinLirc&id=14284"><img src="button/down_blue.png" border="0"></a></td>
    <td width="16,5%" align="center" class="nobg"><img src="button/speaker-64x64.png">
<br>	
		<font color=#FF9933><big><big>
		<style="font-weight: bold;">Subwoofer</big></big></td>
    
    <td width="16,5%" style="text-align:left" class="nobg"><a href="?action=setWinLirc&id=23018"><img src="button/up_red.png" border="0"></a></td>
  </tr>
  <td width="14,28%" style="text-align:right" class="nobg"><a href="?action=setWinLirc&id=24481"><img src="button/left.png" border="0"></a></td>
    <td width="14,28%" align="center" class="nobg"><a href="?action=setWinLirc&id=12641"><img src="button/apply.png" border="0"></a></td>
    <td width="14,28%" style="text-align:left" class="nobg"><a href="?action=setWinLirc&id=15529"><img src="button/right.png" border="0"></a></td>
    <td width="14,28%" style="text-align:right" class="nobg"> </td>
    <td width="14,28%" align="center" class="nobg"> </td>
    <td width="14,28%" style="text-align:left" class="nobg"> </td>
  </tr><td width="14,28%" align="center" class="nobg"><a href="countaus.php?action=setWinLirc&id=22317"><img src="button/redbutton72.png" border="0"></a></td>

    <td width="14,28%" align="center" class="nobg"><a href="?action=setWinLirc&id=38885"><img src="button/down.png" border="0"></a></td>
    <td width="14,28%" align="center" class="nobg"> </td>
    <td width="14,28%" style="text-align:right" class="nobg"><a href="?action=setWinLirc&id=40631"><img src="button/down_blue.png" border="0"></a></td>
    <td width="14,28%" align="center" class="nobg"><img src="button/center64x64.png">
<br>	
		<font color=#FF9933><big><big>

und dazu noch das counter-script für Volume-minus:

<?php

  if(isset($_GET['action']) && $_GET['action'] == "setWinLirc" && isset($_GET['id']))
    {
        IPS_RunScript((int)$_GET['id']);
    }

  $datei = fopen("counter.txt","r+");
  $counterstand = fgets($datei, 10);
  if($counterstand == "")
    {
    $counterstand = 47;
    }
  $counterstand--;
  $counterstand--;
  rewind($datei);
  fwrite($datei, $counterstand);
  fclose($datei);
  header("Location:onkyo.php");
  ?> 

Mein Fehler war, dass ich im counterscript den code

if(isset($_GET['action']) && $_GET['action'] == "setWinLirc" && isset($_GET['id']))
    {
        IPS_RunScript((int)$_GET['id']);

für die setWinLirc-Aktion nicht drin hatte. Ich dachte, es reicht, wenn dieser Code in der obigen „Haupt“-.php ist. Dem ist aber nicht so. Ist ja eigentlich logisch. Jetzt funktioniert alles. Ich danker Euch für Eure Mühe.

poronneb