Server IP : 119.59.102.212 / Your IP : 18.117.197.188 Web Server : Apache/2 System : Linux narin 2.6.32-042stab142.1 #1 SMP Tue Jan 28 23:44:17 MSK 2020 x86_64 User : yangkam ( 1022) PHP Version : 5.6.40 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/yangkam/domains/yangkam.go.th/public_html/coremain/module/question/ |
Upload File : |
<?php $sel_q = "select * from cms_question where id_sub = '".$_SESSION['id_sub']."'"; $que_q = mysql_query($sel_q); $obj_q = mysql_fetch_assoc($que_q); $qid = $obj_q['id_question']; $navig['question'] = $data_name_menu_sub['name']; navigator($navig); echo"<br>"; bar_header($data_name_menu_sub['name']); // Bar_Header fieldset_top($obj_q['topic']); import_request_variables('pG', 'p_'); # เปิด/ปิดรายการ if($p_status != ''){ $upd_status = "update cms_question_title set title_status = '$p_status' where title_id = '$p_parent'"; mysql_query($upd_status); } # เรียงลำดับ if($p_id_order != ''){ $get_curr = "select title_order from cms_question_title where title_id = '$p_parent'"; $que_curr = mysql_query($get_curr); $obj_curr = mysql_fetch_assoc($que_curr); $curr_order = $obj_curr['title_order']; $new_order = $p_id_order == '1' ? $curr_order - 1 : $curr_order + 1; $upd_other = "update cms_question_title set title_order = '$curr_order' where question_id = '$qid' and title_parent = '0' and title_order = '$new_order'"; mysql_query($upd_other); $upd_order_new = "update cms_question_title set title_order = '$new_order' where title_id = '$p_parent'"; mysql_query($upd_order_new); refresh_data('index.php?mod=question&path=question&id_sub='.$_SESSION['id_sub'].'&parent='.$p_parent, 1); } # ลบรายการ if($p_delete != ''){ # select current order $get_order = "select title_order from cms_question_title where title_id = '$p_parent'"; $que_order = mysql_query($get_order); $obj_order = mysql_fetch_assoc($que_order); $curr_order = $obj_order['title_order']; # delete $del_title = "delete from cms_question_title where title_parent = '$p_parent' or title_id = '$p_parent'"; mysql_query($del_title); $sel_curr = "select * from cms_question_title where title_parent = '0' and question_id = '$qid' and title_order >= '$curr_order'"; $que_curr = mysql_query($sel_curr); while($obj_curr = mysql_fetch_assoc($que_curr)){ mysql_query("update cms_question_title set title_order = (title_order - 1) where title_id = '$obj_curr[title_id]'"); } $del_choice = "delete from cms_question_choice where title_id = '$p_parent'"; mysql_query($del_choice); refresh_data('index.php?mod=question&path=question&id_sub='.$_SESSION['id_sub'].'&parent='.$p_parent, 1); } # question_title $array_title = array(); $sel_title = "select * from cms_question_title where question_id = '$qid' and title_parent = '0' order by title_order"; $que_title = mysql_query($sel_title); while($obj = mysql_fetch_assoc($que_title)){ $array_title[$obj['title_order']]['title'] = $obj; # question_choice $choice = array(); $sel_choice = "select * from cms_question_choice where question_id = '$qid' and title_id = '$obj[title_id]' order by choice_order"; $que_choice = mysql_query($sel_choice); while($_choice = mysql_fetch_assoc($que_choice)){ $choice[$_choice['choice_order']] = $_choice; } $array_title[$obj['title_order']]['choice'] = $choice; } # data_title $sel_data = "select * from cms_question_title where question_id = '$qid' and title_parent > '0' order by title_order"; $que_data = mysql_query($sel_data); while($obj = mysql_fetch_assoc($que_data)){ $array_data[$obj['title_parent']][$obj['title_order']] = $obj; } //debuga($array_title); $num_question = count($array_title); function get_client_ip() { $ipaddress = ''; if (getenv('HTTP_CLIENT_IP')) $ipaddress = getenv('HTTP_CLIENT_IP'); else if(getenv('HTTP_X_FORWARDED_FOR')) $ipaddress = getenv('HTTP_X_FORWARDED_FOR'); else if(getenv('HTTP_X_FORWARDED')) $ipaddress = getenv('HTTP_X_FORWARDED'); else if(getenv('HTTP_FORWARDED_FOR')) $ipaddress = getenv('HTTP_FORWARDED_FOR'); else if(getenv('HTTP_FORWARDED')) $ipaddress = getenv('HTTP_FORWARDED'); else if(getenv('REMOTE_ADDR')) $ipaddress = getenv('REMOTE_ADDR'); else $ipaddress = 'UNKNOWN'; return $ipaddress; } $user_ip = get_client_ip().'_'.$qid; ?> <form name="fm_questionnaire" method="post" action="index.php?mod=questionnaire&path=question&id_sub=<?= $_SESSION['id_sub'] ?>&parent=<?= $t_id ?>"> <input type="hidden" name="question_id" value="<?= $qid ?>" /> <input type="hidden" name="user_ip" value="<?= $user_ip ?>" /> <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center"> <?php foreach($array_title as $title_order => $title){ $t_id = $title['title']['title_id']; $type = $title['title']['type_id']; $icon_manage = '<br/>'; $td_value = 'width="100%"'; $td_manage = 'width="0"'; if($_SESSION['admin_web']=="admin" || $_SESSION['per']=="ok"){ $td_value = 'width="90%"'; $td_manage = 'width="10%"'; # Up if($title['title']['title_order'] > 1){ $icon_manage .= "<a href='index.php?mod=question&path=question&id_sub=".$_SESSION['id_sub']."&parent=".$t_id."&id_order=1'><img src='coremain/images/up.gif' border='0' title='เลื่อนขึ้น'></a> "; }else{ $icon_manage .= " "; } # Down if($title['title']['title_order'] < $num_question){ $icon_manage .= "<a href='index.php?mod=question&path=question&id_sub=".$_SESSION['id_sub']."&parent=".$t_id."&id_order=2'><img src='coremain/images/down.gif' border='0' title='เลื่อนลง'></a> "; }else { $icon_manage .= " "; } $icon_manage .= '<br/>'; # show - hide if($title['title']['title_status'] == '1'){ $icon_manage .= "<a href='index.php?mod=question&path=question&id_sub=".$_SESSION['id_sub']."&parent=".$t_id."&status=0' title='ซ่อนข้อมูล'><img src='coremain/images/show.gif' border='0'></a> "; }else{ $icon_manage .= "<a href='index.php?mod=question&path=question&id_sub=".$_SESSION['id_sub']."&parent=".$t_id."&status=1' title='แสดงข้อมูล'><img src='coremain/images/hide.gif' border='0'></a> "; } # Edit $icon_manage .= '<a href="index.php?mod=question_edit&path=question&id_sub='.$_SESSION['id_sub'].'&parent='.$t_id.'"><img src="coremain/images/edit.gif" border="0" title="แก้ไขข้อมูล"></a>'; # Delete $icon_manage .= " <a href='javascript:void(0);'><img src='coremain/images/del1.gif' border='0' title='ลบข้อมูล' onclick='return confirm_delete();'></a>"; } ?> <?php if($type == '1'){ ?> <tr valign="top"> <td <?= $td_value ?>> <table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse;"> <tr bgcolor="#f0e8d0"> <td colspan="2"> <b><?= $title['title']['title_name'] ?></b> </td> </tr> <?php if(isset($array_data[$t_id])){ foreach($array_data[$t_id] as $data_order => $data){ ?> <tr> <td width="40%"> <?= $data_order ?>) <?= $data['title_name'] ?><?php echo $data['title_validate'] == 1 ? ' <span style="color: #ff0000">*</span>' : '' ?> </td> <td width="60%"><input type="text" name="data_<?= $type ?>_<?= $data['title_id'] ?>_<?= $t_id ?>" size="40" <?php echo $data['title_validate'] == 1 ? 'validate="'.$data['title_name'].'"' : '' ?> /></td> </tr> <?php }} ?> </table> </td> <td <?= $td_manage ?> align="center"> <?php echo $icon_manage; ?> </td> </tr> <?php }else if($type == '2'){ $num_choice = count($title['choice']); $title_width = 100 - (10 * $num_choice); ?> <tr valign="top"> <td <?= $td_value ?>> <table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse;"> <tr bgcolor="#f0e8d0"> <td width="<?= $title_width ?>%"> <b><?= $title['title']['title_name'] ?></b> </td> <?php foreach($title['choice'] as $order_choice => $choice){ ?> <td width="10%" align="center"> <b><?= $choice['choice_name'] ?></b> </td> <?php } ?> </tr> <?php if(isset($array_data[$t_id])){ foreach($array_data[$t_id] as $data_order => $data){ ?> <tr> <td> <?= $data_order ?>) <?= $data['title_name'] ?> </td> <?php foreach($title['choice'] as $order_choice => $choice){ ?> <td align="center"><input type="radio" name="data_<?= $type ?>_<?= $data['title_id'] ?>_<?= $t_id ?>" value="<?= $choice['choice_id'] ?>" validate="<?= $data['title_name'] ?>" /></td> <?php } ?> </tr> <?php }} ?> </table> </td> <td <?= $td_manage ?> align="center"> <?php echo $icon_manage; ?> </td> </tr> <?php }else if($type == '3'){ ?> <tr valign="top"> <td <?= $td_value ?>> <table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse;"> <tr bgcolor="#f0e8d0"> <td colspan="2"> <b><?= $title['title']['title_name'] ?></b> </td> </tr> <?php if(isset($array_data[$t_id])){ $num_title = isset($array_data[$t_id]) ? count($array_data[$t_id]) : 0; $half = ceil($num_title/2); if($num_title%2 == 1){ $array_data[$t_id][($num_title + 1)] = ''; ++$half; } sort($array_data[$t_id]); ?> <tr valign="top"> <td width="50%" style="padding: 0;"> <?php foreach($array_data[$t_id] as $l => $data){ if($l < $half && is_array($data)){ ?><div style="padding: 3px; line-height: 16px;"> <input type="checkbox" class="val_<?= $t_id ?>" name="data_<?= $type ?>_<?= $data['title_id'] ?>_<?= $t_id ?>" validate="<?= $title['title']['title_name'] ?>" value="<?= $t_id ?>" <?= $data['title_other'] == '1' ? 'have_text="text_other_'.$data['title_id'].'"' : '' ?> /> <?= $data['title_name'] ?> <?php echo $data['title_other'] == '1' ? '<input type="text" name="text_other_'.$data['title_id'].'" size="20" />' : ''; ?> </div> <?php } } ?> </td> <td width="50%" style="padding: 0;"> <?php foreach($array_data[$t_id] as $l => $data){ if($l >= $half && is_array($data)){ ?><div style="padding: 3px; line-height: 16px;"> <input type="checkbox" class="val_<?= $t_id ?>" name="data_<?= $type ?>_<?= $data['title_id'] ?>_<?= $t_id ?>" validate="<?= $title['title']['title_name'] ?>" value="<?= $t_id ?>" <?= $data['title_other'] == '1' ? 'have_text="text_other_'.$data['title_id'].'"' : '' ?> /> <?= $data['title_name'] ?> <?php echo $data['title_other'] == '1' ? '<input type="text" name="text_other_'.$data['title_id'].'" size="20" />' : ''; ?> </div> <?php } } ?> </td> </tr> <?php } /*if(isset($array_data[$t_id])){ $num_title = isset($array_data[$t_id]) ? count($array_data[$t_id]) : 0; if($num_title%2 == 1){ $array_data[$t_id][($num_title + 1)] = ''; } foreach($array_data[$t_id] as $data_order => $data){ echo $data_order%2 == 0 ? '' : '<tr>'; ?> <td width="50%"> <?php if(is_array($data)){ ?> <input type="checkbox" name="data_<?= $type ?>_<?= $data['title_id'] ?>_<?= $t_id ?>" value="<?= $t_id ?>" <?= $data['title_other'] == '1' ? 'have_text="text_other_'.$data['title_id'].'"' : '' ?> /> <?= $data['title_name'] ?> <?php echo $data['title_other'] == '1' ? '<input type="text" name="text_other_'.$data['title_id'].'" size="20" />' : ''; ?> <?php } ?> </td> <?php echo $data_order%2 == 0 ? '</tr>' : ''; } }*/ ?> </table> </td> <td <?= $td_manage ?> align="center"> <?php echo $icon_manage; ?> </td> </tr> <?php }else if($type == '4'){ ?> <tr valign="top"> <td <?= $td_value ?>> <table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse;"> <tr bgcolor="#f0e8d0"> <td colspan="2"> <b><?= $title['title']['title_name'] ?></b> </td> </tr> <?php if(isset($array_data[$t_id])){ $num_title = isset($array_data[$t_id]) ? count($array_data[$t_id]) : 0; $half = ceil($num_title/2); if($num_title%2 == 1){ $array_data[$t_id][($num_title + 1)] = ''; ++$half; } sort($array_data[$t_id]); ?> <tr valign="top"> <td width="50%" style="padding: 0;"> <?php foreach($array_data[$t_id] as $l => $data){ if($l < $half && is_array($data)){ ?><div style="padding: 3px; line-height: 16px;"> <input type="radio" name="data_<?= $type ?>_<?= $t_id ?>_<?= $t_id ?>" value="<?= $data['title_id'] ?>" validate="<?= $title['title']['title_name'] ?>" <?= $data['title_other'] == '1' ? 'have_text="text_other_'.$data['title_id'].'"' : '' ?> /> <?= $data['title_name'] ?> <?php echo $data['title_other'] == '1' ? '<input type="text" name="text_other_'.$data['title_id'].'" size="20" style="padding: 0;" />' : ''; ?> </div> <?php } } ?> </td> <td width="50%" style="padding: 0;"> <?php foreach($array_data[$t_id] as $l => $data){ if($l >= $half && is_array($data)){ ?><div style="padding: 3px; line-height: 16px;"> <input type="radio" name="data_<?= $type ?>_<?= $t_id ?>_<?= $t_id ?>" value="<?= $data['title_id'] ?>" validate="<?= $title['title']['title_name'] ?>" <?= $data['title_other'] == '1' ? 'have_text="text_other_'.$data['title_id'].'"' : '' ?> /> <?= $data['title_name'] ?> <?php echo $data['title_other'] == '1' ? '<input type="text" name="text_other_'.$data['title_id'].'" size="20" style="padding: 0;" />' : ''; ?> </div> <?php } } ?> </td> </tr> <?php } /*if(isset($array_data[$t_id])){ if($num_title%2 == 1){ $array_data[$t_id][($num_title + 1)] = ''; } foreach($array_data[$t_id] as $data_order => $data){ echo $data_order%2 == 0 ? '' : '<tr>'; ?> <td width="50%"> <?php if(is_array($data)){ ?> <input type="radio" name="data_<?= $type ?>_<?= $t_id ?>_<?= $t_id ?>" value="<?= $data['title_id'] ?>" validate="<?= $title['title']['title_name'] ?>" <?= $data['title_other'] == '1' ? 'have_text="text_other_'.$data['title_id'].'"' : '' ?> /> <?= $data['title_name'] ?> <?php echo $data['title_other'] == '1' ? '<input type="text" name="text_other_'.$data['title_id'].'" size="20" />' : ''; ?> <?php } ?> </td> <?php echo $data_order%2 == 0 ? '</tr>' : ''; } }*/ ?> </table> </td> <td <?= $td_manage ?> align="center"> <?php echo $icon_manage; ?> </td> </tr> <?php }else if($type == '5'){ ?> <tr valign="top"> <td <?= $td_value ?>> <table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse;"> <tr valign="top"> <td width="30%"> <b><?= $title['title']['title_name'] ?> : </b> </td> <td width="70%"> <textarea name="data_<?= $type ?>_<?= $t_id ?>_<?= $t_id ?>" cols="50" rows="5"></textarea> </td> </tr> </table> </td> <td <?= $td_manage ?> align="center"> <?php echo $icon_manage; ?> </td> </tr> <?php }else if($type == '6'){ ?> <tr valign="top"> <td <?= $td_value ?>> <table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse;"> <tr bgcolor="#f0e8d0"> <td> <b><?= $title['title']['title_name'] ?></b> </td> </tr> <?php if(isset($array_data[$t_id])){ foreach($array_data[$t_id] as $data_order => $data){ ?> <tr> <td style="text-indent: 30px;"> <?= $data['title_name'] ?> </td> </tr> <?php }} ?> </table> </td> <td <?= $td_manage ?> align="center"> <?php echo $icon_manage; ?> </td> </tr> <?php } ?> <?php } ?> </table> <?php if(!isset($_SESSION['admin_web']) && !isset($_SESSION['per'])){ ?> <table border="0" cellpadding="0" cellspacing="1" align="center"> <tr height='40px'> <td> </td> <td ><img src='coremain/images/bullet2.gif'> รหัสลับ </td> <td> <div class='iframe' valign=top> <iframe name='ifrm' id='ifrm' src='coremain/module/question/secure_image.php' frameborder='0' WIDTH='120' HEIGHT='20' SCROLLING='no'></iframe> <a href='javascript:void(0)' onclick="loadIframe('ifrm', 'coremain/module/question/secure_image.php')"><img src='coremain/module/question/img/view_refresh.png' border=0 title="เปลี่ยนรูปใหม่"></a> </div> </td> </tr> <tr height='30px'> <td > </td> <td><img src='coremain/images/bullet2.gif'> กรอกรหัสลับ </td> <td><input name='secure_code'></td> </tr> </table> <?php } ?> </form> <?php if($_SESSION['admin_web']=="admin" || $_SESSION['per']=="ok"){ ?> <center> <FORM NAME='formnew' METHOD=POST ACTION='index.php?mod=question_title&path=question'> <input type="hidden" name="id_sub" value="<?= $_SESSION['id_sub'] ?>" /> <input type="hidden" name="sub_name" value="<?= $data_name_menu_sub['name'] ?>" /> <input type="hidden" name="question_id" value="<?= $qid ?>" /> <table width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#eff3f7' style="padding: 15px;"> <tr> <td align="right"><button type="submit" name="Submit" class="ui-button ui-widget ui-corner-all ui-state-focus" style="padding: 5px 10px;">เพิ่มหัวข้อ</button> </td> <td align="left"> <button type="button" onclick="window.location.href='index.php?mod=question_show&path=question&id_sub=<?= $_SESSION['id_sub'] ?>&question=<?= $qid ?>'" class="ui-button ui-widget ui-corner-all ui-state-focus" style="padding: 5px 10px;">ผลสำรวจ</button></td> </tr> </table> </FORM> </center> <?php }else{ ?> <table width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#eff3f7' style="padding: 15px;"> <tr> <td align="center"> <?php if($_COOKIE['question_'.$qid] == $user_ip){ ?> <h4>คุณทำการตอบแบบสอบถามนี้ไปแล้ว</h4> <?php }else{ ?> <button type="button" name="bt_send_questionnaire" class="ui-button ui-widget ui-corner-all ui-state-focus" id="bt_send_questionnaire" style="padding: 5px 10px;">ส่งแบบสอบถาม</button> <?php } ?> </td> </tr> </table> <?php } ?> <style> input, textarea{ background: #FFFFEE; } </style> <script language="javascript"> function loadIframe(iframeName, url) { if (window.frames[iframeName]) { $('input[name="secure_code"]').val(''); window.frames[iframeName].location = url; return false; } return true; } $('.topic_update').on('click', function(){ $('form[name="fm_topic_edit"]').submit(); }); function check_topic() { if(document.fm_question_edit.topic.value=="") { alert("กรุณากรอกชื่อแบบสำรวจ !") ; document.fm_question_edit.topic.focus() ; return false ; }else return true ; } $('.title_update').on('click', function(){ $('form[name="fm_title_edit"]').submit(); }); function check_title(){ if(document.fm_title_edit.title.value=="") { alert("กรุณากรอกหัวข้อ !") ; document.fm_title_edit.topic.focus() ; return false ; }else return true ; } $('.choice_update').on('click', function(){ $('form[name="fm_choice_edit"]').submit(); }); function check_choice(){ if(document.fm_choice_edit.choice.value == ''){ alert('กรุณากรอกตัวเลือก !'); document.fm_choice_edit.choice.focus(); return false; }else{ return true; } } function confirm_delete(){ if(confirm('หากคุณลบรายการนี้ ข้อมูลที่เกี่ยวข้องจะถูกลบทั้งหมด ?')){ window.location.href = 'index.php?mod=question&path=question&id_sub=<?= $_SESSION['id_sub'] ?>&parent=<?= $t_id ?>&delete=1'; } } $('#bt_send_questionnaire').on('click', function(){ var have_validate = {}; var text_validate = {}; $('form[name="fm_questionnaire"]').find('input').each(function(){ var name = $(this).attr('name'); if($(this).attr('type') == 'text' && $(this).attr('validate') !== undefined){ have_validate[name] = $(this).attr('type'); text_validate[name] = $(this).attr('validate'); }else if($(this).attr('type') == 'radio' && $(this).attr('validate') !== undefined){ have_validate[name] = $(this).attr('type'); text_validate[name] = $(this).attr('validate'); }else if($(this).attr('type') == 'checkbox' && $(this).attr('validate') !== undefined){ name = $(this).attr('class'); have_validate[name] = $(this).attr('type'); text_validate[name] = $(this).attr('validate'); } if($(this).is(':checked') && $(this).attr('have_text') !== undefined){ have_validate[$(this).attr('have_text')] = 'text'; text_validate[$(this).attr('have_text')] = 'อื่นๆ '; } }); var chk_submit = true; $.each(have_validate, function(i, j){ if(j == 'text' && $('input[name="'+ i +'"]').val() == ''){ alert('กรุณากรอก '+ text_validate[i]); $('input[name="'+ i +'"]').focus(); chk_submit &= false; return false; }else if(j == 'radio' && $('input[name="'+ i +'"]:checked').val() == undefined){ alert('กรุณาเลือก '+ text_validate[i]); chk_submit &= false; return false; }else if(j == 'checkbox' && $('input[class="'+ i +'"]:checked').val() == undefined){ alert('กรุณาเลือก '+ text_validate[i] +' อย่างน้อย 1 ตัวเลือก'); chk_submit &= false; return false; } }); if(chk_submit){ $.ajax({ url: 'coremain/module/question/set_secure_code.php', type: 'post', data: {secure_code: $('input[name="secure_code"]').val()}, success: function(response){ if(response == 'OK'){ $('form[name="fm_questionnaire"]').submit(); }else{ alert('รหัสลับไม่ถูกต้อง !'); } } }); } }); </script>