( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
include("includes/limittext.php");
include('Connections/videoondemand.php');
require("DbSql.inc.php");
require("NewsSql.inc.php");
include("protect.php");
$db = new NewsSQL($DBName);
error_reporting(1);
/*set_time_limit(0) ;*/
function filter($arr) {
global $link;
return array_map(array($link, 'real_escape_string'), $arr);
}
/*
https://maps.googleapis.com/maps/api/staticmap?center=NAKURU&zoom=13&size=600x600&maptype=hybrid
http://localhost/mimix/brandX.php?AppNo=254722407698&mag=yes&gratitude=posted&filter=mood&nani=254722407699&cl=rightnow&pic=0fbfb36bad36a37e22955b2081eac3036SAMCOM2011DAY3-051.jpg*/
$_GET = filter($_GET);
$_POST = filter($_POST);
$mode=$_GET["mode"];
$nani=$_GET["nani"];
class imageGrid
{
private $realWidth;
private $realHeight;
private $gridWidth;
private $gridHeight;
private $image;
public function __construct($realWidth, $realHeight, $gridWidth, $gridHeight)
{
$this->realWidth = $realWidth;
$this->realHeight = $realHeight;
$this->gridWidth = $gridWidth;
$this->gridHeight = $gridHeight;
// create destination image
$this->image = imagecreatetruecolor($realWidth, $realHeight);
// set image default background
$white = imagecolorallocate($this->image, 255, 255, 255);
imagefill($this->image, 0, 0, $white);
}
public function __destruct()
{
imagedestroy($this->image);
}
public function display()
{
header("Content-type: image/png");
imagepng($this->image);
}
public function demoGrid()
{
$black = imagecolorallocate($this->image, 0, 0, 0);
imagesetthickness($this->image, 1);
$cellWidth = ($this->realWidth - 1) / $this->gridWidth; // note: -1 to avoid writting
$cellHeight = ($this->realHeight - 1) / $this->gridHeight; // a pixel outside the image
for ($x = 0; ($x <= $this->gridWidth); $x++)
{
for ($y = 0; ($y <= $this->gridHeight); $y++)
{
imageline($this->image, ($x * $cellWidth), 0, ($x * $cellWidth), $this->realHeight, $black);
imageline($this->image, 0, ($y * $cellHeight), $this->realWidth, ($y * $cellHeight), $black);
}
}
}
public function resizePreservingAspectRatio($brand, $targetWidth, $targetHeight)
{
/* $foto2W = imagesx($brand);
$foto2H = imagesy($brand);
$srcRatio = $foto2W / $foto2H;
$targetRatio = $targetWidth / $targetHeight;
if (($foto2W <= $targetWidth) && ( $foto2H <= $targetHeight))
{
$brandTargetWidth = $foto2W;
$brandTargetHeight = $foto2H;
}
else if ($targetRatio > $srcRatio)
{
$brandTargetWidth = (int) ($targetHeight * $srcRatio);
$brandTargetHeight = $targetHeight;
}
else
{
$brandTargetWidth = $targetWidth;
$brandTargetHeight = (int) ($targetWidth / $srcRatio);
}
$background2 = imagecreatetruecolor($targetWidth, $targetHeight);
imagecopyresampled(
$background2,
$brand,
($targetWidth - $brandTargetWidth) / 2, // centered
($targetHeight - $brandTargetHeight) / 2, // centered
0,
0,
$brandTargetWidth,
$brandTargetHeight,
$foto2W,
$foto2H
);*/
$foto2W = imagesx($brand);
$foto2H = imagesy($brand);
$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,
$brand,
0 - ($background2W - $targetWidth) / 2, // Center the image horizontally
0 - ($background2H - $targetHeight) / 2, // Center the image vertically
0, 0,
$background2W, $background2H,
$foto2W, $foto2H);
return $background2;
}
public function demoPutSquare($sizeW, $sizeH, $posX, $posY)
{
// Cell width
$cellWidth = $this->realWidth / $this->gridWidth;
$cellHeight = $this->realHeight / $this->gridHeight;
// Conversion of our virtual sizes/positions to real ones
$realSizeW = ($cellWidth * $sizeW);
$realSizeH = ($cellHeight * $sizeH);
$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($this->image, 100, 0, 0);
imagefilledrectangle($this->image, $topLeftX, $topLeftY, $bottomRightX, $bottomRightY, $red);
}
public function putImage($brand, $sizeW, $sizeH, $posX, $posY)
{
// Cell width
$cellWidth = $this->realWidth / $this->gridWidth;
$cellHeight = $this->realHeight / $this->gridHeight;
// Conversion of our virtual sizes/positions to real ones
$realSizeW = ceil($cellWidth * $sizeW);
$realSizeH = ceil($cellHeight * $sizeH);
$realPosX = ($cellWidth * $posX);
$realPosY = ($cellHeight * $posY);
$brand = $this->resizePreservingAspectRatio($brand, $realSizeW, $realSizeH);
// Copying the image
imagecopyresampled($this->image, $brand, $realPosX, $realPosY, 0, 0, $realSizeW, $realSizeH, imagesx($brand), imagesy($brand));
}
}
function removeslashesX($string)
{
$string=implode("",explode("\\",$string));
return stripslashes(trim($string));
}
function checkBg($id)
{
$rs_settings = mysqli_query($link,"SELECT * from posts WHERE newsid=$id");
while ($row_settings = mysql_fetch_array($rs_settings)) {
$picture = $row_settings['picture'] ;
return removeslashesX($picture);
}
}
$imageGrid = new imageGrid(600, 600, 10, 10);
$imageGrid->demoGrid();
$string = $_GET["pics"];
$string = str_replace("null,","", $string);
$string = str_replace("null","", $string);
$str_arr = explode (",", $string);
$str_arr =array_unique($str_arr);
$str_arr = array_values($str_arr);
$count = count($str_arr);
$fileServer ="v/uploads/gthumbs/";
/* exit("$count");*/
$image ="images/backgrounds/bg-4.jpg";
$one = imagecreatefromjpeg($image);
$imageGrid->putImage($one, 10,10, 0, 0);
switch ($count) {
case "1": //1
if (file_exists($fileServer.checkBg($str_arr[0])))
{
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[0]));
$imageGrid->putImage($one, 10,10, 0, 0);}
break;
case "2"://2
if (file_exists($fileServer.checkBg($str_arr[1])))
{
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[0]));
$imageGrid->putImage($one, 5,10, 0, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[1]));
$imageGrid->putImage($one, 5,10, 5, 0);}
break;
case "3"://3
if (file_exists($fileServer.checkBg($str_arr[2])))
{
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[0]));
$imageGrid->putImage($one, 3,10, 0, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[1]));
$imageGrid->putImage($one, 4,10, 3, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[2]));
$imageGrid->putImage($one, 3,10, 7, 0);}
break;
case "4": // 4
if (file_exists($fileServer.checkBg($str_arr[3])))
{
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[0]));
$imageGrid->putImage($one,5,5, 0, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[1]));
$imageGrid->putImage($one, 5,5, 5, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[2]));
$imageGrid->putImage($one, 5,5, 0, 5);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[3]));
$imageGrid->putImage($one, 5,5, 5, 5);}
break;
case "5"://5
if (file_exists($fileServer.checkBg($str_arr[4])))
{
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[0]));
$imageGrid->putImage($one, 3,5, 0, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[1]));
$imageGrid->putImage($one, 4,10, 3, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[2]));
$imageGrid->putImage($one, 3,5, 7, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[3]));
$imageGrid->putImage($one, 3,5, 0, 5);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[4]));
$imageGrid->putImage($one, 3,5, 7, 5);
}
break;
case "6"://6
if (file_exists($fileServer.checkBg($str_arr[5])))
{
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[0]));
$imageGrid->putImage($one, 3,5, 0, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[1]));
$imageGrid->putImage($one, 4,5, 3, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[2]));
$imageGrid->putImage($one, 3,5, 7, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[3]));
$imageGrid->putImage($one, 3,5, 0, 5);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[4]));
$imageGrid->putImage($one, 4,5, 3, 5);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[5]));
$imageGrid->putImage($one, 3,5, 7, 5);}
break;
case "7"://7
if (file_exists($fileServer.checkBg($str_arr[6])))
{
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[0]));
$imageGrid->putImage($one, 3,5, 0, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[1]));
$imageGrid->putImage($one, 4,3, 3, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[2]));
$imageGrid->putImage($one, 4,3, 3, 3);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[3]));
$imageGrid->putImage($one, 4,4, 3, 3);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[4]));
$imageGrid->putImage($one, 3,5, 7, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[5]));
$imageGrid->putImage($one, 3,5, 0, 5);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[6]));
$imageGrid->putImage($one, 3,5, 7, 5);
}
/*
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[5]));
$imageGrid->putImage($one, 4,5, 3, 5);
*/
break;
case "8":
if (file_exists($fileServer.checkBg($str_arr[7])))
{
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[0]));
$imageGrid->putImage($one, 3,3, 0, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[1]));
$imageGrid->putImage($one, 4,3, 3, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[2]));
$imageGrid->putImage($one, 3,3, 7, 0);
/*
*/
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[3]));
$imageGrid->putImage($one, 5,4, 0, 3);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[4]));
$imageGrid->putImage($one, 5,4, 5, 3);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[5]));
$imageGrid->putImage($one, 4,3, 3, 7);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[6]));
$imageGrid->putImage($one, 3,3, 0, 7);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[7]));
$imageGrid->putImage($one, 3,3, 7, 7);
}
break;
case "9":
if (file_exists($fileServer.checkBg($str_arr[8])))
{
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[0]));
$imageGrid->putImage($one, 3,3, 0, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[1]));
$imageGrid->putImage($one, 4,3, 3, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[2]));
$imageGrid->putImage($one, 3,3, 7, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[3]));
$imageGrid->putImage($one, 3,4, 0, 3);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[4]));
$imageGrid->putImage($one, 4,4, 3, 3);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[5]));
$imageGrid->putImage($one, 3,4,7, 3);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[6]));
$imageGrid->putImage($one, 4,3, 3, 7);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[7]));
$imageGrid->putImage($one, 3,3, 0, 7);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[8]));
$imageGrid->putImage($one, 3,3, 7, 7);
}
break;
case "10":
if (file_exists($fileServer.checkBg($str_arr[9])))
{
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[0]));
$imageGrid->putImage($one, 7,3, 0, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[1]));
$imageGrid->putImage($one, 3,3, 7, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[2]));
$imageGrid->putImage($one, 3,2, 0, 3);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[3]));
$imageGrid->putImage($one, 4,2, 3, 3);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[4]));
$imageGrid->putImage($one, 3,2,7, 3);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[5]));
$imageGrid->putImage($one, 3,2, 0, 5);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[6]));
$imageGrid->putImage($one, 4,2, 3, 5);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[7]));
$imageGrid->putImage($one, 3,2,7, 5);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[8]));
$imageGrid->putImage($one, 7,3, 3, 7);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[9]));
$imageGrid->putImage($one, 3,3, 0, 7);
}
break;
default:
if (file_exists($fileServer.checkBg($str_arr[9])))
{
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[0]));
$imageGrid->putImage($one, 7,3, 0, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[1]));
$imageGrid->putImage($one, 3,3, 7, 0);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[2]));
$imageGrid->putImage($one, 3,2, 0, 3);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[3]));
$imageGrid->putImage($one, 4,2, 3, 3);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[4]));
$imageGrid->putImage($one, 3,2,7, 3);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[5]));
$imageGrid->putImage($one, 3,2, 0, 5);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[6]));
$imageGrid->putImage($one, 4,2, 3, 5);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[7]));
$imageGrid->putImage($one, 3,2,7, 5);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[8]));
$imageGrid->putImage($one, 7,3, 3, 7);
$one = imagecreatefromjpeg($fileServer.checkBg($str_arr[9]));
$imageGrid->putImage($one, 3,3, 0, 7);}
}
/*print_r($str_arr);*/
/*echo $str_arr[0];*/
/* $one = imagecreatefromjpeg("media/d9244-r6306Qkb_400x400.jpg");
$imageGrid->putImage($one, 5,5, 0, 0);
$one = imagecreatefromjpeg("v/uploads/gthumbs/0f2fb5a3fb9e7b735b89d8f33c45da168Wallpaper-l-001.jpg");
$imageGrid->putImage($one, 5,5, 5, 0);
$one = imagecreatefromjpeg("media/d9244-r6306Qkb_400x400.jpg");
$imageGrid->putImage($one, 5,5, 0, 5);
$one = imagecreatefromjpeg("v/uploads/gthumbs/0f2fb5a3fb9e7b735b89d8f33c45da168Wallpaper-l-001.jpg");
$imageGrid->putImage($one, 5,5, 5, 5);
*/
if (empty($str_arr[0]))
{ $image ="images/backgrounds/bg-4.jpg";
$one = imagecreatefromjpeg($image);
$imageGrid->putImage($one, 10,10, 0, 0);
}
$imageGrid->display();
?>