( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
include('../Connections/videoondemand.php');
Class DBSQL
{
function DBSQL($DBName)
{
global $DBHost,$DBUser,$DBPassword;
$videoondemand=mysql_pconnect($DBHost,$DBUser,$DBPassword);
mysql_select_db($DBName,$videoondemand);
$this->CONN = $videoondemand;
return true;
}
function select($sql="")
{
if (empty($sql)) return false;
if (empty($this->CONN)) return false;
$videoondemand = $this->CONN;
$results = mysqli_query($sql,$videoondemand);
if ((!$results) or (empty($results)))
{
return false;
}
$count = 0;
$data = array();
while ($row = mysql_fetch_array($results)) {
$data[$count] = $row;
$count++;
}
mysql_free_result($results);
return $data;
}
function insert($sql="")
{
if (empty($sql)) return false;
if (empty($this->CONN)) return false;
$videoondemand = $this->CONN;
$results = mysqli_query($sql,$videoondemand);
if (!$results) return false;
$results = mysql_insert_id();
return $results;
}
function update($sql="")
{
if(empty($sql)) return false;
if(empty($this->CONN)) return false;
$videoondemand = $this->CONN;
$result = mysqli_query($sql,$videoondemand);
return $result;
}
function delete($sql="")
{
if(empty($sql)) return false;
if(empty($this->CONN)) return false;
$videoondemand = $this->CONN;
$result = mysqli_query($sql,$videoondemand);
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"];
$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` (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());
/* $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 addlayouts($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload)
{
$part = substr($titleme,-500);
$part = explode('.',$part);
$part = $part[0];
$part = preg_replace('/[\!@#$%^&*()+=\',.;:]/', '', $part);
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
$newsid=rand(1111111111111,9999999999999999);
$query = mysqli_query("INSERT INTO `layouts` (appno,title,catalogid, ip,adddate,picture,isdisplay,type) VALUES ('$appno','$part', '$yanani','$ip','$adddate','$upload','3','3')") or die(mysql_error());
return $results;
}
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());
return $results;
}
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 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', '254722407698', '254722407698','$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 gd_apply_overlay($background, $brand, $amount)
{
$width = 600; $height = 600;
// 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 = $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 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]'");
?>