( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
include("includes/limittext.php");
include('Connections/videoondemand.php');
require("DbSql.inc.php");
require("NewsSql.inc.php");
$db = new NewsSQL($DBName);
function filter($arr) {
global $link;
return array_map(array($link, 'real_escape_string'), $arr);
}
$_GET = filter($_GET);
$_POST = filter($_POST);
$mode=$_GET["mode"];
include("protect.php");
if (empty($page)) {
$page = 0;
}
function findSharp($orig, $final) // function from Ryan Rud (http://adryrun.com)
{
$final = $final * (750.0 / $orig);
$a = 52;
$b = -0.27810650887573124;
$c = .00047337278106508946;
$result = $a + $b * $final + $c * $final * $final;
return max(round($result), 0);
} // findSharp()
/** Apply a PNG overlay */
function gd_apply_overlay($background, $brand, $amount)
{
if (!empty($_GET['description']))
{
$width = 600; $height = 600;
}
else
{
$width = 600; $height = 600;
}
// Get the size and MIME type of the requested image
/*$size = GetImageSize($docRoot . $image);
$mime = $size['mime'];*/
$photoFrame2 = imagecreatetruecolor($width, $height);
imagealphablending($photoFrame2, false);
imagesavealpha($photoFrame2, true);
$trans_colour = imagecolorallocatealpha($photoFrame2, 0, 0, 0, 127);
imagefilledrectangle($photoFrame2, 0, 0, $width, $height, $trans_colour);
$mag = $brand;
$brand = 'filters/effects2/' . $brand . '.png';
$photo2 = imagecreatefrompng($brand);
include("mags/switch.php");
imagecopyresampled($photoFrame2, $photo2, 0, 0, 0,0, $width, $height, $width, $height);
$photoFrame = imagecreatetruecolor($width, $height);
imagecopy($photoFrame, $background, 0, 0, 0, 0, $width, $height);
imagecopy($photoFrame, $photoFrame2, 0, 0, 0, 0, $width, $height);
imagecopymerge($background, $photoFrame, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($photoFrame);
return $background;
}
/** Apply a PNG overlay */
function user()
{
$nani = $_SESSION["user"];
if(!empty($_GET['nani']))
{
$nani = $_GET['nani'];
}
$rs_settings = mysqli_query($link,"select * from users where catalogid=$nani");
while ($row_settings = mysql_fetch_array($rs_settings)) {
return $ca = strtolower($row_settings['catalogname']);
} }
function AppOwner()
{
$AppNo = $_GET['AppNo'];
$rs_settings = mysqli_query($link,"select * from users where catalogid=$AppNo");
while ($row_settings = mysql_fetch_array($rs_settings)) {
return $cat = strtolower($row_settings['catalogname']);
} }
if ($_GET['gratitude'] == "start") {
$uploaddir = 'v/uploads/gthumbs/';
$image ="images/gratitude.jpg";
$date = md5(date('D, d M Y H:i:s'));
$upload = $date.basename($image);
$uploadfile = $uploaddir .$upload;
copy($image,$uploadfile);
$user = user();
$owner = AppOwner();
$AppNo = $_GET['AppNo'];
$nani = $_GET['nani'];
$db->addgratitude($user,$owner,$AppNo,$nani,$upload);
$pic = $upload;
}
if ($_GET['gratitude'] == "tshirt") {
$uploaddir = 'v/uploads/gthumbs/';
$image ="images/tshirt.jpg";
$date = md5(date('D, d M Y H:i:s'));
$upload = $date.basename($image);
$uploadfile = $uploaddir .$upload;
copy($image,$uploadfile);
$user = user();
$owner = AppOwner();
$AppNo = $_GET['AppNo'];
$nani = $_GET['nani'];
$db->addtshirt($user,$owner,$AppNo,$nani,$upload);
$pic = $upload;
}
if ($_GET['gratitude'] == "hbd") {
$uploaddir = 'v/uploads/gthumbs/';
$image ="images/hbd.jpg";
$date = md5(date('D, d M Y H:i:s'));
$upload = $date.basename($image);
$uploadfile = $uploaddir .$upload;
copy($image,$uploadfile);
$user = user();
$owner = AppOwner();
$AppNo = $_GET['AppNo'];
$nani = $_GET['nani'];
$db->addhbd($user,$owner,$AppNo,$nani,$upload);
$pic = $upload;
}
if ($_GET['gratitude'] == "xmas") {
$uploaddir = 'v/uploads/gthumbs/';
$image ="images/xmas.jpg";
$date = md5(date('D, d M Y H:i:s'));
$upload = $date.basename($image);
$uploadfile = $uploaddir .$upload;
copy($image,$uploadfile);
$user = user();
$owner = AppOwner();
$AppNo = $_GET['AppNo'];
$nani = $_GET['nani'];
$db->addxmas($user,$owner,$AppNo,$nani,$upload);
$pic = $upload;
}
if ($_GET['gratitude'] == "shop") {
$imager = $_GET['imager'];;
$uploaddir = 'v/uploads/gthumbs/';
$image ="elements/$imager";
$date = md5(date('D, d M Y H:i:s'));
$upload = $date.basename($image);
$uploadfile = $uploaddir .$upload;
copy($image,$uploadfile);
$user = user();
$owner = AppOwner();
$AppNo = $_GET['AppNo'];
$nani = $_GET['nani'];
$newsid = $_GET['newsid'];
$db->addshop($user,$owner,$AppNo,$nani,$upload,$newsid);
$pic = $upload;
$background = $upload;
}
if ($_GET['gratitude'] == "message") {
$uploaddir = 'v/uploads/gthumbs/';
$image ="images/messagea.jpg";
$date = md5(date('D, d M Y H:i:s'));
$upload = $date.basename($image);
$uploadfile = $uploaddir .$upload;
copy($image,$uploadfile);
$user = user();
$owner = AppOwner();
$AppNo = $_GET['AppNo'];
$nani = $_GET['nani'];
$db->addmessage($user,$owner,$AppNo,$nani,$upload);
$pic = $upload;
}
if (empty($_GET['gratitude']))
{
$pic = $_GET['image'];
}
if ($_GET['message']) {
$uploaddir = 'v/uploads/gthumbs/';
$image ="images/gratitude.jpg";
$date = md5(date('D, d M Y H:i:s'));
$upload = $date.basename($image);
$uploadfile = $uploaddir .$upload;
copy($image,$uploadfile);
$user = user();
$owner = AppOwner();
$AppNo = $_GET['AppNo'];
$nani = $_GET['nani'];
$db->addgratitude($user,$owner,$AppNo,$nani,$upload);
$pic = $upload;
}
/** Check for correct params */
if ($pic && $_GET['filter']) {
if($step=="1")
{
$AppNo = $_GET['AppNo'];
$newsid = $db->base64url_decode($newsid);
$db->mag($pic,$action,$AppNo);
}
if (!empty($_GET['finish']) && $_GET['mag'] =="no" ) {
$AppNo = $_GET['AppNo'];
$db->mag6($pic,$AppNo);
}
if (!empty($_GET['justSave']) && $_GET['mag'] =="naah" ) {
$AppNo = $_GET['AppNo'];
$db->mag6($pic,$AppNo);
exit();
}
if (!empty($_GET['execute']) && $_GET['mag'] =="no" ) {
/*$AppNo = $_GET['AppNo'];
$db->mag6($pic,$AppNo);*/
$AppNo = $_GET['AppNo'];
/*$db->mag6($pic,$AppNo);*/
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
$filter = $_GET['filter'];
$text = $_GET['context'];
$isdisplay = 15;
$nani = $_GET['nani'];
$query = mysqli_query("INSERT INTO `reporta` (message,original, catalogid_fk,catalogid, ip,created,type,isdisplay,yanani,appno,filter) VALUES (N'$text', '$pic', '$nani','$AppNo', '$ip','$time','6','$isdisplay','$nani','$Appno','$filter')") or die(mysql_error());
}
if (!empty($_GET['execute']) && $_GET['mag'] =="yes" ) {
$AppNo = $_GET['AppNo'];
$db->mag2($pic,$AppNo);
}
$mag = $_GET['mag'];
$id = substr($pic, 5, 1);gd_filter_image('v/uploads/gthumbs/' . $pic, $_GET['filter']);
if (isset($pic)) {
}
}
/** Apply and deliver the image and clean up */
function gd_filter_image($image_path, $photoFrame2_name)
{
$photoFrame2 = 'gd_filter_' . $photoFrame2_name;
list($width, $height) = getimagesize($image_path);
$size = GetImageSize($image_path);
$mime = $size['mime'];
if (substr($mime, 0, 6) != 'image/')
{
header("Location: ./index.php?mode=photos&msg=requested file is not an accepted type");
exit();
}
$background = imagecreatetruecolor($width, $height);
// Set up the appropriate image handling functions based on the original image's mime type
switch ($size['mime'])
{
case 'image/gif':
// We will be converting GIFs to PNGs to avoid transparency issues when resizing GIFs
// This is maybe not the ideal solution, but IE6 can suck it
$creationFunction = 'ImageCreateFromGif';
$outputFunction = 'ImagePng';
$mime = 'image/png'; // We need to convert GIFs to PNGs
$quality = round(10 - ($quality / 10));
/*if (empty($_GET['execute'])) {$quality = round(10 - (35 / 10));}*/
// We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'image/png':
$quality=100;
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
/*if (empty($_GET['execute'])) {$quality = round(10 - (35 / 10));}*/
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$quality=100;
/* if (empty($_GET['execute'])) {$quality = 35;}*/
break;
}
$src = $creationFunction($image_path);
if (in_array($size['mime'], array('image/gif', 'image/png')))
{
if (!$color)
{
// If this is a GIF or a PNG, we need to set up transparency
imagealphablending($background, false);
imagesavealpha($background, true);
}
else
{
// Fill the background with the specified color for matting purposes
if ($color[0] == '#')
$color = substr($color, 1);
$background = FALSE;
if (strlen($color) == 6)
$background = imagecolorallocate($background, hexdec($color[0].$color[1]), hexdec($color[2].$color[3]), hexdec($color[4].$color[5]));
else if (strlen($color) == 3)
$background = imagecolorallocate($background, hexdec($color[0].$color[0]), hexdec($color[1].$color[1]), hexdec($color[2].$color[2]));
if ($background)
imagefill($background, 0, 0, $background);
}
}
$x = $_GET['x'];
$y = $_GET['y'];
if(($x !=0) ||($y !=0)) {
$x = $_GET['x'];
$y = $_GET['y'];
}
else
{
$action = $_GET['filter'];
if($action=="x1"){ $y = -90; $x = -30;}
if($action=="x2"){ $y = -90; $x = -30;}
if($action=="x3"){ $y = -90; $x = -40;}
if($action=="x4"){ $y = -90; $x = -40;}
if($action=="x6"){ $y = -100; $x = -40;}
if($action=="newyear"){ $y = -100; $x = -40;}
if($action=="framemeb"){ $y = -50; $x = -50;}
if($action=="pooh"){ $y = -40; $x = -50;}
if($action=="framed"){ $y = -120; $x = -20;}
if($action=="framec"){ $y = -40; $x = -20;}
if($action=="frameb"){ $y = -50; $x = -20;}
if($action=="framef"){ $y = -30; $x = -20;}
if($action=="merry"){ $y = -30; $x = -20;}
if($action=="colurful"){ $y = -30; $x = -20;}
if($action=="wedding"){ $y = -20; $x = -10;}
if($action=="elegance"){ $y = -30; $x = -20;}
if (empty($y)) { $y = 0; } else { $y = $y; }
if (empty($x)) { $x = 0; } else { $x = $x; }
}
imagecopyresampled($background, $src, 0, 0, $x, $y, $width, $height, $width, $height);
$background = $photoFrame2($background);
if (!empty($_GET['execute'])) {
/*$outputFunction($background, $image_path, $quality);*/
$newPath = str_replace("gthumbs","raw",$image_path);
$outputFunction($background, $newPath, $quality);
}
header("Content-type: $mime");
$outputFunction($background, null, $quality);
imagedestroy($background);
imagedestroy($src);
}
/** Apply 'Contrast' preset */
function gd_filter_contrast($background)
{
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
return $background;
}
function gd_filter_none($background)
{
return $background;
}
function gd_filter_painting($background)
{
imagefilter($background, IMG_FILTER_BRIGHTNESS, 5);
imagefilter($background, IMG_FILTER_CONTRAST,-20);
/* $background = gd_apply_overlay($background, 'border', 100);*/
$gaussian = array(
array(-2.0, -1.0, 0.0),
array(-1.0, 1.0, 1.0),
array(0.0, 1.0, 2.0)
);
imageconvolution($background, $gaussian, 1, 5);
$background = gd_apply_overlay($background, 'canvas', 100);
$background = gd_apply_overlay($background, 'x7', 100);
return $background;
}
/** Apply 'Cartoonise' preset */
function gd_filter_comic($background)
{
/*
*/
imagefilter($background, IMG_FILTER_MEAN_REMOVAL);
imagefilter($background, IMG_FILTER_GRAYSCALE);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 15);
imagefilter($background, IMG_FILTER_CONTRAST, -40);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($background, IMG_FILTER_SELECTIVE_BLUR);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 30);
imagefilter($background, IMG_FILTER_CONTRAST, -100);
$matrix = array(
array(-1, -2, -1),
array(-2, 16, -2),
array(-1, -2, -1),
);
$divisor = array_sum(array_map('array_sum', $matrix));
$offset =0;
imageconvolution($background, $matrix, $divisor, $offset);
imagefilter($background, IMG_FILTER_SMOOTH, 2);
$background = gd_apply_overlay($background, 'canvas', 100);
return $background;
}
/** Apply 'Cartoonise' preset */
function gd_filter_cartoon($background)
{
/*
*/
imagefilter($background, IMG_FILTER_EDGEDETECT);
imagefilter($background, IMG_FILTER_GRAYSCALE);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($background, IMG_FILTER_CONTRAST, -40);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($background, IMG_FILTER_SELECTIVE_BLUR);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 100);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 5);
$background = gd_apply_overlay($background, 'canvas', 100);
$matrix = array(
array(-1, -1, -1),
array(-1, 16, -1),
array(-1, -1, -1),
);
$divisor = array_sum(array_map('array_sum', $matrix));
$offset = 0;
imageconvolution($background, $matrix, $divisor, $offset);
imagefilter($background, IMG_FILTER_SMOOTH, 3);
return $background;
}
function gd_filter_coke($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke', 100);
return $background;}
function gd_filter_coke1($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke1', 100);
return $background;}
function gd_filter_coke2($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke2', 100);
return $background;}
function gd_filter_coke3($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke3', 100);
return $background;}
function gd_filter_coke4($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke4', 100);
return $background;}
function gd_filter_coke5($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke5', 100);
return $background;}
function gd_filter_coke6($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke6', 100);
return $background;}
function gd_filter_coke7($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke7', 100);
return $background;}
function gd_filter_coke8($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke8', 100);
return $background;}
function gd_filter_coke9($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke9', 100);
return $background;}
function gd_filter_coke10($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke10', 100);
return $background;}
function gd_filter_coke11($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke11', 100);
return $background;}
function gd_filter_coke12($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke12', 70);
return $background;}
function gd_filter_coke13($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke13', 100);
return $background;}
function gd_filter_coke14($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke14', 100);
return $background;}
function gd_filter_coke15($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke15', 100);
return $background;}
function gd_filter_coke16($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke16', 100);
return $background;}
function gd_filter_coke17($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke17', 100);
return $background;}
function gd_filter_coke18($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke18', 100);
return $background;}
function gd_filter_coke19($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke19', 100);
return $background;}
function gd_filter_coke20($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke20', 100);
return $background;}
function gd_filter_coke21($background) {
imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);
$background = gd_apply_overlay($background, 'coke21', 100);
return $background;}
/** Apply 'Vintage 600' preset */
function gd_filter_vintage($background)
{
/*imagefilter($background, IMG_FILTER_BRIGHTNESS, 15);
imagefilter($background, IMG_FILTER_CONTRAST, -25);
imagefilter($background, IMG_FILTER_COLORIZE, -10, -5, -15);
imagefilter($background, IMG_FILTER_SMOOTH, 7);*/
imagefilter($background, IMG_FILTER_GRAYSCALE);
imagefilter($background, IMG_FILTER_BRIGHTNESS, -15);
imagefilter($background, IMG_FILTER_CONTRAST, -15);
$background = gd_apply_overlay($background, 'vintage', 100);
return $background;
}
/** Apply 'Monopin' preset */
function gd_filter_oldschool($background)
{
imagefilter($background, IMG_FILTER_GRAYSCALE);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 5);
imagefilter($background, IMG_FILTER_CONTRAST, -15);
$background = gd_apply_overlay($background, 'vignette', 100);
return $background;
}