diff --git a/ci_scms/.gitignore b/ci_scms/.gitignore new file mode 100644 index 0000000..3ebe0b2 --- /dev/null +++ b/ci_scms/.gitignore @@ -0,0 +1,4 @@ +img/upload/** +img/gallery/mid/** +img/gallery/orig/** +img/gallery/thumb/** \ No newline at end of file diff --git a/ci_scms/application/.htaccess b/ci_scms/application/.htaccess new file mode 100644 index 0000000..6c63ed4 --- /dev/null +++ b/ci_scms/application/.htaccess @@ -0,0 +1,6 @@ + + Require all denied + + + Deny from all + \ No newline at end of file diff --git a/ci_scms/application/controllers/Mgallery.php b/ci_scms/application/controllers/Mgallery.php new file mode 100644 index 0000000..fc9ed9e --- /dev/null +++ b/ci_scms/application/controllers/Mgallery.php @@ -0,0 +1,83 @@ +load->helper("url"); + redirect('gallery/view/'); + } + + public function view($gallery = "", $folder = "", $picture = "") + { + if (!$gallery || !$folder) { + $this->load->helper("url"); + redirect("main/index"); + } + + $this->load->model("multi_gallery_model"); + + $data["is_admin"] = $this->is_admin; + + $p = $this->multi_gallery_model->get_page_and_id_from_gallery_name($gallery); + + if (!$p) { + $this->load->helper("url"); + redirect("main/index"); + } + + $page = $p["page"]; + $pageid = $p["pageid"]; + + $data["pageid"] = $pageid; + $data["page"] = $page; + + $data["gallery_info"] = $this->multi_gallery_model->get_multi_gallery_folder($gallery, $folder); + $data["gallery_data"] = $this->multi_gallery_model->get_multi_gallery_folder_images($data["gallery_info"]["id"]); + + $picdata = null; + + if ($data["gallery_data"]) { + $found = false; + foreach ($data["gallery_data"] as $d) { + if ($d["link"] == strval($picture)) { + $picdata = $d; + $found = true; + break; + } + /* + if (is_numeric($picture)) { + if ($d["id"] == intval($picture)) { + $picdata = $d; + $found = true; + break; + } + } else { + if ($d["name"] == $picture) { + $picdata = $d; + $found = true; + break; + } + }*/ + } + + if (!$found) { + if ($data["gallery_data"]) { + $picdata = $data["gallery_data"][0]; + } + } + } + + $data["curr_pic"] = $picdata; + + $data["galleryname"] = $gallery; + $data["currpic"] = $picture; + + $this->_send_headers($page, "gallery"); + + $this->load->view("multigallery", $data); + + $this->_send_footer(); + } +} \ No newline at end of file diff --git a/ci_scms/application/controllers/admin.php b/ci_scms/application/controllers/admin.php new file mode 100644 index 0000000..c7ea123 --- /dev/null +++ b/ci_scms/application/controllers/admin.php @@ -0,0 +1,795 @@ +_manage_admin_session(); + $this->load->model("admin_model"); + } + + public function index() + { + $this->load->helper("url"); + redirect("admin/login"); + } + + public function login() + { + $this->load->helper("url"); + + $data["reg_enabled"] = $this->admin_model->is_registration_enabled(); + + $this->load->view("admin/login", $data); + } + + public function dologin() + { + $username = $this->input->post("user"); + $password = $this->input->post("pass"); + + $password = $this->salt_md5($password); + + if ($this->admin_model->check_user($username, $password)) + { + //let's generate the session data + $sessionid = $this->admin_model->get_or_create_session_id($username); + + if ($sessionid == -1) { + //echo "sessid -1"; + $this->load->helper('url'); + redirect("admin/login"); + } + + $cookie_session_id = $this->admin_model->create_cookie_session_id($username); + + if ($cookie_session_id == -1) { + $this->load->helper('url'); + redirect("admin/login"); + } + + if (!$this->admin_model->register_session($sessionid, $cookie_session_id)) { + $this->load->helper('url'); + redirect("admin/login"); + } + + $this->session->set_userdata('sid', $cookie_session_id); + + $this->load->helper('url'); + redirect("main/index"); + } else { + $this->load->helper('url'); + redirect("admin/login"); + } + } + + public function register() + { + $this->load->helper("url"); + + $data["reg_enabled"] = $this->admin_model->is_registration_enabled(); + + if ($data["reg_enabled"] == false) { + show_404(); + } + + $this->load->view("admin/register", $data); + } + + public function doregister() + { + $username = $this->input->post('user'); + $password = $this->input->post('pass'); + $password2 = $this->input->post('pass2'); + $email = $this->input->post('email'); + + if (!$username || !$password || !$password2 || !$email || !($password == $password2)) { + $this->load->helper('url'); + redirect("admin/register"); + } + + $password = $this->salt_md5($password); + + $this->admin_model->register_user($username, $password, $email); + + $this->load->helper('url'); + redirect("admin/login"); + } + + public function addcontent($page = -1, $elementid = -1) + { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + if ($page == -1) { + redirect("main/index"); + } + + $this->load->model("content_model"); + + if ($elementid == -1) { + redirect("main/index"); + } + + $data["pageid"] = $page; + $data["mode"] = "add"; + + switch ($elementid) { + case 1: + $this->load->view("admin/text", $data); + break; + case 3: + $this->load->view("admin/add_gallery", $data); + break; + case 4: + $this->load->view("admin/add_multi_gallery", $data); + break; + default: + redirect("main/index"); + } + } + + public function editcontent($page = -1, $elementid = -1, $contentid = -1) + { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + if ($page == -1 || $elementid == -1 || $contentid == -1) { + redirect("main/index"); + } + + $this->load->model("content_model"); + + $data["pageid"] = $page; + $data["contentid"] = $contentid; + $data["mode"] = "edit"; + $s = $this->content_model->get_content_text($contentid); + $data["text"] = $s["text_noformat"]; + + switch ($elementid) { + case 1: + $this->load->view("admin/text", $data); + break; + default: + redirect("main/index"); + } + } + + public function addtext($pageid = -1) + { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + $message = $this->input->post("message"); + + $this->load->model("content_model"); + $this->content_model->add_page_text($pageid, $message); + + redirect("main/index"); + } + + public function edittext($textid = -1) + { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + $message = $this->input->post("message"); + + $this->load->model("content_model"); + $this->content_model->edit_page_text($textid, $message); + + redirect("main/index"); + } + + public function contentdown($pageid = -1, $contentid = -1) { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + if ($pageid == -1 && $contentid == -1) + redirect("main/index"); + + $this->load->model("content_model"); + $this->content_model->content_down($pageid, $contentid); + + redirect("main/index"); + } + + public function contentup($pageid = -1, $contentid = -1) { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + if ($pageid == -1 && $contentid == -1) + redirect("main/index"); + + $this->load->model("content_model"); + $this->content_model->content_up($pageid, $contentid); + + redirect("main/index"); + } + + public function deletecontent($pageid = -1, $id = -1) { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + if ($pageid == -1 && $id == -1) + redirect("main/index"); + + $this->load->model("content_model"); + $this->content_model->content_delete($pageid, $id); + + redirect("main/index"); + } + + public function logout() { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + $this->admin_model->logout($_SESSION["sid"]); + unset($_SESSION['sid']); + + redirect("main/index"); + } + + public function logoutall() { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + $this->admin_model->logout_all($_SESSION["sid"]); + unset($_SESSION['sid']); + + redirect("main/index"); + } + + public function addgallery($page = -1) { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + if ($page == -1) + redirect("main/index"); + + $name = $this->input->post("name"); + $description = $this->input->post("description"); + + $this->load->model("content_model"); + $this->content_model->add_gallery($page, $name, $description); + + redirect("main/index"); + } + + public function addgalleryimage($galleryid = -1) { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + if ($galleryid == -1) + redirect("main/index"); + + $this->load->helper('form'); + $data["id"] = $galleryid; + $data["mode"] = 'add'; + $this->load->view("admin/add_gallery_img", $data); + + //redirect("main/index"); + } + + public function doaddgalleryimage($galleryid = -1) { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + if ($galleryid == -1) + redirect("main/index"); + + $name = $this->input->post("name"); + $description = $this->input->post("description"); + //$img = $this->input->post("img"); + + //$this->load->model("content_model"); + //$this->content_model->add_gallery_image($galleryid, $name, $description); + + $config['upload_path'] = './img/upload/'; + $config['allowed_types'] = 'gif|jpg|png'; + $config['max_size'] = 80000; + $config['max_width'] = 90000; + $config['max_height'] = 90000; + + $this->load->library('upload', $config); + + if ($this->upload->do_upload("img")) + { + //$data = array('upload_data' => $this->upload->data()); + //$this->load->view('upload_success', $data); + + $data = $this->upload->data(); + + /* + $data = array( + 'file_name' => $this->file_name, + 'file_type' => $this->file_type, + 'file_path' => $this->upload_path, + 'full_path' => $this->upload_path.$this->file_name, + 'raw_name' => str_replace($this->file_ext, '', $this->file_name), + 'orig_name' => $this->orig_name, + 'client_name' => $this->client_name, + 'file_ext' => $this->file_ext, + 'file_size' => $this->file_size, + 'is_image' => $this->is_image(), + 'image_width' => $this->image_width, + 'image_height' => $this->image_height, + 'image_type' => $this->image_type, + 'image_size_str' => $this->image_size_str, + ); + + */ + //var_dump($data); + //var_dump(gd_info()); + //var_dump(getimagesize($data["full_path"])); + + //first let's make a thumbnail + $res = null; + if ($data["file_type"] == "image/jpeg") { + $res = imagecreatefromjpeg($data["full_path"]); + } elseif ($data["file_type"] == "image/gif") { + $res = imagecreatefromgif($data["full_path"]); + } elseif ($data["file_type"] == "image/png") { + $res = imagecreatefrompng($data["full_path"]); + } else { + die("Nem támogatott kép formátum!"); + } + + //first let's crop out a rectangle from the middle + $size = getimagesize($data["full_path"]); + $width = $size[0]; + $height = $size[1]; + + $rect = null; + $cropped = imagecreatetruecolor(155, 155); + + if ($width > $height) { + $x = intval(($width - $height) / 2); + $y = 0; + $w = $height; + $h = $height; + + imagecopyresampled($cropped, $res, 0, 0, $x, $y, 155, 155, $w, $h); + //imagecopyresized($cropped, $res, 0, 0, $rect["x"], $rect["y"], 155, 155, $rect["width"], $rect["height"]); + } elseif($height > $width) { + $x = 0; + $y = intval(($height - $width) / 2); + $w = $width; + $h = $width; + + imagecopyresampled($cropped, $res, 0, 0, $x, $y, 155, 155, $w, $h); + //imagecopyresized($cropped, $res, 0, 0, $rect["x"], $rect["y"], 155, 155, $rect["width"], $rect["height"]); + //$cropped = imagecrop ($res, $rect); + } else { + imagecopyresampled($cropped, $res, 0, 0, 0, 0, 155, 155, $width, $height); + } + + //bool + imagejpeg($cropped, $data["file_path"] . "thumb.jpg", 100); + + //Now let's make a big version + //470 width + $imgsize = getimagesize($data["full_path"]); + $widthrat = 470 / $imgsize[0]; + $h = $imgsize[1] * $widthrat; + $h = intval($h); + $big = imagecreatetruecolor(470, $h); + imagecopyresampled($big, $res, 0, 0, 0, 0, 470, $h, $imgsize[0], $imgsize[1]); + //var_dump($imgsize); + //imagecopyresized($big, $res, 0, 0, 0, 0, 470, $h, $imgsize[0], $imgsize[1]); + imagejpeg($big, $data["file_path"] . "mid.jpg", 100); + + //Now let's make a big version + //1200 width + $imgsize = getimagesize($data["full_path"]); + $widthrat = 1200 / $imgsize[0]; + $h = $imgsize[1] * $widthrat; + $h = intval($h); + $big = imagecreatetruecolor(1200, $h); + imagecopyresampled($big, $res, 0, 0, 0, 0, 1200, $h, $imgsize[0], $imgsize[1]); + imagejpeg($big, $data["file_path"] . "big.jpg", 100); + + //now let's put hem into the img directory + $this->load->helper('file'); + + $finalfilename = $this->_get_unique_file_name(str_replace('\\', '/', realpath('') . '/img/gallery/orig/'), $name); + + $f = read_file($data["file_path"] . "big.jpg"); + $werfull = str_replace('\\', '/', realpath('') . '/img/gallery/orig/'); + $werfull = $werfull . $finalfilename . ".jpg"; + write_file($werfull, $f); + + $f = read_file($data["file_path"] . "thumb.jpg"); + $werthumb = str_replace('\\', '/', realpath('') . '/img/gallery/thumb/'); + $werthumb = $werthumb . $finalfilename . ".jpg"; + write_file($werthumb, $f); + + $f = read_file($data["file_path"] . "mid.jpg"); + $wermid = str_replace('\\', '/', realpath('') . '/img/gallery/mid/'); + $wermid = $wermid . $finalfilename . ".jpg"; + write_file($wermid, $f); + + $this->load->model("content_model"); + $this->content_model->add_gallery_image($galleryid, $name, $description, $finalfilename . ".jpg", $finalfilename . ".jpg", $finalfilename . ".jpg"); + + //$d = str_replace('\\', '/', realpath('') . '/img/upload/'); + delete_files('./img/upload/'); + } + else + { + //echo $this->upload->display_errors(); + //$error = array('error' => $this->upload->display_errors()); + //var_dump($error); + //$this->load->view('upload_form', $error); + } + + $this->load->model("gallery_model"); + $url = $this->gallery_model->get_gallery_link($galleryid); + redirect("gallery/view/" . $url); + } + + function delgalleryimage($galleryid = -1, $imageid = -1) { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + if ($galleryid == -1) + redirect("main/index"); + + if ($imageid == -1) + redirect("gallery/view/" . $galleryid); + + + $this->load->model("gallery_model"); + + $data = $this->gallery_model->del_gallery_image_from_db($imageid); + + if ($data) { + $this->load->helper('file'); + + $werfull = str_replace('\\', '/', realpath('') . '/img/gallery/orig/'); + $werfull = $werfull . $data["orig_img"]; + + if (get_file_info($werfull)) { + unlink($werfull); + } + + $werthumb = str_replace('\\', '/', realpath('') . '/img/gallery/thumb/'); + $werthumb = $werthumb . $data["thumb"]; + + if (get_file_info($werthumb)) { + unlink($werthumb); + } + + $wermid = str_replace('\\', '/', realpath('') . '/img/gallery/mid/'); + $wermid = $wermid . $data["img"]; + + if (get_file_info($wermid)) { + unlink($wermid); + } + } + + //$url = $this->gallery_model->get_gallery_name($galleryid); + redirect("gallery/view/" . $galleryid); + } + + public function addmultigallery($page = -1) { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + if ($page == -1) + redirect("main/index"); + + $name = $this->input->post("name"); + $description = $this->input->post("description"); + + $this->load->model("content_model"); + $this->content_model->add_multi_gallery($page, $name, $description); + + $this->redirect_to_pageid($page); + //redirect("main/index"); + } + + public function addmultigalleryfolder($galleryid = -1) { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + if ($galleryid == -1) + redirect("main/index"); + + if (!$this->input->post()) { + $this->load->helper('form'); + $data["id"] = $galleryid; + $data["mode"] = 'add'; + $this->load->view("admin/add_multi_gallery_folder", $data); + return; + } + + $name = $this->input->post("name"); + $description = $this->input->post("description"); + + $config['upload_path'] = './img/upload/'; + $config['allowed_types'] = 'gif|jpg|png'; + $config['max_size'] = 80000; + $config['max_width'] = 90000; + $config['max_height'] = 90000; + + $this->load->library('upload', $config); + + if ($this->upload->do_upload("img")) + { + $data = $this->upload->data(); + + //let's make a thumbnail + $res = null; + if ($data["file_type"] == "image/jpeg") { + $res = imagecreatefromjpeg($data["full_path"]); + } elseif ($data["file_type"] == "image/gif") { + $res = imagecreatefromgif($data["full_path"]); + } elseif ($data["file_type"] == "image/png") { + $res = imagecreatefrompng($data["full_path"]); + } else { + die("Nem támogatott kép formátum!"); + } + + //first let's crop out a rectangle from the middle + $size = getimagesize($data["full_path"]); + $width = $size[0]; + $height = $size[1]; + + $rect = null; + $cropped = imagecreatetruecolor(202, 202); + + if ($width > $height) { + $x = intval(($width - $height) / 2); + $y = 0; + $w = $height; + $h = $height; + + imagecopyresampled($cropped, $res, 0, 0, $x, $y, 202, 202, $w, $h); + } elseif($height > $width) { + $x = 0; + $y = intval(($height - $width) / 2); + $w = $width; + $h = $width; + + imagecopyresampled($cropped, $res, 0, 0, $x, $y, 202, 202, $w, $h); + } else { + imagecopyresampled($cropped, $res, 0, 0, 0, 0, 202, 202, $width, $height); + } + + //bool + imagejpeg($cropped, $data["file_path"] . "thumb.jpg", 100); + + //now let's put hem into the img directory + $this->load->helper('file'); + + $finalfilename = $this->_get_unique_file_name(str_replace('\\', '/', realpath('') . '/img/mgallery/folder/'), $name); + + $f = read_file($data["file_path"] . "thumb.jpg"); + $werthumb = str_replace('\\', '/', realpath('') . '/img/mgallery/folder/'); + $werthumb = $werthumb . $finalfilename . ".jpg"; + write_file($werthumb, $f); + + $this->load->model("multi_gallery_model"); + $this->multi_gallery_model->add_multi_gallery_folder($galleryid, $name, $description, $finalfilename . ".jpg"); + + delete_files('./img/upload/'); + } + else + { + //echo $this->upload->display_errors(); + //$error = array('error' => $this->upload->display_errors()); + //var_dump($error); + //$this->load->view('upload_form', $error); + } + + $this->load->model("multi_gallery_model"); + $url = $this->multi_gallery_model->get_page_name_from_gallery_id($galleryid); + redirect("main/index/" . $url); + } + + public function addmultigalleryimage($galleryid = -1, $folderid = -1) { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + if ($galleryid == -1 || $folderid == -1) + redirect("main/index"); + + if (!$this->input->post()) { + $this->load->helper('form'); + $data["id"] = $galleryid; + $data["folderid"] = $folderid; + $data["mode"] = 'add'; + $this->load->view("admin/add_multi_gallery_img", $data); + return; + } + + $name = $this->input->post("name"); + $description = $this->input->post("description"); + + $config['upload_path'] = './img/upload/'; + $config['allowed_types'] = 'gif|jpg|png'; + $config['max_size'] = 80000; + $config['max_width'] = 90000; + $config['max_height'] = 90000; + + $this->load->library('upload', $config); + + if ($this->upload->do_upload("img")) + { + $data = $this->upload->data(); + + $res = null; + if ($data["file_type"] == "image/jpeg") { + $res = imagecreatefromjpeg($data["full_path"]); + } elseif ($data["file_type"] == "image/gif") { + $res = imagecreatefromgif($data["full_path"]); + } elseif ($data["file_type"] == "image/png") { + $res = imagecreatefrompng($data["full_path"]); + } else { + die("Nem támogatott kép formátum!"); + } + + //first let's make a thumbnail + //let's crop out a rectangle from the middle + $size = getimagesize($data["full_path"]); + $width = $size[0]; + $height = $size[1]; + + $rect = null; + $cropped = imagecreatetruecolor(155, 155); + + if ($width > $height) { + $x = intval(($width - $height) / 2); + $y = 0; + $w = $height; + $h = $height; + + imagecopyresampled($cropped, $res, 0, 0, $x, $y, 155, 155, $w, $h); + } elseif($height > $width) { + $x = 0; + $y = intval(($height - $width) / 2); + $w = $width; + $h = $width; + + imagecopyresampled($cropped, $res, 0, 0, $x, $y, 155, 155, $w, $h); + } else { + imagecopyresampled($cropped, $res, 0, 0, 0, 0, 155, 155, $width, $height); + } + + //bool + imagejpeg($cropped, $data["file_path"] . "thumb.jpg", 100); + + //Now let's make a mid version + //470 width + $imgsize = getimagesize($data["full_path"]); + $widthrat = 470 / $imgsize[0]; + $h = $imgsize[1] * $widthrat; + $h = intval($h); + $mid = imagecreatetruecolor(470, $h); + imagecopyresampled($mid, $res, 0, 0, 0, 0, 470, $h, $imgsize[0], $imgsize[1]); + imagejpeg($mid, $data["file_path"] . "mid.jpg", 100); + + //Now let's make a big version + //1200 width + $imgsize = getimagesize($data["full_path"]); + $widthrat = 1200 / $imgsize[0]; + $h = $imgsize[1] * $widthrat; + $h = intval($h); + $big = imagecreatetruecolor(1200, $h); + imagecopyresampled($big, $res, 0, 0, 0, 0, 1200, $h, $imgsize[0], $imgsize[1]); + imagejpeg($big, $data["file_path"] . "big.jpg", 100); + + //now let's put hem into the img directory + $this->load->helper('file'); + + $finalfilename = $this->_get_unique_file_name(str_replace('\\', '/', realpath('') . '/img/mgallery/big/'), $name); + + $f = read_file($data["file_path"] . "big.jpg"); + $werfull = str_replace('\\', '/', realpath('') . '/img/mgallery/big/'); + $werfull = $werfull . $finalfilename . ".jpg"; + write_file($werfull, $f); + + $f = read_file($data["file_path"] . "thumb.jpg"); + $werthumb = str_replace('\\', '/', realpath('') . '/img/mgallery/thumb/'); + $werthumb = $werthumb . $finalfilename . ".jpg"; + write_file($werthumb, $f); + + $f = read_file($data["file_path"] . "mid.jpg"); + $wermid = str_replace('\\', '/', realpath('') . '/img/mgallery/mid/'); + $wermid = $wermid . $finalfilename . ".jpg"; + write_file($wermid, $f); + + $this->load->model("multi_gallery_model"); + $this->multi_gallery_model->add_gallery_image($folderid, $name, $description, $finalfilename . ".jpg", $finalfilename . ".jpg", $finalfilename . ".jpg", $finalfilename . ".jpg"); + + delete_files('./img/upload/'); + } + else + { + //echo $this->upload->display_errors(); + //$error = array('error' => $this->upload->display_errors()); + //var_dump($error); + //$this->load->view('upload_form', $error); + } + + $this->load->model("multi_gallery_model"); + $gn = $this->multi_gallery_model->get_gallery_name($galleryid); + $fn = $this->multi_gallery_model->get_folder_name($folderid); + redirect("mgallery/view/" . $gn . "/" . $fn); + } + + function delmultigalleryimage($galleryname = "", $foldername = "", $imageid = -1) { + if (!$this->is_admin) + show_404(); + + $this->load->helper("url"); + + if ($imageid == -1) + redirect("mgallery/view/" . $galleryname . "/" . $foldername); + + $this->load->model("multi_gallery_model"); + + $data = $this->multi_gallery_model->del_image_from_db($imageid); + + if ($data) { + $this->load->helper('file'); + + $werfull = str_replace('\\', '/', realpath('') . '/img/mgallery/big/'); + $werfull = $werfull . $data["big"]; + + if (get_file_info($werfull)) { + unlink($werfull); + } + + $werthumb = str_replace('\\', '/', realpath('') . '/img/mgallery/thumb/'); + $werthumb = $werthumb . $data["thumb"]; + + if (get_file_info($werthumb)) { + unlink($werthumb); + } + + $wermid = str_replace('\\', '/', realpath('') . '/img/mgallery/mid/'); + $wermid = $wermid . $data["mid"]; + + if (get_file_info($wermid)) { + unlink($wermid); + } + } + + redirect("mgallery/view/" . $galleryname . "/" . $foldername); + } +} \ No newline at end of file diff --git a/ci_scms/application/controllers/gallery.php b/ci_scms/application/controllers/gallery.php new file mode 100644 index 0000000..823aedd --- /dev/null +++ b/ci_scms/application/controllers/gallery.php @@ -0,0 +1,86 @@ +load->helper("url"); + redirect('gallery/view/'); + } + + public function view($gallery = "", $picture = "") + { + if (!$gallery) { + $this->load->helper("url"); + redirect("main/index"); + } + + $this->load->model("gallery_model"); + $this->load->model('menu_model'); + $this->load->model("content_model"); + + $data["is_admin"] = $this->is_admin; + + $p = $this->gallery_model->get_page_and_id_from_gallery_link($gallery); + + if (!$p) { + $this->load->helper("url"); + redirect("main/index"); + } + + $page = $p["page"]; + $pageid = $p["pageid"]; + + $data["pageid"] = $pageid; + $data["page"] = $page; + + $data["gallery_info"] = $this->gallery_model->get_gallery_info($gallery); + $data["gallery_data"] = $this->gallery_model->get_gallery_data($data["gallery_info"]["id"]); + + $picdata = null; + + if ($data["gallery_data"]) { + $found = false; + foreach ($data["gallery_data"] as $d) { + if ($d["link"] == strval($picture)) { + $picdata = $d; + $found = true; + break; + } + + /* + if (is_numeric($picture)) { + if ($d["id"] == intval($picture)) { + $picdata = $d; + $found = true; + break; + } + } else { + if ($d["name"] == $picture) { + $picdata = $d; + $found = true; + break; + } + }*/ + } + + if (!$found) { + if ($data["gallery_data"]) { + $picdata = $data["gallery_data"][0]; + } + } + } + + $data["curr_pic"] = $picdata; + + $data["galleryname"] = $gallery; + $data["currpic"] = $picture; + + $this->_send_headers($page, "gallery"); + + $this->load->view("gallery", $data); + + $this->_send_footer(); + } +} \ No newline at end of file diff --git a/ci_scms/application/controllers/index.html b/ci_scms/application/controllers/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/ci_scms/application/controllers/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/ci_scms/application/controllers/main.php b/ci_scms/application/controllers/main.php new file mode 100644 index 0000000..f3d043f --- /dev/null +++ b/ci_scms/application/controllers/main.php @@ -0,0 +1,90 @@ +load->model('menu_model'); + $this->load->model("content_model"); + $data["is_admin"] = $this->is_admin; + + if ($page != "") { + if (!$this->menu_model->is_page_valid($page)) { + show_404(); + } + } + + if ($page == "") { + $data = $this->menu_model->getFirstMenuItem(); + $page = $data["link"]; + } + + $pageid = $this->menu_model->getPageId($page); + $data["pageid"] = $pageid; + $content_data; + $contents; + $i = 0; + + if ($pageid != -1) { + $contentlinks = $this->content_model->get_page_contents($pageid); + + if (sizeof($contentlinks) > 0) + { + //first let's prep a class like array + foreach($contentlinks as $c) { + $contents[$i]["link"] = $c; + + $d = null; + if ($c["content_type"] == "1") { + $d = $this->content_model->get_content_text($c["content_id"]); + } elseif ($c["content_type"] == "3") { + $d["main"] = $this->content_model->get_content_gallery($c["content_id"]); + $d["data"] = $this->content_model->get_gallery_data($d["main"]["id"]); + } elseif ($c["content_type"] == "4") { + $d["main"] = $this->content_model->get_content_multi_gallery($c["content_id"]); + $d["folders"] = $this->content_model->get_content_multi_gallery_folders($d["main"]["id"]); + } + + $contents[$i]["data"] = $d; + + $i++; + } + } + } + + + $this->_send_headers($page); + + $htmld; + $j = 0; + + if (isset($contents)) { + if (sizeof($contents) > 0) { + $i = 0; + $data["contsize"] = sizeof($contents); + foreach ($contents as $c) { + $data["data"] = $c["data"]; + $data["link"] = $c["link"]; + $data["i"] = $i; + //var_dump($c["data"]); + //var_dump($c["data"]); + if ($c["link"]["content_type"] == 1) { + $data["htmld"][$j] = $this->load->view("textcontent", $data, true); + } else if ($c["link"]["content_type"] == 3) { + $data["htmld"][$j] = $this->load->view("gallerycontent", $data, true); + } else if ($c["link"]["content_type"] == 4) { + $data["htmld"][$j] = $this->load->view("multigallerycontent", $data, true); + } + + $i++; + $j++; + } + } + } + + $this->load->view("content", $data); + $this->_send_footer(); + } +} \ No newline at end of file diff --git a/ci_scms/application/core/V_Controller.php b/ci_scms/application/core/V_Controller.php new file mode 100644 index 0000000..583f325 --- /dev/null +++ b/ci_scms/application/core/V_Controller.php @@ -0,0 +1,159 @@ +isadmin = false; + $this->_manage_session(); + } + + function _manage_session() { + if (isset($_SESSION['sid'])) { + $this->load->model("admin_model"); + $this->is_admin = $this->admin_model->is_admin($_SESSION['sid']); + } + } + + function _manage_admin_session() { + } + + function _send_admin_headers() { + } + + function _send_headers($page, $type = "") { + $this->load->helper('url'); + + $data["title"] = "title"; + $data["pageid"] = $page; + $data["is_admin"] = $this->is_admin; + $data["type"] = $type; + + $this->load->helper("url"); + + $this->_send_header($data); + $this->_send_menu($data); + } + + function _send_header($data) { + $this->load->view("header", $data); + } + + function _send_menu($data) { + $this->load->model('menu_model'); + + $data["menu"] = $this->menu_model->getBaseMenuData(); + + $this->load->view("menu", $data); + } + + function _send_footer() { + $data["is_admin"] = $this->is_admin; + $this->load->view("footer", $data); + } + + function salt_md5($text) { + return hash("sha512", "dla=/aasdf42)%/sf14" . $text . "$)/fasdfh297452sdikfahzsbgdfa|"); + } + + function redirect_to_pageid($id) { + $this->load->helper('url'); + + if (!is_numeric($id)) + redirect("main/index"); + + if ($id < 0) + redirect("main/index"); + + $this->load->model("common_model"); + $pname = $this->common_model->get_page_name_from_id($id); + + if ($pname) + redirect("main/index/" . $pname); + else + redirect("main/index"); + } + + protected function _url_sanitize_name($name) { + //allowed a-z, A-Z, 0-9, _ + + $name = str_replace(" ","_", $name); + + //var_dump($name); + + $regex = '/[^A-Za-z0-9_]/'; + + $name = preg_replace($regex, "", $name); + + //var_dump($name); + + return $name; + } + + protected function _get_unique_file_name($path, $hint) { + $filename = ""; + + $this->load->helper('file'); + $dir = get_filenames($path); + + if ($hint) { + //$hint = str_replace(" ","_", $hint); + $hint = $this->_url_sanitize_name($hint); + $h = $hint . ".jpg"; + $mid = ""; + + if ($dir) { + $i = 0; + while (true) { + $ffound = false; + foreach ($dir as $d) { + if ($d == $h) { + $ffound = true; + break; + } + } + + if ($ffound) { + $mid = "_" . $i; + $h = $hint . $mid . ".jpg"; + } else { + return $hint . $mid; + } + + $i++; + } + } else { + return $hint; + } + } else { + if ($dir) { + $max = 0; + foreach ($dir as $d) { + $n = explode(".", $d); + if ($n[0]) { + $name = $n[0]; + + if (is_numeric($name)) { + $num = intval($name); + + if ($num > $max) { + $max = $num; + } + } + } + } + + $max++; + return $max; + } else { + return "1"; + } + } + + return $filename; + } +} diff --git a/ci_scms/application/core/V_Model.php b/ci_scms/application/core/V_Model.php new file mode 100644 index 0000000..20ada0f --- /dev/null +++ b/ci_scms/application/core/V_Model.php @@ -0,0 +1,51 @@ +escape($text); + $text = $this->convert_le_to_br($text); + $text = $this->convert_bb_to_html($text); + + return $text; + } + + public function escape($text) { + $text = strip_tags($text); + $text = htmlentities($text, ENT_COMPAT | ENT_HTML5, "UTF-8", true); + $test = htmlspecialchars($text, ENT_COMPAT | ENT_HTML5, "UTF-8", true); + + return $text; + } + + public function convert_le_to_br($text) { + $text = nl2br($text, false); + return $text; + } + + public function convert_bb_to_html($text) { + return $text; + } + + protected function _url_sanitize_name($name) { + //allowed a-z, A-Z, 0-9, _ + + $name = str_replace(" ","_", $name); + + //var_dump($name); + + $regex = '/[^A-Za-z0-9_]/'; + + $name = preg_replace($regex, "", $name); + + //var_dump($name); + + return $name; + } +} \ No newline at end of file diff --git a/ci_scms/application/core/index.html b/ci_scms/application/core/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/ci_scms/application/core/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/ci_scms/application/index.html b/ci_scms/application/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/ci_scms/application/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/ci_scms/application/models/Common_model.php b/ci_scms/application/models/Common_model.php new file mode 100644 index 0000000..759d9da --- /dev/null +++ b/ci_scms/application/models/Common_model.php @@ -0,0 +1,22 @@ +db->query($sql, array($id)); + + if (!$res->num_rows()) + return false; + + $res = $res->row_array(); + + return $res["link"]; + } +} \ No newline at end of file diff --git a/ci_scms/application/models/admin_model.php b/ci_scms/application/models/admin_model.php new file mode 100644 index 0000000..bdeadb4 --- /dev/null +++ b/ci_scms/application/models/admin_model.php @@ -0,0 +1,221 @@ +db->query($sql); + + $res = $res->result_array(); + + foreach ($res as $r) { + if ($r["name"] == "reg_enabled") { + if ($r["value"] == "true") { + return true; + } else { + return false; + } + } + } + + return false; + } + + function check_user($username, $password) { + $sql = "SELECT password FROM avxg_users WHERE name = ?"; + $res = $this->db->query($sql, array($username)); + + if ($res->num_rows() <= 0) { + return false; + } + + $res = $res->row_array(); + + + if ($res['password'] == $password) + return true; + + return false; + } + + function create_cookie_session_id() { + $sql = "SELECT * FROM session_links"; + $res = $this->db->query($sql); + + if ($res->num_rows() <= 0) + return $this->getcsid(); + + $res->result_array(); + + $sess_id = ""; + $found = false; + while(!found) { + $sess_id = $this->getcsid(); + + $f = false; + foreach ($res as $r) { + if ($r["cookie_session_id"] == $sess_id) { + $f = true; + break; + } + } + + if (!$f) { + $found = true; + } + } + + return $sess_id; + } + + function getcsid() { + return md5("+41)d" . rand() . "ikZtzdDJU"); + } + + function get_or_create_session_id($username) { + $sql = "SELECT * FROM avxg_users WHERE name = ?"; + $res = $this->db->query($sql, array($username)); + + if ($res->num_rows() <= 0) + return -1; + + $res = $res->row_array(); + + $sess_id = ""; + if ($res['session_id'] == "") { + $sql = "SELECT * FROM avxg_users"; + $res2 = $this->db->query($sql); + + $res2 = $res2->result_array(); + + $found = false; + while (!$found) { + $sess_id = md5("77=89$@" + rand() + "99)(!4%)"); + + $f = false; + foreach ($res2 as $u) { + if ($u["session_id"] == $sess_id) { + $f = true; + break; + } + } + + if (!$f) { + $found = true; + } + + $sql = "UPDATE avxg_users SET session_id = ? WHERE name = ?"; + $this->db->query($sql, array($sess_id, $username)); + } + } else { + $sess_id = $res['session_id']; + } + + return $sess_id; + } + + function register_session($sessionid, $cookie_session_id) { + $sql = "INSERT INTO session_links VALUES(default, ?, ?)"; + $this->db->query($sql, array($sessionid, $cookie_session_id)); + + return true; + } + + function login_user($username, $sessionid) { + + } + + function register_user($username, $password, $email) { + $sql = "SELECT * FROM avxg_users"; + $res = $this->db->query($sql); + $res = $res->result_array(); + + $nametaken = false; + $emailtaken = false; + foreach ($res as $r) { + if ($r["name"] == $username) { + $nametaken = true; + } + + if ($r["email"] == $email) { + $emailtaken = true; + } + } + + //TODO tell error? + + if ($emailtaken || $nametaken) + return; + + $sql = "INSERT INTO avxg_users VALUES(default, ?, ?, ?, NULL, NULL, NULL)"; + + $this->db->query($sql, array($username, $password, $email)); + + //turn off registration + $sql = "UPDATE settings SET value = 'false' WHERE name LIKE 'reg_enabled'"; + $this->db->query($sql); + } + + function is_admin($sid) { + $sql = "SELECT * FROM session_links WHERE cookie_session_id = ?"; + $res = $this->db->query($sql, array($sid)); + + if (!$res->num_rows()) + return false; + + $res = $res->row_array(); + + $sql = "SELECT * FROM avxg_users WHERE session_id = ?"; + $res2 = $this->db->query($sql, array($res["session_id"])); + + if (!$res2->num_rows()) + return false; + + return true; + } + + function get_username_sid($sid) { + $sql = "SELECT * FROM session_links WHERE cookie_session_id = ?"; + $res = $this->db->query($sql, array($sid)); + + if (!$res->num_rows()) + return "E"; + + $res = $res->row_array(); + + $sql = "SELECT * FROM avxg_users WHERE session_id = ?"; + $res2 = $this->db->query($sql, array($res["session_id"])); + + if (!$res2->num_rows()) + return "E2"; + + $res2 = $res2->row_array(); + + return $res2["name"]; + } + + function logout($sid) { + $sql = "DELETE FROM session_links WHERE cookie_session_id = ?"; + $this->db->query($sql, array($sid)); + } + + function logout_all($sid) { + $sql = "SELECT * FROM session_links WHERE cookie_session_id = ?"; + $res = $this->db->query($sql, array($sid)); + + if (!$res->num_rows()) + return; + + $res = $res->row_array(); + + $sql = "DELETE FROM session_links WHERE session_id = ?"; + $this->db->query($sql, array($res["session_id"])); + } +} \ No newline at end of file diff --git a/ci_scms/application/models/content_model.php b/ci_scms/application/models/content_model.php new file mode 100644 index 0000000..2ef8a34 --- /dev/null +++ b/ci_scms/application/models/content_model.php @@ -0,0 +1,355 @@ + "TEXT" + ); + + function __construct() + { + parent::__construct(); + } + + function get_page_contents($pageid) { + $sql = "SELECT * FROM page_contents WHERE pageid = ? ORDER BY `order` ASC"; + $res = $this->db->query($sql, array($pageid)); + return $res->result_array(); + } + + function get_content_text($id) { + $sql = "SELECT * FROM content_text WHERE id = ?"; + $res = $this->db->query($sql, array($id)); + + + if (!$res->num_rows()) + return false; + + return $res->row_array(); + } + + function get_content_gallery($id) { + $sql = "SELECT * FROM content_gallery WHERE id = ?"; + $res = $this->db->query($sql, array($id)); + + + if (!$res->num_rows()) + return false; + + return $res->row_array(); + } + + function get_gallery_data($id) { + $sql = "SELECT * FROM gallery_data WHERE gallery_id = ?"; + $res = $this->db->query($sql, array($id)); + + + if (!$res->num_rows()) + return false; + + return $res->result_array(); + } + + function get_content_multi_gallery($id) { + $sql = "SELECT * FROM content_multi_gallery WHERE id = ?"; + $res = $this->db->query($sql, array($id)); + + if (!$res->num_rows()) + return false; + + return $res->row_array(); + } + + function get_content_multi_gallery_folders($id) { + $sql = "SELECT * FROM multi_gallery_folders WHERE galleryid = ?"; + $res = $this->db->query($sql, array($id)); + + if (!$res->num_rows()) + return false; + + return $res->result_array(); + } + + function get_content_text_noformat($id) { + $sql = "SELECT * FROM content_text WHERE id = ?"; + $res = $this->db->query($sql, array($id)); + + + //if ($res->num_rows() > 0) + //$res = $res->row_array(); + + return $res->row_array(); + } + + function add_page_text($pageid, $message) { + $sql = "SELECT * FROM page_contents WHERE pageid = ? ORDER BY `order` ASC"; + $res = $this->db->query($sql, array($pageid)); + + $nextid = 1; + + if ($res->num_rows()) { + $res = $res->result_array(); + + foreach($res as $e) { + if ($e["order"] > $nextid) { + $nextid = $e["order"]; + } + } + + $nextid++; + } + + $m = $message; + $messagehtmld = $this->convert_string_all($m); + + $sql = "INSERT INTO content_text VALUES(DEFAULT, ?, ?)"; + $this->db->query($sql, array($messagehtmld, $message)); + + $sql = "SELECT MAX(id) AS id FROM content_text"; + $res = $this->db->query($sql); + + if ($res->num_rows()) { + $res = $res->row_array(); + + $sql = "INSERT INTO page_contents VALUES(DEFAULT, ?, ?, 1, ?)"; + $this->db->query($sql, array($pageid, $nextid, $res["id"])); + } + } + + function edit_page_text($textid, $message) { + $m = $message; + $messagehtmld = $this->convert_string_all($m); + + $sql = "UPDATE content_text SET `text` = ?,`text_noformat` = ? WHERE id = ?"; + $this->db->query($sql, array($messagehtmld, $message, $textid)); + } + + function get_content_types() { + return $content_types; + } + + function content_down($pageid, $id) { + $sql = "SELECT * from page_contents WHERE pageid = ?"; + $res = $this->db->query($sql, array($pageid)); + + if (!$res->num_rows()) + return; + + $res = $res->result_array(); + + $selected; + foreach ($res as $r) { + if ($r["id"] == $id) { + $selected = $r; + break; + } + } + + if (!$selected) + return; + + $lower; + foreach ($res as $r) { + if ($r["order"] == $selected["order"] + 1) { + $lower = $r; + break; + } + } + + if (!$lower) + return; + + $sql = "UPDATE page_contents SET `order` = ? WHERE id = ?"; + $this->db->query($sql, array($lower["order"], $selected["id"])); + $this->db->query($sql, array($selected["order"], $lower["id"])); + } + + function content_up($pageid, $id) { + $sql = "SELECT * from page_contents WHERE pageid = ?"; + $res = $this->db->query($sql, array($pageid)); + + if (!$res->num_rows()) + return; + + $res = $res->result_array(); + + $selected; + foreach ($res as $r) { + if ($r["id"] == $id) { + $selected = $r; + break; + } + } + + if (!$selected) + return; + + $higher; + foreach ($res as $r) { + if ($r["order"] == $selected["order"] - 1) { + $higher = $r; + break; + } + } + + if (!$higher) + return; + + $sql = "UPDATE page_contents SET `order` = ? WHERE id = ?"; + $this->db->query($sql, array($higher["order"], $selected["id"])); + $this->db->query($sql, array($selected["order"], $higher["id"])); + } + + function content_delete($pageid, $id) { + $sql = "SELECT * FROM page_contents WHERE id = ?"; + $res = $this->db->query($sql, array($id)); + + if (!$res->num_rows()) + return; + + $res = $res->row_array(); + + $sql = "DELETE FROM page_contents WHERE id = ?"; + $this->db->query($sql, array($id)); + + $sql = "SELECT * FROM page_contents WHERE pageid = ?"; + $ares = $this->db->query($sql, array($id)); + + if (!$ares->num_rows()) + return; + + $ares = $ares->result_array(); + + //TODO make a concatenated query + foreach ($ares as $r) { + if ($r["order"] > $res["order"]) { + $sql = "UPDATE page_contents SET `order` = ? WHERE id = ?"; + $this->db->query($sql, array($r["order"] - 1, $r["id"])); + } + } + + switch ($res["content_type"]) { + case 1: //text + $sql = "DELETE FROM content_text WHERE id = ?"; + $this->db->query($sql, array($res["content_id"])); + break; + } + } + + function add_gallery($pageid, $name, $description) { + $link = ""; + + if ($name) { + $link = _url_sanitize_name($name); + + $sql = "SELECT * FROM content_gallery WHERE link LIKE ?"; + $res = $this->db->query($sql, array($link)); + + if ($res->num_rows()) + $link = ""; + } + + $sql = "INSERT INTO content_gallery VALUES(default, ?, ?, ?, default)"; + $this->db->query($sql, array($name, $link, $description)); + + $sql = "SELECT MAX(id) AS id FROM content_gallery"; + $res = $this->db->query($sql); + $res = $res->row_array(); + + $id = $res["id"]; + + if (!$name) { + $sql = "UPDATE content_gallery SET name = ? WHERE id = ?"; + $this->db->query($sql, array($id, $id)); + } + + if (!$link) { + $sql = "UPDATE content_gallery SET link = ? WHERE id = ?"; + $this->db->query($sql, array($id, $id)); + } + + $order = 1; + + $sql = "SELECT MAX(`order`) AS `order` FROM page_contents WHERE pageid = ?"; + $res = $this->db->query($sql, array($pageid)); + + if ($res->num_rows()) { + $res = $res->row_array(); + $order = $res["order"]; + $order++; + } + + $sql = "INSERT INTO page_contents VALUES(default, ?, ?, 3, ?)"; + $this->db->query($sql, array($pageid, $order, $id)); + } + + function add_gallery_image($galleryid, $name, $description, $img, $thumb, $orig_img) { + $link = ""; + + if ($name) { + $link = $this->_url_sanitize_name($name); + + $sql = "SELECT * FROM gallery_data WHERE gallery_id = ? AND link LIKE ?"; + $res = $this->db->query($sql, array($galleryid, $link)); + + if ($res->num_rows()) + $link = ""; + } + + $sql = "INSERT INTO gallery_data VALUES(default, ?, ?, ?, ?, ?, ?, ?)"; + $this->db->query($sql, array($galleryid, $name, $link, $description, $img, $thumb, $orig_img)); + + if (!$link) { + $sql = "UPDATE gallery_data SET link = id ORDER BY id DESC LIMIT 1"; + $this->db->query($sql); + } + } + + function add_multi_gallery($pageid, $name, $description) { + $link = ""; + + if ($name) { + $link = $this->_url_sanitize_name($name); + + $sql = "SELECT * FROM content_multi_gallery WHERE id = ? AND link LIKE ?"; + $res = $this->db->query($sql, array($pageid, $link)); + + if ($res->num_rows()) + $link = ""; + } + + $sql = "INSERT INTO content_multi_gallery VALUES(default, ?, ?, ?, default)"; + $this->db->query($sql, array($name, $link, $description)); + + $sql = "SELECT MAX(id) AS id FROM content_multi_gallery"; + $res = $this->db->query($sql); + $res = $res->row_array(); + + $id = $res["id"]; + + if (!$name) { + $sql = "UPDATE content_multi_gallery SET name = ? WHERE id = ?"; + $this->db->query($sql, array($id, $id)); + } + + if (!$link) { + $sql = "UPDATE content_multi_gallery SET link = ? WHERE id = ?"; + $this->db->query($sql, array($id, $id)); + } + + $order = 1; + + $sql = "SELECT MAX(`order`) AS `order` FROM page_contents WHERE pageid = ?"; + $res = $this->db->query($sql, array($pageid)); + + if ($res->num_rows()) { + $res = $res->row_array(); + $order = $res["order"]; + $order++; + } + + $sql = "INSERT INTO page_contents VALUES(default, ?, ?, 4, ?)"; + $this->db->query($sql, array($pageid, $order, $id)); + } +} \ No newline at end of file diff --git a/ci_scms/application/models/gallery_model.php b/ci_scms/application/models/gallery_model.php new file mode 100644 index 0000000..d6c682b --- /dev/null +++ b/ci_scms/application/models/gallery_model.php @@ -0,0 +1,149 @@ +db->query($sql, array($galleryname)); + + if ($res->num_rows()) + return $res->row_array(); + + $sql = "SELECT * FROM content_gallery LIMIT 1"; + $res = $this->db->query($sql); + + if ($res->num_rows()) + return $res->row_array(); + } + + function get_gallery_data($galleryid) { + $sql = "SELECT * FROM gallery_data WHERE gallery_id = ?"; + $res = $this->db->query($sql, array($galleryid)); + + if ($res->num_rows()) + return $res->result_array(); + + return null; + } + + function get_gallery_image_data($galleryid, $imagename) { + + } + + function get_first_gallery_name() { + + } + + function get_fake_page_and_id_from_gallery_name() { + //let's just return false for now + return false; + + /* + $sql = "SELECT * FROM content_gallery LIMIT 1"; + $res = $this->db->query($sql); + + $res = $res->row_array(); + + $id = $res["id"]; + + $sql = "SELECT * FROM page_contents WHERE content_id = ? AND content_type = 3"; + $res = $this->db->query($sql, array($id)); + + $res = $res->row_array(); + $pageid = $res["pageid"]; + + $sql = "SELECT * FROM menu WHERE id = ?"; + $res = $this->db->query($sql, array($pageid)); + + $res = $res->row_array(); + $link = $res["link"]; + + $d["page"] = $link; + $d["pageid"] = $pageid; + + return $d;*/ + } + + function get_page_and_id_from_gallery_link($galleryname) { + $sql = "SELECT * FROM content_gallery WHERE link = ?"; + $res = $this->db->query($sql, array($galleryname)); + + if (!$res->num_rows()) + return $this->get_fake_page_and_id_from_gallery_name(); + + $res = $res->row_array(); + + $id = $res["id"]; + + $sql = "SELECT * FROM page_contents WHERE content_id = ? AND content_type = 3"; + $res = $this->db->query($sql, array($id)); + + if (!$res->num_rows()) + return $this->get_fake_page_and_id_from_gallery_name(); + + $res = $res->row_array(); + + $pageid = $res["pageid"]; + + $sql = "SELECT * FROM menu WHERE id = ?"; + $res = $this->db->query($sql, array($pageid)); + + if (!$res->num_rows()) + return $this->get_fake_page_and_id_from_gallery_name(); + + $res = $res->row_array(); + $link = $res["link"]; + + + $d["page"] = $link; + $d["pageid"] = $pageid; + + return $d; + } + + function get_gallery_name($id) { + $sql = "SELECT * FROM content_gallery WHERE id = ?"; + $res = $this->db->query($sql, array($id)); + + if (!$res->num_rows()) + return $this->get_first_gallery_name(); + + $res = $res->row_array(); + + return $res["name"]; + } + + function get_gallery_link($id) { + $sql = "SELECT * FROM content_gallery WHERE id = ?"; + $res = $this->db->query($sql, array($id)); + + if (!$res->num_rows()) + return $this->get_first_gallery_name(); + + $res = $res->row_array(); + + return $res["link"]; + } + + function del_gallery_image_from_db($id) { + $id = intval($id); + $sql = "SELECT * FROM gallery_data WHERE id = ?"; + $res = $this->db->query($sql, array($id)); + + if (!$res->num_rows()) + return false; + + $res = $res->row_array(); + + $sql = "DELETE FROM gallery_data WHERE id = ?"; + $this->db->query($sql, array($id)); + + return $res; + } +} \ No newline at end of file diff --git a/ci_scms/application/models/index.html b/ci_scms/application/models/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/ci_scms/application/models/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + diff --git a/ci_scms/application/models/menu_model.php b/ci_scms/application/models/menu_model.php new file mode 100644 index 0000000..7b9e4cb --- /dev/null +++ b/ci_scms/application/models/menu_model.php @@ -0,0 +1,57 @@ +db->query($sql); + + if (!$res->num_rows()) + return false; + + $res = $res->result_array(); + + foreach ($res as $m) { + if ($m["link"] == $page) { + return true; + } + } + + return false; + } + + function getFirstMenuItem() { + $sql = "SELECT * FROM menu WHERE id = 1"; + + $q = $this->db->query($sql); + + return $q->row_array(); + } + + function getBaseMenuData() { + $sql = "SELECT * FROM menu ORDER BY menu.order ASC"; + + $q = $this->db->query($sql); + + return $q->result_array(); + } + + function getPageId($page) { + $sql = "SELECT * FROM menu WHERE name = ?"; + + $q = $this->db->query($sql, array($page)); + + if ($q->num_rows()) + $q = $q->row_array(); + else + return -1; + + return $q["id"]; + } +} \ No newline at end of file diff --git a/ci_scms/application/models/multi_gallery_model.php b/ci_scms/application/models/multi_gallery_model.php new file mode 100644 index 0000000..eeac6ed --- /dev/null +++ b/ci_scms/application/models/multi_gallery_model.php @@ -0,0 +1,260 @@ +_url_sanitize_name($name); + + $sql = "SELECT * FROM multi_gallery_folders WHERE galleryid = ? AND link LIKE ?"; + $res = $this->db->query($sql, array($galleryid, $link)); + + if ($res->num_rows()) + $link = ""; + } + + $sql = "INSERT INTO multi_gallery_folders VALUES(default, ?, ?, ?, ?, ?, ?, default)"; + $this->db->query($sql, array($galleryid, $name, $link, $description, $filename, 0)); + + if (!$link) { + $sql = "UPDATE multi_gallery_folders SET link = id ORDER BY id DESC LIMIT 1"; + $this->db->query($sql); + } + } + + function get_content_multi_gallery($id) { + $sql = "SELECT * FROM content_multi_gallery WHERE id = ?"; + $res = $this->db->query($sql, array($id)); + + if (!$res->num_rows()) + return false; + + return $res->row_array(); + } + + function get_content_multi_gallery_folders($id) { + $sql = "SELECT * FROM multi_gallery_folders WHERE galleryid = ?"; + $res = $this->db->query($sql, array($id)); + + if (!$res->num_rows()) + return false; + + return $res->result_array(); + } + + function get_multi_gallery_folder($gallery, $folder) { + //is folder is a number, it's the id, no need for $gallery + if (is_numeric($folder)) { + $sql = "SELECT * FROM multi_gallery_folders WHERE id = ?"; + $res = $this->db->query($sql, array($folder)); + + if (!$res->num_rows()) + return false; + + return $res->row_array(); + } else { + $sql = ""; + $res = null; + + if (is_numeric($gallery)) { + $sql = "SELECT * FROM multi_gallery_folders WHERE link LIKE ? AND galleryid = ?"; + $res = $this->db->query($sql, array($folder, $gallery)); + } else { + $sql = "SELECT * FROM content_multi_gallery WHERE link LIKE ?"; + $res = $this->db->query($sql, array($gallery)); + + if (!$res->num_rows()) + return false; + + $res = $res->row_array(); + + $sql = "SELECT * FROM multi_gallery_folders WHERE link LIKE ? AND galleryid = ?"; + $res = $this->db->query($sql, array($folder, $res["id"])); + } + + if (!$res->num_rows()) + return false; + + return $res->row_array(); + } + } + + function get_multi_gallery_folder_images($folderid) { + $sql = "SELECT * FROM multi_gallery_data WHERE folderid = ?"; + $res = $this->db->query($sql, array($folderid)); + + if (!$res->num_rows()) + return false; + + return $res->result_array(); + } + + function add_gallery_image($folderid, $name, $description, $thumb, $mid, $big, $orig) { + $link = ""; + + if ($name) { + $link = $this->_url_sanitize_name($name); + + $sql = "SELECT * FROM multi_gallery_data WHERE folderid = ? AND link LIKE ?"; + $res = $this->db->query($sql, array($folderid, $name)); + + if ($res->num_rows()) + $link = ""; + } + + $sql = "INSERT INTO multi_gallery_data VALUES(default, ?, ?, ?, ?, ?, ?, ?, ?)"; + $this->db->query($sql, array($folderid, $name, $link, $description, $thumb, $mid, $big, $orig)); + + if (!$name) { + $sql = "UPDATE multi_gallery_data SET name = id ORDER BY id DESC LIMIT 1"; + $this->db->query($sql); + } + + if (!$link) { + $sql = "UPDATE multi_gallery_data SET link = id ORDER BY id DESC LIMIT 1"; + $this->db->query($sql); + } + } + + function get_gallery_name($id) { + $sql = "SELECT * FROM content_multi_gallery WHERE id = ?"; + $res = $this->db->query($sql, array($id)); + + if (!$res->num_rows()) + return ""; + + $res = $res->row_array(); + + return $res["link"]; + } + + function get_folder_name($id) { + $sql = "SELECT * FROM multi_gallery_folders WHERE id = ?"; + $res = $this->db->query($sql, array($id)); + + if (!$res->num_rows()) + return ""; + + $res = $res->row_array(); + + return $res["link"]; + } + + function del_image_from_db($imageid) { + $imageid = intval($imageid); + $sql = "SELECT * FROM multi_gallery_data WHERE id = ?"; + $res = $this->db->query($sql, array($imageid)); + + if (!$res->num_rows()) + return false; + + $res = $res->row_array(); + + $sql = "DELETE FROM multi_gallery_data WHERE id = ?"; + $this->db->query($sql, array($imageid)); + + return $res; + } + + //TODO are any of this needed?: + function get_fake_page_and_id_from_gallery_name() { + //let's just return false for now + return false; + + /* + $sql = "SELECT * FROM content_gallery LIMIT 1"; + $res = $this->db->query($sql); + + $res = $res->row_array(); + + $id = $res["id"]; + + $sql = "SELECT * FROM page_contents WHERE content_id = ? AND content_type = 3"; + $res = $this->db->query($sql, array($id)); + + $res = $res->row_array(); + $pageid = $res["pageid"]; + + $sql = "SELECT * FROM menu WHERE id = ?"; + $res = $this->db->query($sql, array($pageid)); + + $res = $res->row_array(); + $link = $res["link"]; + + $d["page"] = $link; + $d["pageid"] = $pageid; + + return $d;*/ + } + + function get_page_and_id_from_gallery_name($galleryname) { + $id = 0; + if (!is_numeric($galleryname)) { + $sql = "SELECT * FROM content_multi_gallery WHERE link = ?"; + $res = $this->db->query($sql, array($galleryname)); + + if (!$res->num_rows()) + return $this->get_fake_page_and_id_from_gallery_name(); + + $res = $res->row_array(); + + $id = $res["id"]; + } else { + $id = $galleryname; + } + + $sql = "SELECT * FROM page_contents WHERE content_id = ? AND content_type = 4"; + $res = $this->db->query($sql, array($id)); + + if (!$res->num_rows()) + return $this->get_fake_page_and_id_from_gallery_name(); + + $res = $res->row_array(); + + $pageid = $res["pageid"]; + + $sql = "SELECT * FROM menu WHERE id = ?"; + $res = $this->db->query($sql, array($pageid)); + + if (!$res->num_rows()) + return $this->get_fake_page_and_id_from_gallery_name(); + + $res = $res->row_array(); + $link = $res["link"]; + + $d["page"] = $link; + $d["pageid"] = $pageid; + + return $d; + } + + function get_page_name_from_gallery_id($galleryid) { + $sql = "SELECT * FROM page_contents WHERE content_id = ? AND content_type = 4"; + $res = $this->db->query($sql, array($galleryid)); + + if (!$res->num_rows()) + return ""; + + $res = $res->row_array(); + + $pageid = $res["pageid"]; + + $sql = "SELECT * FROM menu WHERE id = ?"; + $res = $this->db->query($sql, array($pageid)); + + if (!$res->num_rows()) + return ""; + + $res = $res->row_array(); + + return $res["link"]; + } +} \ No newline at end of file diff --git a/ci_scms/application/views/admin/add_gallery.php b/ci_scms/application/views/admin/add_gallery.php new file mode 100644 index 0000000..1f80a53 --- /dev/null +++ b/ci_scms/application/views/admin/add_gallery.php @@ -0,0 +1,52 @@ + + + + + + "> + + Galéria Szerkesztése + + + Galéria hozzáadása + + + +
+
+
+ Galéria Szerkesztése + + + Galéria hozzáadása +

+
+Galéria neve (Nem kötelező):
+ + + +
+Leírás: (Nem kötelező):
+

+ +
+
+
+ + \ No newline at end of file diff --git a/ci_scms/application/views/admin/add_gallery_img.php b/ci_scms/application/views/admin/add_gallery_img.php new file mode 100644 index 0000000..b1b5cd0 --- /dev/null +++ b/ci_scms/application/views/admin/add_gallery_img.php @@ -0,0 +1,54 @@ + + + + + + "> + + Kép hozzáadása + + + Kép hozzáadása + + + +
+
+
+ + + Kép szerkesztése: + + + Kép hozzáadása: +

+Kép neve (Nem kötelező):
+ + + +
+Leírás: (Nem kötelező):
+

+

+ + +
+
+ + \ No newline at end of file diff --git a/ci_scms/application/views/admin/add_multi_gallery.php b/ci_scms/application/views/admin/add_multi_gallery.php new file mode 100644 index 0000000..2a3f522 --- /dev/null +++ b/ci_scms/application/views/admin/add_multi_gallery.php @@ -0,0 +1,52 @@ + + + + + + "> + + Galéria Szerkesztése + + + Galéria hozzáadása + + + +
+
+
+ Galéria Szerkesztése + + + Galéria hozzáadása +

+
+Galéria neve (Nem kötelező):
+ + + +
+Leírás: (Nem kötelező):
+

+ +
+
+
+ + \ No newline at end of file diff --git a/ci_scms/application/views/admin/add_multi_gallery_folder.php b/ci_scms/application/views/admin/add_multi_gallery_folder.php new file mode 100644 index 0000000..e3da30e --- /dev/null +++ b/ci_scms/application/views/admin/add_multi_gallery_folder.php @@ -0,0 +1,60 @@ + + + + + + "> + + Mappa szerkesztése + + + Mappa hozzáadása + + + +
+
+
+ + + Mappa szerkesztése: + + + Mappa hozzáadása: +

+Mappa neve (Nem kötelező):
+ + + +
+Mappa leírása: (Nem kötelező):
+

+Kép: + +Csak csere esetén kell választani! + +
+
+
+ + +
+
+ + \ No newline at end of file diff --git a/ci_scms/application/views/admin/add_multi_gallery_img.php b/ci_scms/application/views/admin/add_multi_gallery_img.php new file mode 100644 index 0000000..3164d48 --- /dev/null +++ b/ci_scms/application/views/admin/add_multi_gallery_img.php @@ -0,0 +1,54 @@ + + + + + + "> + + Kép hozzáadása + + + Kép hozzáadása + + + +
+
+
+ + + Kép szerkesztése: + + + Kép hozzáadása: +

+Kép neve (Nem kötelező):
+ + + +
+Leírás: (Nem kötelező):
+

+

+ + +
+
+ + \ No newline at end of file diff --git a/ci_scms/application/views/admin/login.php b/ci_scms/application/views/admin/login.php new file mode 100644 index 0000000..aa3e21e --- /dev/null +++ b/ci_scms/application/views/admin/login.php @@ -0,0 +1,30 @@ + + + + + + + "> + Admin + + +
+
+
+ Belépés:

+
" method="POST"> + Felhasználónév:
+
+ Jelszó:
+

+
+
+ + ">Regisztráció + +
+
+ + \ No newline at end of file diff --git a/ci_scms/application/views/admin/register.php b/ci_scms/application/views/admin/register.php new file mode 100644 index 0000000..20fc197 --- /dev/null +++ b/ci_scms/application/views/admin/register.php @@ -0,0 +1,30 @@ + + + + + + "> + Admin + + +
+
+
+ Regisztráció:

+
" method="POST"> + Felhasználónév (legalább 4 karakter):
+
+ Jelszó (legalább 5 karakter):
+
+ Jelszó megint:
+
+ e-mail cím:
+

+ +
+
+
+ + \ No newline at end of file diff --git a/ci_scms/application/views/admin/text.php b/ci_scms/application/views/admin/text.php new file mode 100644 index 0000000..0647b3d --- /dev/null +++ b/ci_scms/application/views/admin/text.php @@ -0,0 +1,40 @@ + + + + + + "> + + Szöveg Szerkesztése + + + Szöveg hozzáadása + + + +
+
+ +

+ +
+
+ + \ No newline at end of file diff --git a/ci_scms/application/views/content.php b/ci_scms/application/views/content.php new file mode 100644 index 0000000..78cbd39 --- /dev/null +++ b/ci_scms/application/views/content.php @@ -0,0 +1,17 @@ + +
+ 0): ?> + +
+ +
+ + + +
+ [Szövegdoboz hozzáadása] + [Galéria hozzáadása] + [Többmappás Galéria hozzáadása] +
+ +
\ No newline at end of file diff --git a/ci_scms/application/views/footer.php b/ci_scms/application/views/footer.php new file mode 100644 index 0000000..f5017c9 --- /dev/null +++ b/ci_scms/application/views/footer.php @@ -0,0 +1,13 @@ + +