pollController:procInsert 코드 정리

This commit is contained in:
SMaker 2013-12-30 17:57:15 +09:00
parent b6b3a78826
commit 8a7334ef12

View file

@ -20,9 +20,9 @@ class pollController extends poll
function procInsert() function procInsert()
{ {
$stop_date = Context::get('stop_date'); $stop_date = Context::get('stop_date');
if($stop_date < date("Ymd")) if($stop_date < date('Ymd'))
{ {
$stop_date = date("YmdHis", $_SERVER['REQUEST_TIME']+60*60*24*365); $stop_date = date('YmdHis', $_SERVER['REQUEST_TIME']+60*60*24*365);
} }
$logged_info = Context::get('logged_info'); $logged_info = Context::get('logged_info');
@ -30,17 +30,13 @@ class pollController extends poll
$args = new stdClass; $args = new stdClass;
$tmp_args = array(); $tmp_args = array();
unset($vars->_filter);
unset($vars->error_return_url);
unset($vars->stop_date);
foreach($vars as $key => $val) foreach($vars as $key => $val)
{ {
if(strpos($key,'tidx')) if(stripos($key, 'tidx'))
{
continue;
}
if(!preg_match("/^(title|checkcount|item)_/i", $key))
{
continue;
}
if(!trim($val))
{ {
continue; continue;
} }
@ -48,10 +44,14 @@ class pollController extends poll
$tmp_arr = explode('_', $key); $tmp_arr = explode('_', $key);
$poll_index = $tmp_arr[1]; $poll_index = $tmp_arr[1];
if(!$poll_index)
if($logged_info->is_admin != 'Y')
{ {
$val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); continue;
}
if(!trim($val))
{
continue;
} }
if($tmp_args[$poll_index] == NULL) if($tmp_args[$poll_index] == NULL)
@ -59,6 +59,16 @@ class pollController extends poll
$tmp_args[$poll_index] = new stdClass; $tmp_args[$poll_index] = new stdClass;
} }
if(!is_array($tmp_args[$poll_index]->item))
{
$tmp_args[$poll_index]->item = array();
}
if($logged_info->is_admin != 'Y')
{
$val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
}
if($tmp_arr[0] == 'title') if($tmp_arr[0] == 'title')
{ {
$tmp_args[$poll_index]->title = $val; $tmp_args[$poll_index]->title = $val;
@ -72,6 +82,7 @@ class pollController extends poll
$tmp_args[$poll_index]->item[] = $val; $tmp_args[$poll_index]->item[] = $val;
} }
} }
return new Object(-1, print_r($tmp_args, true));
foreach($tmp_args as $key => $val) foreach($tmp_args as $key => $val)
{ {
@ -79,6 +90,7 @@ class pollController extends poll
{ {
$val->checkcount = 1; $val->checkcount = 1;
} }
if($val->title && count($val->item)) if($val->title && count($val->item))
{ {
$args->poll[] = $val; $args->poll[] = $val;