function delete($topic_id, $category_id) { $this->authenticate(); if (!is_valid_category($category_id)) { show_error('Invalid category'); exit; } if (!is_valid_topic($topic_id)) { show_error('Invalid Topic'); exit; } $response = $this->Topic_model->delete_topics($topic_id); if ($response["rc"]) { $this->session->set_flashdata("success_msg", $response["msg"]); redirect("admin/topic/listing_by_category_id/" . $category_id); } else { $this->session->set_flashdata("error_msg", $response["msg"]); redirect("admin/topic/listing_by_category_id/" . $category_id); } }
function topics_by_category_url() { $category_id = 0; if ($this->input->get("category_id")) { $category_id = $this->input->get("category_id"); } if (!is_valid_category($category_id)) { redirect("categories"); exit; } if ($category_id != 0) { $data["category_id"] = $category_id; $data["topics"] = $this->Topic_model->get_all_topics($category_id); $data["header"] = true; $data["_view"] = "topic/listing"; $data["footer"] = true; $this->load->view("layout/baseTemplate", $data); } else { redirect("categories"); } }
function post_belongs_to_topic() { $category_id = 0; $topic_id = 0; if ($this->input->get("category_id")) { $category_id = $this->input->get("category_id"); } if ($this->input->get("topic_id")) { $topic_id = $this->input->get("topic_id"); } if ($category_id != 0 && $topic_id == 0 || $category_id != 0 && !is_valid_category($category_id) || $topic_id != 0 && !is_valid_topic($topic_id)) { $this->session->set_flashdata("error", "Invalid parameters"); redirect("categories"); exit; } $data["category_id"] = $category_id; $data["topic_id"] = $topic_id; $data["posts"] = $this->Post_model->get_all_posts($topic_id); $data["header"] = true; $data["_view"] = "post/post_by_topic"; $data["footer"] = true; $this->load->view("layout/baseTemplate", $data); }
$category = $_POST['category']; $title = $_POST['title']; $subtitle = $_POST['subtitle']; $content = $_POST['content']; $created_on = date("Y-m-d"); $imageLink = $_POST['imageLink']; $videoLink = $_POST['videoLink']; $extra1 = "extra1"; $extra2 = "extra2"; $image['name'] = mysql_real_escape_string($image['name']); $title = mysql_real_escape_string($title); $subtitle = mysql_real_escape_string($subtitle); $content = mysql_real_escape_string($content); $seconds = microtime(true); $image_tmp_name = round($seconds * 1000); if (!is_valid_category($category)) { echo "Incorrect category"; } else { //History if ($category == "History") { $TARGET_PATH = "images/History/"; $TARGET_PATH .= $image_tmp_name . ".jpeg"; if ($image['name'] == "" || $content == "" || $title == "") { $_SESSION['error'] = "All fields are required"; echo "All fields are required"; } if (!is_valid_type($image)) { $_SESSION['error'] = "You must upload a jpeg, gif, or bmp"; } if (move_uploaded_file($image['tmp_name'], $TARGET_PATH)) { $sql = "insert into History (title,subheading,image_path,content,created_on,extra1,extra2) values ('{$title}','{$subtitle}','" . $TARGET_PATH . "','{$content}', '{$created_on}','{$extra1}','{$extra2}')";