Visualizzazione risultati 1 fino 6 di 6

Discussione: Sondaggio in php: problemi di voto

  1. #1
    Guest

    Predefinito

    Se provo a votare qua dà errore:
    http://paynegame.altervista.org/poll/template1.php

    Sospetto che si tratti del config.php, qualcosa che abbia a che fare con la root path non sono sicuro....


    CONFIG.PHP


    [code:1:c41ab3e127]
    <?PHP
    / ****************************************
    **********************************
    * config.php (Text)
    * -------------------
    * $Id: config.php,v 1.13 2002/09/28 16:25:35 d-campbell Exp $
    * For support go to - http://php.pogoworld.co.uk
    * Copyright (C) Duncan Campbell 2002.
    *
    ****************************************
    *********************************/

    / ****************************************
    **********************************
    * *
    * 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. *
    * *
    ****************************************
    *********************************/

    function display_error($error_text)
    {
    print '<B>Flipper Poll - Error:</B><P>'.$error_text.'</P>';
    exit;
    }


    if (!isset ($poll_id))
    {
    display_error('Please set the poll id. Refer to readme for more information');
    }
    if (!isset ($root_path))
    {
    $root_path = 'poll.php';
    }


    $fp = @fopen('data/data_' . $poll_id . '.csv','r'); // Open file containing options, question, etc.
    if (!$fp)
    {
    display_error('Unable to open file: data_'.$poll_id.'.csv');
    exit;
    }
    $vote_options = fgetcsv ($fp, 1000, ','); // Put csv file into an array
    fclose ($fp);

    $fp2 = @fopen('data/vote_' . $poll_id . '.csv','r');
    if (!$fp2)
    {
    display_error('Unable to open file: vote_'.$poll_id.'.csv');
    exit;
    }
    $vote_data = fgetcsv ($fp2, 1000, ',');
    fclose ($fp2);

    // Misc options
    $csv_entry = count($vote_options);
    $n = $csv_entry - 4;
    $debate = $n + 1;
    $poll_info = '<A href="http://php.pogoworld.co.uk/" target="_blank"><FONT face = "Arial Black" size="1" color="#CC0000">By Flipper Poll</font></A>';
    ?>

    --------------------------------------------------------------------------------
    [/code:1:c41ab3e127]


    POLL.PHP


    [code:1:c41ab3e127]:--------------------------------------------------------------------------------<?PHP
    / ****************************************
    **********************************
    * poll.php (Text)
    * -------------------
    * $Id: poll.php,v 1.16 2002/09/28 16:25:35 d-campbell Exp $
    * For support go to - http://php.pogoworld.co.uk
    * Copyright (C) Duncan Campbell 2002.
    *
    ****************************************
    *********************************/

    / ****************************************
    **********************************
    * *
    * 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. *
    * *
    ****************************************
    *********************************/

    include_once($root_path . 'config.php');

    if (isset ($HTTP_GET_VARS['id']))
    {
    $poll_id = $HTTP_GET_VARS['id'];
    }

    if (!isset ($poll_id))
    {
    display_error('Poll Error! Please set the poll id. Refer to readme.txt for more information');
    }

    // Start Output
    ?>

    <SCRIPT language = "JavaScript">
    <!--
    function OptionChecked()
    {
    var i;
    for (i = 0; i < document.frmPoll.radPoll.length; i++)
    if (document.frmPoll.radPoll[i].checked&# 41; return true;
    alert("Per votare devi selezionare una delle risposte!");
    return false;
    }

    function results()
    {
    var url = "<?PHP print 'id='.$poll_id; ?>";
    window.open('<?PHP print $root_path.'results.php?'; ?>' +url,'results','width=185,height=730,men
    ubar=no,scrollbars=no,toolbar=no,locatio
    n=no,directories=no,resizable=yes,top=0,
    left=0');
    }
    //-->
    </SCRIPT>
    <style type="text/css">
    A:link {text-decoration: none}
    A:visited {text-decoration: none}
    A:hover {color: "CC0000"; text-decoration: underline}
    </style>
    <TABLE width="177" cellpadding="3" cellspacing="1" border="0" bgcolor="#000000">
    <TR>
    <TD width="100%" align="center"><FONT face ="Arial Black" color="#CC0000" size="2"></TD>
    </TR>
    <TR bgcolor="#000000">
    <TD width="100%">
    <?PHP
    if ($HTTP_COOKIE_VARS['flippoll'] == $poll_id)
    {
    $total_votes = array_sum($vote_data);
    ?>
    <FONT face ="Arial Black" size="2" color="#CC0000" >
    <?PHP print $vote_options[$debate]; ?>
    <BR /><BR />

    <?PHP
    for ($i = 1; $i <= $n; $i++)
    {
    $percent = $vote_data[$i] / $total_votes * 100;
    $percent = round($percent);
    print "$vote_options[$i] ($percent %) <BR /><IMG src=\"".$root_path."red.jpg\" height=\"16\" width=\"$percent\"><BR />";
    }
    ?>
    <BR />
    </FONT>
    <CENTER>
    <FONT face ="Arial Black" size="2" color="#CC0000" >Voti totali: <?PHP print $total_votes; ?></FONT><BR />
    <?PHP
    }
    else
    {
    ?>
    <FORM method="POST" action="<?PHP print $root_path.'vote.php'; ?>" onsubmit="return OptionChecked();" name="frmPoll">
    <FONT face ="Arial Black" size="2" color="#CC0000" ><?PHP print $vote_options[$debate]; ?><BR /><BR /></FONT>
    <?PHP
    for ($i = 1; $i <= $n; $i++)
    {
    ?>
    <INPUT type="RADIO" name="radPoll" value="<?PHP print $i ?>" />
    <FONT face ="Arial Black" size="2" color="#CC0000"><?PHP print $vote_options[$i]; ?></FONT><BR />
    <?PHP
    }
    ?>
    <INPUT type="hidden" name="id" value="<?PHP print $poll_id ?>" /><BR />
    <CENTER><INPUT type="SUBMIT" value="Vota" name="Submit" /></FORM></CENTER>
    <CENTER>
    <FONT face ="Arial Black" size="1" color="#CC0000" >
    <A href="java script:results()"><FONT face ="Arial Black" size="1" color="#CC0000" >Risultati sondaggio</font></A></FONT><BR />

    <?PHP
    }
    ?>

    </TD>
    </TR>
    </TABLE>
    --------[/code:1:c41ab3e127]


    VOTE.PHP

    [code:1:c41ab3e127]
    code:--------------------------------------------------------------------------------<?PHP
    / ****************************************
    **********************************
    * vote.php (Text)
    * -------------------
    * $Id: vote.php,v 1.12 2002/09/28 16:25:35 d-campbell Exp $
    * For support go to - http://php.pogoworld.co.uk
    * Copyright (C) Duncan Campbell 2002.
    *
    ****************************************
    *********************************/

    / ****************************************
    **********************************
    * *
    * 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. *
    * *
    ****************************************
    *********************************/
    //
    // Poll File Processor
    //

    $option = $HTTP_POST_VARS['radPoll']; // Contains vote number
    $poll_id = $HTTP_POST_VARS['id']; // Poll id, used for cookie and file write.

    include_once('config.php');

    if (!isset ($HTTP_POST_VARS['radPoll']) && !isset ($poll_id))
    {
    display_error('Possible Hacking Attempt!');
    }

    $vote_data[$option] = $vote_data[$option] + 1;

    $fp_write = fopen('data/vote_' . $poll_id . '.csv','w'); // Erases the poll file and re-written
    fwrite($fp_write, 'Poll');
    fwrite($fp_write, ',');

    for ($i = 1; $i <= $n; $i++)
    {
    fwrite($fp_write, $vote_data[$i]);
    fwrite($fp_write, ",");
    }
    fclose ($fp_write);

    setcookie ('flippoll', $poll_id, time()+86400, '/'); // Sends a cookie to the browser.
    header("Location: http://paynegame.altervista.org/voto.htm" . $HTTP_SERVER_VARS['HTTP_REFERER']);
    if (isset ($HTTP_COOKIE_VARS) )
    { while (list ($nome, $valore) = each ( $HTTP_COOKIE_VARS ) )
    { echo "$nome = $valore\n";
    }
    }

    exit;
    //
    // End form processor
    //
    ?>
    ("Pragma: no-cache");--------------------------------------------------------------------------------
    [/code:1:c41ab3e127]


    TEMPLATE1.php (PAGINA IN CUI E' INSTALLATO LO SCRIPT)
    [code:1:c41ab3e127]

    code:--------------------------------------------------------------------------------<HTML>
    <HEAD>
    <style>

    BODY{
    cursor:url("http://vampiresblood.supereva.it/HotWave Mix edition arrow.ani");
    }

    </style>
    <style type="text/css">
    <!--
    body {
    scrollbar-face-color: #404040;
    scrollbar-highlight-color: #303030;
    scrollbar-3dlight-color: #282828;
    scrollbar-darkshadow-color: #303030;
    scrollbar-shadow-color: #282828;
    scrollbar-arrow-color: #000000;
    scrollbar-track-color: #000000;
    scrollbar-darkshadow-color: #4682B4;
    background-image: url('/test/news/25_news/gfx/pagebg.gif');
    }
    select.snewsdropdown {
    background : #DCDCDC;
    color : #0000FF;
    border-style : none;
    font-size : 10pt;
    font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
    font-style : normal;
    font-weight : normal;
    }
    a.morelink {
    font-size : 8pt;
    }
    a.morelink:link {
    color : #191970;
    }
    a.morelink:visited {
    color : #191970;
    }
    a.morelink:activ {
    color : #191970;
    }
    a.catlink:link {
    color : #F0FFFF;
    }
    a.catlink:visited {
    color : #F0FFFF;
    }
    a.catlink:activ {
    color : #F0FFFF;
    }
    a:link {
    color : #FF0000;
    }
    a:visited {
    color : #FF0000;
    }
    a:activ {
    color : #FF0000;
    }
    a.commentlink:link {
    color : #FF0000;
    }
    a.commentlink:visited {
    color : #FF0000;
    }
    a.commentlink:activ {
    color : #FF0000;
    }
    a.pagenav:link {
    color : #FF0000;
    }
    a.pagenav:visited {
    color : #FF0000;
    }
    a.pagenav:activ {
    color : #FF0000;
    }
    a.attach:link {
    color : #FF0000;
    }
    a.attach:visited {
    color : #FF0000;
    }
    a.attach:activ {
    color : #FF0000;
    }
    input.snewsinput {
    background : #0000FF;
    color : #000000;
    border-style : solid;
    border-width : thin;
    border-color : #0000FF;
    font-size : 10pt;
    font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
    font-style : normal;
    font-weight : normal;
    }
    textarea.snewsinput {
    background : #0000FF;
    color : #0000FF;
    border-style : solid;
    border-width : thin;
    border-color : #696969;
    font-size : 10pt;
    font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
    font-style : normal;
    font-weight : normal;
    scrollbar-face-color: #708090;
    scrollbar-highlight-color: #0000FF;
    scrollbar-shadow-color: #0000FF;
    scrollbar-3dlight-color: #0000FF;
    scrollbar-arrow-color: #c0c0c0;
    scrollbar-track-color: #0000FF;
    scrollbar-darkshadow-color: #0000FF;
    }
    input.snewsbutton {
    background : #0000FF;
    color : #0000FF;
    border-style : ridge;
    border-width : thin;
    border-color : #0000FF;
    font-size : 9pt;
    font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
    font-style : normal;
    font-weight : normal;
    }
    a.eventlink {
    font-size : 9pt;
    }
    a.eventshorts {
    font-size : 9pt;
    }
    a.eventlink:link {
    color : #FF0000;
    }
    a.eventshorts:link {
    color : #FF0000;
    }
    a.eventlink:visited {
    color : #FF0000;
    }
    a.eventshorts:visited {
    color : #FF0000;
    }
    a.eventlink:activ {
    color : #FF0000;
    }
    a.eventshorts:activ {
    color : #FF0000;
    }
    a.actionlink:link {
    color : #FF0000;
    }
    a.actionlink:visited {
    color : #FF0000;
    }
    a.actionlink:activ {
    color : #FF0000;
    }
    -->
    </style>
    <TITLE>Sondaggio</TITLE>
    </HEAD>
    <BODY>
    <body bgcolor="#000000">
    <P>
    <center><BR / ><BR />
    <?PHP
    $poll_id = '3'; // example: "x"; means vote_x.csv data_x.csv
    $root_path = './'; // Directory where poll files are. ./ = current directory.
    include($root_path.'poll.php');
    ?>
    <BR /><BR />
    </P>
    </BODY>
    </HTML>
    </center>--------------------------------------------------------------------------------

    [/code:1:c41ab3e127]

  2. #2
    Guest

    Predefinito

    non trova questa pagina, controlla nome e path!!

    http://paynegame.altervista.org/voto.htm

  3. #3
    Guest

    Predefinito

    Guarda che quella pagina è un redirect che ho messo io apposta, quindi esiste eccome...

  4. #4
    Guest

    Predefinito

    già, ora funziona, prima mi dava pagina non trovata.... mi caricava la tua not_found.htm...

  5. #5
    Guest

    Predefinito

    eheh :)
    Chiedo qui perchè su html.it ho lasciato una ventina di up e nessuno si è degnato di darmi una risposta....

    Dove può essere il problema? Cosa mi consigli di fare?
    In qualche post ho letto che è il config della root path che non va, ma io che caspita posso fare??

  6. #6
    Guest

    Predefinito

    Trovato!!!! ed è anche per questo che prima non me la trovava, guarda:
    [code:1:9210613228]
    header("Location: http://paynegame.altervista.org/voto.htm" . $HTTP_SERVER_VARS['HTTP_REFERER']);
    [/code:1:9210613228]

    al posto di qeusta, metti:
    [code:1:9210613228]
    header("Location: http://paynegame.altervista.org/voto.htm" );
    [/code:1:9210613228]

    heheheh, lo dicevo io che c'era qualcosa che non andava in quel link!!!!

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •