Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Add voting to your site  (Read 2935 times)

0 Members and 1 Guest are viewing this topic.

carefree

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 32
Add voting to your site
« on: August 02, 2007, 11:32:27 am »

Ok heres the voting MOD. Add it to anycontent or template

See it live here: http://www.freexxxhunters.com/all   //Warning Adult content//

3 Files:

vote.php (Included here)
neg.txt (Basicly a blank text doc)
plus.txt (Create the 2 txt docs with notepad)

Chmod all files to 777 and keep in same directory

Quote
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
  <head>
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Revisit-After" content="2 Days">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>Thank you for voting</title>
  </head>
  <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" alink="#0000FF" vlink="#0000FF">
   <h1>Results</h1>
//////////////////////////////////////////////////////////// 
//////////////////CHMOD ALL 3 FILES TO 777 /////////////////
///////////////////////////////////////////////////////////

<?php
$question = "Movie Vote"; // change this to your question
$questionoptionone = "Full screen movies with low quality"; // change this to the first option
$questionoptiontwo = "Smaller screen with HD Movies"; // change this to the second option
if(isset($_POST['vote'])){
     if (!empty($_POST['vote'])){
          $vote = $_POST['vote'];
          if($vote == "yes") {
               $votegd = "plus.txt";
               $votebd = "neg.txt";
               $abab = $questionoptionone;
               $baba = $questionoptiontwo;
          } elseif($vote == "no") {
               $votegd = "neg.txt";
               $votebd = "plus.txt";
               $abab = $questionoptiontwo;
               $baba = $questionoptionone;
          } else {
               echo "<h3>Sorry there was an error.</h3>";
          }
          $fp = fopen($votegd,"r");
          $numa = fgets($fp,9999);
          fclose($fp);
          $fp = fopen($votegd,"w");
          $numa += 1;
          fputs($fp, $numa);
          fclose($fp);
          $fpb = fopen($votebd,"r");
          $numb = fgets($fpb,9999);
          fclose($fpb);
          $fpb = fopen($votebd,"w");
          fputs($fpb, $numb);
          fclose($fpb);
          $a = $numa;
          $b = $numb;
          $num = $a + $b;
          $numaa = round($a/$num * 100);
          $numbb = round($b/$num * 100);
          $anumaa = round($a/$num * 300);
          $anumbb = round($b/$num * 300);
          $numnum = $a + $b;
?>
<font size="4" face="arial">
<?php
print "".$question."";
?>
</font><br><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20%">
<?php
          print "".$abab."";
          print "</td>\n";
          print "<td width=\"80%\">\n";
          print "<img src=\"bar.gif\" WIDTH=".$anumaa." HEIGHT=15> ".$numaa."%<br>\n";
          print "</td>\n";
          print "</tr>\n";
          print "<tr>\n";
          print "<td width=\"20%\">\n";
          print "".$baba."\n";
          print "</td>\n";
          print "<td width=\"80%\">\n";
          print "<img src=\"bar.gif\" WIDTH=".$anumbb." HEIGHT=15> ".$numbb."%<br>\n";
          print "</td>\n";
          print "</tr>\n";
          print "</table><br>\n";
          print "out of ".$numnum." people who voted\n";
          print "</font>\n";
     } elseif (empty($_POST['vote'])){
          print "<font size=\"4\" face=\"arial\">Sorry you need to check one of the boxes</font>\n"; //not really needed, checkbox is ticked by default, but you neva know
     } else {
          print "<font size=\"4\" face=\"arial\">Sorry there was an error</font>\n";
     }
} else {
     $votegd = "plus.txt";
     $votebd = "neg.txt";
     $abab = $questionoptionone;
     $baba = $questionoptiontwo;
     $fp = fopen($votegd,"r");
     $numa = fgets($fp,9999);
     fclose($fp);
     $fpb = fopen($votebd,"r");
     $numb = fgets($fpb,9999);
     fclose($fpb);
     $a = $numa;
     $b = $numb;
     $num = $a + $b;
     if($a > 0 || $b > 0) {
          $numaa = round($a/$num * 100);
          $numbb = round($b/$num * 100);
          $anumaa = round($a/$num * 300);
          $anumbb = round($b/$num * 300);
     } else {
          $numaa = 0;
          $numbb = 0;
          $anumaa = 0;
          $anumbb = 0;
     }
     $numnum = $a + $b;
?>
<font size="4" face="arial">
<?php
print "".$question."";
?>
</font><br><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20%">
<?php
     print "".$abab."";
     print "</td>\n";
     print "<td width=\"80%\">\n";
     print "<img src=\"bar.gif\" WIDTH=".$anumaa." HEIGHT=15> ".$numaa."%<br>\n";
     print "</td>\n";
     print "</tr>\n";
     print "<tr>\n";
     print "<td width=\"20%\">\n";
     print "".$baba."\n";
     print "</td>\n";
     print "<td width=\"80%\">\n";
     print "<img src=\"bar.gif\" WIDTH=".$anumbb." HEIGHT=15> ".$numbb."%<br>\n";
     print "</td>\n";
     print "</tr>\n";
     print "</table><br>\n";
     print "out of ".$numnum." people who voted\n";
     print "</font>\n";
}
?>

   

  </body>
</html>
Logged
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 20 queries.