Keresés

Új hozzászólás Aktív témák

  • klinnsy

    csendes tag

    válasz Sk8erPeter #6579 üzenetére

    MEGOLDÁS:

    if ($answer < count($ANSWER) && $vote) {

    csere ERRE:

    // if ($answer < count($ANSWER) && $vote) {
    if ($answer < count($ANSWER) && ($vote || $vote_x)) {

  • klinnsy

    csendes tag

    Php kód értetlen módon nem jó!

    Sziasztok a problémám a következő lapon (is) megtalálható (régebben jó volt most hirtelen nem műxik):
    http://nicelife.hu/tanuljunk/szemtipus/05.php
    Az a gondom, hogy régebben működött ez a script, ahol szavazni lehet, most pedig a szavaz gomb után ugyanúgy csinálja mintha jó lenne, de a szavazás értékét nem adja hozzá a txt file-hoz.
    Az az érdekes (és most jön a poén), hogy másnál pedig működik, mert kipróbálta ismerősöm, illetve látom, hogy töb szavazat is érkezik egy nap.

    Itt a szavaz.php forráskódja, a többi adatot (kérdés, válaszok, ip, szavazatok 1-1 txt-ben tárolja melyek igen 777 attr-al vannak ellátva).

    Már néztem több gépről, nekem nem működött, mi lehet a baj?

    EZ TELJESEN LOGIKÁTLAN HIBA! AKI MEGOLDJA AZ ULTRAÁSZ! Köszönöm!

    <?php
    $ip = getenv(REMOTE_ADDR);
    $RESULT_FILE_NAME = "../../scripts/szavaz/hirek/halottidezes/szavazatok.txt";
    $que = "../../scripts/szavaz/hirek/halottidezes/kerdes.txt";
    $ans = "../../scripts/szavaz/hirek/halottidezes/valaszok.txt";
    $fn = fopen ($que, "r");
    $puff = fread ($fn, filesize($que));
    fclose ($fn);
    $QUESTION = "$puff";
    $lis= 0;
    $plsr = file("../../scripts/szavaz/hirek/halottidezes/valaszok.txt");
    for($x=0;$x<sizeof($plsr);$x++) {
    $temp = explode("|",$plsr[$x]);
    $list[$lis] = $temp[0];
    $lis++;
    }
    $ANSWER = $list;
    extract($HTTP_GET_VARS);
    extract($HTTP_POST_VARS);
    $fname="ip_log.dat";
    if (strlen($answer)<=0&&!$vresult){
    echo "<FORM METHOD=\"POST\">\n";

    echo "<TABLE align=center border=0 borderColor=#D9F2CC cellPadding=2 class=normaltext style=\" BORDER-COLLAPSE: collapse; \">\n";
    echo "<TR><TH><font color=ffffff size=2>$QUESTION</TH></TR>\n";
    while (list($key, $val) = each($ANSWER)) {
    echo "<TR><TD align=\"left\"><INPUT TYPE=\"radio\" NAME=\"answer\" VALUE=\"$key\"><font color=8d9aa6 size=2> $val</TD></TR>\n";}
    echo "<TR><TD align=\"center\"><INPUT TYPE=\"image\" src='http://www.nicelife.hu/scripts/szavaz/szavaz.png' NAME=\"vote\" VALUE=\" Szavazok \"></TD></TR>\n";
    echo "<TR><TD align=\"center\"></form><form method=post><input type=hidden name=vresult value=1><INPUT TYPE=\"image\" src='http://www.nicelife.hu/scripts/szavaz/eredmenyek.png' NAME=\"result\" VALUE=\"Eredmények\">\n";
    echo "</TABLE></form>";
    }

    if (strlen($answer)>0) {
    $plsr = file("../../scripts/szavaz/hirek/halottidezes/ip.txt");
    for($x=0;$x<sizeof($plsr);$x++) {
    $temp = explode("|",$plsr[$x]);
    }
    if($ip==$temp[0] && strlen($answer)>0 ){
    echo "<font color=red size=2><div align=center>Erre a kérdésre egyszer már válaszoltál!</div></font>";
    $file_array = file($RESULT_FILE_NAME);
    if ($answer < count($ANSWER) && $vote) {
    while (list($key, $val) = each($file_array)) {
    $total += $val;
    }

    echo "<TABLE align=center border=0 borderColor=#D9F2CC cellPadding=2 class=normaltext style=\" BORDER-COLLAPSE: collapse; \">\n";
    echo "<tr><th><font color=ffffff size=2><div align=center>Válaszok</th><th><font color=ffffff size=2><div align=center>Szavazatok aránya</th><th><font color=ffffff size=2><div align=center>Szavazatok száma</th></tr>";

    while (list($key, $val) = each($ANSWER)){
    $percent = $file_array[$key] * 100 / $total;
    $percent_int = floor($percent);
    $percent_float = number_format($percent, 1);
    $tp += $percent_float;
    if($percent_int>=75){
    $color="#45abe5";
    }
    elseif($percent_int>=50){
    $color="#388dbe";
    }
    elseif($percent_int>=25){
    $color="#2d729a";
    }
    elseif($percent_int<25){
    $color="#215370";
    }

    echo "<tr><td><font color=8d9aa6 size=2> $ANSWER[$key] </td><td><table cellpadding=1 cellspacing=0 width=100% border=0 bgcolor=black><tr><td><table cellpadding=0 cellspacing=0 border=0 width=100%>
    <tr>
    <td bgcolor=$color width=$percent_int% height=10 style=border:0 >
    <spacer type=block width=2 height=8>
    </td>
    <td bgcolor=white width=91% height=10 style=border:0>
    <font color=8d9aa6 size=2>
    <spacer type=block width=2 height=8>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table><font color=67727c size=2>$percent_float%</td><td><font color=8d9aa6 size=2><center>$file_array[$key]</td></tr>";
    }

    $tv=$total;

    echo "<td></td><td></td><td><font color=67727c size=2><div align=left><center>Összesen: $tv</font></font></font></td></TABLE>";
    }
    }elseif (strlen($answer)>0 && $ip!=$temp[0]){
    $file_array = file($RESULT_FILE_NAME);
    if ($answer < count($ANSWER) && $vote) {
    $old_answer = $file_array[$answer];
    $old_answer = preg_replace("/\n\r*/", "", $old_answer);
    $file_array[$answer] = ($old_answer + 1)."\n";
    $fname="../../scripts/szavaz/hirek/halottidezes/ip.txt";
    $fq = fopen($fname, "a++");
    fwrite ($fq, $ip);
    fwrite ($fq, "|");
    fwrite ($fq, "\n");
    fclose ($fq);
    $file = join('', $file_array);
    $fp = fopen("$RESULT_FILE_NAME", "w");
    flock($fp, 1);
    fputs($fp, $file);
    flock($fp, 3);
    fclose($fp);
    echo "<div align=center><font color=67727c size=2>Szavazat elfogadva... </div>";
    }
    while (list($key, $val) = each($file_array)) {
    $total += $val;
    }

    echo "<TABLE align=center border=0 borderColor=#D9F2CC cellPadding=2 class=normaltext style=\" BORDER-COLLAPSE: collapse; \">\n";
    echo "<tr><th><font color=ffffff size=2>Válasz lehetőségek</th><th><font color=ffffff size=2>Válaszok aránya</th><th><font color=ffffff size=2><div align=center>Szavazatok száma</th></tr>";

    while (list($key, $val) = each($ANSWER)){
    $percent = $file_array[$key] * 100 / $total;
    $percent_int = floor($percent);
    $percent_float = number_format($percent, 1);
    $tp += $percent_float;
    if($percent_int>=75){
    $color="#45abe5";
    }
    elseif($percent_int>=50){
    $color="#388dbe";
    }
    elseif($percent_int>=25){
    $color="#2d729a";
    }
    elseif($percent_int<25){
    $color="#215370";
    }

    echo "<tr><td><font color=8d9aa6 size=2> $ANSWER[$key] </td><td><table cellpadding=1 cellspacing=0 width=100% border=0 bgcolor=black><tr><td><table cellpadding=0 cellspacing=0 border=0 width=100%>
    <tr>
    <td bgcolor=$color width=$percent_int% height=10 style=border:0>
    <spacer type=block width=2 height=8>
    </td>
    <td bgcolor=white width=91% height=10 style=border:0>
    <spacer type=block width=2 height=8>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table><font color=67727c size=2>$percent_float%</td><td><font color=8d9aa6 size=2><center>$file_array[$key]</td></tr>";

    }
    $tv=$total;
    echo "<td></td><td></td><td><font color=67727c size=2><center>Összesen: $tv</font></font></font></td></TABLE>";
    }
    else {
    echo "Kérlek válassz előbb";
    }
    }
    if (!empty ($vresult)){
    $file_array = file($RESULT_FILE_NAME);
    while (list($key, $val) = each($file_array)) {
    $total += $val;
    }

    echo "<TABLE align=center border=0 borderColor=#D9F2CC cellPadding=2 class=normaltext style=\" BORDER-COLLAPSE: collapse; \">\n";
    echo "<tr><th><font color=ffffff size=2>Válasz lehetőségek</th><th><font color=ffffff size=2>Válaszok aránya</th><th><font color=ffffff size=2>Szavazatok száma</th></tr>";

    while (list($key, $val) = each($ANSWER)){
    $percent = $file_array[$key] * 100 / $total;
    $percent_int = floor($percent);
    $percent_float = number_format($percent, 1);
    $tp += $percent_float;
    if($percent_int>=75){
    $color="#45abe5";
    }
    elseif($percent_int>=50){
    $color="#388dbe";
    }
    elseif($percent_int>=25){
    $color="#2d729a";
    }
    elseif($percent_int<25){
    $color="#215370";
    }

    echo "<tr><td><font color=8d9aa6 size=2> $ANSWER[$key] </td><td><table cellpadding=1 cellspacing=0 width=100% border=0 bgcolor=black><tr><td><table cellpadding=0 cellspacing=0 border=0 width=100%>
    <tr>
    <td bgcolor=$color width=$percent_int% height=10 style=border:0 >
    <spacer type=block width=2 height=8>
    </td>
    <td bgcolor=white width=91% height=10 style=border:0 >
    <spacer type=block width=2 height=8>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table><font color=67727c size=2>$percent_float%</td><td><font color=8d9aa6 size=2><center>$file_array[$key]</td></tr>";

    }
    $tv=$total;
    echo "<td></td><td></td><td><font color=67727c size=2><center>Összes szavazat: $tv</td></TABLE>";
    }

    ?>
    h

Új hozzászólás Aktív témák