Ejemplo n.º 1
0
<?php

$data = array();
$data['title'] = "Danh sách tin tức";
$data['template'] = "news/list_news";
$data['act'] = 5;
$news = new libraries_news();
$pager = new libraries_pager();
$limit = 10;
$pager->set_link("index.php?mod=news&act=list");
$total = $news->total_news();
$start = $pager->start();
$pages = $pager->page($total, $limit);
$data['pagelist'] = $pager->listpage($pages, $start, $limit);
$data['news'] = $news->list_news($start, $limit);
loadview("layout", $data);
Ejemplo n.º 2
0
<?php

$data = array();
$data['title'] = "Sửa tin tức";
$data['template'] = "news/edit_news";
$data['act'] = 5;
$id = $_GET['nid'];
$news = new libraries_news();
$data['info'] = $news->getdata($id);
$data['cate'] = $news->list_cate();
if (isset($_POST['ok'])) {
    $title = $_POST['news_title'];
    $author = $_POST['news_author'];
    $info = $_POST['news_info'];
    $full = $_POST['news_full'];
    $cate = $_POST['news_cate'];
    $rewrite = replace($_POST['news_title']);
    $dir = "../uploads/news/thumb/";
    //đường dẫn
    //Kiểu file, Gif, jpeg, zip ::bạn có thể sửa đổi nếu thích
    $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");
    //Check to determine if the submit button has been pressed
    //Shorten Variables
    $tmp_name = $_FILES["upload"]["tmp_name"];
    $new_name = $_FILES["upload"]["name"];
    //Check MIME Type
    if (in_array($_FILES["upload"]["type"], $types)) {
        //Move file from tmp dir to new location
        move_uploaded_file($tmp_name, $dir . $new_name);
        $img = $_FILES["upload"]["name"];
    } else {
Ejemplo n.º 3
0
<?php

$data = array();
$data['title'] = "Thêm mới tin tức";
$data['template'] = "news/add_news";
$data['act'] = 5;
$news = new libraries_news();
$data['cate'] = $news->list_cate();
//debug($data['cate']);
if (isset($_POST['ok'])) {
    $title = $_POST['news_title'];
    $author = $_POST['news_author'];
    $info = $_POST['news_info'];
    $full = $_POST['news_full'];
    $cate = $_POST['news_cate'];
    $rewrite = replace($_POST['news_title']);
    $dir = "../uploads/news/thumb/";
    //Bạn nên thay đổi đường dẫn cho phù hợp
    //Kiều file, Gif, jpeg, zip ::bạn có thể sửa đổi nếu thích
    $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");
    //Check to determine if the submit button has been pressed
    //Shorten Variables
    $tmp_name = $_FILES["upload"]["tmp_name"];
    $new_name = $_FILES["upload"]["name"];
    //Check MIME Type
    if (in_array($_FILES["upload"]["type"], $types)) {
        //Move file from tmp dir to new location
        move_uploaded_file($tmp_name, $dir . $new_name);
        $img = $_FILES["upload"]["name"];
    } else {
        //Print Error Message
Ejemplo n.º 4
0
<?php

$id = $_GET['nid'];
$db = new libraries_news();
$db->del_news("tbl_news", $id);
header("location:index.php?mod=news&act=list");
exit;