���� JFIF �� � ( %"1"%)+...383,7(-.-
![]() Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20 System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 User : apache ( 48) PHP Version : 7.4.20 Disable Function : NONE Directory : /var/www/html/thietkewebvumi.com/admin_new/mod/ |
<?php class contact_custom{ function contact_custom (){ global $CORE, $TBS; $TBS->LoadTemplate(ADMIN_PATH."skin/contact_custom.html"); switch($CORE->input['code']){ default : $this->goList(); break; case 'detail' : $this->goDetail($id);break; case 'post': $this->goPost(); break; case 'del': $this->goDel(); break; } } function goDetail($id){ global $CORE, $DB, $TBS, $func, $print; $TBS->MergeField('section','detail'); if(!$id){ $id = intval($CORE->input['id']); } if($id=='') return $this->goList(); $query = $DB->query("SELECT * FROM NNCCMS_contact_custom WHERE id = '$id'"); if($DB->get_num_rows($query)==0) return $this->goList(); $row = $DB->fetch_row($query); $row['des'] = html_entity_decode($row['des']); $detail[] = $row; if(is_null($detail)) $detail = array(); $TBS->MergeBlock('detail',$detail); $TBS->Show(TBS_OUTPUT+TBS_NOTHING); } function goList(){ global $CORE, $DB, $TBS, $func, $print; $TBS->MergeField('section','list'); if($CORE->input['task']=='reorder'){ // Do reorder ---------------- $input_arr = $CORE->input; $query = $DB->query("SELECT id,pos FROM NNCCMS_contact_custom"); while($row = $DB->fetch_row($query)) { if($DB->get_num_rows($query)==1) $this->goDetail($row['id']); foreach($input_arr as $k => $v){ $k = intval ($k); $v = intval ($v); if($k==$row['id']) $DB->query("UPDATE NNCCMS_contact_custom SET `pos`='$v' WHERE `id`='$k'"); } } return $print->redirect ('Đã lưu thứ tự',$CORE->admin_url.'&act=contact_custom'); } if($CORE->input['task']=='activate'){ // Do activate ---------------- $selected = explode("|",$CORE->input['sids']); foreach ($selected as $v) $DB->query("UPDATE NNCCMS_contact_custom SET `status`='1' WHERE `id`='$v'"); return $print->redirect ('Đã kích hoạt',$CORE->admin_url.'&act=contact_custom'); } if($CORE->input['task']=='deactivate'){ // Do activate ---------------- $selected = explode("|",$CORE->input['sids']); foreach ($selected as $v) $DB->query("UPDATE NNCCMS_contact_custom SET `status`='0' WHERE `id`='$v'"); return $print->redirect ('Đã bỏ kích hoạt',$CORE->admin_url.'&act=contact_custom'); } if($CORE->input['task']=='massdel'){ // Do activate ---------------- $selected = explode("|",$CORE->input['sids']); foreach ($selected as $v) { $q = $DB->query("SELECT id,img1 FROM NNCCMS_contact_custom WHERE `id`='$v'"); $r = $DB->fetch_row($q); if($r['img1']!='') unlink(ROOT_PATH.'upload/'.$r['img1']); $DB->query("DELETE FROM NNCCMS_contact_custom WHERE `id`='$v'"); } return $print->redirect ('Đã xóa',$CORE->admin_url.'&act=contact_custom'); } // Search - Category //$fcat = $func->drop_down_menu('fcat',$CORE->input['fcat'],'NNCCMS_contact_customcat','cid','cname','','Chọn nhóm...'); //$TBS->Mergefield('fcat',$fcat); // Filtering Begin -------------------------------------------------------- $where = "WHERE name<>''"; if($CORE->input['fstatus'] && $CORE->input['fstatus']<2) { $where .= " AND status=".$CORE->input['fstatus']; } if($CORE->input['fkeyword']) { $where .= " AND name LIKE '%".$CORE->input['fkeyword']."%'"; } // Filtering End -------------------------------------------------------- // Sorting Begin ----------------------------------------------------- if($CORE->input['sortby']) $_SESSION['prod_dirby'] = ($_SESSION['prod_dirby']==1) ? 0 : 1; $dbsort = ($CORE->input['sortby']) ? $CORE->input['sortby'] : $_SESSION['prod_sortby']; switch ($dbsort){ default : $sortby = 'ORDER BY pos DESC, time DESC'; break; case 'name' : $sortby = ($_SESSION['prod_dirby']==1) ? 'ORDER BY name DESC' : 'ORDER BY name'; break; case 'time' : $sortby = ($_SESSION['prod_dirby']==1) ? 'ORDER BY time DESC' : 'ORDER BY time'; break; case 'pos' : $sortby = ($_SESSION['prod_dirby']==1) ? 'ORDER BY pos DESC' : 'ORDER BY pos'; break; case 'status' : $sortby = ($_SESSION['prod_dirby']==1) ? 'ORDER BY status DESC' : 'ORDER BY status'; break; } $_SESSION['prod_sortby'] = $dbsort; // Sorting End -------------------------------------------------------- $pageNum = ($_GET['pageNum']>0) ? intval($_GET['pageNum']) : 1; $pageSize = 20; $from = (($pageNum * $pageSize) - $pageSize); //$t = $DB->query("SELECT a.id FROM NNCCMS_contact_custom"); $t = $DB->query("SELECT * FROM NNCCMS_contact_custom a ".$where); $total = mysql_num_rows($t); $totalPage = ceil($total / $pageSize); // Pagination DB $query = $DB->query("SELECT * FROM NNCCMS_contact_custom ".$where." ".$sortby." LIMIT $from, $pageSize"); $c = 0; while($row = $DB->fetch_row($query)) { $c++; $row['no'] = $c; $row['time'] = date('d/m/Y',$row['time']); $arr[] = $row; } if(is_null($arr)) $arr[] = array(); $TBS->MergeBlock('list',$arr); $nav = $print->Pagination($totalPage,$pageNum,$CORE->admin_url.'&act=contact_custom'); $TBS->MergeField('nav',$nav); $TBS->Show(TBS_OUTPUT+TBS_NOTHING); } function goPost(){ global $CORE, $DB, $func, $TBS, $print; $TBS->MergeField('section','post'); if($_SESSION['error']) unset($CORE->input['bsubmit']); // Show post ----------------------------------------------------------------------- if(!$CORE->input['bsubmit']){ $id = intval($CORE->input['id']); if ($_SESSION['error']) $prevError = $_SESSION['error']; unset($_SESSION['error']); if ($_SESSION['state']) $prevState = $_SESSION['state']; unset($_SESSION['state']); if($prevState!=NULL){ $data = $prevState; }else{ if($id==0){ $data['status'] = 1; }else{ $query = $DB->query( "SELECT c.*, n.* FROM NNCCMS_contact_custom n LEFT JOIN NNCCMS_contact_customcat c on (n.cid = c.cid) WHERE id='".$id."'"); $data = $DB->fetch_row($query); } } $data['cat'] = $func->drop_down_menu('cat',$data['cid'],'NNCCMS_contact_customcat','cid','cname',''); //,'Không chọn...' //$fcat = $func->drop_down_menu('fcat',$CORE->input['fcat'],'NNCCMS_contact_customcat','cid','cname','','Chọn nhóm'); $data['intro'] = $func->loadWYS('intro',$data['intro'],10); $data['eintro'] = $func->loadWYS('eintro',$data['eintro'],10); $data['body'] = $func->loadWYS('body',$data['body'],20); $data['ebody'] = $func->loadWYS('ebody',$data['ebody'],20); $data['noibat'] = $func->makebox($data['noibat'],'noibat'); $data['status'] = $func->yes_no($data['status'],'status'); $error[] = $prevError; $post[] = $data; $TBS->MergeBlock('error',$error); $TBS->MergeBlock('post',$post); // Show page -------------- $TBS->Show(TBS_OUTPUT+TBS_NOTHING); // Do post ------------------------------------------- }else{ $id = $state['id'] = intval($CORE->input['id']); $cat = $state['cat'] = intval($CORE->input['cat']); $title = $state['title'] = $CORE->input['title']; $etitle = $state['etitle'] = $CORE->input['etitle']; $img = $state['img'] = $CORE->input['img']; $intro = $state['intro'] = $CORE->input['intro']; $eintro = $state['eintro'] = $CORE->input['eintro']; $body = $state['body'] = $CORE->input['body']; $ebody = $state['ebody'] = $CORE->input['ebody']; //$price = $state['price'] = intval($CORE->input['price']); $noibat = $state['noibat'] = intval($CORE->input['noibat']); $pos = $state['pos'] = intval($CORE->input['pos']); $status = $state['status'] = intval($CORE->input['status']); $time = time(); // -------------- check ------------------------- if($title=='') $error['title'] = 1; // Create image ------------------------------------------------------------------------ include( ROOT_PATH."lib/class_upload.php" ); $handle = new Upload($_FILES['post_image']); if ($handle->uploaded) { // Check image size and image type if($handle->file_src_size>=500000) $error['image'] = 1; if(!in_array($handle->file_src_mime,array('image/jpeg','image/pjpeg','image/gif','image/png','image/x-png'))) $error['image'] = 1; // process image ----------------- //$handle->image_resize = true; //$handle->image_ratio_crop = true; //$handle->image_x = $this->image_size; //$handle->image_y = $this->image_size; // Crop fill (image_backround_color) -------------------------------------------------------------------- $handle->image_resize = false; $handle->image_x = 300; $handle->image_ratio_y = true; //$handle->image_ratio_fill = true; //$handle->image_x = 300; //$handle->image_y = 300; //$handle->image_background_color = '#ffffff'; //$handle->image_bevel = 5; //$handle->image_bevel_color1 = '#EEEEEE'; //$handle->image_bevel_color2 = '#EEEEEE'; //$handle->image_reflection_height = '50px'; //$handle->image_reflection_space = -50; $handle->Process(ROOT_PATH.'upload/'); // End process image ------------------- if(!$handle->processed) $error['image'] = 1; // Clear ---------------- $handle->Clean(); } elseif($CORE->input['del_img'] && $img) { if(file_exists(ROOT_PATH.'upload/'.$img)) unlink(ROOT_PATH.'upload/'.$img); $file_deleted = true; } // If detects any errors then return to the postform with errors if($error!=''){ $_SESSION['error'] = $error; $_SESSION['state'] = $state; return $this->goPost(); } //$body = str_replace('thietkeweb_vi/upload',$CORE->homeurl.'upload',$body); //$ebody = str_replace('thietkeweb_vi/upload',$CORE->homeurl.'upload',$ebody); // Do Add ------------------ if($id==0){ $DB->query("INSERT INTO `NNCCMS_contact_custom`(`cid`,`img`,`title`,`etitle`,`intro`,`eintro`,`body`,`ebody`,`time`,`pos`,`status`,`noibat`) VALUES( '".$cat."','".$handle->file_dst_name."','".$title."','".$etitle."','".$intro."','".$eintro."','".$body."','".$ebody."','".$time."','".$pos."','".$status."','".$noibat."');"); // Do Edit ----------------- }else{ if($handle->file_dst_name!=''){ $query = $DB->query("SELECT img FROM `NNCCMS_contact_custom` WHERE id='".$id."'"); $result = $DB->fetch_row($query); // Delete old files if($result['img'] !='') unlink(ROOT_PATH.'upload/'.$result['img']); $DB->query("UPDATE `NNCCMS_contact_custom` SET `img`='".$handle->file_dst_name."' WHERE `id`='".$id."'"); } elseif($file_deleted) { $DB->query("UPDATE `NNCCMS_contact_custom` SET `img`='' WHERE `id`='".$id."'"); } $DB->query("UPDATE `NNCCMS_contact_custom` SET `cid` = '$cat',`title` = '$title',`etitle` = '$etitle',`intro` = '$intro',`eintro` = '$eintro',`body` = '$body',`ebody` = '$ebody',`pos` = '$pos',`status` = '$status',`time` = '$time',`noibat` = '$noibat' WHERE `id`='$id'"); } return $print->redirect("Đã cập nhật","index.php?act=contact_custom"); } } function goDel(){ global $CORE, $DB, $print; $id = intval($CORE->input['id']); $query = $DB->query("SELECT img1 FROM NNCCMS_contact_custom WHERE id='".$id."'"); $result = $DB->fetch_row($query); // Delete old files --- if($result['img1'] !=''){ unlink(ROOT_PATH.'upload/'.$result['img1']); } $DB->query("DELETE FROM NNCCMS_contact_custom WHERE id='".$id."'"); $print->redirect("Đã xóa","index.php?act=contact_custom"); } } $run = new contact_custom(); ?>