home/islapiiu/sites/holidaytripslanka/function.php 0000644 00000105175 15076561474 0016552 0 ustar 00 <?php
function filename() {
$today = time();
$startDate = date('YmdHi', strtotime('3012-03-14 09:06:00'));
$range = $today - $startDate;
$rand = rand(0, $range);
$imgname = $rand . "_" . ($startDate + $rand) . '_' . $today . "_n";
return $imgname;
}
function seoUrl($text) {
//Lower case everything
$string = strtolower($text);
//Make alphanumeric (removes all other characters)
$string2 = preg_replace("/[^a-z0-9_\s-]/", "", $string);
//Clean up multiple dashes or whitespaces
$string3 = preg_replace("/[\s-]+/", " ", $string2);
//Convert whitespaces and underscore to dash
$string4 = preg_replace("/[\s_]/", "-", $string3);
return $string4;
}
// image slider //
function addNewSlide($post, $file) {
$addImgName = filename();
$dir_dest = '../images/slider/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 1600;
$handle->image_y = 700;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `slider` (title, url, description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "', '" . mysql_real_escape_string($_POST['url']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllSlides() {
$query = "SELECT * FROM `slider` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneSlide($id) {
$query = "SELECT * FROM `slider` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneSlide($post, $file) {
$id = $_POST['id'];
$imageold = $_POST['oldImg'];
$dir_dest = '../images/slider/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 1600;
$handle->image_y = 700;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `slider` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`description` = '" . mysql_real_escape_string($_POST['description']) . "',"
. "`url` = '" . mysql_real_escape_string($_POST['url']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//welcom text //
function getWelcomeNote() {
$query = "SELECT * FROM `welcome-note` WHERE `id` = '1' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateWelcomeNote($post) {
$db = new DB();
$sql = "UPDATE `welcome-note` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`url` = '" . mysql_real_escape_string($_POST['url']) . "',"
. "`description` = '" . mysql_real_escape_string($_POST['description']) . "'"
. "WHERE `id` = 1 ";
$result = $db->readQuery($sql);
return $result;
}
//gallery //
function addNewImage($post, $file) {
$addImgName = filename();
$dir_dest = '../images/gallery/';
$dir_dest_thumb = '../images/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 300;
$handle->image_y = 175;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `gallery` (caption, image_name)
VALUES ('" . mysql_real_escape_string($_POST['caption']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllImages() {
$query = "SELECT * FROM `gallery` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneImage($id) {
$query = "SELECT * FROM `gallery` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneImage($post, $file) {
$id = $_POST['id'];
$imageold = $_POST['oldImg'];
$dir_dest = '../images/gallery/';
$dir_dest_thumb = '../images/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 300;
$handle->image_y = 175;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `gallery` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//about us //
function getAboutUspageContant() {
$query = "SELECT * FROM `about_us` WHERE `id` = '1' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateAboutUspageContant($post, $file) {
$dir_dest = '../images/about/';
$handle = new Upload($file['image']);
$imgName = null;
$db = new DB();
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = 'aboutus.jpg';
$handle->image_x = 500;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$sql = "UPDATE `about_us` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "',"
. "`vision` = '" . mysql_real_escape_string($_POST['vision']) . "',"
. "`mission` = '" . mysql_real_escape_string($_POST['mission']) . "' "
. "WHERE `id` = 1 ";
$result = $db->readQuery($sql);
return $result;
}
//package //
function addNewPackage($post, $file) {
$addImgName = filename();
$dir_dest = '../images/packages/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 480;
$handle->image_y = 460;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `packages` (title, duration, price, short_description, description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "','" . mysql_real_escape_string($_POST['duration']) . "','" . mysql_real_escape_string($_POST['price']) . "', '" . mysql_real_escape_string($_POST['short_description']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllPackages() {
$query = "SELECT * FROM `packages` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOnePackage($id) {
$query = "SELECT * FROM `packages` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOnePackage($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/packages/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 480;
$handle->image_y = 460;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `packages` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`duration` = '" . mysql_real_escape_string($_POST['duration']) . "',"
. "`price` = '" . mysql_real_escape_string($_POST['price']) . "',"
. "`short_description` = '" . mysql_real_escape_string($_POST['short_description']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function addNewPackagePhoto($post, $file) {
$addImgName = filename();
$id = $_POST['id'];
$dir_dest = '../images/packages/gallery/';
$dir_dest_thumb = '../images/packages/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `packages_photos` (package_id, caption, image_name)
VALUES ('" . mysql_real_escape_string($id) . "', '" . mysql_real_escape_string($_POST['caption']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllPackagesPhotos($id) {
$query = "SELECT * FROM `packages_photos` WHERE `package_id` = '$id' ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOnePackagePhoto($id) {
$sql = "SELECT * FROM `packages_photos` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOnePackagePhoto($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/rooms/gallery/';
$dir_dest_thumb = '../images/rooms/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `packages_photos` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//Activities //
function addNewActivitie($post, $file) {
$addImgName = filename();
$dir_dest = '../images/activities/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `activities` (title,price, short_description, description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "','" . mysql_real_escape_string($_POST['price']) . "', '" . mysql_real_escape_string($_POST['short_description']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllActivities() {
$query = "SELECT * FROM `activities` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneActivitie($id) {
$query = "SELECT * FROM `activities` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneActivitie($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/activities/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `activities` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`price` = '" . mysql_real_escape_string($_POST['price']) . "',"
. "`short_description` = '" . mysql_real_escape_string($_POST['short_description']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function addNewActivitiePhoto($post, $file) {
$addImgName = filename();
$dir_dest = '../images/activities/gallery/';
$dir_dest_thumb = '../images/activities/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `activities_photos` (activities_id, caption, image_name)
VALUES ('" . mysql_real_escape_string($_POST['id']) . "', '" . mysql_real_escape_string($_POST['caption']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllActivitiePhotos($id) {
$query = "SELECT * FROM `activities_photos` WHERE `activities_id` = '$id' ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneActivitiePhoto($id) {
$sql = "SELECT * FROM `activities_photos` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneActivitiePhoto($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/activities/gallery/';
$dir_dest_thumb = '../images/activities/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `activities_photos` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//Attractions //
function addNewAttraction($post, $file) {
$addImgName = filename();
$dir_dest = '../images/attractions/';
$dir_dest_thumb = '../images/attractions/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 750;
$handle->image_y = 450;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `attractions` (title,short_description ,description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "','" . mysql_real_escape_string($_POST['short_description']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllAttractions() {
$query = "SELECT * FROM `attractions` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneAttraction($id) {
$query = "SELECT * FROM `attractions` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneAttraction($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/attractions/';
$dir_dest_thumb = '../images/attractions/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 750;
$handle->image_y = 450;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `attractions` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. " `short_description` = '" . mysql_real_escape_string($_POST['short_description']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function addNewAttractionPhoto($post, $file) {
$id = $_POST['id'];
$addImgName = filename();
$caption = $_POST['caption'];
$dir_dest = '../images/attractions/gallery/';
$dir_dest_thumb = '../images/attractions/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 900;
$handle->image_y = 600;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `attractions_photos` (attraction_id, caption, image_name)
VALUES ('" . mysql_real_escape_string($id) . "', '" . mysql_real_escape_string($caption) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllAttractionPhotos($id) {
$query = "SELECT * FROM `attractions_photos` WHERE `attraction_id` = '$id' ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneAttractionPhoto($id) {
$sql = "SELECT * FROM `attractions_photos` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneAttractionPhoto($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/attractions/gallery/';
$dir_dest_thumb = '../images/attractions/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `attractions_photos` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//Testimonial
function addNewTestimonial($post, $file) {
$name = $_POST['name'];
$description = $_POST['description'];
$status = $_POST['status'];
$dir_dest = '../images/testimonial/';
$handle = new Upload($file['image']);
$addImgName = filename();
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 300;
$handle->image_y = 300;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `testimonial` (name, description, image_name, status)
VALUES ('" . mysql_real_escape_string($name) . "', '" . mysql_real_escape_string($description) . "', '" . mysql_real_escape_string($imgName) . "', '" . mysql_real_escape_string($status) . "')";
$result = $db->readQuery($query);
return $result;
}
function addNewTestimonialBySyte($post, $file) {
$name = $_POST['name'];
$description = $_POST['description'];
$status = $_POST['status'];
$dir_dest = './images/testimonial/';
$handle = new Upload($file['image']);
$addImgName = filename();
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 300;
$handle->image_y = 300;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `testimonial` (name, description, image_name, status)
VALUES ('" . mysql_real_escape_string($name) . "', '" . mysql_real_escape_string($description) . "', '" . mysql_real_escape_string($imgName) . "', '" . mysql_real_escape_string($status) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllTestimonials() {
$query = "SELECT * FROM `testimonial` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getAllActiveTestimonials() {
$db = new DB();
$sql = "SELECT * FROM `testimonial` WHERE `status` = '1' ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'name' => $row['name'],
'description' => $row['description'],
'image_name' => $row['image_name'],
'status' => $row['status'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getOneTestimonial($id) {
$query = "SELECT * FROM `testimonial` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneTestimonial($post, $file) {
$imageold = mysql_real_escape_string($_POST['imageold']);
$id = mysql_real_escape_string($_POST['id']);
$dir_dest = '../images/testimonial/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 300;
$handle->image_y = 300;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `testimonial` SET "
. " `name` = '" . mysql_real_escape_string($_POST['name']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "',"
. " `status` = '" . mysql_real_escape_string($_POST['status']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
} home/islapiiu/sites/mirissa-whales/function.php 0000644 00000070570 15076620427 0015752 0 ustar 00 <?php
function replaceAll($text) {
$text = strtolower(htmlentities($text));
$text = str_replace(get_html_translation_table(), "-", $text);
$text = str_replace(" ", "-", $text);
$text = preg_replace("/[-]+/i", "-", $text);
return $text;
}
//Slider
function addSliderImage($post, $file) {
$dir_dest = '../images/slider/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->image_x = 1122;
$handle->image_y = 480;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `slider` (image_name)
VALUES ('" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getMainSlider() {
$db = new DB();
$sql = "SELECT * FROM `slider` ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'image_name' => $row['image_name'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getSliderImageById($id) {
$query = "SELECT * FROM `slider` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function editSliderImageById($post, $file, $id, $imageold) {
$dir_dest = '../images/slider/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 1122;
$handle->image_y = 480;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
return $imgName;
}
//Welcome TEXT
function getWelcomeNote() {
$query = "SELECT * FROM `welcome-note` WHERE `id` = '1' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateWelcomeNote($post) {
$db = new DB();
$sql = "UPDATE `welcome-note` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`url` = '" . mysql_real_escape_string($_POST['url']) . "',"
. "`description` = '" . mysql_real_escape_string($_POST['description']) . "'"
. "WHERE `id` = 1 ";
$result = $db->readQuery($sql);
return $result;
}
//Subsection
function addSubsections($post, $file) {
$title = $_POST['title'];
$url = $_POST['url'];
$icon = $_POST['icon'];
$description = $_POST['description'];
$db = new DB();
$query = "INSERT INTO `subsections` (title, url, description, icon)
VALUES ('" . mysql_real_escape_string($title) . "', '" . mysql_real_escape_string($url) . "', '" . mysql_real_escape_string($description) . "', '" . mysql_real_escape_string($icon) . "')";
$result = $db->readQuery($query);
return $result;
}
function getSubsections() {
$db = new DB();
$sql = "SELECT * FROM `subsections` ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'title' => $row['title'],
'url' => $row['url'],
'description' => $row['description'],
'icon' => $row['icon'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getSubsectionById($id) {
$query = "SELECT * FROM `subsections` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function editSubsectionById($post, $id) {
$db = new DB();
$sql = "UPDATE `subsections` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "',"
. " `icon` = '" . mysql_real_escape_string($_POST['icon']) . "',"
. " `url` = '" . mysql_real_escape_string($_POST['url']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//Gallery
function addGalleryImage($post, $file) {
$caption = $_POST['caption'];
$dir_dest = '../images/gallery/';
$dir_dest_thumb = '../images/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'L';
$handle->image_x = 900;
$handle->image_y = 600;
$handle->image_text = "Mirissa Whale Warriors";
$handle->image_text_background = '#000000';
$handle->image_text_background_opacity = 50;
$handle->image_text_padding = 10;
$handle->image_text_x = -15;
$handle->image_text_y = -15;
$handle->image_text_line_spacing = 10;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'L';
$handle->image_x = 300;
$handle->image_y = 200;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `gallery` (caption, image_name)
VALUES ('" . mysql_real_escape_string($caption) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getGalleryImage() {
$db = new DB();
$sql = "SELECT * FROM `gallery` ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'caption' => $row['caption'],
'image_name' => $row['image_name'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getGalleryImageById($id) {
$query = "SELECT * FROM `gallery` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function editGalleryImageById($post, $file, $id, $imageold) {
$dir_dest = '../images/gallery/';
$dir_dest_thumb = '../images/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'L';
$handle->file_new_name_body = $imageold;
$handle->image_x = 900;
$handle->image_y = 600;
$handle->image_text = "Mirissa Whale Warriors";
$handle->image_text_background = '#000000';
$handle->image_text_background_opacity = 50;
$handle->image_text_padding = 10;
$handle->image_text_x = -15;
$handle->image_text_y = -15;
$handle->image_text_line_spacing = 10;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'L';
$handle->file_new_name_body = $imageold;
$handle->image_x = 300;
$handle->image_y = 200;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `gallery` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//About US
function getAboutUspageContant() {
$query = "SELECT * FROM `about_us` WHERE `id` = '1' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateAboutUspageContant($post, $file) {
$dir_dest = '../images/about/';
$handle = new Upload($file['image']);
$imgName = null;
$db = new DB();
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'L';
$handle->file_new_name_body = 'aboutus.jpg';
$handle->image_x = 500;
$handle->image_y = 300;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$sql = "UPDATE `about_us` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "',"
. "`vision` = '" . mysql_real_escape_string($_POST['vision']) . "',"
. "`mission` = '" . mysql_real_escape_string($_POST['mission']) . "' "
. "WHERE `id` = 1 ";
$result = $db->readQuery($sql);
return $result;
}
//Services
function newServices($post, $file) {
$title = $_POST['title'];
$description = $_POST['description'];
$dir_dest = '../images/services/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'L';
$handle->image_x = 500;
$handle->image_y = 300;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `services` (title, description, image_name)
VALUES ('" . mysql_real_escape_string($title) . "', '" . mysql_real_escape_string($description) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getServices() {
$db = new DB();
$sql = "SELECT * FROM `services` ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'title' => $row['title'],
'description' => $row['description'],
'image_name' => $row['image_name'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getServiceById($id) {
$query = "SELECT * FROM `services` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function editServicesById($post, $file, $id, $imageold) {
$dir_dest = '../images/services/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'L';
$handle->file_new_name_body = $imageold;
$handle->image_x = 500;
$handle->image_y = 300;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `services` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//Services Photos
function addServicesPhoto($post, $file, $serviceId) {
$caption = $_POST['caption'];
$dir_dest = '../images/services/gallery/';
$dir_dest_thumb = '../images/services/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'L';
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'L';
$handle->image_x = 300;
$handle->image_y = 175;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `services-photos` (services_id, caption, image_name)
VALUES ('" . mysql_real_escape_string($serviceId) . "', '" . mysql_real_escape_string($caption) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getServicesPhotosById($serviceId) {
$db = new DB();
$sql = "SELECT * FROM `services-photos` WHERE `services_id` = '$serviceId' ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'services_id' => $row['services_id'],
'caption' => $row['caption'],
'image_name' => $row['image_name'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getServicePhotosByServiceId($serviceId) {
$db = new DB();
$sql = "SELECT * FROM `services-photos` WHERE `services_id` = '$serviceId' ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'services_id' => $row['services_id'],
'caption' => $row['caption'],
'image_name' => $row['image_name'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getServicePhotoById($id) {
$sql = "SELECT * FROM `services-photos` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
$row = mysql_fetch_assoc($result);
return $row;
}
function editServicePhotoById($post, $file, $id, $imageold) {
$dir_dest = '../images/services/gallery/';
$dir_dest_thumb = '../images/services/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'L';
$handle->file_new_name_body = $imageold;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'L';
$handle->file_new_name_body = $imageold;
$handle->image_x = 300;
$handle->image_y = 175;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `services-photos` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//Comments
function addGestComments($post, $file) {
$dir_dest = '../images/comments/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'L';
$handle->image_x = 300;
$handle->image_y = 300;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `comments` (name, comment, image_name)
VALUES ('" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['comment']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getGestComments() {
$db = new DB();
$sql = "SELECT * FROM `comments` ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'name' => $row['name'],
'comment' => $row['comment'],
'image_name' => $row['image_name'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getGestCommentById($id) {
$query = "SELECT * FROM `comments` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function editGestCommentById($post, $file, $id, $imageold) {
$dir_dest = '../images/comments/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'L';
$handle->file_new_name_body = $imageold;
$handle->image_x = 300;
$handle->image_y = 300;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `comments` SET "
. "`name` = '" . mysql_real_escape_string($_POST['name']) . "',"
. " `comment` = '" . mysql_real_escape_string($_POST['comment']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//Team
function addTeamMember($post, $file) {
$name = $_POST['name'];
$description = $_POST['description'];
$dir_dest = '../images/team/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'L';
$handle->image_x = 350;
$handle->image_y = 350;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `team` (name, description, image_name)
VALUES ('" . mysql_real_escape_string($name) . "', '" . mysql_real_escape_string($description) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getTeamMember() {
$db = new DB();
$sql = "SELECT * FROM `team` ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'name' => $row['name'],
'description' => $row['description'],
'image_name' => $row['image_name'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getTeamById($id) {
$query = "SELECT * FROM `team` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function editTeamById($post, $file, $id, $imageold) {
$dir_dest = '../images/team/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'L';
$handle->file_new_name_body = $imageold;
$handle->image_x = 350;
$handle->image_y = 350;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `team` SET "
. "`name` = '" . mysql_real_escape_string($_POST['name']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//Banner
function getBannerPhotos() {
$db = new DB();
$sql = "SELECT * FROM `banner`";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'image_name' => $row['image_name'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getBannerImageById($id) {
$query = "SELECT * FROM `banner` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateBannerPhotos($post, $file, $id, $imageold) {
$dir_dest = '../images/banner/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 1920;
$handle->image_y = 320;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
}
//Certificats
function addCertificatsImage($post, $file) {
$title = $_POST['title'];
$dir_dest = '../images/certificats/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = FALSE;
$handle->file_new_name_body = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->file_new_name_body = $title.".jpg";
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `certificats` (title, image_name)
VALUES ('" . mysql_real_escape_string($title) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getCertificatsImage() {
$db = new DB();
$sql = "SELECT * FROM `certificats` ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'title' => $row['title'],
'image_name' => $row['image_name'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getCertificatsImageById($id) {
$query = "SELECT * FROM `certificats` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function editCertificatsImageById($post, $file, $id, $imageold) {
$dir_dest = '../images/certificats/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = FALSE;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->file_new_name_body = $imageold;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `certificats` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function CheckUser($id, $username, $enPw) {
$sql = "SELECT * FROM `user` WHERE `id` = '$id' AND `user_name`= '$username' AND `password`= '$enPw'";
$db = new DB();
$result = $db->readQuery($sql);
return mysql_fetch_array($result);
// if ($result) {
// return TRUE;
// } else {
// return FALSE;
// }
}
function getAllUserDetails($id) {
$sql = "SELECT * FROM `user` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
return mysql_fetch_array($result);
// if ($result) {
// return TRUE;
// } else {
// return FALSE;
// }
}
function checkEmail($email) {
$query = "SELECT `email`,`user_name` FROM `user` WHERE `email`= '" . $email . "'";
$db = new DB();
$result = mysql_fetch_array($db->readQuery($query));
if (!$result) {
return FALSE;
} else {
return $result;
}
}
function GenarateCode($email) {
$rand = rand(10000, 99999);
$query = "UPDATE `user` SET "
. "`resetcode` ='" . $rand . "' "
. "WHERE `email` = '" . $email . "'";
$db = new DB();
$result = $db->readQuery($query);
if ($result) {
return TRUE;
} else {
return FALSE;
}
}
function SelectForgetUser($email) {
if ($email) {
$query = "SELECT `email`,`user_name`,`resetcode` FROM `user` WHERE `email`= '" . $email . "'";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
}
function SelectResetCode($code) {
$query = "SELECT `id` FROM `user` WHERE `resetcode`= '" . $code . "'";
$db = new DB();
$result = mysql_fetch_array($db->readQuery($query));
if (!$result) {
return FALSE;
} else {
return TRUE;
}
}
function updatePassword($password, $code) {
$enPass = md5($password);
$query = "UPDATE `user` SET "
. "`password` ='" . $enPass . "' "
. "WHERE `resetcode` = '" . $code . "'";
$db = new DB();
$result = $db->readQuery($query);
if ($result) {
return TRUE;
} else {
return FALSE;
}
} home/islapiiu/sites/hikkalotustours/function.php 0000644 00000110055 15076624505 0016267 0 ustar 00 <?php
function filename() {
$today = time();
$startDate = date('YmdHi', strtotime('3012-03-14 09:06:00'));
$range = $today - $startDate;
$rand = rand(0, $range);
$imgname = $rand . "_" . ($startDate + $rand) . '_' . $today . "_n";
return $imgname;
}
function seoUrl($text) {
//Lower case everything
$string = strtolower($text);
//Make alphanumeric (removes all other characters)
$string2 = preg_replace("/[^a-z0-9_\s-]/", "", $string);
//Clean up multiple dashes or whitespaces
$string3 = preg_replace("/[\s-]+/", " ", $string2);
//Convert whitespaces and underscore to dash
$string4 = preg_replace("/[\s_]/", "-", $string3);
return $string4;
}
// image slider //
function addNewSlide($post, $file) {
$addImgName = filename();
$dir_dest = '../images/slider/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 1600;
$handle->image_y = 700;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `slider` (title, url, description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "', '" . mysql_real_escape_string($_POST['url']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllSlides() {
$query = "SELECT * FROM `slider` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneSlide($id) {
$query = "SELECT * FROM `slider` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneSlide($post, $file) {
$id = $_POST['id'];
$imageold = $_POST['oldImg'];
$dir_dest = '../images/slider/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 1600;
$handle->image_y = 700;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `slider` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`description` = '" . mysql_real_escape_string($_POST['description']) . "',"
. "`url` = '" . mysql_real_escape_string($_POST['url']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//welcom text //
function getWelcomeNote() {
$query = "SELECT * FROM `welcome-note` WHERE `id` = '1' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateWelcomeNote($post) {
$db = new DB();
$sql = "UPDATE `welcome-note` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`url` = '" . mysql_real_escape_string($_POST['url']) . "',"
. "`description` = '" . mysql_real_escape_string($_POST['description']) . "'"
. "WHERE `id` = 1 ";
$result = $db->readQuery($sql);
return $result;
}
//gallery //
function addNewImage($post, $file) {
$addImgName = filename();
$dir_dest = '../images/gallery/';
$dir_dest_thumb = '../images/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 300;
$handle->image_y = 175;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `gallery` (caption, image_name)
VALUES ('" . mysql_real_escape_string($_POST['caption']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllImages() {
$query = "SELECT * FROM `gallery` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneImage($id) {
$query = "SELECT * FROM `gallery` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneImage($post, $file) {
$id = $_POST['id'];
$imageold = $_POST['oldImg'];
$dir_dest = '../images/gallery/';
$dir_dest_thumb = '../images/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 300;
$handle->image_y = 175;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `gallery` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//about us //
function getAboutUspageContant() {
$query = "SELECT * FROM `about_us` WHERE `id` = '1' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateAboutUspageContant($post, $file) {
$dir_dest = '../images/about/';
$handle = new Upload($file['image']);
$imgName = null;
$db = new DB();
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = 'aboutus.jpg';
$handle->image_x = 500;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$sql = "UPDATE `about_us` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "',"
. "`vision` = '" . mysql_real_escape_string($_POST['vision']) . "',"
. "`mission` = '" . mysql_real_escape_string($_POST['mission']) . "' "
. "WHERE `id` = 1 ";
$result = $db->readQuery($sql);
return $result;
}
//package //
function addNewPackage($post, $file) {
$addImgName = filename();
$dir_dest = '../images/packages/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 480;
$handle->image_y = 300;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `packages` (title, duration, short_description, description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "','" . mysql_real_escape_string($_POST['duration']) . "', '" . mysql_real_escape_string($_POST['short_description']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllPackages() {
$query = "SELECT * FROM `packages` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOnePackage($id) {
$query = "SELECT * FROM `packages` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOnePackage($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/packages/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 480;
$handle->image_y = 300;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `packages` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`duration` = '" . mysql_real_escape_string($_POST['duration']) . "',"
. "`short_description` = '" . mysql_real_escape_string($_POST['short_description']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function addNewPackagePhoto($post, $file) {
$addImgName = filename();
$id = $_POST['id'];
$dir_dest = '../images/packages/gallery/';
$dir_dest_thumb = '../images/packages/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `packages_photos` (package_id, caption, image_name)
VALUES ('" . mysql_real_escape_string($id) . "', '" . mysql_real_escape_string($_POST['caption']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllPackagesPhotos($id) {
$query = "SELECT * FROM `packages_photos` WHERE `package_id` = '$id' ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOnePackagePhoto($id) {
$sql = "SELECT * FROM `packages_photos` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOnePackagePhoto($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/rooms/gallery/';
$dir_dest_thumb = '../images/rooms/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `packages_photos` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//end of packages//
//Offers//
function addNewoffers($post, $file) {
$addImgName = filename();
$dir_dest = '../images/offers/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 400;
$handle->image_y = 520;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `offers` (title, Price, Discount, Short_description, Long_description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "','" . mysql_real_escape_string($_POST['Price']) . "','" . mysql_real_escape_string($_POST['Discount']) . "','" . mysql_real_escape_string($_POST['Short_description']) . "', '" . mysql_real_escape_string($_POST['Long_description']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAlloffers() {
$query = "SELECT * FROM `offers` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneoffers($id) {
$query = "SELECT * FROM `offers` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneoffers($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/offers/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 400;
$handle->image_y = 520;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `offers` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`Price` = '" . mysql_real_escape_string($_POST['Price']) . "',"
. "`Discount` = '" . mysql_real_escape_string($_POST['Discount']) . "',"
. " `Short_description` = '" . mysql_real_escape_string($_POST['Short_description']) . "', "
. " `Long_description` = '" . mysql_real_escape_string($_POST['Long_description']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//end of offers//
//Activities //
function addNewActivitie($post, $file) {
$addImgName = filename();
$dir_dest = '../images/activities/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `activities` (title, short_description, description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "', '" . mysql_real_escape_string($_POST['short_description']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllActivities() {
$query = "SELECT * FROM `activities` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneActivitie($id) {
$query = "SELECT * FROM `activities` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneActivitie($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/activities/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `activities` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`short_description` = '" . mysql_real_escape_string($_POST['short_description']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function addNewActivitiePhoto($post, $file) {
$addImgName = filename();
$dir_dest = '../images/activities/gallery/';
$dir_dest_thumb = '../images/activities/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `activities_photos` (activities_id, caption, image_name)
VALUES ('" . mysql_real_escape_string($_POST['id']) . "', '" . mysql_real_escape_string($_POST['caption']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllActivitiePhotos($id) {
$query = "SELECT * FROM `activities_photos` WHERE `activities_id` = '$id' ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneActivitiePhoto($id) {
$sql = "SELECT * FROM `activities_photos` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneActivitiePhoto($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/activities/gallery/';
$dir_dest_thumb = '../images/activities/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `activities_photos` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//Attractions //
function addNewAttraction($post, $file) {
$addImgName = filename();
$dir_dest = '../images/attractions/';
$dir_dest_thumb = '../images/attractions/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 750;
$handle->image_y = 450;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `attractions` (title, short_description ,description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "', '" . mysql_real_escape_string($_POST['short_description']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllAttractions() {
$query = "SELECT * FROM `attractions` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneAttraction($id) {
$query = "SELECT * FROM `attractions` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneAttraction($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/attractions/';
$dir_dest_thumb = '../images/attractions/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 750;
$handle->image_y = 450;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `attractions` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. " `short_description` = '" . mysql_real_escape_string($_POST['short_description']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function addNewAttractionPhoto($post, $file) {
$id = $_POST['id'];
$addImgName = filename();
$caption = $_POST['caption'];
$dir_dest = '../images/attractions/gallery/';
$dir_dest_thumb = '../images/attractions/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 900;
$handle->image_y = 600;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `attractions_photos` (attraction_id, caption, image_name)
VALUES ('" . mysql_real_escape_string($id) . "', '" . mysql_real_escape_string($caption) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllAttractionPhotos($id) {
$query = "SELECT * FROM `attractions_photos` WHERE `attraction_id` = '$id' ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneAttractionPhoto($id) {
$sql = "SELECT * FROM `attractions_photos` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneAttractionPhoto($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/attractions/gallery/';
$dir_dest_thumb = '../images/attractions/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 430;
$handle->image_y = 305;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `attractions_photos` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//Testimonial
function addNewTestimonial($post, $file) {
$name = $_POST['name'];
$description = $_POST['description'];
$status = $_POST['status'];
$addImgName = filename();
$dir_dest = '../images/testimonial/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 300;
$handle->image_y = 300;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `testimonial` (name, description, image_name, status)
VALUES ('" . mysql_real_escape_string($name) . "', '" . mysql_real_escape_string($description) . "', '" . mysql_real_escape_string($imgName) . "', '" . mysql_real_escape_string($status) . "')";
$result = $db->readQuery($query);
return $result;
}
function addNewTestimonialBySyte($post, $file) {
$name = $_POST['name'];
$description = $_POST['description'];
$status = $_POST['status'];
$dir_dest = '../images/testimonial/';
$handle = new Upload($file['image']);
$addImgName = filename();
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 300;
$handle->image_y = 300;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `testimonial` (name, description, image_name, status)
VALUES ('" . mysql_real_escape_string($name) . "', '" . mysql_real_escape_string($description) . "', '" . mysql_real_escape_string($imgName) . "', '" . mysql_real_escape_string($status) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllTestimonials() {
$query = "SELECT * FROM `testimonial` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getAllActiveTestimonials() {
$db = new DB();
$sql = "SELECT * FROM `testimonial` WHERE `status` = '1' ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'name' => $row['name'],
'description' => $row['description'],
'image_name' => $row['image_name'],
'status' => $row['status'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getOneTestimonial($id) {
$query = "SELECT * FROM `testimonial` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneTestimonial($post, $file) {
$imageold = mysql_real_escape_string($_POST['imageold']);
$id = mysql_real_escape_string($_POST['id']);
$dir_dest = '../images/testimonial/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 300;
$handle->image_y = 300;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `testimonial` SET "
. " `name` = '" . mysql_real_escape_string($_POST['name']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "',"
. " `status` = '" . mysql_real_escape_string($_POST['status']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
home/islapiiu/sites/madolduwaboatride/function.php 0000644 00000100151 15076731106 0016473 0 ustar 00 <?php
function filename() {
$today = time();
$startDate = date('YmdHi', strtotime('3012-03-14 09:06:00'));
$range = $today - $startDate;
$rand = rand(0, $range);
$imgname = $rand . "_" . ($startDate + $rand) . '_' . $today . "_n";
return $imgname;
}
function no1() {
$codeRandom = rand(0, 99);
return $codeRandom;
}
function no2() {
$codeRandom = rand(0, 99);
return $codeRandom;
}
function seoUrl($text) {
//Lower case everything
$string = strtolower($text);
//Make alphanumeric (removes all other characters)
$string2 = preg_replace("/[^a-z0-9_\s-]/", "", $string);
//Clean up multiple dashes or whitespaces
$string3 = preg_replace("/[\s-]+/", " ", $string2);
//Convert whitespaces and underscore to dash
$string4 = preg_replace("/[\s_]/", "-", $string3);
return $string4;
}
// image slider //
function addNewSlide($post, $file) {
$addImgName = filename();
$dir_dest = '../images/slider/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 1920;
$handle->image_y = 750;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `slider` (title, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "' , '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllSlides() {
$query = "SELECT * FROM `slider` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneSlide($id) {
$query = "SELECT * FROM `slider` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneSlide($post, $file) {
$id = $_POST['id'];
$imageold = $_POST['oldImg'];
$dir_dest = '../images/slider/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 1920;
$handle->image_y = 750;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `slider` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//welcom text //
function getWelcomeNote() {
$query = "SELECT * FROM `welcome-note` WHERE `id` = '1' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateWelcomeNote($post) {
$db = new DB();
$sql = "UPDATE `welcome-note` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`url` = '" . mysql_real_escape_string($_POST['url']) . "',"
. "`description` = '" . mysql_real_escape_string($_POST['description']) . "'"
. "WHERE `id` = 1 ";
$result = $db->readQuery($sql);
return $result;
}
//gallery //
function addNewImage($post, $file) {
$addImgName = filename();
$dir_dest = '../images/gallery/';
$dir_dest_thumb = '../images/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 1280;
$handle->image_y = 720;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 480;
$handle->image_y = 270;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `gallery` (caption, image_name)
VALUES ('" . mysql_real_escape_string($_POST['caption']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllImages() {
$db = new DB();
$sql = "SELECT * FROM `gallery` ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'caption' => $row['caption'],
'image_name' => $row['image_name'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getOneImage($id) {
$query = "SELECT * FROM `gallery` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneImage($post, $file) {
$id = $_POST['id'];
$imageold = $_POST['oldImg'];
$dir_dest = '../images/gallery/';
$dir_dest_thumb = '../images/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 1280;
$handle->image_y = 720;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 480;
$handle->image_y = 270;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `gallery` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//about us //
function getAboutUspageContant() {
$query = "SELECT * FROM `about_us` WHERE `id` = '1' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateAboutUspageContant($post, $file) {
$dir_dest = '../images/about/';
$handle = new Upload($file['image']);
$imgName = null;
$db = new DB();
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = 'aboutus.jpg';
$handle->image_x = 500;
$handle->image_y = 350;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$sql = "UPDATE `about_us` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "',"
. "`vision` = '" . mysql_real_escape_string($_POST['vision']) . "',"
. "`mission` = '" . mysql_real_escape_string($_POST['mission']) . "' "
. "WHERE `id` = 1 ";
$result = $db->readQuery($sql);
return $result;
}
//rooms //
function addNewRoom($post, $file) {
$addImgName = filename();
$dir_dest = '../images/rooms/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 380;
$handle->image_y = 230;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `rooms` (title, price, sort_description, description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "','" . mysql_real_escape_string($_POST['price']) . "', '" . mysql_real_escape_string($_POST['sort_description']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllRooms() {
$query = "SELECT * FROM `rooms` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneRoom($id) {
$query = "SELECT * FROM `rooms` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneRoom($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/rooms/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 380;
$handle->image_y = 230;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `rooms` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`price` = '" . mysql_real_escape_string($_POST['price']) . "',"
. "`sort_description` = '" . mysql_real_escape_string($_POST['sort_description']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function addNewRoomPhoto($post, $file) {
$addImgName = filename();
$id = $_POST['id'];
$dir_dest = '../images/rooms/gallery/';
$dir_dest_thumb = '../images/rooms/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 300;
$handle->image_y = 175;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `rooms_photos` (room_id, caption, image_name)
VALUES ('" . mysql_real_escape_string($id) . "', '" . mysql_real_escape_string($_POST['caption']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllRoomsPhotos($id) {
$db = new DB();
$sql = "SELECT * FROM `rooms_photos` WHERE `room_id` = '$id' ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'room_id' => $row['room_id'],
'caption' => $row['caption'],
'image_name' => $row['image_name'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getOneRoomPhoto($id) {
$sql = "SELECT * FROM `rooms_photos` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneRoomPhoto($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/rooms/gallery/';
$dir_dest_thumb = '../images/rooms/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 300;
$handle->image_y = 175;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `rooms_photos` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//Activities //
function addNewActivitie($post, $file) {
$addImgName = filename();
$dir_dest = '../images/excursion/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 360;
$handle->image_y = 230;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `activities` (title, sort_description, description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "', '" . mysql_real_escape_string($_POST['sort_description']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllActivities() {
$query = "SELECT * FROM `activities` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneActivitie($id) {
$query = "SELECT * FROM `activities` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneActivitie($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/excursion/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 360;
$handle->image_y = 230;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `activities` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`sort_description` = '" . mysql_real_escape_string($_POST['sort_description']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function addNewActivitiePhoto($post, $file) {
$addImgName = filename();
$dir_dest = '../images/activities/gallery/';
$dir_dest_thumb = '../images/activities/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 300;
$handle->image_y = 175;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `activities_photos` (activities_id, caption, image_name)
VALUES ('" . mysql_real_escape_string($_POST['id']) . "', '" . mysql_real_escape_string($_POST['caption']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllActivitiePhotos($id) {
$query = "SELECT * FROM `activities_photos` WHERE `activities_id` = '$id' ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneActivitiePhoto($id) {
$sql = "SELECT * FROM `activities_photos` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneActivitiePhoto($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/activities/gallery/';
$dir_dest_thumb = '../images/activities/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 300;
$handle->image_y = 175;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `activities_photos` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//album //
function addNewAlbum($post, $file) {
$addImgName = filename();
$dir_dest = '../images/album/';
$dir_dest_thumb = '../images/album/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 720;
$handle->image_y = 490;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 360;
$handle->image_y = 245;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `album` (title, shortDescription, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "', '" . mysql_real_escape_string($_POST['shortDescription']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllAlbum() {
$query = "SELECT * FROM `album` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneAlbum($id) {
$query = "SELECT * FROM `album` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneAlbum($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/album/';
$dir_dest_thumb = '../images/album/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 720;
$handle->image_y = 490;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 360;
$handle->image_y = 245;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `album` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. " `shortDescription` = '" . mysql_real_escape_string($_POST['shortDescription']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function addNewAlbumPhoto($post, $file) {
$id = $_POST['id'];
$addImgName = filename();
$caption = $_POST['caption'];
$dir_dest = '../images/album/gallery/';
$dir_dest_thumb = '../images/album/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 1280;
$handle->image_y = 720;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 480;
$handle->image_y = 270;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `album-photos` (album_id, caption, image_name)
VALUES ('" . mysql_real_escape_string($id) . "', '" . mysql_real_escape_string($caption) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllAlbumPhotos($id) {
$query = "SELECT * FROM `album-photos` WHERE `album_id` = '$id' ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneAlbumPhoto($id) {
$sql = "SELECT * FROM `album-photos` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneAlbumPhoto($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/album/gallery/';
$dir_dest_thumb = '../images/album/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 1280;
$handle->image_y = 720;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 480;
$handle->image_y = 270;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `album-photos` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function countPhotos($id) {
$query = "SELECT * FROM `album-photos` WHERE `album_id` = '$id'";
$db = new DB();
$result = $db->readQuery($query);
$num_rows = mysql_num_rows($result);
return $num_rows;
}
// comments //
function addNewComment($post, $file) {
$addImgName = filename();
$dir_dest = '../images/comments/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 100;
$handle->image_y = 100;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `comments` (name, comment, image_name)
VALUES ('" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['comment']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllComments() {
$query = "SELECT * FROM `comments` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneComment($id) {
$query = "SELECT * FROM `comments` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneComment($post, $file) {
$id = $_POST['id'];
$imageold = $_POST['oldImg'];
$dir_dest = '../images/comments/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 90;
$handle->image_y = 90;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `comments` SET "
. "`name` = '" . mysql_real_escape_string($_POST['name']) . "',"
. " `comment` = '" . mysql_real_escape_string($_POST['comment']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function addNewGuestComment($post, $file) {
$addImgName = filename();
$dir_dest = 'images/comments/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 100;
$handle->image_y = 100;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `comments` (name, comment, image_name)
VALUES ('" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['comment']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
home/islapiiu/sites/villaeffort/function.php 0000644 00000106073 15076747443 0015345 0 ustar 00 <?php
function filename() {
$today = time();
$startDate = date('YmdHi', strtotime('3012-03-14 09:06:00'));
$range = $today - $startDate;
$rand = rand(0, $range);
$imgname = $rand . "_" . ($startDate + $rand) . '_' . $today . "_n";
return $imgname;
}
function seoUrl($text) {
//Lower case everything
$string = strtolower($text);
//Make alphanumeric (removes all other characters)
$string2 = preg_replace("/[^a-z0-9_\s-]/", "", $string);
//Clean up multiple dashes or whitespaces
$string3 = preg_replace("/[\s-]+/", " ", $string2);
//Convert whitespaces and underscore to dash
$string4 = preg_replace("/[\s_]/", "-", $string3);
return $string4;
}
// image slider //
function addNewSlide($post, $file) {
$addImgName = filename();
$dir_dest = '../images/slider/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 1500;
$handle->image_y = 864;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `slider` (title, description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllSlides() {
$query = "SELECT * FROM `slider` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneSlide($id) {
$query = "SELECT * FROM `slider` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneSlide($post, $file) {
$id = $_POST['id'];
$imageold = $_POST['oldImg'];
$dir_dest = '../images/slider/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 1500;
$handle->image_y = 864;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `slider` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`description` = '" . mysql_real_escape_string($_POST['description']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//welcom text //
function getWelcomeNote() {
$query = "SELECT * FROM `welcome-note` WHERE `id` = '1' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateWelcomeNote($post) {
$db = new DB();
$sql = "UPDATE `welcome-note` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`url` = '" . mysql_real_escape_string($_POST['url']) . "',"
. "`description` = '" . mysql_real_escape_string($_POST['description']) . "'"
. "WHERE `id` = 1 ";
$result = $db->readQuery($sql);
return $result;
}
//gallery //
function addNewImage($post, $file) {
$addImgName = filename();
$dir_dest = '../images/gallery/';
$dir_dest_thumb = '../images/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$image_dst_x = $handle->image_dst_x;
$image_dst_y = $handle->image_dst_y;
$newSize = calculateResize(700, $image_dst_x, $image_dst_y);
$handle->image_x = $newSize[0];
$handle->image_y = $newSize[1];
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 270;
$handle->image_y = 320;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `gallery` (caption, image_name)
VALUES ('" . mysql_real_escape_string($_POST['caption']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllImages() {
$db = new DB();
$sql = "SELECT * FROM `gallery` ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'caption' => $row['caption'],
'image_name' => $row['image_name'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getOneImage($id) {
$query = "SELECT * FROM `gallery` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneImage($post, $file) {
$id = $_POST['id'];
$imageold = $_POST['oldImg'];
$dir_dest = '../images/gallery/';
$dir_dest_thumb = '../images/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$image_dst_x = $handle->image_dst_x;
$image_dst_y = $handle->image_dst_y;
$newSize = calculateResize(700, $image_dst_x, $image_dst_y);
$handle->image_x = $newSize[0];
$handle->image_y = $newSize[1];
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 270;
$handle->image_y = 320;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `gallery` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//about us //
function getAboutUspageContant() {
$query = "SELECT * FROM `about_us` WHERE `id` = '1' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateAboutUspageContant($post, $file) {
$dir_dest = '../images/about/';
$handle = new Upload($file['image']);
$imgName = null;
$db = new DB();
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'L';
$handle->file_new_name_body = 'aboutus.jpg';
$handle->image_x = 500;
$handle->image_y = 300;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$sql = "UPDATE `about_us` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "',"
. "`vision` = '" . mysql_real_escape_string($_POST['vision']) . "',"
. "`mission` = '" . mysql_real_escape_string($_POST['mission']) . "' "
. "WHERE `id` = 1 ";
$result = $db->readQuery($sql);
return $result;
}
//rooms //
function addNewRoom($post, $file) {
$addImgName = filename();
$dir_dest = '../images/rooms/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 360;
$handle->image_y = 240;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `rooms` (title, price, priceRO, extraBeds, extraBedPrice, numOfRoom, sort_description, description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "', '" .
mysql_real_escape_string($_POST['price']) . "', '" .
mysql_real_escape_string($_POST['priceRO']) . "', '" .
mysql_real_escape_string($_POST['extraBeds']) . "', '" .
mysql_real_escape_string($_POST['extraBedPrice']) . "', '" .
mysql_real_escape_string($_POST['numOfRoom']) . "', '" .
mysql_real_escape_string($_POST['sort_description']) . "', '" .
mysql_real_escape_string($_POST['description']) . "', '" .
mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllRooms() {
$query = "SELECT * FROM `rooms` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneRoom($id) {
$query = "SELECT * FROM `rooms` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneRoom($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/rooms/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 360;
$handle->image_y = 240;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `rooms` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`price` = '" . mysql_real_escape_string($_POST['price']) . "',"
. "`priceRO` = '" . mysql_real_escape_string($_POST['priceRO']) . "',"
. "`extraBeds` = '" . mysql_real_escape_string($_POST['extraBeds']) . "',"
. "`extraBedPrice` = '" . mysql_real_escape_string($_POST['extraBedPrice']) . "',"
. "`numOfRoom` = '" . mysql_real_escape_string($_POST['numOfRoom']) . "',"
. "`sort_description` = '" . mysql_real_escape_string($_POST['sort_description']) . "',"
. "`description` = '" . mysql_real_escape_string($_POST['description']) . "' "
. " WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function addNewRoomPhoto($post, $file) {
$addImgName = filename();
$id = $_POST['id'];
$dir_dest = '../images/rooms/gallery/';
$dir_dest_thumb = '../images/rooms/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$image_dst_x = $handle->image_dst_x;
$image_dst_y = $handle->image_dst_y;
$newSize = calculateResize(700, $image_dst_x, $image_dst_y);
$handle->image_x = $newSize[0];
$handle->image_y = $newSize[1];
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 300;
$handle->image_y = 175;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `rooms_photos` (room_id, caption, image_name)
VALUES ('" . mysql_real_escape_string($id) . "', '" . mysql_real_escape_string($_POST['caption']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllRoomsPhotos($id) {
$db = new DB();
$sql = "SELECT * FROM `rooms_photos` WHERE `room_id` = '$id' ORDER BY sort ASC";
$result = $db->readQuery($sql);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
$property = array(
'id' => $row['id'],
'room_id' => $row['room_id'],
'caption' => $row['caption'],
'image_name' => $row['image_name'],
'sort' => $row['sort'],
);
array_push($array_res, $property);
}
return $array_res;
}
function getOneRoomPhoto($id) {
$sql = "SELECT * FROM `rooms_photos` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneRoomPhoto($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/rooms/gallery/';
$dir_dest_thumb = '../images/rooms/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$image_dst_x = $handle->image_dst_x;
$image_dst_y = $handle->image_dst_y;
$newSize = calculateResize(700, $image_dst_x, $image_dst_y);
$handle->image_x = $newSize[0];
$handle->image_y = $newSize[1];
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 300;
$handle->image_y = 175;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `rooms_photos` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//Activities //
function addNewActivitie($post, $file) {
$addImgName = filename();
$dir_dest = '../images/activities/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 263;
$handle->image_y = 308;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `activities` (title, sort_description, description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "', '" . mysql_real_escape_string($_POST['sort_description']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllActivities() {
$query = "SELECT * FROM `activities` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneActivitie($id) {
$query = "SELECT * FROM `activities` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneActivitie($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/activities/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 263;
$handle->image_y = 308;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `activities` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. "`sort_description` = '" . mysql_real_escape_string($_POST['sort_description']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function addNewActivitiePhoto($post, $file) {
$addImgName = filename();
$dir_dest = '../images/activities/gallery/';
$dir_dest_thumb = '../images/activities/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 360;
$handle->image_y = 234;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `activities_photos` (activities_id, caption, image_name)
VALUES ('" . mysql_real_escape_string($_POST['id']) . "', '" . mysql_real_escape_string($_POST['caption']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllActivitiePhotos($id) {
$query = "SELECT * FROM `activities_photos` WHERE `activities_id` = '$id' ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneActivitiePhoto($id) {
$sql = "SELECT * FROM `activities_photos` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneActivitiePhoto($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/activities/gallery/';
$dir_dest_thumb = '../images/activities/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 900;
$handle->image_y = 500;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 360;
$handle->image_y = 234;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `activities_photos` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
//service //
function addNewService($post, $file) {
$addImgName = filename();
$dir_dest = '../images/services/';
$dir_dest_thumb = '../images/services/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 540;
$handle->image_y = 400;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 263;
$handle->image_y = 308;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `services` (title, shortDescription ,description, image_name)
VALUES ('" . mysql_real_escape_string($_POST['title']) . "', '" . mysql_real_escape_string($_POST['shortDescription']) . "', '" . mysql_real_escape_string($_POST['description']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllServices() {
$query = "SELECT * FROM `services` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneService($id) {
$query = "SELECT * FROM `services` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneService($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/services/';
$dir_dest_thumb = '../images/services/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 540;
$handle->image_y = 400;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 263;
$handle->image_y = 308;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `services` SET "
. "`title` = '" . mysql_real_escape_string($_POST['title']) . "',"
. " `shortDescription` = '" . mysql_real_escape_string($_POST['shortDescription']) . "',"
. " `description` = '" . mysql_real_escape_string($_POST['description']) . "' "
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function addNewServicePhoto($post, $file) {
$id = $_POST['id'];
$addImgName = filename();
$caption = $_POST['caption'];
$dir_dest = '../images/services/gallery/';
$dir_dest_thumb = '../images/services/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 900;
$handle->image_y = 600;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 300;
$handle->image_y = 200;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
}
}
$db = new DB();
$query = "INSERT INTO `services-photos` (service_id, caption, image_name)
VALUES ('" . mysql_real_escape_string($id) . "', '" . mysql_real_escape_string($caption) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllServicePhotos($id) {
$query = "SELECT * FROM `services-photos` WHERE `service_id` = '$id' ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneServicePhoto($id) {
$sql = "SELECT * FROM `services-photos` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneServicePhoto($post, $file) {
$imageold = $_POST['oldImg'];
$id = $_POST['id'];
$dir_dest = '../images/services/gallery/';
$dir_dest_thumb = '../images/services/gallery/thumb/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 900;
$handle->image_y = 600;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 300;
$handle->image_y = 200;
$handle->Process($dir_dest_thumb);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `services-photos` SET "
. "`caption` = '" . mysql_real_escape_string($_POST['caption']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
// comments //
function addNewComment($post, $file) {
$addImgName = filename();
$dir_dest = '../images/comments/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_ext = 'jpg';
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $addImgName;
$handle->image_x = 100;
$handle->image_y = 100;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$query = "INSERT INTO `comments` (name, comment, image_name)
VALUES ('" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['comment']) . "', '" . mysql_real_escape_string($imgName) . "')";
$result = $db->readQuery($query);
return $result;
}
function getAllComments() {
$query = "SELECT * FROM `comments` ORDER BY sort ASC";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
function getOneComment($id) {
$query = "SELECT * FROM `comments` WHERE `id` = '$id' LIMIT 1";
$db = new DB();
$result = $db->readQuery($query);
$row = mysql_fetch_assoc($result);
return $row;
}
function updateOneComment($post, $file) {
$id = $_POST['id'];
$imageold = $_POST['oldImg'];
$dir_dest = '../images/comments/';
$handle = new Upload($file['image']);
$imgName = null;
if ($handle->uploaded) {
$handle->image_resize = true;
$handle->file_new_name_body = TRUE;
$handle->file_overwrite = TRUE;
$handle->file_new_name_ext = FALSE;
$handle->image_ratio_crop = 'C';
$handle->file_new_name_body = $imageold;
$handle->image_x = 100;
$handle->image_y = 100;
$handle->Process($dir_dest);
if ($handle->processed) {
$info = getimagesize($handle->file_dst_pathname);
$imgName = $handle->file_dst_name;
}
}
$db = new DB();
$sql = "UPDATE `comments` SET "
. "`name` = '" . mysql_real_escape_string($_POST['name']) . "',"
. " `comment` = '" . mysql_real_escape_string($_POST['comment']) . "'"
. "WHERE `id` = '$id' ";
$result = $db->readQuery($sql);
return $result;
}
function calculateResize($newHeight, $width, $height) {
$percent = $newHeight / $height;
$result1 = $percent * 100;
$result2 = $width * $result1 / 100;
return array($result2, $newHeight);
}
function CheckUser($id, $username, $enPw) {
$sql = "SELECT * FROM `user` WHERE `id` = '$id' AND `user_name`= '$username' AND `password`= '$enPw'";
$db = new DB();
$result = $db->readQuery($sql);
return mysql_fetch_array($result);
// if ($result) {
// return TRUE;
// } else {
// return FALSE;
// }
}
function getAllUserDetails($id) {
$sql = "SELECT * FROM `user` WHERE `id` = '$id'";
$db = new DB();
$result = $db->readQuery($sql);
return mysql_fetch_array($result);
// if ($result) {
// return TRUE;
// } else {
// return FALSE;
// }
}
function checkEmail($email) {
$query = "SELECT `email`,`user_name` FROM `user` WHERE `email`= '" . $email . "'";
$db = new DB();
$result = mysql_fetch_array($db->readQuery($query));
if (!$result) {
return FALSE;
} else {
return $result;
}
}
function GenarateCode($email) {
$rand = rand(10000, 99999);
$query = "UPDATE `user` SET "
. "`resetcode` ='" . $rand . "' "
. "WHERE `email` = '" . $email . "'";
$db = new DB();
$result = $db->readQuery($query);
if ($result) {
return TRUE;
} else {
return FALSE;
}
}
function SelectForgetUser($email) {
if ($email) {
$query = "SELECT `email`,`user_name`,`resetcode` FROM `user` WHERE `email`= '" . $email . "'";
$db = new DB();
$result = $db->readQuery($query);
$array_res = array();
while ($row = mysql_fetch_array($result)) {
array_push($array_res, $row);
}
return $array_res;
}
}
function SelectResetCode($code) {
$query = "SELECT `id` FROM `user` WHERE `resetcode`= '" . $code . "'";
$db = new DB();
$result = mysql_fetch_array($db->readQuery($query));
if (!$result) {
return FALSE;
} else {
return TRUE;
}
}
function updatePassword($password, $code) {
$enPass = md5($password);
$query = "UPDATE `user` SET "
. "`password` ='" . $enPass . "' "
. "WHERE `resetcode` = '" . $code . "'";
$db = new DB();
$result = $db->readQuery($query);
if ($result) {
return TRUE;
} else {
return FALSE;
}
} |