<?php $id = $_GET['sid']; $db = new libraries_slideshow(); $data['info'] = $db->getdata($id); $abc = "../public/images/slider/" . $data['info']['slide_image'] . ""; @unlink($abc); $db->del_slide("tbl_slideshow", $id); header("location:index.php?mod=slideshow&act=list"); exit;
<?php $data = array(); $data['title'] = "Sửa slide show"; $data['template'] = "slideshow/edit_slide"; $db = new libraries_slideshow(); $id = $_GET['sid']; $data['info'] = $db->getdata($id); if (isset($_POST['ok'])) { $title = $_POST['slide_title']; $status = $_POST['status']; //$alt = $_POST['slide_alt']; $dir = "../public/images/slider/"; $types = array("image/gif", "image/GIF", "image/JPG", "image/jpg", "image/JPEG", "image/jpeg", "image/png", "image/PNG", "application/x-zip-compressed", "application/msword", "application/vnd.ms-excel"); $tmp_name = $_FILES["upload"]["tmp_name"]; $new_name = $_FILES["upload"]["name"]; if (in_array($_FILES["upload"]["type"], $types)) { move_uploaded_file($tmp_name, $dir . $new_name); $img = $_FILES["upload"]["name"]; } else { echo "<script>alert('Định dạng file không hợp lệ !');</script>"; } if ($_FILES["upload"]["name"] != NULL) { $data = array("slide_title" => $title, "slide_alt" => $title, "slide_status" => $status, "slide_image" => $img); } else { $data = array("slide_title" => $title, "slide_alt" => $title, "slide_status" => $status); } $db->update_slide($data, $id); header("location:index.php?mod=slideshow&act=list"); exit; }
<?php $data = array(); $data['title'] = "Danh sách slide show"; $data['template'] = "slideshow/list_slide"; $db = new libraries_slideshow(); $pager = new libraries_pager(); $limit = 10; $pager->set_link("index.php?mod=slideshow&act=list"); $total = $db->total_slide(); $start = $pager->start(); $pages = $pager->page($total, $limit); $data['pagelist'] = $pager->listpage($pages, $start, $limit); $data['list'] = $db->list_slide($start, $limit); loadview("layout", $data);
<?php $data = array(); $data['title'] = "Thêm mới slide show"; $data['template'] = "slideshow/add_slide"; $db = new libraries_slideshow(); if (isset($_POST['ok'])) { $title = $_POST['slide_title']; //$alt = $_POST['slide_alt']; $dir = "../public/images/slider/"; $types = array("image/gif", "image/GIF", "image/JPG", "image/jpg", "image/JPEG", "image/jpeg", "image/png", "image/PNG", "application/x-zip-compressed", "application/msword", "application/vnd.ms-excel"); $tmp_name = $_FILES["upload"]["tmp_name"]; $new_name = $_FILES["upload"]["name"]; if (in_array($_FILES["upload"]["type"], $types)) { move_uploaded_file($tmp_name, $dir . $new_name); //$random = date("dmYHis").rand(); $img = $_FILES["upload"]["name"]; } else { echo "<script>alert('Định dạng file không hợp lệ !');</script>"; } $data = array("slide_title" => $title, "slide_alt" => $title, "slide_image" => $img); $db->add_slide($data); header("location:index.php?mod=slideshow&act=list"); exit; } loadview("layout", $data);