( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
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;
}
include("includes/limittext.php");
include('Connections/videoondemand.php');
require("DbSql2.inc.php");
require("NewsSql2.inc.php");
$db = new NewsSQL();
function user()
{
$nani = $_SESSION["user"];
$rs_settings = mysqli_query($link,"select * from users where catalogid=$nani");
while ($row_settings = mysql_fetch_array($rs_settings)) {
return $ca = $row_settings['catalogname'];
} }
/** Check for correct params */
if ($_GET['image'] && $_GET['filter']) {
if($step=="1")
{
$newsid = $db->base64url_decode($newsid);
$db->mag($_GET['image']);
}
if($step=="2")
{
$newsid = $db->base64url_decode($newsid);
$db->mag2($_GET['image']);
}
$mag = $_GET['mag'];
$id = substr($_GET['image'], 5, 1);
if (isset($_GET['image'])) {
gd_filter_image('v/uploads/raw/' . $_GET['image'], $_GET['filter']);
}
}
/** Apply and deliver the image and clean up */
function gd_filter_image($image_path, $photoFrame2_name)
{
$photoFrame2 = 'gd_filter_' . $photoFrame2_name;
if (function_exists($photoFrame2)) {
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)); // 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
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$quality=100;
break;
}
$src = $creationFunction($image_path);
if (in_array($size['mime'], array('image/gif', 'image/png')))
{
/* exit("ikooooooooooooooooooo");*/
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);
}
}
imagecopyresampled($background, $src, 0, 0, 0, 0, $width, $height, $width, $height);
if (!empty($_GET['execute'])) {
imagejpeg($background,$image_path,100);
}
$background = $photoFrame2($background);
/*$background = gd_filter_fake($background); */
imagejpeg($background, $image_path, 100);
header('Content-type: image/jpeg');
imagejpeg($background, null, 100);
imagedestroy($background);
imagedestroy($src);
}
}
function gd_filter_pink($background)
{
$background = gd_apply_overlay($background, 'pink', 100);
return $background;
}
function gd_filter_red($background)
{
$background = gd_apply_overlay($background, 'red', 100);
return $background;
}
function gd_filter_lady($background)
{
$background = gd_apply_overlay($background, 'lady', 100);
return $background;
}
function gd_filter_red2($background)
{
$background = gd_apply_overlay($background, 'red2', 100);
return $background;
}
function gd_filter_red3($background)
{
$background = gd_apply_overlay($background, 'red3', 100);
return $background;
}
/** Apply 'Cartoonise' preset */
function gd_filter_abstract($background)
{
/*
*/
imagefilter($background, IMG_FILTER_MEAN_REMOVAL);
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, -100);
imagefilter($background, IMG_FILTER_CONTRAST, -100);
imagefilter($background, IMG_FILTER_SMOOTH, 3);
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;
}
/** Apply 'Red' preset */
function gd_filter_yellow($background)
{
imagefilter($background, IMG_FILTER_COLORIZE ,0, -155, -255);
return $background;
}
/** Apply 'Purple' preset */
function gd_filter_purple($background)
{
imagefilter($background, IMG_FILTER_COLORIZE, 0, 0, 100);
return $background;
}
/** Apply 'Contrast' preset */
function gd_filter_contrast($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -40);
return $background;
}
function gd_filter_fake($background){
$background = gd_apply_overlay($background, 'fake', 100);
return $background;
}
function gd_filter_mc($background){
$background = gd_apply_overlay($background, 'mc', 100);
return $background;
}
function gd_filter_ms($background){
$background = gd_apply_overlay($background, 'ms', 100);
return $background;
}
function gd_filter_si($background)
{
$background = gd_apply_overlay($background, 'si', 100);
return $background;
}
function gd_filter_teenvogue($background)
{
$background = gd_apply_overlay($background, 'teenvogue', 100);
return $background;
}
function gd_filter_wired($background)
{
$background = gd_apply_overlay($background, 'wired', 100);
return $background;
}
function gd_filter_vibe($background)
{
$background = gd_apply_overlay($background, 'vibe', 100);
return $background;
}
function gd_filter_people($background)
{
$background = gd_apply_overlay($background, 'people', 100);
return $background;
}
function gd_filter_allure($background)
{
$background = gd_apply_overlay($background, 'allure', 100);
return $background;
}
function gd_filter_bazaar($background)
{
$background = gd_apply_overlay($background, 'bazaar', 100);
return $background;
}
function gd_filter_vogue($background)
{
$background = gd_apply_overlay($background, 'vogue', 100);
return $background;
}
function gd_filter_glamour($background)
{
$background = gd_apply_overlay($background, 'glamour', 100);
return $background;
}
function gd_filter_fortune($background)
{
$background = gd_apply_overlay($background, 'fortune', 100);
return $background;
}
function gd_filter_elle($background)
{
$background = gd_apply_overlay($background, 'elle', 100);
return $background;
}
function gd_filter_cosmopolitan($background)
{
$background = gd_apply_overlay($background, 'cosmopolitan', 100);
return $background;
}
function gd_filter_bloomberg($background)
{
$background = gd_apply_overlay($background, 'bloomberg', 100);
return $background;
}
function gd_filter_economist($background)
{
$background = gd_apply_overlay($background, 'economist', 100);
return $background;
}
function gd_filter_time($background)
{
$background = gd_apply_overlay($background, 'time', 100);
return $background;
}
/** Apply 'Blue Velvet' preset */
function gd_filter_velvet($background)
{
imagefilter($background, IMG_FILTER_BRIGHTNESS, 5);
imagefilter($background, IMG_FILTER_CONTRAST, -25);
imagefilter($background, IMG_FILTER_COLORIZE, -10, 45, 65);
/* $background = gd_apply_overlay($background, 'noise', 45);
$background = gd_apply_overlay($background, 'vignette', 100);*/
return $background;
}
/** Apply 'Chrome' preset */
function gd_filter_chrome($background)
{
imagefilter($background, IMG_FILTER_BRIGHTNESS, 15);
imagefilter($background, IMG_FILTER_CONTRAST, -15);
imagefilter($background, IMG_FILTER_COLORIZE, -5, -10, -15);
$background = gd_apply_overlay($background, 'noise', 45);
$background = gd_apply_overlay($background, 'vignette', 100);
return $background;
}
/** Apply 'Lift' preset */
function gd_filter_lift($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -25);
/*imagefilter($background, IMG_FILTER_COLORIZE, 75, 0, 25);*/
$background = gd_apply_overlay($background, 'emulsion', 100);
return $background;
}
/** Apply 'Canvas' preset */
function gd_filter_canvas($background)
{
imagefilter($background, IMG_FILTER_BRIGHTNESS, 25);
imagefilter($background, IMG_FILTER_CONTRAST, -25);
imagefilter($background, IMG_FILTER_COLORIZE, 50, 25, -35);
$background = gd_apply_overlay($background, 'canvas', 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);
$background = gd_apply_overlay($background, 'scratch', 7);
return $background;
}
/** Apply 'Monopin' preset */
function gd_filter_monopin($background)
{
imagefilter($background, IMG_FILTER_GRAYSCALE);
imagefilter($background, IMG_FILTER_BRIGHTNESS, -15);
imagefilter($background, IMG_FILTER_CONTRAST, -15);
$background = gd_apply_overlay($background, 'vignette', 100);
return $background;
}
/** Apply 'Antique' preset */
function gd_filter_antique($background)
{
imagefilter($background, IMG_FILTER_BRIGHTNESS, 0);
imagefilter($background, IMG_FILTER_CONTRAST, -30);
imagefilter($background, IMG_FILTER_COLORIZE, 75, 50, 25);
return $background;
}
/** Apply 'Black & White' preset */
function gd_filter_blackwhite($background)
{
imagefilter($background, IMG_FILTER_GRAYSCALE);
imagefilter($background, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($background, IMG_FILTER_CONTRAST, -20);
return $background;
}
/** Apply 'Colour Boost' preset */
function gd_filter_boost($background)
{
imagefilter($background, IMG_FILTER_CONTRAST, -35);
imagefilter($background, IMG_FILTER_COLORIZE, 25, 25, 25);
return $background;
}
/** Apply 'Sepia' preset */
function gd_filter_sepia($background)
{
imagefilter($background, IMG_FILTER_GRAYSCALE);
imagefilter($background, IMG_FILTER_BRIGHTNESS, -10);
imagefilter($background, IMG_FILTER_CONTRAST, -20);
imagefilter($background, IMG_FILTER_COLORIZE, 60, 30, -15);
return $background;
}
/** Apply 'Partial blur' preset */
function gd_filter_blur($background)
{
imagefilter($background, IMG_FILTER_SELECTIVE_BLUR);
imagefilter($background, IMG_FILTER_GAUSSIAN_BLUR);
imagefilter($background, IMG_FILTER_CONTRAST, -15);
imagefilter($background, IMG_FILTER_SMOOTH, -2);
return $background;
}
/** Apply a PNG overlay */
function gd_apply_overlay($background, $brand, $amount)
{
$width = 500;
$height = 666;
$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 */