plugins/Surveyor.php
author Dan
Sat, 10 Jul 2010 05:01:17 -0400
changeset 2 f1ff9ce00132
parent 1 97507d2ca929
permissions -rw-r--r--
Fixed use of deprecated ip2hex() and a few other minutae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
     1
<?php
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
     2
/*
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
     3
Plugin Name: Survey/Poll plugin
1
97507d2ca929 Updated header and metadata blocks
Dan
parents: 0
diff changeset
     4
Plugin URI: http://enanocms.org/Survey_plugin
0
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
     5
Description: Adds a customizable poll to your sidebar. You can have any number of options, and the poll is randomly selected from a list of enabled polls. <b>Important:</b> When first loaded, this plugin creates the following tables in your Enano database: enano_polls, enano_poll_options, enano_poll_results
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
     6
Author: Dan Fuhry
1
97507d2ca929 Updated header and metadata blocks
Dan
parents: 0
diff changeset
     7
Version: 0.3
97507d2ca929 Updated header and metadata blocks
Dan
parents: 0
diff changeset
     8
Author URI: http://enanocms.org/
0
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
     9
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    10
Changelog:
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    11
  9/27/06:
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    12
  Updated to be valid XHTML 1.1
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    13
  11/2/07:
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    14
  Made compatible with Loch Ness and later (oops!)
1
97507d2ca929 Updated header and metadata blocks
Dan
parents: 0
diff changeset
    15
  11/29/08:
97507d2ca929 Updated header and metadata blocks
Dan
parents: 0
diff changeset
    16
  One change a year! Moved to Mercurial and brought up to date with naming conventions.
0
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    17
*/
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    18
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    19
/*
1
97507d2ca929 Updated header and metadata blocks
Dan
parents: 0
diff changeset
    20
 * Surveyor
97507d2ca929 Updated header and metadata blocks
Dan
parents: 0
diff changeset
    21
 * Version 0.3
0
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    22
 * Copyright (C) 2006-2007 Dan Fuhry
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    23
 *
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    24
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    25
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    26
 *
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    27
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    28
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    29
 */
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    30
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    31
global $db, $session, $paths, $template, $plugins; // Common objects
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    32
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    33
// Uncomment this line once the plugin has been enabled for the first time and at least one page has been requested
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    34
define('ENANO_SURVEYOR_TABLES_CREATED', 'true');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    35
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    36
  if(!defined('ENANO_SURVEYOR_TABLES_CREATED')) {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    37
  $e = $db->sql_query('CREATE TABLE IF NOT EXISTS '.table_prefix.'polls(
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    38
                         poll_id mediumint(5) NOT NULL auto_increment,
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    39
                         poll_question text,
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    40
                         end_time datetime,
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    41
                         enabled tinyint(1),
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    42
                         PRIMARY KEY (poll_id)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    43
                       );');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    44
  if(!$e) $db->_die('Surveyor plugin: error creating table '.table_prefix.'polls.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    45
  
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    46
  $e = $db->sql_query('CREATE TABLE IF NOT EXISTS '.table_prefix.'poll_options(
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    47
                         item_id mediumint(5) NOT NULL auto_increment,
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    48
                         poll_id mediumint(5) NOT NULL,
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    49
                         option_value text,
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    50
                         PRIMARY KEY (item_id)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    51
                       );');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    52
  if(!$e) $db->_die('Surveyor plugin: error creating table '.table_prefix.'poll_options.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    53
  
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    54
  $e = $db->sql_query('CREATE TABLE IF NOT EXISTS '.table_prefix.'poll_results(
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    55
                         poll_id mediumint(5),
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    56
                         item_id mediumint(5),
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    57
                         user_id mediumint(8),
2
f1ff9ce00132 Fixed use of deprecated ip2hex() and a few other minutae
Dan
parents: 1
diff changeset
    58
                         ip_addr varchar(39)
0
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    59
                       );');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    60
  if(!$e) $db->_die('Surveyor plugin: error creating table '.table_prefix.'poll_results.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    61
  
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    62
}
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    63
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    64
class Surveyor_Plugin {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    65
  var $header_added;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    66
  function html($pid = false)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    67
  {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    68
    global $db, $session, $paths, $template, $plugins; // Common objects
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    69
    $s = '';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    70
    if(is_int($pid)) $s = ' AND p.poll_id='.$pid;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    71
    $ret = '';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    72
    if(!is_int($pid)) $ret .= '<div id="mdgVotePlugin" style="padding: 5px;">';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    73
    $ret .= '<form id="survey" action="'.makeUrlNS('Special', 'SubmitVote').'" method="post"><div>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    74
    $q = $db->sql_query('SELECT p.poll_id AS pid,o.item_id AS oid,p.poll_question AS q,o.option_value AS v FROM '.table_prefix.'polls p, '.table_prefix.'poll_options o WHERE p.poll_id=o.poll_id AND p.enabled=1'.$s.';');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    75
    if(!$q) $db->_die('An error occurred whilst selecting the poll data.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    76
    $l = Array();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    77
    while($row = $db->fetchrow())
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    78
    {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    79
      if(!isset($l[$row['q']]))
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    80
      {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    81
        $l[$row['q']] = Array();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    82
        $l[$row['q']]['pid'] = $row['pid'];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    83
      }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    84
      $l[$row['q']][] = $row;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    85
    }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    86
    if(sizeof($l) < 1) return 'No polls created yet';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    87
    $ques = array_rand($l);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    88
    $poll_id = $l[$ques]['pid'];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    89
    unset($l[$ques]['pid']);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    90
    if(!$poll_id) die_semicritical('Surveyor plugin error', 'Invalid poll ID: '.$poll_id);
2
f1ff9ce00132 Fixed use of deprecated ip2hex() and a few other minutae
Dan
parents: 1
diff changeset
    91
    $uidbit = $session->user_logged_in ? 'OR user_id='.$session->user_id : '';
f1ff9ce00132 Fixed use of deprecated ip2hex() and a few other minutae
Dan
parents: 1
diff changeset
    92
    $q = $db->sql_query('SELECT * FROM '.table_prefix.'poll_results WHERE poll_id='.$poll_id.' AND ( ip_addr=\''.$db->escape($_SERVER['REMOTE_ADDR']).'\' ' . $uidbit . ' );');
0
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    93
    if(!$q) $db->_die('Error obtaining vote result information');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    94
    if($db->numrows() > 0)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    95
    {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    96
      if(!isset($_GET['results'])) $_GET['results'] = '';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    97
      $_REQUEST['poll_id'] = $poll_id.'';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    98
      $_GET['poll_id'] = $poll_id.'';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
    99
      return __enanoVoteAjaxhandler(false);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   100
    }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   101
    $ret .= '<input type="hidden" name="poll_id" value="'.$poll_id.'" />';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   102
    $ret .= '<span style="font-weight: bold;">'.$ques.'</span><br />';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   103
    foreach($l[$ques] as $o)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   104
    {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   105
      $ret .= '<label><input type="radio" name="item_id" value="'.addslashes($o['oid']).'" /> '.$o['v'].'</label><br />';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   106
    }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   107
    $ret .= '<br /><div style="text-align: center"><input type="button" value="Vote!" onclick="ajaxSubmitVote(); return false;" /> <input type="button" onclick="ajaxVoteResults(); return false;" value="View results" /></div>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   108
    $ret .= '</div></form>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   109
    if(!is_int($pid)) $ret .= '</div>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   110
    
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   111
    $template->add_header('
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   112
      <script type="text/javascript">
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   113
      //<![CDATA[
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   114
        function ajaxSubmitVote()
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   115
        {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   116
          frm = document.forms.survey;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   117
          radios = document.getElementsByTagName(\'input\');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   118
          optlist = new Array();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   119
          j = 0;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   120
          for(i=0;i<radios.length;i++)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   121
          {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   122
            if(radios[i].name == \'item_id\')
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   123
            {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   124
              optlist[j] = radios[i];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   125
              j++;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   126
            }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   127
          }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   128
          val = \'enanoNuLl\';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   129
          for(i=0;i<optlist.length;i++)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   130
          {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   131
            if(optlist[i].checked) val = optlist[i].value;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   132
          }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   133
          if(val==\'enanoNuLl\') { alert(\'Please select an option.\'); return; }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   134
          ajaxPost(\''.makeUrlNS('Special', 'SubmitVote', 'redirect=no').'\', \'poll_id=\'+frm.poll_id.value+unescape(\'%26\')+\'item_id=\'+val, function() {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   135
              if(ajax.readyState==4)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   136
              {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   137
                ajaxVoteResults();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   138
              }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   139
            });
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   140
        }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   141
        function ajaxVoteForm()
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   142
        {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   143
          ajaxGet(\''.makeUrlNS('Special', 'SubmitVote', 'voteform\'+unescape(\'%26\')+\'poll_id='.$poll_id).'\', function() {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   144
              if(ajax.readyState==4)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   145
              {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   146
                document.getElementById("mdgVotePlugin").innerHTML = ajax.responseText;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   147
              }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   148
            });
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   149
        }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   150
        function ajaxVoteResults()
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   151
        {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   152
          ajaxGet(\''.makeUrlNS('Special', 'SubmitVote', 'results\'+unescape(\'%26\')+\'poll_id='.$poll_id).'\', function() {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   153
              if(ajax.readyState==4)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   154
              {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   155
                document.getElementById("mdgVotePlugin").innerHTML = ajax.responseText;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   156
              }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   157
            });
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   158
        }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   159
        // ]]>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   160
      </script>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   161
      ');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   162
    
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   163
    return $ret;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   164
  }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   165
}
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   166
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   167
$plugins->attachHook('base_classes_initted', '
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   168
  $paths->add_page(Array(
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   169
      \'name\'=>\'Submit a poll vote\',
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   170
      \'urlname\'=>\'SubmitVote\',
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   171
      \'namespace\'=>\'Special\',
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   172
      \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   173
      ));
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   174
  $paths->addAdminNode(\'Plugin configuration\', \'Manage polls\', \'PollEditor\');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   175
  ');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   176
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   177
function __mdgPluginDoSurvey() {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   178
  global $db, $session, $paths, $template, $plugins; // Common objects
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   179
  $s = new Surveyor_Plugin();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   180
  $template->sidebar_widget('Poll', $s->html());
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   181
}
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   182
$plugins->attachHook('compile_template', '__mdgPluginDoSurvey();');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   183
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   184
function page_Special_SubmitVote()
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   185
{
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   186
  echo __enanoVoteAjaxhandler();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   187
}
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   188
function __enanoVoteAjaxhandler($allow_vote = true)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   189
{
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   190
  global $db, $session, $paths, $template, $plugins; // Common objects
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   191
  $ret = '';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   192
  if(!isset($_REQUEST['poll_id'])) { die_semicritical('Critical error in plugin', '$_REQUEST[\'poll_id\'] is not set'); $paths->main_page(); exit; }
2
f1ff9ce00132 Fixed use of deprecated ip2hex() and a few other minutae
Dan
parents: 1
diff changeset
   193
  if(isset($_GET['poll_id']) && !preg_match('/^([0-9]+)$/', $_GET['poll_id'])) die('Hacking attempt'); // Prevents SQL injection from the URL
f1ff9ce00132 Fixed use of deprecated ip2hex() and a few other minutae
Dan
parents: 1
diff changeset
   194
  if(isset($_POST['poll_id']) && !preg_match('/^([0-9]+)$/', $_POST['poll_id'])) die('Hacking attempt'); // Prevents SQL injection from the URL
0
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   195
  if(isset($_GET['results']))
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   196
  {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   197
    $q = $db->sql_query('SELECT p.poll_id AS pid,o.item_id AS oid,p.poll_question AS q,o.option_value AS v FROM '.table_prefix.'polls p, '.table_prefix.'poll_options o WHERE p.poll_id=o.poll_id AND p.poll_id=\''.$_GET['poll_id'].'\';');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   198
    $l = Array();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   199
    while($row = $db->fetchrow())
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   200
    {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   201
      if(!isset($l[$row['q']]))
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   202
      {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   203
        $l[$row['q']] = Array();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   204
        $l[$row['q']]['pid'] = $row['pid'];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   205
      }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   206
      $l[$row['q']][] = $row;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   207
    }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   208
    // The reason we use array_rand() here? Simple - we used a WHERE clause to select only one poll, and since poll_id is
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   209
    // a primary key, there is only one match in the polls table. Therefore, array_rand() effectively returns the first key in the array
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   210
    $ques = array_rand($l);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   211
    $poll_id = $l[$ques]['pid'];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   212
    unset($l[$ques]['pid']);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   213
    $results = Array();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   214
    foreach($l[$ques] as $o)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   215
    {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   216
      $q = $db->sql_query('SELECT * FROM '.table_prefix.'poll_results WHERE poll_id='.$_GET['poll_id'].' AND item_id='.$o['oid'].';');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   217
      if(!$q) $db->_die('The poll result data could not be selected.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   218
      $results[$o['v']] = $db->numrows();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   219
    }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   220
    $k = array_keys($results);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   221
    $total = 0;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   222
    foreach($k as $key)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   223
    {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   224
      $total = $total + $results[$key];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   225
    }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   226
    if($total==0) $total = 1;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   227
    // Figure out the percentage, round it, and send the images
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   228
    $ret .= '<table border="0" style="margin: 0; padding: 0; width: 100%;" cellspacing="0" cellpadding="0">';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   229
    $ret .= '<tr><td colspan="2"><b>'.$ques.'</b></td></tr>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   230
    foreach($k as $key)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   231
    {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   232
      $this_width = round(100*($results[$key] / $total));
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   233
      if ( $this_width == 0 )
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   234
        $this_width = 4;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   235
      $ret .= '<tr>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   236
                 <td colspan="2">'.$key.'</td>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   237
               </tr>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   238
               <tr>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   239
                 <td style="padding: 0px 4px 0px 4px;">
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   240
                   <img alt="Poll bar" src="'.scriptPath.'/plugins/surveyor/poll-bar-left.png"
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   241
                    width="2" height="12" style="margin: 2px 0px 2px 0px; padding: 0;" hspace="0" 
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   242
                    
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   243
                  /><img alt="Poll bar" src="'.scriptPath.'/plugins/surveyor/poll-bar-middle.png"
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   244
                    width="'.$this_width.'" height="12" style="margin: 2px 0px 2px 0px; padding: 0;" hspace="0"
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   245
                    
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   246
                  /><img alt="Poll bar" src="'.scriptPath.'/plugins/surveyor/poll-bar-right.png"
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   247
                    width="2" height="12" style="margin: 2px 0px 2px 0px; padding: 0;" hspace="0" />
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   248
                    
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   249
                  </td>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   250
                  
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   251
                  <td>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   252
                    ['.$results[$key].']
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   253
                  </td>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   254
                </tr>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   255
    }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   256
    if($allow_vote) $ret .= '<tr><td colspan="2" style="text-align: center"><input type="button" value="Cast your vote" onclick="ajaxVoteForm(); return false;" /></td></tr>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   257
    $ret .= '</table>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   258
  } elseif(isset($_GET['voteform'])) {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   259
    $s = new Surveyor_Plugin();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   260
    $pid = (int)$_GET['poll_id'];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   261
    $ret .= $s->html($pid);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   262
  } else {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   263
    if(!isset($_POST['item_id']) || (isset($_POST['item_id']) && !preg_match('/^([0-9]+)$/', $_POST['item_id']))) die('Hacking attempt'); // Once again, ensure that only numbers are passed on the URL
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   264
    if(isset($_GET['redirect']) && $_GET['redirect'] == 'no')
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   265
    {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   266
      header('Content-type: text/plain');
2
f1ff9ce00132 Fixed use of deprecated ip2hex() and a few other minutae
Dan
parents: 1
diff changeset
   267
      $uidbit = $session->user_logged_in ? 'OR user_id='.$session->user_id : '';
f1ff9ce00132 Fixed use of deprecated ip2hex() and a few other minutae
Dan
parents: 1
diff changeset
   268
      $q = $db->sql_query('SELECT * FROM '.table_prefix.'poll_results WHERE poll_id='.$_POST['poll_id'].' AND ( ip_addr=\''.$db->escape($_SERVER['REMOTE_ADDR']).'\' ' . $uidbit . ' );');
0
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   269
      if(!$q) $db->_die('Error obtaining vote result information');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   270
      if($db->numrows() > 0)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   271
      {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   272
        die('Looks like you already voted in this poll.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   273
      }
2
f1ff9ce00132 Fixed use of deprecated ip2hex() and a few other minutae
Dan
parents: 1
diff changeset
   274
      $q = $db->sql_query('INSERT INTO '.table_prefix.'poll_results(poll_id,item_id,ip_addr,user_id) VALUES('.$_POST['poll_id'].', '.$_POST['item_id'].', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', '.$session->user_id.');');
0
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   275
      if(!$q) $db->_die('Your vote could not be inserted into the results table.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   276
      $ret .= 'Your vote has been cast.';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   277
    } else {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   278
      $paths->main_page();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   279
    }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   280
  }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   281
  return $ret;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   282
}
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   283
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   284
function page_Admin_PollEditor()
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   285
{
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   286
  global $db, $session, $paths, $template, $plugins; if(!$session->sid_super || $session->user_level < 2) { header('Location: '.makeUrl($paths->nslist['Special'].'Administration'.urlSeparator.'noheaders')); die('Hacking attempt'); }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   287
  if(isset($_POST['newpoll_create']))
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   288
  {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   289
    $date_string = $_POST['newpoll_year'].'-'.$_POST['newpoll_month'].'-'.$_POST['newpoll_day'].' '.$_POST['newpoll_hour'].':'.$_POST['newpoll_minute'].':00';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   290
    if(isset($_POST['newpoll_never']))
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   291
      $date_string = '9999-01-01 00:00:00';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   292
    if(!$db->sql_query('INSERT INTO '.table_prefix.'polls(poll_question,enabled,end_time) VALUES(\''.mysql_real_escape_string($_POST['newpoll_name']).'\', 1, \''.$date_string.'\');')) $db->_die('The poll information could not be inserted.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   293
    $q = $db->sql_query('SELECT poll_id FROM '.table_prefix.'polls WHERE poll_question=\''.mysql_real_escape_string($_POST['newpoll_name']).'\' AND end_time=\''.$date_string.'\';');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   294
    if(!$q) $db->_die('The new poll ID could not be fetched.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   295
    $r = $db->fetchrow();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   296
    if(!$db->sql_query('INSERT INTO '.table_prefix.'poll_options(poll_id,option_value) VALUES('.$r['poll_id'].', \'First option\')')) $db->_die('The default option data could not be inserted.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   297
  }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   298
  
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   299
  echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module'], true).'" method="post">';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   300
    ?>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   301
    <h3>Create a new poll</h3>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   302
    <p>Question: <input name="newpoll_name" type="text" /></p>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   303
    <p>Ending time:
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   304
    <select name="newpoll_month">
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   305
      <option value="01">January</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   306
      <option value="02">February</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   307
      <option value="03">March</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   308
      <option value="04">April</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   309
      <option value="05">May</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   310
      <option value="06">June</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   311
      <option value="07">July</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   312
      <option value="08">August</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   313
      <option value="09">September</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   314
      <option value="10">October</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   315
      <option value="11">November</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   316
      <option value="12">December</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   317
    </select>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   318
    <select name="newpoll_day">
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   319
    <?php
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   320
      // This would be too hard to write by hand, so let's use a simple for-loop to take care of it for us
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   321
      for($i=1;$i<=31;$i++)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   322
      {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   323
        if($i < 10) $t = '0'.$i;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   324
        else $t = $i.'';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   325
        echo '<option value="'.$t.'">'.$t.'</option>'."\n      "; 
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   326
      }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   327
    ?>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   328
    </select>,
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   329
    <select name="newpoll_year">
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   330
    <?php
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   331
      // What the heck? Let's do it again :-D
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   332
      for($i=2006;$i<=2026;$i++)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   333
      {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   334
        echo '<option value="'.$i.'">'.$i.'</option>'."\n      "; 
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   335
      }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   336
    ?>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   337
    </select>&nbsp;&nbsp;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   338
    <select name="newpoll_hour">
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   339
    <?php
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   340
      for($i=0;$i<=23;$i++)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   341
      {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   342
        if($i < 10) $t = '0'.$i;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   343
        else $t = $i.'';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   344
        echo '<option value="'.$t.'">'.$t.'</option>'."\n      "; 
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   345
      }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   346
    ?>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   347
    </select>:<select name="newpoll_minute">
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   348
    <?php
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   349
      for($i=0;$i<=59;$i++)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   350
      {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   351
        if($i < 10) $t = '0'.$i;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   352
        else $t = $i.'';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   353
        echo '<option value="'.$t.'">'.$t.'</option>'."\n      "; 
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   354
      }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   355
    ?>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   356
    </select><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label><input type="checkbox" name="newpoll_never" />Never ends</label></p>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   357
    
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   358
    <p><input type="submit" name="newpoll_create" value="Create poll" /></p>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   359
    <?php
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   360
  echo '</form>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   361
  
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   362
  $q = $db->sql_query('SELECT p.poll_id AS pid,o.item_id AS oid,p.poll_question AS q,o.option_value AS v,p.end_time,p.enabled FROM '.table_prefix.'polls p, '.table_prefix.'poll_options o WHERE p.poll_id=o.poll_id;');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   363
  if(!$q) $db->_die('The poll information could not be selected.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   364
  $l = Array();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   365
  while($row = $db->fetchrow())
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   366
  {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   367
    if(!isset($l[$row['q']]))
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   368
    {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   369
      $l[$row['q']] = Array();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   370
    }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   371
    $l[$row['q']][] = $row;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   372
  }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   373
  $k = array_keys($l);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   374
  foreach ( $k as $key )
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   375
  {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   376
    $c = $l[$key][0];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   377
    $poll_id = $c['pid'];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   378
    $enabled = $c['enabled'];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   379
    $ending_time = $c['end_time'];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   380
    $year = substr($ending_time, 0, 4);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   381
    $month = substr($ending_time, 5, 2);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   382
    $day = substr($ending_time, 8, 2);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   383
    $hour = substr($ending_time, 11, 2);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   384
    $minute = substr($ending_time, 14, 2);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   385
    if(isset($_POST['poll_'.$c['pid'].'_update']))
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   386
    {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   387
      $date_string = $_POST['poll_'.$c['pid'].'_year'].'-'.$_POST['poll_'.$c['pid'].'_month'].'-'.$_POST['poll_'.$c['pid'].'_day'].' '.$_POST['poll_'.$c['pid'].'_hour'].':'.$_POST['poll_'.$c['pid'].'_minute'].':00';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   388
      if(isset($_POST['poll_'.$c['pid'].'_never']))
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   389
        $date_string = '9999-01-01 00:00:00';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   390
      $en = isset($_POST['poll_'.$c['pid'].'_enabled']) ? '1' : '0';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   391
      $q = $db->sql_query('UPDATE '.table_prefix.'polls SET enabled='.$en.',end_time=\''.$date_string.'\' WHERE poll_id='.$c['pid'].';');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   392
      if(!$q) $db->_die('The poll data could not be updated.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   393
      
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   394
      $q = $db->sql_query('SELECT p.poll_id AS pid,o.item_id AS oid,p.poll_question AS q,o.option_value AS v,p.end_time,p.enabled FROM '.table_prefix.'polls p, '.table_prefix.'poll_options o WHERE p.poll_id=o.poll_id;');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   395
      if(!$q) $db->_die('The poll information could not be selected.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   396
      $l = Array();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   397
      while($row = $db->fetchrow())
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   398
      {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   399
        if(!isset($l[$row['q']]))
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   400
        {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   401
          $l[$row['q']] = Array();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   402
        }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   403
        $l[$row['q']][] = $row;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   404
      }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   405
      $k = array_keys($l);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   406
      
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   407
      echo '<h3>Information</h3><p>Poll updated successfully.</p>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   408
    }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   409
    if(isset($_POST['poll_'.$c['pid'].'_delete']))
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   410
    {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   411
      // Safe to use the poll ID here because it's the primary key
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   412
      if(!$db->sql_query('DELETE FROM '.table_prefix.'poll_results WHERE poll_id='.$c['pid'].';') ) $db->_die('The poll results could not be deleted.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   413
      if(!$db->sql_query('DELETE FROM '.table_prefix.'poll_options WHERE poll_id='.$c['pid'].';') ) $db->_die('The poll options could not be deleted.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   414
      if(!$db->sql_query('DELETE FROM '.table_prefix.'polls WHERE poll_id='.$c['pid'].';')        ) $db->_die('The poll could not be deleted.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   415
      unset($l[$key]);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   416
      echo '<h3>Information</h3><p>Poll deleted.</p>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   417
    }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   418
  }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   419
  $k = array_keys($l); // Refresh the key list after any deletions that may have been done
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   420
  foreach ( $k as $key )
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   421
  {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   422
    if(isset($_POST['create_'.$l[$key][0]['pid']]))
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   423
    {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   424
      $str = mysql_real_escape_string($_POST['value_'.$l[$key][0]['pid']]);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   425
      $q = $db->sql_query('INSERT INTO '.table_prefix.'poll_options(poll_id,option_value) VALUES('.$l[$key][0]['pid'].', \''.$str.'\');');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   426
      if(!$q) $db->_die('The poll data could not be inserted.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   427
      $q = $db->sql_query('SELECT o.item_id AS oid,option_value AS v, p.poll_id AS pid FROM '.table_prefix.'polls p, '.table_prefix.'poll_options o WHERE p.poll_id=o.poll_id AND option_value=\''.$str.'\';');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   428
      if(!$q) $db->_die('The poll data could not be selected.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   429
      $nr = $db->fetchrow();
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   430
      $l[$key][] = $nr; // Fetches the option ID, which is needed for updating and deleting the poll option
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   431
    }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   432
    echo '<hr /><h3>Poll: '.$key.'</h3>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   433
    echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module'], true).'" method="post">';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   434
    $poll_id = $l[$key][0]['pid'];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   435
    $enabled = $l[$key][0]['enabled'];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   436
    $ending_time = $l[$key][0]['end_time'];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   437
    $year = substr($ending_time, 0, 4);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   438
    $month = substr($ending_time, 5, 2);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   439
    $day = substr($ending_time, 8, 2);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   440
    $hour = substr($ending_time, 11, 2);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   441
    $minute = substr($ending_time, 14, 2);
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   442
    ?>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   443
    <p>Ending time:
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   444
    <select name="poll_<?php echo $poll_id; ?>_month">
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   445
      <option<?php if($month=='01') echo ' selected="selected"'; ?> value="01">January</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   446
      <option<?php if($month=='02') echo ' selected="selected"'; ?> value="02">February</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   447
      <option<?php if($month=='03') echo ' selected="selected"'; ?> value="03">March</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   448
      <option<?php if($month=='04') echo ' selected="selected"'; ?> value="04">April</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   449
      <option<?php if($month=='05') echo ' selected="selected"'; ?> value="05">May</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   450
      <option<?php if($month=='06') echo ' selected="selected"'; ?> value="06">June</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   451
      <option<?php if($month=='07') echo ' selected="selected"'; ?> value="07">July</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   452
      <option<?php if($month=='08') echo ' selected="selected"'; ?> value="08">August</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   453
      <option<?php if($month=='09') echo ' selected="selected"'; ?> value="09">September</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   454
      <option<?php if($month=='10') echo ' selected="selected"'; ?> value="10">October</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   455
      <option<?php if($month=='11') echo ' selected="selected"'; ?> value="11">November</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   456
      <option<?php if($month=='12') echo ' selected="selected"'; ?> value="12">December</option>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   457
    </select>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   458
    <select name="poll_<?php echo $poll_id; ?>_day">
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   459
    <?php
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   460
      // This would be too hard to write by hand, so let's use a simple for-loop to take care of it for us
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   461
      for($i=1;$i<=31;$i++)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   462
      {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   463
        if($i < 10) $t = '0'.$i;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   464
        else $t = $i.'';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   465
        echo '<option';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   466
        if($t == $day) echo ' selected="selected"';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   467
        echo ' value="'.$t.'">'.$t.'</option>'."\n      "; 
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   468
      }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   469
    ?>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   470
    </select>,
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   471
    <select name="poll_<?php echo $poll_id; ?>_year">
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   472
    <?php
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   473
      // What the heck? Let's do it again :-D
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   474
      for($i=2006;$i<=2026;$i++)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   475
      {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   476
        echo '<option';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   477
        if($i.'' == $year) echo ' selected="selected"';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   478
        echo ' value="'.$i.'">'.$i.'</option>'."\n      "; 
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   479
      }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   480
    ?>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   481
    </select>&nbsp;&nbsp;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   482
    <select name="poll_<?php echo $poll_id; ?>_hour">
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   483
    <?php
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   484
      for($i=0;$i<=23;$i++)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   485
      {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   486
        if($i < 10) $t = '0'.$i;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   487
        else $t = $i.'';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   488
        echo '<option';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   489
        if($t == $hour) echo ' selected="selected"';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   490
        echo ' value="'.$t.'">'.$t.'</option>'."\n      "; 
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   491
      }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   492
    ?>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   493
    </select>:<select name="poll_<?php echo $poll_id; ?>_minute">
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   494
    <?php
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   495
      for($i=0;$i<=59;$i++)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   496
      {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   497
        if($i < 10) $t = '0'.$i;
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   498
        else $t = $i.'';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   499
        echo '<option';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   500
        if($t == $minute) echo ' selected="selected"';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   501
        echo ' value="'.$t.'">'.$t.'</option>'."\n      "; 
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   502
      }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   503
    ?>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   504
    </select><br />
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   505
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label><input<?php if($year=='9999' && $month=='01' && $day=='01' && $hour=='00' && $minute=='00') echo ' checked="checked"'; ?> type="checkbox" name="poll_<?php echo $poll_id; ?>_never" />Never ends</label></p>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   506
    <p><label><input<?php if($enabled) echo ' checked="checked"'; ?> type="checkbox" name="poll_<?php echo $poll_id; ?>_enabled" /> Poll is enabled</label></p>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   507
    <p><input type="submit" name="poll_<?php echo $poll_id; ?>_update" value="Update this poll" />  <input type="submit" name="poll_<?php echo $poll_id; ?>_delete" value="Delete this poll" /></p></p>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   508
    <table border="0" width="100%" cellspacing="1" cellpadding="4">
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   509
      <tr><th>Option value</th><th>Votes</th><th>Actions</th></tr>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   510
      <?php
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   511
        foreach($l[$key] as $row)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   512
        {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   513
          if(isset($_POST['delete_'.$row['pid'].'_'.$row['oid']]) && sizeof($l[$key]) > 1)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   514
          {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   515
            $q = $db->sql_query('DELETE FROM '.table_prefix.'poll_options WHERE poll_id='.$row['pid'].' AND item_id='.$row['oid'].';');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   516
            if(!$q) $db->_die('The poll data could not be deleted.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   517
            $q = $db->sql_query('DELETE FROM '.table_prefix.'poll_results WHERE poll_id='.$row['pid'].' AND item_id='.$row['oid'].';');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   518
            if(!$q) $db->_die('The poll result data could not be deleted.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   519
            echo '<tr><td colspan="3" style="text-align: center"><b>Item deleted.</b></tr>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   520
          } else {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   521
            if(isset($_POST['delete_'.$row['pid'].'_'.$row['oid']]) && sizeof($l[$key]) < 2)
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   522
              echo '<tr><td colspan="3" style="text-align: center"><b>You cannot delete the last option in a poll.<br />Instead, please use the "Update" button.</b></tr>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   523
            if(isset($_POST['update_'.$row['pid'].'_'.$row['oid']]))
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   524
            {
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   525
              $q = $db->sql_query('UPDATE '.table_prefix.'poll_options SET option_value=\''.mysql_real_escape_string($_POST['value_'.$row['pid'].'_'.$row['oid']]).'\' WHERE poll_id='.$row['pid'].' AND item_id='.$row['oid'].';');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   526
              if(!$q) $db->_die('The poll data could not be updated.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   527
              $row['v'] = $_POST['value_'.$row['pid'].'_'.$row['oid']];
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   528
            }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   529
            // Sorry guys, really, I hate to make a ton of queries here but there's really no other way to do this :'(
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   530
            $q = $db->sql_query('SELECT * FROM '.table_prefix.'poll_results WHERE poll_id='.$row['pid'].' AND item_id='.$row['oid'].';');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   531
            if(!$q) $db->_die('The poll result data could not be selected.');
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   532
            echo '<tr><td><input name="value_'.$row['pid'].'_'.$row['oid'].'" value="'.htmlspecialchars($row['v']).'" /></td><td>'.$db->numrows().'</td><td style="text-align: center"><input name="update_'.$row['pid'].'_'.$row['oid'].'" type="submit" value="Update" />  <input name="delete_'.$row['pid'].'_'.$row['oid'].'" type="submit" value="Delete" /></td></tr>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   533
          }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   534
          //$last_pid
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   535
        }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   536
      ?>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   537
      <tr><td colspan="2"><input name="value_<?php echo $l[$key][0]['pid']; ?>" type="text" /></td><td style="text-align: center;"><input type="submit" name="create_<?php echo $l[$key][0]['pid']; ?>" value="Create option" /></td>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   538
    </table>
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   539
    <?php
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   540
    echo '</form>';
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   541
  }
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   542
}
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   543
e96ded22104a First revision, moved around a bit but other than that mostly unchanged from the old version from stable.
Dan
parents:
diff changeset
   544
?>