( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
error_reporting(0);
include("includes/limittext.php");
include('Connections/videoondemand.php');
require("DbSql.inc.php");
require("NewsSql.inc.php");
$db = new NewsSQL($DBName);
/*set_time_limit(0) ;*/
function filter($arr) {
global $link;
return array_map(array($link, 'real_escape_string'), $arr);
}
/*
https://maps.googleapis.com/maps/api/staticmap?center=NAKURU&zoom=13&size=600x600&maptype=hybrid
http://localhost/mimix/brandX.php?AppNo=254722407698&mag=yes&gratitude=posted&filter=mood&nani=254722407699&cl=rightnow&pic=0fbfb36bad36a37e22955b2081eac3036SAMCOM2011DAY3-051.jpg*/
$_GET = filter($_GET);
$_POST = filter($_POST);
$mode=$_GET["mode"];
include("protect.php");
if (empty($page)) {
$page = 0;
}
/*$url = "https://maps.googleapis.com/maps/api/staticmap?center=NAKURU&zoom=13&size=600x600&maptype=hybrid";
$resource = imagecreatefromstring(file_get_contents($url));
$img = imagecreatetruecolor($w*$size,$h*$size);*/
include("includes/processFunctions.php");
/** Apply and deliver the image and clean up */
function gd_filter_image($image_path, $photoFrame2_name)
{
$photoFrame2 = 'gd_filter_' . $photoFrame2_name;
$height = 600;
$width = 600;
$background = imagecreatetruecolor($width, $height);
imagealphablending($background, false);
imagesavealpha($background, true);
$bgcolor = imagecolorallocatealpha($background, 0, 0, 0, 127);
imagefill($background, 0, 0, $bgcolor);
$background = $photoFrame2($background);
if (!empty($_GET['display'])) {
header("content-type: image/png");
imagepng($background, null, $quality);
imagedestroy($background);
imagedestroy($src);
exit();
}
if (!empty($_GET['output'])) {
imagepng($background, $image_path, $quality);
$nani = $_GET['nani'];
/* if(!empty($_GET['newnani']))
{
$nani = $_GET['newnani'];
}*/
if (!empty($_GET['newPic']))
{
$nani = $_GET['nani'];
$query = mysqli_query("UPDATE posts SET id='0' where catalogid='$nani'") or die(mysql_error());
}
showUpdate($nani);
exit();
}
if (!empty($_GET['execute'])) {
imagepng($background, $image_path, $quality);
}
if (!empty($_GET['fire'])) {
$imageX = "v/uploads/thumbs/".$_GET['pic'];
imagepng($background, $imageX, $quality);
}
header("content-type: image/png");
imagepng($background, null, $quality);
imagedestroy($background);
imagedestroy($src);
}
function gd_filter_mood($background)
{
if (empty($_GET['cl']))
{
$text = realText() ;
}
else
{
$text = dummyText();
}
$text = stripslashes($text) ;
$text = nl2br(htmlentities($text, ENT_QUOTES, 'UTF-8'));
$text = preg_replace('/\s+/', ' ', trim($text));
preg_match('/\*(\\w+)/',$text,$matches);
$moods =$matches[1];
$moods =strtolower($moods);
switch ($moods) {
case "machine" :
$background= gd_filter_machine($background);
return $background;
break;
default:
$background= gd_filter_moodswing($background);
return $background;
}
}
function getEachLayer($themeid,$catalogid,$position)
{
$sql = "select * from layerorder where themeid='$themeid' and catalogid='$catalogid' and position='$position'";
$result = mysqli_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);
/*print_r($row);*/
return $row;
}
function gd_filter_machine($background)
{
$themeid = $_GET["theme_id"];
$catalogid = $_GET["nani"];
if (empty($_GET['cl']))
{
$text = realText() ;
}
else
{
$text = dummyText();
}
$myArray = get_startags($text, $str = 0);
$moodswing2 =$myArray[1];
$moodswing2 =strtolower($moodswing2);
$row = getEachLayer($themeid,$catalogid,0);
$str =$row['name'];
$layerPosition=1;
include("includes/machineWrite2.php");
$layerPosition=2;
include("includes/machineWrite2.php");
$layerPosition=3;
include("includes/machineWrite2.php");
$layerPosition=4;
include("includes/machineWrite2.php");
$layerPosition=5;
include("includes/machineWrite2.php");
$layerPosition=6;
include("includes/machineWrite2.php");
$layerPosition=7;
include("includes/machineWrite2.php");
$layerPosition=8;
include("includes/machineWrite2.php");
$layerPosition=9;
include("includes/machineWrite2.php");
$layerPosition=10;
include("includes/machineWrite2.php");
/*$background = gd_apply_overlay($background, 'bfma', 100);*/
return $background;
}
function get_startags($string, $str = 1) {
preg_match_all('/\*(\w+)/',$string,$matches);
$i = 0;
if ($str) {
foreach ($matches[1] as $match) {
$count = count($matches[1]);
$keywords .= "$match";
$i++;
if ($count > $i) $keywords .= ", ";
}
} else {
foreach ($matches[1] as $match) {
$keyword[] = $match;
}
$keywords = $keyword;
}
return $keywords;
}
function get_spaces($string, $str = 10) {
preg_match_all('/(\w+)/',$string,$matches);
$i = 0;
if ($str) {
foreach ($matches[1] as $match) {
$count = count($matches[1]);
$keywords .= "$match";
$i++;
if ($count > $i) $keywords .= ", ";
}
} else {
foreach ($matches[1] as $match) {
$keyword[] = $match;
}
$keywords = $keyword;
}
return $keywords;
}
function gd_filter_classic($background)
{
if (empty($_GET['cl']))
{
$text = realText() ;
}
else
{
$text = dummyText();
}
$fontX = 'assets/fonts/TitilliumWeb-SemiBold_0.ttf'; //font used
$myArray = get_startags($text, $str = 0);
$moodswing2 =$myArray[1];
$moodswing2 =strtolower($moodswing2);
$hasPicture = verifyStartag();
/*if (empty($moodswing2))
{
if (empty($_GET['cl']) && empty($hasPicture)) { $background = gd_apply_overlay($background, 'twitter', 90);}
if (!empty($hasPicture)) { $background = gd_apply_overlay($background, 'twitter2', 100);}
if (!empty($_GET['cl'])) { $background = gd_apply_overlay($background, 'twitter2', 100);}
}
*/
if (empty($moodswing2)&& empty($hasPicture))
{
$background = gd_apply_overlay($background, 'classic', 100);
$font_color = imagecolorallocate($background, 252,206,96); // Create blue color
$fontX = 'assets/fonts/TitilliumWeb-SemiBold_0.ttf'; //font used
}
else
{
imagefilter($background, IMG_FILTER_BRIGHTNESS, 80);
imagefilter($background, IMG_FILTER_CONTRAST, -20);
imagefilter($background, IMG_FILTER_GRAYSCALE);
$background = gd_apply_overlay($background, 'black', 70);
$background = gd_apply_overlay($background, 'shadow', 100);
$font_color = imagecolorallocate($background, 255, 255, 255); // Create blue color
$fontX = 'assets/fonts/TitilliumWeb-SemiBold_0.ttf'; //font used
}
if (!empty($_GET['cl']) || !empty($hasPicture)) { $font_color = imagecolorallocate($background, 252,206,96);}
$fontY = 'assets/fonts/Montserrat-Bold.ttf'; //font used
$fontZ = 'assets/fonts/Montserrat-Regular_0.ttf'; //font used
$fontC = 'assets/fonts/TitilliumWeb-Light.ttf'; //font used
$fontA = 'assets/fonts/TitilliumWeb-SemiBold_0.ttf'; //font used
$fontB = 'assets/fonts/TitilliumWeb-Regular_2.ttf'; //font used
$fontW = 'assets/fonts/Autograf_PersonalUseOnly.ttf'; //font used
$font_color2 = imagecolorallocate($background, 255, 255, 255); // Create blue color
$font_color3 = imagecolorallocate($background, 255, 255,255); // Create blue color
$text= preg_replace('/\*(\\w+)/', "", $text);
$text= preg_replace('/\#(\\w+)/', "", $text);
$text= trim($text);
$text = wordwrap($text,36,"\n");
$font_size = 1;
$txt_max_width = intval(0.7*600);
do{
$font_size++;
$p = imagettfbbox($font_size,0,$fontZ,$text);
$txt_width = $p[2] - $p[0];
$txt_height = $p[1] - $p[7];
}
while (($txt_width <= $txt_max_width) && ($font_size <=25)) ;
$y = (600 - $txt_height) / 2;
$x = (600 - $txt_width) / 2;
imagettftext($background,20, 0, 30, $y, $font_color, $fontX, $text); //Write
$font_size = 25;
$user2 = "*".username();
$user3 = user();
$slug = "thebrand.co.ke/".slug();
$user4 = "#".username();
$bio = bio();
imagettftext($background,20, 0, 30, 50, $font_color2, $fontY, $user4); //Write
imagettftext($background,10, 0, 30, 67, $font_color2, $fontZ,$bio ); //Write
$user3 = user();
$myArray = get_spaces($user3, $str = 0);
$firstname =$myArray[1];
$secondname =ucwords($myArray[0]);
$dimensions = imagettfbbox(20, 0, $fontX, $secondname);
$textWidth = abs($dimensions[4] - $dimensions[0]);
$x2 = 30;
imagettftext($background,20, 0, $x2, 510, $font_color2, $fontX, $secondname);
$dimensionsx = imagettfbbox(20, 0, $fontC, $firstname);
$textWidthx = abs($dimensionsx[4] - $dimensionsx[0]);
$xx = $x2 + $textWidth+5;
imagettftext($background,20, 0, $xx, 510, $font_color2, $fontC, $firstname);
imagettftext($background,14, 0, 30, 528, $font_color2, $fontW, $secondname);
imagettftext($background,12, 0, 30, 545, $font_color2, $fontY, $user2); //Write
return $background;
}
function verifyStartag()
{
$text = realText() ;
$myArray = get_startags($text, $str = 0);
$moodswing0 =$myArray[0];
$moodswing0 =strtolower($moodswing0);
$startag =findStartag($moodswing0);
$startag = explode('|',$startag);
return $picture = $startag[0];
}
function gd_filter_moodswing($background)
{
if (empty($_GET['cl']))
{
$text = realText() ;
}
else
{
$text = dummyText();
}
$myArray = get_startags($text, $str = 0);
$moodswing0 =$myArray[0];
$moodswing1 =$myArray[1];
$moodswing2 =$myArray[2];
$moodswingX =$myArray[2];
$moodswing4 =$myArray[4];
$moodswing0 =strtolower($moodswing0);
$moodswing1 =strtolower($moodswing1);
$moodswing2 =strtolower($moodswing2);
$text= preg_replace('/\*(\\w+)/', "", $text);
$text= preg_replace('/\#(\\w+)/', "", $text);
$text= trim($text);
if (empty($moodswing0))
{
$startag =openGallery($moodswing0);
if(!empty($startag))
{
$startag = explode('|',$startag);
$picture = $startag[0];
$background = gd_apply_overlay4($background, $picture, 100);
if(!empty($moodswingX))
{
$moodswing2 = $moodswingX;
include("mags/effects.php");
}
if(!empty($moodswing1))
{
$moods =strtolower($moodswing1);
}
else
{
$moods = $startag[1];
$moods =strtolower($moods);
}
switch ($moods) {
case "machine" :
$background= gd_filter_machine($background);
return $background;
}
}
include("mags/default.php");
}
if (!empty($moodswing1))
{
$moodswing2 = $moodswing1;
include("mags/effects.php");
}
if (!empty($moodswing0))
{
$startag =findStartag($moodswing0);
$startag = explode('|',$startag);
$picture = $startag[0];
$x = $startag[4];
$y = $startag[5];
$fx = $startag[6];
if (!empty($picture))
{
if (!empty($text) && !empty($picture))
{
$background = gd_apply_overlay2($background, $picture , 100,$x,$y);
if (!empty($_GET['newPic']))
{
$newPic = $_GET['newPic'];
$background = gd_apply_logo($background,$newPic, 100,0,0,600,600);
}
if (!empty($_GET['fx']))
{
$moodswing2 = $_GET['fx'];
include("mags/effects.php");
}
if (!empty($fx))
{
$moodswing2 = $startag[6];
include("mags/effects.php");
}
if (!empty($moodswing1))
{
$moods =strtolower($moodswing1);
include("mags/moods.php");
}
else
{
$themes = $startag[1];
$moods =strtolower($themes);
include("mags/moods.php");
}
}
if (empty($text) && !empty($picture))
{
$background = gd_apply_overlay2($background, $picture , 100,$x,$y);
$fontZ = 'assets/fonts/HelveticaNeueLTStd-UltLt.otf'; //font used
$font_color2 = imagecolorallocate($background, 255, 255, 255); // Create blue color
$yanani = $startag[3];
$yanani = "*".yanani($yanani);
imagettftext($background,35, 0, 20, 580, $font_color2, $fontZ, $yanani);
}
}
else
{
if (!empty($text) && empty($picture))
{
$startag =openGallery($moodswing0);
$startag =openGallery($moodswing0);
if(!empty($startag))
{
$startag = explode('|',$startag);
$picture = $startag[0];
$background = gd_apply_overlay4($background, $picture, 100);
$moods = $startag[1];
if(!empty($moodswingX))
{
$moodswing2 = $moodswingX;
include("mags/effects.php");
}
if(!empty($moodswing1))
{
$moods =strtolower($moodswing1);
}
else
{
$moods = $startag[1];
$moods =strtolower($moods);
}
switch ($moods) {
case "machine" :
$background= gd_filter_machine($background);
return $background;
case "blank" :
}
}
include("mags/default.php");
}
}
}
/*$background = gd_filter_news($background);*/
return $background;
}