예제 #1
0
global $session, $main_db;
if (isset($_POST['submit'])) {
    $data['post_title'] = $_POST['contact_title'];
    $data['post_content'] = $_POST['address_content'];
    $data['post_type'] = 'tab';
    $data['post_position'] = $_POST['tab_position'];
    if (isset($_GET['id'])) {
        if ($post->update_post($data, array('id' => $_GET['id']))) {
            $session->message("Your tab update successful! ");
            safe_redirect(admin_url('new-post') . '?post=tab&id=' . $_GET['id']);
        } else {
            var_dump($main_db->last_query);
            exit;
        }
    } else {
        if ($post->insert_posts($data)) {
            $session->message("Your tab has been created!");
            safe_redirect(admin_url('new-post') . '?post=tab&id=' . $main_db->insert_id);
        } else {
            var_dump($main_db->last_query);
            exit;
        }
    }
}
$current_post = NULL;
if (isset($_GET['id'])) {
    $current_post = $post->get_post_by_id($_GET['id']);
}
$allPosts = $post->get_post_by('address');
?>
function check_hotline()
{
    global $main_db;
    $post = new posts();
    if (isset($_POST['action'])) {
        $data['post_content'] = $_POST['hotline'];
        $data['post_type'] = 'hotline';
        $hotline = $post->get_single_post_by('hotline');
        if ($hotline == NULL) {
            if ($post->insert_posts($data)) {
                echo '1';
            }
        } else {
            if ($post->update_post($data, array('id' => $hotline->id))) {
                echo '2';
            }
        }
    }
}