public function results() { if (!$this->isAdmin) { $this->login(); } $this->check(); $this->title("Manage " . $this->application); $this->CSS("results", "cpanel"); $this->CSS("pagination"); $this->js("checkbox"); $trash = segment(3, isLang()) === "trash" ? TRUE : FALSE; $total = $this->CPanel_Model->total($trash); $thead = $this->CPanel_Model->thead("checkbox, " . getFields($this->application) . ", Action", FALSE); $pagination = $this->CPanel_Model->getPagination($trash); $tFoot = getTFoot($trash); $this->vars["message"] = !$tFoot ? "Error" : NULL; $this->vars["pagination"] = $pagination; $this->vars["trash"] = $trash; $this->vars["search"] = getSearch(); $this->vars["table"] = getTable(__(_("Manage " . ucfirst($this->application))), $thead, $tFoot, $total); $this->vars["view"] = $this->view("results", TRUE, "cpanel"); $this->render("content", $this->vars); }
/** * * function getPageTitle * * */ function getPageTitle() { $CI =& get_instance(); $page_index = $CI->uri - segment(1) . '/' . $CI->uri - segment(2); $title = array('catalog/index' => 'Catalog', 'settings/edit_store' => 'Settings', 'pricingoverview/' => 'Reports', 'reports/' => 'Reports', 'reports/show' => 'Reports', '' => ''); return isset($title[$page_index]) ? 'TrackStreet :: ' . $title[$page_index] : 'TrackStreet'; }
private function limit() { if (isLang()) { if (segment(1) === "videos" and segment(2) > 0) { $start = segment(2) * _maxLimitVideos - _maxLimitVideos; } else { $start = 0; } } else { if (segment(0) === "videos" and segment(1) > 0) { $start = segment(2) * _maxLimitVideos - _maxLimitVideos; } else { $start = 0; } } $limit = $start . ", " . _maxLimitVideos; $count = $this->Videos_Model->count(); $URL = path("videos/"); if ($count > _maxLimitVideos) { $this->pagination = paginate($count, _maxLimitVideos, $start, $URL); } else { $this->pagination = NULL; } return $limit; }
function edit() { $data['title'] = 'Cập nhật danh mục tin tức'; $data['save'] = true; $data['apply'] = true; $data['cancel'] = 'category'; $id = segment(3, 'int'); $data['rs'] = $this->category->get_cat_by_id($id); $data['listmain'] = $this->category->get_all_category(); $data['list'] = $this->category->get_category_by_lang($id); // Form validation //foreach($this->language as $lang): $this->form_validation->set_rules('vdata[cat_name][' . $lang[0]->lang_id . ']', 'Danh mục ' . $lang[0]->lang_name, 'required'); $this->form_validation->set_rules('vdata[cat_des][' . $lang[0]->lang_id . ']', '', ''); $this->form_validation->set_rules('vdata[cat_keyword][' . $lang[0]->lang_id . ']', '', ''); //endforeach; $this->form_validation->set_rules('vdata[cat_order]', '', ''); $this->form_validation->set_rules('vdata[parent_id]', '', ''); if ($this->form_validation->run() === FALSE) { $this->pre_message = validation_errors(); } else { $vdata = $this->request->post['vdata']; $idata['cat_order'] = $vdata['cat_order']; $idata['published'] = $vdata['published']; $idata['parent_id'] = $vdata['parent_id']; if ($this->db->update('category', $idata, array('cat_id' => $id))) { $this->db->delete('category_des', array('cat_id' => $id)); for ($i = 0; $i < sizeof($this->language); $i++) { $val1 = $this->language[0]; $val = $this->language[$i]; $vdes['cat_id'] = $id; $vdes['lang_id'] = $val->lang_id; $vdes['cat_name'] = $vdata['cat_name'][$val->lang_id] != '' ? $vdata['cat_name'][$val->lang_id] : $vdata['cat_name'][$val1->lang_id]; $vdes['cat_slug'] = vnit_change_title($vdes['cat_name']); $vdes['cat_des'] = $vdata['cat_des'][$val->lang_id] != '' ? $vdata['cat_des'][$val->lang_id] : $vdata['cat_des'][$val1->lang_id]; $vdes['cat_keyword'] = $vdata['cat_keyword'][$val->lang_id] != '' ? $vdata['cat_keyword'][$val->lang_id] : $vdata['cat_keyword'][$val1->lang_id]; $this->db->insert('category_des', $vdes); //Update news $parent_id = $vdata['parent_id']; $vnews['main_slug'] = $vdes['cat_slug']; //$vnews['main_id'] = $vdes['cat_slug']; $this->db->update('news_des', $vnews, array('cat_id' => $id, 'lang_id' => $val->lang_id)); } $this->session->set_flashdata('message', 'Lưu thành công'); $option = $_POST['option']; if ($option == 'save') { $url = 'category'; } else { $url = uri_string(); } redirect($url); } } $data['message'] = $this->pre_message; $this->_templates['page'] = 'edit'; $this->load->templates($this->_templates['page'], $data); }
function del() { $id = segment(3, 'int'); if ($this->db->delete('weblink', array('id' => $id))) { $this->session->set_flashdata('message', 'Xóa thành công'); } else { $this->session->set_flashdata('message', 'Xóa không thành công'); } redirect('weblink/ds'); }
function del() { $id = segment(3, 'int'); $page = segment(4, 'int'); if ($this->db->delete('dangky', array('id' => $id))) { $msg = "Xóa thành công"; } else { $msg = "Xóa không thành công"; } $this->session->set_flashdata('message', $msg); redirect('dangky/ds/' . $page); }
function index() { $data['title'] = lang('khachhang'); $config['base_url'] = base_url() . $this->lang_url . 'khach-hang'; $config['suffix'] = '.html'; $config['total_rows'] = $this->khachhang->get_num_khachhang($this->lang_id); $data['num'] = $config['total_rows']; $config['per_page'] = 15; $config['uri_segment'] = 2; $this->load->library('pagination'); $this->pagination->initialize($config); $data['list'] = $this->khachhang->get_all_khachhang($config['per_page'], segment(2, 'int'), $this->lang_id); $data['pagination'] = $this->pagination->create_links(); $this->load->templates('index', $data); }
function result() { $s = $this->request->get['keyword']; $key = str_replace('+', ' ', $s); $data['key'] = $key; $data['title'] = lang('s.timkiem') . ': ' . $key; $config['base_url'] = base_url() . $this->lang_url . 'tim-kiem'; $config['suffix'] = '.html?keyword=' . $s; $config['total_rows'] = $this->search->get_num_product($this->lang_id, $key); $data['num'] = $config['total_rows']; $config['per_page'] = 20; $config['uri_segment'] = 2; $this->load->library('pagination'); $this->pagination->initialize($config); $data['list'] = $this->search->get_all_product($config['per_page'], segment(2, 'int'), $this->lang_id, $key); $data['pagination'] = $this->pagination->create_links(); $this->load->templates('result', $data); }
function cat() { $slug = $this->uri->segment(2); $catinfo = $this->news->get_catinfo_by_slug($this->lang_id, $slug); $data['title'] = lang('tintuc') . ': ' . $catinfo->cat_name; $data['catinfo'] = $catinfo; $config['base_url'] = base_url() . $this->lang_url . 'tin-tuc/' . $slug; $config['suffix'] = '.html'; $config['total_rows'] = $this->news->get_num_news($this->lang_id, $catinfo->cat_id); $data['num'] = $config['total_rows']; $config['per_page'] = 8; $config['uri_segment'] = 3; $this->load->library('pagination'); $this->pagination->initialize($config); $data['list'] = $this->news->get_all_news($config['per_page'], segment(3, 'int'), $this->lang_id, $catinfo->cat_id); $data['pagination'] = $this->pagination->create_links(); $this->load->templates('cat', $data); }
function ds() { $data['title'] = 'Quản lý Module'; $data['add'] = 'mod/readadd'; $data['delete'] = true; $field = $this->request->get['f'] != '' ? $this->request->get['f'] : 'm-id'; $order = $this->request->get['o'] != '' ? $this->request->get['o'] : 'desc'; $config['suffix'] = '/' . $field . '/' . $order; $config['base_url'] = base_url() . 'mod/ds/'; $config['total_rows'] = $this->mod->get_num_modules(); $data['num'] = $config['total_rows']; $config['per_page'] = 20; $config['uri_segment'] = 3; $this->pagination->initialize($config); $data['list'] = $this->mod->get_all_modules($config['per_page'], segment(4, 'int'), str_replace('-', '.', $field), $order); $data['pagination'] = $this->pagination->create_links(); $this->_templates['page'] = 'index'; $this->load->templates($this->_templates['page'], $data); }
function edit() { $data['title'] = 'Cập nhật danh mục Cơ Quan Tổ Chức'; $data['save'] = true; $data['apply'] = true; $data['cancel'] = 'category'; $id = segment(3, 'int'); $data['rs'] = $this->office->get_office_id($id); $data['listmain'] = $this->office->get_all_office(); $data['list'] = $this->office->get_office_id($id); // var_dump( $data['list'] ); // Form validation //foreach($this->language as $lang): $this->form_validation->set_rules('vdata[title]', 'Tên Cơ Quan Tổ Chức', 'required'); $this->form_validation->set_rules('vdata[website]', 'Website', ''); $this->form_validation->set_rules('vdata[address]', 'Địa chỉ', 'required'); $this->form_validation->set_rules('vdata[phone_1]', 'Số điện thoại', ''); //endforeach; $this->form_validation->set_rules('vdata[ordering]', '', ''); $this->form_validation->set_rules('vdata[parent_id]', '', ''); if ($this->form_validation->run() === FALSE) { $this->pre_message = validation_errors(); } else { $vdata = $this->request->post['vdata']; // var_dump($vdata); // exit(); if ($this->db->update('office', $vdata, array('id' => $id))) { //$this->db->delete('category_des', array('cat_id' => $id));, array('cat_id' => $id) $this->session->set_flashdata('message', 'Lưu thành công'); $option = $_POST['option']; if ($option == 'save') { $url = 'office'; } else { $url = uri_string(); } redirect($url); } } $data['message'] = $this->pre_message; $this->_templates['page'] = 'edit'; $this->load->templates($this->_templates['page'], $data); }
function routePath() { $flag = FALSE; $rsaquo = " ›› "; $path = path(whichApplication()); if (segments() > 0) { for ($i = 0; $i <= segments() - 1; $i++) { if (!$flag) { if (segments() === 6) { $flag = TRUE; $HTML = a(__(_("Home")), PATH("cpanel")) . $rsaquo; $HTML .= a(__(_(ucfirst(segment(2)))), $path . segment(2)) . $rsaquo; $HTML .= a(__(_(ucfirst(segment(3)))), $path . segment(2) . _sh . segment(3)) . $rsaquo; $HTML .= a(__(_(ucfirst(segment(4)))), $path . segment(2) . _sh . segment(3) . _sh . segment(4)) . $rsaquo; $HTML .= a(__(_(ucfirst(segment(5)))), $path . segment(2) . _sh . segment(3) . _sh . segment(4) . _sh . segment(5)); } elseif (segments() === 5) { $flag = TRUE; $HTML = a(__(_("Home"), path("cpanel"))) . $rsaquo; $HTML .= a(__(_(ucfirst(segment(2)))), $path . segment(2)) . $rsaquo; $HTML .= a(__(_(ucfirst(segment(3)))), $path . segment(2) . _sh . segment(3)) . $rsaquo; $HTML .= a(__(_(ucfirst(segment(4)))), $path . segment(2) . _sh . segment(3) . _sh . segment(4)); } elseif (segments() === 4) { $flag = TRUE; $HTML = a(__(_("Home")), path("cpanel")) . $rsaquo; $HTML .= a(__(_(ucfirst(segment(1)))), $path . "cpanel") . $rsaquo; $HTML .= a(__(_(ucfirst(segment(3)))), $path . segment(2) . _sh . segment(3)); } elseif (segments() === 3) { $flag = TRUE; $HTML = a(__(_("Home")), path("cpanel")) . $rsaquo; $HTML .= a(__(_(ucfirst(segment(1)))), $path . segment(3)); } elseif (segments() === 2) { $flag = TRUE; $HTML = a(__(_("Home")), path("cpanel")); } else { $HTML = a(__(_("Home")), path("cpanel")); } } } } return $HTML; }
public function index() { if (segment(2)) { switch (segment(2)) { case "gettoken": $this->token(); break; case "login": $this->login(); break; case "logout": $this->logout(); break; case "account": $this->account(); break; } } else { $this->login(); } }
public function showImage() { $data = $this->Gallery_Model->getByID(segment(3), TRUE); if (!$data) { redirect(_webBase . _sh . getXMLang(whichLanguage()) . _sh . _gallery); } if ($data["Album"] !== "None") { $this->count = $this->Gallery_Model->getCount($data["Album_Nice"]); } else { $this->count = $this->Gallery_Model->getCount(); } //Código para comentarios: /* if(isset($_POST["publishComment"])) { $this->Set("Comment"); } if($this->Users_Model->isMember()) { $vars["publish"] = TRUE; } if(isset($error) and is_array($error)) { $vars["error"] = $error; } $comments = $this->Gallery_Model->getComments($this->record["ID"]); if($comments == FALSE) $vars["comments"] = FALSE; else $vars["comments"] = $comments; */ $vars["count"] = $this->count; $vars["picture"] = $data; if (_webGalleryComments === TRUE) { $vars["view"][0] = $this->view("image", $this->application, TRUE); $vars["view"][1] = $this->view("comments", $this->application, TRUE); } else { $vars["view"] = $this->view("image", $this->application, TRUE); } $this->template("content", $vars); $this->Render(); }
public function getCategories($action = "add", $type = "checkbox", $name = "categories") { if ($action === "add") { $this->Categories_Model = $this->model("Categories_Model"); $data = $this->Categories_Model->categories(); if ($data) { $HTML = $this->build($data, NULL, $type, $name); } else { return FALSE; } unset($this->HTML); return $HTML; } elseif ($action === "edit") { $this->Categories_Model = $this->model("Categories_Model"); $categories = $this->Categories_Model->categories(); $data = $this->Categories_Model->getCategoriesByRecord("3", isLang() ? segment(4) : segment(3)); if ($data) { $i = 0; foreach ($categories as $category) { foreach ($data as $category_match) { if ($category["ID_Category"] === $category_match["ID_Category"]) { $categories[$i]["checked"] = TRUE; } } $i++; } } $data = $categories; if ($data) { $HTML = $this->build($data, NULL, $type, $name); } else { return FALSE; } unset($this->HTML); return $HTML; } }
?> "><a href="<?php echo url('diensten'); ?> ">diensten</a></li> <li class="<?php echo segment(0) == 'news' ? 'selected' : ''; ?> "><a href="<?php echo url('nieuws'); ?> ">nieuws</a></li> <li class="<?php echo segment(0) == 'testimonials' ? 'selected' : ''; ?> "><a href="<?php echo url('getuigenissen'); ?> ">getuigenissen</a></li> <li class="<?php echo segment(0) == 'contact' ? 'selected' : ''; ?> "><a href="<?php echo url('contact'); ?> ">contact</a></li> </ul> </nav> </div> </header> <div id="wrapper">
private function getView($view = NULL) { $view = segment(2); $vars["view"] = $this->view("{$view}", TRUE); $this->render("content", $vars); }
<?php // neprihlihláseného užívateľa presmeruje na prihlásenie if (!is_logged_in()) { redirect("/prihlasenie"); } // získame id článku z url adresy $post_id = segment(2); // ak sa tam žiadne id článku nenachádzalo, zobrazíme 404 stránku if (!$post_id) { show_404(); } // získame dáta o článku $post = get_post($post_id); // ak sme nezískali žiadne dáta, článok neexistuje a zobrazíme 404 stránku if (!$post) { show_404(); } // ak prihlásený užívateľ nie je majteľom článku, zobrazíme 404 stránku if (!is_owner($post)) { show_404(); } // ak bol na túto stránku odoslaný formulár... if (is_post()) { // ... vymažeme článok ... if (delete_post($post_id)) { // ... a ak sa úspešne vymazal, presmerujeme na úvodnú stránku redirect(); } } include_header(array("title" => "Vymazanie článku"));
function del() { $id = segment(3, 'int'); $page = segment(4, 'int'); if ($this->db->delete('user', array('user_id' => $id))) { $this->session->set_flashdata('message', 'Xóa thành công'); } else { $this->session->set_flashdata('error', 'Xóa không thành công'); } redirect('account/ds/' . $page); }
function whichLanguage($invert = true, $lower = false) { global $Load; $Load->helper("router"); if (isLang(segment(0))) { if (segment(0) and !$invert) { return segment(0); } elseif (segment(0) and getLang(segment(0), true)) { return $lower ? strtolower(getLang(segment(0), true)) : getLang(segment(0), true); } elseif (!$invert) { return getLang(_get("webLanguage")); } else { return $lower ? strtolower(_get("webLanguage")) : _get("webLanguage"); } } else { if (!$invert) { return getLang(_get("webLanguage")); } else { return $lower ? strtolower(_get("webLanguage")) : _get("webLanguage"); } } }
public function response($data, $segment = 4, $method = "GET") { if ($this->method() === $method) { if (isLang() and segment($segment) === "xml" or !isLang() and segment($segment - 1) === "xml") { header("Content-Type: text/xml"); $this->Array2XML = $this->core("Array2XML"); $this->Array2XML->printXML($data, "data", "contact"); } else { print json_encode($data); } } else { return false; } }
public function count($type = "posts") { if (isLang()) { $year = isYear(segment(1)) ? segment(1) : FALSE; $month = isMonth(segment(2)) ? segment(2) : FALSE; $day = isDay(segment(3)) ? segment(3) : FALSE; } else { $year = isYear(segment(0)) ? segment(0) : FALSE; $month = isMonth(segment(1)) ? segment(1) : FALSE; $day = isDay(segment(2)) ? segment(2) : FALSE; } if ($type === "posts") { if ($year and $month and $day) { $count = $this->Db->countBySQL("Language = '{$this->language}' AND Year = '{$year}' AND Month = '{$month}' AND Day = '{$day}' AND Situation = 'Active'", $this->table); } elseif ($year and $month) { $count = $this->Db->countBySQL("Language = '{$this->language}' AND Year = '{$year}' AND Month = '{$month}' AND Situation = 'Active'", $this->table); } elseif ($year) { $count = $this->Db->countBySQL("Language = '{$this->language}' AND Year = '{$year}' AND Situation = 'Active'", $this->table); } else { $count = $this->Db->countBySQL("Language = '{$this->language}' AND Situation = 'Active'", $this->table); } } elseif ($type === "comments") { $count = 0; } elseif ($type === "tag") { $data = $this->getByTag(segment(3)); $count = count($data); } elseif ($type === "categories") { $data = $this->getByCategory(segment(3)); $count = count($data); } return isset($count) ? $count : 0; }
function edit() { $get = $this->request->get; $str = ''; foreach ($get as $val => $keys) { $str .= '&' . $val . '=' . $keys; } $str = trim($str, '&'); $str_get = count($get) ? '?' . $str : ''; $data['title'] = 'Cập nhật bài viết'; $data['save'] = true; $data['apply'] = true; $data['cancel'] = 'news/ds/' . $this->uri->segment(4) . '/' . $str_get; $id = segment(3, 'int'); $data['listcategory'] = $this->news->get_all_category(); $data['rs'] = $this->news->get_info_new($id); $data['list'] = $this->news->get_news_by_id($id); $row = $this->db->row("SELECT * FROM category WHERE cat_id=" . $data['rs']->catid); if ($row->parent_id == 0) { $cat = $row->cat_id; } else { $cat = $row->parent_id; } $data['channel'] = $this->news->get_list_channel($cat); // Form validation foreach ($this->language as $lang) { $this->form_validation->set_rules('vdata[title][' . $lang->lang_id . ']', 'Tiêu đề: ' . $lang->lang_name, 'required'); $this->form_validation->set_rules('vdata[fulltext][' . $lang->lang_id . ']', '', ''); $this->form_validation->set_rules('vdata[introtext][' . $lang->lang_id . ']', '', ''); } $this->form_validation->set_rules('vdata[cat_id]', '', ''); $this->form_validation->set_rules('vdata[published]', '', ''); $this->form_validation->set_rules('vdata[metakey]', '', ''); $this->form_validation->set_rules('vdata[metadesc]', '', ''); if ($this->form_validation->run() === FALSE) { $this->pre_message = validation_errors(); } else { $vdata = $this->request->post['vdata']; $attr = $_POST['attr']; $idata['cat_id'] = $vdata['cat_id']; $idata['published'] = $vdata['published']; $idata['noibat'] = $this->request->post['noibat']; $idata['created_by'] = $_SESSION['user_id']; $idata['modified'] = time(); $idata['attr'] = ''; $idata['attr'] .= 'show_intro=' . $attr['show_intro']; $idata['attr'] .= '&show_author=' . $attr['show_author']; $idata['attr'] .= '&show_date=' . $attr['show_date']; $idata['attr'] .= '&show_editdate=' . $attr['show_editdate']; $idata['attr'] .= '&show_print=' . $attr['show_print']; $idata['attr'] .= '&show_email=' . $attr['show_email']; $idata['attr'] .= '&show_comment=' . $attr['show_comment']; $idata['attr'] .= '&show_other=' . $attr['show_other']; if ($_FILES["userfile"]["size"] > 0) { $config['upload_path'] = ROOT . 'data/news/default/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '10000'; $config['file_name'] = vnit_change_title($vdata['title'][$this->lang_default]); $this->load->library('upload', $config); $this->upload->initialize($config); if (!$this->upload->do_upload()) { $this->pre_message = $this->upload->display_errors(); $this->session->set_flashdata('error', $this->pre_message); redirect(uri_string()); } else { $result = $this->upload->data(); $idata['images'] = $result['file_name']; vnit_resize_image(ROOT . 'data/news/default/' . $idata['images'], ROOT . 'data/news/80/' . $idata['images'], 80, 0, false); vnit_resize_image(ROOT . 'data/news/default/' . $idata['images'], ROOT . 'data/news/200/' . $idata['images'], 200, 0, false); vnit_resize_image(ROOT . 'data/news/default/' . $idata['images'], ROOT . 'data/news/300/' . $idata['images'], 300, 0, false); } } if ($this->db->update('news', $idata, array('id' => $id))) { $this->db->delete('news_des', array('id' => $id)); for ($i = 0; $i < sizeof($this->language); $i++) { $val1 = $this->language[0]; $val = $this->language[$i]; $vdes['id'] = $id; $vdes['cat_id'] = $idata['cat_id']; $vdes['lang_id'] = $val->lang_id; $vdes['title'] = $vdata['title'][$val->lang_id] != '' ? $vdata['title'][$val->lang_id] : $vdata['title'][$val1->lang_id]; $vdes['slug'] = vnit_change_title($vdes['title']); $vdes['cat_slug'] = $this->news->get_cat_by_id($vdata['cat_id'], $val->lang_id)->cat_slug; $vdes['main_slug'] = $this->news->main_cat_slug($vdata['cat_id'], $val->lang_id); $vdes['main_id'] = $this->news->main_cat_id($vdata['cat_id'], $val->lang_id); $vdes['introtext'] = $vdata['introtext'][$val->lang_id] != '' ? $vdata['introtext'][$val->lang_id] : $vdata['introtext'][$val1->lang_id]; $vdes['fulltext'] = $vdata['fulltext'][$val->lang_id] != '' ? $vdata['fulltext'][$val->lang_id] : $vdata['fulltext'][$val1->lang_id]; $this->db->insert('news_des', $vdes); } $this->session->set_flashdata('message', 'Lưu thành công'); $option = $_POST['option']; if ($option == 'save') { $url = 'news/ds/' . $this->uri->segment(4) . '/' . $str_get; } else { $url = uri_string(); } redirect($url); } } $data['message'] = $this->pre_message; $this->load->templates('edit', $data); }
public function records($trash = FALSE, $order = NULL) { $Model = ucfirst(segment(0, isLang())) . "_Model"; $this->{$Model} = $this->model($Model); if (isset($this->{$Model})) { if (POST("seek")) { $data = $this->{$Model}->cpanel("search", NULL, POST("field") . " " . POST("order"), POST("search"), POST("field")); if (!$data) { showAlert("Results not found", path(whichApplication() . "/cpanel/results")); } } else { $start = 0; if ($trash) { $start = (segment(4, isLang()) === "page" and segment(5, isLang()) > 0) ? segment(5, isLang()) * _maxLimit - _maxLimit : 0; } else { $start = (segment(3, isLang()) === "page" and segment(4, isLang()) > 0) ? segment(4, isLang()) * _maxLimit - _maxLimit : 0; } $limit = $start . ", " . _maxLimit; if (segment(3, isLang()) === "order") { $i = segment(4) ? 3 : 4; $j = segment(4) ? 4 : 5; if (segment($i) === "id") { $field = "ID"; } elseif (segment($i) === "end-date") { $field = "End_Date"; } elseif (segment($i) === "start-date") { $field = "Start_Date"; } elseif (segment($i) === "text-date") { $field = "Text_Date"; } else { $field = ucfirst(segment($i)); } if (segment($j) === "asc") { $data = $this->{$Model}->cpanel("all", $limit, "{$field} ASC", NULL, NULL, $trash); } elseif (segment($j) === "desc") { $data = $this->{$Model}->cpanel("all", $limit, "{$field} DESC", NULL, NULL, $trash); } } else { $data = $this->{$Model}->cpanel("all", $limit, $order, NULL, NULL, $trash); } } return $data; } return FALSE; }
<?php $site = current_site(); if (segment(1) == 'delete') { $file = where('id = %d', intval(segment(2)))->get_row('site>downloads'); @unlink(FILESPATH . $file->filename); where('id = %d', intval(segment(2)))->delete('site>downloads'); redirect('/admin/_downloadspopup'); } if (isset($_FILES['addFile']) && is_array($_FILES['addFile']['name'])) { $files = array(); foreach ($_FILES['addFile']['name'] as $index => $file_name) { $newfile = array(); foreach (array_keys($_FILES['addFile']) as $key) { $newfile[$key] = $_FILES['addFile'][$key][$index]; } $files[] = $newfile; } foreach ($files as $f) { if ($f['size']) { $toinsert = array(); $extension = substr($f['name'], strrpos($f['name'], '.') + 1); do { $name = md5(rand(0, 99999) . rand(0, 99999)); } while (file_exists(FILESPATH . $name . "." . $extension)); move_uploaded_file($f['tmp_name'], FILESPATH . $name . "." . $extension); $toinsert['orig_filename'] = $f['name']; $toinsert['filename'] = $name . '.' . $extension; $toinsert['upload_date'] = time(); $toinsert["site_id"] = intval($site->id); insert('site>downloads', $toinsert);
if (isset($config["db_name"])) { DB::setDbName($config["db_name"]); } if (isset($config["db_user"])) { DB::setDbUser($config["db_user"]); } if (isset($config["db_pass"])) { DB::setDbPass($config["db_pass"]); } // pridáme si ďalšie súbory s funkciami, ktoré budeme používať require_once APP_PATH . "/functions/general.php"; require_once APP_PATH . "/functions/message.php"; require_once APP_PATH . "/functions/auth.php"; require_once APP_PATH . "/functions/tasks.php"; // naštartujeme session potrebné pre prihlásenie a správičky if (!session_id()) { @session_start(); } // podstránky ktoré sú dostupné if (!file_exists(APP_PATH . "/routes.php")) { exit("Application error: Routes not found."); } $routes = (include APP_PATH . "/routes.php"); // v prvom segmente url máme podstránku $page = segment(1); // ak taká podstránka neexistuje v našom poli dostupných podstránok, tak zobrazíme 404 stránku if (!isset($routes[$page])) { show_404(); } // inak ju zobrazíme show_page($routes[$page]);
function del() { $id = segment(3, 'int'); $catid = segment(4, 'int'); if ($this->db->delete('th', array('id' => $id))) { $this->db->delete('th_des', array('id' => $id)); $msg = "Xóa thành công"; } else { $msg = "Xóa không thành công"; } $this->session->set_flashdata('message', $msg); redirect('tuvan/ds/' . $catid); }
function del() { $id = segment(3, 'int'); $page_ = segment(4, 'int'); if ($this->db->delete("wp_terms_link", array('ids' => $id))) { $error = 0; $msg = "Xóa link ID: " . $id . " thành công"; } else { $error = 1; $msg = "Xóa link ID: " . $id . " không thành công"; } $act = $error == 1 ? "notes" : "message"; $this->session->set_flashdata($act, $msg); redirect("term/ds/" . $page_ . '/' . $this->str); }
public function getAll(array $keys = array(), array $params = array(), array $limit = array()) { $result = array('count' => 0, 'data' => array()); if (empty($keys)) { $fields = "*"; } else { $fields = implode(',', $keys); } $where = '1=1'; if (isset($params['is_active']) && $params['is_active'] !== null) { $where .= " AND is_active='{$params['is_active']}'"; } if (isset($params['c_id']) && $params['c_id']) { $where .= " AND c_id='{$params['c_id']}'"; } if (isset($params['kw']) && $params['kw']) { $match = segment($params['kw']); if (empty($match)) { $where .= " AND `name` LIKE '%{$params['kw']}%'"; } else { $match = implode(' ', array_unique($match)); $where .= " AND ((`name` LIKE '%{$params['kw']}%' ) OR (MATCH(name_match) AGAINST('*{$match}*' IN BOOLEAN MODE)))"; } } $result['count'] = $this->field($fields)->where($where)->count(); $result['data'] = $this->field($fields)->where($where)->order('sort_order ASC, id DESC')->limit("{$limit['begin']}, {$limit['offset']}")->select(); return $result; }
function formSave($action = NULL) { if ($action === "save") { $href = path(segment(0, isLang()) . "/cpanel/add/"); } else { $href = path(segment(0, isLang()) . "/cpanel/edit/" . segment(3, isLang())); } $onclick = 'onclick="document.getElementById(\'form-add\').target=\'\'; document.getElementById(\'form-add\').action=\'' . $href . '\'"'; $HTML = ' <p class="save-cancel"> <input id="' . $action . '" name="' . $action . '" value="' . __(ucfirst($action)) . '" ' . $onclick . ' type="submit" class="btn btn-success"> <input id="cancel" name="cancel" value="' . __("Cancel") . '" type="submit" class="btn btn-danger" /> </p>'; return $HTML; }