( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ HEX
HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux mail.thebrand.ai 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: www-data (33)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/tmpr/../tmpr/..//tmpr/..//ezikiframework.php
<?php
include("protect.php");
include('Connections/videoondemand.php');
require("DbSql.inc.php");
require("NewsSql.inc.php"); 
$db = new NewsSQL($DBName);
$tandau = yaw($tandau, "qiu3ggrubfabffuwhfuiwhfiwgfiub");
$tandao = yaw($tandao, "qiu3ggrubfabffuwhfuiwhfiwgfiub");
 
$mode=$_GET["mode"];

if($mode=="Deal") {
	 
 $id = mysqli_real_escape_string($link,$_GET['id']);
$amount = mysqli_real_escape_string($link,$_GET['amount']);
 $reaction = mysqli_real_escape_string($link,$_GET['reaction']);	
    $effecto = mysqli_real_escape_string($link,$_GET['effecto']);
	  $yanani = mysqli_real_escape_string($link,$_GET['yanani']);	
 $catalogid = mysqli_real_escape_string($link,$_GET['catalogid']);
 mysqli_query("UPDATE connections SET isdisplay= '7' WHERE id= '$id'");
exit(1);}
	
	 
 if($mode=="ReplyToConnection") {
	 
 $id = mysqli_real_escape_string($link,$_GET['id']);
$amount = mysqli_real_escape_string($link,$_GET['amount']);
 $reaction = mysqli_real_escape_string($link,$_GET['reaction']);	
    $effecto = mysqli_real_escape_string($link,$_GET['effecto']);
	  $yanani = mysqli_real_escape_string($link,$_GET['yanani']);	
 $catalogid = mysqli_real_escape_string($link,$_GET['catalogid']);
    	 
  	 
					switch ($effecto)
					{
						case '3':
						$str ="offer";
						$condition =",reaction= '$reaction'";
						$who =" and yanani= '$yanani'";
						$state =4;
						break;
						case '4':
						$str ="counteroffer";
						$condition ="";
						$who =" and catalogid= '$catalogid'";
						$state =5;
						
						break;
						case '5':
						$str ="finaloffer";
						$condition =",reaction= '$reaction'";
						$who =" and yanani= '$yanani'";
						$state =6;
						
						break;
					
						default:
						exit("0");
						break;
						 
						
					}

 
mysqli_query("UPDATE connections SET $str= '$amount' $condition ,isdisplay= '$state' WHERE id= '$id' $who");

exit(1);
     
    } 
  //start of go save
  if($mode=="updateConnecta") {
	 
 $id = mysqli_real_escape_string($link,$_GET['id']);
$description = mysqli_real_escape_string($link,$_GET['description']);
$when = mysqli_real_escape_string($link,$_GET['when']);
 $where = mysqli_real_escape_string($link,$_GET['where']);
	  $yanani = mysqli_real_escape_string($link,$_GET['yanani']);	
 $catalogid = mysqli_real_escape_string($link,$_GET['catalogid']);
    	 
  	  
 
mysqli_query("UPDATE connections SET  comments= '$description',when= '$when',where = '$where' WHERE id= '$id' and isdisplay='3'");

exit(1);
     
    } 		
 
 if($mode=="connect") {
	 
 $description = mysqli_real_escape_string($link,$_GET['description']);
$when = mysqli_real_escape_string($link,$_GET['when']);
 $where = mysqli_real_escape_string($link,$_GET['where']);	
    $type = mysqli_real_escape_string($link,$_GET['type']);
	$timeis = mysqli_real_escape_string($link,$_GET['time']);
	$offer = mysqli_real_escape_string($link,$_GET['offer']);
	$counteroffer = mysqli_real_escape_string($link,$_GET['counteroffer']);
	$finaloffer = mysqli_real_escape_string($link,$_GET['finaloffer']);	
	$deal = mysqli_real_escape_string($link,$_GET['deal']);
	  $yanani = mysqli_real_escape_string($link,$_GET['yanani']);	
 $catalogid = mysqli_real_escape_string($link,$_GET['catalogid']);
 
		$ip = $_SERVER["REMOTE_ADDR"];
		
    	 
  	 
					switch ($type)
					{
						case 'Gig':
						$str ="1";
						break;
						case 'Meeting':
						$str ="2";
						
						break;
						case 'Studio':
						$str ="3";
						
						break;
						case 'Collabo':
						$str ="4";
						break;
						case 'Interview':
						$str ="5";
						break;
						default:
						exit();
						break;
						 
						
					}

			




    	$query = mysqli_query("SELECT * FROM connections where yanani= '$yanani' and catalogid= '$catalogid' and type= '$str' and isdisplay= '3'"); 
    	while($data = mysql_fetch_assoc($query)){
    		$rate_db[] = $data;
    	}

    	if(@count($rate_db) == 0 ){
			 
			$time = time();
    		 $sql_insert = "INSERT INTO connections (`when`, `where`,`ip`, `catalogid`, `yanani`, `isdisplay`, `comments`, `type`, `time`, `timeis`) VALUES ('$when', '$where', '$ip', '$catalogid', '$yanani', '3', '$description', '$str', '$time', '$timeis')";
		mysqli_query($sql_insert,$link) or die("0" . mysql_error());
		exit("1");
    	} 
		else {
		 exit("0");}
    } 
  //start of go save
  
 if($mode=="eventRate") {
	
	 	$ip = $_SERVER["REMOTE_ADDR"];
    	$therate = $_GET['rate'];
    	 $thepost = $_GET['theid'];
		 $qn = $_GET['qn'];
  	 
					switch ($qn)
					{
						case '1':
						$str ="performance";
						break;
						case '2':
						$str ="satisfied";
						
						break;
						case '3':
						$str ="punctuality";
						
						break;
						
						 
						
					}

			

mysqli_query("UPDATE connections SET $str= '$therate' WHERE id= '$thepost'");
exit("UPDATE connections SET $str= '$therate' WHERE id= '$thepost'");
			
	
     		
							 	
					 }
			
			
			
			
			
			
			
			
			
			
			
			
			
			
 	
 
 if($mode=="rate") {
	 
	 	$ip = $_SERVER["REMOTE_ADDR"];
    	$therate = $_GET['rate'];
    	 $thepost = $_GET['theid'];
		 $qn = $_GET['qn'];
  	 
					switch ($qn)
					{
						case '1':
						$str ="originality";
						break;
						case '2':
						$str ="quality";
						
						break;
						case '3':
						$str ="sound";
						
						break;
						case '4':
						$str ="creativity";
						break;
						 
						
					}

			




    	$query = mysqli_query("SELECT * FROM distributions where id= '$thepost'  "); 
    	while($data = mysql_fetch_assoc($query)){
    		$rate_db[] = $data;
    	}

    	if(@count($rate_db) == 0 ){
    		
    	}else{
    		mysqli_query("UPDATE distributions SET $str= '$therate' WHERE id= '$thepost'");
			
			
			 
			
			$query = "select * from distributions where id=$thepost";
						 $result = mysqli_query($query,$videoondemand);
						 while($row2 = mysql_fetch_assoc($result))
						{
						
						
										$yanani = $row2['yanani'];
										$catalogid = $row2['catalogid'];
										$distribution = $row2['distribution'];
										$newsid = $row2['newsid'];
										$rate = $row2['rate'];
										
										
						$query = "SELECT AVG($str) as detail FROM distributions where distribution= '$distribution'"; 
						$result = mysqli_query($query) or die(mysql_error());
						while($row = mysql_fetch_array($result)){
						
	 mysqli_query("UPDATE distribute SET $str= ".$row['detail']." WHERE newsid= '$distribution'");
	 



						$query = "select * from distribute WHERE newsid= '$distribution'";
						 $result = mysqli_query($query,$videoondemand);
						 while($row2 = mysql_fetch_assoc($result))
						{
						
										$originality = $row2['originality'];
										$quality = $row2['quality'];
										$sound = $row2['sound'];
										$creativity = $row2['creativity'];
										 $avg = ($creativity + $sound + $quality + $originality)/4;
										mysqli_query("UPDATE distribute SET average='$avg' WHERE newsid= '$distribution'");
										 
										 
						
						}












	 
	 
}				
							exit();					
					 }
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
    	}
    } 
  //start of go save
  
  if($mode=="emailContent") {
 
$email= $_GET['email'];
$yanani=$_SESSION['euserid'];
 $name= $_GET['name'];
 $femail= $_GET['femail'];
 $fname= $_GET['fname'];
 $who= $_GET['who'];
 $distribute= $_GET['distribute'];
 
 
 //check if he is on users list 
 $rs_duplicate = mysqli_query("select count(*) as total from users where user_email='$femail'") or die(mysql_error());
list($total) = mysql_fetch_row($rs_duplicate);

if ($total > 0)
{

 
}
else

{
	
	
	
$user_ip = $_SERVER['REMOTE_ADDR'];	
$slug  =  $fname; 
 $slug = preg_replace( '/[«»""!?,.!@£$%^&*{};:()]+/', '', $slug);
   $slug = strtolower($slug);
   $slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $slug);	

	
	$sql_insert = "INSERT into `users`
  			(`catalogname`,`user_email`,`admin`,`date`,`users_ip`,`slug`)
		    VALUES
		    ('$fname','$femail','20',now(),'$user_ip','$slug')";
			
			 
mysqli_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
$user_id = mysql_insert_id($link);


$message = 
"
Hi $fname \n 

Welcome to Mimi. \n 

Mimi is a Content Distribution Network allowing Artists, Film Makers and Publishers to  share content \n


like Music, Videos, Photos and Documents with you. \n

$who has shared  content with you today \n


Kindly login in to http://ziqi.co.ke to download this Content \n
  

Thank You \n

Mimi Team
ziqi.co.ke

";
 
	mail($femail, "$fname , $who has shared content  with you on Mimi.co.ke", $message,
    "From: \"$fname\" <auto-reply@ziqi.co.ke>\r\n" .
     "X-Mailer: PHP/" . phpversion());
	
 	
}
 
 //end check  
 
 
 
 
 
 
 $rs_duplicate2 = mysqli_query("select count(*) as total from mailing where femail='$femail' and catalogid='$yanani'") or die(mysql_error());
list($total2) = mysql_fetch_row($rs_duplicate2);

if ($total2 > 0)
{


}
	else
	{
		$sql_insert2 = "INSERT into `mailing`
  			(`fname`,`femail`,`catalogid`)
		    VALUES
		    ('$fname','$femail','$yanani')
			";
	mysqli_query($sql_insert2,$link) or die("Insertion Failed:" . mysql_error());
	
	}
	
 
 
 
 

 
 
  $sqlF = "SELECT `catalogid`  FROM users WHERE  `user_email` = '$femail'"; 
			$resultF = mysqli_query($sqlF) or die (mysql_error()); 
$numF = mysql_num_rows($resultF);
  // Match row found with more than 1 results  - the user is authenticated. 
    if ( $numF > 0 ) { 
	
	list($catalogidF) = mysql_fetch_row($resultF);
	
	
	
	
	
	
	
	$result5 = mysqli_query("select count(*) as total from distributions where yanani=$yanani");
while($row5 = mysql_fetch_assoc($result5))
		{
		
		
		$icount5 = $row5['total'];
		 
		}

$result2 = mysqli_query("select count(*) as total from distributions where yanani=$yanani and catalogid=$catalogidF and distribution=$distribute");
while($row2 = mysql_fetch_assoc($result2))
		{
		
		
		$icount = $row2['total'];
		
 
							if ($icount < 1) {
								
								 $result3 = mysqli_query("select count(*) as total2 from distributions where yanani=$yanani");
							while($row2 = mysql_fetch_assoc($result3))
															{
															$icount2 = $row2['total2'];
														
														
													
			 										 
															
																				if ($icount2 < 1000) {
																					
																					
							 
	
	mysqli_query("insert into distributions(yanani,distribution,catalogid,isdisplay) values('$yanani','$distribute','$catalogidF','1') ") or die(mysql_error());

if($catalogidF == 1005023688676278)
{
	mysqli_query("insert into distributions(yanani,distribution,catalogid,isdisplay) values('$yanani','$distribute','1005023688676281','1') ") or die(mysql_error());
	mysqli_query("insert into distributions(yanani,distribution,catalogid,isdisplay) values('$yanani','$distribute','1005023688676282','1') ") or die(mysql_error());
	mysqli_query("insert into distributions(yanani,distribution,catalogid,isdisplay) values('$yanani','$distribute','1005023688676277','1') ") or die(mysql_error());
	 mysqli_query("insert into distributions(yanani,distribution,catalogid,isdisplay) values('$yanani','$distribute','1005023688676301','1') ") or die(mysql_error());
	  mysqli_query("insert into distributions(yanani,distribution,catalogid,isdisplay) values('$yanani','$distribute','1005023688676299','1') ") or die(mysql_error());
	   mysqli_query("insert into distributions(yanani,distribution,catalogid,isdisplay) values('$yanani','$distribute','1005023688676278','1') ") or die(mysql_error());
  
	   mysqli_query("insert into distributions(yanani,distribution,catalogid,isdisplay) values('$yanani','$distribute','1005023688676280','1') ") or die(mysql_error());
}



	
	 $nameinfo2 = $db->getallugccatalogname(); 
                if (!empty($nameinfo2)){
	            while (list($key,$val)=each($nameinfo2)) {
		    $tempcatalogid2 = stripslashes($val["catalogid"]);
		    $user_email = stripslashes($val["user_email"]);
			 $catalogname = stripslashes($val["catalogname"]);
			$slug = stripslashes($val["slug"]);
		    if ($catalogidF==$tempcatalogid2){ 
			$message = 
"Hi $catalogname \n 
Welcome to Mimi. \n New Content has been uploaded to your control panel
 Thank You \n
Mimi Team
ziqi.co.ke
";
echo "$user_email";
mail($user_email, "New Content has been uploaded ", $message,
    "From: \"Mimi\" <auto-reply@ziqi.co.ke>\r\n" .
     "X-Mailer: PHP/" . phpversion());
}	}	}							
								
	
	
	
	
	
	
	
																					
																					
																					
		 												
																				
																				
																				
																				
																				
																				
		
		
		
		//COUNT IT
				 $counter = mysqli_query("select count(*) as mycount from distributions where yanani=$yanani");
							while($row2 = mysql_fetch_assoc($counter))
															{
															$mycount = $row2['mycount'];
															
															
															 
														if (!empty($_GET['runingaID'])){
														//exit();
															echo "$mycount";
														 }
														else {
														echo "$mycount";
														}	
															
														 
															
															}
		
															
																				}
																				else {
																				
																				
																				echo "Max";
																				
																				}
																				
																				
																				
															
															
															
															}
																
							
							
							}
		else {
		
		if (!empty($_GET['runingaID'])){
														 
														 }
														else {
														print "$icount5";
														}	
														
														
														
														
														
		
		}
		}


	
	
	
	
	
	
	
	
	
	}
 
















 }
 
  
  //end of go save
  
  
  
  
  
  
  
  
  
  
  
  
  

if($_POST['deletefromcart'])

{


$cartitem = $_POST['deletefromcart'];
   $query = "DELETE FROM distributions where id = $cartitem";

   $result = mysqli_query($query,$videoondemand);  
   } 

if($_POST['deleteplaylist'])

{
   $query = 'DELETE FROM ilikethis where id = '.(int)$_POST['deleteplaylist'];

   $result = mysqli_query($query,$videoondemand);  
   }
   
   
  
 
 if($_POST['deletewidget'])

{
   $query = 'DELETE FROM api WHERE id = '.(int)$_POST['deletewidget'];

   $result = mysqli_query($query,$videoondemand);  
   }
 
 
  if(isset($_POST['thememe']))

{
    $id = $_POST['thememe'];
   $user = $_SESSION['euserid'];
  $username =$_SESSION['user_name'];
	$query = "UPDATE users SET themeid = '$id' where catalogid=$user";
		mysqli_query($query) or die('Error, insert query failed');	
		
		 $newidd="2";
 $mycomment5 = "$username has chosen a new  theme";
mysqli_query("insert into icomment(mycomment,myname,newsid,id,catalogid) values('$mycomment5','','','$newidd','$user')") 
or die(mysql_error());  
		
		
		
		
		
		
		
		
			   


}




 if($_POST['followme'])

{
   
   
   $query_Minilatestvideos = 'select * from usercontent where isdisplay=1 and vcat= '.(int)$_POST['followme'].' order by newsid desc limit 0,10'; 
   include("includes/encrypt.php");
  
$encrypted = encrypt($query_Minilatestvideos, "chitgoks");


$user = $_SESSION['euserid'];
$table = "usercontent";

						 mysql_select_db($DBName, $videoondemand);
						 $query = "select count(*) as total from api where user=$user order by id desc";
						 $result = mysqli_query($query,$videoondemand);
						 while($row = mysql_fetch_assoc($result))
						{
						if ($row['total'] >9)
										{
										exit();
										 }
										 
										 else
										  {
										   
										  
									 
   
				
														$nameinfos = $db->getallcategory(); 
										if (!empty($nameinfos)){
										while (list($key,$val)=each($nameinfos)) {
									$tempcategoryid = stripslashes($val["categoryid"]);
									$categoryname = stripslashes($val["categoryname"]);
								 $slug = stripslashes($val["slug"]);
									if ( (int)$_POST['followme'] ==$tempcategoryid){
								 
								$user3 =$_SESSION['user_name'];
								 $mycomment5 = "$user3 is following the category <a href=category/channels/$slug>$categoryname</a>";
 								
 						/*mysqli_query("insert into icomment(mycomment,myname,newsid,id,catalogid) values('$mycomment5','$myname','$newsid','2','0')") 
 or die(mysql_error());  */
 								   
 								  
 								  $icon = "<img src=\"images/icons/cate.png\" align=\"texttop\" vspace=\"1\" > Following $categoryname ";
								  
$insertcate = "insert into api(user, myquery,title) values('$user','$encrypted','$icon')"; 

								  $result2 = mysqli_query($insertcate);	
								  
								  
									}
								 }
								}		  
										  
										  
										   
										 }
						
}









   }
 
 
 
 
 
 
 
 
 
 if($_POST['channelfollow'])

{
 
   $query_Minilatestvideos2 = 'SELECT * FROM usercontent al LEFT JOIN ilikethis im ON al.newsid  = im.newsid where yanani = '.(int)$_POST['channelfollow'].' limit 0,10 '; 
   $query_Minilatestvideos = 'select * from usercontent where isdisplay=1 and catalogid= '.(int)$_POST['channelfollow'].' order by newsid desc limit 0,10'; 
   include("includes/encrypt.php");
  
$encrypted = encrypt($query_Minilatestvideos, "chitgoks");
$encrypted2 = encrypt($query_Minilatestvideos2, "chitgoks");

$user = $_SESSION['euserid'];
$table = "usercontent";

						 mysql_select_db($DBName, $videoondemand);
						 $query = "select count(*) as total from api where user=$user order by id desc";
						 $result = mysqli_query($query,$videoondemand);
						 while($row = mysql_fetch_assoc($result))
						{
						if ($row['total'] >9)
										{
										exit();
										 }
										 
										 else
										  {
										   
					$nani = (int)$_POST['channelfollow'];					  
				 $query = "select * from users where catalogid=$nani";
						 $result = mysqli_query($query,$videoondemand);
						 while($row2 = mysql_fetch_assoc($result))
						{
						
						
										$admin = $row2['admin'];
										if ($admin ==1) {
										
											$catalogname = $row2['catalogname']; 
						$slug = $row2['slug'];
						
						$user3 =$_SESSION['user_name'];
						 $newidd="2";
 $mycomment5 = "$user3 is following  <a href =$slug target=_blank>$catalogname</a>";
mysqli_query("insert into icomment(mycomment,myname,newsid,id,catalogid) values('$mycomment5','','$slug','$newidd','$nani')") 
or die(mysql_error());  
						
						
						
						
						
						
						
			
				//mysqli_query("insert into icomment(mycomment,myname,newsid,id,catalogid) values('$mycomment5','$myname','$newsid','0','0')") 
//or die(mysql_error());

 
								  $icon = "<img src=\"images/icons/cog2.png\" align=\"texttop\" vspace=\"1\" > Following $catalogname  ";
								  
$insertcate = "insert into api(user, myquery,title) values('$user','$encrypted','$icon')"; 

								  $result2 = mysqli_query($insertcate);
								  $title = "";
					
							$delcate = "delete from api where title = '$title' "; 
								  $delresult = mysqli_query($delcate);
								
										
										}
										
										
									if ($admin ==0) {
							 
						$catalogname = $row2['catalogname']; 
						$slug = $row2['slug'];
						
						 $newidd="2";
 $mycomment5 = "A guest is following  <a href =$slug target=_blank>$catalogname</a>";
mysqli_query("insert into icomment(mycomment,myname,newsid,id,catalogid) values('$mycomment5','','$slug','$newidd','$nani')") 
or die(mysql_error());  
						
			
				//mysqli_query("insert into icomment(mycomment,myname,newsid,id,catalogid) values('$mycomment5','$myname','$newsid','0','0')") 
//or die(mysql_error());

 
								  $icon = "<img src=\"images/icons/socialc.png\" align=\"texttop\" vspace=\"1\" > Following $catalogname  ";
								  
$insertcate = "insert into api(user, myquery,title) values('$user','$encrypted2','$icon')"; 

								  $result2 = mysqli_query($insertcate);
					
								  
										
										
										}
										
										
										
										
										
										
										
										
										
										
										
										
										
						
					
					
						}					 
  
  
            
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
			
				
}
						
}

 }
 
 
 
 
 
 
 
 
 
 
 
if(isset($_GET['dc']))

{
$page = $_GET['page'];
$_GET['sn'] = $sn;
   $query = 'DELETE FROM icomment where sn = '.(int)$_GET['sn'].' and id = '.(int)$_GET['dc'];

   $result5 = mysqli_query($query,$videoondemand);
   header("Location: ./$page");
   
   }
//check user

 if($mode=="check") {
 
$user=$_GET["user"];

$user = @ereg_replace("[^A-Za-z0-9]", "", $user);
 

if(empty($user) && strlen($user) <4) {
echo "Please enter 5 chars or more";
 exit();
}

$result = mysqli_query("select count(*) as total from users where slug='$user' ") or die(mysql_error());

while($row = mysql_fetch_assoc($result))
		{	$total = $row["total"];
 

	if ($total > 0)
	{
	echo "<br />
Sorry the newsid eziki.tv/$user is <strong>taken</strong>.

 <a href=videos/v/register.php>Please Try again</a> ";
	} else {
	$_SESSION['euserid']= $user;
	
 $user = preg_replace('/[\!-@#$%^&*()+=,.;:]/', '', $user); 
	 $user = preg_replace('/eziki/', '', $user); 
	  $user = preg_replace('/eziki.tv/', '', $user);
	echo "<br />
The newsid <strong>eziki.tv/$user</strong> is <strong>available</strong>   

 <img src=images/done.png hspace=3 align=texttop><a href=videos/v/register.php?msg2=$user><strong>Click here to Get it!</strong></a> 



";
	}
}
 
}













//search channel from seo news





 if($mode=="channelsearch2") {
 $query=$_GET["keyword"];
$query=$_GET["query"];
 $query = mysqli_real_escape_string($link,$query);
 
 	
 $result4 = mysqli_query("select * from usercontent where isdisplay=1 and  (title like '%$query%') order by newsid desc Limit 10;");
	while($row4 = mysql_fetch_assoc($result4))
 
		
		
		{	$title = $row4["title"];
		$slug = $row4["slug"];
		$picture = $row4["picture"];
		$newsid = $row4["newsid"];
		?>
		
		<div id="csstde">
		 <a href="<?php print $slug;?>"><img src="v/uploads/images/<?php print $picture;?>" border="0" width="100" height="60" /></a>
		 
		  <a href="videos/<?php print $slug;?>"><strong><?php print $title;?></strong></a>
		 </div>
		 
		<?php
		
				}	
				
		print "<div style=\"clear:both;\"><div id=\"rule\"></div></div>";		
				

 }





//search channel from seo news





 if($mode=="mainsearch") {
 $query=$_GET["keyword"];
  $query = mysqli_real_escape_string($link,$query);
 	
 $result4 = mysqli_query("select * from usercontent where isdisplay=1 and (title like '%$query%') order by newsid desc Limit 10;");
	while($row4 = mysql_fetch_assoc($result4))
 
		
		
		{	$title = $row4["title"];
		$slug = $row4["slug"];
		$picture = $row4["picture"];
		$newsid = $row4["newsid"];
		?>
		
		<div id="csstde">
		 <a href="<?php print $slug;?>"><img src="v/uploads/images/<?php print $picture;?>" border="0" width="100" height="60" /></a>
		 
		  <a href="videos/<?php print $slug;?>"><strong><?php print $title;?></strong></a>
		 </div>
		 
		<?php
		
				}	
				
		print "<div style=\"clear:both;\"><div id=\"rule\"></div></div>";		
				

 }





//search channelfrom channel






 if($mode=="channelsearch") {
 
$channelid=$_GET["channelid"];
$query=$_GET["query"];
 $query = mysqli_real_escape_string($link,$query);
 $query = mysqli_real_escape_string($link,$query);
 $query = @ereg_replace("[^A-Za-z0-9]", "", $query);
 
 
 	
 $result4 = mysqli_query("select * from usercontent where isdisplay=1 and  (title like '%$query%') and catalogid = $channelid order by newsid desc;");
	while($row4 = mysql_fetch_assoc($result4))
 
		
		
		{	$title = $row4["title"];
		$slug = $row4["slug"];
		$picture = $row4["picture"];
		$newsid = $row4["newsid"];
		?>
		
		<div id="csstde">
		 <a href="videos/<?php print $slug;?>">
		 <img src="videos/v/uploads/images/<?php print $picture;?>" border="0" width="100" height="60" />
		 </a>
		 
		  <a href="videos/<?php print $slug;?>"><strong><?php print $title;?></strong></a>
		 </div>
		 
		<?php
		
				}	
				
		print "<div style=\"clear:both;\"><div id=\"rule\"></div></div>";		
				

 }





 
if($mode=="fuata") {
$channelid= $_GET['channelid'];
$user=$_SESSION['euserid'];
$title=$_GET["channelname"];
$title = "Following $title";
$titlex = "";
	$delcate = "delete from api where title = '$titlex'"; 
								  $delresult = mysqli_query($delcate);

 $newidd="2";
 $mycomment5 = "A guest is following $title";
mysqli_query("insert into icomment(mycomment,myname,newsid,id,catalogid) values('$mycomment5','','','$newidd','$channelid')") 
or die(mysql_error());  
		




$username =$_SESSION['user_name'];
$time=date(y).date(m).date(d).date(h).date(i).date(s); //get current time 
 
$getchanneldetails = $db->getidtochannel($page,$front_searchresultrecord,$channelid);
			     if (!empty($getchanneldetails)) {
	      while ( list($key,$val)=each($getchanneldetails) ) {
	      $slug= stripslashes($val["slug"]);
		   $catalogname= stripslashes($val["catalogname"]);
		   $catalogid= stripslashes($val["catalogid"]);
	
										
						$catalogname = $row2['catalogname']; 
						$slug = $row2['slug'];
						
				 
						
		   
		   




	 	} 	 
	      }


 
			 $result4 = mysqli_query("select count(*) as total from api where  (title like '%$title%') and (user like '%$user%') order by id");
	while($row4 = mysql_fetch_assoc($result4))
		{	$icount4 = $row4["total"];
		
		//print $icount4;
				}	
				



if ($icount4 < 1) {
	
	$myidis = $_SESSION['euserid'];
	
	
	 $result5 = mysqli_query("select count(*) as total5 from api where user=$myidis");
	while($row5 = mysql_fetch_assoc($result5))
		{	$icount5 = $row5["total5"];
				
			//print $icount5;	
			
			
				}
				
		if ($icount4 < 10) {	
		
		
		
		
				 $resultb = mysqli_query("select * from users where catalogid=$channelid");
					while($rowb = mysql_fetch_assoc($resultb))
						{	
						$myadmin = $rowb["admin"];
		
		
							if ($myadmin ==1) {
							 $title = "<img src=\"images/icons/cog2.png\" align=\"texttop\" vspace=\"1\" > $title";
							
				$myquery = "select * from usercontent where isdisplay=1 and catalogid = $channelid order by newsid DESC LIMIT 10";
						
						include("includes/encrypt.php");
						  
						$myquery = encrypt($myquery, "chitgoks");
						$table = mysqli_real_escape_string($link,$table);
						
						mysqli_query("INSERT INTO api (user,title,myquery,ascdesc,num,code) VALUES('$user', '$title', '$myquery', '$ascdesc', '$num', '$channelid') "); 
							
							
							}
							
							
							if ($myadmin ==0) {
							  $title = "<img src=\"images/icons/socialc.png\" align=\"texttop\" vspace=\"1\" > $title";
$myquery = "SELECT * FROM usercontent al LEFT JOIN ilikethis im ON al.newsid = im.newsid WHERE yanani =$channelid LIMIT 0 , 10 "; 	
			
							include("includes/encrypt.php");
						  
						$myquery = encrypt($myquery, "chitgoks");
						
						
						mysqli_query("INSERT INTO api (user,title,myquery,ascdesc,num,code) VALUES('$user', '$title', '$myquery', '$ascdesc', '$num', '$channelid') "); 
						
			/*			$newidd="2";
 $mycomment5 = "A guest is following  <a href =$slug target=_blank>$catalogname</a>";
mysqli_query("insert into icomment(mycomment,myname,newsid,id,catalogid) values('$mycomment5','','$slug','$newidd','$nani')") 
or die(mysql_error());  */
							  
										
										
										}
							
							
							
							
							
							
		
		 
		
		
		}		
		
		
		
		
		
		
			
				
				













$result10 = mysqli_query("select * from api where  (title like '%$title%') order by id desc Limit 1;");
 
	while($row10 = mysql_fetch_assoc($result10))
		{	$id = $row10["id"];
		
		print "<strong>$title</strong><a href=\"#\" onclick=\"ezikiLoadRemote('targetArea4','widget$id');return false\"> View Widget</a>";
		
		
		}
 
				 
				
				}
				
				else {
				print "Maximum number of channels saved";
				
				}
				
		
}






 

 
 }






 if($mode=="clap") {
 
 
$user=$_GET["userid"];

$myname = $_SESSION['user_name']; 
 $mycomment= "$myname is Clapping!" ;
 	$myidis = $_SESSION['euserid']; 
	

mysqli_query("insert into scomment(mycomment,myname,id,catalogid,type) values('$mycomment','$myname','$myidis','$user','0')") 
or die(mysql_error());  
 

echo "<img src=images/done.png hspace=3 align=texttop> Successfully Clapped!";
 
}


 if($mode=="cheer") {
 
 
$user=$_GET["userid"];

$myname = $_SESSION['user_name']; 
 $mycomment= "$myname is Cheering!" ;
 	$myidis = $_SESSION['euserid']; 
	

mysqli_query("insert into scomment(mycomment,myname,id,catalogid,type) values('$mycomment','$myname','$myidis','$user','0')") 
or die(mysql_error());

echo "<img src=images/done.png hspace=3 align=texttop> Successfully Cheered!";


}

 if($mode=="ovation") {
 
 
$user=$_GET["userid"];

$myname = $_SESSION['user_name']; 
 $mycomment= "$myname has given a standing Ovation!" ;
 	$myidis = $_SESSION['euserid']; 
	

mysqli_query("insert into scomment(mycomment,myname,id,catalogid,type) values('$mycomment','$myname','$myidis','$user','0')") 
or die(mysql_error());

echo "<img src=images/done.png hspace=3 align=texttop> Successfully Gave Standing Ovation!";

}


 if($mode=="likeevent") {
 
$channelid=$_GET["channelid"];
$title=$_GET["channelname"];
$title2=$_GET["channelname"];
$user=$_GET["userid"];
$ascdesc= "DESC";
$table= "usercontent";
$num= "5";

 			
$username =$_SESSION['user_name'];
 $newidd="2";
 
 $mycomment5 = "$username likes the event $title";
mysqli_query("insert into icomment(mycomment,id,catalogid) values('$mycomment5','$newidd','$channelid')") 
or die(mysql_error());  
		
	 
 
 	$myidis = $_SESSION['euserid']; 
	

mysqli_query("insert into scomment(mycomment,myname,id,catalogid,type) values('$mycomment5','$username','$myidis','$channelid','0')") 
or die(mysql_error());  
	
		
		
		
		}





 if($mode=="trackchannel") {
 
$channelid=$_GET["channelid"];
$title=$_GET["channelname"];
$title2=$_GET["channelname"];
$user=$_GET["userid"];
$ascdesc= "DESC";
$table= "usercontent";
$num= "5";

 			
$username =$_SESSION['user_name'];
 $newidd="2";
 $theuser = "$username";
 $mycomment5 = "$username is following $title";
mysqli_query("insert into icomment(mycomment,id,catalogid) values('$mycomment5','$newidd','$channelid')") 
or die(mysql_error());  
		

					
		 
$time=time(); //get current time 
 
$getchanneldetails = $db->getidtochannel($channelid);
	
			     if (!empty($getchanneldetails)) {
	      while ( list($key,$val)=each($getchanneldetails) ) {
	      $slug= stripslashes($val["slug"]);
		   $catalogname= stripslashes($val["catalogname"]);
		   $catalogid= stripslashes($val["catalogid"]);
              $link= stripslashes($val["slug"]);
						
		   




	 	} 	 
	      }


 
			 $result4 = mysqli_query("select count(*) as total from api where  (title like '%$title%') and (user like '%$user%') order by id");
	while($row4 = mysql_fetch_assoc($result4))
		{	$icount4 = $row4["total"];
		
		//print $icount4;
				}	
				



if ($icount4 < 1) {
	
	$myidis = $_SESSION['euserid'];
	
	
	 $result5 = mysqli_query("select count(*) as total5 from api where user=$myidis");
	while($row5 = mysql_fetch_assoc($result5))
		{	$icount5 = $row5["total5"];
				
			//print $icount5;	
			
			
				}
				
		if ($icount4 < 10) {	
		
		
		
		
				 $resultb = mysqli_query("select * from users where catalogid=$channelid");
					while($rowb = mysql_fetch_assoc($resultb))
						{	
						$myadmin = $rowb["admin"];
		
		
							if ($myadmin ==1 || $myadmin ==4 ) {
							 $title = "<img src=\"images/icons/cog2.png\" align=\"texttop\" vspace=\"1\" > $title";
							
				$myquery = "select * from usercontent where isdisplay=1 and catalogid = $channelid order by newsid DESC LIMIT 10";
						
						include("includes/encrypt.php");
						  
						$myquery = encrypt($myquery, "chitgoks");
						$table = mysqli_real_escape_string($link,$table);
						
						mysqli_query("INSERT INTO api (user,title,myquery,ascdesc,num,code) VALUES('$user', '$title', '$myquery', '$ascdesc', '$num', '$channelid') "); 
							
							
							}
							
							
							
							
							if ($myadmin ==0) {
							  $title = "<img src=\"images/icons/socialc.png\" align=\"texttop\" vspace=\"1\" > $title";
$myquery = "SELECT * FROM usercontent al LEFT JOIN ilikethis im ON al.newsid = im.newsid WHERE yanani =$channelid LIMIT 0 , 10 "; 	
			
							include("includes/encrypt.php");
						  
						$myquery = encrypt($myquery, "chitgoks");
						
						
						mysqli_query("INSERT INTO api (user,title,myquery,ascdesc,num,code) VALUES('$user', '$title', '$myquery', '$ascdesc', '$num', '$channelid') "); 
						
			/*			$newidd="2";
 $mycomment5 = "A guest is following  <a href =$slug target=_blank>$catalogname</a>";
mysqli_query("insert into icomment(mycomment,myname,newsid,id,catalogid) values('$mycomment5','','$slug','$newidd','$nani')") 
or die(mysql_error());  */
							  
										
										
										}
							
							
							
							
							
							
		
		 
		
		
		}		
		
		
		
		
		
		
			
				
				













$result10 = mysqli_query("select * from api where  (title like '%$title%') order by id desc Limit 1;");
 
	while($row10 = mysql_fetch_assoc($result10))
		{	$id = $row10["id"];
		
		print "<strong>$title</strong><a href=\"#\" onclick=\"ezikiLoadRemote('targetArea4','widget$id');return false\"> View Schedule</a>";
		
				
													 
														 
				 
		if (isset($_SESSION['fbme'])) {	header("Location: fbmain.php?mode=follow&message=$title2&link=$link&pushschedule=$pushschedule");	
		
		$pushschedule = "<strong>$title</strong><a href=\"#\" onclick=\"ezikiLoadRemote('targetArea4','widget$id');return false\"> View Schedule</a>";
			}
				
				
				
		}
 
				 
				
				}
				
				else {
				print "Maximum number of channels saved";
				
				}
				
		
}







 

 
 }

























$cmode = $_POST['mode'];







$array 	= $_POST['recordsArray'];

if ($cmode == "crowdsource"){
	$video = $_POST["video"];
	
	$jina = $_POST["jina"];
	if (!isset($_SESSION['euserid'])) { 
	  $result4 = mysqli_query("select * from usercontent where isdisplay=1 and newsid=$video");
	while($row4 = mysql_fetch_assoc($result4))
 		
		{	$slug = $row4["slug"];
			exit("<b> Sorry. You need to login to suggest your recommendation:
 <a href=v/login.php?p=$slug>Click here to login</a></b> ");
	 
	}
	
  }  
	 
	
	
 
	
	
	
	$listingCounter = 1;
	foreach ($array as $newsidValue) {
	
	
	  $result4 = mysqli_query("select count(*) as counter from relevance where newsid=$video and related=$newsidValue");
	while($row4 = mysql_fetch_assoc($result4))
 		
		{	$counter = $row4["counter"];
	 
	}
	  if ($counter < 1)
	  {
	  
	  
	    $sql="insert into relevance (newsid,relevance,related,weight,user) values('$video', '$listingCounter', '$newsidValue', '1', '$jina')";  
	  mysqli_query($sql) or die('Error, insert query failed');
	 
	  
	  
	  $sql2="delete from relevance where relevance > 2";  
	  mysqli_query($sql2) or die('delete fail');
	   $listingCounter = $listingCounter + 1;
	  }
	  
	  else {
	   $result6 = mysqli_query("select weight from relevance where newsid=$video and related=$newsidValue");
	while($row6 = mysql_fetch_assoc($result6))
	
	{
	
	$weight = $row6["weight"];
	
	$query = "UPDATE relevance SET relevance = $listingCounter where newsid=$video and related=$newsidValue ";
		mysqli_query($query) or die('Error, insert query failed');
		
		
		
		  if ($listingCounter < 2)
	  {
		
		$weight = $weight + 1;
		
		$query = "UPDATE relevance SET weight = $weight where newsid=$video and related=$newsidValue ";
		mysqli_query($query) or die('Error, insert query failed');
		
		 		
		
		}
		
		
		
		  if ($listingCounter > 2)
	  {
		
		$weight = $weight - 1;
		
		$query = "UPDATE relevance SET weight = $weight where newsid=$video and related=$newsidValue ";
		mysqli_query($query) or die('Error, insert query failed');
		
		 		
		
		}
		
		
		
		
		$listingCounter = $listingCounter + 1;
		
		
		
	}
	    }
	   
	
	}
	
/*	echo '<pre>';
	print_r($array);
	echo '</pre>';*/
	echo '<img src=images/done.png hspace=3 align=texttop><strong>Thank you for your recommendation</strong><br />
(awaiting aggregation) ';
}



if ($cmode == "arrangewidget"){
	
	
	
	$listingCounter = 1;
	foreach ($array as $newsidValue) {
	
	exit("$newsidValue $array soooooooooooooooooo");
	
	  $result4 = mysqli_query("select rating,ratenum from usercontent where isdisplay=1 and newsid=$video");
	while($row4 = mysql_fetch_assoc($result4))
 		
		{	$rating = $row4["rating"];
	 $ratenum = $row4["ratenum"];
	 $OldR = $row4["rating"];
      $OldN = $row4["ratenum"];
	  

      $NewN = $OldN+1;
      $NewR = ($OldR*$OldN+$Rating)/$NewN;	   
	 $sql = "update usercontent set rating=$NewR,ratenum=$NewN,relevance=$$NewR where newsid=$video";
	
	echo '$jina $video<img src=images/done.png hspace=3 align=texttop><strong>Thank you for your recommendation</strong><br />
(awaiting aggregation) ';
	
	 $listingCounter = $listingCounter + 1;
	}
	 
		
	 
	
	}
	
/*	echo '<pre>';
	print_r($array);
	echo '</pre>';*/
	
}




if ($cmode == "crowdsource3"){
	
	$video = $_POST["video"];
	
	$jina = $_POST["jina"];
	
 
	
	
	
	$listingCounter = 1;
	foreach ($array as $newsidValue) {
	
	
	
	  $result4 = mysqli_query("select rating,ratenum from usercontent where isdisplay=1 and newsid=$video");
	while($row4 = mysql_fetch_assoc($result4))
 		
		{	$rating = $row4["rating"];
	 $ratenum = $row4["ratenum"];
	 $OldR = $row4["rating"];
      $OldN = $row4["ratenum"];
	  

      $NewN = $OldN+1;
      $NewR = ($OldR*$OldN+$Rating)/$NewN;	   
	 $sql = "update usercontent set rating=$NewR,ratenum=$NewN,relevance=$$NewR where newsid=$video";
	
	echo '$jina $video<img src=images/done.png hspace=3 align=texttop><strong>Thank you for your recommendation</strong><br />
(awaiting aggregation) ';
	
	 $listingCounter = $listingCounter + 1;
	}
	 
		
	 
	
	}
	
/*	echo '<pre>';
	print_r($array);
	echo '</pre>';*/
	
}









 
    if($mode=="sortdata") {
 $sortdata=$_GET["sortdata"];
  
 
 	$data=explode(',',str_replace('li','',$_GET['sortdata']));
	$data=explode(',',str_replace('box','',$_GET['sortdata']));
	
 $sortuser = $_SESSION['euserid'];

	// Getting the number of objects
	list($tot_objects) = mysql_fetch_array(mysqli_query("SELECT COUNT(*) FROM ilikethis where yanani=$sortuser" ));

	if(count($data)!=$tot_objects);

	foreach($data as $k=>$v)
	{
		// Building the sql query:
		$str[]='('.(int)$v.','.($tot_objects-$k).')';
	}
	
	$str = 'VALUES'.join(',',$str);
	$sortuser = $_SESSION['euserid'];
	mysqli_query('INSERT INTO `ilikethis` (id,positions) '.$str.' ON DUPLICATE KEY UPDATE positions = VALUES(positions)');
mysqli_query('DELETE FROM ilikethis WHERE yanani=0');

 
 
 
 
 
 
 
 
 
 
 
 
 
 }
 
 
 
 
 
 
 
 
 
 
 
   if($mode=="sortdata2") {
   
   $sortrated=$_GET["sortrated"];
 
	$data=explode(',',str_replace('li','',$_GET['sortrated']));
 $sortuser = $_SESSION['euserid'];
	// Getting the number of objects
	list($tot_objects) = mysql_fetch_array(mysqli_query("SELECT COUNT(*) FROM ratedilike where yananir=$sortuser"));
 
	if(count($data)!=$tot_objects) ;

	foreach($data as $k=>$v)
	{
		// Building the sql query:
		$str[]='('.(int)$v.','.($tot_objects-$k).')';
	}
	
	$str = 'VALUES'.join(',',$str);
	

	mysqli_query('INSERT INTO `ratedilike` (rid,positions) '.$str.' ON DUPLICATE KEY UPDATE positions = VALUES(positions)');
	mysqli_query('DELETE FROM ratedilike WHERE yanani=0');
 }
 
 
 
 
 
 
 
 
   if($mode=="sendemail") {
   
   $to=$_GET["to"];
   $user=$_GET["user"];
  $Rating=$_GET["rateit"];
   
   $email = $_GET['email'];
if(!preg_match("~([a-zA-Z0-9!#$%&amp;'*+-/=?^_`{|}~])@([a-zA-Z0-9-]).([a-zA-Z0-9]{2,4})~",$email)) 

{
	die('This is an invalid email.');
}

   
   
   $to = "viralpatel.net@gmail.com";
$subject = "$user has sent you a website request";
$body = "Hi, $user, Check out this website. www.eziki.com.Body of your message here you can use HTML too. e.g. <br> <b> Bold </b>";
$headers = "From: $user\r\n";
$headers .= "Reply-To: info@eziki.com\r\n";
$headers .= "Return-Path: info@yoursite.com\r\n";
$headers .= "X-Mailer: PHP5\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to,$subject,$body,$headers);
   echo "The email has been sent."; 
   
   
   
 }
 
 
 
 
 
  if($mode=="crater") {
   
 $catalogid=$_GET["catalogid"];
  $Rating=$_GET["rateit"];
     
 $result20 = mysqli_query("select rating,ratenum from users where catalogid=$catalogid");
while($row2 = mysql_fetch_assoc($result20))
		{	
		$OldR = $row2["rating"];
      $OldN = $row2["ratenum"];
	  
	  
	  
      $NewN = $OldN+1;
      $NewR = ($OldR*$OldN+$Rating)/$NewN;
	  
	  }
 
		$query = "UPDATE users SET rating = $NewR, ratenum=$NewN where catalogid=$catalogid ";
		mysqli_query($query) or die('Error, insert query failed');
		
    
	  
	 
	 
	 
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
   if($mode=="rater") {
   
 $newsid=$_GET["newsid"];
  $Rating=$_GET["Rating"];
   $videor=$_GET["videor"];
  $newsidr=$_GET["newsidr"];
   $categoryr=$_GET["categoryr"];
  $yananir=$_GET["yananir"];
   $topicr=$_GET["topicr"];
  $imager=$_GET["imager"];
   $slug= $_GET["slug"];
  $videoid=$_GET["videoid"];
  
 $result2 = mysqli_query("select rating,ratenum from usercontent where isdisplay=1 and newsid=$newsid LIMIT 0,1");
while($row2 = mysql_fetch_assoc($result2))
		{	$OldR = $row2["rating"];
      $OldN = $row2["ratenum"];
      $NewN = $OldN+1;
      $NewR = ($OldR*$OldN+$Rating)/$NewN; }
		
  $result3 = mysqli_query("update usercontent set rating=$NewR,ratenum=$NewN where newsid=$newsid");
     
	 
	
	 
	 if (($Rating>=4)){ 
 
	
	$time=date(y).date(m).date(d).date(h).date(i).date(s); //get current time 
    $nick= $_SESSION['user_name'];
	 $words= "has rated the video <a href=videos/$slug target=_blank>$topicr</a> with $Rating stars";
    mysqli_query("insert into socialroom (chtime,nick,words,videoid,slug) values('$time', '$nick' , '$words', '$videoid', '$slug')");
	
	
	
	
	 $result4 = mysqli_query("select count(*) as total from ratedilike where newsidr=$newsidr");
	while($row4 = mysql_fetch_assoc($result4))
		{	$icount = $row4["total"];
				}
	
	 
		
	if ($icount < 1) {
	
	$myidis = $_SESSION['euserid'];
	
	
	 $result5 = mysqli_query("select count(*) as total2 from ratedilike where yananir=$myidis");
	while($row5 = mysql_fetch_assoc($result5))
		{	$icount2 = $row5["total2"];
				}
	
		if ($icount2 < 10) {
	
	print "";
	 mysqli_query("insert into ratedilike(yananir,newsidr,imager,topicr,videor,siter,categoryr) values('$yananir','$newsidr','$imager','$videor','$topicr','$siter','$categoryr')");
	 
	 
	 
	 //COUNT IT
				 $counter = mysqli_query("select count(*) as mycount from ratedilike where yananir=$myidis");
							while($row2 = mysql_fetch_assoc($counter))
															{
															$mycount = $row2['mycount'];
														 
															echo "$mycount";
															}
		
	 
	 }
	    
	  }  
	 
	
	
	
	
	
	
	
	
	
	
		 
	 }  
	  
 }
  
 
 
 
   if($mode=="playlistdelete") {
$id=$_GET["id"];
 mysqli_query("DELETE FROM ilikethis where id='$id'") 
or die(mysql_error()); 
 print "done $id";
 }
  
    if($mode=="qview") {
$newsid=$_GET["newsid"];

?>


<iframe src="quickugcvideo.php?newsid=<?php print "$newsid"; ?>" scrolling="no" width="940" height="320" frameborder="0"></iframe>



<?php
 
 }
  
 
 if($mode=="cc") {
$time=date(y).date(m).date(d).date(h).date(i).date(s); //get current time 
$words=$_GET["words"];
 
$nick=$_GET["nick"];
$videoid=$_GET["videoid"];
$slug=$_GET["slug"];

 
// Insert a row of information into the table "example"
mysqli_query("INSERT INTO socialroom (chtime,nick,words,videoid,slug) VALUES('$time', '$nick' , '$words', '$videoid', '$slug' ) ") 
or die(mysql_error());  

 }
 
 
 
 
 
 if($mode=="tagger") {
  
$who=$_GET["who"];
$video=$_GET["video"];
$newsid=$_GET["newsid"];
$tag=$_GET["tag"];
$tag = mysqli_real_escape_string($link,$tag);
$tag = @ereg_replace("[^A-Za-z0-9]", "", $tag);



 if (empty($tag))
					   {
					  print "<strong>Please enter a comment</strong>";
					  }
					  else 
					   {
					  
					  



// Insert a row of information into the table "example"
mysqli_query("INSERT INTO tags (user,tags,newsid,type,votes_up) VALUES('$who', '$tag' , '$newsid', '0', '0' ) ") 
or die(mysql_error());  

 print "<img src=images/done.png hspace=3 align=texttop><b>Thank you for suggesting:</b> Awaiting user approval";
}

 }
 
 
 
 
 if($mode=="rc") {
 $sn=$_GET["sn"];
 
 print "You Posted: $sn";
$time=date(y).date(m).date(d).date(h).date(i).date(s); //get current time 

$nick=$_GET["nick"];
$videoid=$_GET["videoid"];
$slug=$_GET["slug"];
// Insert a row of information into the table "example"
mysqli_query("INSERT INTO socialroom (chtime,nick,words,videoid,slug) VALUES('$time', '$nick' , '$words', '$videoid', '$slug' ) ") 
or die(mysql_error());  

 }
 
if($mode=="connecttwitter") {
 
$ttoken=$_GET["ttoken"];
$tuid=$_GET["tuid"];
$tplatform=$_GET["tplatform"];
$tupw=$_GET["tupw"];
$tuun=$_GET["tuun"];
$myid = $_SESSION['euserid'];

include("includes/encrypt.php");
$encryptedpwd2 = encrypt($tupw, "$ttoken");
$decryptedpwd2 = decrypt($encryptedpwd2, "$ttoken");
$encrypteduun2 = encrypt($tuun, "$ttoken");
$decrypteduun2 = decrypt($encrypteduun2, "$ttoken");
 
$twittername = $decrypteduun2;
$twitterpassword = $decryptedpwd2;
$status = 'Hi, status updated';
$format = 'xml'; 
//$result = shell_exec('curl http://twitter.com/statuses/update.'.$format.' -u '.$twittername.':'.$twitterpassword.' -d status="'.str_replace('"','\"',$status).'"');
//echo $result;
 
    
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://twitter.com/statuses/friends_timeline.xml');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_USERPWD, $twittername.":".$twitterpassword);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:'));
$xml = curl_exec($curl);
$resultArray = curl_getinfo($curl);
 if ($resultArray['http_code'] == 200) {
echo 'Eziki was Connected to Twitter Successfully';}
else {
mysqli_query("INSERT INTO socialconnect (code,uid,upw,uun,platform) VALUES('$ttoken', '$myid' , '$encryptedpwd2', '$encrypteduun2', '$tplatform' ) ") 
or die(mysql_error());
echo 'Could not connect Eziki to Twitter <br>right now. Check your Twitter<br> Login credentials, network connection<br> and try again.<br><a href=invite.php>Invite your friends to Eziki</a>        '; }
curl_close($curl); 

 

 }
 
 
   if($mode=="connectfacebook") {
   
   
   
 
$uun=$_GET["uun"];
$token=$_GET["token"];
$upw=$_GET["upw"];
include("includes/encrypt.php");
$encryptedpwd = encrypt($upw, "$token");
$decryptedpwd = decrypt($encryptedpwd, "$token");
$encrypteduun = encrypt($uun, "$token");
$decrypteduun = decrypt($encrypteduun, "$token");
 
 
$uid=$_GET["uid"];
$platform=$_GET["platform"];


$fbemail = $encrypteduun;
$fbpass = $encryptedpwd;
$myid = $_SESSION['euserid'];
$status = 'Hi, status updated';
 $debug = false;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?m&amp;amp;next=http%3A%2F%2Fm.facebook.com%2Fhome.php');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'email=' . urlencode($fbemail) . '&pass=' . urlencode($fbpass) . '&amp;login=' . urlencode("Log in"));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12");
curl_exec($ch);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com/home.php');
$page = curl_exec($ch);
curl_setopt($ch, CURLOPT_POST, 1);
preg_match("/input type=\"hidden\" name=\"post_form_id\" value=\"(.*?)\"/", $page, $form_id);
preg_match("/form action=\"(.*?)\"/", $page, $form_num);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'post_form_id=' . $form_id[1] . '&status=' . urlencode($status) . '&update=' . urlencode("Update status"));
curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com' . $form_num[1]);
curl_exec($ch);
if ($debug) {

// Insert a row of information into the table "example"
mysqli_query("INSERT INTO socialconnect (code,uid,upw,uun,platform) VALUES('$token', '$myid' , '$encryptedpwd', '$encrypteduun', '$platform' ) ") 
or die(mysql_error());
echo "Status Updated.<br><a href=\"twitter.php\">Connect Eziki to Twitter</a>     |          <a href=\"invite.php\">Skip</a>";

}
else
{
mysqli_query("INSERT INTO socialconnect (code,uid,upw,uun,platform) VALUES('$token', '$myid' , '$encryptedpwd', '$encrypteduun', '$platform' ) ") 
or die(mysql_error());
echo "$encryptedpwd $decryptedpwd Could not connect Eziki to Facebook <br>right now. Check your Facebook<br> Login credentials, network connection<br> and try again.<br><a href=\"twitter.php\">Connect Eziki to Twitter</a>     |          <a href=\"invite.php\">Skip</a>";
}curl_close($ch);

 

 }
 
 
 
 
   if($mode=="ezikistatus") {
 include("includes/encrypt.php");
$status=$_GET["status"];
$myid = $_SESSION['euserid'];
$result = mysqli_query("select *  from socialconnect where uid='$myid' and platform = 'facebook' LIMIT 0,1 ") or die(mysql_error());

while($row = mysql_fetch_assoc($result))

		{
$platform = $row["platform"];
$encryptedpwd = $row["upw"];
$encrypteduun = $row["uun"];
$token = $row["code"];	
$decryptedpwd = decrypt($encryptedpwd, "$token");
$decrypteduun = decrypt($encrypteduun, "$token");
//echo "$decryptedpwd  <br>$decrypteduun";		  		  
		  
$debug = false;
 
    //CURL stuff
 
    //This executes the login procedure
 
    $ch = curl_init();
 
    curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?m&amp;next=http%3A%2F%2Fm.facebook.com%2Fhome.php');
 
    curl_setopt($ch, CURLOPT_POSTFIELDS, 'email=' . urlencode($decrypteduun) . '&pass=' . urlencode($decryptedpwd) . '&login=' . urlencode("Log in"));
 
    curl_setopt($ch, CURLOPT_POST, 1);
 
    curl_setopt($ch, CURLOPT_HEADER, 0);
 
    //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 
    curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
 
    curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
    //make sure you put a popular web browser here (signature for your web browser can be retrieved with 'echo $_SERVER['HTTP_USER_AGENT'];'
 
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12");
 
    curl_exec($ch);
 
 
 
    //This executes the status update
 
    curl_setopt($ch, CURLOPT_POST, 0);
 
    curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com/home.php');
 
    $page = curl_exec($ch);
 
 
 
    curl_setopt($ch, CURLOPT_POST, 1);
 
    //this gets the post_form_id value
 
    preg_match("/input type=\"hidden\" name=\"post_form_id\" value=\"(.*?)\"/", $page, $form_id);
 
    //we'll also need the exact name of the form processor page
 
    preg_match("/form action=\"(.*?)\"/", $page, $form_num);
 
 
    curl_setopt($ch, CURLOPT_POSTFIELDS, 'post_form_id=' . $form_id[1] . '&status=' . urlencode($status) . '&update=' . urlencode("Update status"));
 
    //set url to form processor page
 
    curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com' . $form_num[1]);
 
    curl_exec($ch);
 
 
 
    if ($debug) {
 
        //show information regarding the request
 
        print_r(curl_getinfo($ch));
 
        echo curl_errno($ch) . '-' . curl_error($ch);
 
        echo "<br><br>Your Facebook status seems to have been updated.";
 
    }
 
    //close the connection
 
    curl_close($ch);
 
		  
		 
		   
		     		     
	 	}
		 


	$result2 = mysqli_query("select *  from socialconnect where uid='$myid' and platform = 'twitter' LIMIT 0,1 ") or die(mysql_error());
while($row2 = mysql_fetch_assoc($result2))
 
		{	
		 $platform2 = $row2["platform"];
$encryptedpwd2 = $row2["upw"];
$encrypteduun2 = $row2["uun"];
$token2 = $row2["code"];	
		

$decryptedpwd2 = decrypt($encryptedpwd2, "$token2");
$decrypteduun2 = decrypt($encrypteduun2, "$token2");
 
$twittername = decrypteduun2;
$twitterpassword = $decryptedpwd2;
$format = 'xml'; 
//$result = shell_exec('curl http://twitter.com/statuses/update.'.$format.' -u '.$twittername.':'.$twitterpassword.' -d status="'.str_replace('"','\"',$status).'"');
//echo $result;
 
    
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://twitter.com/statuses/friends_timeline.xml');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_USERPWD, $twittername.":".$twitterpassword);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:'));
$xml = curl_exec($curl);
$resultArray = curl_getinfo($curl);
 if ($resultArray['http_code'] == 200) {
echo 'Twitter:Successfully posted your Tweet';}
else {
echo " Could not connect Eziki to Twitter right now. Check your Twitter<br> Login credentials, network connection  and try again."; }
curl_close($curl); 		 
		 
		  		     
	 	}	 
		
 

 

 }
 
  $myname=$_GET["myname"];
  $slug=$_GET["slug"];
    $catalogid=$_GET["catalogid"];
	$type=$_GET["type"];
	   $id=$_GET["id"];
	   
	   
 if($mode=="pp") {
 
 $time=date(y).date(m).date(d).date(h).date(i).date(s); //get current time
 $mycomment=$_GET["mycomment"];
 $mycomment = mysqli_real_escape_string($link,$mycomment);
   $newsid=$_GET["newsid"];
    $title=$_GET["title"];
	$myidis = $_SESSION['euserid']; 
	$myname =$_SESSION['user_name'];

	
	
	
	  
	   
	    if (empty($mycomment))
					   {
					  print "<strong>Please enter a comment</strong>";
					  }
					  else 
					   {
					  
$process = explode("x", $newsid);
   $checkcount = count($process);
 	
	
	 $c = $checkcount - 1; // find last element
	 $n = $checkcount - 2;
        $catalogid9 = $process[$c];
		$newsid = $process[$n]; 
		
							  
	   
	   // Insert a row of information into the table "example"
mysqli_query("insert into icomment(mycomment,myname,newsid,id,catalogid) values('$mycomment','$myname','$newsid','$myidis','$catalogid9')") 
or die(mysql_error());  
	   
echo "<img src=images/done.png hspace=3 align=texttop><b>Post Successful:</b>";	   
 
 print "<br />
<br />
<font size=2px><img src=images/user.png alt=userpic align=texttop hspace=5><strong>$myname:</strong> $mycomment<br /> (Refresh page to delete comment)</font>
<br />
";





$getvids = $db->getidtovideo($page,$front_searchresultrecord,$newsid);
			     if (!empty($getvids)) {
	      while ( list($key,$val)=each($getvids) ) {
	      $title = stripslashes($val["title"]);
		  $slug= stripslashes($val["slug"]);
		   $description= stripslashes($val["description"]);
		   $picture= stripslashes($val["picture"]);
	$viewnum= stripslashes($val["viewnum"]); 
	$catalogid= stripslashes($val["catalogid"]);
	      $newsid = stripslashes($val["newsid"]); 
	    $video = stripslashes($val["video"]);
		 
	$mycomment = "has commented on the video <a href =videos/$slug target=_blank> $title</a> 
     | <a href =videos/$slug target=_blank>read</a>";

// Insert a row of information into the table "example"
mysqli_query("INSERT INTO socialroom (chtime,nick,words,videoid,slug) VALUES('$time', '$myname' , '$mycomment', '$catalogid', '$slug' ) ") 
or die(mysql_error());  
	 	} 	 
	      }
 
 














 } }
 
 
 

if($mode=="pSocial") {
 
 $time=date(y).date(m).date(d).date(h).date(i).date(s); //get current time
 $mycomment=$_GET["mycomment"];
 $mycomment = mysqli_real_escape_string($link,$mycomment);
   $newsid=$_GET["newsid"];
    $title=$_GET["title"];
	$myidis = $_SESSION['euserid']; 
	$myname =$_SESSION['user_name'];

	
	
	
	  
	   
	    if (empty($mycomment))
					   {
					  print "<strong>Please enter a comment</strong>";
					  }
					  else 
					   {
					  
 
        $catalogid = $newsid;
 
							  
	   
	   // Insert a row of information into the table "example"
mysqli_query("insert into scomment(mycomment,myname,id,catalogid,type) values('$mycomment','$myname','$myidis','$catalogid','1')") 
or die(mysql_error());  
	   
echo "<img src=images/done.png hspace=3 align=texttop><b>Post Successful:</b>";	   
 
 
 
 } }
 
  
if($_POST['rateit'])
{
$id=mysql_escape_String($_POST['rateit']);
$newsid=$id;
$name=mysql_escape_String($_POST['name']);
$who=$_SESSION['euserid'];
$user =$_SESSION['user_name'];
 


											$getvids = $db->getidtovideo($page,$front_searchresultrecord,$id);
											 if (!empty($getvids)) {
									  while ( list($key,$val)=each($getvids) ) {
									  $title = stripslashes($val["title"]);
									  $slug= stripslashes($val["slug"]);
									   $description= stripslashes($val["description"]);
									   $picture= stripslashes($val["picture"]);
								$viewnum= stripslashes($val["viewnum"]); 
								$catalogid= stripslashes($val["catalogid"]);
								
									 $newsid = stripslashes($val["newsid"]); 
									$video = stripslashes($val["video"]);
									$keywords = stripslashes($val["keywords"]);
									$keywords = trim($keywords.$title);
								
								 $keywords = @ereg_replace("[^A-Za-z0-9],", "", $keywords);
								$code="1";
								mysqli_query("DELETE FROM api WHERE user=$who and code=$code") or die(mysql_error());
							
								$keywords = preg_replace('/ /', ',', $keywords);
								$keywords = preg_replace('/\'/', '', $keywords);
								$keywords = "(title like '%$keywords %')";
								$keywords = preg_replace("/,/", "%') or (title like '%", $keywords);
								$keywords = preg_replace('/ %/', '%', $keywords);
								 
								
								$title2 = preg_replace("/keywords/", "title", $keywords);
								$keywords = preg_replace("/title/", "keywords", $keywords);
								$widgettitle= '<img src=\"images/icons/searcher.png\" align=\"texttop\" vspace=\"1\" > Suggestions (Based on Liked videos)';
								
								 $myquery = "select * from usercontent where isdisplay=1 and newsid != $newsid and ($title2 or $keywords or(content like '%sdsjdjbj%')) order by viewnum desc LIMIT 3"; 
								 include("includes/encrypt.php");
								$myquery = encrypt($myquery, "chitgoks");	 
								 
							mysqli_query("INSERT INTO api (user,title,myquery,ascdesc,num,code) VALUES('$yanani', '$widgettitle', '$myquery', 'ASC', '4', '1') "); 
									 
							 
								
									 
									$mycomment2 = "likes the video <a href =videos/$slug target=_blank>$title</a>";
							
							// Insert a row of information into the table "example"
							//mysqli_query("INSERT INTO socialroom (chtime,nick,words,videoid,slug) VALUES('$time', '$user' , '$mycomment2', '$videoid', '$slug' ) ") 
							//or die(mysql_error());
							
							
							$newidd="2";
							 // Insert a row of information into the table "example"
							 $mycomment5 = "likes the video <a href =videos/$slug target=_blank>$title</a>";
							  $mycomment6 = "$user ".$mycomment5;
							  $link = "http://www.eziki.tv/videos/$slug";
							mysqli_query("insert into icomment(mycomment,myname,newsid,id,catalogid) values('$mycomment6','$myname','$newsid','$newidd','$yanani')") 
							or die(mysql_error());  
							 
							if (isset($_SESSION['fbme'])) {													 
														 
header("Location: fbmain.php?mode=like&message=$mycomment5&link=$link&picture=$picture&title=$title");				 
				}
				 	
							
							
									} 	 
									  }
							 
 
 
 
mysqli_query("update usercontent set $name=$name+1 where newsid='$id'");


$result=mysqli_query("select up,down from usercontent where newsid='$id'");
$row=mysql_fetch_array($result);
$up_value=$row['up'];
$down_value=$row['down'];
$total=$up_value+$down_value;

$up_per=($up_value*100)/$total;
$down_per=($down_value*100)/$total;
?>

<table width="216">

<tr>
<td width="5"></td>
<td width="87"><?php echo $up_value; ?> Likes</td>
<td width="108"><div id="greebar" style="width:<?php echo $up_per; ?>%"></div></td>
</tr>

<tr>
<td width="5"></td>
<td width="87"><?php echo $down_value; ?> Dislikes</td>
<td width="108"><div id="redbar" style="width:<?php echo $down_per; ?>%"></div></td>
</tr>

</table>
<div style="margin-top:10px">
<b><?php echo $total; ?> Total Likes and Dislikes for this video</b>
</div>
<?php

}
  
  
  
if($mode=="sv") {
$sessionID = $_COOKIE['PHPSESSID'];
$newsid2= $_GET['runingaID'];
if (!empty($newsid2)){
$newsid="$newsid2";
 }
else {
$newsid=$_GET["newsid"];
}

 

$time=date(y).date(m).date(d).date(h).date(i).date(s); //get current time 
$yanani=$_SESSION['euserid'];
$image=$_GET["image"];
$topic=$_GET["topic"];
$video2=$_GET["video2"];
$category=$_GET["category"];
$site=$_GET["site"];
$vcat=$_GET["vcat"];
$slug=$_GET["slug"];
$videoid=$_GET["videoid"];
$user =$_SESSION['user_name'];

 
 $video2 = preg_replace('/[\!-@#$%^&*()+=,.;:]/', '', $video2); 
 
 
 
 

 
 
 			$getvids = $db->getidtovideo($page,$front_searchresultrecord,$newsid);
			     if (!empty($getvids)) {
	      while ( list($key,$val)=each($getvids) ) {
	      $title = stripslashes($val["title"]);
		  $slug= stripslashes($val["slug"]);
		   $description= stripslashes($val["description"]);
		   $picture= stripslashes($val["picture"]);
	$viewnum= stripslashes($val["viewnum"]); 
	$catalogid= stripslashes($val["catalogid"]);
	
	     $newsid = stripslashes($val["newsid"]); 
	    $video = stripslashes($val["video"]);
		$keywords = stripslashes($val["keywords"]);
		$keywords = trim($keywords.$title);
	
	 $keywords = @ereg_replace("[^A-Za-z0-9],", "", $keywords);
	$code="1";
	mysqli_query("DELETE FROM api WHERE user=$yanani and code=$code") or die(mysql_error());

	$keywords = preg_replace('/ /', ',', $keywords);
	$keywords = preg_replace('/\'/', '', $keywords);
	$keywords = "(title like '%$keywords %')";
	$keywords = preg_replace("/,/", "%') or (title like '%", $keywords);
 	$keywords = preg_replace('/ %/', '%', $keywords);
	 
	
	$title2 = preg_replace("/keywords/", "title", $keywords);
	$keywords = preg_replace("/title/", "keywords", $keywords);
	$widgettitle= '<img src=\"images/icons/searcher.png\" align=\"texttop\" vspace=\"1\" > Suggestions (Based on Saved videos)';
	
	 $myquery = "select * from usercontent where isdisplay=1 and newsid != $newsid and ($title2 or $keywords or(content like '%sdsjdjbj%')) order by viewnum desc LIMIT 3"; 
	 include("includes/encrypt.php");
    $myquery = encrypt($myquery, "chitgoks");	 
	 
mysqli_query("INSERT INTO api (user,title,myquery,ascdesc,num,code) VALUES('$yanani', '$widgettitle', '$myquery', 'ASC', '4', '1') "); 
		 
 
	
		 
		$mycomment2 = "added the video <a href =videos/$slug target=_blank>$title</a> to Favourites";

// Insert a row of information into the table "example"
//mysqli_query("INSERT INTO socialroom (chtime,nick,words,videoid,slug) VALUES('$time', '$user' , '$mycomment2', '$videoid', '$slug' ) ") 
//or die(mysql_error());


$newidd="2";
 // Insert a row of information into the table "example"
 $mycomment5 = "added the video <a href =videos/$slug target=_blank>$title</a> to Favourites";
  $mycomment6 = "$user ".$mycomment5;
  $link = "http://www.eziki.tv/videos/$slug";
mysqli_query("insert into icomment(mycomment,myname,newsid,id,catalogid) values('$mycomment6','$myname','$newsid','$newidd','$yanani')") 
or die(mysql_error());  
 



	 	} 	 
	      }
 
 
  

   

session_start(); 
$_SESSION['cate']= $vcat; 


if (isset($_SESSION['euserid'])) {



$myidis = $_SESSION['euserid'];
}
else {
$myidis = "A guest ";

}

 $video2 = mysqli_real_escape_string($link,$video2);  


$result5 = mysqli_query("select count(*) as total from ilikethis where yanani=$myidis");
while($row5 = mysql_fetch_assoc($result5))
		{
		
		
		$icount5 = $row5['total'];
		
		}

$result2 = mysqli_query("select count(*) as total from ilikethis where newsid=$newsid and yanani=$myidis");
while($row2 = mysql_fetch_assoc($result2))
		{
		
		
		$icount = $row2['total'];
		
 
							if ($icount < 1) {
								
								 $result3 = mysqli_query("select count(*) as total2 from ilikethis where yanani=$myidis");
							while($row2 = mysql_fetch_assoc($result3))
															{
															$icount2 = $row2['total2'];
														
														
													
			 										 
															
																				if ($icount2 < 10) {
																				 
																				// Insert a row of information into the table "example"
																				mysqli_query("insert into ilikethis(yanani,newsid,videoSession) values('$yanani','$newsid','$sessionID') ") 
																				or die(mysql_error());
																				
		
		
		
		//COUNT IT
				 $counter = mysqli_query("select count(*) as mycount from ilikethis where yanani=$myidis");
							while($row2 = mysql_fetch_assoc($counter))
															{
															$mycount = $row2['mycount'];
															
															
															 
														if (!empty($_GET['runingaID'])){
														//exit();
															echo "$mycount";
														 }
														else {
														echo "$mycount";
														}	
															
														 
	if (isset($_SESSION['fbme'])) {													 
														 
header("Location: fbmain.php?mode=sv&mycount=$mycount&message=$mycomment5&link=$link&picture=$picture&title=$title");				 
				}
				 									 
															
															}
		
															
																				}
																				else {
																				
																				
																				echo "Max";
																				
																				}
																				
																				
																				
															
															
															
															}
																
							
							
							}
		else {
		
		if (!empty($_GET['runingaID'])){
														 
														 }
														else {
														print "$icount5";
														}	
														
														
														
														
														
		
		}
		}















 }












 //sat fbconnect
 
 
 if($mode=="fbconnect") {
$sessionID = $_COOKIE['PHPSESSID'];
$newsid2= $_GET['runingaID'];
if (!empty($newsid2)){
$newsid="$newsid2";
 }
else {
$newsid=$_GET["newsid"];
}

 

$time=date(y).date(m).date(d).date(h).date(i).date(s); //get current time 
$yanani=$_SESSION['euserid'];
$image=$_GET["image"];
$topic=$_GET["topic"];
$video2=$_GET["video2"];
$category=$_GET["category"];
$site=$_GET["site"];
$vcat=$_GET["vcat"];
$slug=$_GET["slug"];
$videoid=$_GET["videoid"];
$fbme=$_GET["fbme"];
$user =$_SESSION['user_name'];

 
 $video2 = preg_replace('/[\!-@#$%^&*()+=,.;:]/', '', $video2); 
 
 
 
 

 
 
 			$getvids = $db->getidtovideo($page,$front_searchresultrecord,$newsid);
			     if (!empty($getvids)) {
	      while ( list($key,$val)=each($getvids) ) {
	      $title = stripslashes($val["title"]);
		  $slug= stripslashes($val["slug"]);
		   $description= stripslashes($val["description"]);
		   $picture= stripslashes($val["picture"]);
	$viewnum= stripslashes($val["viewnum"]); 
	$catalogid= stripslashes($val["catalogid"]);
	
	     $newsid = stripslashes($val["newsid"]); 
	    $video = stripslashes($val["video"]);
		$keywords = stripslashes($val["keywords"]);
		$keywords = trim($keywords.$title);
	
	 $keywords = @ereg_replace("[^A-Za-z0-9],", "", $keywords);
	$code="1";
	mysqli_query("DELETE FROM api WHERE user=$yanani and code=$code") or die(mysql_error());

	$keywords = preg_replace('/ /', ',', $keywords);
	$keywords = preg_replace('/\'/', '', $keywords);
	$keywords = "(title like '%$keywords %')";
	$keywords = preg_replace("/,/", "%') or (title like '%", $keywords);
 	$keywords = preg_replace('/ %/', '%', $keywords);
	 
	
	$title2 = preg_replace("/keywords/", "title", $keywords);
	$keywords = preg_replace("/title/", "keywords", $keywords);
	$widgettitle= '<img src=\"images/icons/searcher.png\" align=\"texttop\" vspace=\"1\" > Suggestions (Based on Facebook Posts)';
	
	 $myquery = "select * from usercontent where isdisplay=1 and newsid != $newsid and ($title2 or $keywords or(content like '%sdsjdjbj%')) order by viewnum desc LIMIT 3"; 
	 include("includes/encrypt.php");
    $myquery = encrypt($myquery, "chitgoks");	 
	 
mysqli_query("INSERT INTO api (user,title,myquery,ascdesc,num,code) VALUES('$yanani', '$widgettitle', '$myquery', 'ASC', '4', '1') "); 
		 
 
	
		 
		$mycomment2 = "added the video <a href =videos/$slug target=_blank>$title</a> to Favourites";

// Insert a row of information into the table "example"
//mysqli_query("INSERT INTO socialroom (chtime,nick,words,videoid,slug) VALUES('$time', '$user' , '$mycomment2', '$videoid', '$slug' ) ") 
//or die(mysql_error());


$newidd="2";
 // Insert a row of information into the table "example"
 $mycomment5 = "posted Facebook status update on video <a href =videos/$slug target=_blank>$title</a>";
  $mycomment6 = "$user ".$mycomment5;
  $link = "http://www.eziki.tv/videos/$slug";
mysqli_query("insert into icomment(mycomment,myname,newsid,id,catalogid) values('$mycomment6','$myname','$newsid','$newidd','$yanani')") 
or die(mysql_error());  
 



	 	} 	 
	      }
 
 
  

   

session_start(); 
$_SESSION['cate']= $vcat; 


if (isset($_SESSION['euserid'])) {



$myidis = $_SESSION['euserid'];
}
else {
$myidis = "A guest ";

}

 $video2 = mysqli_real_escape_string($link,$video2);  


$result5 = mysqli_query("select count(*) as total from fbconnect where yanani=$myidis");
while($row5 = mysql_fetch_assoc($result5))
		{
		
		
		$icount5 = $row5['total'];
		
		}

$result2 = mysqli_query("select count(*) as total from fbconnect where newsid=$newsid and yanani=$myidis");
while($row2 = mysql_fetch_assoc($result2))
		{
		
		
		$icount = $row2['total'];
		
 
							if ($icount < 1) {
								
								 $result3 = mysqli_query("select count(*) as total2 from fbconnect where yanani=$myidis");
							while($row2 = mysql_fetch_assoc($result3))
															{
															$icount2 = $row2['total2'];
														
														
													
			 										 
															
																				if ($icount2 < 20) {
																				 
																				// Insert a row of information into the table "example"
																				mysqli_query("insert into fbconnect(yanani,newsid,videoSession) values('$yanani','$newsid','$sessionID') ") 
																				or die(mysql_error());
																				
		
		
		
		//COUNT IT
				 $counter = mysqli_query("select count(*) as mycount from fbconnect where yanani=$myidis");
							while($row2 = mysql_fetch_assoc($counter))
															{
															$mycount = $row2['mycount'];
															
															
															 
														if (!empty($_GET['runingaID'])){
														//exit();
															//echo "$mycount";
														 }
														else {
														//echo "$mycount";
														}	
															
														 
												 
														 
header("Location: fbmain.php?mode=fbconnect&mycount=$mycount&message=$fbme&link=$link&picture=$picture&title=$title");				 
	if (isset($_SESSION['fbme'])) {					}
				 									 
															
															}
		
															
																				}
																				else {
																				
																				
																				echo "Max";
																				
																				}
																				
																				
																				
															
															
															
															}
																
							
							
							}
		else {
		
		if (!empty($_GET['runingaID'])){
														 
														 }
														else {
														print "<img src=images/done.png hspace=3 align=texttop><b>Already posted that on Facebook</b>";
														}	
														
														
														
														
														
		
		}
		}















 }
 
 
 //end fbconnect
 
 
 
 
 
 
 
 
 
 
 
 
 
  //start of go save
  
  if($mode=="gosave") {
 
$newsid= $_GET['newsid'];
$yanani=$_SESSION['euserid'];
 $catalogid= $_GET['catalogid'];
 $distribution= $_GET['distribution'];
 


$result5 = mysqli_query("select count(*) as total from distributions where yanani=$yanani");
while($row5 = mysql_fetch_assoc($result5))
		{
		
		
		$icount5 = $row5['total'];
		
		}

$result2 = mysqli_query("select count(*) as total from distributions where newsid=$newsid and yanani=$yanani and catalogid=$catalogid and distribution=$distribution");
while($row2 = mysql_fetch_assoc($result2))
		{
		
		
		$icount = $row2['total'];
		
 
							if ($icount < 1) {
								
								 $result3 = mysqli_query("select count(*) as total2 from distributions where yanani=$yanani");
							while($row2 = mysql_fetch_assoc($result3))
															{
															$icount2 = $row2['total2'];
														
														
													
			 										 
															
																				if ($icount2 < 1000) {
																				 
																				// Insert a row of information into the table "example"
																				mysqli_query("insert into distributions(yanani,newsid,distribution,catalogid,isdisplay) values('$yanani','$newsid','$distribution','$catalogid','1') ") 
																				or die(mysql_error());
																				
																	$created =time();			
																	mysqli_query("insert into notifications(yanani,newsid,catalogid,type,created) values('$yanani','$newsid','$catalogid','7','$created') ") 
																				or die(mysql_error());				
																				
																				
														if($newsid == 119)
{
	
	mysqli_query("insert into distributions(yanani,newsid,distribution,catalogid,isdisplay) values('$yanani','$newsid','$distribution','1005023688676281','1')") or die(mysql_error());
		mysqli_query("insert into distributions(yanani,newsid,distribution,catalogid,isdisplay) values('$yanani','$newsid','$distribution','1005023688676282','1')") or die(mysql_error());
			mysqli_query("insert into distributions(yanani,newsid,distribution,catalogid,isdisplay) values('$yanani','$newsid','$distribution','1005023688676280','1')") or die(mysql_error());
			
			
		mysqli_query("insert into distributions(yanani,newsid,distribution,catalogid,isdisplay) values('$yanani','$newsid','$distribution','1005023688676277','1')") or die(mysql_error());
		
		
			mysqli_query("insert into distributions(yanani,newsid,distribution,catalogid,isdisplay) values('$yanani','$newsid','$distribution','1005023688676301','1')") or die(mysql_error());
			
				mysqli_query("insert into distributions(yanani,newsid,distribution,catalogid,isdisplay) values('$yanani','$newsid','$distribution','1005023688676299','1')") or die(mysql_error());		
		
				mysqli_query("insert into distributions(yanani,newsid,distribution,catalogid,isdisplay) values('$yanani','$newsid','$distribution','1005023688676278','1')") or die(mysql_error());	
				
				
$message = 
"Hi  \n 

Welcome to Mimi. \n 

Mimi is a Content Distribution Network allowing Artists, Film Makers and Publishers to  share content \n


like Music, Videos, Photos and Documents with you. \n

A user has shared  content with you today \n


Kindly login in to http://ziqi.co.ke/v/login.php to download this Content \n
  

Thank You \n

Mimi Team
ziqi.co.ke

 
";
/*echo "$user_email";*/
mail("nmukii@gmail.com", "User has shared  content with you ", $message,
    "From: \"Mimi\" <auto-reply@ziqi.co.ke>\r\n" .
     "X-Mailer: PHP/" . phpversion());	
	 
	 /*echo "$user_email";*/
mail("alfred.muchilwa@gmail.com", "User has shared  content with you ", $message,
    "From: \"Mimi\" <auto-reply@ziqi.co.ke>\r\n" .
     "X-Mailer: PHP/" . phpversion());
	 
	 /*echo "$user_email";*/
mail("mundumwara@gmail.com", "User has shared  content with you ", $message,
    "From: \"Mimi\" <auto-reply@ziqi.co.ke>\r\n" .
     "X-Mailer: PHP/" . phpversion());
	 
	 /*echo "$user_email";*/
mail("nyongo@gmail.com", "User has shared  content with you ", $message,
    "From: \"Mimi\" <auto-reply@ziqi.co.ke>\r\n" .
     "X-Mailer: PHP/" . phpversion());	
	 
	 
	 	 /*echo "$user_email";*/
mail("sokottah2@gmail.com", "User has shared  content with you ", $message,
    "From: \"Mimi\" <auto-reply@ziqi.co.ke>\r\n" .
     "X-Mailer: PHP/" . phpversion());	
	 
mail("paulacallus@gmail.com", "User has shared  content with you ", $message,
    "From: \"Mimi\" <auto-reply@ziqi.co.ke>\r\n" .
     "X-Mailer: PHP/" . phpversion());	
	 
	 
	 mail("solomonjagwe@gmail.com", "User has shared  content with you ", $message,
    "From: \"Mimi\" <auto-reply@ziqi.co.ke>\r\n" .
     "X-Mailer: PHP/" . phpversion());				
			
			
			
			
			
			
			
			
			
			
			
 
	 
}						
																				
																				
																				
				$nameinfo2 = $db->getallugccatalogname(); 
                if (!empty($nameinfo2)){
	            while (list($key,$val)=each($nameinfo2)) {
		    $tempcatalogid2 = stripslashes($val["catalogid"]);
		    $user_email = stripslashes($val["user_email"]);
			 $catalogname = stripslashes($val["catalogname"]);
			 $femail = stripslashes($val["user_email"]);
			 $fname = stripslashes($val["catalogname"]);
			$slug = stripslashes($val["slug"]);
		    if ($catalogid==$tempcatalogid2){ 
			




//check if he is on his mailing list
 	 $rs_duplicate2 = mysqli_query("select count(*) as total from mailing where femail='$femail' and catalogid='$yanani'") or die(mysql_error());
list($total2) = mysql_fetch_row($rs_duplicate2);

if ($total2 > 0)
{


}
	else
	{
		$sql_insert2 = "INSERT into `mailing`
  			(`fname`,`femail`,`catalogid`,`parentid`,`isdisplay`)
		    VALUES
		    ('$fname','$femail','$yanani','$catalogid','1')
			";
	mysqli_query($sql_insert2,$link) or die("Insertion Failed:" . mysql_error());
	
	}
	
 
 //end check



			
			
			$message = 
"Hi $catalogname \n 

Welcome to Mimi. \n 

Mimi is a Content Distribution Network allowing Artists, Film Makers and Publishers to  share content \n


like Music, Videos, Photos and Documents with you. \n

A user has shared  content with you today \n


Kindly login in to http://ziqi.co.ke/v/login.php to download this Content \n
  

Thank You \n

Mimi Team
ziqi.co.ke

 
";
/*echo "$user_email";*/
mail($user_email, "User has shared  content with you ", $message,
    "From: \"Mimi\" <auto-reply@ziqi.co.ke>\r\n" .
     "X-Mailer: PHP/" . phpversion());
}	}	}							
																				
																				
																				
																				
																				
																				
																				
		
		
		
		//COUNT IT
				 $counter = mysqli_query("select count(*) as mycount from distributions where yanani=$yanani");
							while($row2 = mysql_fetch_assoc($counter))
															{
															$mycount = $row2['mycount'];
															
															
															 
														if (!empty($_GET['runingaID'])){
														//exit();
															echo "$mycount";
														 }
														else {
														echo "$mycount";
														}	
															
														 
															
															}
		
															
																				}
																				else {
																				
																				
																				echo "Max";
																				
																				}
																				
																				
																				
															
															
															
															}
																
							
							
							}
		else {
		
		if (!empty($_GET['runingaID'])){
														 
														 }
														else {
														print "$icount5";
														}	
														
														
														
														
														
		
		}
		}















 }
 
  
  //end of go save
 
//reorder widgets
$widgetorder	= $_POST['widgetorder'];
if ($_POST['orderwidget'] == "orderwidget"){
	
	$count = 1;
	foreach ($widgetorder as $idval) {
		$query = "update api SET listorder = " . $count . " WHERE id = " . $idval;
		mysqli_query($query) or die('Error, insert query failed');
		$count ++;	
	}
	echo 'Widget Order Saved';
}
//end order widget


//delete ilike

if($_POST['vid'])
{
$id=$_POST['vid'];
$id = mysql_escape_String($id);
$sql = "delete from ilikethis where id='$id'";
mysqli_query( $sql);
}




//delete rated

if($_POST['rid'])
{
$rid=$_POST['rid'];
$rid = mysql_escape_String($rid);
$sql = "delete from ilikethis where id='$rid'";
mysqli_query( $sql);
}

//ratevideo




//quickview

if($_POST['quickview'])
{
$quickview=$_POST['quickview'];
$quickview = mysql_escape_String($quickview);


print "$quickview i love ";


mysqli_query( $sql);
}
 ?>
 
 
 <?php
if(isSet($_POST['textcontent']))
{
$textcontent=$_POST['textcontent'];
// Some SQL data values insert into comments table
}
?>
<div class="load_comment">
<?php echo $textcontent; ?></div>