News Script + Vote Script geht zusammen nicht!

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • News Script + Vote Script geht zusammen nicht!

    Ich habe ein News Script und ein Vote script auf meiner page laufen aber das gibt mit diesen beiden scripten in einer datei immer probs vieleicht weis einer eine antwort dadrauf. Es hat irgendwas mit dem save zu tun das weis ich.
    -------------------------------------------------
    PHP-Code:
    <?php
    function head() {
    include(
    'config.php');
    echo 
    "<table width=\"150\" border=\"0\" cellpadding=\"0\" cellspacing=\"\" align=\"center\">
    <tr><td bgcolor=\"#555555\">"
    ;
    }
    function 
    foot () {
    echo 
    "</td></tr></table>";
    }
    function 
    record($REMOTE_ADDR) {
    include(
    'config.php');
    $fp=fopen("$ip_file""a+");
    fputs ($fp,$REMOTE_ADDR."][".time()."\n");
    fclose($fp);
    }
    function 
    check($REMOTE_ADDR) {
    include(
    'config.php');
    global 
    $valid;
    $ip=$REMOTE_ADDR;
    $data=file("$ip_file");
    $now=time();
    foreach (
    $data as $record) {
    $subdata=explode("][",$record);
    if (
    $now < ($subdata[1]+3600*$timeout)) {
    if (
    $ip == $subdata[0]) {
    $valid=0;
    break;
    }}}}
    //##################### Save data ##############################
    function save($answer){
    global 
    $answer;
    include(
    'config.php');
    $data=file($datafile);
    $subdata=explode("][",$data[$answer]);
    $subdata[2]+=1;
    $data[$answer]=implode("]["$subdata);
    $data[$answer]=$data[$answer]."\n";
    $fp=fopen($datafile,"w+");
    $a=0;
    do{
    fputs($fp,$data[$a]);
    $a++;
    }while(
    $a<count($data));
    fclose($fp);
    }
    //########################## Show Form ############################
    function form($PHP_SELF){
    include(
    'config.php');
    head();
    echo 
    "<font size=\"$fontsize\" face=\"$font\" color=\"$textcolor\"><form method=\"post\" action=\"$PHP_SELF\"><p align=\"center\">";
    $data=file($datafile);
    $question=$data[0];
    $nb_options=count($data)-1;
    echo 
    "<b>$question</b></p>";
    for(
    $nb=1;$nb <= $nb_options$nb++){
    $option=explode("][","$data[$nb]");
    echo 
    "&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"radio\" name=\"answer\" value=\"$nb\"> ";
    echo 
    "$option[0]<br>";
    }
    echo 
    "<input type=\"hidden\" name=\"save\" value=\"yes\">";
    echo 
    "<br><TABLE border=0 cellPadding=0 cellSpacing=0 class=leftpanellink2 width=\"100%\">
              <TBODY>
              <TR class=leftpanelinkbg>
              <TD align=left style=\"HEIGHT: 19px; WIDTH: 140px\"><SPAN class=smalltext></SPAN><a href=\"#\" onclick=\"document.forms[0].submit()\"><SPAN class=leftpaneblacklink><SPAN style=\"COLOR: #cccccc\"><p align=\"right\">Vote</p></SPAN></SPAN></a>
              <TD class=leftpanesmalldivider style=\"WIDTH: 1px\"><IMG style=\"WIDTH: 1px\"></TD>
              <TD class=home style=\"WIDTH: 4px\"><IMG style=\"WIDTH: 4px\"></TD>
              <TD class=leftpanesmalldivider style=\"WIDTH: 1px\"><IMG style=\"WIDTH: 1px\"></TD></TR></TBODY></TABLE>
    <TABLE border=0 cellPadding=0 cellSpacing=0 class=leftpanellink3 width=\"100%\">
              <TBODY>
              <TR class=leftpanelinkbg>
              <TD align=left style=\"HEIGHT: 19px; WIDTH: 140px\"><SPAN class=smalltext></SPAN><a href=\"mitte-news.php?number=0&action=results\"><SPAN class=leftpaneblacklink><SPAN style=\"COLOR: #cccccc\"><p align=\"right\">Ergebnisse</p></SPAN></SPAN></a>
              <TD class=leftpanesmalldivider style=\"WIDTH: 1px\"><IMG style=\"WIDTH: 1px\"></TD>
              <TD class=home style=\"WIDTH: 4px\"><IMG style=\"WIDTH: 4px\"></TD>
              <TD class=leftpanesmalldivider style=\"WIDTH: 1px\"><IMG style=\"WIDTH: 1px\"></TD></TD></TR></TBODY></TABLE>"
    ;
    foot();
    }
    //################## Function to show results ########################
    function results(){
    include(
    'config.php');
    head();
    $data=file($datafile);
    $nb_answers=count($data);
    $votes=0;
    $a=1;
    do{
    $subdata=explode("][",$data[$a]);
    $votes += $subdata[2];
    $a++;
    }while(
    $a $nb_answers);
    $a=1;
    $b="answerv";
    $v=100/$votes;
    echo 
    "<p align=\"center\"><font size=\"$fontsize\" face=\"$font\" color=\"$textcolor\"><b>$data[0]</b><br><br>";
    do{
    $subdata=explode("][",$data[$a]);
    $av $subdata[2] * $v;
    echo 
    "<font size=\"$fontsize\" face=\"$font\" color=\"$textcolor\">$subdata[0] -"printf(" %01.1f"$av); echo"%<br>";
    $p2v 100-$av;
    echo 
    "<img src=\"$subdata[1]\" width=\"$av\" height=\"10\"><img src=\"$image\" width=\"$p2v\" height=\"10\"><br>";
    $a++;
    } while (
    $a $nb_answers);
    echo 
    "<br>";
    echo 
    "<TABLE border=0 cellPadding=0 cellSpacing=0 class=leftpanellink2 width=\"100%\">
              <TBODY>
              <TR class=leftpanelinkbg>
              <TD align=left style=\"HEIGHT: 19px; WIDTH: 140px\"><SPAN class=smalltext></SPAN><a href=\"mitte-news.php\"><SPAN class=leftpaneblacklink><SPAN style=\"COLOR: #cccccc\"><p align=\"right\">Zur&uuml;ck</p></SPAN></SPAN></a>
              <TD class=leftpanesmalldivider style=\"WIDTH: 1px\"><IMG style=\"WIDTH: 1px\"></TD>
              <TD class=home style=\"WIDTH: 4px\"><IMG style=\"WIDTH: 4px\"></TD>
              <TD class=leftpanesmalldivider style=\"WIDTH: 1px\"><IMG style=\"WIDTH: 1px\"></TD>"
    ;
    foot();
    }
    //###################### Engine ####################################
    check($REMOTE_ADDR);
    if (
    $valid=="0"){ results();}
    elseif (
    $action=="results") { results(); }
    elseif (
    $save=="yes" && $valid!="0") { save($Answer); record($REMOTE_ADDR); results();}
    elseif (
    $action=="save" && !empty($valid)) { results(); }
    elseif (
    $action!="save" && $valid!="0"){ form($PHP_SELF); }
    ?>

  • #2
    Und hier der Newsscript zum Downloaden:

    Download

    Kommentar


    • #3
      Muss man sich das alles durchlesen?

      Woher sollen wir wissen, was nicht Funktioniert? Fehlermeldungen ...?

      Würde spontan einfach sagen, dass da die Selben Variablen, Bezeichnungen, etc benutzt werden.

      Aus diesem Grund bietet es sich an eigene Scripte zu Programmieren.

      Kommentar

      Lädt...
      X