1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
<?php session_start(); include('../../../'.$_SESSION['web_name'].'/connect.php'); include('../../function_msg.php'); check_user_permission($_SESSION['admin_web']);
$arrayData = setArrayToAdd($_POST['formData']); $fileData = $_POST['fileData'];
$topic = $arrayData['topic']; $date_post = $arrayData['year'].$arrayData['month'].$arrayData['date']; $fulltexts = $arrayData['evar'];
$allow_image_type = allow_image_type(); $allow_document_type = allow_document_type(); $arrayFile = array(); $j = 1; $k = 1; foreach($fileData as $i => $file){ $_type = explode('.', $file['file_name']); $ftype = end($_type); if(in_array('.'.$ftype, $allow_image_type)){ $arrayFile['image'][$j] = $file; ++$j; }else if(in_array('.'.$ftype, $allow_document_type)){ $arrayFile['document'][$k] = $file; ++$k; } }
$name1 = $name2 = $name3 = $name4 = $name5 = ''; $explain1 = $explain2 = $explain3 = $explain4 = ''; $position_pic1 = $position_pic2 = $position_pic3 = $position_pic4 = ''; $chk_update = 1; $num_image = $arrayData['num_image']; $num_file = $arrayData['num_file']; $new_image = isset($arrayFile['image']) ? count($arrayFile['image']) : 0; $new_file = isset($arrayFile['document']) ? count($arrayFile['document']) : 0;
$count_image = 0; $count_file = 0; $select = "SELECT pic1, pic2, pic3, pic4, files FROM cms_news_page WHERE id_sub = '$_SESSION[id_sub]' AND id_type = '$_SESSION[id_type]'"; $query = mysql_query($select); $object = mysql_fetch_assoc($query); if(isset($arrayData['check_pic1']) && $arrayData['check_pic1'] == '1'){ // $count_image }
if($new_image <= $num_image && $new_file <= $num_file){ foreach($arrayFile as $file_type => $arr){ foreach($arr as $no => $obj){ if($file_type == 'image'){ ${'name'.$no} = $obj['file_name']; ${'explain'.$no} = $obj['explain']; ${'position_pic'.$no} = $obj['position_pic']; }else if($file_type == 'document'){ $name5 = $obj['file_name']; } } } }else{ $result = '0จำนวนรูปภาพต้องไม่เกิน 4 ภาพ และมีเอกสารประกอบได้เพียง 1 ไฟล์'; $chk_update = 0; } if($chk_update){ $who = isset($_SESSION['name_post']) ? $_SESSION['name_post'] : $_SESSION['admin_web']; $sql = "UPDATE `cms_news_page` SET `topic` = '$topic', `fulltexts` = '$fulltexts', `date_post` = '$date_post', `who` = '$who',`pic1` = '$name1', `position_pic1` = '$position_pic1',`explain1` = '$explain1',`pic2` = '$name2', `position_pic2` = '$position_pic2',`explain2` = '$explain2',`pic3` = '$name3', `position_pic3` = '$position_pic3',`explain3` = '$explain3',`pic4` = '$name4', `position_pic4` = '$position_pic4',`explain4` = '$explain4',`files` = '$name5' WHERE id_sub='$_SESSION[id_sub]' and id_type='$_SESSION[id_type]'"; mysql_query($sql);
$result = 'index.php?mod=news_page&path=news_page'; }
echo $result;
?>
|