( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ HEX
HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux mail.thebrand.ai 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: www-data (33)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/processEngine.php
<?php
include("includes/limittext.php");
include('Connections/videoondemand.php');  
require("DbSql.inc.php");
require("NewsSql.inc.php");
require_once('gd2imaging.php');

$db = new NewsSQL($DBName); 
error_reporting(1);
/*set_time_limit(0) ;*/
function filter($arr) {
    global $link;
return array_map(array($link, 'real_escape_string'), $arr);
}
/*
https://maps.googleapis.com/maps/api/staticmap?center=NAKURU&zoom=13&size=600x600&maptype=hybrid
http://localhost/mimix/brandX.php?AppNo=254722407698&mag=yes&gratitude=posted&filter=mood&nani=254722407699&cl=rightnow&pic=0fbfb36bad36a37e22955b2081eac3036SAMCOM2011DAY3-051.jpg*/
$_GET = filter($_GET);
$_POST = filter($_POST); 
$mode=$_GET["mode"];

include("protect.php");
if (empty($page)) {
	$page = 0;
}




 
if ($_GET["default"]=="yes") {
	$msg_id =  $_GET["msg_id"] ;
  
/*exit($msg_id);*/
$db->def($msg_id);
}




/*$url = "https://maps.googleapis.com/maps/api/staticmap?center=NAKURU&zoom=13&size=600x600&maptype=hybrid";
$resource = imagecreatefromstring(file_get_contents($url));
$img = imagecreatetruecolor($w*$size,$h*$size);*/
if (!empty($_GET['updateEffect'])) { 
 $pic = $_GET["pic"];
$catalogid = $_GET["nani"];

$cl = $_GET["newcl"];  
		if (!empty($_GET['fx'])) { 
		 $fx = $_GET["fx"];
 		}
		else
		{
			$fx = 0;
		}
$db -> updateEffect($catalogid,$pic,$cl,$fx);


}

include("includes/processFunctions.php");




if ($_GET["exportGif"]=="yes") {
	$catalogid =  $_GET["catalogid"] ;
	
	$theme_id = $_GET['theme_id'];	
	

							 
							  
  $nani = $_GET['catalogid'];	
	
	
/*  $myLayers = $db->getmygifs($nani);
 while ( list($key,$val)=each($myLayers) ) {
			    
$catalogid = $val["catalogid"];
$themeid = $val["themeid"];

if(empty($val["picture"])){exit(0);};
 

}
 */
 
   
include "newdatasets/GIFEncoder.class.php";  


/*exit('<a class="icon-ok" > </a> Animation Saved Successfully!');*/


  $username      = username();
 
/*
	Build a frames array from sources...
*/
if ( $dh = opendir ( "v/uploads/gif/" ) ) {
	while ( false !== ( $dat = readdir ( $dh ) ) ) {
		if ( $dat != "." && $dat != ".." ) {
			$frames [ ] = "v/uploads/gif/$username$dat";
			$framed [ ] = 200;
		}
	}
	closedir ( $dh );
}
/*
		GIFEncoder constructor:
        =======================

		image_stream = new GIFEncoder	(
							URL or Binary data	'Sources'
							int					'Delay times'
							int					'Animation loops'
							int					'Disposal'
							int					'Transparent red, green, blue colors'
							int					'Source type'
						);
*/


/*print_r($frames);*/
/* $frames = "[0] => v/uploads/gif/52989366512107383b05920959a25523c5769d5804642985170eda4198b8f46283cac263abg222.gif
    [1] => v/uploads/gif/52989366512107383b05920959a25523c5769d5804642985170eda4198b8f46283cac263abg240.gif
    [2] => v/uploads/gif/52989366512107383b05920959a25523c5769d5804642985170eda4198b8f46283cac263abg252.gif
    [3] => v/uploads/gif/593858508387044252989366512107383b05920959a25523c5769d5804642985170eda4198b8f46283cac263abg211.gif
    [4] => v/uploads/gif/593858508387044252989366512107383b05920959a25523c5769d5804642985170eda4198b8f46283cac263abg226.gif
    [5] => v/uploads/gif/593858508387044252989366512107383b05920959a25523c5769d5804642985170eda4198b8f46283cac263abg237.gif
    [6] => v/uploads/gif/593858508387044252989366512107383b05920959a25523c5769d5804642985170eda4198b8f46283cac263abg247.gif
    [7] => v/uploads/gif/593858508387044252989366512107383b05920959a25523c5769d5804642985170eda4198b8f46283cac263abg290.gif
    [8] => v/uploads/gif/741590718960503487117513593858508387044252989366512107383b05920959a25523c5769d5804642985170eda4198b8f46283cac263abg237.gif
    [9] => v/uploads/gif/741590718960503487117513593858508387044252989366512107383b05920959a25523c5769d5804642985170eda4198b8f46283cac263abg293.gif
    [10] => v/uploads/gif/8960503487117513593858508387044252989366512107383b05920959a25523c5769d5804642985170eda4198b8f46283cac263abg220.gif
    [11] => v/uploads/gif/8960503487117513593858508387044252989366512107383b05920959a25523c5769d5804642985170eda4198b8f46283cac263abg263.gif
    [12] => v/uploads/gif/8960503487117513593858508387044252989366512107383b05920959a25523c5769d5804642985170eda4198b8f46283cac263abg271.gif";*/
$gif = new GIFEncoder	(
							$frames,
							$framed,
							0,
							2,
							0, 0, 1,
							"url"
		);
/*
		Possibles outputs:
		==================

        Output as GIF for browsers :
        	- Header ( 'Content-type:image/gif' );
        Output as GIF for browsers with filename:
        	- Header ( 'Content-disposition:Attachment;filename=myanimation.gif');
        Output as file to store into a specified file:
        	- FWrite ( FOpen ( "myanimation.gif", "wb" ), $gif->GetAnimation ( ) );
*/
$random = md5(rand(11,99));
FWrite ( FOpen ( "v/uploads/raw/anim$username$random.gif", "wb" ), $gif->GetAnimation ( ) );

  
  $image_path = basename("anim$username$random.gif");
  
  
$owner     = AppOwner();
$AppNo = mysqli_real_escape_string($link,$_GET['AppNo']);
$nani = mysqli_real_escape_string($link,$_GET['catalogid']);
$text = "Animation";
$text = str_replace("\n" , ' ',$text);
$text = str_replace("\r" , ' ',$text);
$uploads="";
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
 $isdisplay = 15; 
 $image_path = basename($image_path);
	/*	exit("INSERT INTO `reporta` (message,original, catalogid_fk,catalogid, ip,created,type,isdisplay,appno,filter) VALUES (N'$text', '$image_path', '$nani','$AppNo', '$ip','$time',6,'$isdisplay','$appno','mood')");*/
 $query = mysqli_query("INSERT INTO `reporta` (message,original, catalogid_fk,catalogid, ip,created,type,isdisplay,appno,filter) VALUES (N'$text', '$image_path', '$nani','$AppNo', '$ip','$time',6,'$isdisplay','$appno','mood')") or die(mysql_error());	
 
 
 
 $rs_settings = mysqli_query($link,"select * from elements where catalogid=$nani");	
	$num = mysql_num_rows($rs_settings);
 
 
								 while ($row_settings = mysql_fetch_array($rs_settings)) {
								 
							  $picture = "v/uploads/gif/".$row_settings['picture'] ;
							 unlink($picture);
							
							  
							 }	
							 
/*Header ( 'Content-type:image/gif' );
echo	$gif->GetAnimation ( );
*/

 $rs_settings = mysqli_query($link,"delete  from elements where catalogid=$nani");
 
 exit("v/uploads/raw/anim$username$random.gif");
}

/** Apply and deliver the image and clean up */
function gd_filter_image($image_path, $photoFrame2_name)
{


if(!empty($_GET['quality'])){ $quality=$_GET['quality']; } else {$quality=100;}
 $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: ./indexAlone.php?mode=startags&msg=requested file is not an accepted type");
	exit();
	} 
   	
	
	$brand_width = $width;   
	$brand_height = $height; 
	
	
	if(!empty($_GET['width'])){
		$newWidth= $_GET['width']; 
	$brand_width = $newWidth;   
	$brand_height = $newWidth; 
	$width = $newWidth;   
	$height = $newWidth;
	$quality=40; }

	
	 					// 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
						if (!empty($_GET['execute'])) {$quality = 100;}
						$creationFunction	= 'ImageCreateFromGif';
						$outputFunction		= 'ImagePng';
						$mime				= 'image/png'; // We need to convert GIFs to PNGs
						$quality			= round(10 - ($quality / 10));
						$qualityGif			= 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':
						if (!empty($_GET['execute'])) {$quality = 100;}
					
						$creationFunction	= 'ImageCreateFromPng';
						$outputFunction		= 'ImagePng';
						$quality			= round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
				 
					break;
					
					default:
						if (!empty($_GET['execute'])) {$quality = 100;}
						$creationFunction	= 'ImageCreateFromJpeg';
						$outputFunction	 	= 'ImageJpeg';
						 
					 
					
					break;
				}

  
  
$src = $creationFunction($image_path);
$background = imagecreatetruecolor($width, $height);   

 



$dest_x = 0;   

$dest_y = 0;   

imagecopy($background, $src, $dest_x, $dest_y, 0, 0, $brand_width, $brand_height); 
  
/*$fontZ = 'assets/fonts/HelveticaNeueLTStd-Ex.otf';  
$font_color2 = imagecolorallocate($background,  0, 0, 0);    
$slug      = "thebrand.co.ke/";
imagettftext($background,20, 0, 20, 570, $font_color2, $fontZ, $slug); */
$background = $photoFrame2($background);

	
/*	if($_GET['publicExecute']==1)
 {
	 
	 if(empty($_GET['theme_id'])){}
 
	exit($image_path);
 
	 $outputFunction($background, $image_path, $quality);
	 
	 exit();
	
	} 
	 */
	 
	 
	if($_GET['display']==1) {
	
 
	 
	 	header("Content-type: $mime");
	$outputFunction($background, null, $quality);
		 
		imagedestroy($background);
		imagedestroy($src);
	 exit();
	
	} 
	
			if($_GET['saveGifPoster']==1) {
	$random = rand(11,99);
	$gifUser = username();
 $image_path = str_replace(".jpg",".gif",$image_path);
 $image_path = str_replace("gthumbs","gif",$image_path);
 $image_path = str_replace(".gif","$random.gif",$image_path);
  $image_path = str_replace("v/uploads/gif/","v/uploads/gif/$gifUser",$image_path);
 $image_pathX = str_replace("v/uploads/gif/","",$image_path);
  $theme_id = $_GET['theme_id'];	 
  $nani = $_GET['nani'];	
  $imageX = basename($image_path);
				 $query = mysqli_query("INSERT INTO `elements` (picture,themeid, catalogid) VALUES ('$imageX', '$theme_id', '$nani')") or die(mysql_error());	
					 
	 imagegif($background, $image_path, $qualityGif);
	 exit();
	
	}

		if($_GET['saveThemePoster']==1) {
	
 $image_path = str_replace("gthumbs","gallery",$image_path);
 $image_pathX = str_replace("v/uploads/gallery/","",$image_path);
  $theme_id = $_GET['theme_id'];	 
  $nani = $_GET['nani'];	
					 $query = mysqli_query("UPDATE profilepicture SET poster='$image_pathX' where catalogid='$nani' and  id='$theme_id'") or die(mysql_error());
					 
	 $outputFunction($background, $image_path, $quality);
	 exit();
	
	}



		if($_GET['publicExecute']==1) {
	$image_path = str_replace("gthumbs","raw",$image_path);
	$image_path = str_replace("v/uploads/raw/","v/uploads/raw/".rand(11111111,99999999)."",$image_path);
	/*exit($image_path);*/
	 $outputFunction($background, $image_path, $quality);

		
$user      = user();
$owner     = AppOwner();
$AppNo = mysqli_real_escape_string($link,$_GET['AppNo']);
$nani = mysqli_real_escape_string($link,$_GET['nani']);
$text = realText();
$text = str_replace("\n" , ' ',$text);
$text = str_replace("\r" , ' ',$text);
$uploads="";
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
 $isdisplay = 15; 
 $image_path = basename($image_path);
		
 $query = mysqli_query("INSERT INTO `reporta` (message,original, catalogid_fk,catalogid, ip,created,type,isdisplay,appno,filter) VALUES (N'$text', '$image_path', '$nani','$AppNo', '$ip','$time',6,'$isdisplay','$appno','mood')") or die(mysql_error());		
		
		
		
		header("Content-type: $mime");
	$outputFunction($background, null, $quality);
		 
		imagedestroy($background);
		imagedestroy($src);
		
	 exit();
	
	} 
	  
	
	if($_GET['output']==1) {
		
				//if public
/*	if (empty($_GET['theme_id']))
	 { 
	$image_path = str_replace("gthumbs","raw",$image_path);
	 
	}*/
	
	
			$outputFunction($background, $image_path, $quality);
				 $nani = $_GET['nani'];		
				 
	/*			 if(!empty($_GET['newnani']))
	{
	$nani = $_GET['newnani']; 	
	 
	
	}*/
	
	if (!empty($_GET['newPic']))
				{
					$nani = $_GET['nani'];	
					 $query = mysqli_query("UPDATE posts SET id='0' where catalogid='$nani'") or die(mysql_error());
				 
				}

	 showUpdate($nani);
	 exit();
	} 
	
	if($_GET['execute']==1) {
		
		
			/*if public*/
/*	if (empty($_GET['theme_id']))
	 { 
	$image_path = str_replace("gthumbs","raw",$image_path);
	 
	}
	*/
	
	 
	$outputFunction($background, $image_path, $quality);
	} 

	
	 if (!empty($_GET['fire'])) {
	 
	 $imageX = "v/uploads/thumbs/".$_GET['pic'];
	  
	$outputFunction($background, $imageX, $quality);
	}
	
	
	 
	header("Content-type: $mime");
	$outputFunction($background, null, $quality);
		 
		imagedestroy($background);
		imagedestroy($src);
	 	 
}


/** Apply and deliver the image and clean up */
function gd_filter_imageXX($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: ./indexAlone.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'];
} 

	
	
	
	
	
		$zoom = $_GET['zoom'];
		if (empty($zoom)) 
				{ 
				$zoomheight = $height; 
				$zoomwidth = $width; 
				}
		 else {
			  $zoomheight =  $height + $zoom ;
			  $zoomwidth =  $width + $zoom ;
			  
				}
 
		 	
		imagecopyresampled($background, $src, 0, 0, $x, $y, $zoomwidth, $zoomheight, $width, $height);

	$background = $photoFrame2($background);
	
	
		if (!empty($_GET['display'])) {
	
	
	 
	 	header("Content-type: $mime");
	$outputFunction($background, null, $quality);
		 
		imagedestroy($background);
		imagedestroy($src);
	 exit();
	
	} 
	
	
		if ($_GET['output'] == 1) {
			
							//if public
/*	if (empty($_GET['theme_id']))
	 { 
	$image_path = str_replace("gthumbs","raw",$image_path);
 
	}*/


			$outputFunction($background, $image_path, $quality);
				 $nani = $_GET['nani'];		
				 
	/*			 if(!empty($_GET['newnani']))
	{
	$nani = $_GET['newnani']; 	
	 
	
	}*/

	 showUpdate($nani);
	 exit();
	} 
	
	if (!empty($_GET['execute'])) {
	 
	  
	//if public
/*	if (empty($_GET['theme_id']))
	 { 
	$image_path = str_replace("gthumbs","raw",$image_path);
	 
	}*/
	 
	 
	$outputFunction($background, $image_path, $quality);
	} 

	
	 if (!empty($_GET['fire'])) {
	 
	 $imageX = "v/uploads/thumbs/".$_GET['pic'];
	  
	$outputFunction($background, $imageX, $quality);
	}
	
	
	 
	header("Content-type: $mime");
	$outputFunction($background, null, $quality);
		 
		imagedestroy($background);
		imagedestroy($src);
	 
}



function imagettftextSp($background, $size, $angle, $x, $y, $color, $font, $text, $spacing = 0)
{        
    if ($spacing == 0)
    {
       return  imagettftext($background, $size, $angle, $x, $y, $color, $font, $text);
    }
    else
    {
        $temp_x = $x;
        for ($i = 0; $i < strlen($text); $i++)
        {
            return  imagettftext($background, $size, $angle, $temp_x, $y, $color, $font, $text[$i]);
            $temp_x += $spacing + ($bbox[2] - $bbox[0]);
        }
    }
}



function gd_filter_mood($background)
{
	
if (empty($_GET['cl']))  
  { 
  $text = realText() ; 
  } 
  else 
  { 
  $text = dummyText(); 
  } 
$text = stripslashes($text) ; 
$text = nl2br(htmlentities($text, ENT_QUOTES, 'UTF-8'));
$text = preg_replace('/\s+/', ' ', trim($text));
	 
 
preg_match('/\*(\\w+)/',$text,$matches);
 $moods =$matches[1];
 $moods =strtolower($moods); 
   
  switch ($moods) {
	  case  "widgetstats" :
        $background= gd_filter_widget($background);
		return $background;
        break;
		 case  "widgetstats2" :
         $background= gd_filter_widget($background);
		return $background;
        break;
		 case  "widgetstats" :
         $background= gd_filter_widget($background);
		return $background;
        break;
		 case  "widgetblue" :
         $background= gd_filter_widget($background);
		return $background;
        break;
		 case  "widgetred" :
        $background= gd_filter_widget($background);
		return $background;
        break;
		 case  "widgetgreen" :
         $background= gd_filter_widget($background);
		return $background;
        break;
		   case  "classic" :
        $background= gd_filter_classic($background);
		return $background;
        break;
		case  "royal" :
        $background= gd_filter_royal($background);
		return $background;
        break;
		case  "yellow" :
        $background= gd_filter_yellow($background);
		return $background;
        break;
		case  "coolpost" :
		$background= gd_filter_coolpost($background);
		return $background;
		break;
								  case  "glassy" :
								  $background= gd_filter_glassy($background);
								  return $background;
								  break;
								  case  "followme" :
								  $background= gd_filter_followme($background);
								  return $background;
								  break;
								  case  "orange" :
								  $background= gd_filter_orange($background);
								  return $background;
								  break;
		case  "green" :
        $background= gd_filter_yellow($background);
		return $background;
        break;
		  
		 case  "blue" :
        $background= gd_filter_yellow($background);
		return $background;
        break;
		 case  "red" :
        $background= gd_filter_yellow($background);
		return $background;
        break;
			 case  "purple" :
        $background= gd_filter_yellow($background);
		return $background;
        break;
			 case  "pink" :
        $background= gd_filter_yellow($background);
		return $background;
        break;

								  case  "modernyellow" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
								  case  "moderngreen" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
									
								   case  "modernblue" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
								   case  "modernred" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
									   case  "modernpurple" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
									   case  "modernpink" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;



								  case  "shangwemtaani" :
								  $background= gd_filter_safaricom($background);
								  return $background;
								  break;
								  case  "teammafisi" :
								  $background= gd_filter_safaricom($background);
								  return $background;
								  break;
									
								   case  "thisisforyou" :
								  $background= gd_filter_safaricom($background);
								  return $background;
								  break;
								   case  "mpesa" :
								  $background= gd_filter_safaricom($background);
								  return $background;
								  break;
									   case  "suzziemaselfie" :
								  $background= gd_filter_safaricom($background);
								  return $background;
								  break;
									   case  "safaricomcare" :
								  $background= gd_filter_safaricom($background);
								  return $background;
								  break;
								  
								  
								  
								  case  "gaasimple" :
								  $background= gd_filter_gaame($background);
								  return $background;
								  break;
								  case  "gaasocial" :
								  $background= gd_filter_gaame($background);
								  return $background;
								  break;
									
								   case  "gaaclean" :
								  $background= gd_filter_gaame($background);
								  return $background;
								  break;
								   case  "gaacool" :
								  $background= gd_filter_gaame($background);
								  return $background;
								  break;
									   case  "gaa5" :
								  $background= gd_filter_gaame($background);
								  return $background;
								  break;
									   case  "gaa6" :
								  $background= gd_filter_gaame($background);
								  return $background;
								  break;





		 case  "calmgreen" :
        $background= gd_filter_calmgreen($background);
		return $background;
        break;
		 case  "calmyellow" :
        $background= gd_filter_calmgreen($background);
		return $background;
        break;
		 case  "calmblue" :
        $background= gd_filter_calmgreen($background);
		return $background;
        break;
		 case  "calmred" :
        $background= gd_filter_calmgreen($background);
		return $background;
        break;
			 case  "calmpurple" :
        $background= gd_filter_calmgreen($background);
		return $background;
        break;
			 case  "adgreen" :
        $background= gd_filter_adgreen($background);
		return $background;
        break;
		 case  "adyellow" :
        $background= gd_filter_adgreen($background);
		return $background;
        break;
		case  "adwhite" :
        $background= gd_filter_adgreen($background);
		return $background;
        break;
		 case  "adblue" :
        $background= gd_filter_adgreen($background);
		return $background;
        break;
	 
 case  "adred" :
        $background= gd_filter_adgreen($background);
		return $background;
        break;

 case  "impact" :
        $background= gd_filter_impact($background);
		return $background;
        break;
 case  "notice" :
        $background= gd_filter_notice($background);
		return $background;
        break;
 case  "exquisite" :
        $background= gd_filter_exquisite($background);
		return $background;
        break;
 case  "classy" :
        $background= gd_filter_classy($background);
		return $background;
        break;


		 case  "adpink" :
        $background= gd_filter_adgreen($background);
		return $background;
        break;
			 case  "adpurple" :
        $background= gd_filter_adgreen($background);
		return $background;
        break;
         case  "fun" :
        $background= gd_filter_fun($background);
		return $background;
        break;
         case  "bold" :
        $background= gd_filter_bold($background);
		return $background;
        break;
         case  "bfma" :
        $background= gd_filter_bfma($background);
		return $background;
        break;
         case  "machine" :
	 
        $background= gd_filter_machine($background);
		return $background;
        break;
         case  "corporate" :
        $background= gd_filter_corporate($background);
		return $background;
        break;
         case  "corporateblack" :
        $background= gd_filter_corporateblack($background);
		return $background;
        break;
         case  "twisted" :
        $background= gd_filter_twisted($background);
		return $background;
        break;
         case  "whitebrand" :
        $background= gd_filter_whitebrand($background);
		return $background;
        break;
         case  "awesome" :
        $background= gd_filter_awesome($background);
		return $background;
        break; 
		  case  "awesome2" :
        $background= gd_filter_awesome2($background);
		return $background;
        break; 
		  case  "elated" :
        $background= gd_filter_elated($background);
		return $background;
        break; 
		  case  "newsupdate" :
        $background= gd_filter_newsupdate($background);
		return $background;
        break; 
		 case  "professional" :
        $background= gd_filter_professional($background);
		return $background;
        break;	
		
		 case  "clean" :
        $background= gd_filter_clean($background);
		return $background;
        break; 
		 case  "stylish" :
        $background= gd_filter_stylish($background);
		return $background;
        break; 
		case  "tech" :
        $background= gd_filter_tech($background);
		return $background;
        break;
		case  "twitter" :
        $background= gd_filter_twitter($background);
		return $background;
        break;
		case  "awesometweet" :
        $background= gd_filter_awesometweet($background);
		return $background;
        break;
		case  "executive" :
        $background= gd_filter_executive($background);
		return $background;
        break;
		case  "business" :
        $background= gd_filter_business($background);
		return $background;
        break;
		case  "realnews" :
        $background= gd_filter_realnews($background);
		return $background;
        break;
		case  "kbc" :
        $background= gd_filter_kbc($background);
		return $background;
        break;
		
		case  "elegant" :
        $background= gd_filter_elegant($background);
		return $background;
        break;
		case  "brownblog" :
        $background= gd_filter_brownblog($background);
		return $background;
        break;
			case  "blogmain" :
        $background= gd_filter_blogmain($background);
		return $background;
        break;
		case  "purpleblog" :
        $background= gd_filter_purpleblog($background);
		return $background;
        break;
		
		case  "redblog" :
        $background= gd_filter_redblog($background);
		return $background;
        break;
		case  "masters" :
        $background= gd_filter_masters($background);
		return $background;
        break;
		case  "blueblog" :
        $background= gd_filter_blueblog($background);
		return $background;
        break;
		case  "greenblog" :
        $background= gd_filter_greenblog($background);
		return $background;
        break;
		
		case  "boldgreen" :
        $background= gd_filter_boldgreen($background);
		return $background;
        break;
		
		case  "boldblue" :
        $background= gd_filter_boldblue($background);
		return $background;
        break;
		case  "boldorange" :
        $background= gd_filter_boldorange($background);
		return $background;
        break;
		case  "boldred" :
        $background= gd_filter_boldred($background);
		return $background;
        break;
	 case  "powerful" :
        $background= gd_filter_powerful($background);
		return $background;
        break;
			 case  "redglory" :
        $background= gd_filter_redglory($background);
		return $background;
        break;
		
		 case  "now" :
        $background= gd_filter_now($background);
		return $background;
        break;
		 case  "rightnow" :
        $background= gd_filter_rightnow($background);
		return $background;
        break;
		 case  "worldnews" :
        $background= gd_filter_worldnews($background);
		return $background;
        break;
		 case  "reporting" :
        $background= gd_filter_reporting($background);
		return $background;
        break;
		 case  "headlines" :
        $background= gd_filter_headlines($background);
		return $background;
        break;
		case  "boldpurple" :
        $background= gd_filter_boldpurple($background);
		return $background;
        break;
		
		case  "boldblack" :
        $background= gd_filter_boldblack($background);
		return $background;
        break;
		 
		
         case  "colored" :
        $background= gd_filter_colored($background);
		return $background;
        break;
         case  "stickynote" :
        $background= gd_filter_stickynote($background);
		return $background;
        break;
         case  "coffee" :
        $background= gd_filter_coffee($background);
		return $background;
        break;
         case  "highlight" :
        $background= gd_filter_highlight($background);
		return $background;
        break;
         case  "funky" :
        $background= gd_filter_funky($background);
		return $background;
        break;
         case  "coolblue" :
        $background= gd_filter_coolblue($background);
		return $background;
        break;
         case  "punch" :
        $background= gd_filter_punch($background);
		return $background;
        break;
			  case  "trends" :
        $background= gd_filter_trends($background);
		return $background;
        break;
		  case  "smart" :
        $background= gd_filter_smart($background);
		return $background;
        break;
         case  "nairobi" :
        $background= gd_filter_nairobi($background);
		return $background;
        break;
         case  "nairobi2" :
        $background= gd_filter_nairobi2($background);
		return $background;
        break;
		
		   case  "news" :
        $background= gd_filter_news($background);
		return $background;
        break;
        
         case  "breaking" :
        $background= gd_filter_breaking($background);
		return $background;
        break;
								   case  "newsy" :
								  $background= gd_filter_newsy($background);
								  return $background;
								  break;
		case  "happening" :
        $background= gd_filter_happening($background);
		return $background;
        break;
		case  "gaa" :
        $background= gd_filter_gaa($background);
		return $background;
        break;
		case  "sevens" :
        $background= gd_filter_sevens($background);
		return $background;
        break;
		case  "live" :
        $background= gd_filter_live($background);
		return $background;
        break;
		case  "exclusive" :
        $background= gd_filter_exclusive($background);
		return $background;
        break;
		
		case  "comicbook" :
        $background= gd_filter_comicbook($background);
		return $background;
        break;
          case  "newsone" :
        $background= gd_filter_newsone($background);
		return $background;
        break;   
		case  "atnine" :
        $background= gd_filter_atnine($background);
		return $background;
		case  "blank" :
        $background= gd_filter_blank($background);
		return $background;
        break;
        default:
		 
		 
		
           $background= gd_filter_moodswing($background); 
		   
		 
			
			
		   return $background;
	 
    }
	
	
	 
	
	
}

/** Apply 'Contrast' preset */
function gd_filter_contrast($background)
{
	
	imagefilter($background, IMG_FILTER_BRIGHTNESS, 8);
imagefilter($background, IMG_FILTER_CONTRAST, -8);

 


	return $background;
	
}	 
 //posted
 


  function getOpacity($value)
   
   {   
 
switch ($value) {
case "100":
$value ="0";
break;

case "99":
$value ="1";
break;

case "98":
$value ="2";
break;

case "97":
$value ="3";
break;

case "96":
$value ="4";
break;

case "95":
$value ="5";
break;

case "94":
$value ="6";
break;

case "93":
$value ="7";
break;

case "92":
$value ="8";
break;

case "91":
$value ="9";
break;

case "90":
$value ="10";
break;

case "89":
$value ="11";
break;

case "88":
$value ="12";
break;

case "87":
$value ="13";
break;

case "86":
$value ="14";
break;

case "85":
$value ="15";
break;

case "84":
$value ="16";
break;

case "83":
$value ="17";
break;

case "82":
$value ="18";
break;

case "81":
$value ="19";
break;

case "80":
$value ="20";
break;

case "79":
$value ="21";
break;

case "78":
$value ="22";
break;

case "77":
$value ="23";
break;

case "76":
$value ="24";
break;

case "75":
$value ="25";
break;

case "74":
$value ="26";
break;

case "73":
$value ="27";
break;

case "72":
$value ="28";
break;

case "71":
$value ="29";
break;

case "70":
$value ="30";
break;

case "69":
$value ="31";
break;

case "68":
$value ="32";
break;

case "67":
$value ="33";
break;

case "66":
$value ="34";
break;

case "65":
$value ="35";
break;

case "64":
$value ="36";
break;

case "63":
$value ="37";
break;

case "62":
$value ="38";
break;

case "61":
$value ="39";
break;

case "60":
$value ="40";
break;

case "59":
$value ="41";
break;

case "58":
$value ="42";
break;

case "57":
$value ="43";
break;

case "56":
$value ="44";
break;

case "55":
$value ="45";
break;

case "54":
$value ="46";
break;

case "53":
$value ="47";
break;

case "52":
$value ="48";
break;

case "51":
$value ="49";
break;

case "50":
$value ="50";
break;

case "49":
$value ="51";
break;

case "48":
$value ="52";
break;

case "47":
$value ="53";
break;

case "46":
$value ="54";
break;

case "45":
$value ="55";
break;

case "44":
$value ="56";
break;

case "43":
$value ="57";
break;

case "42":
$value ="58";
break;

case "41":
$value ="59";
break;

case "40":
$value ="60";
break;

case "39":
$value ="61";
break;

case "38":
$value ="62";
break;

case "37":
$value ="63";
break;

case "36":
$value ="64";
break;

case "35":
$value ="65";
break;

case "34":
$value ="66";
break;

case "33":
$value ="67";
break;

case "32":
$value ="68";
break;

case "31":
$value ="69";
break;

case "30":
$value ="70";
break;

case "29":
$value ="71";
break;

case "28":
$value ="72";
break;

case "27":
$value ="73";
break;

case "26":
$value ="74";
break;

case "25":
$value ="75";
break;

case "24":
$value ="76";
break;

case "23":
$value ="77";
break;

case "22":
$value ="78";
break;

case "21":
$value ="79";
break;

case "20":
$value ="80";
break;

case "19":
$value ="81";
break;

case "18":
$value ="82";
break;

case "17":
$value ="83";
break;

case "16":
$value ="84";
break;

case "15":
$value ="85";
break;

case "14":
$value ="86";
break;

case "13":
$value ="87";
break;

case "12":
$value ="88";
break;

case "11":
$value ="89";
break;

case "10":
$value ="90";
break;

case "9":
$value ="91";
break;

case "8":
$value ="92";
break;

case "7":
$value ="93";
break;

case "6":
$value ="94";
break;

case "5":
$value ="95";
break;

case "4":
$value ="96";
break;

case "3":
$value ="97";
break;

case "2":
$value ="98";
break;

case "1":
$value ="99";
break;

case "0":
$value ="100";
break;

default:
return false;
}
 
		 
return $value;


   }

  function getEachLayer($themeid,$catalogid,$position)
   
   {   

  $sql = "select * from layerorder where themeid='$themeid' and catalogid='$catalogid' and position='$position'";
$result = mysqli_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);

/*print_r($row);*/
		 
return $row;


   }
  function gd_filter_machine($background)
{ 
 $themeid = $_GET["theme_id"];
$catalogid = $_GET["nani"]; 

if (empty($_GET['cl']))  
  { 
  $text = realText() ; 
  } 
  else 
  { 
  $text = dummyText(); 
  }

$myArray = get_startags($text, $str = 0);
$moodswing2 =$myArray[1];
 $moodswing2 =strtolower($moodswing2);
 

		
$x =$layer1x; $y=$layer1y; $w=$layer1w; $h=$layer1h; 


	
$background = gd_apply_logo($background, $picme, 100,$x,$y,$w,$h);

					 $row = getEachLayer($themeid,$catalogid,0);
					 $str =$row['name'];
					  
					 $x =0; $y=0; $w=600; $h=600; 
					 $str =basename(str_replace("&route=profilePic","",$str));
	
					 $background = gd_apply_logo($background,$str, 100,$x,$y,$w,$h);
					 
					 
			
				
				
			 	if (!empty($_GET['newPic']))
				{
					$newPic = $_GET['newPic'];
					if(!empty($_GET['width'])){
		$newWidth= $_GET['width']; 
	$w = $newWidth;   
	$h = $newWidth;
	  }	
				  $background = gd_apply_newpic($background,$newPic, 100,$x,$y,$w,$h);
				}


		 	if (!empty($_GET['newUrl']))
				{
					$newUrl = $_GET['newUrl'];
					if(!empty($_GET['width'])){
		$newWidth= $_GET['width']; 
	$w = $newWidth;   
	$h = $newWidth;
	  }	
				  $background = gd_apply_url($background,$newUrl, 100,$x,$y,$w,$h);
				}
				
			 	if (!empty($_GET['fx']))
				{
					$moodswing2 = $_GET['fx'];
					
				include("mags/machineEffects.php"); 
				}

			 	 
					
				 
				
				
				
			

			 		
		$layerPosition=1;
		
		 include("includes/machineWrite.php"); 
/*	if (!empty($_GET['fx']))
				{
					$moodswing2 = $_GET['fx'];
					
				include("mags/effects.php"); 
				}
		*/
		
			/*if (!empty($_GET['fx']))
				{
					$moodswing2 = $_GET['fx'];
					
				include("mags/effects.php"); 
				}*/

		$layerPosition=2;			
		 include("includes/machineWrite.php"); 
	
		$layerPosition=3;			
		 include("includes/machineWrite.php"); 

		$layerPosition=4;			
		 include("includes/machineWrite.php"); 
		$layerPosition=5;			
		 include("includes/machineWrite.php"); 
					$layerPosition=6;			
		 include("includes/machineWrite.php"); 
					
					$layerPosition=7;
							
		 include("includes/machineWrite.php"); 
		 
		 			$layerPosition=8;
							
		 include("includes/machineWrite.php"); 
		 			$layerPosition=9;
							
		 include("includes/machineWrite.php"); 
		 			$layerPosition=10;
							
		include("includes/machineWrite.php"); 
						
	
/*$background = gd_apply_overlay($background, 'bfma', 100);*/
  
 

return $background; 
	
	
} 
 
function gd_filter_machine2($background)
{ 
			$themeid = $_GET["theme_id"];
			$catalogid = $_GET["nani"];  
			
		

					 $rs_settings = mysqli_query($link,"select * from layers where themeid='$themeid' and catalogid='$catalogid'  limit 0,1"); 
					 while ($row_settings = mysql_fetch_array($rs_settings)) {
				
					 $y = $row_settings['y'];
			$test = $row_settings["themeid"];
						$catalogid = $row_settings["catalogid"];
					
						$layer0=$row_settings["layer0"];	
						 
						 $layer1=$row_settings["layer1"];
						 $layer2=$row_settings["layer2"];
						$layer3=$row_settings["layer3"]; 
						  $layer4=$row_settings["layer4"];
						    $layer5=$row_settings["layer5"];
						
						$layer0w=$row_settings["layer0w"];
						$layer0h=$row_settings["layer0h"];
						$layer1w=$row_settings["layer1w"];
						$layer1h=$row_settings["layer1h"];
						$layer2w=$row_settings["layer2w"];
						$layer2h=$row_settings["layer2h"];
						$layer3w=$row_settings["layer3w"];
						$layer3h=$row_settings["layer3h"];
						$layer4w=$row_settings["layer4w"];
						$layer4h=$row_settings["layer4h"];
						
						$layer5w=$row_settings["layer5w"];
						$layer5h=$row_settings["layer5h"];
						
						$layer0r=$row_settings["layer0r"];
						$layer1r=$row_settings["layer1r"];
						$layer2r=$row_settings["layer2r"];
						$layer3r=$row_settings["layer3r"];
						 $layer4r=$row_settings["layer4r"];
						$layer5r=$row_settings["layer5r"];
						$layer0opacity =$row_settings["layer0opacity"]; 
						$layer1opacity =$row_settings["layer1opacity"]; 
						$layer2opacity =$row_settings["layer2opacity"]; 
						$layer3opacity =$row_settings["layer3opacity"]; 
						$layer4opacity =$row_settings["layer4opacity"];
						$layer5opacity =$row_settings["layer5opacity"];
						
						$layerbg =$row_settings["layerbg"]; 
						
						$layer0x=$row_settings["layer0x"];
						$layer0y=$row_settings["layer0y"];
						$layer1x=$row_settings["layer1x"];
						$layer1y=$row_settings["layer1y"];
						$layer2x=$row_settings["layer2x"];
						$layer2y=$row_settings["layer2y"];
						$layer3x=$row_settings["layer3x"];
						$layer3y=$row_settings["layer3y"];
						$layer4x=$row_settings["layer4x"];
						$layer4y=$row_settings["layer4y"];
						
						$layer5x=$row_settings["layer5x"];
						$layer5y=$row_settings["layer5y"];
						 
						$layer0fliph=$row_settings["flipH"];
						$layer0flipv=$row_settings["flipV"];
						$layer1fliph=$row_settings["flipH"];
						$layer1flipv=$row_settings["flipV"];
						$layer3fliph=$row_settings["flipH"];
						$layer3flipv=$row_settings["flipV"];
						$layer4fliph=$row_settings["flipH"];
						 $layer4flipv=$row_settings["flipV"];
						 
								
						$rs_settings = mysqli_query($link,"select * from textlayer where themeid='$themeid' and catalogid='$catalogid'  limit 0,1"); 
						while ($row_settings2 = mysql_fetch_array($rs_settings)) 
						{
			
						$fontid = $row_settings2["themeid"];
						$myfont= $row_settings2["layerid"];
						$fontcatalogid= $row_settings2["catalogid"];
						 $themeid= $row_settings2["themeid"];
						$font_Username= $row_settings2["font_Username"];
						$font_Name= $row_settings2["font_Name"];
						$font_Url= $row_settings2["font_Url"];
						$font_Text= $row_settings2["font_Text"];
						$text_w= $row_settings2["text_w"];
						$text_h= $row_settings2["text_h"];
						$text_x= $row_settings2["text_x"];
						$text_y= $row_settings2["text_y"];
						$text_align= $row_settings2["text_align"];
						$text_size= $row_settings2["text_size"];
						$text_color= $row_settings2["text_color"];
						$url_color= $row_settings2["url_color"];
						$name_color= $row_settings2["name_color"];
						$username_color= $row_settings2["username_color"];
						  $url_size= $row_settings2["url_size"];
						$name_size= $row_settings2["name_size"];
						$username_size= $row_settings2["username_size"];
						$text_pad= $row_settings2["text_pad"];
						$text_line_height= $row_settings2["text_line_height"];
						$text= $row_settings2["text"];
			
						}
								
								
								
								 }
					 
		 
 //create text
 
 
 
 
 
		  
			$x =26; $y=304; $w=105; $h=105;
			 
			$background = gd_apply_overlay4($background, basename(str_replace("&route=profilePic","",$layer0)), 100);	
			
				$themeid = $_GET['theme_id'];  
	if(!empty($layer1))
		{ 
		$check = checkType($layer1);
/* exit($check)*/;

					if($check=="theGraphics")
					{ 
					$layer1 = str_replace(".png","",basename($layer1));
					$background = gd_apply_overlay($background, $layer1, 100);
					} 
					if($check=="profilePicture")
					{ 
					 $picme=profilepicture();
					  $x =$layer1x; $y=$layer1y; $w=$layer1w; $h=$layer1h; 
					  $background = gd_apply_logo($background, $picme, 100,$x,$y,$w,$h);
					} 
					if($check=="theUpdate")
					{ 
					  $update = write($layer1,1);
					 $background = gd_apply_graphic_text($background,  $update , 100,200,100);
					} 

					if($check=="theUrl")
					{ 
					 $background = gd_apply_graphic_text($background,  $themeid."Url.png" , 100,200,100);
					} 
					if($check=="theName")
					{ 
					
					
					
					$row = getEachLayer($themeid,$catalogid,1);
					 $str =$row['name'];
					$str = str_replace('?', '&', $str);
					parse_str($str, $output);
 							$route=$output['route'];
							$fontid=$output['fontid'];
							$myfont=$output['myfont'];
							$fontcatalogid=$output['fontcatalogid'];
							$themeid=$output['themeid'];
							$font_Username=$output['font_Username'];
							$font_Name=$output['font_Name'];
							$font_Url=$output['font_Url'];
							$font_Text=$output['font_Text'];
							$text_w=$output['text_w'];
							$text_h=$output['text_h'];
							$text_x=$output['text_x'];
							$text_y=$output['text_y'];
							$text_align=$output['text_align'];
							$text_size=$output['text_size'];
							$text_color=$output['text_color'];
							$url_color=$output['url_color'];
							$name_color=$output['name_color'];
							$username_color=$output['username_color'];
							$url_size=$output['url_size'];
							$name_size=$output['name_size'];
							$username_size=$output['username_size'];
							$text_pad=$output['text_pad'];
							$text_line_height=$output['text_line_height'];
							$text=$output['text'];
							list($fontColorRed, $fontColorBlue, $fontColorGreen) = hex2rgb($name_color);
							$font_color = imagecolorallocate($background,  $fontColorRed, $fontColorBlue, $fontColorGreen); // Create blue color
						 	$font  = 'assets/fonts/$font_Name'; 

					/*exit();*/
					$user      = user(); 
					imagettftext($background,$name_size, 0, 30, 90, $font_color, $font, $user); //Write 



					 /*$background = gd_apply_graphic_text($background,  $themeid."Name.png" , 100,200,100);*/
					} 

					if($check=="theImage")
					{ 
					 $x =$layer1x; $y=$layer1y; $w=$layer1w; $h=$layer1h;
					 $background = gd_apply_logo($background, basename($layer1), 100,$x,$y,$w,$h);
					} 
					if($check=="Uploaded")
					{ 
					 $x =$layer1x; $y=$layer1y; $w=$layer1w; $h=$layer1h;
					 $background = gd_apply_logo($background, basename($layer1), 100,$x,$y,$w,$h);
					} 
 
 
		} 



	if(!empty($layer2))
		{ 
		$check = checkType($layer2);
/* exit($check)*/;

					if($check=="theGraphics")
					{ 
					$layer1 = str_replace(".png","",basename($layer2));
					$background = gd_apply_overlay($background, $layer2, 100);
					} 
					if($check=="profilePicture")
					{ 
					 $picme=profilepicture();
					  $x =$layer1x; $y=$layer1y; $w=$layer1w; $h=$layer1h; 
					  $background = gd_apply_logo($background, $picme, 100,$x,$y,$w,$h);
					} 
					if($check=="theUpdate")
					{ 
					  $update = write($layer2,2);
					 $background = gd_apply_graphic_text($background,  $update , 100,200,100);
					} 

					if($check=="theUrl")
					{ 
					 $background = gd_apply_graphic_text($background,  $themeid."Url.png" , 100,200,100);
					} 
					if($check=="theName")
					{ 
					 $background = gd_apply_graphic_text($background,  $themeid."Name.png" , 100,200,100);
					} 

					if($check=="theImage")
					{ 
					 $x =$layer2x; $y=$layer2y; $w=$layer2w; $h=$layer2h;
					 $background = gd_apply_logo($background, basename($layer2), 100,$x,$y,$w,$h);
					} 

					if($check=="Uploaded")
					{ 
					 $x =$layer2x; $y=$layer2y; $w=$layer2w; $h=$layer2h;
					 $background = gd_apply_logo($background, basename($layer2), 100,$x,$y,$w,$h);
					} 

 
		} 
	if(!empty($layer3))
		{ 
		$check = checkType($layer3);
/* exit($check)*/;

					if($check=="theGraphics")
					{ 
					$layer1 = str_replace(".png","",basename($layer3));
					$background = gd_apply_overlay($background, $layer3, 100);
					} 
					if($check=="profilePicture")
					{ 
					 $picme=profilepicture();
					  $x =$layer3x; $y=$layer3y; $w=$layer3w; $h=$layer3h; 
					  $background = gd_apply_logo($background, $picme, 100,$x,$y,$w,$h);
					} 
					if($check=="theUpdate")
					{ 
					  $update = write($layer3,3);
					 $background = gd_apply_graphic_text($background,  $update , 100,200,100);
					} 

					if($check=="theUrl")
					{ 
					 $background = gd_apply_graphic_text($background,  $themeid."Url.png" , 100,200,100);
					} 
					if($check=="theName")
					{ 
					 $background = gd_apply_graphic_text($background,  $themeid."Name.png" , 100,200,100);
					} 

					if($check=="theImage")
					{ 
					 $x =$layer3x; $y=$layer3y; $w=$layer3w; $h=$layer3h;
					 $background = gd_apply_logo($background, basename($layer3), 100,$x,$y,$w,$h);
					} 

					if($check=="Uploaded")
					{ 
					 $x =$layer3x; $y=$layer3y; $w=$layer3w; $h=$layer3h;
					 $background = gd_apply_logo($background, basename($layer3), 100,$x,$y,$w,$h);
					} 

 
		} 




	if(!empty($layer4))
		{ 
		$check = checkType($layer4);
/* exit($check)*/;

					if($check=="theGraphics")
					{ 
					$layer4 = str_replace(".png","",basename($layer4));
					$background = gd_apply_overlay($background, $layer4, 100);
					} 
					if($check=="profilePicture")
					{ 
					 $picme=profilepicture();
					  $x =$layer4x; $y=$layer4y; $w=$layer4w; $h=$layer4h; 
					  $background = gd_apply_logo($background, $picme, 100,$x,$y,$w,$h);
					} 
					if($check=="theUpdate")
					{ 
					  $update = write($layer4,4);
					 $background = gd_apply_graphic_text($background,  $update , 100,200,100);
					} 

					if($check=="theUrl")
					{ 
					 $background = gd_apply_graphic_text($background,  $themeid."Url.png" , 100,200,100);
					} 
					if($check=="theName")
					{ 
					 $background = gd_apply_graphic_text($background,  $themeid."Name.png" , 100,200,100);
					} 

					if($check=="theImage")
					{ 
					 $x =$layer4x; $y=$layer4y; $w=$layer4w; $h=$layer4h;
					 $background = gd_apply_logo($background, basename($layer4), 100,$x,$y,$w,$h);
					} 


 					if($check=="Uploaded")
					{ 
					 $x =$layer4x; $y=$layer4y; $w=$layer4w; $h=$layer4h;
					 $background = gd_apply_logo($background, basename($layer4), 100,$x,$y,$w,$h);
					} 

		} 

	if(!empty($layer5))
		{ 
		$check = checkType($layer5);
/* exit($check)*/;

					if($check=="theGraphics")
					{ 
					$layer5 = str_replace(".png","",basename($layer5));
					$background = gd_apply_overlay($background, $layer5, 100);
					} 
					if($check=="profilePicture")
					{ 
					 $picme=profilepicture();
					  $x =$layer5x; $y=$layer5y; $w=$layer5w; $h=$layer5h; 
					  $background = gd_apply_logo($background, $picme, 100,$x,$y,$w,$h);
					} 
					if($check=="theUpdate")
					{ 
					  $update = write($layer5,5);
					 $background = gd_apply_graphic_text($background,  $update , 100,200,100);
					} 

					if($check=="theUrl")
					{ 
					 $background = gd_apply_graphic_text($background,  $themeid."Url.png" , 100,200,100);
					} 
					if($check=="theName")
					{ 
					 $background = gd_apply_graphic_text($background,  $themeid."Name.png" , 100,200,100);
					} 

					if($check=="theImage")
					{ 
					 $x =$layer5x; $y=$layer5y; $w=$layer5w; $h=$layer5h;
					 $background = gd_apply_logo($background, basename($layer5), 100,$x,$y,$w,$h);
					} 


 					if($check=="Uploaded")
					{ 
					 $x =$layer5x; $y=$layer5y; $w=800; $h=800;
					 /*exit("monte carlo $x");*/
					 $background = gd_apply_logo($background, basename($layer5), 100,$x,$y,$w,$h);
					} 


		} 

	 
	
		 


return $background; 
	
}
  
  
function imagettfstroketext(&$image, $size, $angle, $x, $y, &$textcolor, &$strokecolor, $fontfile, $text, $px) {
 
    for($c1 = ($x-abs($px)); $c1 <= ($x+abs($px)); $c1++)
        for($c2 = ($y-abs($px)); $c2 <= ($y+abs($px)); $c2++)
            $bg = imagettftext($image, $size, $angle, $c1, $c2, $strokecolor, $fontfile, $text);
 
   return imagettftext($image, $size, $angle, $x, $y, $textcolor, $fontfile, $text);
}
  





 
function gd_filter_default($background)
{ 
 
 
 
 $background = gd_apply_effect($background, 'shadow', 100);
$fontY = 'assets/fonts/TitilliumWeb-Bold_0.ttf'; //font used
$fontX = 'assets/fonts/OpenSans-CondBold_0.ttf'; //font used
$fontZ = 'assets/fonts/TitilliumWeb-Light.ttf'; //font used
$fontW = 'assets/fonts/TitilliumWeb-ExtraLight_0.ttf'; //font used
$font_color = imagecolorallocate($background,   255, 255, 255); // Create blue color 
$font_color2 = imagecolorallocate($background,   255, 255, 255); // Create blue color  
$font_color3 = imagecolorallocate($background,  255, 255,255); // Create blue color  
if (empty($_GET['cl']))  
  { 
  $text = realText() ; 
  } 
  else 
  { 
  $text = dummyText(); 
  } 
preg_match('/\*(\\w+)/',$text,$matches);
$mood ="*".$matches[1];
$text= preg_replace('/\*(\\w+)/', "", $text); 
$text= preg_replace('/\#(\\w+)/', "", $text);
$text= trim($text); 
$text = wordwrap($text,42,"\n");
 
$font_size = 1;
$txt_max_width = intval(0.85*600);

do{
	$font_size++;
	$p = imagettfbbox($font_size,0,$fontX,$text);
	$txt_width = $p[2] - $p[0];
	$txt_height = $p[1] - $p[7];
	
}
while (($txt_width <= $txt_max_width)  &&   ($font_size   <=22)) ;
$y = (600 - $txt_height) / 2;
$x = (600 - $txt_width) / 2;
 
$text = removeslashes($text);
imagettftext($background,$font_size, 0, $x, $y, $font_color3, $fontX, $text); //Write 






$font_size = 1;
$txt_max_width = intval(0.7*250);
$user2      = "*".username(); 
$user3      = user(); 
$slug      = "thebrand.co.ke/".slug();
do{
	$font_size++;
	$p = imagettfbbox($font_size,0,$fontY,$user2);
	$txt_width = $p[2] - $p[0];
	$txt_height = $p[1] - $p[7];
	
}
while (($txt_width <= $txt_max_width) &&   ($font_size   <=25)) ;
$y = (250 - $txt_height) / 2;
$x = (250 - $txt_width) / 2;

imagettftext($background,$font_size, 0, 35, 60, $font_color2, $fontY, $user3); //Write 
imagettftext($background,$font_size-2, 0, 30, 90, $font_color2, $fontZ, $user2); //Write 

/*imagettfstroketext($background, 70, 0, 10, 50, $font_color2, $stroke_color, $fontZ, $user3, 2);*/
$dimensions = imagettfbbox(20, 0, $fontY, $slug);
$textWidth = abs($dimensions[4] - $dimensions[0]);
$x2 = 600 - $textWidth-50; 
imagettftext($background,20, 0, $x2, 570, $font_color2, $fontY, $slug); 
   

 
return $background; 
	
	
}
       
 

 
function get_startags($string, $str = 1) {
 preg_match_all('/\*(\w+)/',$string,$matches);
  $i = 0;
  if ($str) {
   foreach ($matches[1] as $match) {
   $count = count($matches[1]);
   $keywords .= "$match";
    $i++;
    if ($count > $i) $keywords .= ", ";
   }
  } else {
  foreach ($matches[1] as $match) {
  $keyword[] = $match;
  }
  $keywords = $keyword;
 }
return $keywords;
}
function get_spaces($string, $str = 10) {
 preg_match_all('/(\w+)/',$string,$matches);
  $i = 0;
  if ($str) {
   foreach ($matches[1] as $match) {
   $count = count($matches[1]);
   $keywords .= "$match";
    $i++;
    if ($count > $i) $keywords .= ", ";
   }
  } else {
  foreach ($matches[1] as $match) {
  $keyword[] = $match;
  }
  $keywords = $keyword;
 }
return $keywords;
}

  
function gd_filter_followme($background)
{ 
 
  if (empty($_GET['cl']))  
  { 
  $text = realText() ; 
  } 
  else 
  { 
  $text = dummyText(); 
  } 
 $picme=profilepicture();
if(!empty($picme)) 
{
$x =20; $y=20; $w=250; $h=250; 
$background = gd_apply_logo($background, $picme, 100,$x,$y,$w,$h);
}

 
 $background = gd_apply_overlay($background, 'followme', 100);  


$fontX = 'assets/fonts/OpenSans-Light.ttf'; //font used
$fontY = 'assets/fonts/Roboto-Light_2.ttf'; //font used
$fontZ = 'assets/fonts/OpenSans-Bold_0.ttf'; //font used

$fontA = 'assets/fonts/Cabin-Regular_0.otf'; //font used
$fontB = 'assets/fonts/Cabin-Regular_0.otf'; //font used
$fontW = 'assets/fonts/Roboto-Medium_0.ttf'; //font used

$font_color2 = imagecolorallocate($background,   152, 159, 169); // Create blue color  
$font_color3 = imagecolorallocate($background,  214, 215,220); // Create blue color  


 
$text= preg_replace('/\*(\\w+)/', "", $text); 
$text= preg_replace('/\#(\\w+)/', "", $text);
$text= trim($text); 
$text = wordwrap($text,24,"\n");
 
$font_size = 1;
$txt_max_width = intval(0.7*600);

do{
	$font_size++;
	$p = imagettfbbox($font_size,0,$fontZ,$text);
	$txt_width = $p[2] - $p[0];
	$txt_height = $p[1] - $p[7];
	
}
while (($txt_width <= $txt_max_width)  &&   ($font_size   <=15)) ;
$y = (600 - $txt_height) / 2;
$x = (600 - $txt_width) / 2;
 $y = $y+10;



 $dimensions = imagettfbbox(15, 0, $fontX, $text);
$textWidth = abs($dimensions[4] - $dimensions[3]);

imagettftext($background,15, 0, 315, 150, $font_color2, $fontY, $text); //Write 

$font_size = 25;
$user2      = "*".username(); 
$user3      = user(); 
$slug      = strtoupper("thebrand.co.ke/".slug());
$user4      = "#".username(); 
$bio      = strtoupper(bio()); 

     
 

$dimensions = imagettfbbox(10, 0, $fontY, $slug);
$textWidth = abs($dimensions[4] - $dimensions[0]);
$x2 = 600 - $textWidth-35;
imagettftext($background,10, 0, 40, 570, $font_color2, $fontZ, $slug); //Write 
 
 
  $user3      = user();

imagettftext($background,20, 0, 315, 80, $font_color2,$fontW, $user3); 


 
$dimensions = imagettfbbox(25, 0, $fontZ, $user2);
$textWidth = abs($dimensions[4] - $dimensions[0]);
$x2 = 600 - $textWidth-30; 
imagettftext($background,15, 0, 315, 100, $font_color3,$fontZ, $user2); 



imagettftext($background,14, 0, 70, 528, $font_color2, $fontW, $secondname);  
 
return $background; 


}

 
function gd_filter_safaricom($background)
{ 
 
  if (empty($_GET['cl']))  
  { 
  $text = realText() ; 
  } 
  else 
  { 
  $text = dummyText(); 
  } 


 
 

$myArray = get_startags($text, $str = 0);
$moodswing0 =$myArray[0];
$moodswing1 =$myArray[1];
 $moodswing0 =strtolower($moodswing0);
 $moodswing1 =strtolower($moodswing1);

 if ($moodswing1=="safaricomcare" || $moodswing0 =="safaricomcare") {
	  
	  
$picme = rand(1,8);
if($picme == 1) {$image ="1.jpg"; } 
if($picme == 2) { $image ="2.jpg"; } 
if($picme == 3) { $image ="3.jpg";  } 
if($picme == 4) {$image ="4.jpg";  } 
if($picme == 5) { $image ="5.jpg"; } 
if($picme == 6) { $image ="6.jpg"; } 
if($picme == 7) { $image ="7.jpg"; } 
if($picme == 8) { $image ="8.jpg";  } 
if($picme == 8) { $image ="9.jpg";  } 
 
   	  
 $background = gd_apply_overlay6($background, $image, 100);	  
 
	}

 switch ($moodswing0) {
     
         case  "shangwemtaani" :
		 $font_color = imagecolorallocate($background,    0, 0, 0); // Create blue color 
  $font_color4 = imagecolorallocate($background,  207, 130,251); // Create blue color
		$background = gd_apply_overlay($background, 'shangwemtaani', 100);
		 $font_color3 = imagecolorallocate($background,  151, 204,74); // Create blue color  
          break; 
		    case  "teammafisi" :
			$font_color = imagecolorallocate($background,    255, 255, 255); // Create blue color 
  $font_color4 = imagecolorallocate($background,  207, 130,251); // Create blue color
		 $background = gd_apply_overlay($background, 'teammafisi', 100);
		 $font_color3 = imagecolorallocate($background,  228, 4,4);
          break;  
		  case  "thisisforyou" :
		  $font_color = imagecolorallocate($background,    255, 255, 255); // Create blue color 
  $font_color4 = imagecolorallocate($background,  207, 130,251); // Create blue color
		 $background = gd_apply_overlay($background, 'thisisforyou', 100);
		 $font_color3 = imagecolorallocate($background,  168, 100,168);
          break;
		  case  "mpesa" :
		  $font_color = imagecolorallocate($background,    255, 255, 255); // Create blue color 
  $font_color4 = imagecolorallocate($background,  207, 130,251); // Create blue color
		 $background = gd_apply_overlay($background, 'mpesa', 100);
		 $font_color3 = imagecolorallocate($background,  252, 195,59);
          break;
         case  "suzziemaselfie" :
		 $font_color = imagecolorallocate($background,   255, 255, 255); // Create blue color 
  $font_color4 = imagecolorallocate($background,  207, 130,251); // Create blue color
		 $background = gd_apply_overlay($background, 'suzziemaselfie', 100);
		 $font_color3 = imagecolorallocate($background,  15, 198,248);
          break;
         
		  case  "safaricomcare" :
		 $font_color = imagecolorallocate($background,   255, 255, 255); // Create blue color 
  $font_color4 = imagecolorallocate($background,  207, 130,251); // Create blue color
		 $background = gd_apply_overlay($background, 'safaricomcare', 100);
		 $font_color3 = imagecolorallocate($background,  15, 198,248);
          break;
 }	

	
	
	

	
	
	switch ($moodswing1) {
     
         case  "shangwemtaani" :
		imagefilter($background, IMG_FILTER_BRIGHTNESS, -40);
	imagefilter($background, IMG_FILTER_CONTRAST, -15);
	$background = gd_apply_overlay($background, 'shangwemtaani', 50);
 
 $font_color = imagecolorallocate($background,   0, 0, 0); // Create blue color 
  $font_color4 = imagecolorallocate($background,  0, 0, 0); // Create blue color
		 $font_color3 = imagecolorallocate($background,  151, 204,74); // Create blue color  
          break; 
		    case  "teammafisi" :
		 imagefilter($background, IMG_FILTER_BRIGHTNESS, -40);
	imagefilter($background, IMG_FILTER_CONTRAST, -15);
	 $background = gd_apply_overlay($background, 'teammafisi', 50);
 $font_color = imagecolorallocate($background,   255, 255, 255); // Create blue color 
  $font_color4 = imagecolorallocate($background,  255, 255, 255); // Create blue color
		 $font_color3 = imagecolorallocate($background,  228, 4,4);
          break;  
		  case  "thisisforyou" :
		 imagefilter($background, IMG_FILTER_BRIGHTNESS, -40);
	imagefilter($background, IMG_FILTER_CONTRAST, -15);
	 $background = gd_apply_overlay($background, 'thisisforyou', 50);
 $font_color = imagecolorallocate($background,   255, 255, 255); // Create blue color 
  $font_color4 = imagecolorallocate($background,  255, 255, 255); // Create blue color
		 $font_color3 = imagecolorallocate($background,  168, 100,168);
          break;
		  case  "mpesa" :
		imagefilter($background, IMG_FILTER_BRIGHTNESS, -40);
	imagefilter($background, IMG_FILTER_CONTRAST, -15);
	 $background = gd_apply_overlay($background, 'mpesa', 50);
 $font_color = imagecolorallocate($background,   255, 255, 255); // Create blue color 
  $font_color4 = imagecolorallocate($background,  255, 255, 255); // Create blue color
		 $font_color3 = imagecolorallocate($background,  252, 195,59);
          break;
         case  "suzziemaselfie" :
		 imagefilter($background, IMG_FILTER_BRIGHTNESS, -40);
	imagefilter($background, IMG_FILTER_CONTRAST, -15);
	 $background = gd_apply_overlay($background, 'suzziemaselfie', 50);
 $font_color = imagecolorallocate($background,   255, 255, 255); // Create blue color 
  $font_color4 = imagecolorallocate($background,  255, 255, 255); // Create blue color
		 $font_color3 = imagecolorallocate($background,  15, 198,248);
          break;
		   case  "safaricomcare" :
		 imagefilter($background, IMG_FILTER_BRIGHTNESS, -40);
	imagefilter($background, IMG_FILTER_CONTRAST, -15);
	 $background = gd_apply_overlay($background, 'safaricomcare', 50);
 $font_color = imagecolorallocate($background,   255, 255, 255); // Create blue color 
  $font_color4 = imagecolorallocate($background,  255, 255, 255); // Create blue color
		 $font_color3 = imagecolorallocate($background,  15, 198,248);
          break;
		 
 }	


  $fontC = 'assets/fonts/GOTHICB_0.TTF'; //font used
 $fontB = 'assets/fonts/HelveticaNeueLTStd-BdCnO.otf'; //font used
 $fontA = 'assets/fonts/MyriadWebPro-Italic_0.ttf'; //font used
$fontY = 'assets/fonts/HelveticaNeueLTStd-BdCn.otf'; //font used
$fontX = 'assets/fonts/HelveticaNeueLTStd-Ex.otf'; //font used
$fontZ = 'assets/fonts/HelveticaNeueLTStd-LtCnO.otf'; //font used
$fontW = 'assets/fonts/HelveticaLTStd-BlkCondObl.otf'; //font used
$font_color = imagecolorallocate($background,   255,223,67); // Create blue color 
$font_color2 = imagecolorallocate($background,   0, 0, 0); // Create blue color  
$font_color3 = imagecolorallocate($background, 136,184,20); // Create blue color  






/*   */







if (empty($_GET['cl']))  
  { 
  $text = realText() ; 
  } 
  else 
  { 
  $text = dummyText(); 
  } 
  
  
 
$text = removeslashes($text);
$font_size = 1;
$txt_max_width = intval(0.7*250);
$user2      = ucwords(username()); 
$user3      = strtoupper(user()); 
$slug      = "thebrand.co.ke/".slug();

 


 
$dimensions = imagettfbbox(12, 0, $fontY, $slug);
$textWidth = abs($dimensions[4] - $dimensions[0]);
$x2 = 600 - $textWidth-15; 

 


preg_match('/\*(\\w+)/',$text,$matches);
$mood ="*".$matches[1];
$text= preg_replace('/\*(\\w+)/', "", $text); 
$text= preg_replace('/\#(\\w+)/', "", $text);
$text= trim($text); 






  if ($moodswing1=="safaricomcare" || $moodswing0 =="safaricomcare") {
	     
	  
 $yme = 445;	    
  $xme = 445;
  $yme2 = 40;
  $xme2 = 160;
  $yme3 = 445;
  
  
  
  $text = wordwrap($text,30,"\n");
 
$font_size = 1;
$txt_max_width = intval(0.7*600);

do{
	$font_size++;
	$p = imagettfbbox($font_size,0,$fontC,$text);
	$txt_width = $p[2] - $p[0];
	$txt_height = $p[1] - $p[7];
	
}
while (($txt_width <= $txt_max_width)  &&   ($font_size   <=18)) ;
$y = (600 - $txt_height) / 2;
$x = (600 - $txt_width) / 2;

   imagettftext($background,$font_size, 0, $x, $y, $font_color3, $fontC, $text); //Write 
  
}
else
{
$yme = 585;	
 $xme = 0;
 $yme2 = 585;

 $xme2 = 28;
 $yme3 = 490;
 imagettftext($background,20, 0, 28, 95, $font_color2, $fontA, $user2); //Write 
 
 imagettftext($background,12, 0, $x2, $yme2, $font_color2, $fontY, $slug); 
imagettftext($background,14, 0, 28,$yme2, $font_color2, $fontY,  "*".username()); 

  $text = wordwrap($text,26,"\n");
 
$font_size = 1;
$txt_max_width = intval(0.9*300);

do{
	$font_size++;
	$p = imagettfbbox($font_size,0,$fontZ,$text);
	$txt_width = $p[2] - $p[0];
	$txt_height = $p[1] - $p[7];
	
}
while (($txt_width <= $txt_max_width)  &&   ($font_size   <=22)) ;
$y = (600 - $txt_height) / 2;
$x = (300 - $txt_width) / 2;
 imagettftext($background,$font_size, 0, 35, $y, $font_color3, $fontZ, $text); //Write 
	
	}








 
  $user3      = user();
 $myArray = get_spaces($user3, $str = 0);
$firstname =$myArray[1];
$secondname =ucwords($myArray[0]);

$dimensions = imagettfbbox(20, 0, $fontZ, $secondname);
$textWidth = abs($dimensions[4] - $dimensions[0]);
$x2 = $xme2; 

$arSize = imagettfbbox(30, 0, $fontZ, $text);
$iWidth = abs($arSize[2] - $arSize[0]);
$iHeight = abs($arSize[7] - $arSize[1]);


imagettftext($background,20, 0, $x2, $yme3, $font_color2, $fontZ, $secondname); 


$dimensionsx = imagettfbbox(20, 0, $fontB, $firstname);
$textWidthx = abs($dimensionsx[4] - $dimensionsx[0]);
$xx = $x2 + $textWidth+5; 
 
 imagettftext($background,20, 0, $xx, $yme3, $font_color2, $fontB, $firstname);  

/*imagettfstroketext($background, 70, 0, 10, 50, $font_color2, $stroke_color, $fontZ, $user3, 2);*/
  if ($moodswing1=="safaricomcare" || $moodswing0 =="safaricomcare") {
   $picme="9.jpg";
   if ($picme=="9.jpg") {
		
		$background = gd_apply_overlay6($background, $picme, 100);	
		
		}	
	 }
 	  
 
 
 
 
 
 
return $background; 


}




function verifyStartag()
{
$text = realText() ; 
$myArray = get_startags($text, $str = 0);
$moodswing0 =$myArray[0];
$moodswing0 =strtolower($moodswing0);
$startag =findStartag($moodswing0);
$startag = explode('|',$startag);
return $picture = $startag[0];
}


function gd_filter_moodswing($background)
{ 
if (empty($_GET['cl']))  
  { 
  $text = realText() ; 
  } 
  else 
  { 
  $text = dummyText(); 
  } 
 
$myArray = get_startags($text, $str = 0);
$moodswing0 =$myArray[0];
$moodswing1 =$myArray[1];
$moodswing2 =$myArray[2];
$moodswingX =$myArray[2];
$moodswing4 =$myArray[4];

$moodswing0 =strtolower($moodswing0);
$moodswing1 =strtolower($moodswing1);
$moodswing2 =strtolower($moodswing2);

$text= preg_replace('/\*(\\w+)/', "", $text); 
$text= preg_replace('/\#(\\w+)/', "", $text);
$text= trim($text);



			if (empty($moodswing0))
			{
			 
						$startag =openGallery($moodswing0);
						if(!empty($startag))
						{
							$startag = explode('|',$startag);
							$picture = $startag[0];
							 
							$background = gd_apply_overlay4($background, $picture, 100);
							
							if(!empty($moodswingX))
							{ 
							    $moodswing2 = $moodswingX;
								include("mags/effects.php");
							}
							
							if(!empty($moodswing1))
							{
								$moods =strtolower($moodswing1);
							}
							else
							{
								$moods = $startag[1];
								$moods =strtolower($moods); 
							}
							
   
							switch ($moods) {
								case  "widgetstats" :
								  $background= gd_filter_widget($background);
								  return $background;
								  break;
								   case  "widgetstats2" :
								   $background= gd_filter_widget($background);
								  return $background;
								  break;
								   case  "widgetstats" :
								   $background= gd_filter_widget($background);
								  return $background;
								  break;
								   case  "widgetblue" :
								   $background= gd_filter_widget($background);
								  return $background;
								  break;
								   case  "widgetred" :
								  $background= gd_filter_widget($background);
								  return $background;
								  break;
								   case  "widgetgreen" :
								   $background= gd_filter_widget($background);
								  return $background;
								  break;
									 case  "classic" :
								  $background= gd_filter_classic($background);
								  return $background;
								  break;
								  case  "royal" :
								  $background= gd_filter_royal($background);
								  return $background;
								  break;
								  case  "yellow" :
								  $background= gd_filter_yellow($background);
								  return $background;
								  break;
								  case  "coolpost" :
								  $background= gd_filter_coolpost($background);
								  return $background;
								  break;

								  case  "glassy" :
								  $background= gd_filter_glassy($background);
								  return $background;
								  break;
								  case  "followme" :
								  $background= gd_filter_followme($background);
								  return $background;
								  break;

								  case  "orange" :
								  $background= gd_filter_orange($background);
								  return $background;
								  break;
								  case  "green" :
								  $background= gd_filter_yellow($background);
								  return $background;
								  break;
									
								   case  "blue" :
								  $background= gd_filter_yellow($background);
								  return $background;
								  break;
								   case  "red" :
								  $background= gd_filter_yellow($background);
								  return $background;
								  break;
									   case  "purple" :
								  $background= gd_filter_yellow($background);
								  return $background;
								  break;
									   case  "pink" :
								  $background= gd_filter_yellow($background);
								  return $background;
								  break;
								  case  "modernyellow" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
								  case  "moderngreen" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
									
								   case  "modernblue" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
								   case  "modernred" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
									   case  "modernpurple" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
									   case  "modernpink" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;


								   case  "calmgreen" :
								  $background= gd_filter_calmgreen($background);
								  return $background;
								  break;
								   case  "calmyellow" :
								  $background= gd_filter_calmgreen($background);
								  return $background;
								  break;
								   case  "calmblue" :
								  $background= gd_filter_calmgreen($background);
								  return $background;
								  break;
								   case  "calmred" :
								  $background= gd_filter_calmgreen($background);
								  return $background;
								  break;
									   case  "calmpurple" :
								  $background= gd_filter_calmgreen($background);
								  return $background;
								  break;
									   case  "adgreen" :
								  $background= gd_filter_adgreen($background);
								  return $background;
								  break;
								   case  "adyellow" :
								  $background= gd_filter_adgreen($background);
								  return $background;
								  break;
								  case  "adwhite" :
								  $background= gd_filter_adgreen($background);
								  return $background;
								  break;
								   case  "adblue" :
								  $background= gd_filter_adgreen($background);
								  return $background;
								  break;
							   
						   case  "adred" :
								  $background= gd_filter_adgreen($background);
								  return $background;
								  break;
								  
							 case  "impact" :
									$background= gd_filter_impact($background);
									return $background;
									break;
 case  "classy" :
        $background= gd_filter_classy($background);
		return $background;
        break;
 case  "notice" :
        $background= gd_filter_notice($background);
		return $background;
        break;
 case  "exquisite" :
        $background= gd_filter_exquisite($background);
		return $background;
        break;
									
								   case  "adpink" :
								  $background= gd_filter_adgreen($background);
								  return $background;
								  break;
									   case  "adpurple" :
								  $background= gd_filter_adgreen($background);
								  return $background;
								  break;
								   case  "fun" :
								  $background= gd_filter_fun($background);
								  return $background;
								  break;
								   case  "bold" :
								  $background= gd_filter_bold($background);
								  return $background;
								  break;
								   case  "bfma" :
								  $background= gd_filter_bfma($background);
								  return $background;
								  break;
								   case  "machine" :
								  $background= gd_filter_machine($background);
								  return $background;
								  break;
								   case  "corporate" :
								  $background= gd_filter_corporate($background);
								  return $background;
								  break;
								   case  "corporateblack" :
								  $background= gd_filter_corporateblack($background);
								  return $background;
								  break;
								   case  "twisted" :
								  $background= gd_filter_twisted($background);
								  return $background;
								  break;
								   case  "whitebrand" :
								  $background= gd_filter_whitebrand($background);
								  return $background;
								  break;
								   case  "awesome" :
								  $background= gd_filter_awesome($background);
								  return $background;
								  break; 
									case  "awesome2" :
								  $background= gd_filter_awesome2($background);
								  return $background;
								  break; 
									case  "elated" :
								  $background= gd_filter_elated($background);
								  return $background;
								  break; 
									case  "newsupdate" :
								  $background= gd_filter_newsupdate($background);
								  return $background;
								  break; 
								   case  "professional" :
								  $background= gd_filter_professional($background);
								  return $background;
								  break; 
								   case  "clean" :
        $background= gd_filter_clean($background);
		return $background;
        break; 
		 case  "stylish" :						  
        $background= gd_filter_stylish($background);
		return $background;
        break; 
								  case  "tech" :
								  $background= gd_filter_tech($background);
								  return $background;
								  break;
								  case  "twitter" :
								  $background= gd_filter_twitter($background);
								  return $background;
								  break;
								  case  "awesometweet" :
								  $background= gd_filter_awesometweet($background);
								  return $background;
								  break;
								  case  "executive" :
								  $background= gd_filter_executive($background);
								  return $background;
								  break;
								  case  "business" :
								  $background= gd_filter_business($background);
								  return $background;
								  break;
								  case  "realnews" :
								  $background= gd_filter_realnews($background);
								  return $background;
								  break;  case  "kbc" :
								  $background= gd_filter_kbc($background);
								  return $background;
								  break;
								  

								  case  "elegant" :
								  $background= gd_filter_elegant($background);
								  return $background;
								  break;
								  case  "brownblog" :
								  $background= gd_filter_brownblog($background);
								  return $background;
								  break;
									  case  "blogmain" :
								  $background= gd_filter_blogmain($background);
								  return $background;
								  break;
								  case  "purpleblog" :
								  $background= gd_filter_purpleblog($background);
								  return $background;
								  break;
								  
								  case  "redblog" :
								  $background= gd_filter_redblog($background);
								  return $background;
								  break;
								  case  "masters" :
								  $background= gd_filter_masters($background);
								  return $background;
								  break;
								  case  "blueblog" :
								  $background= gd_filter_blueblog($background);
								  return $background;
								  break;
								  case  "greenblog" :
								  $background= gd_filter_greenblog($background);
								  return $background;
								  break;
								  
								  case  "boldgreen" :
								  $background= gd_filter_boldgreen($background);
								  return $background;
								  break;
								  
								  case  "boldblue" :
								  $background= gd_filter_boldblue($background);
								  return $background;
								  break;
								  case  "boldorange" :
								  $background= gd_filter_boldorange($background);
								  return $background;
								  break;
								  case  "boldred" :
								  $background= gd_filter_boldred($background);
								  return $background;
								  break;
							   case  "powerful" :
								  $background= gd_filter_powerful($background);
								  return $background;
								  break;
									   case  "redglory" :
								  $background= gd_filter_redglory($background);
								  return $background;
								  break;
								  
								   case  "now" :
								  $background= gd_filter_now($background);
								  return $background;
								  break;
								   case  "rightnow" :
								  $background= gd_filter_rightnow($background);
								  return $background;
								  break;
								   case  "headlines" :
								  $background= gd_filter_headlines($background);
								  return $background;
								  break;
		 case  "worldnews" :
        $background= gd_filter_worldnews($background);
		return $background;
        break;

		 case  "reporting" :
        $background= gd_filter_reporting($background);
		return $background;
        break;
								  case  "boldpurple" :
								  $background= gd_filter_boldpurple($background);
								  return $background;
								  break;
								  
								  case  "boldblack" :
								  $background= gd_filter_boldblack($background);
								  return $background;
								  break;
								   
								  
								   case  "colored" :
								  $background= gd_filter_colored($background);
								  return $background;
								  break;
								   case  "stickynote" :
								  $background= gd_filter_stickynote($background);
								  return $background;
								  break;
								   case  "coffee" :
								  $background= gd_filter_coffee($background);
								  return $background;
								  break;
								   case  "highlight" :
								  $background= gd_filter_highlight($background);
								  return $background;
								  break;
								   case  "funky" :
								  $background= gd_filter_funky($background);
								  return $background;
								  break;
								   case  "coolblue" :
								  $background= gd_filter_coolblue($background);
								  return $background;
								  break;
								   case  "punch" :
								  $background= gd_filter_punch($background);
								  return $background;
								  break;
										case  "trends" :
								  $background= gd_filter_trends($background);
								  return $background;
								  break;
									case  "smart" :
								  $background= gd_filter_smart($background);
								  return $background;
								  break;
								   case  "nairobi" :
								  $background= gd_filter_nairobi($background);
								  return $background;
								  break;
								   case  "nairobi2" :
								  $background= gd_filter_nairobi2($background);
								  return $background;
								  break;
								  
									 case  "news" :
								  $background= gd_filter_news($background);
								  return $background;
								  break;
								  
								   case  "breaking" :
								  $background= gd_filter_breaking($background);
								  return $background;
								  break;
								   case  "newsy" :
								  $background= gd_filter_newsy($background);
								  return $background;
								  break;
								  
								  case  "happening" :
								  $background= gd_filter_happening($background);
								  return $background;
								  break;

								  case  "gaa" :
								  $background= gd_filter_gaa($background);
								  return $background;
								  break;
								  
								  case  "sevens" :
								  $background= gd_filter_sevens($background);
								  return $background;
								  break;
								  case  "live" :
								  $background= gd_filter_live($background);
								  return $background;
								  break;
								  case  "exclusive" :
								  $background= gd_filter_exclusive($background);
return $background;
								  break;
																	  case  "comicbook" :
								  $background= gd_filter_comicbook($background);
return $background;
								  break;
case  "newsone" :
								  $background= gd_filter_newsone($background);
								  return $background;
								  break;   
								  case  "atnine" :
								  $background= gd_filter_atnine($background);
								  return $background;
								  case  "blank" :
								  $background= gd_filter_blank($background);
								  return $background;
								  break;
								  
							   
							  }
						}
						 	
						include("mags/default.php"); 	
						 
				
			}
			
						 



			if (!empty($moodswing1))
			{
				
				$moodswing2 = $moodswing1;
					
				include("mags/effects.php");
				
			}			
			 

if (!empty($moodswing0))
{
 $startag =findStartag($moodswing0);
 $startag = explode('|',$startag);
 $picture = $startag[0];
$x = $startag[4];
$y = $startag[5];
$fx = $startag[6];
			
			if (!empty($picture))
		{
		  
				if (!empty($text) && !empty($picture))
				{
				$background = gd_apply_overlay2($background,  $picture , 100,$x,$y);				



	if (!empty($_GET['newPic']))
				{
					$newPic = $_GET['newPic'];
					
				  $background = gd_apply_logo($background,$newPic, 100,0,0,600,600);
				}
						 
							 
						 






				if (!empty($_GET['fx']))
				{
					$moodswing2 = $_GET['fx'];
					
				include("mags/effects.php"); 
				}
				
				
				if (!empty($fx))
				{
					$moodswing2 = $startag[6];
					
				include("mags/effects.php"); 
				}
				
				
				
				if (!empty($moodswing1))
				{
				$moods =strtolower($moodswing1);
				
				include("mags/moods.php"); 
				}
				else
				{
				$themes = $startag[1];
				$moods =strtolower($themes);
				include("mags/moods.php"); 
				} 


				
				}
				if (empty($text) && !empty($picture))
				{
				$background = gd_apply_overlay2($background,  $picture , 100,$x,$y);
				$fontZ = 'assets/fonts/HelveticaNeueLTStd-UltLt.otf'; //font used
				$font_color2 = imagecolorallocate($background,   255, 255, 255); // Create blue color 
				$yanani = $startag[3];
				$yanani = "*".yanani($yanani); 
				imagettftext($background,35, 0, 20, 580, $font_color2, $fontZ, $yanani);
				}
		
		
		
		}
		else
		{
				if (!empty($text) && empty($picture))
				{
				
				$startag =openGallery($moodswing0);
			$startag =openGallery($moodswing0);
						if(!empty($startag))
						{
							$startag = explode('|',$startag);
							$picture = $startag[0];
							$background = gd_apply_overlay4($background, $picture, 100);
							$moods = $startag[1];
							if(!empty($moodswingX))
							{ 
							    $moodswing2 = $moodswingX;
								include("mags/effects.php");
							}
							

							
							if(!empty($moodswing1))
							{
								$moods =strtolower($moodswing1);
							}
							else
							{
								$moods = $startag[1];
								$moods =strtolower($moods); 
							}
   
							switch ($moods) {
								case  "widgetstats" :
								  $background= gd_filter_widget($background);
								  return $background;
								  break;
								   case  "widgetstats2" :
								   $background= gd_filter_widget($background);
								  return $background;
								  break;
								   case  "widgetstats" :
								   $background= gd_filter_widget($background);
								  return $background;
								  break;
								   case  "widgetblue" :
								   $background= gd_filter_widget($background);
								  return $background;
								  break;
								   case  "widgetred" :
								  $background= gd_filter_widget($background);
								  return $background;
								  break;
								   case  "widgetgreen" :
								   $background= gd_filter_widget($background);
								  return $background;
								  break;
									 case  "classic" :
								  $background= gd_filter_classic($background);
								  return $background;
								  break;
								  case  "royal" :
								  $background= gd_filter_royal($background);
								  return $background;
								  break;
								  case  "yellow" :
								  $background= gd_filter_yellow($background);
								  return $background;
								  break;
								  case  "coolpost" :
								  $background= gd_filter_coolpost($background);
								  return $background;
								  break;
								  case  "glassy" :
								  $background= gd_filter_glassy($background);
								  return $background;
								  break;
								  case  "followme" :
								  $background= gd_filter_followme($background);
								  return $background;
								  break;
								  case  "orange" :
								  $background= gd_filter_orange($background);
								  return $background;
								  break;
								  case  "green" :
								  $background= gd_filter_yellow($background);
								  return $background;
								  break;
									
								   case  "blue" :
								  $background= gd_filter_yellow($background);
								  return $background;
								  break;
								   case  "red" :
								  $background= gd_filter_yellow($background);
								  return $background;
								  break;
									   case  "purple" :
								  $background= gd_filter_yellow($background);
								  return $background;
								  break;
								  case  "modernyellow" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
								  case  "moderngreen" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
									
								   case  "modernblue" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
								   case  "modernred" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
									   case  "modernpurple" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
									   case  "modernpink" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;

								  case  "modernyellow" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
								  case  "moderngreen" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
									
								   case  "modernblue" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
								   case  "modernred" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
									   case  "modernpurple" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;
									   case  "modernpink" :
								  $background= gd_filter_modern($background);
								  return $background;
								  break;



								  case  "shangwemtaani" :
								  $background= gd_filter_safaricom($background);
								  return $background;
								  break;
								  case  "teammafisi" :
								  $background= gd_filter_safaricom($background);
								  return $background;
								  break;
									
								   case  "thisisforyou" :
								  $background= gd_filter_safaricom($background);
								  return $background;
								  break;
								   case  "mpesa" :
								  $background= gd_filter_safaricom($background);
								  return $background;
								  break;
									   case  "suzziemaselfie" :
								  $background= gd_filter_safaricom($background);
								  return $background;
								  break;
									   case  "safaricomcare" :
								  $background= gd_filter_safaricom($background);
								  return $background;
								  break;




									   case  "pink" :
								  $background= gd_filter_yellow($background);
								  return $background;
								  break;
								   case  "calmgreen" :
								  $background= gd_filter_calmgreen($background);
								  return $background;
								  break;
								   case  "calmyellow" :
								  $background= gd_filter_calmgreen($background);
								  return $background;
								  break;
								   case  "calmblue" :
								  $background= gd_filter_calmgreen($background);
								  return $background;
								  break;
								   case  "calmred" :
								  $background= gd_filter_calmgreen($background);
								  return $background;
								  break;
									   case  "calmpurple" :
								  $background= gd_filter_calmgreen($background);
								  return $background;
								  break;
									   case  "adgreen" :
								  $background= gd_filter_adgreen($background);
								  return $background;
								  break;
								   case  "adyellow" :
								  $background= gd_filter_adgreen($background);
								  return $background;
								  break;
								  case  "adwhite" :
								  $background= gd_filter_adgreen($background);
								  return $background;
								  break;
								   case  "adblue" :
								  $background= gd_filter_adgreen($background);
								  return $background;
								  break;
							   
						   case  "adred" :
								  $background= gd_filter_adgreen($background);
								  return $background;
								  break;
								  
							 case  "impact" :
									$background= gd_filter_impact($background);
									return $background;
									break;
 case  "notice" :
        $background= gd_filter_notice($background);
		return $background;
        break;
 case  "exquisite" :
        $background= gd_filter_exquisite($background);
		return $background;
        break;
									 case  "classy" :
        $background= gd_filter_classy($background);
		return $background;
        break;

								   case  "adpink" :
								  $background= gd_filter_adgreen($background);
								  return $background;
								  break;
									   case  "adpurple" :
								  $background= gd_filter_adgreen($background);
								  return $background;
								  break;
								   case  "fun" :
								  $background= gd_filter_fun($background);
								  return $background;
								  break;
								   case  "bold" :
								  $background= gd_filter_bold($background);
								  return $background;
								  break;
								   case  "bfma" :
								  $background= gd_filter_bfma($background);
								  return $background;
								  break;
								   case  "machine" :
								  $background= gd_filter_machine($background);
								  return $background;
								  break;
								   case  "corporate" :
								  $background= gd_filter_corporate($background);
								  return $background;
								  break;
								   case  "corporateblack" :
								  $background= gd_filter_corporateblack($background);
								  return $background;
								  break;
								   case  "twisted" :
								  $background= gd_filter_twisted($background);
								  return $background;
								  break;
								   case  "whitebrand" :
								  $background= gd_filter_whitebrand($background);
								  return $background;
								  break;
								   case  "awesome" :
								  $background= gd_filter_awesome($background);
								  return $background;
								  break; 
									case  "awesome2" :
								  $background= gd_filter_awesome2($background);
								  return $background;
								  break; 
									case  "elated" :
								  $background= gd_filter_elated($background);
								  return $background;
								  break; 
									case  "newsupdate" :
								  $background= gd_filter_newsupdate($background);
								  return $background;
								  break; 
								   case  "professional" :
								  $background= gd_filter_professional($background);
								  return $background;
								  break; 
								   case  "clean" :
        $background= gd_filter_clean($background);
		return $background;
        break; 
		 case  "stylish" :
        $background= gd_filter_stylish($background);
		return $background;
        break; 
		
								  case  "tech" :
								  $background= gd_filter_tech($background);
								  return $background;
								  break;
								  case  "twitter" :
								  $background= gd_filter_twitter($background);
								  return $background;
								  break;
								  case  "awesometweet" :
								  $background= gd_filter_awesometweet($background);
								  return $background;
								  break;
								  case  "executive" :
								  $background= gd_filter_executive($background);
								  return $background;
								  break;
								  case  "business" :
								  $background= gd_filter_business($background);
								  return $background;
								  break;
								  case  "realnews" :
								  $background= gd_filter_realnews($background);
								  return $background;
								  break;
								  
								  case  "kbc" :
								  $background= gd_filter_kbc($background);
								  return $background;
								  break;
								  
								  case  "elegant" :
								  $background= gd_filter_elegant($background);
								  return $background;
								  break;
								  case  "brownblog" :
								  $background= gd_filter_brownblog($background);
								  return $background;
								  break;
									  case  "blogmain" :
								  $background= gd_filter_blogmain($background);
								  return $background;
								  break;
								  case  "purpleblog" :
								  $background= gd_filter_purpleblog($background);
								  return $background;
								  break;
								  
								  case  "redblog" :
								  $background= gd_filter_redblog($background);
								  return $background;
								  break;
								  case  "masters" :
								  $background= gd_filter_masters($background);
								  return $background;
								  break;
								  case  "blueblog" :
								  $background= gd_filter_blueblog($background);
								  return $background;
								  break;
								  case  "greenblog" :
								  $background= gd_filter_greenblog($background);
								  return $background;
								  break;
								  
								  case  "boldgreen" :
								  $background= gd_filter_boldgreen($background);
								  return $background;
								  break;
								  
								  case  "boldblue" :
								  $background= gd_filter_boldblue($background);
								  return $background;
								  break;
								  case  "boldorange" :
								  $background= gd_filter_boldorange($background);
								  return $background;
								  break;
								  case  "boldred" :
								  $background= gd_filter_boldred($background);
								  return $background;
								  break;
							   case  "powerful" :
								  $background= gd_filter_powerful($background);
								  return $background;
								  break;
									   case  "redglory" :
								  $background= gd_filter_redglory($background);
								  return $background;
								  break;
								  
								   case  "now" :
								  $background= gd_filter_now($background);
								  return $background;
								  break;
								   case  "rightnow" :
								  $background= gd_filter_rightnow($background);
								  return $background;
								  break;
								   case  "headlines" :
								  $background= gd_filter_headlines($background);
								  return $background;
								  break;
		 case  "worldnews" :
        $background= gd_filter_worldnews($background);
		return $background;
        break;
		 case  "reporting" :
        $background= gd_filter_reporting($background);
		return $background;
        break;
								  case  "boldpurple" :
								  $background= gd_filter_boldpurple($background);
								  return $background;
								  break;
								  
								  case  "boldblack" :
								  $background= gd_filter_boldblack($background);
								  return $background;
								  break;
								   
								  
								   case  "colored" :
								  $background= gd_filter_colored($background);
								  return $background;
								  break;
								   case  "stickynote" :
								  $background= gd_filter_stickynote($background);
								  return $background;
								  break;
								   case  "coffee" :
								  $background= gd_filter_coffee($background);
								  return $background;
								  break;
								   case  "highlight" :
								  $background= gd_filter_highlight($background);
								  return $background;
								  break;
								   case  "funky" :
								  $background= gd_filter_funky($background);
								  return $background;
								  break;
								   case  "coolblue" :
								  $background= gd_filter_coolblue($background);
								  return $background;
								  break;
								   case  "punch" :
								  $background= gd_filter_punch($background);
								  return $background;
								  break;
										case  "trends" :
								  $background= gd_filter_trends($background);
								  return $background;
								  break;
									case  "smart" :
								  $background= gd_filter_smart($background);
								  return $background;
								  break;
								   case  "nairobi" :
								  $background= gd_filter_nairobi($background);
								  return $background;
								  break;
								   case  "nairobi2" :
								  $background= gd_filter_nairobi2($background);
								  return $background;
								  break;
								  
									 case  "news" :
								  $background= gd_filter_news($background);
								  return $background;
								  break;
								  
								   case  "breaking" :
								  $background= gd_filter_breaking($background);
								  return $background;
								  break;
								   case  "newsy" :
								  $background= gd_filter_newsy($background);
								  return $background;
								  break;
								  case  "happening" :
								  $background= gd_filter_happening($background);
								  return $background;
								  break;
								  case  "gaa" :
								  $background= gd_filter_gaa($background);
								  return $background;
								  break;case  "sevens" :
								  $background= gd_filter_sevens($background);
								  return $background;
								  break;
								  case  "live" :
								  $background= gd_filter_live($background);
								  return $background;
								  break;
								  case  "exclusive" :
								  $background= gd_filter_exclusive($background);
								  return $background;
								  break;
																  case  "comicbook" :
								  $background= gd_filter_comicbook($background);
								  return $background;
								  break;
	case  "newsone" :
								  $background= gd_filter_newsone($background);
								  return $background;
								  break;   
								  case  "atnine" :
								  $background= gd_filter_atnine($background);
								  return $background;
								  case  "blank" :
								  $background= gd_filter_blank($background);
								  return $background;
								  break;
								  
							   
							  }


	 
						}
			include("mags/default.php"); 	
		 
				
				}
			
		}
	
}	 
 
   

  
/*$background = gd_filter_news($background);*/
return $background; 
	
	
}
 
function gd_filter_blank($background)
{  

	if (!empty($_GET['newPic']))
				{
					$newPic = $_GET['newPic'];
					if(!empty($_GET['width'])){
		$newWidth= $_GET['width']; 
	$w = $newWidth;   
	$h = $newWidth;
	  }	
				  $background = gd_apply_newpic($background,$newPic, 100,$x,$y,$w,$h);
				}

	if (!empty($_GET['fx']))
				{
					$moodswing2 = $_GET['fx'];
					
				include("mags/machineEffects.php"); 
				}
				
 				
		 $text = str_replace("thebrand","",$text) ;	$text = strtoupper($text) ;
				
$fontY = 'assets/fonts/MyriadPro-Semibold.otf'; //font used
$fontX = 'assets/fonts/HelveticaNeueLTStd-BdCn.otf'; //font used
$fontZ = 'assets/fonts/HelveticaNeueLTStd-Hv.otf'; //font used
$fontW = 'assets/fonts/HelveticaNeueLTStd-BdCnO.otf'; //font used
$font_color = imagecolorallocate($background,   0,0,0); // Create blue color 
$font_color3 = imagecolorallocate($background,   255, 255, 255); // Create blue color  
$font_color2 = imagecolorallocate($background,  72,73,77); // Create blue color  
 
  
  
				
		
$text= preg_replace('/\*(\\w+)/', "", $text); 
$text= preg_replace('/\#(\\w+)/', "", $text);
$text= trim($text); 
$text = wordwrap($text,40,"\n");
 
$font_size = 1;
$txt_max_width = intval(0.9*600);

do{
	$font_size++;
	$p = imagettfbbox($font_size,0,$fontZ,$text);
	$txt_width = $p[2] - $p[0];
	$txt_height = $p[1] - $p[7];
	
}
while (($txt_width <= $txt_max_width)  &&   ($font_size   <=25)) ;
$y = (600 - $txt_height) / 2;$y = 500;
$x = (600 - $txt_width) / 2;
 
imagettftext($background,20, 0, 30, $y, $font_color3, $fontX, $text); //Write 				
				
				

return $background; 
	
	
}