( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
Class DBSQL
{
function DBSQL($DBName)
{
/*
$videoondemand=mysql_pconnect($DBHost,$DBUser,$DBPassword);
mysql_select_db($DBName,$videoondemand);
$this->CONN = $videoondemand;
return true;*/
global $DBHost,$DBUser,$DBPassword;
$conn = mysqli_connect($DBHost,$DBUser,$DBPassword,$DBName);
/*$conn=mysql_connect($DBHost,$DBUser,$DBPassword);
mysql_select_db($DBName,$conn); */
$this->CONN = $conn;
return true;
}
function select($sql="")
{
if (empty($sql)) return false;
if (empty($this->CONN)) return false;
$conn = $this->CONN;
$results = mysqli_query($conn,$sql);
if ((!$results) or (empty($results)))
{
return false;
}
$count = 0;
$data = array();
while ($row = mysqli_fetch_array($results)) {
$data[$count] = $row;
$count++;
}
mysqli_free_result($results);
return $data;
}
function insert($sql="")
{
if (empty($sql)) return false;
if (empty($this->CONN)) return false;
$conn = $this->CONN;
$results = mysqli_query($conn,$sql);
if (!$results) return false;
$results = mysqli_insert_id($this->CONN);
return $results;
}
function update($sql="")
{
if(empty($sql)) return false;
if(empty($this->CONN)) return false;
$conn = $this->CONN;
$result = mysqli_query($conn,$sql);
return $result;
}
function delete($sql="")
{
if(empty($sql)) return false;
if(empty($this->CONN)) return false;
$conn = $this->CONN;
$result = mysqli_query($conn,$sql);
return $result;
}
function createtable($sql="")
{
if(empty($sql)) return false;
if(empty($this->CONN)) return false;
$conn = $this->CONN;
$result = mysqli_query($conn,$sql);
return $result;
}
function droptable($sql="")
{
if(empty($sql)) return false;
if(empty($this->CONN)) return false;
$conn = $this->CONN;
$result = mysqli_query($conn,$sql);
return $result;
}
function createindex($sql="")
{
if(empty($sql)) return false;
if(empty($this->CONN)) return false;
$conn = $this->CONN;
$result = mysqli_query($conn,$sql);
return $result;
}
function dropindex($sql="")
{
if(empty($sql)) return false;
if(empty($this->CONN)) return false;
$conn = $this->CONN;
$result = mysqli_query($conn,$sql);
return $result;
}
}
Class NewsSQL extends DBSQL
{
// the constructor
function NewsSQL($dbname = "")
{
$this->DBSQL($dbname);
}
function getusercategory($videouser)
{
$sql = "select * from users where catalogid=$videouser";
$result = $this->select($sql);
return $result;
}
function slug($str){
$str = strtolower(trim($str));
$str = preg_replace('/[^a-z0-9-]/', '-', $str);
$str = preg_replace('/-+/', "-", $str);
return $str;
}
function addvideofile($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload)
{
$sqlc = "select * from users where catalogid=$videouser";
$resultc = $this->select($sqlc);
$vcat = $resultc[0]["category"];
$username = $resultc[0]["user_name"];
$catalogname = $resultc[0]["catalogname"];
$user_email = $resultc[0]["user_email"];
$episodeid = $resultc[0]["episodeid"];
$county = $resultc[0]["county"];
$sqlo = "select * from users where catalogid=$yanani";
$result0 = $this->select($sqlo);
$vcato = $resulto[0]["category"];
$usernameo = $resulto[0]["user_name"];
$catalognameo = $resulto[0]["catalogname"];
$user_emailo = $resulto[0]["user_email"];
$nameReporta = $usernameo;
$emailReporta = $usernameo;
$emailAdmin = "sokottah2@gmail.com";
$message = "Hi $username \n
The Reporter $nameReporta has submitted content for your approval \n
Please kindly have a look
Thank You \n
Eziki Team \n
$host_upper ";
/* mail( $emailAdmin, "A reporter has submitted a story!", $message,
"From: \"Eziki Reporta\" <reporta@$host>\r\n" .
"X-Mailer: PHP/" . phpversion());*/
$message = "Hi $username \n
We have successfully received your content \n
Kindly wait for it to be approved \n
Thank You \n
Eziki Team \n
$host_upper ";
/*
mail($user_email, "We have received your story!", $message,
"From: \"Eziki \" <info@$host>\r\n" .
"X-Mailer: PHP/" . phpversion()); */
$adddate = date("y-m-d");
$viewnum = "1";
$ratenum = "1";
//$titleme = strtolower($titleme);
$titleme = mysqli_real_escape_string($link,$titleme);
$part = substr($titleme,-500);
$part = explode('.',$part);
$part = $part[0];
$part = preg_replace('/[\!@#$%^&*()+=\',.;:]/', '', $part);
$slugx = "$part";
$keywords = preg_replace('/[\!@#$%^&*()+=\'-,.;:]/', '', $part);
$keywords = trim($keywords);
$keywords = str_replace(" ", ",", $keywords);
$keyworda = str_replace("-", "", $keywords);
$keyworda = str_replace(",,", ",", $keyworda);
$keyworda = str_replace(",,,", ",", $keyworda);
if ($videouser ==99)
{
$viral = 99;
$isdisplay =20;
}
else
{
$viral = 0;
$isdisplay = 3;
}
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
$newsid=rand(1111111111111,9999999999999999);
$query = mysqli_query("INSERT INTO `reporta` (appno,message,catalogid_fk,catalogid, ip,created,type,original,isdisplay,keywords,slug,newsid) VALUES ('$appno','$part', '$yanani', '$yanani','$ip','$time',$type,'$upload','$isdisplay','$keyworda','$url','$time')") or die(mysql_error());
/* $sql = "insert into reporta (catalogid,title,yanani,video,isdisplay,picture,viewnum,ratenum,adddate,keywords,slug,type,original,episodeid,county) values ('$viral','$part','$yanani','$db_file','$isdisplay','$new_image','$viewnum','$ratenum','$adddate','$keyworda','$url','$type','$upload','$episodeid','$county')";
$results = $this->insert($sql);*/
return $results;
}
function addstarfile($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload)
{
$sqlc = "select * from users where catalogid=$videouser";
$resultc = $this->select($sqlc);
$vcat = $resultc[0]["category"];
$username = $resultc[0]["user_name"];
$catalogname = $resultc[0]["catalogname"];
$user_email = $resultc[0]["user_email"];
$episodeid = $resultc[0]["episodeid"];
$county = $resultc[0]["county"];
$sqlo = "select * from users where catalogid=$yanani";
$result0 = $this->select($sqlo);
$vcato = $resulto[0]["category"];
$usernameo = $resulto[0]["user_name"];
$catalognameo = $resulto[0]["catalogname"];
$user_emailo = $resulto[0]["user_email"];
$adddate = time();
$viewnum = "1";
$ratenum = "1";
//$titleme = strtolower($titleme);
$titleme = mysqli_real_escape_string($link,$titleme);
$part = substr($titleme,-500);
$part = explode('.',$part);
$part = $part[0];
$part = preg_replace('/[\!@#$%^&*()+=\',.;:]/', '', $part);
$slugx = "$part";
$keywords = preg_replace('/[\!@#$%^&*()+=\'-,.;:]/', '', $part);
$keywords = trim($keywords);
$keywords = str_replace(" ", ",", $keywords);
$keyworda = str_replace("-", "", $keywords);
$keyworda = str_replace(",,", ",", $keyworda);
$keyworda = str_replace(",,,", ",", $keyworda);
if ($videouser ==99)
{
$viral = 99;
$isdisplay =20;
}
else
{
$viral = 0;
$isdisplay = 3;
}
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
$newsid=rand(1111111111111,9999999999999999);
$query = mysqli_query("INSERT INTO `profilepicture` (appno,title,catalogid, ip,adddate,picture,isdisplay,keywords,slug,type) VALUES ('$appno','$part', '$yanani','$ip','$adddate','$upload','3','$keyworda','$url','2')") or die(mysql_error());
return $results;
}
function replaceit($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload,$oldpic,$picID,$who)
{
$source ="uploads/startags/$upload";
$desti = str_replace(".png",".jpg",$source);
$desti2 = str_replace(".gif",".jpg",$source);
$image_path="uploads/gthumbs/$upload";
$check ="uploads/gallery/$upload";
//Get the original image dimensions + type
//Figure out if we need to create a new JPG, PNG or GIF
$ext = strtolower(pathinfo($source, PATHINFO_EXTENSION));
if ($ext == "png") {
$brand = imagecreatefrompng($source);
$brand_width = imagesx($brand);
$brand_height = imagesy($brand);
$background = imagecreatefromjpeg('default.jpg');
$size = getimagesize('default.jpg');
$dest_x = 0;
$dest_y = 0;
imagecopy($background, $brand, $dest_x, $dest_y, 0, 0, $brand_width, $brand_height);
/*$fontZ = 'Yellowtail-Regular.ttf'; //font used
$font_color2 = imagecolorallocate($background, 208, 208, 208); // Create blue color
$slug = "thebrand.co.ke/";
imagettftext($background,20, 0, 20, 570, $font_color2, $fontZ, $slug); */
unlink($source);
imagejpeg($background, $desti, 100);
/* $image = imagecreatefrompng($source);
$bg = imagecreatetruecolor(imagesx($image), imagesy($image));
imagefill($bg, 0, 0, imagecolorallocate($bg, 255, 255, 255));
imagealphablending($bg, TRUE);
imagecopy($bg, $image, 0, 0, 0, 0, imagesx($image), imagesy($image));
imagedestroy($image);
$quality = 100;
$rand= rand(100000000000,9999999999);
$destination="uploads/gallery/$rand.jpg";
$image_path="uploads/gthumbs/$rand.jpg";
imagejpeg($bg, $destination, $quality);
imagedestroy($bg);
$upload="$rand.jpg";
$source =$destination;*/
/*unlink($source); */
}
if ($ext == "gif") {
$brand = imagecreatefromgif($source);
$brand_width = imagesx($brand);
$brand_height = imagesy($brand);
$background = imagecreatefromjpeg('default.jpg');
$size = getimagesize('default.jpg');
$dest_x = $size[0] - $brand_width - 5;
$dest_y = $size[1] - $brand_height - 5;
imagecopy($background, $brand, $dest_x, $dest_y, 0, 0, $brand_width, $brand_height);
/*$fontZ = 'Yellowtail-Regular.ttf'; //font used
$font_color2 = imagecolorallocate($background, 208, 208, 208); // Create blue color
$slug = "thebrand.co.ke/";
imagettftext($background,20, 0, 20, 570, $font_color2, $fontZ, $slug); */
unlink($source);
imagejpeg($background, $desti2, 100); }
$sqlc = "select * from users where catalogid=$videouser";
$resultc = $this->select($sqlc);
$vcat = $resultc[0]["category"];
$username = $resultc[0]["user_name"];
$catalogname = $resultc[0]["catalogname"];
$user_email = $resultc[0]["user_email"];
$episodeid = $resultc[0]["episodeid"];
$county = $resultc[0]["county"];
$sqlo = "select * from users where catalogid=$yanani";
$result0 = $this->select($sqlo);
$vcato = $resulto[0]["category"];
$usernameo = $resulto[0]["user_name"];
$catalognameo = $resulto[0]["catalogname"];
$user_emailo = $resulto[0]["user_email"];
$adddate = time();
$viewnum = "1";
$ratenum = "1";
//$titleme = strtolower($titleme);
$titleme = mysqli_real_escape_string($link,$titleme);
$part = substr($titleme,-500);
$part = explode('.',$part);
$part = $part[0];
$part = preg_replace('/[\!@#$%^&*()+=\',.;:]/', '', $part);
$slugx = "$part";
$keywords = preg_replace('/[\!@#$%^&*()+=\'-,.;:]/', '', $part);
$keywords = trim($keywords);
$keywords = str_replace(" ", ",", $keywords);
$keyworda = str_replace("-", "", $keywords);
$keyworda = str_replace(",,", ",", $keyworda);
$keyworda = str_replace(",,,", ",", $keyworda);
if ($videouser ==99)
{
$viral = 99;
$isdisplay =20;
}
else
{
$viral = 0;
$isdisplay = 3;
}
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
$newsid=rand(1111111111111,9999999999999999);
if ($ext == "png") {$upload = basename($desti);}
if ($ext == "gif") {$upload = basename($desti);}
$time = time();
$sql = "UPDATE posts SET id='0' where catalogid='$who'";
$result = $this->update($sql);
$ext = strtolower(pathinfo($titleme, PATHINFO_EXTENSION));
$titleme = basename($titleme);
$titleme = str_replace(".$ext","",$titleme);
$query = mysqli_query("INSERT INTO `posts` (themeid,catalogid,picture,title,id) VALUES ('$picID', '$who','$upload','$titleme','1')") or die(mysql_error());
/*
$sql = "UPDATE profilepicture SET picture='$upload', adddate='$time', isdisplay='14' where id='$picID'";
$result = $this->update($sql);
$sql = "select * from layerorder WHERE themeid='$picID' and position='0'";
$result = $this->select($sql);
$Oldimage = $result[0]["name"];
if(!empty($Oldimage))
{
$str = str_replace('?', '&', $Oldimage);
parse_str($str, $output);
$image=$output['image'];
$oldFile=basename($image);
$finalImage=str_replace($oldFile, $upload, $Oldimage);
$sql = "UPDATE layerorder SET name = '$finalImage' WHERE themeid='$picID' and position='0'";
$results = $this->update($sql);
unlink($image);
}
*/
return $results;
}
function market($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload)
{
$image_path="uploads/gthumbs/$upload";
$sqlc = "select * from users where catalogid=$videouser";
$resultc = $this->select($sqlc);
$vcat = $resultc[0]["category"];
$username = $resultc[0]["user_name"];
$catalogname = $resultc[0]["catalogname"];
$user_email = $resultc[0]["user_email"];
$episodeid = $resultc[0]["episodeid"];
$county = $resultc[0]["county"];
$sqlo = "select * from users where catalogid=$yanani";
$result0 = $this->select($sqlo);
$vcato = $resulto[0]["category"];
$usernameo = $resulto[0]["user_name"];
$catalognameo = $resulto[0]["catalogname"];
$user_emailo = $resulto[0]["user_email"];
$adddate = time();
$viewnum = "1";
$ratenum = "1";
//$titleme = strtolower($titleme);
$titleme = mysqli_real_escape_string($link,$titleme);
$part = substr($titleme,-500);
$part = explode('.',$part);
$part = $part[0];
$part = preg_replace('/[\!@#$%^&*()+=\',.;:]/', '', $part);
$slugx = "$part";
$keywords = preg_replace('/[\!@#$%^&*()+=\'-,.;:]/', '', $part);
$keywords = trim($keywords);
$keywords = str_replace(" ", ",", $keywords);
$keyworda = str_replace("-", "", $keywords);
$keyworda = str_replace(",,", ",", $keyworda);
$keyworda = str_replace(",,,", ",", $keyworda);
if ($videouser ==99)
{
$viral = 99;
$isdisplay =20;
}
else
{
$viral = 0;
$isdisplay = 3;
}
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
$newsid=rand(1111111111111,9999999999999999);
if ($ext == "png") {$upload = basename($desti);}
if ($ext == "gif") {$upload = basename($desti);}
$time = time();
$query = mysqli_query("insert into profilepicture (catalogid,title,def,picture,type,isdisplay,adddate) values ('$yanani','$titleme','2','$upload','3','11',$time)") or die(mysql_error());
return $results;
}
function theme($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload)
{
$source ="uploads/startags/$upload";
$desti = str_replace(".png",".jpg",$source);
$desti2 = str_replace(".gif",".jpg",$source);
$image_path="uploads/gthumbs/$upload";
$check ="uploads/gallery/$upload";
//Get the original image dimensions + type
//Figure out if we need to create a new JPG, PNG or GIF
$ext = strtolower(pathinfo($source, PATHINFO_EXTENSION));
if ($ext == "png") {
$brand = imagecreatefrompng($source);
$brand_width = imagesx($brand);
$brand_height = imagesy($brand);
$background = imagecreatefromjpeg('default.jpg');
$size = getimagesize('default.jpg');
$dest_x = 0;
$dest_y = 0;
imagecopy($background, $brand, $dest_x, $dest_y, 0, 0, $brand_width, $brand_height);
/*$fontZ = 'Yellowtail-Regular.ttf'; //font used
$font_color2 = imagecolorallocate($background, 208, 208, 208); // Create blue color
$slug = "thebrand.co.ke/";
imagettftext($background,20, 0, 20, 570, $font_color2, $fontZ, $slug); */
unlink($source);
imagejpeg($background, $desti, 100);
/* $image = imagecreatefrompng($source);
$bg = imagecreatetruecolor(imagesx($image), imagesy($image));
imagefill($bg, 0, 0, imagecolorallocate($bg, 255, 255, 255));
imagealphablending($bg, TRUE);
imagecopy($bg, $image, 0, 0, 0, 0, imagesx($image), imagesy($image));
imagedestroy($image);
$quality = 100;
$rand= rand(100000000000,9999999999);
$destination="uploads/gallery/$rand.jpg";
$image_path="uploads/gthumbs/$rand.jpg";
imagejpeg($bg, $destination, $quality);
imagedestroy($bg);
$upload="$rand.jpg";
$source =$destination;*/
/*unlink($source); */
}
if ($ext == "gif") {
$brand = imagecreatefromgif($source);
$brand_width = imagesx($brand);
$brand_height = imagesy($brand);
$background = imagecreatefromjpeg('default.jpg');
$size = getimagesize('default.jpg');
$dest_x = $size[0] - $brand_width - 5;
$dest_y = $size[1] - $brand_height - 5;
imagecopy($background, $brand, $dest_x, $dest_y, 0, 0, $brand_width, $brand_height);
/*$fontZ = 'Yellowtail-Regular.ttf'; //font used
$font_color2 = imagecolorallocate($background, 208, 208, 208); // Create blue color
$slug = "thebrand.co.ke/";
imagettftext($background,20, 0, 20, 570, $font_color2, $fontZ, $slug); */
unlink($source);
imagejpeg($background, $desti2, 100); }
$sqlc = "select * from users where catalogid=$videouser";
$resultc = $this->select($sqlc);
$vcat = $resultc[0]["category"];
$username = $resultc[0]["user_name"];
$catalogname = $resultc[0]["catalogname"];
$user_email = $resultc[0]["user_email"];
$episodeid = $resultc[0]["episodeid"];
$county = $resultc[0]["county"];
$sqlo = "select * from users where catalogid=$yanani";
$result0 = $this->select($sqlo);
$vcato = $resulto[0]["category"];
$usernameo = $resulto[0]["user_name"];
$catalognameo = $resulto[0]["catalogname"];
$user_emailo = $resulto[0]["user_email"];
$adddate = time();
$viewnum = "1";
$ratenum = "1";
//$titleme = strtolower($titleme);
$titleme = mysqli_real_escape_string($link,$titleme);
$part = substr($titleme,-500);
$part = explode('.',$part);
$part = $part[0];
$part = preg_replace('/[\!@#$%^&*()+=\',.;:]/', '', $part);
$slugx = "$part";
$keywords = preg_replace('/[\!@#$%^&*()+=\'-,.;:]/', '', $part);
$keywords = trim($keywords);
$keywords = str_replace(" ", ",", $keywords);
$keyworda = str_replace("-", "", $keywords);
$keyworda = str_replace(",,", ",", $keyworda);
$keyworda = str_replace(",,,", ",", $keyworda);
if ($videouser ==99)
{
$viral = 99;
$isdisplay =20;
}
else
{
$viral = 0;
$isdisplay = 3;
}
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
$newsid=rand(1111111111111,9999999999999999);
if ($ext == "png") {$upload = basename($desti);}
if ($ext == "gif") {$upload = basename($desti);}
$query = mysqli_query("INSERT INTO `profilepicture` (title,catalogid, ip,adddate,picture,isdisplay,keywords,slug,type) VALUES ('$part', '$yanani','$ip','$adddate','$upload','3','$keyworda','$url','2')") or die(mysql_error());
return $results;
}
function addMyGraphics($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload)
{
$titleme = mysqli_real_escape_string($link,$titleme);
$part = substr($titleme,-500);
$part = explode('.',$part);
$part = $part[0];
$part = preg_replace('/[\!@#$%^&*()+=\',.;:]/', '', $part);
$type = "1";
$description = "Realistic";
$type = "5";
$description = "Social";
$query = mysqli_query("insert into layouts (catalogid,picture,title,description,type) values ('$yanani','$upload','$part','$description','$type')") or die(mysql_error());
}
function addprofile($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload)
{
$sqlc = "select * from users where catalogid=$yanani";
$resultc = $this->select($sqlc);
$username = $resultc[0]["user_name"];
$query = mysqli_query("insert into profilepicture (catalogid,title,def,picture,type) values ('$yanani','$username','2','$upload','1')") or die(mysql_error());
//add default theme
$sqld = "delete from profilepicture where catalogid=$yanani and title='Blank'";
$resultd = $this->delete($sqld);
$blank ="Blank";
$time =time();
$query = mysqli_query("insert into profilepicture (catalogid,title,isdisplay,picture,type,adddate,poster) values ('$yanani','$blank','13','$upload','2','$time','$upload')") or die(mysql_error());
//add default theme
$sqld = "delete from layerorder where catalogid=$yanani and type=0";
$resultd = $this->delete($sqld);
$sqlp = "select * from profilepicture where catalogid=$yanani and type=2 order by id desc limit 0,1";
$resultp = $this->select($sqlp);
$newsid = $resultp[0]["newsid"];
$username = $resultc[0]["user_name"];
$query = mysqli_query("INSERT INTO `layerorder` ( `fontText`, `fontUrl`, `fontName`, `fontUser`, `name`, `layertype`, `catalogid`, `themeid`, `position`, `layerw`, `layerh`, `layerx`, `layery`, `layerr`, `layeropacity`, `layerflipv`, `layerfliph`, `layerbg`, `text`, `font`, `type`) VALUES ( NULL, NULL, NULL, NULL, 'taswira.php?quality=100&width=600w&height=600&cropratio=1:1&image=/v/uploads/gthumbs/$upload&route=profilePic', 'Background', '$yanani', '$newsid', 0, '600', '600', '0', '0', '0', '100', 0, 0, '#666666', NULL, NULL, 0)") or die(mysql_error());
return $results;
}
function ThreeDFonts($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload)
{
$query = mysqli_query("insert into 3DFonts (catalogid,title,picture,type,isdisplay) values ('$yanani','$titleme','$upload','3','11')") or die(mysql_error());
return $results;
}
function addgalleryPhotos($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload)
{
$sqlc = "select * from users where catalogid=$yanani";
$resultc = $this->select($sqlc);
$username = $resultc[0]["user_name"];
$query = mysqli_query("insert into posts (catalogid,title,id,picture,type) values ('$yanani','$username','0','$upload','1')") or die(mysql_error());
$upload = basename("uploads/gthumbs/$upload");
$newUrl ="uploads/gthumbs/$upload";
$picture = basename($upload);
$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';
$quality = 100;
$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($dest_img, $source_img, 0 , 0 , $src_x, $src_y, $crop_w, $crop_h, $orig_w, $orig_h);
$outputFunction($dest_img, $newUrl, $quality);
return $results;
}
function addgallery($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload)
{
/*
$query = mysqli_query("insert into profilepicture (catalogid,title,def,picture,type) values ('$yanani','$titleme','2','$upload','3')") or die(mysql_error());*/
$query = mysqli_query("insert into profilepicture (catalogid,title,def,picture,type,isdisplay) values ('$yanani','$titleme','2','$upload','3','11')") or die(mysql_error());
$upload = basename("uploads/gthumbs/$upload");
$newUrl ="uploads/gthumbs/$upload";
$picture = basename($upload);
$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';
$quality = 100;
$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($dest_img, $source_img, 0 , 0 , $src_x, $src_y, $crop_w, $crop_h, $orig_w, $orig_h);
$outputFunction($dest_img, $newUrl, $quality);
return $results;
}
function mygallery($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload)
{
$upload ="uploads/gallery/$upload";
$newUrl="uploads/gthumbs/$upload";
$picture = basename($upload);
$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';
$quality = 100;
$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($dest_img, $source_img, 0 , 0 , $src_x, $src_y, $crop_w, $crop_h, $orig_w, $orig_h);
$outputFunction($dest_img, $newUrl, $quality);
$query = mysqli_query("insert into posts (catalogid) values ('$yanani')") or die(mysql_error());
return $results;
}
function replacebrand($pic,$videouser)
{
/* $sql = 'select * from profilepicture where picture="\$pic\" and catalogid="$videouser"';
$result = $this->select($sql);
$picture = $result[0]["picture"];
$newsid = $result[0]["newsid"];}
*/
$time = time();
$sql = "UPDATE profilepicture SET isdisplay='3', adddate='$time' where picture='$pic' and catalogid='$videouser'";
$result = $this->update($sql);
return $result;
}
/* function add_profilePicture($newsid,$userfile_name,$PicturePath)
{
$sql = "select picture from profilepicture where id='$newsid'";
$result = $this->select($sql);
$picture = $result[0]["picture"];
if (!empty($picture)){
$file = $PicturePath.$picture;
unlink($file);
}
$sql = "UPDATE profilepicture SET picture=\"$userfile_name\" WHERE id='$newsid'";
$result = $this->update($sql);
return $result;
}*/
function distributionfile($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$kind,$upload)
{
$sqlc = "select * from users where catalogid=$videouser";
$resultc = $this->select($sqlc);
$vcat = $resultc[0]["category"];
$username = $resultc[0]["user_name"];
$catalogname = $resultc[0]["catalogname"];
$user_email = $resultc[0]["user_email"];
$episodeid = $resultc[0]["episodeid"];
$county = $resultc[0]["county"];
$sqlo = "select * from users where catalogid=$yanani";
$result0 = $this->select($sqlo);
$vcato = $resulto[0]["category"];
$usernameo = $resulto[0]["user_name"];
$catalognameo = $resulto[0]["catalogname"];
$user_emailo = $resulto[0]["user_email"];
$nameReporta = $usernameo;
$emailReporta = $usernameo;
$emailAdmin = "sokottah2@gmail.com";
$message = "Hi $username \n
The Reporter $nameReporta has submitted content for your approval \n
Please kindly have a look
Thank You \n
Eziki Team \n
$host_upper ";
/* mail( $emailAdmin, "A reporter has submitted a story!", $message,
"From: \"Eziki Reporta\" <reporta@$host>\r\n" .
"X-Mailer: PHP/" . phpversion());*/
$message = "Hi $username \n
We have successfully received your content \n
Kindly wait for it to be approved \n
Thank You \n
Eziki Team \n
$host_upper ";
/*
mail($user_email, "We have received your story!", $message,
"From: \"Eziki \" <info@$host>\r\n" .
"X-Mailer: PHP/" . phpversion()); */
$adddate = time();
$viewnum = "1";
$ratenum = "1";
//$titleme = strtolower($titleme);
$titleme = mysqli_real_escape_string($link,$titleme);
$part = substr($titleme,-500);
$part = explode('.',$part);
$part = $part[0];
$part = preg_replace('/[\!@#$%^&*()+=\',.;:]/', '', $part);
$slugx = "$part";
$keywords = preg_replace('/[\!@#$%^&*()+=\'-,.;:]/', '', $part);
$keywords = trim($keywords);
$keywords = str_replace(" ", ",", $keywords);
$keyworda = str_replace("-", "", $keywords);
$keyworda = str_replace(",,", ",", $keyworda);
$keyworda = str_replace(",,,", ",", $keyworda);
if ($videouser ==99)
{
$viral = 99;
$isdisplay =20;
}
else
{
$viral = 0;
$isdisplay = 3;
}
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
$newsid=rand(1111111111111,9999999999999999);
$sql = "insert into distribute (catalogid,title,video,isdisplay,picture,adddate,keywords,slug,type,original) values ('$yanani','$part','$upload','3','$upload','$adddate','$keyworda','$url','$kind','$upload')";
$query = mysqli_query($sql) or die(mysql_error());
return $results;
}
function addtogallery($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload)
{
$source ="uploads/gallery/$upload";
$image_path="uploads/gthumbs/$upload";
$check ="uploads/gallery/$upload";
//Get the original image dimensions + type
//Figure out if we need to create a new JPG, PNG or GIF
$ext = strtolower(pathinfo($source, PATHINFO_EXTENSION));
if ($ext == "png") {
$image = imagecreatefrompng($source);
$bg = imagecreatetruecolor(imagesx($image), imagesy($image));
imagefill($bg, 0, 0, imagecolorallocate($bg, 255, 255, 255));
imagealphablending($bg, TRUE);
imagecopy($bg, $image, 0, 0, 0, 0, imagesx($image), imagesy($image));
imagedestroy($image);
$quality = 100;
$rand= rand(100000000000,9999999999);
$destination="uploads/gallery/$rand.jpg";
$image_path="uploads/gthumbs/$rand.jpg";
imagejpeg($bg, $destination, $quality);
imagedestroy($bg);
$upload="$rand.jpg";
$source =$destination;
/*unlink($source); */
}
if ($ext == "gif") {
$image = imagecreatefromgif($source);
$bg = imagecreatetruecolor(imagesx($image), imagesy($image));
imagefill($bg, 0, 0, imagecolorallocate($bg, 255, 255, 255));
imagealphablending($bg, TRUE);
imagecopy($bg, $image, 0, 0, 0, 0, imagesx($image), imagesy($image));
imagedestroy($image);
$quality = 100;
$rand= rand(100000000000,9999999999);
$destination="uploads/gallery/$rand.jpg";
$image_path="uploads/gthumbs/$rand.jpg";
imagejpeg($bg, $destination, $quality);
imagedestroy($bg);
$upload="$rand.jpg";
$source =$destination;
unlink($source);
}
$sqlc = "select * from users where catalogid=$videouser";
$resultc = $this->select($sqlc);
$vcat = $resultc[0]["category"];
$username = $resultc[0]["user_name"];
$catalogname = $resultc[0]["catalogname"];
$user_email = $resultc[0]["user_email"];
$episodeid = $resultc[0]["episodeid"];
$county = $resultc[0]["county"];
$sqlo = "select * from users where catalogid=$yanani";
$result0 = $this->select($sqlo);
$vcato = $resulto[0]["category"];
$usernameo = $resulto[0]["user_name"];
$catalognameo = $resulto[0]["catalogname"];
$user_emailo = $resulto[0]["user_email"];
$nameReporta = $usernameo;
$emailReporta = $usernameo;
$emailAdmin = "sokottah2@gmail.com";
$message = "Hi $username \n
The Reporter $nameReporta has submitted content for your approval \n
Please kindly have a look
Thank You \n
Eziki Team \n
$host_upper ";
/* mail( $emailAdmin, "A reporter has submitted a story!", $message,
"From: \"Eziki Reporta\" <reporta@$host>\r\n" .
"X-Mailer: PHP/" . phpversion());*/
$message = "Hi $username \n
We have successfully received your content \n
Kindly wait for it to be approved \n
Thank You \n
Eziki Team \n
$host_upper ";
/*
mail($user_email, "We have received your story!", $message,
"From: \"Eziki \" <info@$host>\r\n" .
"X-Mailer: PHP/" . phpversion()); */
$adddate = time();
$viewnum = "1";
$ratenum = "1";
//$titleme = strtolower($titleme);
$titleme = mysqli_real_escape_string($link,$titleme);
$part = substr($titleme,-500);
$part = explode('.',$part);
$part = $part[0];
$part = preg_replace('/[\!@#$%^&*()+=\',.;:]/', '', $part);
$slugx = "$part";
$keywords = preg_replace('/[\!@#$%^&*()+=\'-,.;:]/', '', $part);
$keywords = trim($keywords);
$keywords = str_replace(" ", ",", $keywords);
$keyworda = str_replace("-", "", $keywords);
$keyworda = str_replace(",,", ",", $keyworda);
$keyworda = str_replace(",,,", ",", $keyworda);
if ($videouser ==99)
{
$viral = 99;
$isdisplay =20;
}
else
{
$viral = 0;
$isdisplay = 3;
}
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
$newsid=rand(1111111111111,9999999999999999);
$query = mysqli_query("INSERT INTO `profilepicture` (title,catalogid, ip,adddate,picture,isdisplay,keywords,slug,type) VALUES ('$part', '$yanani','$ip','$adddate','$upload','11','$keyworda','$url','3')") or die(mysql_error());
$w=600;
$h=600;
//Get the original image dimensions + type
list($source_width, $source_height, $source_type) = getimagesize($source);
//Figure out if we need to create a new JPG, PNG or GIF
$ext = strtolower(pathinfo($source, PATHINFO_EXTENSION));
if ($ext == "jpg" || $ext == "jpeg") {
$source_gdim=imagecreatefromjpeg($source);
} elseif ($ext == "png") {
$source_gdim=imagecreatefrompng($source);
} elseif ($ext == "gif") {
$source_gdim=imagecreatefromgif($source);
} else {
//Invalid file type? Return.
return;
}
if ($w && !$h) {
$ratio = $w / $source_width;
$temp_width = $w;
$temp_height = $source_height * $ratio;
$background = imagecreatetruecolor($temp_width, $temp_height);
imagecopyresampled(
$background,
$source_gdim,
0, 0,
0, 0,
$temp_width, $temp_height,
$source_width, $source_height
);
} else {
$source_aspect_ratio = $source_width / $source_height;
$desired_aspect_ratio = $w / $h;
if ($source_aspect_ratio > $desired_aspect_ratio) {
$temp_height = $h;
$temp_width = ( int ) ($h * $source_aspect_ratio);
} else {
$temp_width = $w;
$temp_height = ( int ) ($w / $source_aspect_ratio);
}
$temp_gdim = imagecreatetruecolor($temp_width, $temp_height);
imagecopyresampled(
$temp_gdim,
$source_gdim,
0, 0,
0, 0,
$temp_width, $temp_height,
$source_width, $source_height
);
$x0 = ($temp_width - $w) / 2;
$y0 = ($temp_height - $h) / 2;
$background = imagecreatetruecolor($w, $h);
imagecopy(
$background,
$temp_gdim,
0, 0,
$x0, $y0,
$w, $h
);
}
if ($ext == "jpg" || $ext == "jpeg") {
ImageJpeg($background,$image_path,100);
} elseif ($ext == "png") {
ImagePng($background,$image_path);
} elseif ($ext == "gif") {
ImageGif($background,$image_path);
} else {
return;
}
ImageDestroy ($background);
$ext = strtolower(pathinfo($check, PATHINFO_EXTENSION));
if ($ext == "png") {
unlink($check);
}
return $results;
}
function addtobfma($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload)
{
$source ="uploads/gallery/$upload";
$image_path="uploads/raw/$upload";
$check ="uploads/gallery/$upload";
//Get the original image dimensions + type
//Figure out if we need to create a new JPG, PNG or GIF
$ext = strtolower(pathinfo($source, PATHINFO_EXTENSION));
if ($ext == "png") {
$image = imagecreatefrompng($source);
$bg = imagecreatetruecolor(imagesx($image), imagesy($image));
imagefill($bg, 0, 0, imagecolorallocate($bg, 255, 255, 255));
imagealphablending($bg, TRUE);
imagecopy($bg, $image, 0, 0, 0, 0, imagesx($image), imagesy($image));
imagedestroy($image);
$quality = 100;
$rand= rand(100000000000,9999999999);
$destination="uploads/gallery/$rand.jpg";
$image_path="uploads/raw/$rand.jpg";
imagejpeg($bg, $destination, $quality);
imagedestroy($bg);
$upload="$rand.jpg";
$source =$destination;
/*unlink($source); */
}
if ($ext == "gif") {
$image = imagecreatefromgif($source);
$bg = imagecreatetruecolor(imagesx($image), imagesy($image));
imagefill($bg, 0, 0, imagecolorallocate($bg, 255, 255, 255));
imagealphablending($bg, TRUE);
imagecopy($bg, $image, 0, 0, 0, 0, imagesx($image), imagesy($image));
imagedestroy($image);
$quality = 100;
$rand= rand(100000000000,9999999999);
$destination="uploads/gallery/$rand.jpg";
$image_path="uploads/raw/$rand.jpg";
imagejpeg($bg, $destination, $quality);
imagedestroy($bg);
$upload="$rand.jpg";
$source =$destination;
unlink($source);
}
$adddate = time();
$viewnum = "1";
$ratenum = "1";
//$titleme = strtolower($titleme);
$titleme = mysqli_real_escape_string($link,$titleme);
$part = substr($titleme,-500);
$part = explode('.',$part);
$part = $part[0];
$part = preg_replace('/[\!@#$%^&*()+=\',.;:]/', '', $part);
$slugx = "$part";
$keywords = preg_replace('/[\!@#$%^&*()+=\'-,.;:]/', '', $part);
$keywords = trim($keywords);
$keywords = str_replace(" ", ",", $keywords);
$keyworda = str_replace("-", "", $keywords);
$keyworda = str_replace(",,", ",", $keyworda);
$keyworda = str_replace(",,,", ",", $keyworda);
if ($videouser ==99)
{
$viral = 99;
$isdisplay =20;
}
else
{
$viral = 0;
$isdisplay = 3;
}
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
$newsid=rand(1111111111111,9999999999999999);
$query = mysqli_query("INSERT INTO `reporta` (appno,message,catalogid_fk,catalogid, ip,created,type,original,isdisplay,keywords,slug,newsid) VALUES ('$appno','$part', '911', '911','$ip','$time','6','$upload','15','$keyworda','$url','$time')") or die(mysql_error());
$w=600;
$h=600;
//Get the original image dimensions + type
list($source_width, $source_height, $source_type) = getimagesize($source);
//Figure out if we need to create a new JPG, PNG or GIF
$ext = strtolower(pathinfo($source, PATHINFO_EXTENSION));
if ($ext == "jpg" || $ext == "jpeg") {
$source_gdim=imagecreatefromjpeg($source);
} elseif ($ext == "png") {
$source_gdim=imagecreatefrompng($source);
} elseif ($ext == "gif") {
$source_gdim=imagecreatefromgif($source);
} else {
//Invalid file type? Return.
return;
}
if ($w && !$h) {
$ratio = $w / $source_width;
$temp_width = $w;
$temp_height = $source_height * $ratio;
$background = imagecreatetruecolor($temp_width, $temp_height);
imagecopyresampled(
$background,
$source_gdim,
0, 0,
0, 0,
$temp_width, $temp_height,
$source_width, $source_height
);
} else {
$source_aspect_ratio = $source_width / $source_height;
$desired_aspect_ratio = $w / $h;
if ($source_aspect_ratio > $desired_aspect_ratio) {
$temp_height = $h;
$temp_width = ( int ) ($h * $source_aspect_ratio);
} else {
$temp_width = $w;
$temp_height = ( int ) ($w / $source_aspect_ratio);
}
$background = gd_apply_overlay($background, 'redcarpet', 100);
$temp_gdim = imagecreatetruecolor($temp_width, $temp_height);
imagecopyresampled(
$temp_gdim,
$source_gdim,
0, 0,
0, 0,
$temp_width, $temp_height,
$source_width, $source_height
);
$x0 = ($temp_width - $w) / 2;
$y0 = ($temp_height - $h) / 2;
$background = imagecreatetruecolor($w, $h);
imagecopy(
$background,
$temp_gdim,
0, 0,
$x0, $y0,
$w, $h
);
}
if ($ext == "jpg" || $ext == "jpeg") {
ImageJpeg($background,$image_path,100);
} elseif ($ext == "png") {
ImagePng($background,$image_path);
} elseif ($ext == "gif") {
ImageGif($background,$image_path);
} else {
return;
}
ImageDestroy ($background);
$ext = strtolower(pathinfo($check, PATHINFO_EXTENSION));
if ($ext == "png") {
unlink($check);
}
return $results;
}
function addbranding($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload)
{
$adddate = time();
$viewnum = "1";
$ratenum = "1";
//$titleme = strtolower($titleme);
$titleme = mysqli_real_escape_string($link,$titleme);
$part = substr($titleme,-500);
$part = explode('.',$part);
$part = $part[0];
$part = preg_replace('/[\!@#$%^&*()+=\',.;:]/', '', $part);
$slugx = "$part";
$keywords = preg_replace('/[\!@#$%^&*()+=\'-,.;:]/', '', $part);
$keywords = trim($keywords);
$keywords = str_replace(" ", ",", $keywords);
$keyworda = str_replace("-", "", $keywords);
$keyworda = str_replace(",,", ",", $keyworda);
$keyworda = str_replace(",,,", ",", $keyworda);
$message = "BFMA 2015 ".$part;
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
$newsid=rand(1111111111111,9999999999999999);
$query = mysqli_query("INSERT INTO `reporta` (appno,message,catalogid_fk,catalogid, ip,created,type,original,isdisplay,keywords,slug,newsid) VALUES ('$appno','$message', '254722407698', '254722407698','$ip','$time','6','$upload','15','$keyworda','$url','$time')") or die(mysql_error());
return $results;
}
function addphoto($yanani,$type,$upload)
{
$query = mysqli_query("INSERT INTO `profilepicture` (catalogid,picture,isdisplay) VALUES ('$yanani', '$upload','$type')") or die(mysql_error());
return $results;
}
}
$rs_settings = mysqli_query($link,"select * from users where catalogid='$_SESSION[euserid]'");
?>