Ejemplo n.º 1
0
        echo $main_db->last_query;
    }
}
/*
 * Logo Upload
 * */
if (isset($_FILES['logo'])) {
    $temp = explode(".", $_FILES['logo']['name']);
    $newfilename = 'sitelogo' . '.' . end($temp);
    $data['post_content'] = $newfilename;
    $data['post_type'] = 'logo';
    $data['post_status'] = 'top';
    $hasLogo = $post->get_single_post_by('logo');
    if ($hasLogo != NULL) {
        unlink(UPLOAD_DIR . $hasLogo->post_content);
        $post->delete_post($hasLogo->id);
    }
    if (move_uploaded_file($_FILES['logo']['tmp_name'], UPLOAD_DIR . $newfilename)) {
        if ($post->insert_posts($data)) {
            $id[] = $main_db->insert_id;
        }
    }
    $allImg = $post->get_multi_results_by_ID($id);
    $return = '';
    $id = NULL;
    if ($allImg != NULL) {
        foreach ($allImg as $img) {
            $src = upload_dir() . $img->post_content;
            $return .= '<li> <a href="#" data-id="' . $img->id . '"> <span class="media_trash"> <i class="fa fa-times"></i></span><img src="' . $src . '" alt=""> </a></li>';
        }
        echo $return;
function delete_media()
{
    $post = new posts();
    global $main_db, $session;
    if (isset($_POST['action'])) {
        $file = $post->get_post_by_id($_POST['id']);
        unlink(UPLOAD_DIR . $file->post_content);
        if ($post->delete_post($_POST['id'])) {
            echo 'yes';
            $session->message('Your media has been deleted');
        } else {
            echo $main_db->last_query;
        }
    }
}
Ejemplo n.º 3
0
<?php

/**
 * Created by PhpStorm.
 * User: sahid
 * Date: 1/5/16
 * Time: 5:49 PM
 */
global $session;
$post = new posts();
if ($post->delete_post($_GET['id'])) {
    $session->message('Post Delete Successfull!');
    safe_redirect(admin_url('new-post') . '?post=' . $_GET['post']);
} else {
    echo $main_db->last_query;
    exit;
}