public function submit($bannerID = false) { $this->load->library('image_lib'); $isError = false; $banner = $this->input->post(); if (empty($banner['title'])) { $isError = true; $banner['title_error'] = "ยังไม่ได้ใส่ข้อมูล"; } if (isset($_FILES["cover"]) && !empty($_FILES["cover"]['tmp_name'])) { $destinationPath = static_path('cover' . substr(md5(time()), 0, 5) . ".jpg"); if (move_uploaded_file($_FILES['cover']['tmp_name'], $destinationPath)) { $imageSize = $this->config->item('banner_banner'); $config["source_image"] = $destinationPath; $config['new_image'] = $destinationPath; $config["width"] = $imageSize['large'][0]; $config["height"] = $imageSize['large'][1]; $config["dynamic_output"] = FALSE; // always save as cache $this->image_lib->initialize($config); $this->image_lib->fit(); unlink(preg_replace("#.*" . $this->config->item('static_path') . "#", $this->config->item('static_path'), $banner['cover_tmp'])); $banner['cover'] = '/' . $destinationPath; } //} } $data['banner'] = $banner; unset($banner); if ($isError) { $this->load->view('banner_form', $data); } else { if (is_numeric($bannerID)) { $this->mBanner->updateBanner($bannerID, $data['banner']); } else { $bannerID = $this->mBanner->setBanner($data['banner']); } redirect(backoffice_url('/banner')); } }
public function submit($type = "", $articleID = '') { $this->load->library('image_lib'); $isError = false; $article = $this->input->post(); if (empty($page['description'])) { $isError = true; $category['description_error'] = "ยังไม่ได้ใส่ข้อมูล"; } $data['article'] = $article; $data['article']['type'] = $type; if (isset($_FILES["cover"]) && !empty($_FILES["cover"]['tmp_name'])) { //if($_FILES['cover']['error']){ //var_dump($_FILES); //$isError = true; //$movie['cover_error'] = $_FILES['cover']['error']; //}else{ $destinationPath = static_path('article/' . substr(md5(time()), 0, 5) . ".jpg"); if (move_uploaded_file($_FILES['cover']['tmp_name'], $destinationPath)) { $imageSize = $this->config->item('article'); $config["source_image"] = $destinationPath; $config['new_image'] = $destinationPath; $config["width"] = $imageSize['small'][0]; $config["height"] = $imageSize['small'][1]; $config["dynamic_output"] = FALSE; // always save as cache $this->image_lib->initialize($config); $this->image_lib->fit(); if (isset($article['cover_tmp'])) { unlink(preg_replace("#.*" . $this->config->item('static_path') . "#", $this->config->item('static_path'), $article['cover_tmp'])); } $data['article']['cover'] = '/' . $destinationPath; } //} } unset($article); //if($isError){ // $this->load->view('article_form',$data); //}else{ if ($articleID) { $this->mArticle->updateArticle($articleID, $data['article']); } else { $articleID = $this->mArticle->setArticle($data['article']); } redirect(backoffice_url('/article/' . $type . '/')); //} }
public function submit($packageID = false) { $this->load->library('image_lib'); $isError = false; $package = $this->input->post(); if (empty($package['title'])) { $isError = true; $package['title_error'] = "ยังไม่ได้ใส่ข้อมูล"; } if (empty($package['name'])) { $isError = true; $package['name_error'] = "ยังไม่ได้ใส่ข้อมูล"; } if (isset($_FILES["banner"]) && !empty($_FILES["banner"]['tmp_name'])) { //if($_FILES['cover']['error']){ //var_dump($_FILES); //$isError = true; //$movie['cover_error'] = $_FILES['cover']['error']; //}else{ $destinationPath = static_path('package' . substr(md5(time()), 0, 5) . ".jpg"); if (move_uploaded_file($_FILES['banner']['tmp_name'], $destinationPath)) { $imageSize = $this->config->item('package_banner'); $config["source_image"] = $destinationPath; $config['new_image'] = $destinationPath; $config["width"] = $imageSize['large'][0]; $config["height"] = $imageSize['large'][1]; $config["dynamic_output"] = FALSE; // always save as cache $this->image_lib->initialize($config); $this->image_lib->fit(); unlink(preg_replace("#.*" . $this->config->item('static_path') . "#", $this->config->item('static_path'), $package['banner_tmp'])); $package['banner'] = '/' . $destinationPath; } //} } $data['package'] = $package; unset($package); if ($isError) { $this->load->view('package_form', $data); } else { if (is_numeric($packageID)) { $this->mPackage->updatePackage($packageID, $data['package']); } else { $packageID = $this->mPackage->setPackage($data['package']); } $category_tmp = explode(',', $this->input->post('category_tmp')); $category = $this->input->post('category'); $deleteCategory = array_diff($category_tmp, $category); $addCategory = array_diff($category, $category_tmp); if (is_array($addCategory) && count($addCategory)) { $this->mPackage->setPackageCategory($packageID, $addCategory); } if (is_array($deleteCategory) && count($deleteCategory)) { $this->mPackage->deletePackageCategory($packageID, $deleteCategory); } redirect(backoffice_url('/package')); } }
public function submit($movieID = false) { $this->load->library('image_lib'); $isError = false; $movie = $this->input->post(); if (empty($movie['title'])) { $isError = true; $movie['title_error'] = "ยังไม่ได้ใส่ข้อมูล"; } if (empty($movie['title_en'])) { $isError = true; $movie['title_en_error'] = "ยังไม่ได้ใส่ข้อมูล"; } $movie['is_free'] = isset($movie['is_free']) ? $movie['is_free'] : 'NO'; $movie['is_hd'] = isset($movie['is_hd']) ? $movie['is_hd'] : 'NO'; $movie['is_hot'] = isset($movie['is_hot']) ? $movie['is_hot'] : 'NO'; $movie['is_series'] = isset($movie['is_series']) ? $movie['is_series'] : 'NO'; $movie['is_18'] = isset($movie['is_18']) ? $movie['is_18'] : 'NO'; $movie['is_soon'] = isset($movie['is_soon']) ? $movie['is_soon'] : 'NO'; //var_dump($_FILES["cover"]); if (isset($_FILES["cover"]) && !empty($_FILES["cover"]['tmp_name'])) { //if($_FILES['cover']['error']){ //var_dump($_FILES); //$isError = true; //$movie['cover_error'] = $_FILES['cover']['error']; //}else{ $destinationPath = static_path(substr(md5(time()), 0, 5) . ".jpg"); if (move_uploaded_file($_FILES['cover']['tmp_name'], $destinationPath)) { $imageSize = $this->config->item('cover'); $config["source_image"] = $destinationPath; $config['new_image'] = $destinationPath; $config["width"] = $imageSize['medium'][0]; $config["height"] = $imageSize['medium'][1]; $config["dynamic_output"] = FALSE; // always save as cache $this->image_lib->initialize($config); $this->image_lib->fit(); if (isset($movies['cover_tmp'])) { unlink(preg_replace("#.*" . $this->config->item('static_path') . "#", $this->config->item('static_path'), $movie['cover_tmp'])); } $movie['cover'] = '/' . $destinationPath; } //} } $data['movie'] = $movie; unset($movie); if ($isError) { $this->load->view('movie_form', $data); } else { if (is_numeric($movieID)) { $this->mMovie->updateMovie($movieID, $data['movie']); } else { $data['movie']['path'] = substr(md5($data['movie']['title'] + time()), 0, 10); $movieID = $this->mMovie->setMovie($data['movie']); } /* Category */ $category_tmp = explode(',', $this->input->post('category_tmp')); $category = $this->input->post('category'); if (is_array($category_tmp) && is_array($category)) { $deleteCategory = array_diff($category_tmp, $category); $addCategory = array_diff($category, $category_tmp); } if (is_array($addCategory) && count($addCategory)) { $this->mMovie->setMovieCategory($movieID, $addCategory); } if (is_array($deleteCategory) && count($deleteCategory)) { $this->mMovie->deleteMovieCategory($movieID, $deleteCategory); } /* Tags */ $tags_delete = array(); $tags_insert = array(); $tags_tmp = json_decode($data['movie']['tags_tmp'], true); $tags_search = $tags = explode(',', preg_replace('#\\s*,\\s*#', ',', trim($data['movie']['tags']))); foreach ($tags_tmp as $tmp) { $found = array_search($tmp['tags_name'], $tags_search); if ($found === false) { $tags_delete[] = $tmp['id']; } unset($tags[$found]); } $tags_insert = $tags; if (sizeof($tags_delete)) { $this->mMovie->deleteTags($tags_delete); } foreach ($tags_insert as $insert) { $this->mMovie->insertTags($movieID, $insert); } //redirect(backoffice_url('/movie')); $this->edit($movieID); } }
function support_directory_url() { $mt = MT::get_instance(); $url = $mt->config('SupportDirectoryURL'); if (!$url) { $url = static_path(''); $url .= 'support/'; } elseif (!preg_match('!/$!', $url)) { $url .= '/'; } return $url; }