Вход Регистрация
Файл: forum/pollsettings.php
Строк: 148
<?php
# Script by seg0ro http://mobilarts.ru
# Not for sale!!!

defined('_IN_JOHNCMS') or die('Error: restricted access');

$textl .= ' | Голосование';
require_once(
'../incfiles/head.php');

if (!
$topic){
  echo 
functions::display_error('Отсутствует идентификатор темы!<br /><a href="index.php">Форум</a>');
  require_once(
'../incfiles/end.php');
  exit;
}

if (
$rights != && $rights 6){
  echo 
functions::display_error('У вас недостаточно прав для просмотра этой страницы!<br /><a href="index.php">Форум</a>');
  require_once(
'../incfiles/end.php');
  exit;
}

$pollName = isset($_POST['poll_name']) ? trim($_POST['poll_name']) : $topicRes['poll_name'];

$tree = array('<a href="index.php">Форум</a>''<a href="index.php?topic='.$topic.'&amp;page='.$page.'">'.functions::checkout($topicRes['topicname']).'</a>''Голосование');
echo 
'<div class="phdr">'.functions::display_menu($tree).'</div>';

if (isset(
$_GET['delete'])){
  if (isset(
$_POST['yes'])){
    
mysql_query("DELETE FROM `forum_polls` WHERE `topic` = '$topic' LIMIT 50 ");
    
mysql_query("DELETE FROM `forum_polled` WHERE `topic` = '$topic' ");
      
    
mysql_query("UPDATE `forum_topics` SET
    `poll_name` = '',
    `poll_set` = ''
    WHERE `topic` = '
$topic' LIMIT 1 ");
      
    
mysql_query("OPTIMIZE TABLE `forum_polled` ");
    
    
header ('Refresh:1; URL=index.php?act=pollsettings&topic='.$topic.'&page='.$page);  
    echo 
'<div class="gmenu">Голосование удалено<br /><a href="index.php?act=pollsettings&amp;topic='.$topic.'&amp;page='.$page.'">Далее</a></div>';
  }else{
    echo 
'<form action="index.php?act=pollsettings&amp;topic='.$topic.'&amp;page='.$page.'&amp;delete" method="post"><div class="rmenu">Вы действительно хотите удалить голосование?<br /><input type="submit" name="yes" value="Удалить" /> <a href="index.php?act=pollsettings='.$topic.'&amp;page='.$page.'">Отмена</a></div></form>';
  }  
  require_once(
'../incfiles/end.php');
  exit;
}

if (isset(
$_GET['close'])){
  
$pollSet = array('poll_mod' => $pollSet['poll_mod'], 'total_polls' => $pollSet['total_polls'], 'total_polled' => $pollSet['total_polled'], 'poll_close' => '1');
  
mysql_query("UPDATE `forum_topics` SET
  `poll_set` = '"
.serialize($pollSet)."'
  WHERE `topic`='
$topic'
  "
);
  
$pollSet['poll_close'] = 1;
  echo 
'<div class="gmenu">Голосование закрыто</div>';
}

if (isset(
$_GET['open'])){
  
$pollSet = array('poll_mod' => $pollSet['poll_mod'], 'total_polls' => $pollSet['total_polls'], 'total_polled' => $pollSet['total_polled'], 'poll_close' => '0');
  
mysql_query("UPDATE `forum_topics` SET
  `poll_set` = '"
.serialize($pollSet)."'
  WHERE `topic` = '
$topic'
  "
);
  
$pollSet['poll_close'] = 0;
  echo 
'<div class="gmenu">Голосование открыто</div>';
}

if (isset(
$_POST['poll'])){
  if (empty(
$_POST['poll_name']))
    
$error .= 'Вы не ввели имя голосования!<br />';
    
  if (!
$topicRes['poll_name'] && (empty($_POST[0]) || empty($_POST[1])))
    
$error .= 'Не введены как минимум два варианта голосования!<br />';
  
  if (!
$error){
    if (
$topicRes['poll_name']){
      
$pollSet = array('poll_mod' => $pollSet['poll_mod'], 'total_polls' => $pollSet['total_polls'], 'total_polled' => $pollSet['total_polled'], 'poll_close' => $pollSet['poll_close']);
      
mysql_query("UPDATE `forum_topics` SET
      `poll_name` = '
$pollName',
      `poll_set` = '"
.serialize($pollSet)."'
      WHERE `topic` = '
$topic'
      "
);
      while (
$pollRes mysql_fetch_array($pollReq)){
        if (!empty (
$_POST[$pollRes['id']])){
          
$text mb_substr(trim($_POST[$pollRes['id']]), 0100);
          
mysql_query("UPDATE `forum_polls` SET
          `variantname` = '"
.mysql_real_escape_string($text)."'
          WHERE `id` = '"
.$pollRes['id']."'
          "
);
        }
      }
      
      
header ('Refresh:1; URL=index.php?topic='.$topic.'&page='.$page);
      echo 
'<div class="gmenu">Голосование изменено<br /><a href="index.php?topic='.$topic.'&amp;page='.$page.'">Далее</a></div>';
      require_once(
'../incfiles/end.php');
      exit;
    }else{
      
$polName mb_substr($pollName0200);
      
$pollSet = array('poll_mod' => intval($_POST['poll_mod']), 'total_polls' => '0''total_polled' => '0''poll_close' => '0');
      
mysql_query("UPDATE `forum_topics` SET
      `poll_name` = '"
.mysql_real_escape_string($pollName)."',
      `poll_set` = '"
.serialize($pollSet)."'
      WHERE `topic` = '
$topic'
      "
);
        
      if (
$_POST['count_vars'] > 20)
        
$_POST['count_vars'] = 20;
      elseif (
$_POST['count_vars'] < 2)
        
$_POST['count_vars'] = 2;
      for (
$var 0$var $_POST['count_vars']; $var++){
        
$vars mb_substr(trim($_POST[$var]), 0100);
        if (empty(
$vars)){
          continue;
        }
        
mysql_query("INSERT INTO `forum_polls` SET
        `topic` = '
$topic',
        `variantname` = '"
.mysql_real_escape_string($vars)."'
        "
);
      }
      
header ('Refresh:1; URL=index.php?topic='.$topic.'&page='.$page);
      echo 
'<div class="gmenu">Голосование создано<br /><a href="index.php?topic='.$topic.'&amp;page='.$page.'">Далее</a></div>';
      require_once(
'../incfiles/end.php');
      exit;
    }
  }
}

if (
$error)
  echo 
functions::display_error($error);

echo 
'<form id="form" action="index.php?act=pollsettings&amp;topic='.$topic.'&amp;page='.$page.'" method="post">';
if (
$topicRes['poll_name']){
  echo 
'<div class="list1">Название <img style="cursor: pointer;" onclick="alert(this.title);" src="images/question.png" alt="?" title="Максимально 200 символов" />:<br /><input type="text" name="poll_name" value="'.text($pollName).'" /><br />';
  while (
$pollRes mysql_fetch_assoc($pollReq)){
    echo 
'Вариант '.($i 1).' <img style="cursor: pointer;" onclick="alert(this.title);" src="images/question.png" alt="?" title="Максимально 100 символов" />:<br /><input type="text" name="'.$pollRes['id'].'" value="'.text($pollRes['variantname']).'" /><br />';          
    ++
$i;
  }
  echo 
'<input type="submit" name="poll" value="Сохранить" /></div><div class="rmenu"><a href="index.php?act=pollsettings&amp;topic='.$topic.'&amp;page='.$page.'&amp;delete">Удалить</a> <a href="index.php?act=pollsettings&amp;topic='.$topic.'&amp;page='.$page.'&amp;'.($pollSet['poll_close'] ? 'open">Открыть' 'close">Закрыть').'</a></div>';
}else{
  echo 
'<div class="list1">Название <img style="cursor: pointer;" onclick="alert(this.title);" src="images/question.png" alt="?" title="Максимально 200 символов" />:<br /><input type="text" name="poll_name" value="'.text($_POST['poll_name']).'" /><br />';

  if (isset(
$_POST['add']))
    ++
$_POST['count_vars'];
  elseif (isset(
$_POST['del']))
    --
$_POST['count_vars'];
  if (
$_POST['count_vars'] < || empty($_POST['count_vars']))
    
$_POST['count_vars'] = 2;
  elseif (
$_POST['count_vars'] > 20)
    
$_POST['count_vars'] = 20;
  for (
$vars 0$vars $_POST['count_vars']; $vars++){
    echo 
'Вариант '.($vars 1).' <img style="cursor: pointer;" onclick="alert(this.title);" src="images/question.png" alt="?" title="Максимально 100 символов" />:<br /><input type="text" name="'.$vars.'" value="'.text($_POST[$vars]).'" /><br />';
  }
  echo 
'<input type="hidden" name="count_vars" value="'.intval($_POST['count_vars']).'" />';
  echo 
$_POST['count_vars'] < 20 '<br /><input type="submit" name="add" value=" + " />' '';
  echo 
$_POST['count_vars'] > '<input type="submit" name="del" value=" - " /><br />' '<br />';
  echo 
'<label><input type="radio" value="0" name="poll_mod" '.($_POST['poll_mod'] == 'checked="checked" ' '').'/> Можно выбирать только один вариант</label><br />
<label><input type="radio" value="1" name="poll_mod" '
.($_POST['poll_mod'] == 'checked="checked" ' '').'/> Можно выбирать несколько вариантов</label><br /><input type="submit" name="poll" value="Сохранить" /></div>';
}

echo 
'</form>';
Онлайн: 0
Реклама