<?php
/*
###################################################################################
  Bigware Shop 2.3
  Release Datum: 23.08.2015
  
  Bigware Shop
  http://www.bigware.de

  Copyright (c) 2015 Bigware LTD
  (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
  (c) 2015	Bigware LTD

  Copyrightvermerke duerfen nicht entfernt werden.
  ------------------------------------------------------------------------
  Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
  der GNU General Public License, wie von der Free Software Foundation
  veroeffentlicht, weitergeben und/oder modifizieren, entweder gemaess Version 2 
  der Lizenz oder (nach Ihrer Option) jeder spaeteren Version.
  Die Veroeffentlichung dieses Programms erfolgt in der Hoffnung, dass es Ihnen
  von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die
  implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FUER EINEN
  BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License.
  
  Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
  Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

  Infos:
  ------------------------------------------------------------------------
  Der Bigware Shop wurde vor vielen Jahren bereits aus dem bekannten Shopsystem osCommerce
  weiter- und neuentwickelt.
  Der Bigware Shop legt im hohen Masse Wert auf Bedienerfreundlichkeit, beinhaltet eine leichte
  Installation, viele neue professionelle Werkzeuge und zeichnet sich aus durch eine grosse 
  Community, die bei Problemen weiterhelfen kann.
  
  Der Bigware Shop ist auf jedem System lauffaehig, welches eine PHP Umgebung
  (ab PHP 4.1.3) und mySQL zur Verfuegung stellt und auf Linux basiert.
 
  Hilfe erhalten Sie im Forum auf www.bigware.de 
  
  -----------------------------------------------------------------------
  
 ##################################################################################

Captcha für Bigware 2.1 by Ede & Tigerstyle


*/
//Captcha by Ede & Tigerstyle
if($captcha_enable_53=="ja"){
//Ede uniq JPG-Name Start 4 IE Cache prob.
$rand=rand(1,1000);
$bild=CAPTCHA_LOAD;
$ausgab= "$bild?$rand";
}
//end
?>

    <table border="0" style="width:100%" cellspacing="0" cellpadding="0">
      <tr>
        <td style="width:100%"><table border="0" style="width:100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageGeneralsign"><?php echo ABOVE_TITLE; ?></td>
            <td align="right"></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo go_fetch_dividing_up('tranparentes.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
      
<?php
if ($_GET['warn']) {
?>
          <tr class="headerError">
            <td class="headerError"><?php echo (VO_WARNING);$warn=preg_replace("/[^A-Za-z0-9\.\,\s\s+]/"," ",$_GET['warn']);echo($warn);?></td>
          </tr>
<?php
}
?>
     <tr>
       <td>
       <table style="width:100%">
       <?php
       if (!isset($_GET['op'])) {
	       $_GET['op']="list";
       }
      
        
switch ($_GET['op']) {
	case "results":
		if (isset($_GET['pollid'])) {
			$pollid=(int)$_GET['pollid'];
		} else {
			$pollid=1;
		}
	$pollid = $pollid + 0;
	$poll_query = go_db_query("SELECT pollid, timeStamp FROM phesis_poll_desc WHERE pollid='".$pollid."'");	
	$polls = go_db_fetch_array($poll_query);
	$title_query = go_db_query("select optionText from phesis_poll_data where pollid=$pollid and voteid='0' and language_id = '" . $languages_id . "'");
	$title = go_db_fetch_array($title_query);
	?>
		<tr><td colspan="2" align="center"><b><br><br><?php echo $title['optionText']?></b></td></tr>
		<tr><td>&nbsp;</td></tr>
		<?php
		$query="SELECT SUM(optionCount) AS sum FROM phesis_poll_data WHERE pollid='".$pollid."'";
	$result=go_db_query($query);
	$polls=go_db_fetch_array($result);
	$sum=$polls['sum'];
	for($i = 1; $i <= 12; $i++) {
		$query = "SELECT pollid, optiontext, optioncount, voteid FROM phesis_poll_data WHERE (language_id = '" . $languages_id . "') and (pollid='".$pollid."') AND (voteid='".$i."')";	
		$result=go_db_query($query);$polls=go_db_fetch_array($result);
		$optiontext=$polls['optiontext'];
		$optioncount=$polls['optioncount'];
		if ($optiontext) {
			?>
				<tr><td align="right">
				<?php echo $optiontext?></td>
				<?php
				if ($sum) {
					$percent = 100 * $optioncount / $sum;
				} else {
					$percent = 0;
				}
			?>
				<td align="left">
				<?php
				$percentInt = (int)$percent * 4 * 1;
			$percent2 = (int)$percent;
			if ($percent > 0) {
				?>
					<img src="<?php echo FOLDER_RELATIV_PIC_SYSTEM_TEMPLATES; ?>leftbar.gif" height="15" style="width:7" Alt="<?php echo $percent2?> %"><img src="<?php echo FOLDER_RELATIV_PIC_SYSTEM_TEMPLATES; ?>mainbar.gif" height="15" style="width:<?php echo $percentInt?>px" Alt="<?php echo $percent2?> %"><img src="<?php echo FOLDER_RELATIV_PIC_SYSTEM_TEMPLATES; ?>rightbar.gif" height="15" style="width:7" Alt="<?php echo $percent2?> %">
					
					<?php
			} else {
				?>
					<img src="<?php echo FOLDER_RELATIV_PIC_SYSTEM_TEMPLATES; ?>leftbar.gif" height="15" style="width:7" Alt="<?php echo $percent2?> %"><img src="<?php echo FOLDER_RELATIV_PIC_SYSTEM_TEMPLATES; ?>mainbar.gif" height="15" style="width:3" Alt="<?php echo $percent2?> %"><img src="<?php echo FOLDER_RELATIV_PIC_SYSTEM_TEMPLATES; ?>rightbar.gif" height="15" style="width:7" Alt="<?php echo $percent2?> %">
					<?php
			}
			printf(" %.2f%% (%d)", $percent, $optioncount);
			?>
				</td></tr>
				<?php
		}
	}
	// Änderung um Kommentare nach Datum zu sortieren 26.11.2012
	$comments_query_raw = "select * from phesis_comments where pollid = '" . $pollid . "' and language_id = '" . $languages_id . "'ORDER BY date DESC" ; 
	$comments_query = go_db_query($comments_query_raw);
	if ($comments_numrows > 0) {
		?>
			<tr><td colspan="2">&nbsp;</td></tr>
			<tr><td class="pageheading" colspan="2"><?php echo _COMMENTS_POSTED; ?></td></tr>  
			<td colspan="2"><?php echo go_fetch_dividing_up('tranparentes.gif', '100%', '5'); ?></td>
			<?php
	}
	if (($comments_numrows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
		?>
			<tr>
			<td colspan="2"><br><table border="0" style="width:100%" cellspacing="0" cellpadding="2">
			<tr>
			<td class="smallText"><?php echo $comments_split->display_count($comments_numrows, MAX_SHOW_NEW_COMMENTS, $_GET['page'], TEXT_SHOW_NUMBER_OF_COMMENTS); ?></td>
			<td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE; ?> <?php echo $comments_split->display_links($comments_numrows, MAX_SHOW_NEW_COMMENTS, MAX_SHOW_PAGE_LINKS, $_GET['page'], go_get_all_get_parameter(array('page', 'info', 'x', 'y'))); ?></td>
			</tr>
			</table></td>
			</tr>
			<?php
	}
	while ($comments = go_db_fetch_array($comments_query)) {
		if ($comments['attendee_id'] != '0') {
			$name_query = go_db_query("select attendees_firstname, attendees_lastname from " . DB_TBL_ATTENDEES . " where attendees_id = '". $comments['attendee_id'] . "'");
			$name = go_db_fetch_array($name_query);
			$comment_name = $name['attendees_firstname'] . " " . $name['attendees_lastname'];
		} else {
			$comment_name = $comments['name'];
		}

		$post_details = '<br>'. _COMMENTS_BY . $comment_name . '&nbsp; <br>' . _COMMENTS_ON . $comments['date'];
		?>
			<tr><td class="main" colspan="2"><b><?php echo $post_details; ?></b></td></tr>
			<td colspan="2"><?php echo go_fetch_dividing_up('tranparentes.gif', '100%', '5'); ?></td>
			<tr><td class="main" colspan="2"><?php echo isohtmlspecialchars($comments['comment']); ?><br>--------------------</td></tr>
			<td colspan="2"><?php echo go_fetch_dividing_up('tranparentes.gif', '100%', '5'); ?></td>

			<?php
	}
	if (($comments_numrows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
		?>
			<tr>
			<td colspan="2"><br><table border="0" style="width:100%" cellspacing="0" cellpadding="2">
			<tr>
			<td class="smallText"><?php echo $comments_split->display_count($comments_numrows, MAX_SHOW_NEW_COMMENTS, $_GET['page'], TEXT_SHOW_NUMBER_OF_COMMENTS); ?></td>
			<td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE; ?> <?php echo $comments_split->display_links($comments_numrows, MAX_SHOW_NEW_COMMENTS, MAX_SHOW_PAGE_LINKS, $_GET['page'], go_get_all_get_parameter(array('page', 'info', 'x', 'y'))); ?></td>
			</tr>
			</table></td>
			</tr>
			<?php
	}
	?>
		<tr><td colspan="2" align="center">&nbsp;</td></tr>
		<tr><td colspan="2" align="center" class="main"><?php echo _TOTALVOTES?> = <?php echo $sum?></td></tr>
		<tr><td colspan="2" align="center" class="main">[ <a href="<?php echo go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_53],'pollid='.$pollid.'&op=comment','NONSSL')?>"><?php echo _COMMENT?></a> | <a href="<?php echo go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_53],'pollid='.$pollid.'&op=vote','NONSSL')?>"><?php echo _VOTING?></a> | <a href="<?php echo go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_53],'op=list','NONSSL')?>"><?php echo _OTHERPOLLS?></a> ]</td></tr>
		<?php
 
		break;


	case 'comment':

	if (isset($_GET['pollid'])) {
		$pollid=(int)$_GET['pollid'];
	} else {
		$pollid=1;
	}
	$pollid = $pollid + 0;
	$poll_query = go_db_query("SELECT pollid, timeStamp FROM phesis_poll_desc WHERE pollid='".$pollid."'");	
	$polls = go_db_fetch_array($poll_query);
	$title_query = go_db_query("select optionText from phesis_poll_data where pollid=$pollid and voteid='0' and language_id = '" . $languages_id . "'");
	$title = go_db_fetch_array($title_query);
	?>
		<?php echo go_fetch_form('poll_comment', go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_53], 'action=do_comment&pollid=' . $pollid), 'post'); ?>
		<tr><td colspan="2" align="center"><b><br><br><?php echo $title['optionText']?></b></td></tr>
		<tr><td colspan="2">&nbsp;</td></tr>
		<?php
		
// Tigerstyle	
		
  if ($messageStack->size('polls') > 0) {
?>
      <tr>
        <td><?php echo $messageStack->output('polls'); ?></td>
      </tr>
      <tr>
        <td><?php echo go_fetch_dividing_up('tranparentes.gif', '100%', '10'); ?></td>
      </tr>
<?php
}  
// END Tigerstyle			
		
		if (!$attendee_id) {
			?>
				<tr><td><?php echo go_fetch_inputfeld('comment_name',''); ?>&nbsp;<?php echo _YOURNAME; ?></td></tr>
				<?php
		}
	?>
		<tr><td><?php echo go_fetch_textarea_field('comment', 'soft', '30', '4', ''); ?></td></tr>
<!-- Tigerstyle captcha field edited by Ede -->
               <?php
         if($captcha_enable_53=="ja"){
              ?>    
            <tr>
          <td class="main"><label for="captcha_code"><?php echo CAPTCHA_TEXT1; ?>:</label><br></td>
            </tr>
            <tr>
        <td><a href="<?php echo go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_53],'pollid='.$pollid.'&op=comment','NONSSL')?>"><img src="<?php echo $ausgab; ?>" alt="<?php echo CAPTCHA_CHANGE; ?>" border=0></a></td>   
            </tr>
        <tr>
        <td class="main"><?php echo CAPTCHA_TEXT2; ?>:</td>
          </tr>
          <tr>
        <td class="main"><?php echo go_fetch_captcha_field('captcha_code');?></td>
      </tr> 
      <?php
         }
              ?> 
<!-- Tigerstyle END -->
		<tr><td><?php echo go_picture_submit('button_continue.gif','TEXT_CONTINUE'); ?></td></tr>
		<form>
		<?php
		
		$nolink = true;
	break;
	
	case 'list':

?>
		<tr><td colspan="6">&nbsp;</td></tr>
		<?php
		$result=go_db_query("SELECT pollid, timestamp, voters, poll_type, poll_open FROM phesis_poll_desc ORDER BY timestamp desc");
	$row=0;
	while ($polls=go_db_fetch_array($result)) {
		$row++;
		$id=$polls['pollid'];
		if (($row / 2) == floor($row / 2)) {
			?>
				<tr class="Payment-even">
				<?php
		} else {
			?>
				<tr class="Payment-odd">
				<?php
		}
		$title_query = go_db_query("select optionText from phesis_poll_data where pollid=$id and voteid='0' and language_id = '" . $languages_id . "'");
		$title = go_db_fetch_array($title_query);
		$fullresults="<a href=\"".go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_53],'op=results&pollid='.$id,'NONSSL')."\">"._POLLRESULTS."</a>";
		$result1 = go_db_query("SELECT SUM(optioncount) AS sum FROM phesis_poll_data WHERE pollid='".$id."'");
		$poll_sum=go_db_fetch_array($result1);
		$sum=$poll_sum['sum'];
		$query1=go_db_query("select count(pollid) as comments from phesis_comments where pollid=$id and language_id=$languages_id");
		$result1 = go_db_fetch_array($query1);
		$comments = $result1['comments'];
		echo("<td align=\"center\" class=\"main\">".$title['optionText']."</td><td align=\"center\" class=\"main\">".$sum." ".VO_VOTES."</td><td align=\"center\" class=\"main\">".$comments." ".VO_COMMENTS."</td><td align=\"center\" class=\"main\">".$fullresults."</td>");
		if ($polls['poll_type']=='0') {
			echo ("<td align=\"center\" class=\"main\">".VO_PUBLIC."</td>");
		} else {
			echo ("<td class=\"main\">".VO_PRIVATE."</td>");
		}
		if ($polls['poll_open']=='0') {
			echo ("<td align=\"center\" class=\"main\">".VO_POLLOPEN."</td>");
		} else {
			echo ("<td align=\"center\" class=\"main\">".VO_POLLCLOSED."</td>");
		}
		echo("</tr>\n");
	} 
	break;
	case "vote":
		$poll_query=go_db_query("select voters from phesis_poll_desc where pollid=$pollid");
	$poll_details=go_db_fetch_array($poll_query);
	$title_query = go_db_query("select optionText from phesis_poll_data where pollid=$pollid and voteid='0' and language_id = '" . $languages_id . "'");
	$title = go_db_fetch_array($title_query);
	?>
		<tr>
		<td align="center"><b><?php echo $title['optionText']?></b><td>
		</tr>
		<?php		
		$url = go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_53],'op=results&pollid='.$pollid,'NONSSL');
	$content =  "<input type=\"hidden\" name=\"pollid\" value=\"".$pollid."\">\n";
	$content .=  "<input type=\"hidden\" name=\"forwarder\" value=\"".$url."\">\n";
	for ($i=1;$i<=12;$i++) {
		$query=go_db_query("select pollid, optiontext, optioncount, voteid from phesis_poll_data where (pollid=$pollid) and (voteid=$i) and (language_id=$languages_id)");
		if ($result=go_db_fetch_array($query)) {
			if ($result['optiontext']) {
				$content.= "<input type=\"radio\" name=\"voteid\" value=\"".$i."\">".$result['optiontext']."<br>\n";
			}
		}
	}
	$content .= "<br><center><input type=\"submit\" value=\"".VOE_VOTE."\"></center><br>\n";
	$query=go_db_query("select sum(optioncount) as sum from phesis_poll_data where pollid=$pollid");
	if ($result=go_db_fetch_array($query)) {
		$sum=$result['sum'];
	}
	$content .= "<center>[ <a href=\"".go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_53],'op=results&pollid='.$pollid,'NONSSL')."\">".ZWISCHEN_RESULTS."</a> | <a href=\"".go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_53],'op=list','NONSSL')."\">"._OTHERPOLLS."</a> ]";
	$content .= "</br><center>" . $sum . " ".VO_VOTES."</center>\n";
	echo '<tr><td align="center"><form name="poll" method="post" action="' . $GLOBALS[CONFIG_NAME_FILE][main_bigware_54] . '">';
	echo $content;
	echo '<form>';
	?>
		</td>
		</tr>
		<?php
		break;
}
?>
</table>
</tr>
<?php 
if (!$nolink) {
	?>
    
		<tr>
		<td align="right" class="main"><br><?php echo '<a href="' . go_href_link($GLOBALS[CONFIG_NAME_FILE][main_bigware_29], '', 'NONSSL') . '">' . go_picture_button('button_continue.gif', PICTURE_BUTTON_CONTINUE) . '</a>'; ?></td>
		</tr>
		<?php
}
?>
    </table>
