Keine aktive Umfrage in der DB vorhanden!

Gesperrt
Invent_06
Beiträge: 19
Registriert: So 29. Okt 2006, 13:18
Kontaktdaten:

Keine aktive Umfrage in der DB vorhanden!

Beitrag von Invent_06 »

Hallo Forum,

Ich versuche gerade eine Umfrage auf meiner HP einzubauen.
Leider werden keine Fragen in der Datenbank gespeichert. Was mache ich falsch?



Code: Alles auswählen

/********************************************************
* CONTENIDO MODUL - INPUT
*
* Modulname   :     Umfrage
* Author      :     Alexander Höhn
* Copyright   :     art & weise medienproduktion
                    info@auw-media.de
* Created     :     16-09-2002
* Modified    :     04-07-2003
* Modified again & again until:   May. 18th 2004 by Lars D. Forseth <lars@forseth.de>
*********************************************************/



/* debugging? */
$debugging = "no";
/* end "debugging?" */


/* debugging stuff */
if ($debugging == "yes") {
  echo "
  - poll_action: $poll_action<br>
  - poll_id_active: $poll_id_active<br>
  - poll_subaction: $poll_subaction<br>
  - poll_reset: $poll_reset<br>
  ";
}
/* end "debugging stuff" */


$db0 = new DB_Contenido;
$db0->query("LOCK TABLES poll WRITE,poll_log WRITE;"); // lock tables


switch($poll_action){

//-------------------------- Speichern der Daten in die Tabelle ------------------------------
  case "save_poll" : {


                       if("CMS_VALUE[96]" == "") {$poll_answer3 = " ";}
                       else {
                         $poll_answer3 = "CMS_VALUE[96]";
                         $poll_answer3 = str_replace (";","",$poll_answer3);
                         $poll_answer3 = str_replace ("--","",$poll_answer3);
                         $poll_answer3 = str_replace ("'","",$poll_answer3);
                         $poll_answer3 = htmlentities($poll_answer3);
                       }
                       if("CMS_VALUE[95]" == "") {$poll_answer4 = " ";}
                       else {
                         $poll_answer4 = "CMS_VALUE[95]";
                         $poll_answer4 = str_replace (";","",$poll_answer4);
                         $poll_answer4 = str_replace ("--","",$poll_answer4);
                         $poll_answer4 = str_replace ("'","",$poll_answer4);
                         $poll_answer4 = htmlentities($poll_answer4);
                       }
                       if($CMS_VAR[94] == "") {$poll_answer5 = " ";}
                       else {
                         $poll_answer5 = $CMS_VAR[94];
                         $poll_answer5 = str_replace (";","",$poll_answer5);
                         $poll_answer5 = str_replace ("--","",$poll_answer5);
                         $poll_answer5 = str_replace ("'","",$poll_answer5);
                         $poll_answer5 = htmlentities($poll_answer5);
                       }
                       if($CMS_VAR[93] == "") {$poll_answer6 = " ";}
                       else {
                         $poll_answer6 = $CMS_VAR[93];
                         $poll_answer6 = str_replace (";","",$poll_answer6);
                         $poll_answer6 = str_replace ("--","",$poll_answer6);
                         $poll_answer6 = str_replace ("'","",$poll_answer6);
                         $poll_answer6 = htmlentities($poll_answer6);
                       }

                       /* filter given data */
                       $poll_question = str_replace (";","","CMS_VALUE[99]");
                       $poll_question = str_replace ("--","",$poll_question);
                       $poll_question = str_replace ("'","",$poll_question);
                       $poll_question = htmlentities($poll_question);

                       $poll_answer1 = "CMS_VALUE[98]";
                       $poll_answer1 = str_replace (";","",$poll_answer1);
                       $poll_answer1 = str_replace ("--","",$poll_answer1);
                       $poll_answer1 = str_replace ("'","",$poll_answer1);
                       $poll_answer1 = htmlentities($poll_answer1);

                       $poll_answer2 = "CMS_VALUE[97]";
                       $poll_answer2 = str_replace (";","",$poll_answer2);
                       $poll_answer2 = str_replace ("--","",$poll_answer2);
                       $poll_answer2 = str_replace ("'","",$poll_answer2);
                       $poll_answer2 = htmlentities($poll_answer2);

                       $db1 = new DB_Contenido;


                       /* if one tries to edit a non-existing poll, let him create it as a new poll */
                       if (($poll_id_active <= 0) and ($poll_subaction == "edit_poll")) {
                         $poll_subaction = "new_poll";
                       }
                       if ($debugging == "yes") echo "- poll_subaction: $poll_subaction<br>";
                       /* end "if one tries to edit a non-existing poll, let him create it as a new poll" */



                       /* create new poll */
                       if ($poll_subaction == "new_poll") {
                         $sql1 = "INSERT INTO poll VALUES (\"\", \"".$poll_question."\", ".
                                 "\"".$poll_answer1."\", \"".$poll_answer2."\", \"".$poll_answer3.
                                 "\", \"".$poll_answer4."\", \"".$poll_answer5."\", \"".$poll_answer6.
                                 "\", \"0\");";
                         $db1->query($sql1);
                       }
                       /* end "create new poll" */


                       /* edit existing poll */
                       if ($poll_subaction == "edit_poll") {
                         $sql1 = "UPDATE poll SET poll_question=\"".$poll_question."\", ".
                                 "poll_answer1=\"".$poll_answer1."\", poll_answer2=\"".$poll_answer2."\", ".
                                 "poll_answer3=\"".$poll_answer3."\", poll_answer4=\"".$poll_answer4."\", ".
                                 "poll_answer5=\"".$poll_answer5."\", poll_answer6=\"".$poll_answer6."\", ".
                                 "poll_active=1 WHERE poll_id=".$poll_id_active.";";
                         $db1->query($sql1);
                       }
                       /* end "edit existing poll" */


                       /* reset vote counter */
                       if($poll_reset == "yes") {
                         $sql1_2 = "DELETE FROM poll_log WHERE poll_id=".$poll_id_active.";";
                         $db1->query($sql1_2);
                       }
                       /* end "reset vote counter" */

                     } // end " case "save_poll" "


  case "activate_poll" :     {

//--------------------------- Aktivieren der gewünschten Frage --------------------------------
                      $poll_question = str_replace (";","","CMS_VALUE[92]");
                      $poll_question = str_replace ("--","",$poll_question);
                      $poll_question = str_replace ("'","",$poll_question);
                      $poll_question = htmlentities($poll_question);

                      $db3 = new DB_Contenido;
                      $db3->query("UPDATE poll SET poll_active=0;");
                      $db3->query("UPDATE poll SET poll_active=1 WHERE poll_question=\"".$poll_question."\";");

                      break;
                     } // end " case "activate_poll" "
  } //  end switch




echo "

<!-- start Umfragenmodul backend -->

<table>
";
echo "  <tr bgcolor=\"#FFFFE0\">
         <td colspan='2'>
          <font size='2' face='Verdana'>
           <b>HINWEISE:</b><br><br>
           <font color=\"darkblue\"><p style=\"padding-left: 10px;\">
           Durch "Speichern" wird die aktuelle Umfrage nicht aktiviert,<br>
           sondern nur in der Datenbank gespeichert.<br>
           Eine Umfrage bearbeiten oder neu anlegen, geht natürlich nur,<br>
           wenn die entsprechende Option ausgewählt und dann auf <br>
           "Speichern" geklickt wurde!<br>
           Eine Umfrage aktivieren kann man, in dem man sie <br>
           in dem Drop-Down-Menü auswählt und dann auf "Aktivieren" klickt.<br>
           </p></font>
          </font>
         </td>
        </tr>";
echo "<tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>";

$db2 = new DB_Contenido;
$sql2 = "SELECT * FROM poll WHERE poll_active=1;";
$db2->query($sql2);
$db2->next_record();
$poll_question_active   = $db2->f("poll_question");
$poll_answer1_active    = $db2->f("poll_answer1");
$poll_answer2_active    = $db2->f("poll_answer2");
$poll_answer3_active    = $db2->f("poll_answer3");
$poll_answer4_active    = $db2->f("poll_answer4");
$poll_answer5_active    = $db2->f("poll_answer5");
$poll_answer6_active    = $db2->f("poll_answer6");
$poll_id_active         = $db2->f("poll_id");

echo "  <tr bgcolor=\"#FFFFE0\">
         <td colspan='2'>
          <font size='2' face='Verdana'><b>
           Momentan ist folgende Umfrage aktiv:<br>
           <i style=\"padding-left: 10px;\">\"$poll_question_active\"</i>
          </b></font>
         </td>
        </tr>
        ";



echo "
     <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>";
echo "
    <tr>
        <td colspan=\"2\">
         <u>Aktion:</u><br><br>
         <input type=\"radio\" name=\"poll_action\" value=\"save_poll\">
         &nbsp;&nbsp;Umfrage mit eine der beiden folgenden Funktionen abspeichern:
         <p style=\"padding-left: 30px;\">
         <input type=\"radio\" name=\"poll_subaction\" value=\"edit_poll\">
         &nbsp;&nbsp;momentan aktive Umfrage bearbeiten
         <br>
         <input type=\"radio\" name=\"poll_subaction\" value=\"new_poll\">
         &nbsp;&nbsp;neue Umfrage anlegen
         </p>
        </td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>Frage :</td>
        <td><input type=\"text\" name=\"CMS_VAR[99]\" value=\"$poll_question_active\"></td>
    </tr>
    <tr>
        <td>Antwort 1 :</td>
        <td><input type=\"text\" name=\"CMS_VAR[98]\" value=\"$poll_answer1_active\"></td>
    </tr>
    <tr>
        <td>Antwort 2 :</td>
        <td><input type=\"text\" name=\"CMS_VAR[97]\" value=\"$poll_answer2_active\"></td>
    </tr>
    <tr>
        <td>Antwort 3:</td>
        <td><input type=\"text\" name=\"CMS_VAR[96]\" value=\"$poll_answer3_active\"></td>
    </tr>
    <tr>
        <td>Antwort 4 :</td>
        <td><input type=\"text\" name=\"CMS_VAR[95]\" value=\"$poll_answer4_active\"></td>
    </tr>
    <tr>
        <td>Antwort 5 :</td>
        <td><input type=\"text\" name=\"CMS_VAR[94]\" value=\"$poll_answer5_active\"></td>
    </tr>
    <tr>
        <td>Antwort 6 :</td>
        <td><input type=\"text\" name=\"CMS_VAR[93]\" value=\"$poll_answer6_active\"></td>
    </tr>
    <tr>
     <td> Alle Z&auml;hler auf 0 setzen:</td>
     <td><input type=\"checkbox\" name=\"poll_reset\" value=\"yes\"></td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>

    <tr>
        <td>&nbsp;</td>
        <td>
         <input type=\"hidden\" name=\"poll_id_active\" value=\"$poll_id_active\">
        </td>
    </tr>
    <tr>
        <td colspan=\"2\"><center>";



//---------------------- Darstellung aller Umfragen in einer drop-down Liste --------------------------------

$db4 = new DB_Contenido;
$db4->query("SELECT * FROM poll;");
$db4->next_record();
$test = $db4->f("poll_id");

if (!$test) {
  $sql4 = "CREATE TABLE poll (poll_id int(11) NOT NULL auto_increment, poll_question text NOT NULL, ".
          "poll_answer1 text NOT NULL, poll_answer2 text NOT NULL, poll_answer3 text NOT NULL, ".
          "poll_answer4 text NOT NULL, poll_answer5 text NOT NULL, poll_answer6 text NOT NULL, ".
          "poll_active int(1) default NULL, PRIMARY KEY  (poll_id) ) TYPE=MyISAM;";
  $db4->query("SELECT * FROM poll;");
  $db4->next_record();
} // if DB doesn't exist yet, create it

echo "
         <input type=\"radio\" name=\"poll_action\" value=\"activate_poll\">
         &nbsp;&nbsp;Umfrage aus der Liste auswählen und aktivieren:
         <br>
         <select name=\"CMS_VAR[92]\" size=\"1\">";

for($i=0; $i<$db4->num_rows(); $i++){
  if(($db4->f("poll_id")) == $poll_id_active) {$a = " selected";}
  else {$a = "";}
  echo "
          <option value=\"".$db4->f("poll_question")."\"$a>".$db4->f("poll_question")."</option>";
  $db4->next_record();
} // end for

echo "
         </select>" ;

echo "
        </td>
    </tr>
    <tr>
     <td colspan=\"2\">
      <center>
    ";




/* print statistic of current poll */

if ($poll_id_active > 0) {

$db = new DB_Contenido;

$db->query("SELECT COUNT(*) FROM poll_log WHERE poll_id=$poll_id_active;");
$db->next_record();
$test = $db->f("COUNT(*)");

if ($test > 0) {


$db->query("SELECT COUNT(*) FROM poll_log WHERE poll_id=$poll_id_active and user_vote=1;");
$db->next_record();
$result1 = $db->f("COUNT(*)");

$db->query("SELECT COUNT(*) FROM poll_log WHERE poll_id=$poll_id_active and user_vote=2;");
$db->next_record();
$result2 = $db->f("COUNT(*)");

$db->query("SELECT COUNT(*) FROM poll_log WHERE poll_id=$poll_id_active and user_vote=3;");
$db->next_record();
$result3 = $db->f("COUNT(*)");

$db->query("SELECT COUNT(*) FROM poll_log WHERE poll_id=$poll_id_active and user_vote=4;");
$db->next_record();
$result4 = $db->f("COUNT(*)");

$db->query("SELECT COUNT(*) FROM poll_log WHERE poll_id=$poll_id_active and user_vote=5;");
$db->next_record();
$result5 = $db->f("COUNT(*)");

$db->query("SELECT COUNT(*) FROM poll_log WHERE poll_id=$poll_id_active and user_vote=6;");
$db->next_record();
$result6 = $db->f("COUNT(*)");

$total = $result1+$result2+$result3+$result4+$result5+$result6;

echo "
  <br><br>
  <p style=\"FONT-SIZE: 12px; COLOR: #000000;FONT-FAMILY: helvetica, arial, geneva, sans-serif;\"><b>Statistik der momentan aktiven Umfrage:</b></p>
  <br><br>
  <table width=\"165\" cellspacing=\"0\" cellpadding=\"2\" style=\"BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid;
        MARGIN-BOTTOM: 3pt; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid;
        BACKGROUND-COLOR: #efefef;\">";

echo "
   <tr style=\"padding-left: 8px; padding-right: 8x; padding-top: 5px; padding-bottom: 3px;
        font-family: Verdana; font-size: 10pt; color: darkblue; BACKGROUND-COLOR: #efefef;\"><td>".$poll_question_active."</td></tr><tr><td>&nbsp;</td></tr>";

echo "
   <tr style=\"FONT-SIZE: 12px; COLOR: #000000;FONT-FAMILY: helvetica, arial, geneva, sans-serif;\"><td><i><u>Gesamt:</u> ".$total." Stimmen</i></td></tr><tr><td>&nbsp;</td></tr>";


if (($result1 > 0) and ($total > 0)) $percent = round(((100*$result1)/$total), 2);
if($result1!="0") $color1= "cornflowerblue";
if ($percent < 5.00) $color1 = "";
echo "
   <tr style=\"FONT-SIZE: 12px; COLOR: #000000;FONT-FAMILY: helvetica, arial, geneva, sans-serif;\"><td>\"<b>".$poll_answer1_active."</b>\" (".$result1.") :</td></tr>";
echo "
   <tr><td>
    <table><tr style=\"FONT-SIZE: 12px; COLOR: #000000;FONT-FAMILY: helvetica, arial, geneva, sans-serif;\"><td bgcolor=\"".$color1."\" width=\"".$percent."\">&nbsp;</td></tr></table>";
echo "
   </td></tr>
  ";

if (($result2 > 0) and ($total > 0)) $percent = round(((100*$result2)/$total), 2);
if($result2!="0") $color2= "skyblue";
if ($percent < 5.00) $color2 = "";
echo "
   <tr style=\"FONT-SIZE: 12px; COLOR: #000000;FONT-FAMILY: helvetica, arial, geneva, sans-serif;\"><td>\"<b>".$poll_answer2_active."</b>\" (".$result2.") :</td></tr>";
echo "
   <tr><td>
    <table><tr style=\"FONT-SIZE: 12px; COLOR: #000000;FONT-FAMILY: helvetica, arial, geneva, sans-serif;\"><td bgcolor=\"".$color2."\" width=\"".$percent."\">&nbsp;</td></tr></table>";
echo "
   </td></tr>
  ";

if(strlen($poll_answer3_active) > 1){
  if (($result3 > 0) and ($total > 0)) $percent = round(((100*$result3)/$total), 2);
  if($result3!="0") $color3= "lightskyblue";
  if ($percent < 5.00) $color3 = "";
  echo "
   <tr style=\"FONT-SIZE: 12px; COLOR: #000000;FONT-FAMILY: helvetica, arial, geneva, sans-serif;\"><td>\"<b>".$poll_answer3_active."</b>\" (".$result3.") :</td></tr>";
  echo "
   <tr><td>
    <table><tr style=\"FONT-SIZE: 12px; COLOR: #000000;FONT-FAMILY: helvetica, arial, geneva, sans-serif;\"><td bgcolor=\"".$color3."\" width=\"".$percent."\">&nbsp;</td></tr></table>";
  echo "
   </td></tr>
    ";
}

if(strlen($poll_answer4_active) > 1){
  if (($result4 > 0) and ($total > 0)) $percent = round(((100*$result4)/$total), 2);
  if($result4!="0") $color4= "lightblue";
  if ($percent < 5.00) $color4 = "";
  echo "
   <tr style=\"FONT-SIZE: 12px; COLOR: #000000;FONT-FAMILY: helvetica, arial, geneva, sans-serif;\"><td>\"<b>".$poll_answer4_active."</b>\" (".$result4.") :</td></tr>";
  echo "
   <tr><td>
    <table><tr style=\"FONT-SIZE: 12px; COLOR: #000000;FONT-FAMILY: helvetica, arial, geneva, sans-serif;\"><td bgcolor=\"".$color4."\" width=\"".$percent."\">&nbsp;</td></tr></table>";
  echo "
   </td></tr>
    ";
  }

if(strlen($poll_answer5_active) > 1){
  if (($result5 > 0) and ($total > 0)) $percent = round(((100*$result5)/$total), 2);
  if($result5!="0") $color5= "lightsteelblue";
  if ($percent < 5.00) $color5 = "";
  echo "
   <tr style=\"FONT-SIZE: 12px; COLOR: #000000;FONT-FAMILY: helvetica, arial, geneva, sans-serif;\"><td>\"<b>".$poll_answer5_active."</b>\" (".$result5.") :</td></tr>";
  echo "
   <tr><td>
    <table><tr style=\"FONT-SIZE: 12px; COLOR: #000000;FONT-FAMILY: helvetica, arial, geneva, sans-serif;\"><td bgcolor=\"".$color5."\" width=\"".$percent."\">&nbsp;</td></tr></table>";
  echo "
   </td></tr>
    ";
  }

if(strlen($poll_answer6_active) > 1){
  if (($result6 > 0) and ($total > 0)) $percent = round(((100*$result6)/$total), 2);
  if($result6!="0") $color6= "darkgray";
  if ($percent < 5.00) $color6 = "";
  echo "
   <tr style=\"FONT-SIZE: 12px; COLOR: #000000;FONT-FAMILY: helvetica, arial, geneva, sans-serif;\"><td>\"<b>".$poll_answer6_active."</b>\" (".$result6.") :</td></tr>";
  echo "
   <tr><td>
    <table><tr style=\"FONT-SIZE: 12px; COLOR: #000000;FONT-FAMILY: helvetica, arial, geneva, sans-serif;\"><td bgcolor=\"".$color6."\" width=\"".$percent."\">&nbsp;</td></tr></table>";
  echo "
   </td></tr>
    ";
}


echo "
</table>

";

} // end "if (isset($test))"
} // end "if (isset($poll_id_active))"


/* end of modul*/
echo "
   </center>
  </td>
 </tr>
</table>

<!-- end Umfragenmodul backend -->

";

$db0->query("UNLOCK TABLES;"); // unlock tables







<?php

/********************************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname   :     Umfrage
* Author      :     Alexander Höhn
* Copyright   :     art & weise medienproduktion
                    info@auw-media.de
* Created     :     16-09-2002
* Modified    :     04-07-2003
* Modified again & again until:   May. 12th 2004 by Lars D. Forseth <lars@forseth.de>
*********************************************************/



/* set this to "yes" if you want to run script in debugging mode */
$debugging = "no";
/* end "set this to "yes" if you want to run script in debugging mode" */


/* get only vars accepted by POST or GET */
$poll_action = $_POST['poll_action'];
$given_answer = $_POST['given_answer'];
$poll_stats = $_GET['poll_stats'];
if ($debugging == "yes") echo "- poll_action: $poll_action<br>";
if ($debugging == "yes") echo "- given_answer: $given_answer<br>";
if ($debugging == "yes") echo "- poll_stats: $poll_stats<br>";
if ($debugging == "yes") echo "- cookie: ".($_COOKIE['poll'])."<br>";
/* end "get only vars accepted by POST or GET" */


$db1 = new DB_Contenido;

/* lock tables */
$db1->query("LOCK TABLES poll WRITE,poll_log WRITE;");
/* end "lock tables" */

/* get * from active poll */
$db1->query("SELECT * FROM poll WHERE poll_active=1 LIMIT 1;");
$db1->next_record();
$poll_id_active         = $db1->f("poll_id");

/* no active poll in DB */
if (!isset($poll_id_active)) {echo "Keine aktive Umfrage in der DB vorhanden!";}
/* end "no active poll in DB" */

/* there is an active poll in DB */
else {

$poll_question_active   = $db1->f("poll_question");
$poll_answer1_active    = $db1->f("poll_answer1");
$poll_answer2_active    = $db1->f("poll_answer2");
$poll_answer3_active    = $db1->f("poll_answer3");
$poll_answer4_active    = $db1->f("poll_answer4");
$poll_answer5_active    = $db1->f("poll_answer5");
$poll_answer6_active    = $db1->f("poll_answer6");
if ($debugging == "yes") echo "- poll_id_active: $poll_id_active<br>";
/* end "get od from active poll" */

/* get user's ip and proxy ip */
$user_ip = $_SERVER['REMOTE_ADDR'];
$user_proxy = $_SERVER['HTTP_X_FORWARDED_FOR'];
/* end "get user's ip and proxy ip" */



/* user is only allowed to vote if cookies are enabled and his IP isn't blocked (anymore) */

if ($poll_stats == "yes") {$poll_action = "vote"; $given_answer = 666;}

if ($poll_action == "vote") {

  $db0 = new DB_Contenido;
  $sql = "SELECT poll_log_id,user_time FROM poll_log WHERE poll_id=$poll_id_active ".
         "and user_ip='$user_ip' ORDER BY user_time DESC LIMIT 1;";
  $db0->query($sql);
  $db0->next_record();
  $poll_log_id = $db0->f("poll_log_id");
  $user_time = $db0->f("user_time");

  if ($debugging == "yes") {
    echo "- poll_action: $poll_action<br>";
    echo "- poll_id_active: $poll_id_active<br>";
    echo "- user_time: $user_time<br>- poll_log_id: $poll_log_id<br>";
  } // end if ($debugging == "yes")


  if ((isset($user_time)) and (isset($poll_log_id))) {
    if ($debugging == "yes") echo "- user_time: $user_time<br>- poll_log_id: $poll_log_id<br>";
    $block_seconds        = 0;
    $block_minutes        = 15;
    $block_hours          = 0;
    $block_days           = 0;
    $block_months         = 0;
    $block_total          = ($block_seconds + ($block_minutes * 60) + ($block_hours * 60 * 60)
                            + ($block_days * 60 * 60 * 24) + ($block_months * 60 * 60 * 24 * 30));
    // IP is still blocked
    if ((time()) < ($user_time + $block_total)) {
      $poll_stats = "yes";
      $given_answer = 666;
      if ($debugging == "yes") echo "- poll_stats: $poll_stats<br>- given_answer: $given_answer<br>";
      $db0->query("UPDATE poll_log SET user_time=UNIX_TIMESTAMP() WHERE poll_log_id=$poll_log_id;");
    } // end if
  } // end if

} // end if

/* end "user is only allowed to vote if cookies are enabled" and his IP isn't blocked (anymore) */




echo "

<!-- umfragenmodul -->
";



/* allowed to vote and no form data given -> show poll form */
if((($_COOKIE['poll']) == "poll_allowed")
   and ($poll_action != "vote") and ($poll_stats != "yes")){

  $links = explode('?',$auth->url());
  $links2 = explode('&',$links[1]);
  $link = $links[0].'?'.$links2[0];
  if ($debugging == "yes") echo "- link: $link<br>";

  echo "
  <form action=\"$link\" method=\"post\" name=\"poll_form\">";

  echo "

  <table width=\"165\" cellspacing=\"0\" cellpadding=\"2\" class=\"poll\">
   <tr>
    <td colspan=\"2\" align=\"left\" class=\"poll_question\">$poll_question_active<br></td>
   </tr>
   <tr><td colspan=\"2\">&nbsp;</td></tr>
   <tr class=\"text\">
    <td width=\"25\"></td><td><input value=\"1\" type=\"radio\" name=\"given_answer\">&nbsp;&nbsp;$poll_answer1_active</td>
   </tr>
   <tr class=\"text\">
    <td width=\"25\" ></td><td><input value=\"2\" type=\"radio\" name=\"given_answer\">&nbsp;&nbsp;$poll_answer2_active</td>
   </tr>";

  // poll_answer3 to poll_answer6 are optional...
  if(strlen($poll_answer3_active) > 1)
     echo "
   <tr class=\"text\">
    <td width=\"25\" ></td><td><input value=\"3\" type=\"radio\" name=\"given_answer\">&nbsp;&nbsp;$poll_answer3_active</td>
   </tr>";
  if(strlen($poll_answer4_active) > 1)
     echo "
   <tr class=\"text\">
    <td width=\"25\" ></td><td><input value=\"4\" type=\"radio\" name=\"given_answer\">&nbsp;&nbsp;$poll_answer4_active</td>
   </tr>";
  if(strlen($poll_answer5_active) > 1)
     echo "
   <tr class=\"text\">
    <td width=\"25\" ></td><td><input value=\"5\" type=\"radio\" name=\"given_answer\">&nbsp;&nbsp;$poll_answer5_active</td>
   </tr>";
  if(strlen($poll_answer6_active) > 1)
     echo "
   <tr class=\"text\">
    <td width=\"25\" ></td><td><input value=\"6\" type=\"radio\" name=\"given_answer\">&nbsp;&nbsp;$poll_answer6_active</td>
   </tr>";
  echo "<tr>
    <td>&nbsp;</td><td>&nbsp;</td>
   </tr class=\"text\">
   <tr>
    <td colspan =\"2\">
     <input type=\"hidden\" name=\"poll_id\" value=\"".$poll_id_active."\">
     <input type=\"hidden\" name=\"poll_action\" value=\"vote\">
     <center><input type=\"submit\" class=\"poll_button\" value=\"Abstimmen\"><br>

    <!-- end of poll_form -->
    </form>
    <!--             -->
   </tr>";

} /* end "allowed to vote and no form data given -> show poll form" */


/* show poll stats and store vote if there was one given */
else {

  $db = new DB_Contenido;

  // if given_answer is valid, store it in poll_log
  if ((ereg("^[1-6]{1}$",$given_answer)) and ($poll_stats != "yes")) {
    if ($debugging == "yes") echo "- given_answer: $given_answer<br>- poll_stats: $poll_stats<br>";
    $sql = "INSERT INTO poll_log VALUES (\"\",$poll_id_active,".
           "$given_answer,\"$user_ip\",\"$user_proxy\",UNIX_TIMESTAMP());";
    $db->query($sql);
  } // end if



  $db->query("SELECT COUNT(*) FROM poll_log WHERE poll_id=$poll_id_active and user_vote=1;");
  $db->next_record();
  $result1 = $db->f("COUNT(*)");

  $db->query("SELECT COUNT(*) FROM poll_log WHERE poll_id=$poll_id_active and user_vote=2;");
  $db->next_record();
  $result2 = $db->f("COUNT(*)");

  $db->query("SELECT COUNT(*) FROM poll_log WHERE poll_id=$poll_id_active and user_vote=3;");
  $db->next_record();
  $result3 = $db->f("COUNT(*)");

  $db->query("SELECT COUNT(*) FROM poll_log WHERE poll_id=$poll_id_active and user_vote=4;");
  $db->next_record();
  $result4 = $db->f("COUNT(*)");

  $db->query("SELECT COUNT(*) FROM poll_log WHERE poll_id=$poll_id_active and user_vote=5;");
  $db->next_record();
  $result5 = $db->f("COUNT(*)");

  $db->query("SELECT COUNT(*) FROM poll_log WHERE poll_id=$poll_id_active and user_vote=6;");
  $db->next_record();
  $result6 = $db->f("COUNT(*)");

  $total = $result1+$result2+$result3+$result4+$result5+$result6;

  echo "
  <table width=\"165\" cellspacing=\"0\" cellpadding=\"2\" class=\"poll\">";

  echo "
   <tr class=\"poll_question\"><td>".$poll_question_active."</td></tr><tr><td>&nbsp;</td></tr>";

  echo "
   <tr class=\"text\"><td><i><u>Gesamt:</u> ".$total." Stimmen</i></td></tr><tr><td>&nbsp;</td></tr>";


  if (($result1 > 0) and ($total > 0)) $percent = round(((100*$result1)/$total), 2);
  if($result1!="0") $class1= "bar1";
  if ($percent < 5.00) $class1 = "";
  echo "
   <tr class=\"text\"><td>\"<b>".$poll_answer1_active."</b>\" (".$result1.") :</td></tr>";
  echo "
   <tr><td>
    <table><tr class=\"text\"><td class=\"".$class1."\" width=\"".$percent."\">&nbsp;</td></tr></table>";
  echo "
   </td></tr>
  ";

  if (($result2 > 0) and ($total > 0)) $percent = round(((100*$result2)/$total), 2);
  if($result2!="0") $class2= "bar2";
  if ($percent < 5.00) $class2 = "";
  echo "
   <tr class=\"text\"><td>\"<b>".$poll_answer2_active."</b>\" (".$result2.") :</td></tr>";
  echo "
   <tr><td>
    <table><tr class=\"text\"><td class=\"".$class2."\" width=\"".$percent."\">&nbsp;</td></tr></table>";
  echo "
   </td></tr>
  ";

  if(strlen($poll_answer3_active) > 1){
    if (($result3 > 0) and ($total > 0)) $percent = round(((100*$result3)/$total), 2);
    if($result3!="0") $class3= "bar3";
    if ($percent < 5.00) $class3 = "";
    echo "
   <tr class=\"text\"><td>\"<b>".$poll_answer3_active."</b>\" (".$result3.") :</td></tr>";
    echo "
   <tr><td>
    <table><tr class=\"text\"><td class=\"".$class3."\" width=\"".$percent."\">&nbsp;</td></tr></table>";
    echo "
   </td></tr>
    ";
  }

  if(strlen($poll_answer4_active) > 1){
    if (($result4 > 0) and ($total > 0)) $percent = round(((100*$result4)/$total), 2);
    if($result4!="0") $class4= "bar4";
    if ($percent < 5.00) $class4 = "";
    echo "
   <tr class=\"text\"><td>\"<b>".$poll_answer4_active."</b>\" (".$result4.") :</td></tr>";
    echo "
   <tr><td>
    <table><tr class=\"text\"><td class=\"".$class4."\" width=\"".$percent."\">&nbsp;</td></tr></table>";
    echo "
   </td></tr>
    ";
  }

  if(strlen($poll_answer5_active) > 1){
    if (($result5 > 0) and ($total > 0)) $percent = round(((100*$result5)/$total), 2);
    if($result5!="0") $class5= "bar5";
    if ($percent < 5.00) $class5 = "";
    echo "
   <tr class=\"text\"><td>\"<b>".$poll_answer5_active."</b>\" (".$result5.") :</td></tr>";
    echo "
   <tr><td>
    <table><tr class=\"text\"><td class=\"".$class5."\" width=\"".$percent."\">&nbsp;</td></tr></table>";
    echo "
   </td></tr>
    ";
  }

  if(strlen($poll_answer6_active) > 1){
    if (($result6 > 0) and ($total > 0)) $percent = round(((100*$result6)/$total), 2);
    if($result6!="0") $class6= "bar6";
    if ($percent < 5.00) $class6 = "";
    echo "
   <tr class=\"text\"><td>\"<b>".$poll_answer6_active."</b>\" (".$result6.") :</td></tr>";
    echo "
   <tr><td>
    <table><tr class=\"text\"><td class=\"".$class6."\" width=\"".$percent."\">&nbsp;</td></tr></table>";
    echo "
   </td></tr>
    ";
  }


} // end else


/* print stats link only if stats aren't displayed already */
if ((($_COOKIE['poll']) == "poll_allowed") and ($poll_action != "vote") and ($poll_stats != "yes")) {
  echo "
    <!-- poll_stats button -->
     <tr>
      <td colspan=\"2\" align=\"center\">
       <div align=\"center\"><a href=\"$PHP_SELF?idcat=$idcat&poll_stats=yes\">Statistik &raquo;</a></div>
      </td>
     </tr>
    <!-- end poll_stats button -->";
}
/* end "print stats link only if stats aren't displayed already" */


echo "

 </table>
";

}
/* end "there is an active poll in DB" */


echo "

<!-- end umfragenmodul -->


";

/* unlock tables */
$db1->query("UNLOCK TABLES;");
/* end "unlock tables" */

?>

Zuletzt geändert von Invent_06 am Mo 20. Nov 2006, 12:13, insgesamt 1-mal geändert.
votapero
Beiträge: 63
Registriert: Do 9. Mär 2006, 15:04
Kontaktdaten:

Beitrag von votapero »

Hast du die Tabelle angelegt? Es gibt ein SQL Script um die Tabelle für das voting zu erstellen. Ohne gehts nicht....und nicht vergessen den Cookie-Code einzubauen.

Aber benutze doch die bestehenden Themen. Suche mal nach Forseth oder Umfrage.
Gruss
HerrB
Beiträge: 6935
Registriert: Do 22. Mai 2003, 12:44
Wohnort: Berlin
Kontaktdaten:

Beitrag von HerrB »

Und für Code gibt es diesen schönen "Code"-Button beim Erstellen von Beiträgen...

Gruß
HerrB
Bitte keine unaufgeforderten PMs oder E-Mails -> use da Forum!

Newsletter: V4.4.x | V4.6.0-15 (Module, Backend) | V4.6.22+
Standardartikelliste: V4.4.x | V4.6.x
http://www.contenido.org/forum/search.php | http://faq.contenido.org | http://www.communido.net
Invent_06
Beiträge: 19
Registriert: So 29. Okt 2006, 13:18
Kontaktdaten:

Beitrag von Invent_06 »

HerrB hat geschrieben:Und für Code gibt es diesen schönen "Code"-Button beim Erstellen von Beiträgen...

Gruß
HerrB
Sorry beim nächsten mal :oops:
Dodger77
Beiträge: 3626
Registriert: Di 12. Okt 2004, 20:00
Wohnort: Voerde (Niederrhein)
Kontaktdaten:

Beitrag von Dodger77 »

Invent_06 hat geschrieben:Sorry beim nächsten mal :oops:
Es gibt ja auch noch einen "edit"-Button. :wink:
Invent_06
Beiträge: 19
Registriert: So 29. Okt 2006, 13:18
Kontaktdaten:

Ich finde es nicht!

Beitrag von Invent_06 »

Leider finde ich das SQL Script nicht um die Tabelle für das voting zu erstellen. Genau so den Cookie-Code.

In der Suche kommt einiges, aber ich bin mir nicht sicher welches ich nehmen soll.

:cry:
schlaucher
Beiträge: 444
Registriert: Mi 14. Sep 2005, 10:38
Wohnort: Karlsruhe
Kontaktdaten:

Re: Ich finde es nicht!

Beitrag von schlaucher »

Invent_06 hat geschrieben:Leider finde ich das SQL Script nicht um die Tabelle für das voting zu erstellen. Genau so den Cookie-Code.

In der Suche kommt einiges, aber ich bin mir nicht sicher welches ich nehmen soll.

:cry:
schau mal hier: http://www.x28.de/front_content.php?cli ... =412&m=&s=

Gruß
schlaucher
Gesperrt