Файл: vsime.com/polls/inc/poll_diary_create.php
Строк: 186
<?
$title .= ' - Создание опроса';
ex_head();
if (isset($_SESSION['poll_diary_new']['oki'])) {
header("Location: /diary/?act=create");
exit();
}
if(!isset($_SESSION['poll_diary_new']))
{
$_SESSION['poll_diary_new']=array();
$_SESSION['poll_diary_new']['text']=NULL;
$_SESSION['poll_diary_new']['vars']=array();
$_SESSION['poll_diary_new']['vars'][]=NULL;
$_SESSION['poll_diary_new']['vars'][]=NULL;
$_SESSION['poll_diary_new']['multi']=0;
$_SESSION['poll_diary_new']['polltime']='infin';
}
$poll_new=$_SESSION['poll_diary_new'];
// Counter of Variants
$count_vars=count($poll_new['vars']);
// Save New Poll
if(isset($_POST['submited']) && isset($_POST['poll_text']))
{
if (hsc(@$_POST['mdp'])==$mdp)
{
$_SESSION['poll_diary_new']['text']=$_POST['poll_text'];
if(isset($_POST['multi']) && $_POST['multi']==1)$_SESSION['poll_diary_new']['multi']=1;else $_SESSION['poll_diary_new']['multi']=0;
if(in_array($_POST['polltime'],array('infin','day','3days','week','month','3months')))$_SESSION['poll_diary_new']['polltime']=$_POST['polltime'];
$pros=0;
$_SESSION['poll_diary_new']['vars']=array();
$count_vars_not_null = 0;
foreach ($_POST as $key => $value)
{
if (str_replace('vaRiant_','x',$key)!=$key)
{
$pros++;
$_SESSION['poll_diary_new']['vars'][] = $value;
if (strlen(trim($value)) > 0)$count_vars_not_null++;
if($pros==100)break;
}
}
if(strlen($_POST['poll_text']) < $min_size_poll)$error[] = 'Короткое описание опроса.';
if(strlen($_POST['poll_text']) > $max_size_poll)$error[] = 'Слишком длинное описание опроса.';
if($count_vars_not_null < 2)$error[] = 'Вы не заполнили варианты ответов.';
if(!isset($error))
{
$_SESSION['poll_diary_new']['vars']=array();
foreach ($_POST as $key => $value)
{
if (str_replace('vaRiant_','x',$key)!=$key)
{
if (strlen(trim($value)) > 0)$_SESSION['poll_diary_new']['vars'][] = $value;
}
}
$_SESSION['poll_diary_new']['oki']=1;
header("Location: /diary/?act=create");
exit;
}
} else hacked_by_Killer();
}
// Add Variant
if(isset($_POST['add_vaRiant']) && $count_vars<=9 && hsc(@$_POST['mdp'])==$mdp)
{
$_SESSION['poll_diary_new']['text']=$_POST['poll_text'];
if(isset($_POST['multi']) && $_POST['multi']==1)$_SESSION['poll_diary_new']['multi']=1;else $_SESSION['poll_diary_new']['multi']=0;
if(in_array($_POST['polltime'],array('infin','day','3days','week','month','3months')))$_SESSION['poll_diary_new']['polltime']=$_POST['polltime'];
$_SESSION['poll_diary_new']['vars']=array();
$pros=0;
foreach ($_POST as $key => $value)
{
if (str_replace('vaRiant_','x',$key)!=$key)
{
$pros++;
$_SESSION['poll_diary_new']['vars'][]=$value;
if($pros==100)break;
}
}
$_SESSION['poll_diary_new']['vars'][]=NULL;
}
// Delete Variant
if(isset($_POST['delete_vaRiant']) && $count_vars>2 && hsc(@$_POST['mdp'])==$mdp)
{
$_SESSION['poll_diary_new']['text']=$_POST['poll_text'];
if(in_array($_POST['polltime'],array('infin','day','3days','week','month','3months')))$_SESSION['poll_diary_new']['polltime']=$_POST['polltime'];
if(isset($_POST['multi']) && $_POST['multi']==1)$_SESSION['poll_diary_new']['multi']=1;else $_SESSION['poll_diary_new']['multi']=0;
$_SESSION['poll_diary_new']['vars']=array();
$pros=0;
$ncountv=count($poll_new['vars']);
foreach ($poll_new['vars'] as $key => $value)
{
$pros++;
if($pros != $ncountv)$_SESSION['poll_diary_new']['vars'][] = $value;
}
}
$poll_new=$_SESSION['poll_diary_new'];
show_errors();
input_bbs('textarea', 1, array('fon' => 0, 'quote' => 0, 'url' => 0));
echo "<form method='post' action='' class='multi'>n";
echo "<div class='list'>n";
if(isset($_POST['poll_text']))$pt=$_POST['poll_text'];
else $pt=$poll_new['text'];
echo "Описание</b> (".sklon_text($max_size_poll,array('знак','знака','знаков')).")</span><br/>n";
echo "<textarea name='poll_text' id='textarea' rows='5' cols='17' style='width: 98%'>".input_value($pt)."</textarea><br />n";
echo "</div>n";
echo "<div class='list'>n";
$lp=0;
foreach ($poll_new['vars'] as $key => $value)
{
$lp++;
echo "<input type='text' style='width: 99%' name='vaRiant_$lp' value='".input_value($value)."'><br/>n";
}
echo "".($lp<=9?"<input style='width: ".($lp>2?50:100)."%' type='submit' name='add_vaRiant' value='Добавить' />":null)."".($lp>2?"<input style='width: ".($lp<=9?50:100)."%' type='submit' name='delete_vaRiant' value='Убрать' />":null)."n";
echo "<div class='clear'></div>n";
echo "</div>n";
echo "<div class='list'>n";
echo "Дата окончания через: </span>n";
echo "<select name='polltime'>n";
echo "<option value='infin'".($poll_new['polltime']=='infin'?" selected='selected'":null).">Бессрочное</option>n";
echo "<option value='day'".($poll_new['polltime']=='day'?" selected='selected'":null).">1 День</option>n";
echo "<option value='3days'".($poll_new['polltime']=='3days'?" selected='selected'":null).">3 Дня</option>n";
echo "<option value='week'".($poll_new['polltime']=='week'?" selected='selected'":null).">1 Неделю</option>n";
echo "<option value='month'".($poll_new['polltime']=='month'?" selected='selected'":null).">1 Месяц</option>n";
echo "<option value='3months'".($poll_new['polltime']=='3months'?" selected='selected'":null).">3 Месяца</option></select>n";
echo "<div class='clear'></div>n";
echo "</div>n";
echo "<div class='list'>n";
if(isset($_POST['multi']) && $_POST['multi']==1 || $poll_new['multi']==1)$multi=1;
echo "<input type='checkbox' name='multi' id='multi_1' value='1'".(isset($multi)?" checked='checked'":null)."> <label for='multi_1'>Выбор нескольких вариантов</label>n";
echo "</div>n";
echo "<div class='list'>n";
echo "<input type='hidden' name='mdp' value='".$mdp."'>n";
echo "<input type='submit' name='submited' style='width: 99%' value='Сохранить'>n";
echo "<div class='clear'></div>n";
echo "</div>n";
echo "</form>n";
echo "<div class='foot'>n";
echo image_back()."<a href='/diary/?act=create'>Назад</a>n";
echo "</div>";
ex_foot();
?>