( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
function dummyText()
{
global $link;
if(!empty($_GET['context']))
{
$text = $_GET['context']." *".$_GET['cl'];
}
else
{
$text = "How Are You Feeling Today? *".$_GET['cl'];
}
return $text;
}
function realText()
{
global $link;
$string = mysqli_real_escape_string($link,$_GET['context']) ;
$string = str_replace("*thebrand","",$string) ;
$string = str_replace("thebrand","",$string) ;
$string = removeslashes($string);
if (is_string($string))
{
$filtered = strip_tags($string);
$found = false;
while ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) {
$filtered = str_replace($match[0], '', $filtered);
$found = true;
}
if ( $found ) {
$filtered = trim( preg_replace('/ +/', ' ', $filtered) );
}
return $filtered;
}
else
{
foreach($string as $_key => $_string) {
$string[$_key] = sanitize_text_field($_string);
}
return $string;
}
$text = $string;
return $text;
}
function sanitize_text_field($string) {
if (is_string($string))
{
$filtered = strip_tags($string);
$found = false;
while ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) {
$filtered = str_replace($match[0], '', $filtered);
$found = true;
}
if ( $found ) {
$filtered = trim( preg_replace('/ +/', ' ', $filtered) );
}
return $filtered;
}
else
{
foreach($string as $_key => $_string) {
$string[$_key] = sanitize_text_field($_string);
}
return $string;
}
}
function makeGrid($background,$gridWidth, $gridHeight, $width, $height) {
$black = imagecolorallocate($background, 255, 255, 255);
imagesetthickness($background, 1);
$cellWidth = ($width - 1) / $gridWidth; // note: -1 to avoid writting
$cellHeight = ($height - 1) / $gridHeight; // a pixel outside the image
for ($x = 0; ($x <= $gridWidth); $x++)
{
for ($y = 0; ($y <= $gridHeight); $y++)
{
imageline($background, ($x * $cellWidth), 0, ($x * $cellWidth), $height, $black);
imageline($background, 0, ($y * $cellHeight), $width, ($y * $cellHeight), $black);
}
}
return $background;
}
function makeRectangle($background,$sizeW, $sizeH, $posX, $posY,$gridWidth,$gridHeight, $width, $height) {
$cellWidth = $width / $gridWidth;
$cellHeight = $height / $gridHeight;
// Conversion of our virtual sizes/positions to real ones
$realSizeW = ($cellWidth * $sizeW)-2;
$realSizeH = ($cellHeight * $sizeH)-2;
$realPosX = ($cellWidth * $posX);
$realPosY = ($cellHeight * $posY);
// Getting top left and bottom right of our rectangle
$topLeftX = $realPosX;
$topLeftY = $realPosY;
$bottomRightX = $realPosX + $realSizeW;
$bottomRightY = $realPosY + $realSizeH;
// Displaying rectangle
$red = imagecolorallocate($background, 100, 0, 0);
imagefilledrectangle($background, $topLeftX, $topLeftY, $bottomRightX, $bottomRightY, $red);
return $background;
}
function MakeGridPicture($background, $brand, $amount,$sizeW, $sizeH, $posX, $posY,$gridWidth,$gridHeight, $width, $height)
{
global $link;
$cellWidth = $width / $gridWidth;
$cellHeight = $height / $gridHeight;
// Conversion of our virtual sizes/positions to real ones
$realSizeW = ($cellWidth * $sizeW)-2; // with borders
$realSizeH = ($cellHeight * $sizeH)-2;
$realSizeW = ($cellWidth * $sizeW);
$realSizeH = ($cellHeight * $sizeH);
$realPosX = ($cellWidth * $posX);
$realPosY = ($cellHeight * $posY);
// Getting top left and bottom right of our rectangle
$topLeftX = $realPosX;
$realPosY = $realPosY;
$bottomRightX = $realPosX + $realSizeW;
$bottomRightY = $realPosY + $realSizeH;
// Conversion of our virtual sizes/positions to real ones
$realSizeW = ($cellWidth * $sizeW)-2; //with borders
$realSizeH = ($cellHeight * $sizeH)-2;
$realSizeW = ($cellWidth * $sizeW); //with borders
$realSizeH = ($cellHeight * $sizeH);
$realPosX = ($cellWidth * $posX);
$realPosY = ($cellHeight * $posY);
// Getting top left and bottom right of our rectangle
$topLeftX = $realPosX;
$realPosY = $realPosY;
$bottomRightX = $realPosX + $realSizeW;
$bottomRightY = $realPosY + $realSizeH;
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
$imageFolder ="v/uploads/gthumbs/$brand";
switch ($ext)
{
case '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
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'png':
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$doSharpen = FALSE;
break;
}
$brand = $creationFunction("v/uploads/gthumbs/$brand");
$foto2W = imagesx($brand);
$foto2H = imagesy($brand);
$srcRatio = $foto2W / $foto2H;
$targetRatio = $realSizeW / $realSizeH;
if ( $srcRatio >= $targetRatio )
{
// If image is wider than thumbnail (in aspect ratio sense)
$background2H = $realSizeH;
$background2W = $foto2W / ( $foto2H / $realSizeH);
}
else
{
// If the thumbnail is wider than the image
$background2W = $realSizeW;
$background2H = $foto2H / ($foto2W / $realSizeW);
}
$background2 = imagecreatetruecolor( $realSizeW, $realSizeH );
$brand = imagecopyresampled($background2,
$brand,
0 - ($background2W - $realSizeW) / 2, // Center the image horizontally
0 - ($background2H - $realSizeH) / 2, // Center the image vertically
0, 0,
$background2W, $background2H,
$foto2W, $foto2H);
imagecopyresampled($background, $brand, $realPosX, $realPosY, 0, 0, $realSizeW, $realSizeH, imagesx($brand), imagesy($brand));
imagecopy($background, $background2,$topLeftX, $realPosY, 0, 0, imagesx($background2), imagesy($background2));
return $background;
}
function MakeGridStartag($background, $brand, $amount,$sizeW, $sizeH, $posX, $posY,$gridWidth,$gridHeight, $width, $height)
{
global $link;
$cellWidth = $width / $gridWidth;
$cellHeight = $height / $gridHeight;
// Conversion of our virtual sizes/positions to real ones
$realSizeW = ($cellWidth * $sizeW)-2; // with borders
$realSizeH = ($cellHeight * $sizeH)-2;
$realSizeW = ($cellWidth * $sizeW);
$realSizeH = ($cellHeight * $sizeH);
$realPosX = ($cellWidth * $posX);
$realPosY = ($cellHeight * $posY);
// Getting top left and bottom right of our rectangle
$topLeftX = $realPosX;
$realPosY = $realPosY;
$bottomRightX = $realPosX + $realSizeW;
$bottomRightY = $realPosY + $realSizeH;
// Conversion of our virtual sizes/positions to real ones
$realSizeW = ($cellWidth * $sizeW)-2; //with borders
$realSizeH = ($cellHeight * $sizeH)-2;
$realSizeW = ($cellWidth * $sizeW); //with borders
$realSizeH = ($cellHeight * $sizeH);
/*exit("$realSizeH" );
if($realSizeH > $height)
{
$realSizeW = $realSizeW-200;
$realSizeH = $realSizeH-200;
}*/
$realPosX = ($cellWidth * $posX);
$realPosY = ($cellHeight * $posY);
// Getting top left and bottom right of our rectangle
$topLeftX = $realPosX;
$realPosY = $realPosY;
$bottomRightX = $realPosX + $realSizeW;
$bottomRightY = $realPosY + $realSizeH;
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
$imageFolder ="v/uploads/opengallery/$brand";
switch ($ext)
{
case '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
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'png':
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$doSharpen = FALSE;
break;
}
$brand = $creationFunction("v/uploads/opengallery/$brand");
$foto2W = imagesx($brand);
$foto2H = imagesy($brand);
$srcRatio = $foto2W / $foto2H;
$targetRatio = $realSizeW / $realSizeH;
if ( $srcRatio >= $targetRatio )
{
// If image is wider than thumbnail (in aspect ratio sense)
$background2H = $realSizeH;
$background2W = $foto2W / ( $foto2H / $realSizeH);
}
else
{
// If the thumbnail is wider than the image
$background2W = $realSizeW;
$background2H = $foto2H / ($foto2W / $realSizeW);
}
$background2 = imagecreatetruecolor( $realSizeW, $realSizeH );
$trans_colour = imagecolorallocatealpha($background2, 0, 0, 0, 127);
imagefill($background2, 0, 0, $trans_colour);
$size = $realSizeH/$srcRatio;
if($size > $height)
{
$brand = imagecopyresampled($background2,
$brand,
($width- $realSizeW) / 2, // Center the image horizontally
0, // Center the image vertically
0, 0,
$realSizeW, $realSizeH/$srcRatio,
$foto2W, $foto2H);
}
else
{
$brand = imagecopyresampled($background2,
$brand,
($width- $realSizeW) / 2, // Center the image horizontally
(($height - ($realSizeH/$srcRatio)) / 2), // Center the image vertically
0, 0,
$realSizeW, $realSizeH/$srcRatio,
$foto2W, $foto2H);
}
/*imagecopyresampled($background, $brand, $realPosX, $realPosY, 0, 0, $realSizeW, $realSizeH, $foto2W, $foto2H);*/
imagecopy($background, $background2,$topLeftX, $realPosY, 0, 0, imagesx($background2), imagesy($background2));
return $background;
}
function checkBg($id)
{
global $link;
$rs_settings = mysqli_query($link,"SELECT * from general_post_manager WHERE id=$id");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$picture = $row_settings['file_name'] ;
return removeslashes($picture);
}
}
function resizePreservingAspectRatio($brandX, $targetWidth, $targetHeight)
{
global $link;
$foto2W = imagesx($brandX);
$foto2H = imagesy($brandX);
$srcRatio = $foto2W / $foto2H;
$targetRatio = $targetWidth / $targetHeight;
if ( $srcRatio >= $targetRatio )
{
// If image is wider than thumbnail (in aspect ratio sense)
$background2H = $targetHeight;
$background2W = $foto2W / ( $foto2H / $targetHeight);
}
else
{
// If the thumbnail is wider than the image
$background2W = $targetWidth;
$background2H = $foto2H / ($foto2W / $targetWidth);
}
$background2 = imagecreatetruecolor( $targetWidth, $targetHeight );
// Resize and crop
imagecopyresampled($background2,
$brandX,
0 - ($background2W - $targetWidth) / 2, // Center the image horizontally
0 - ($background2H - $targetHeight) / 2, // Center the image vertically
0, 0,
$background2W, $background2H,
$foto2W, $foto2H);
return $background2;
}
function arc($x, $y, $width, $height, $start, $end, $color, $thickness = 1) {
// Allocate the color
$color = allocateColor($color);
// Draw an arc
if($thickness === 'filled') {
imagesetthickness($background, 1);
imagefilledarc($background, $x, $y, $width, $height, $start, $end, $color, IMG_ARC_PIE);
} else {
imagesetthickness($background, $thickness);
imagearc($background, $x, $y, $width, $height, $start, $end, $color);
}
return $background;
}
function allocateColor($color) {
$color = normalizeColor($color);
// Was this color already allocated?
$index = imagecolorexactalpha(
$background,
$color['red'],
$color['green'],
$color['blue'],
127 - ($color['alpha'] * 127)
);
if($index > -1) {
// Yes, return this color index
return $index;
}
// Allocate a new color index
return imagecolorallocatealpha(
$background,
$color['red'],
$color['green'],
$color['blue'],
127 - ($color['alpha'] * 127)
);
}
function normalizeColor($color) {
// 140 CSS color names and hex values
$cssColors = [
'aliceblue' => '#f0f8ff', 'antiquewhite' => '#faebd7', 'aqua' => '#00ffff',
'aquamarine' => '#7fffd4', 'azure' => '#f0ffff', 'beige' => '#f5f5dc', 'bisque' => '#ffe4c4',
'black' => '#000000', 'blanchedalmond' => '#ffebcd', 'blue' => '#0000ff',
'blueviolet' => '#8a2be2', 'brown' => '#a52a2a', 'burlywood' => '#deb887',
'cadetblue' => '#5f9ea0', 'chartreuse' => '#7fff00', 'chocolate' => '#d2691e',
'coral' => '#ff7f50', 'cornflowerblue' => '#6495ed', 'cornsilk' => '#fff8dc',
'crimson' => '#dc143c', 'cyan' => '#00ffff', 'darkblue' => '#00008b', 'darkcyan' => '#008b8b',
'darkgoldenrod' => '#b8860b', 'darkgray' => '#a9a9a9', 'darkgrey' => '#a9a9a9',
'darkgreen' => '#006400', 'darkkhaki' => '#bdb76b', 'darkmagenta' => '#8b008b',
'darkolivegreen' => '#556b2f', 'darkorange' => '#ff8c00', 'darkorchid' => '#9932cc',
'darkred' => '#8b0000', 'darksalmon' => '#e9967a', 'darkseagreen' => '#8fbc8f',
'darkslateblue' => '#483d8b', 'darkslategray' => '#2f4f4f', 'darkslategrey' => '#2f4f4f',
'darkturquoise' => '#00ced1', 'darkviolet' => '#9400d3', 'deeppink' => '#ff1493',
'deepskyblue' => '#00bfff', 'dimgray' => '#696969', 'dimgrey' => '#696969',
'dodgerblue' => '#1e90ff', 'firebrick' => '#b22222', 'floralwhite' => '#fffaf0',
'forestgreen' => '#228b22', 'fuchsia' => '#ff00ff', 'gainsboro' => '#dcdcdc',
'ghostwhite' => '#f8f8ff', 'gold' => '#ffd700', 'goldenrod' => '#daa520', 'gray' => '#808080',
'grey' => '#808080', 'green' => '#008000', 'greenyellow' => '#adff2f',
'honeydew' => '#f0fff0', 'hotpink' => '#ff69b4', 'indianred ' => '#cd5c5c',
'indigo ' => '#4b0082', 'ivory' => '#fffff0', 'khaki' => '#f0e68c', 'lavender' => '#e6e6fa',
'lavenderblush' => '#fff0f5', 'lawngreen' => '#7cfc00', 'lemonchiffon' => '#fffacd',
'lightblue' => '#add8e6', 'lightcoral' => '#f08080', 'lightcyan' => '#e0ffff',
'lightgoldenrodyellow' => '#fafad2', 'lightgray' => '#d3d3d3', 'lightgrey' => '#d3d3d3',
'lightgreen' => '#90ee90', 'lightpink' => '#ffb6c1', 'lightsalmon' => '#ffa07a',
'lightseagreen' => '#20b2aa', 'lightskyblue' => '#87cefa', 'lightslategray' => '#778899',
'lightslategrey' => '#778899', 'lightsteelblue' => '#b0c4de', 'lightyellow' => '#ffffe0',
'lime' => '#00ff00', 'limegreen' => '#32cd32', 'linen' => '#faf0e6', 'magenta' => '#ff00ff',
'maroon' => '#800000', 'mediumaquamarine' => '#66cdaa', 'mediumblue' => '#0000cd',
'mediumorchid' => '#ba55d3', 'mediumpurple' => '#9370db', 'mediumseagreen' => '#3cb371',
'mediumslateblue' => '#7b68ee', 'mediumspringgreen' => '#00fa9a',
'mediumturquoise' => '#48d1cc', 'mediumvioletred' => '#c71585', 'midnightblue' => '#191970',
'mintcream' => '#f5fffa', 'mistyrose' => '#ffe4e1', 'moccasin' => '#ffe4b5',
'navajowhite' => '#ffdead', 'navy' => '#000080', 'oldlace' => '#fdf5e6', 'olive' => '#808000',
'olivedrab' => '#6b8e23', 'orange' => '#ffa500', 'orangered' => '#ff4500',
'orchid' => '#da70d6', 'palegoldenrod' => '#eee8aa', 'palegreen' => '#98fb98',
'paleturquoise' => '#afeeee', 'palevioletred' => '#db7093', 'papayawhip' => '#ffefd5',
'peachpuff' => '#ffdab9', 'peru' => '#cd853f', 'pink' => '#ffc0cb', 'plum' => '#dda0dd',
'powderblue' => '#b0e0e6', 'purple' => '#800080', 'rebeccapurple' => '#663399',
'red' => '#ff0000', 'rosybrown' => '#bc8f8f', 'royalblue' => '#4169e1',
'saddlebrown' => '#8b4513', 'salmon' => '#fa8072', 'sandybrown' => '#f4a460',
'seagreen' => '#2e8b57', 'seashell' => '#fff5ee', 'sienna' => '#a0522d',
'silver' => '#c0c0c0', 'skyblue' => '#87ceeb', 'slateblue' => '#6a5acd',
'slategray' => '#708090', 'slategrey' => '#708090', 'snow' => '#fffafa',
'springgreen' => '#00ff7f', 'steelblue' => '#4682b4', 'tan' => '#d2b48c', 'teal' => '#008080',
'thistle' => '#d8bfd8', 'tomato' => '#ff6347', 'turquoise' => '#40e0d0',
'violet' => '#ee82ee', 'wheat' => '#f5deb3', 'white' => '#ffffff', 'whitesmoke' => '#f5f5f5',
'yellow' => '#ffff00', 'yellowgreen' => '#9acd32'
];}
function checkTypeX($layerType)
{
global $link;
switch($layerType){
case "dynamicdate":
/*echo "THIS IS STATIC IMAGE <br>";*/
$check="theDate";
break;
case "dynamictime":
/*echo "THIS IS STATIC IMAGE <br>";*/
$check="theTime";
break;
case "dynamicname":
/*echo "THIS IS STATIC IMAGE <br>";*/
$check="theName";
break;
case "dynamicusername":
/*echo "THIS IS STATIC IMAGE <br>";*/
$check="theUser";
break;
case "dynamicweb":
/*echo "THIS IS STATIC IMAGE <br>";*/
$check="theWeb";
break;
case "dynamicbio":
/*echo "THIS IS STATIC IMAGE <br>";*/
$check="theBio";
break;
case "dynamictime":
/*echo "THIS IS STATIC IMAGE <br>";*/
$check="theTime";
break;
case "dynamicrandom":
/*echo "THIS IS STATIC IMAGE <br>";*/
$check="theRandom";
break;
case "dynamictext":
/* echo "THIS IS DYNAMIC TEXT <br>";*/
$check="theUpdate";
break;
case "dynamicdescription":
/* echo "THIS IS DYNAMIC TEXT <br>";*/
$check="theDescription";
break;
case "dynamicurl":
/* echo "THIS IS DYNAMIC TEXT <br>";*/
$check="theUrl";
break;
case "dynamicuser":
/* echo "THIS IS DYNAMIC TEXT <br>";*/
$check="theUser";
break;
case "dynamicname":
/* echo "THIS IS DYNAMIC TEXT <br>";*/
$check="theName";
break;
case "dynamicplain":
/* echo "THIS IS DYNAMIC TEXT <br>";*/
$check="thePlain";
break;
case "text":
/* echo "THIS IS TEXT <br>";*/
$check="thePlain";
break;
case "image":
/*echo "THIS IS STATIC IMAGE <br>";*/
$check="Uploaded";
break;
case "mood":
/*echo "THIS IS STATIC IMAGE <br>";*/
$check="theMood";
break;
case "staticimage":
/*echo "THIS IS STATIC IMAGE <br>";*/
$check="Uploaded";
break;
case "dynamicprofile":
/*echo "THIS IS STATIC IMAGE <br>";*/
$check="UploadedProfile";
break;
case "staticgraphics":
/* echo "THIS IS STATIC GRAPHICS <br>";*/
$check="theMood";
break;
case "dynamicimage":
/*echo "THIS IS DYNAMIC IMAGE <br>";*/
$check="theDynamicImage";
break;
case "shape":
/* echo "THIS IS TEXT <br>";*/
$check="theShape";
break;
case "3d":
/* echo "THIS IS TEXT <br>";*/
$check="the3D";
break;
default:
break;
}
return $check;
}
function getEachJSONLayer($themeid,$layerPosition)
{
$sql = "select * from layerorder where themeid='$themeid' and type='2' and graphic_order ='$layerPosition' order by graphic_order ASC";
global $link;
$result = mysqli_query($link,$sql) or die(mysql_error());
$row = mysqli_fetch_assoc($result);
/*print_r($row);*/
return $row;
}
function getEachJSONTweets($convoId)
{ global $link;
$sql = "select * from tweets where id='$convoId'";
$rs_settings = mysqli_query($link,"$sql");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$tweetid = $row_settings["tweetid"];
}
$sql = "select tweet from raw_tweets where tweetid='$tweetid'";
$rs_settings = mysqli_query($link,"$sql");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$tweet = $row_settings["tweet"];
}
return $tweet;
}
function getParamJSONTheme($themeid)
{
global $link;
$sql = "select * from profilepicture where id='$themeid' and type='2'";
$result = mysqli_query($link,$sql) or die(mysql_error());
$row = mysqli_fetch_assoc($result);
/*print_r($row);*/
return $row;
}
function imagealphamask( &$background, $mask ) {
// Get sizes and set up new picture
$xSize = imagesx( $background );
$ySize = imagesy( $background );
$newPicture = imagecreatetruecolor( $xSize, $ySize );
imagesavealpha( $newPicture, true );
imagefill( $newPicture, 0, 0, imagecolorallocatealpha( $newPicture, 0, 0, 0, 127 ) );
// Resize mask if necessary
if( $xSize != imagesx( $mask ) || $ySize != imagesy( $mask ) ) {
$tempPic = imagecreatetruecolor( $xSize, $ySize );
imagecopyresampled( $tempPic, $mask, 0, 0, 0, 0, $xSize, $ySize, imagesx( $mask ), imagesy( $mask ) );
imagedestroy( $mask );
$mask = $tempPic;
}
// Perform pixel-based alpha map application
for( $x = 0; $x < $xSize; $x++ ) {
for( $y = 0; $y < $ySize; $y++ ) {
$alpha = imagecolorsforindex( $mask, imagecolorat( $mask, $x, $y ) );
$alpha = 127 - floor( $alpha[ 'red' ] / 2 );
$color = imagecolorsforindex( $background, imagecolorat( $background, $x, $y ) );
imagesetpixel( $newPicture, $x, $y, imagecolorallocatealpha( $newPicture, $color[ 'red' ], $color[ 'green' ], $color[ 'blue' ], $alpha ) );
}
}
$background = $newPicture;
}
function themeDetailsX($type,$themeid)
{
global $link;
$sql = "select * from profilepicture where id='$themeid' order by id DESC LIMIT 0,1";
$rs_settings = mysqli_query($link,"$sql");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$result = strtolower($row_settings["$type"]);
}
return $result;
}
function imagehue(&$background, $angle) {
if($angle % 360 == 0) return;
$width = 600;
$height = 600;
for($x = 0; $x < $width; $x++) {
for($y = 0; $y < $height; $y++) {
$rgb = imagecolorat($background, $x, $y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
$alpha = ($rgb & 0x7F000000) >> 24;
list($h, $s, $l) = rgb2hsl($r, $g, $b);
$h += $angle / 360;
if($h > 1) $h--;
list($r, $g, $b) = hsl2rgb($h, $s, $l);
imagesetpixel($background, $x, $y, imagecolorallocatealpha($background, $r, $g, $b, $alpha));
}
}
}
function rgb2hsl($r, $g, $b) {
$var_R = ($r / 255);
$var_G = ($g / 255);
$var_B = ($b / 255);
$var_Min = min($var_R, $var_G, $var_B);
$var_Max = max($var_R, $var_G, $var_B);
$del_Max = $var_Max - $var_Min;
$v = $var_Max;
if ($del_Max == 0) {
$h = 0;
$s = 0;
} else {
$s = $del_Max / $var_Max;
$del_R = ( ( ( $var_Max - $var_R ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max;
$del_G = ( ( ( $var_Max - $var_G ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max;
$del_B = ( ( ( $var_Max - $var_B ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max;
if ($var_R == $var_Max) $h = $del_B - $del_G;
else if ($var_G == $var_Max) $h = ( 1 / 3 ) + $del_R - $del_B;
else if ($var_B == $var_Max) $h = ( 2 / 3 ) + $del_G - $del_R;
if ($h < 0) $h++;
if ($h > 1) $h--;
}
return array($h, $s, $v);
}
function hsl2rgb($h, $s, $v) {
if($s == 0) {
$r = $g = $B = $v * 255;
} else {
$var_H = $h * 6;
$var_i = floor( $var_H );
$var_1 = $v * ( 1 - $s );
$var_2 = $v * ( 1 - $s * ( $var_H - $var_i ) );
$var_3 = $v * ( 1 - $s * (1 - ( $var_H - $var_i ) ) );
if ($var_i == 0) { $var_R = $v ; $var_G = $var_3 ; $var_B = $var_1 ; }
else if ($var_i == 1) { $var_R = $var_2 ; $var_G = $v ; $var_B = $var_1 ; }
else if ($var_i == 2) { $var_R = $var_1 ; $var_G = $v ; $var_B = $var_3 ; }
else if ($var_i == 3) { $var_R = $var_1 ; $var_G = $var_2 ; $var_B = $v ; }
else if ($var_i == 4) { $var_R = $var_3 ; $var_G = $var_1 ; $var_B = $v ; }
else { $var_R = $v ; $var_G = $var_1 ; $var_B = $var_2 ; }
$r = $var_R * 255;
$g = $var_G * 255;
$B = $var_B * 255;
}
return array($r, $g, $B);
}
function removeslashes($string)
{
global $link;
$string=implode("",explode("\\",$string));
return stripslashes(trim($string));
}
function cleanText($text)
{
global $link;
$text = html_entity_decode($text,ENT_NOQUOTES, "ISO-8859-1");
// http(s)://
$text = preg_replace('|https?://www\.[a-z\.0-9]+|i', '', $text);
$text = preg_replace('|http?://www\.[a-z\.0-9]+|i', '', $text);
// only www.
$text = preg_replace('|www\.[a-z\.0-9]+|i', '', $text);
$text = trim(preg_replace('/\s\s+/', ' ', $text));
$text = preg_replace("/&#?[a-z0-9]{2,8};/i","",$text);
$text = preg_replace('/\s+/', ' ', trim($text));
$text = iconv("UTF-8", "UTF-8//IGNORE", $text);
$text = str_replace(': ', ' ', $text);
$text = preg_replace('/#\S+ */', '', $text);
$text = preg_replace('/@\S+ */', '', $text);
$text = str_replace('RT', ' ', $text);
$text = str_replace('', '', $text);
$text = preg_replace("/&#?[a-z0-9]{2,8};/i","",$text);
$text = trim($text);
$text = str_replace("'", "`", $text);
$text = str_replace('"', "`", $text);
$text = str_replace('', "", $text);
return $text;
}
function checkFont($type,$column,$catalogid,$themeid)
{
global $link;
$sql = "select * from myfonts where catalogid='$catalogid' and themeid='$themeid' and layertype='$type' order by layerid DESC LIMIT 0,1";
global $link;
$rs_settings = mysqli_query($link,"$sql");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$theFont = strtolower($row_settings["font"]);
}
return $theFont;
}
function checkFontX($name,$weight,$style)
{
global $link;
$sql = "select * from brandfonts where name LIKE '%$name%' and weight='$weight' and style='$style' order by fontid DESC LIMIT 0,1";
$rs_settings = mysqli_query($link,"$sql");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$filename = $row_settings["filename"].".ttf";
}
if(empty($filename))
{
$stmt2 ="SELECT * FROM `brandfonts` WHERE name LIKE '%$name%' and isdisplay='3' order by fontid desc limit 1";
global $link;
$query = mysqli_query($link,$stmt2) or die(mysql_error());
$result = mysqli_fetch_array($query);
if(!empty($result['filename']))
{
$filename = $result['filename'].".".$result['type'];};
}
/* if(empty($filename))
{
$extfile = explode('.',$name);
$name = $extfile[0];
$filename = $name;
$titleFont = str_replace("-"," ",$name);
$stmt2 ="SELECT fontid FROM `brandfonts` WHERE filename='$filename' and name='$titleFont' and isdisplay='3' order by fontid desc limit 1";
$query = mysqli_query($stmt2) or die(mysql_error());
$result = mysqli_fetch_array($query);
if (empty($result['fontid'])) {
$stmt = "INSERT INTO `brandfonts` (category,weight,style,name,filename,isdisplay) VALUES ('sans-serif','300','normal','$titleFont','$name','3')";
$query = mysqli_query("$stmt") or die(mysql_error());
$filename = $name;
}
}
*/
return $filename;
}
function multiRequestX($data, $options = array()) {
// array of curl handles
$curly = array();
// data to be returned
$result = array();
// multi handle
$mh = curl_multi_init();
// loop through $data and create curl handles
// then add them to the multi-handle
foreach ($data as $id => $d) {
$curly[$id] = curl_init();
$url = (is_array($d) && !empty($d['url'])) ? $d['url'] : $d;
curl_setopt($curly[$id], CURLOPT_URL, $url);
curl_setopt($curly[$id], CURLOPT_HEADER, 0);
curl_setopt($curly[$id], CURLOPT_RETURNTRANSFER, 1);
// post?
if (is_array($d)) {
if (!empty($d['post'])) {
curl_setopt($curly[$id], CURLOPT_POST, 1);
curl_setopt($curly[$id], CURLOPT_POSTFIELDS, $d['post']);
}
}
// extra options?
if (!empty($options)) {
curl_setopt_array($curly[$id], $options);
}
curl_multi_add_handle($mh, $curly[$id]);
}
// execute the handles
$running = null;
do {
curl_multi_exec($mh, $running);
} while($running > 0);
// get content and remove handles
foreach($curly as $id => $c) {
$result[$id] = curl_multi_getcontent($c);
curl_multi_remove_handle($mh, $c);
}
// all done
curl_multi_close($mh);
return $result;
}
function findSharp($orig, $final)
{
$final = $final * (750.0 / $orig);
$a = 52;
$b = -0.27810650887573124;
$c = .00047337278106508946;
$result = $a + $b * $final + $c * $final * $final;
return max(round($result), 0);
} // findSharp()
// Font Awesome v. 4.6.
function fontAwesome2Graphics($hay){
$arr = array(
'fa-glass' => 'f000',
'fa-music' => 'f001',
'fa-search' => 'f002',
'fa-envelope-o' => 'f003',
'fa-heart' => 'f004',
'fa-star' => 'f005',
'fa-star-o' => 'f006',
'fa-user' => 'f007',
'fa-film' => 'f008',
'fa-th-large' => 'f009',
'fa-th' => 'f00a',
'fa-th-list' => 'f00b',
'fa-check' => 'f00c',
'fa-times' => 'f00d',
'fa-search-plus' => 'f00e',
'fa-search-minus' => 'f010',
'fa-power-off' => 'f011',
'fa-signal' => 'f012',
'fa-cog' => 'f013',
'fa-trash-o' => 'f014',
'fa-home' => 'f015',
'fa-file-o' => 'f016',
'fa-clock-o' => 'f017',
'fa-road' => 'f018',
'fa-download' => 'f019',
'fa-arrow-circle-o-down' => 'f01a',
'fa-arrow-circle-o-up' => 'f01b',
'fa-inbox' => 'f01c',
'fa-play-circle-o' => 'f01d',
'fa-repeat' => 'f01e',
'fa-refresh' => 'f021',
'fa-list-alt' => 'f022',
'fa-lock' => 'f023',
'fa-flag' => 'f024',
'fa-headphones' => 'f025',
'fa-volume-off' => 'f026',
'fa-volume-down' => 'f027',
'fa-volume-up' => 'f028',
'fa-qrcode' => 'f029',
'fa-barcode' => 'f02a',
'fa-tag' => 'f02b',
'fa-tags' => 'f02c',
'fa-book' => 'f02d',
'fa-bookmark' => 'f02e',
'fa-print' => 'f02f',
'fa-camera' => 'f030',
'fa-font' => 'f031',
'fa-bold' => 'f032',
'fa-italic' => 'f033',
'fa-text-height' => 'f034',
'fa-text-width' => 'f035',
'fa-align-left' => 'f036',
'fa-align-center' => 'f037',
'fa-align-right' => 'f038',
'fa-align-justify' => 'f039',
'fa-list' => 'f03a',
'fa-outdent' => 'f03b',
'fa-indent' => 'f03c',
'fa-video-camera' => 'f03d',
'fa-picture-o' => 'f03e',
'fa-pencil' => 'f040',
'fa-map-marker' => 'f041',
'fa-adjust' => 'f042',
'fa-tint' => 'f043',
'fa-pencil-square-o' => 'f044',
'fa-share-square-o' => 'f045',
'fa-check-square-o' => 'f046',
'fa-arrows' => 'f047',
'fa-step-backward' => 'f048',
'fa-fast-backward' => 'f049',
'fa-backward' => 'f04a',
'fa-play' => 'f04b',
'fa-pause' => 'f04c',
'fa-stop' => 'f04d',
'fa-forward' => 'f04e',
'fa-fast-forward' => 'f050',
'fa-step-forward' => 'f051',
'fa-eject' => 'f052',
'fa-chevron-left' => 'f053',
'fa-chevron-right' => 'f054',
'fa-plus-circle' => 'f055',
'fa-minus-circle' => 'f056',
'fa-times-circle' => 'f057',
'fa-check-circle' => 'f058',
'fa-question-circle' => 'f059',
'fa-info-circle' => 'f05a',
'fa-crosshairs' => 'f05b',
'fa-times-circle-o' => 'f05c',
'fa-check-circle-o' => 'f05d',
'fa-ban' => 'f05e',
'fa-arrow-left' => 'f060',
'fa-arrow-right' => 'f061',
'fa-arrow-up' => 'f062',
'fa-arrow-down' => 'f063',
'fa-share' => 'f064',
'fa-expand' => 'f065',
'fa-compress' => 'f066',
'fa-plus' => 'f067',
'fa-minus' => 'f068',
'fa-asterisk' => 'f069',
'fa-exclamation-circle' => 'f06a',
'fa-gift' => 'f06b',
'fa-leaf' => 'f06c',
'fa-fire' => 'f06d',
'fa-eye' => 'f06e',
'fa-eye-slash' => 'f070',
'fa-exclamation-triangle' => 'f071',
'fa-plane' => 'f072',
'fa-calendar' => 'f073',
'fa-random' => 'f074',
'fa-comment' => 'f075',
'fa-magnet' => 'f076',
'fa-chevron-up' => 'f077',
'fa-chevron-down' => 'f078',
'fa-retweet' => 'f079',
'fa-shopping-cart' => 'f07a',
'fa-folder' => 'f07b',
'fa-folder-open' => 'f07c',
'fa-arrows-v' => 'f07d',
'fa-arrows-h' => 'f07e',
'fa-bar-chart' => 'f080',
'fa-twitter-square' => 'f081',
'fa-facebook-square' => 'f082',
'fa-camera-retro' => 'f083',
'fa-key' => 'f084',
'fa-cogs' => 'f085',
'fa-comments' => 'f086',
'fa-thumbs-o-up' => 'f087',
'fa-thumbs-o-down' => 'f088',
'fa-star-half' => 'f089',
'fa-heart-o' => 'f08a',
'fa-sign-out' => 'f08b',
'fa-linkedin-square' => 'f08c',
'fa-thumb-tack' => 'f08d',
'fa-external-link' => 'f08e',
'fa-sign-in' => 'f090',
'fa-trophy' => 'f091',
'fa-github-square' => 'f092',
'fa-upload' => 'f093',
'fa-lemon-o' => 'f094',
'fa-phone' => 'f095',
'fa-square-o' => 'f096',
'fa-bookmark-o' => 'f097',
'fa-phone-square' => 'f098',
'fa-twitter' => 'f099',
'fa-facebook' => 'f09a',
'fa-github' => 'f09b',
'fa-unlock' => 'f09c',
'fa-credit-card' => 'f09d',
'fa-rss' => 'f09e',
'fa-hdd-o' => 'f0a0',
'fa-bullhorn' => 'f0a1',
'fa-bell' => 'f0f3',
'fa-certificate' => 'f0a3',
'fa-hand-o-right' => 'f0a4',
'fa-hand-o-left' => 'f0a5',
'fa-hand-o-up' => 'f0a6',
'fa-hand-o-down' => 'f0a7',
'fa-arrow-circle-left' => 'f0a8',
'fa-arrow-circle-right' => 'f0a9',
'fa-arrow-circle-up' => 'f0aa',
'fa-arrow-circle-down' => 'f0ab',
'fa-globe' => 'f0ac',
'fa-wrench' => 'f0ad',
'fa-tasks' => 'f0ae',
'fa-filter' => 'f0b0',
'fa-briefcase' => 'f0b1',
'fa-arrows-alt' => 'f0b2',
'fa-users' => 'f0c0',
'fa-link' => 'f0c1',
'fa-cloud' => 'f0c2',
'fa-flask' => 'f0c3',
'fa-scissors' => 'f0c4',
'fa-files-o' => 'f0c5',
'fa-paperclip' => 'f0c6',
'fa-floppy-o' => 'f0c7',
'fa-square' => 'f0c8',
'fa-bars' => 'f0c9',
'fa-list-ul' => 'f0ca',
'fa-list-ol' => 'f0cb',
'fa-strikethrough' => 'f0cc',
'fa-underline' => 'f0cd',
'fa-table' => 'f0ce',
'fa-magic' => 'f0d0',
'fa-truck' => 'f0d1',
'fa-pinterest' => 'f0d2',
'fa-pinterest-square' => 'f0d3',
'fa-google-plus-square' => 'f0d4',
'fa-google-plus' => 'f0d5',
'fa-money' => 'f0d6',
'fa-caret-down' => 'f0d7',
'fa-caret-up' => 'f0d8',
'fa-caret-left' => 'f0d9',
'fa-caret-right' => 'f0da',
'fa-columns' => 'f0db',
'fa-sort' => 'f0dc',
'fa-sort-desc' => 'f0dd',
'fa-sort-asc' => 'f0de',
'fa-envelope' => 'f0e0',
'fa-linkedin' => 'f0e1',
'fa-undo' => 'f0e2',
'fa-gavel' => 'f0e3',
'fa-tachometer' => 'f0e4',
'fa-comment-o' => 'f0e5',
'fa-comments-o' => 'f0e6',
'fa-bolt' => 'f0e7',
'fa-sitemap' => 'f0e8',
'fa-umbrella' => 'f0e9',
'fa-clipboard' => 'f0ea',
'fa-lightbulb-o' => 'f0eb',
'fa-exchange' => 'f0ec',
'fa-cloud-download' => 'f0ed',
'fa-cloud-upload' => 'f0ee',
'fa-user-md' => 'f0f0',
'fa-stethoscope' => 'f0f1',
'fa-suitcase' => 'f0f2',
'fa-bell-o' => 'f0a2',
'fa-coffee' => 'f0f4',
'fa-cutlery' => 'f0f5',
'fa-file-text-o' => 'f0f6',
'fa-building-o' => 'f0f7',
'fa-hospital-o' => 'f0f8',
'fa-ambulance' => 'f0f9',
'fa-medkit' => 'f0fa',
'fa-fighter-jet' => 'f0fb',
'fa-beer' => 'f0fc',
'fa-h-square' => 'f0fd',
'fa-plus-square' => 'f0fe',
'fa-angle-double-left' => 'f100',
'fa-angle-double-right' => 'f101',
'fa-angle-double-up' => 'f102',
'fa-angle-double-down' => 'f103',
'fa-angle-left' => 'f104',
'fa-angle-right' => 'f105',
'fa-angle-up' => 'f106',
'fa-angle-down' => 'f107',
'fa-desktop' => 'f108',
'fa-laptop' => 'f109',
'fa-tablet' => 'f10a',
'fa-mobile' => 'f10b',
'fa-circle-o' => 'f10c',
'fa-quote-left' => 'f10d',
'fa-quote-right' => 'f10e',
'fa-spinner' => 'f110',
'fa-circle' => 'f111',
'fa-reply' => 'f112',
'fa-github-alt' => 'f113',
'fa-folder-o' => 'f114',
'fa-folder-open-o' => 'f115',
'fa-smile-o' => 'f118',
'fa-frown-o' => 'f119',
'fa-meh-o' => 'f11a',
'fa-gamepad' => 'f11b',
'fa-keyboard-o' => 'f11c',
'fa-flag-o' => 'f11d',
'fa-flag-checkered' => 'f11e',
'fa-terminal' => 'f120',
'fa-code' => 'f121',
'fa-reply-all' => 'f122',
'fa-star-half-o' => 'f123',
'fa-location-arrow' => 'f124',
'fa-crop' => 'f125',
'fa-code-fork' => 'f126',
'fa-chain-broken' => 'f127',
'fa-question' => 'f128',
'fa-info' => 'f129',
'fa-exclamation' => 'f12a',
'fa-superscript' => 'f12b',
'fa-subscript' => 'f12c',
'fa-eraser' => 'f12d',
'fa-puzzle-piece' => 'f12e',
'fa-microphone' => 'f130',
'fa-microphone-slash' => 'f131',
'fa-shield' => 'f132',
'fa-calendar-o' => 'f133',
'fa-fire-extinguisher' => 'f134',
'fa-rocket' => 'f135',
'fa-maxcdn' => 'f136',
'fa-chevron-circle-left' => 'f137',
'fa-chevron-circle-right' => 'f138',
'fa-chevron-circle-up' => 'f139',
'fa-chevron-circle-down' => 'f13a',
'fa-html5' => 'f13b',
'fa-css3' => 'f13c',
'fa-anchor' => 'f13d',
'fa-unlock-alt' => 'f13e',
'fa-bullseye' => 'f140',
'fa-ellipsis-h' => 'f141',
'fa-ellipsis-v' => 'f142',
'fa-rss-square' => 'f143',
'fa-play-circle' => 'f144',
'fa-ticket' => 'f145',
'fa-minus-square' => 'f146',
'fa-minus-square-o' => 'f147',
'fa-level-up' => 'f148',
'fa-level-down' => 'f149',
'fa-check-square' => 'f14a',
'fa-pencil-square' => 'f14b',
'fa-external-link-square' => 'f14c',
'fa-share-square' => 'f14d',
'fa-compass' => 'f14e',
'fa-caret-square-o-down' => 'f150',
'fa-caret-square-o-up' => 'f151',
'fa-caret-square-o-right' => 'f152',
'fa-eur' => 'f153',
'fa-gbp' => 'f154',
'fa-usd' => 'f155',
'fa-inr' => 'f156',
'fa-jpy' => 'f157',
'fa-rub' => 'f158',
'fa-krw' => 'f159',
'fa-btc' => 'f15a',
'fa-file' => 'f15b',
'fa-file-text' => 'f15c',
'fa-sort-alpha-asc' => 'f15d',
'fa-sort-alpha-desc' => 'f15e',
'fa-sort-amount-asc' => 'f160',
'fa-sort-amount-desc' => 'f161',
'fa-sort-numeric-asc' => 'f162',
'fa-sort-numeric-desc' => 'f163',
'fa-thumbs-up' => 'f164',
'fa-thumbs-down' => 'f165',
'fa-youtube-square' => 'f166',
'fa-youtube' => 'f167',
'fa-xing' => 'f168',
'fa-xing-square' => 'f169',
'fa-youtube-play' => 'f16a',
'fa-dropbox' => 'f16b',
'fa-stack-overflow' => 'f16c',
'fa-instagram' => 'f16d',
'fa-flickr' => 'f16e',
'fa-adn' => 'f170',
'fa-bitbucket' => 'f171',
'fa-bitbucket-square' => 'f172',
'fa-tumblr' => 'f173',
'fa-tumblr-square' => 'f174',
'fa-long-arrow-down' => 'f175',
'fa-long-arrow-up' => 'f176',
'fa-long-arrow-left' => 'f177',
'fa-long-arrow-right' => 'f178',
'fa-apple' => 'f179',
'fa-windows' => 'f17a',
'fa-android' => 'f17b',
'fa-linux' => 'f17c',
'fa-dribbble' => 'f17d',
'fa-skype' => 'f17e',
'fa-foursquare' => 'f180',
'fa-trello' => 'f181',
'fa-female' => 'f182',
'fa-male' => 'f183',
'fa-gratipay' => 'f184',
'fa-sun-o' => 'f185',
'fa-moon-o' => 'f186',
'fa-archive' => 'f187',
'fa-bug' => 'f188',
'fa-vk' => 'f189',
'fa-weibo' => 'f18a',
'fa-renren' => 'f18b',
'fa-pagelines' => 'f18c',
'fa-stack-exchange' => 'f18d',
'fa-arrow-circle-o-right' => 'f18e',
'fa-arrow-circle-o-left' => 'f190',
'fa-caret-square-o-left' => 'f191',
'fa-dot-circle-o' => 'f192',
'fa-wheelchair' => 'f193',
'fa-vimeo-square' => 'f194',
'fa-try' => 'f195',
'fa-plus-square-o' => 'f196',
'fa-space-shuttle' => 'f197',
'fa-slack' => 'f198',
'fa-envelope-square' => 'f199',
'fa-wordpress' => 'f19a',
'fa-openid' => 'f19b',
'fa-university' => 'f19c',
'fa-graduation-cap' => 'f19d',
'fa-yahoo' => 'f19e',
'fa-google' => 'f1a0',
'fa-reddit' => 'f1a1',
'fa-reddit-square' => 'f1a2',
'fa-stumbleupon-circle' => 'f1a3',
'fa-stumbleupon' => 'f1a4',
'fa-delicious' => 'f1a5',
'fa-digg' => 'f1a6',
'fa-pied-piper-pp' => 'f1a7',
'fa-pied-piper-alt' => 'f1a8',
'fa-drupal' => 'f1a9',
'fa-joomla' => 'f1aa',
'fa-language' => 'f1ab',
'fa-fax' => 'f1ac',
'fa-building' => 'f1ad',
'fa-child' => 'f1ae',
'fa-paw' => 'f1b0',
'fa-spoon' => 'f1b1',
'fa-cube' => 'f1b2',
'fa-cubes' => 'f1b3',
'fa-behance' => 'f1b4',
'fa-behance-square' => 'f1b5',
'fa-steam' => 'f1b6',
'fa-steam-square' => 'f1b7',
'fa-recycle' => 'f1b8',
'fa-car' => 'f1b9',
'fa-taxi' => 'f1ba',
'fa-tree' => 'f1bb',
'fa-spotify' => 'f1bc',
'fa-deviantart' => 'f1bd',
'fa-soundcloud' => 'f1be',
'fa-database' => 'f1c0',
'fa-file-pdf-o' => 'f1c1',
'fa-file-word-o' => 'f1c2',
'fa-file-excel-o' => 'f1c3',
'fa-file-powerpoint-o' => 'f1c4',
'fa-file-image-o' => 'f1c5',
'fa-file-archive-o' => 'f1c6',
'fa-file-audio-o' => 'f1c7',
'fa-file-video-o' => 'f1c8',
'fa-file-code-o' => 'f1c9',
'fa-vine' => 'f1ca',
'fa-codepen' => 'f1cb',
'fa-jsfiddle' => 'f1cc',
'fa-life-ring' => 'f1cd',
'fa-circle-o-notch' => 'f1ce',
'fa-rebel' => 'f1d0',
'fa-empire' => 'f1d1',
'fa-git-square' => 'f1d2',
'fa-git' => 'f1d3',
'fa-hacker-news' => 'f1d4',
'fa-tencent-weibo' => 'f1d5',
'fa-qq' => 'f1d6',
'fa-weixin' => 'f1d7',
'fa-paper-plane' => 'f1d8',
'fa-paper-plane-o' => 'f1d9',
'fa-history' => 'f1da',
'fa-circle-thin' => 'f1db',
'fa-header' => 'f1dc',
'fa-paragraph' => 'f1dd',
'fa-sliders' => 'f1de',
'fa-share-alt' => 'f1e0',
'fa-share-alt-square' => 'f1e1',
'fa-bomb' => 'f1e2',
'fa-futbol-o' => 'f1e3',
'fa-tty' => 'f1e4',
'fa-binoculars' => 'f1e5',
'fa-plug' => 'f1e6',
'fa-slideshare' => 'f1e7',
'fa-twitch' => 'f1e8',
'fa-yelp' => 'f1e9',
'fa-newspaper-o' => 'f1ea',
'fa-wifi' => 'f1eb',
'fa-calculator' => 'f1ec',
'fa-paypal' => 'f1ed',
'fa-google-wallet' => 'f1ee',
'fa-cc-visa' => 'f1f0',
'fa-cc-mastercard' => 'f1f1',
'fa-cc-discover' => 'f1f2',
'fa-cc-amex' => 'f1f3',
'fa-cc-paypal' => 'f1f4',
'fa-cc-stripe' => 'f1f5',
'fa-bell-slash' => 'f1f6',
'fa-bell-slash-o' => 'f1f7',
'fa-trash' => 'f1f8',
'fa-copyright' => 'f1f9',
'fa-at' => 'f1fa',
'fa-eyedropper' => 'f1fb',
'fa-paint-brush' => 'f1fc',
'fa-birthday-cake' => 'f1fd',
'fa-area-chart' => 'f1fe',
'fa-pie-chart' => 'f200',
'fa-line-chart' => 'f201',
'fa-lastfm' => 'f202',
'fa-lastfm-square' => 'f203',
'fa-toggle-off' => 'f204',
'fa-toggle-on' => 'f205',
'fa-bicycle' => 'f206',
'fa-bus' => 'f207',
'fa-ioxhost' => 'f208',
'fa-angellist' => 'f209',
'fa-cc' => 'f20a',
'fa-ils' => 'f20b',
'fa-meanpath' => 'f20c',
'fa-buysellads' => 'f20d',
'fa-connectdevelop' => 'f20e',
'fa-dashcube' => 'f210',
'fa-forumbee' => 'f211',
'fa-leanpub' => 'f212',
'fa-sellsy' => 'f213',
'fa-shirtsinbulk' => 'f214',
'fa-simplybuilt' => 'f215',
'fa-skyatlas' => 'f216',
'fa-cart-plus' => 'f217',
'fa-cart-arrow-down' => 'f218',
'fa-diamond' => 'f219',
'fa-ship' => 'f21a',
'fa-user-secret' => 'f21b',
'fa-motorcycle' => 'f21c',
'fa-street-view' => 'f21d',
'fa-heartbeat' => 'f21e',
'fa-venus' => 'f221',
'fa-mars' => 'f222',
'fa-mercury' => 'f223',
'fa-transgender' => 'f224',
'fa-transgender-alt' => 'f225',
'fa-venus-double' => 'f226',
'fa-mars-double' => 'f227',
'fa-venus-mars' => 'f228',
'fa-mars-stroke' => 'f229',
'fa-mars-stroke-v' => 'f22a',
'fa-mars-stroke-h' => 'f22b',
'fa-neuter' => 'f22c',
'fa-genderless' => 'f22d',
'fa-facebook-official' => 'f230',
'fa-pinterest-p' => 'f231',
'fa-whatsapp' => 'f232',
'fa-server' => 'f233',
'fa-user-plus' => 'f234',
'fa-user-times' => 'f235',
'fa-bed' => 'f236',
'fa-viacoin' => 'f237',
'fa-train' => 'f238',
'fa-subway' => 'f239',
'fa-medium' => 'f23a',
'fa-y-combinator' => 'f23b',
'fa-optin-monster' => 'f23c',
'fa-opencart' => 'f23d',
'fa-expeditedssl' => 'f23e',
'fa-battery-full' => 'f240',
'fa-battery-three-quarters' => 'f241',
'fa-battery-half' => 'f242',
'fa-battery-quarter' => 'f243',
'fa-battery-empty' => 'f244',
'fa-mouse-pointer' => 'f245',
'fa-i-cursor' => 'f246',
'fa-object-group' => 'f247',
'fa-object-ungroup' => 'f248',
'fa-sticky-note' => 'f249',
'fa-sticky-note-o' => 'f24a',
'fa-cc-jcb' => 'f24b',
'fa-cc-diners-club' => 'f24c',
'fa-clone' => 'f24d',
'fa-balance-scale' => 'f24e',
'fa-hourglass-o' => 'f250',
'fa-hourglass-start' => 'f251',
'fa-hourglass-half' => 'f252',
'fa-hourglass-end' => 'f253',
'fa-hourglass' => 'f254',
'fa-hand-rock-o' => 'f255',
'fa-hand-paper-o' => 'f256',
'fa-hand-scissors-o' => 'f257',
'fa-hand-lizard-o' => 'f258',
'fa-hand-spock-o' => 'f259',
'fa-hand-pointer-o' => 'f25a',
'fa-hand-peace-o' => 'f25b',
'fa-trademark' => 'f25c',
'fa-registered' => 'f25d',
'fa-creative-commons' => 'f25e',
'fa-gg' => 'f260',
'fa-gg-circle' => 'f261',
'fa-tripadvisor' => 'f262',
'fa-odnoklassniki' => 'f263',
'fa-odnoklassniki-square' => 'f264',
'fa-get-pocket' => 'f265',
'fa-wikipedia-w' => 'f266',
'fa-safari' => 'f267',
'fa-chrome' => 'f268',
'fa-firefox' => 'f269',
'fa-opera' => 'f26a',
'fa-internet-explorer' => 'f26b',
'fa-television' => 'f26c',
'fa-contao' => 'f26d',
'fa-500px' => 'f26e',
'fa-amazon' => 'f270',
'fa-calendar-plus-o' => 'f271',
'fa-calendar-minus-o' => 'f272',
'fa-calendar-times-o' => 'f273',
'fa-calendar-check-o' => 'f274',
'fa-industry' => 'f275',
'fa-map-pin' => 'f276',
'fa-map-signs' => 'f277',
'fa-map-o' => 'f278',
'fa-map' => 'f279',
'fa-commenting' => 'f27a',
'fa-commenting-o' => 'f27b',
'fa-houzz' => 'f27c',
'fa-vimeo' => 'f27d',
'fa-black-tie' => 'f27e',
'fa-fonticons' => 'f280',
'fa-reddit-alien' => 'f281',
'fa-edge' => 'f282',
'fa-credit-card-alt' => 'f283',
'fa-codiepie' => 'f284',
'fa-modx' => 'f285',
'fa-fort-awesome' => 'f286',
'fa-usb' => 'f287',
'fa-product-hunt' => 'f288',
'fa-mixcloud' => 'f289',
'fa-scribd' => 'f28a',
'fa-pause-circle' => 'f28b',
'fa-pause-circle-o' => 'f28c',
'fa-stop-circle' => 'f28d',
'fa-stop-circle-o' => 'f28e',
'fa-shopping-bag' => 'f290',
'fa-shopping-basket' => 'f291',
'fa-hashtag' => 'f292',
'fa-bluetooth' => 'f293',
'fa-bluetooth-b' => 'f294',
'fa-percent' => 'f295',
'fa-gitlab' => 'f296',
'fa-wpbeginner' => 'f297',
'fa-wpforms' => 'f298',
'fa-envira' => 'f299',
'fa-universal-access' => 'f29a',
'fa-wheelchair-alt' => 'f29b',
'fa-question-circle-o' => 'f29c',
'fa-blind' => 'f29d',
'fa-audio-description' => 'f29e',
'fa-volume-control-phone' => 'f2a0',
'fa-braille' => 'f2a1',
'fa-assistive-listening-systems' => 'f2a2',
'fa-american-sign-language-interpreting' => 'f2a3',
'fa-deaf' => 'f2a4',
'fa-glide' => 'f2a5',
'fa-glide-g' => 'f2a6',
'fa-sign-language' => 'f2a7',
'fa-low-vision' => 'f2a8',
'fa-viadeo' => 'f2a9',
'fa-viadeo-square' => 'f2aa',
'fa-snapchat' => 'f2ab',
'fa-snapchat-ghost' => 'f2ac',
'fa-snapchat-square' => 'f2ad',
'fa-pied-piper' => 'f2ae',
'fa-first-order' => 'f2b0',
'fa-yoast' => 'f2b1',
'fa-themeisle' => 'f2b2',
'fa-google-plus-official' => 'f2b3',
'fa-font-awesome' => 'f2b4'
);
if(array_key_exists('fa-snapchat',$arr)) {
$value = $arr["$hay"];
}
else {
$value = '';
}
return $value;
}
function
WriteCaption($background,$text_size,$text_color,$text_color,$text_line_height,$text_align,$angle,$underline,$font_Text,$backgroundWidth,$backgroundHeight,$layer_y,$text_pad,$backgroundColor,$layer_x,$text)
{ $re = '/\*\S+\s*/';
$text = preg_replace($re, '', $text);
$lines=array();
$backgroundColor='transparent';
$elements = "v/uploads/text/name.png";
$saveImage ="0";
if($angle == 0){}else{$text_line_height=-30; $layer_y=$layer_y+110; $layer_x=$layer_x-10;}
$lines=array();
$wordSizeArray=array();
$arrWords=explode(" ", $text);
foreach($arrWords as $word){
$wordSize=imagettfbbox($text_size, $angle, $font_Text, $word. " ");
$wordWidth=abs($wordSize[0])+abs($wordSize[2]);
$wordSizeArray[]=array('word'=>$word, 'size'=>$wordWidth);
}
$line='';
$lineWidth=0;
foreach($wordSizeArray as $wordDetail){
$word=$wordDetail['word'];
$wordWidth=$wordDetail['size'];
$lineWidth+=$wordWidth;
if($lineWidth<$backgroundWidth-($text_pad*2)){
$line.= ' ' . $word;
}else{
$line.= "\n" . $word;
$lineWidth=$wordWidth;
}
}
$lines = explode("\n",$line);
if($text_line_height == 0){
if($underline){
$text_line_height = $text_size + ($text_size*80/100);
}else{
$text_line_height = $text_size + ($text_size*60/100);
}
}
$startYPosition = $text_size+1;
list($text_colorRed, $text_colorBlue, $text_colorGreen) = hex2rgb($text_color);
if($backgroundHeight==0){
$backgroundHeight = $text_line_height * count($lines) + ($text_pad*2);
}
$text_color = imagecolorallocate($background, $text_colorRed, $text_colorBlue, $text_colorGreen);
$lineNumber=1;
foreach($lines as $line){
$line=trim($line);
list($xBLeft, $yBLeft, $xBRight, $yBRight, $xTRight, $yTRight, $xTLeft, $yTLeft) = imagettfbbox($text_size, $angle, $font_Text, $line);
$lineWidth = abs($xBLeft) + abs($xBRight);
switch ($text_align) {
case 'left':
$startXPosition = abs($xBottomLeft) + $text_pad;
break;
case 'right':
$startXPosition = $backgroundWidth - $lineWidth - 1 - $text_pad;
break;
case 'center':
$startXPosition = ($backgroundWidth - $lineWidth) / 2;
break;
default:
$startXPosition = abs($xBottomLeft);
break;
}
if($lineNumber==1 && $text_pad>0){
$startYPosition+=$text_pad;
}
imagettftext($background, $text_size, $angle, $startXPosition+$layer_x, $startYPosition+$layer_y, $text_color, $font_Text, $line);
if ($underline==1) {
$underlineY=$startYPosition+$layer_y+5;
imagesetthickness($background, 4);
imageline($background, $startXPosition+$layer_x, $underlineY, $startXPosition+50+$backgroundWidth, $underlineY, $text_color);
}
$startYPosition+=$text_line_height;
$lineNumber++;
}
return $background;
}
function underline($startXPosition, $lineWidth){
if ($underline) {
$underlineY=$startYPosition+5;
imagesetthickness($background, 2);
imageline($background, $startXPosition, $underlineY, $startXPosition+$lineWidth, $underlineY, $font_color);
}
}
function hex2rgb($hex) {
$hex = str_replace("#", "", $hex);
if (strlen($hex) == 3) {
$r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1));
$g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1));
$b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1));
} else {
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
}
$rgb = array($r, $g, $b);
return $rgb;
}
function pr($str){
echo "<pre>";
print_r($str);
echo "</pre>";
}
function gd_apply_overlay_layers($background, $brand, $amount,$x,$y,$url)
{
global $link;
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
switch ($ext)
{
case '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
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'png':
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$doSharpen = FALSE;
break;
}
$width =600;$height =600;
$photoFrame2 = imagecreatetruecolor($width, $height);
imagealphablending($photoFrame2, false);
imagesavealpha($photoFrame2, true);
$trans_colour = imagecolorallocatealpha($photoFrame2, 0, 0, 0, 127);
imagefilledrectangle($photoFrame2, 0, 0, $width, $height, $trans_colour);
$brand = $url . $brand . '';
$photo2 = $creationFunction($brand);
imagecopyresampled($photoFrame2, $photo2, 0, 0, 0,0, $width, $height, $width, $height);
$photoFrame = imagecreatetruecolor($width, $height);
imagecopy($photoFrame, $background, 0, 0, 0, 0, $width, $height);
imagecopy($photoFrame, $photoFrame2, 0, 0, 0, 0, $width, $height);
imagecopymerge($background, $photoFrame, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($photoFrame);
return $background;
}
function checkType($brand)
{
global $link;
if (strpos($brand, 'route=theUpdate') !== false){$type = "theUpdate" ; }
if (strpos($brand, 'route=thePlain') !== false){$type = "thePlain" ; }
if (strpos($brand, 'route=theUrl') !== false){$type = "theUrl" ; }
if (strpos($brand, 'route=theName') !== false){$type = "theName" ; }
if (strpos($brand, 'route=profile') !== false){$type = "theProfile" ; }
if (strpos($brand, 'route=theUser') !== false){$type = "theUser" ; }
if (strpos($brand, 'route=theGraphics') !== false){$type = "theGraphics" ; }
if (strpos($brand, '/filters/mood/') !== false){$type = "theGraphics" ; }
if (strpos($brand, 'route=profilePic') !== false){$type = "ProfilePic" ; }
if (strpos($brand, 'v/uploads/gthumbs') !== false){$type = "Uploaded" ; }
return $type;
}
/** Apply a PNG overlay */
function gd_apply_effect($background, $brand, $amount)
{
global $link;
if ($_GET['action']=="cards")
{
$width = 640; $height = 430;
}
else
{
if (!empty($_GET['description']))
{
$width = 640; $height = 400;
}
else
{
$width = 600; $height = 666;
}
}
// Get the size and MIME type of the requested image
/*$size = GetImageSize($docRoot . $image);
$mime = $size['mime'];*/
$photoFrame2 = imagecreatetruecolor($width, $height);
imagealphablending($photoFrame2, false);
imagesavealpha($photoFrame2, true);
$trans_colour = imagecolorallocatealpha($photoFrame2, 0, 0, 0, 127);
imagefilledrectangle($photoFrame2, 0, 0, $width, $height, $trans_colour);
$mag = $brand;
$brand = 'filters/effects/' . $brand . '.png';
$photo2 = imagecreatefrompng($brand);
/*include("mags/switch.php"); */
imagecopyresampled($photoFrame2, $photo2, 0, 0, 0,0, $width, $height, $width, $height);
$photoFrame = imagecreatetruecolor($width, $height);
imagecopy($photoFrame, $background, 0, 0, 0, 0, $width, $height);
imagecopy($photoFrame, $photoFrame2, 0, 0, 0, 0, $width, $height);
imagecopymerge($background, $photoFrame, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($photoFrame);
return $background;
}
/** Apply a PNG overlay */
/** Apply a PNG overlay */
function gd_apply_overlay($background, $brand, $amount)
{
global $link;
if ($_GET['action']=="cards")
{
$width = 640; $height = 430;
}
else
{
if (!empty($_GET['description']))
{
$width = 640; $height = 400;
}
else
{
$width = 600; $height = 666;
}
}
// Get the size and MIME type of the requested image
/*$size = GetImageSize($docRoot . $image);
$mime = $size['mime'];*/
$photoFrame2 = imagecreatetruecolor($width, $height);
imagealphablending($photoFrame2, false);
imagesavealpha($photoFrame2, true);
$trans_colour = imagecolorallocatealpha($photoFrame2, 0, 0, 0, 127);
imagefilledrectangle($photoFrame2, 0, 0, $width, $height, $trans_colour);
$mag = $brand;
$brand = 'filters/mood/' . $brand . '.png';
$photo2 = imagecreatefrompng($brand);
/*include("mags/switch.php"); */
imagecopyresampled($photoFrame2, $photo2, 0, 0, 0,0, $width, $height, $width, $height);
$photoFrame = imagecreatetruecolor($width, $height);
imagecopy($photoFrame, $background, 0, 0, 0, 0, $width, $height);
imagecopy($photoFrame, $photoFrame2, 0, 0, 0, 0, $width, $height);
imagecopymerge($background, $photoFrame, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($photoFrame);
return $background;
}
/** Apply a PNG overlay */
function gd_apply_url($background, $newUrl, $amount,$x,$y,$w,$h)
{
global $link;
$picture = basename($newUrl);
$picture = explode('.',$picture);
$ext = strtolower($picture[1]);
switch ($ext)
{
case '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
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'png':
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$doSharpen = FALSE;
break;
}
$source_img = $creationFunction($newUrl); //Create a copy of our image for our thumbnails...
$new_w = 600;
$new_h = 600;
$orig_w = imagesx($source_img);
$orig_h = imagesy($source_img);
$w_ratio = ($new_w / $orig_w);
$h_ratio = ($new_h / $orig_h);
if ($orig_w > $orig_h ) {//landscape
$crop_w = round($orig_w * $h_ratio);
$crop_h = $new_h;
$src_x = ceil( ( $orig_w - $orig_h ) / 2 );
$src_y = 0;
} elseif ($orig_w < $orig_h ) {//portrait
$crop_h = round($orig_h * $w_ratio);
$crop_w = $new_w;
$src_x = 0;
$src_y = ceil( ( $orig_h - $orig_w ) / 2 );
} else {//square
$crop_w = $new_w;
$crop_h = $new_h;
$src_x = 0;
$src_y = 0;
}
$dest_img = imagecreatetruecolor($new_w,$new_h);
imagecopyresampled($background, $source_img, 0 , 0 , $src_x, $src_y, $crop_w, $crop_h, $orig_w, $orig_h);
return $background;
}
function applygrid($gridWidth,$gridHeight,$width,$height)
{
global $link;
$black = imagecolorallocate($background, 255, 255, 255);
imagesetthickness($background, 1);
$cellWidth = ($width - 1) / $gridWidth; // note: -1 to avoid writting
$cellHeight = ($height - 1) / $gridHeight; // a pixel outside the image
for ($x = 0; ($x <= $gridWidth); $x++)
{
for ($y = 0; ($y <= $gridHeight); $y++)
{
imageline($background, ($x * $cellWidth), 0, ($x * $cellWidth), $height, $black);
imageline($background, 0, ($y * $cellHeight), $width, ($y * $cellHeight), $black);
}
}
return $background;
}
function gd_apply_newpic($background, $newPic, $amount,$x,$y,$w,$h)
{
global $link;
/* if (!empty($_GET['newPic']))
{
$newPic = $_GET['newPic'];
$background = gd_apply_logo($background,$newPic, 100,$x,$y,$w,$h);
}
*/
$width = 600; $height = 600;
// Get the size and MIME type of the requested image
/*$size = GetImageSize($docRoot . $image);
$mime = $size['mime'];*/
if(!empty($_GET['width'])){
$newWidth= $_GET['width'];
$width = $newWidth; $height = $newWidth;
}
$photoFrame2 = imagecreatetruecolor($width, $height);
imagealphablending($photoFrame2, false);
imagesavealpha($photoFrame2, true);
$trans_colour = imagecolorallocatealpha($photoFrame2, 0, 0, 0, 127);
imagefilledrectangle($photoFrame2, 0, 0, $width, $height, $trans_colour);
$mag = $newPic;
$picture = basename($newPic);
$picture = explode('.',$picture);
$ext = strtolower($picture[1]);
switch ($ext)
{
case '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
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'png':
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$doSharpen = FALSE;
break;
}
if (strpos($newPic, 'http') !== false || strpos($newPic, 'https') !== false) {
}
else
{
$newPic = 'v/uploads/gthumbs/' . $newPic;
}
$photo2 = $creationFunction($newPic);
/*include("mags/switch.php"); */
/*if($w > 600){$w=600;}*/
imagecopyresampled($photoFrame2, $photo2, $x, $y, 0,0, $w, $h, $width, $height);
$photoFrame = imagecreatetruecolor($width, $height);
imagecopy($photoFrame, $background, 0, 0, 0, 0, $width, $height);
imagecopy($photoFrame, $photoFrame2, 0, 0, 0, 0, $width, $height);
imagecopymerge($background, $photoFrame, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($photoFrame);
return $background;
}
function gd_apply_logo($background, $brand, $amount,$x,$y,$w,$h)
{
global $link;
/* if (!empty($_GET['newPic']))
{
$newPic = $_GET['newPic'];
$background = gd_apply_logo($background,$newPic, 100,$x,$y,$w,$h);
}
*/
$width = 600; $height = 600;
if(!empty($_GET['width'])){
$newWidth= $_GET['width'];
$brand_width = $newWidth;
$brand_height = $newWidth;
$width = $newWidth;
$height = $newWidth;
}
// Get the size and MIME type of the requested image
/*$size = GetImageSize($docRoot . $image);
$mime = $size['mime'];*/
$photoFrame2 = imagecreatetruecolor($width, $height);
imagealphablending($photoFrame2, false);
imagesavealpha($photoFrame2, true);
$trans_colour = imagecolorallocatealpha($photoFrame2, 0, 0, 0, 127);
imagefilledrectangle($photoFrame2, 0, 0, $width, $height, $trans_colour);
$mag = $brand;
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
switch ($ext)
{
case '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
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'png':
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$doSharpen = FALSE;
break;
}
$brand = 'v/uploads/gthumbs/' . $brand;
$photo2 = $creationFunction($brand);
/*include("mags/switch.php"); */
imagecopyresampled($photoFrame2, $photo2, $x, $y, 0,0, $w, $h, $width, $height);
$photoFrame = imagecreatetruecolor($width, $height);
imagecopy($photoFrame, $background, 0, 0, 0, 0, $width, $height);
imagecopy($photoFrame, $photoFrame2, 0, 0, 0, 0, $width, $height);
imagecopymerge($background, $photoFrame, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($photoFrame);
return $background;
}
/** Apply a PNG overlay */
function button($x,$y,$left, $top, $padding_x, $padding_y, $color, $opacity, $corner_radius, $text, $text_color,$background,$font,$fontsize,$fontadjust){
list($lefted,, $righted) = imageftbbox($fontsize, 0, "$font", "$text");
/*$width = ($righted - $lefted) + (2*$padding_x);*/
$width = ($righted - $lefted) + (2*$padding_x);
$width=$width-6;
/* $width = $left + strlen($text)*9 + 2*$padding_x; */
$height = $top + $fontadjust + 2*$padding_y;
if(substr($color, 0, 1) == "#"){
$color = substr($color, 1);
}
$width= $width+$padding_x;
$r = substr($color,0,2);
$g = substr($color,2,2);
$b = substr($color,4,2);
$r = hexdec($r);
$g = hexdec($g);
$b = hexdec($b);
if(substr($text_color, 0, 1) == "#"){
$text_color = substr($text_color, 1);
}
$text_r = substr($text_color,0,2);
$text_g = substr($text_color,2,2);
$text_b = substr($text_color,4,2);
$text_r = hexdec($text_r);
$text_g = hexdec($text_g);
$text_b = hexdec($text_b);
$opacity = (100 - $opacity)/100 * 127;
$bg = imagecreatetruecolor($left + $width, $top + $height);
imagesavealpha($bg, true);
$trans_color = imagecolorallocatealpha($bg, 0, 0, 0, 127);
imagefill($bg, 0, 0, $trans_color);
$rectangle_color = imagecolorallocatealpha($bg, $r, $g, $b, $opacity);
$points_array = array(
$left, $top + $corner_radius, //starting from top left corner before radius
$left + $corner_radius - cos(deg2rad(22.5))*$corner_radius, $top + $corner_radius - sin(deg2rad(22.5))*$corner_radius,
$left + $corner_radius - cos(deg2rad(45))*$corner_radius, $top + $corner_radius - sin(deg2rad(45))*$corner_radius,
$left + $corner_radius - cos(deg2rad(67.5))*$corner_radius, $top + $corner_radius - sin(deg2rad(67.5))*$corner_radius,
$left + $corner_radius, $top,
$left + $width - $corner_radius, $top,
$left + $width - $corner_radius + cos(deg2rad(67.5))*$corner_radius, $top + $corner_radius - sin(deg2rad(67.5))*$corner_radius,
$left + $width - $corner_radius + cos(deg2rad(45))*$corner_radius, $top + $corner_radius - sin(deg2rad(45))*$corner_radius,
$left + $width - $corner_radius + cos(deg2rad(22.5))*$corner_radius, $top + $corner_radius - sin(deg2rad(22.5))*$corner_radius,
$left + $width, $top + $corner_radius,
$left + $width, $top + $height - $corner_radius,
$left + $width - $corner_radius + cos(deg2rad(22.5))*$corner_radius, $top + $height - $corner_radius + sin(deg2rad(22.5))*$corner_radius,
$left + $width - $corner_radius + cos(deg2rad(45))*$corner_radius, $top + $height - $corner_radius + sin(deg2rad(45))*$corner_radius,
$left + $width - $corner_radius + cos(deg2rad(67.5))*$corner_radius, $top + $height - $corner_radius + sin(deg2rad(67.5))*$corner_radius,
$left + $width - $corner_radius, $top + $height,
$left + $corner_radius, $top + $height,
$left + $corner_radius - cos(deg2rad(67.5))*$corner_radius, $top + $height - $corner_radius + sin(deg2rad(67.5))*$corner_radius,
$left + $corner_radius - cos(deg2rad(45))*$corner_radius, $top + $height - $corner_radius + sin(deg2rad(45))*$corner_radius,
$left + $corner_radius - cos(deg2rad(22.5))*$corner_radius, $top + $height - $corner_radius + sin(deg2rad(22.5))*$corner_radius,
$left, $top + $height - $corner_radius
);
$rectangle = imagefilledpolygon($bg, $points_array, 20, $rectangle_color);
$text_color = imagecolorallocatealpha($bg, $text_r, $text_g, $text_b, 0);
imagettftext($bg, $fontsize, 0, $left + $padding_x, $top + $fontadjust + $padding_y, $text_color, $font, $text);
imagecopy($background, $bg, $x,$y, 0, 0, $corner_radius+ $width, $corner_radius + $height);
return $background;
}
function gd_apply_graphics($background, $brand, $amount,$x,$y,$w,$h,$layer_r)
{
$mag = $brand;
$brand = basename($brand);
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
switch ($ext)
{
case '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
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'png':
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$doSharpen = FALSE;
break;
}
$background2Rotation = (180+$layer_r) + 180;
$brand = 'v/uploads/layouts/' . $brand;
$brand = $creationFunction($brand);
$foto2W = imagesx($brand);
$foto2H = imagesy($brand);
$background2W = $w;
$background2H = $h;
$background2TOP = $y;
$background2LEFT= $x;
$background2 = imagecreatetruecolor($background2W,$background2H);
$trans_colour = imagecolorallocatealpha($background2, 0, 0, 0, 127);
imagefill($background2, 0, 0, $trans_colour);
imagecopyresampled($background2, $brand, 0, 0, 0, 0, $background2W, $background2H, $foto2W, $foto2H);
$background2 = imagerotate($background2,$background2Rotation, -1,0);
/*after rotating calculate the difference of new height/width with the one before*/
$extraTop =(imagesy($background2)-$background2H)/2;
$extraLeft =(imagesx($background2)-$background2W)/2;
imagecopy($background, $background2,$background2LEFT-$extraLeft, $background2TOP-$extraTop, 0, 0, imagesx($background2), imagesy($background2));
/*$amount = transparency($amount);*/
/*imagecopymerge($background, $background2,$background2LEFT-$extraLeft, $background2TOP-$extraTop, 0, 0, imagesx($background2), imagesy($background2),$amount);*/
return $background;
}
function gd_apply_3D($fromTop,$fromLeft,$background, $brand, $amount,$x,$y,$w,$h,$layer_r,$letterwidth,$letterheight,$documentW,$documentH)
{
global $link;
$mag = $brand;
$brand = basename($brand);
/* exit("monte carlo $brand");*/
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
switch ($ext)
{
case '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
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'png':
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$doSharpen = FALSE;
break;
}
$background2Rotation = (180+$layer_r) + 180;
$brand = 'v/uploads/3DFonts/' . $brand;
$brand = $creationFunction($brand);
$foto2W = imagesx($brand);
$foto2H = imagesy($brand);
$background2W = $w;
$background2H = $h;
$background2TOP = $y;
$background2LEFT= $x;
$background2 = imagecreatetruecolor($documentW,$documentH);
$trans_colour = imagecolorallocatealpha($background2, 0, 0, 0, 127);
imagefill($background2, 0, 0, $trans_colour);
imagecopyresampled($background2, $brand, 0, 0, 0, 0, $background2W, $background2H, $documentW, $documentH);
imagecopy($background, $background2,$fromLeft, $fromTop, $x, $y, $letterwidth, $letterheight);
/*$amount = transparency($amount);*/
/*imagecopymerge($background, $background2,$background2LEFT-$extraLeft, $background2TOP-$extraTop, 0, 0, imagesx($background2), imagesy($background2),$amount);*/
return $background;
}
function transparency($value)
{
global $link;
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:
$value ="100";
}
return $value;
}
/** Apply a PNG overlay */
/** Apply a PNG overlay */
function gd_apply_overlay2($background, $brand, $amount,$x,$y)
{
global $link;
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
switch ($ext)
{
case '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
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'png':
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$doSharpen = FALSE;
break;
}
$width =600;$height =600;
$photoFrame2 = imagecreatetruecolor($width, $height);
imagealphablending($photoFrame2, TRUE);
imagesavealpha($photoFrame2, true);
$trans_colour = imagecolorallocatealpha($photoFrame2, 0, 0, 0, 127);
imagefilledrectangle($photoFrame2, 0, 0, $width, $height, $trans_colour);
$brand = 'v/uploads/gthumbs/' . $brand . '';
$photo2 = $creationFunction($brand);
imagecopyresampled($photoFrame2, $photo2, 0, 0, 0,0, $width, $height, $width, $height);
$photoFrame = imagecreatetruecolor($width, $height);
imagecopy($photoFrame, $background, 0, 0, 0, 0, $width, $height);
imagecopy($photoFrame, $photoFrame2, 0, 0, 0, 0, $width, $height);
imagecopymerge($background, $photoFrame, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($photoFrame);
return $background;
}
function gd_apply_overlay4($background, $brand, $amount)
{
global $link;
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
switch ($ext)
{
case '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
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'png':
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$doSharpen = FALSE;
break;
}
$width =600;$height =600;
$photoFrame2 = imagecreatetruecolor($width, $height);
imagealphablending($photoFrame2, false);
imagesavealpha($photoFrame2, true);
$trans_colour = imagecolorallocatealpha($photoFrame2, 0, 0, 0, 127);
imagefilledrectangle($photoFrame2, 0, 0, $width, $height, $trans_colour);
$brand = 'v/uploads/gthumbs/' . $brand . '';
$photo2 = $creationFunction($brand);
imagecopyresampled($photoFrame2, $photo2, 0, 0, 0,0, $width, $height, $width, $height);
$photoFrame = imagecreatetruecolor($width, $height);
imagecopy($photoFrame, $background, 0, 0, 0, 0, $width, $height);
imagecopy($photoFrame, $photoFrame2, 0, 0, 0, 0, $width, $height);
imagecopymerge($background, $photoFrame, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($photoFrame);
return $background;
}
function gd_apply_graphic_text($background, $brand, $amount,$x,$y)
{
global $link;
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
switch ($ext)
{
case '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
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'png':
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$doSharpen = FALSE;
break;
}
$width =600;$height =600;
$photoFrame2 = imagecreatetruecolor($width, $height);
imagealphablending($photoFrame2, false);
imagesavealpha($photoFrame2, true);
$trans_colour = imagecolorallocatealpha($photoFrame2, 0, 0, 0, 127);
imagefilledrectangle($photoFrame2, 0, 0, $width, $height, $trans_colour);
$brand = 'v/uploads/text/' . $brand . '';
$photo2 = $creationFunction($brand);
imagecopyresampled($photoFrame2, $photo2, 0, 0, 0,0, $width, $height, $width, $height);
$photoFrame = imagecreatetruecolor($width, $height);
imagecopy($photoFrame, $background, 0, 0, 0, 0, $width, $height);
imagecopy($photoFrame, $photoFrame2, 0, 0, 0, 0, $width, $height);
imagecopymerge($background, $photoFrame, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($photoFrame);
return $background;
}
function gd_apply_overlay6($background, $brand, $amount)
{
global $link;
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
switch ($ext)
{
case '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
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'png':
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$doSharpen = FALSE;
break;
}
$width =600;$height =600;
$photoFrame2 = imagecreatetruecolor($width, $height);
imagealphablending($photoFrame2, false);
imagesavealpha($photoFrame2, true);
$trans_colour = imagecolorallocatealpha($photoFrame2, 0, 0, 0, 127);
imagefilledrectangle($photoFrame2, 0, 0, $width, $height, $trans_colour);
$brand = 'brands/' . $brand . '';
$photo2 = $creationFunction($brand);
imagecopyresampled($photoFrame2, $photo2, 0, 0, 0,0, $width, $height, $width, $height);
$photoFrame = imagecreatetruecolor($width, $height);
imagecopy($photoFrame, $background, 0, 0, 0, 0, $width, $height);
imagecopy($photoFrame, $photoFrame2, 0, 0, 0, 0, $width, $height);
imagecopymerge($background, $photoFrame, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($photoFrame);
return $background;
}
/** Apply a PNG overlay */
function hex_to_rgb($hex) {
// remove '#'
if(substr($hex,0,1) == '#')
$hex = substr($hex,1) ;
// expand short form ('fff') color to long form ('ffffff')
if(strlen($hex) == 3) {
$hex = substr($hex,0,1) . substr($hex,0,1) .
substr($hex,1,1) . substr($hex,1,1) .
substr($hex,2,1) . substr($hex,2,1) ;
}
if(strlen($hex) != 6)
fatal_error('Error: Invalid color "'.$hex.'"') ;
// convert from hexidecimal number systems
$rgb['red'] = hexdec(substr($hex,0,2)) ;
$rgb['green'] = hexdec(substr($hex,2,2)) ;
$rgb['blue'] = hexdec(substr($hex,4,2)) ;
return $rgb ;
}
function fatal_error($message)
{
global $link;
// send an image
if(function_exists('ImageCreate'))
{
$width = ImageFontWidth(5) * strlen($message) + 10 ;
$height = ImageFontHeight(5) + 10 ;
if($image = ImageCreate($width,$height))
{
$background = ImageColorAllocate($image,255,255,255) ;
$text_color = ImageColorAllocate($image,0,0,0) ;
ImageString($image,5,5,5,$message,$text_color) ;
header('Content-type: image/png') ;
ImagePNG($image) ;
ImageDestroy($image) ;
exit ;
}
}
// send 500 code
header("HTTP/1.0 500 Internal Server Error") ;
print($message) ;
exit ;
}
/*if(!$image || !$box)
{
fatal_error('Error: The server could not create this image.') ;
}
*/
function web()
{
global $link;
$nani = $_SESSION["user"];
if(!empty($_GET['nani']))
{
$nani = $_GET['nani'];
}
if(!empty($_GET['newnani']))
{
$nani = $_GET['newnani'];
}
if(!empty($_GET['convoId']) && $_GET['context'] != "undefined")
{
$convoId = $_GET['convoId'];
$rs_settings = mysqli_query($link,"select * from tweets where id='$convoId'");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$ca = ucwords($row_settings['screen_name']);
return removeslashes($ca);
}
}
else
{
$rs_settings = mysqli_query($link,"select * from users where catalogid='$nani'");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$un = strtolower($row_settings['website']);
return removeslashes($un);
}
}
}
function name()
{
global $link;
$nani = $_SESSION["user"];
if(!empty($_GET['nani']))
{
$nani = $_GET['nani'];
}
if(!empty($_GET['newnani']))
{
$nani = $_GET['newnani'];
}
if(!empty($_GET['convoId']) && $_GET['context'] != "undefined")
{
$convoId = $_GET['convoId'];
$rs_settings = mysqli_query($link,"select * from tweets where id='$convoId'");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$ca = ucwords($row_settings['user_name']);
return removeslashes($ca);
}
}
else
{
$rs_settings = mysqli_query($link,"select * from users where catalogid='$nani'");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$un = strtolower($row_settings['catalogname']);
return removeslashes($un);
}
}
}
function username()
{
global $link;
$nani = $_SESSION["user"];
if(!empty($_GET['nani']))
{
$nani = $_GET['nani'];
}
if(!empty($_GET['newnani']))
{
$nani = $_GET['newnani'];
}
if(!empty($_GET['convoId']) && $_GET['context'] != "undefined")
{
$convoId = $_GET['convoId'];
$rs_settings = mysqli_query($link,"select * from tweets where id='$convoId'");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$ca = ucwords($row_settings['user_name']);
return removeslashes($ca);
}
}
else
{
$rs_settings = mysqli_query($link,"select * from users where catalogid='$nani'");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$un = strtolower($row_settings['user_name']);
return removeslashes($un);
}
}
}
function user()
{
global $link;
$nani = $_SESSION["user"];
if(!empty($_GET['nani']))
{
$nani = $_GET['nani'];
}
if(!empty($_GET['newnani']))
{
$nani = $_GET['newnani'];
}
if(!empty($_GET['convoId']))
{
$convoId = $_GET['convoId'];
$rs_settings = mysqli_query($link,"select * from tweets where id='$convoId'");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$ca = ucwords($row_settings['screen_name']);
return removeslashes($ca);
}
}
else
{
$rs_settings = mysqli_query($link,"select * from users where catalogid='$nani'");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$ca = $row_settings['user_name'] ;
return removeslashes($ca);
}
}
}
function yanani($yanani)
{
global $link;
$rs_settings = mysqli_query($link,"select * from users where catalogid=$yanani");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$user_name = strtolower($row_settings['user_name']);
return removeslashes($user_name);
} }
function slug()
{
global $link;
$nani = $_SESSION["user"];
if(!empty($_GET['nani']))
{
$nani = $_GET['nani'];
}
if(!empty($_GET['newnani']))
{
$nani = $_GET['newnani'];
}
$rs_settings = mysqli_query($link,"select * from users where catalogid='$nani'");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
return $slug = strtolower($row_settings['slug']);
} }
/*function getuserDetails($detail)
{
$nani = $_SESSION["user"];
if(!empty($_GET['nani']))
{
$nani = $_GET['nani'];
}
if(!empty($_GET['newnani']))
{
$nani = $_GET['newnani'];
}
$rs_settings = mysqli_query($link,"select * from users where catalogid='$nani'");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$detailX = strtolower($row_settings["$detail"]);
return removeslashes($detailX);
} }*/
function bio()
{
global $link;
$nani = $_SESSION["user"];
if(!empty($_GET['nani']))
{
$nani = $_GET['nani'];
}
if(!empty($_GET['newnani']))
{
$nani = $_GET['newnani'];
}
$rs_settings = mysqli_query($link,"select * from users where catalogid='$nani'");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$description = strtolower($row_settings['description']);
if(empty($description)){ $description= "Visit thebrand.co.ke/".$row_settings['user_name']." for updates";}
else{
$description = strtolower($row_settings['description']);
}
return removeslashes($description);
} }
function write($brand,$position)
{
$themeid = $_GET['theme_id'];
global $link;
$query = mysqli_query($link,"SELECT * FROM `layerorder` WHERE themeid='$themeid' and position='$position'") or die(mysql_error());
$row=mysqli_fetch_array($query);
$name= $row['name'];
$layerx = $row['layerx'];;
$layery = $row['layery'];
$context= preg_replace('/\*(\\w+)/', "", $_GET['context']);
$context = urlencode($context);
$type = "Caption";
$parts = parse_url($name);
parse_str($parts['query'], $query);
$remove = $query['text'];
$exec = "&S=1&pichaNi=".$themeid."CaptionLayer&text=$context&position=$position&x=$layerx&y=$layery&type=caption";
$newword = $context.$exec;
$newString = $name.$exec;
/* exit($newString);*/
$data = array(array(),array());
$data[0]['url'] = $newString;
$data[0]['post'] = array();
$data[0]['post']['q'] = 'YahooDemo';
$r = multiRequestX($data);
$brand = $themeid."CaptionLayer.png";
$url = basename($brand);
return $url;
}
function profilepicture()
{
global $link;
global $link;
$nani = $_SESSION["user"];
if(!empty($_GET['nani']))
{
$nani = $_GET['nani'];
}
if(!empty($_GET['newnani']))
{
$nani = $_GET['newnani'];
}
$rs_settings = mysqli_query($link,"select * from profilepicture where catalogid='$nani' and type='1' limit 0,1");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
return $picture = strtolower($row_settings['picture']);
} }
function findStartag($startag)
{
global $link;
$rs_settings = mysqli_query($link,"select * from profilepicture where title='$startag' limit 0,1");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$newsid = $row_settings['id'];
$yanani = $row_settings['catalogid'];
$nani = $_GET['nani'];
if($nani!=$yanani)
{
$viewnum = $row_settings['viewnum'];
$viewnum = $viewnum+1;
global $link;
mysqli_query($link,"update profilepicture set viewnum=$viewnum where id='$newsid'");
}
$picture = explode('.',$row_settings['picture']);
$picture = $picture[0];
$picture = $row_settings['picture'];
$theme = $row_settings['description'];
$overlay = $row_settings['overlay'];
$yanani = $row_settings['catalogid'];
$fx = $row_settings['fx'];
$x = $row_settings['x'];
$y = $row_settings['y'];
return $picture."|".$theme."|".$overlay."|".$yanani."|".$x."|".$y."|".$fx."|";
} }
function openGallery($startag)
{
global $link;
$rs_settings = mysqli_query($link,"select * from profilepicture where title='$startag' and type=3 limit 0,1");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$newsid = $row_settings['id'];
$yanani = $row_settings['catalogid'];
$nani = $_GET['nani'];
if($nani!=$yanani)
{
$viewnum = $row_settings['viewnum'];
$viewnum = $viewnum+1;
global $link;
mysqli_query($link,"update profilepicture set viewnum=$viewnum where id='$newsid'");
}
$picture = explode('.',$row_settings['picture']);
$picture = $picture[0];
$picture = $row_settings['picture'];
$theme = $row_settings['description'];
$overlay = $row_settings['overlay'];
$yanani = $row_settings['catalogid'];
$fx = $row_settings['fx'];
$x = $row_settings['x'];
$y = $row_settings['y'];
return $picture."|".$theme."|".$overlay."|".$yanani."|".$x."|".$y."|".$fx."|";
} }
function AppOwner()
{
global $link;
$AppNo = $_GET['AppNo'];
$rs_settings = mysqli_query($link,"select * from users where catalogid=$AppNo");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
return $cat = strtolower($row_settings['catalogname']);
} }
function country()
{
global $link;
$nani = $_SESSION["user"];
if(!empty($_GET['nani']))
{
$nani = $_GET['nani'];
}
$rs_settings = mysqli_query($link,"select * from users where catalogid='$nani'");
while ($row_settings = mysqli_fetch_array($rs_settings)) {
return $country = strtolower($row_settings['country']);
} }
if ($_GET['gratitude'] == "start") {
$uploaddir = 'v/uploads/raw/';
$image ="images/gratitude.jpg";
$date = md5(date('D, d M Y H:i:s'));
$upload = $date.basename($image);
$uploadfile = $uploaddir .$upload;
copy($image,$uploadfile);
$user = user();
$owner = AppOwner();
$AppNo = $_GET['AppNo'];
$nani = $_GET['nani'];
$db->addgratitude($user,$owner,$AppNo,$nani,$upload);
$pic = $upload;
}
function showUpdate($nani)
{
/*error_reporting(0);*/
include_once 'real/service/social/includes/tolink.php';
include_once 'real/service/social/includes/textlink.php';
include_once 'real/service/social/includes/htmlcode.php';
include_once 'real/service/social/includes/Expand_URL.php';
require("const.inc.php");
global $link;
$newquery = mysqli_query($link,"SELECT M.msg_id, M.newsid, M.catalogid_fk, M.original,M.isdisplay,M.episodeid,M.yanani, M.message, M.created, U.user_name,U.slug,M.uploads,M.type, U.user_name FROM reporta M, users U where M.catalogid_fk=U.catalogid and M.catalogid_fk='$nani' order by M.msg_id desc limit 1 ");
$data = mysqli_fetch_array($newquery);
if(!$data)
{
exit("sent already......");}
if($data)
{
$url=$data['message'];
$returns = 'none';
if(eregi("youtu",$url) or eregi("youtube",$url)){
if(eregi("v=",$url))
$splits = explode("=",$url);
else
$splits = explode("be/",$url);
if(!empty($splits[1])){
if(preg_match("/feature/i", $splits[1])){
$splits[1] = str_replace("&feature","",$splits[1]);
}
$returns = '<iframe width="100%" height="400" src="http://www.youtube.com/embed/'.$splits[1].'" frameborder="0"></iframe>';
}
} else if(eregi("vimeo",$url)){
$splits = explode("com/",$url);
$returns = '<iframe src="http://player.vimeo.com/video/'.$splits[1].'?title=0&byline=0&portrait=0" width="100%" height="400" frameborder="0"></iframe>';
}
$msg_id=$data['msg_id'];
$orimessage=$data['message'];
$message=$db-> $data['message'] ;
$message= preg_replace('/\*(\\w+)/', "",$message );
$message=tolink(htmlcode($message));
$time=$data['created']; $msg_created=$data['created'];
$mtime=date("c", $time);
$user_name=$data['user_name'];
$profile=$data['slug'];
$uploads=$data['uploads'];
$msg_catalogid=$data['catalogid_fk'];
$msg_yanani=$data['yanani'];
$msg_slug=$data['slug'];
$msg_slug=$data['slug'];
$nani=$data['type'];
$photoDisplay=$data['original'];
$msg_newsid=$data['msg_id'];
if($nani==13) { $msg_newsid=$data['newsid'];$msg_id=$data['newsid']; }
$forChannel=$data['msg_id'];
$forText=$data['msg_id'];
$forVideo=$data['msg_id'];
$forLove=$data['msg_id'];
$msgidLove=$data['msg_id'];
$photoDisplay=$data['original'];
$isdisplay=$data['isdisplay'];
$episodeid=$data['episodeid'];
$actualID=$data['msg_id'];
if(!empty($_SESSION['TwitterUsername']))
{
include 'twitter/EpiTwitter/EpiCurl.php';
include 'twitter/EpiTwitter/EpiOAuth.php';
include 'twitter/EpiTwitter/EpiTwitter.php';
include 'twitter/EpiTwitter/TwitterConfig.php';
include("Connections/videoondemand.php");
include("twitter/db.php");
$message=mysql_real_escape_string($orimessage);
$message=stripslashes($message);
$pic = " $siteaddress3/taswira.php?width=500&quality=70&image=/v/uploads/raw/$photoDisplay";
$TwitterUsername=$_SESSION['TwitterUsername'];
$tw_sql=mysqli_query($connection,"SELECT oauth_token,oauth_token_secret FROM users WHERE tel='$msg_catalogid'");
$row=mysqli_fetch_array($tw_sql,MYSQLI_ASSOC);
$oauth_token=$row["oauth_token"];
$oauth_token_secret=$row["oauth_token_secret"];
$Twitter = new EpiTwitter($consumer_key, $consumer_secret);
$Twitter->setToken($oauth_token,$oauth_token_secret);
$status=$Twitter->post_statusesUpdate(array('status' => $message.$pic));
/*echo $status->id_str;*/
}
?>
<?php if($_GET['download']==1) { echo "$photoDisplay"; exit();}?>
<img src="<?php echo $siteaddress3 ?>taswira.php?width=600&quality=100&image=/v/uploads/raw/<?php echo $photoDisplay ?>" width="100%" />
<?php
}
else
{?><?php if($_GET['download']==1) { echo "$photoDisplay"; exit();}?>
<?php /*?> Duplicate Post<?php */?><img src="<?php echo $siteaddress3 ?>taswira.php?width=600&quality=100&image=/v/uploads/raw/<?php echo $photoDisplay ?>" width="100%" />
<?php }
}
if ($_GET['gratitude'] == "posted") {
if (!empty($_GET['context']))
{
$text = realText();
}
else
{
$text = mysqli_real_escape_string($link,$_GET['cl']);
}
preg_match('/\>(\\w+)/',$_GET['context'],$vida);
$vida =$vida[1];
//is it video or not
//is it video or not
if ($vida == "video")
{ //it is video hurraaaay
include("mags/video.php");
exit();}
if ($vida != "video")
{ //its not
$uploaddir = 'v/uploads/raw/';
$picture = profilepicture();
if(!empty($picture))
{
if(!empty($_GET["postDirect"]))
{
$image ="v/uploads/raw/$picture";
}
else
{
$image ="v/uploads/gthumbs/$picture";
}
}
else
{
$picme = rand(1,10);
if($picme == 1) { $image ="images/backgrounds/bg-4.jpg"; }
if($picme == 2) { $image ="images/backgrounds/bold.jpg";}
if($picme == 3) { $image ="images/backgrounds/dusk.jpg"; }
if($picme == 4) { $image ="images/backgrounds/bg-2.jpg"; }
if($picme == 5) { $image ="images/backgrounds/bg-3.jpg"; }
if($picme == 6) { $image ="images/backgrounds/frost.jpg"; }
if($picme == 7) { $image ="images/backgrounds/sky.jpg";}
if($picme == 8) { $image ="images/backgrounds/sunset.jpg"; }
if($picme == 9) { $image ="images/backgrounds/sunset2.jpg"; }
if($picme == 10) { $image ="images/backgrounds/sunset3.jpg"; }
/*$image ="images/backgrounds/bg-4.jpg"; */
}
$date = md5(time());
/*$upload = $date.basename($image);*/
$upload = $date.".jpg";
$uploadfile = $uploaddir .$upload;
if (!empty($_GET['cl']))
{
$pic =$_GET['pic'];
gd_filter_image('v/uploads/gthumbs/' . $pic, $_GET['filter']); }
else
{
copy($image,$uploadfile);
}
$user = user();
$owner = AppOwner();
$AppNo = mysqli_real_escape_string($link,$_GET['AppNo']);
$nani = mysqli_real_escape_string($link,$_GET['nani']);
if (!empty($_GET['context']))
{
$text = realText();
$text = str_replace("\n" , ' ',$context);
$text = str_replace("\r" , ' ',$context);
$uploads="";
if (empty($_GET['display'])) {
$db->Insert_UpdateX($nani,$text,$uploads,$AppNo,$upload,$owner);
}
}
if (!empty($_GET['cl']))
{
$text = dummyText();
}
$pic = $upload;
}
if ($pic && $_GET['filter']) {
if (!empty($_GET['fire'])) {
$AppNo = mysqli_real_escape_string($link,$_GET['AppNo']);
$cl = mysqli_real_escape_string($link,$_GET['cl']);
$overlay = mysqli_real_escape_string($link,$_GET['overlay']);
$pic = $_GET['pic'];
$x = $_GET['x'];
$fx = $_GET['fx'];
$mytitle = $_GET['mytitle'];
$y = $_GET['y'];
$msg_id = $_GET['msg_id'];
$msg_id = $db->base64url_decode($msg_id);
$mytitle = $_GET['mytitle'];
$fx = $_GET['fx'];
if(!empty($fx))
{
$db->mag8($pic,$fx,$msg_id,$ren);
}
else
{
$db->mag7($pic,$AppNo,$cl,$overlay,$mytitle,$x,$y,$msg_id);
}
}
$mag = $_GET['mag'];
$id = substr($pic, 5, 1);
if (!empty($_GET['cl'])) {
$pic =$_GET['pic'];
/*gd_filter_image($image, "blank"); */
gd_filter_image('v/uploads/gthumbs/' . $pic, $_GET['filter']); }
else
{
gd_filter_image('v/uploads/raw/' . $pic, $_GET['filter']);
}
//end no vida
}
}
if ($_GET["exportGif"]=="yes") {
$catalogid = $_GET["catalogid"] ;
$theme_id = $_GET['theme_id'];
$username = username();
$nani = $_GET['catalogid'];
if ( $dh = opendir ( "v/uploads/gif/" ) ) {
while ( false !== ( $dat = readdir ( $dh ) ) ) {
if ( $dat != "." && $dat != ".." ) {
if (strpos($entry, "sokottah") === 0) {
$frames [ ] = "v/uploads/gif/$dat";
$framed [ ] = 500;
}
}
}
}
closedir ( $dh );
}
print_r($frames);
exit();
$frames =array("[0] => v/uploads/gif/$picha1
[1] => v/uploads/gif/$picha2");
/*
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'
);
*/
$gif = new GIFEncoder (
$frames,
$framed,
0,
2,
0, 0, 0,
"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 ( ) );
*/
/*Header ( 'Content-type:image/gif' );
echo $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);
global $link;
$query = mysqli_query($link,"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 = mysqli_num_rows($rs_settings);
while ($row_settings = mysqli_fetch_array($rs_settings)) {
$picture = "v/uploads/gif/".$row_settings['picture'] ;
unlink($picture);
}
$rs_settings = mysqli_query($link,"delete from elements where catalogid='$nani'");
exit("v/uploads/raw/anim$username$random.gif");
/*
$framed [ ] = 200;
$frames = "[0] => v/uploads/gif/$picha1
[1] => v/uploads/gif/$picha2";
$framed [] = 200;
print_r($frames);
*/
}
}
function copyright($background)
{
$themeid = $_GET["theme_id"];
$row = getParamJSONTheme($themeid);
$params = json_decode("[".$row['params']."]");
$docWidth=$params[0]->width;
$docHeight =$params[0]->height ;
$slug = slug();
$text = 'www.thebrandingapp.com';
$font = 'assets/fonts/TitilliumWeb-Regular.ttf';
$size =12;
$type_space = imagettfbbox($size, 0, $font, $text);
// Determine image width and height, 10 pixels are added for 5 pixels padding:
$image_width = abs($type_space[4] - $type_space[0]);
$image_height = abs($type_space[5] - $type_space[1]);
$x = $docWidth - $image_height;
$y = $docHeight - $image_width;
$black = imagecolorallocate($background, 160, 149, 154);
$white = imagecolorallocate($background, 255, 255, 255);
/* imagettftext($background, $size, 90, $x + 5, $y, $black, $font, $text);*/
imagettftext($background, $size,90, $x + 6, $image_width+11, $black, $font, $text);
imagettftext($background, $size, 90, $x + 5, $image_width+10, $white, $font, $text);
return $background;
}
?>