2009-08-25 12:16:42 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
***************************************************************************************************
|
|
|
|
* @Software ClipBucket
|
|
|
|
* @Authoer ArslanHassan
|
|
|
|
* @copyright Copyright (c) 2007-2009 {@link http://www.clip-bucket.com}
|
|
|
|
* @license http://www.clip-bucket.com
|
|
|
|
* @version Lite
|
|
|
|
* @since 2007-10-15
|
|
|
|
* @License CBLA
|
|
|
|
**************************************************************************************************
|
|
|
|
This Source File Is Written For ClipBucket, Please Read its End User License First and Agree its
|
|
|
|
Terms of use at http://clip-bucket.com/cbla
|
|
|
|
**************************************************************************************************
|
|
|
|
Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved.
|
|
|
|
**************************************************************************************************
|
2010-01-06 11:59:41 +00:00
|
|
|
|
2009-10-10 14:25:07 +00:00
|
|
|
check_user
|
|
|
|
check_email
|
|
|
|
DeleteFlv
|
|
|
|
DeleteOriginal
|
|
|
|
DeleteThumbs
|
|
|
|
DeleteVideoFiles
|
|
|
|
UpdateVideo
|
|
|
|
GetCategory
|
|
|
|
RateVideo
|
|
|
|
AddComment
|
|
|
|
AddToFavourite
|
|
|
|
FlagAsInappropriate
|
|
|
|
DeleteFlag
|
|
|
|
|
2009-08-25 12:16:42 +00:00
|
|
|
**/
|
2010-02-06 14:10:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to return db table name with prefix
|
|
|
|
* @param : table name
|
|
|
|
* @return : prefix_table_name;
|
|
|
|
*/
|
|
|
|
function tbl($tbl)
|
|
|
|
{
|
|
|
|
$prefix = TABLE_PREFIX;
|
|
|
|
$tbls = explode(",",$tbl);
|
|
|
|
$new_tbls = "";
|
|
|
|
foreach($tbls as $ntbl)
|
|
|
|
{
|
|
|
|
if(!empty($new_tbls))
|
|
|
|
$new_tbls .= ",";
|
|
|
|
$new_tbls .= $prefix.$ntbl;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $new_tbls;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-25 12:16:42 +00:00
|
|
|
class myquery {
|
|
|
|
|
|
|
|
function Set_Website_Details($name,$value){
|
|
|
|
//mysql_query("UPDATE config SET value = '".$value."' WHERE name ='".$name."'");
|
2009-09-28 05:23:50 +00:00
|
|
|
global $db,$Cbucket;
|
2010-02-06 09:56:30 +00:00
|
|
|
$db->update(tbl("config"),array('value'),array($value)," name = '".$name."'");
|
2009-09-28 05:23:50 +00:00
|
|
|
$Cbucket->configs = $Cbucket->get_configs();
|
2009-08-25 12:16:42 +00:00
|
|
|
}
|
|
|
|
|
2010-02-06 13:38:16 +00:00
|
|
|
function Get_Website_Details()
|
|
|
|
{
|
2010-02-06 14:10:53 +00:00
|
|
|
|
|
|
|
$query = mysql_query("SELECT * FROM ".tbl("config"));
|
2009-10-10 14:25:07 +00:00
|
|
|
while($row = mysql_fetch_array($query))
|
|
|
|
{
|
|
|
|
$name = $row['name'];
|
|
|
|
$data[$name] = $row['value'];
|
|
|
|
}
|
|
|
|
return $data;
|
2009-08-25 12:16:42 +00:00
|
|
|
}
|
2010-02-06 13:38:16 +00:00
|
|
|
|
2009-08-25 12:16:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
//Function Used to Check Weather Video Exists or not
|
2009-10-10 14:25:07 +00:00
|
|
|
function VideoExists($videoid){global $cbvid;return $cbvid->exists($videoid);}
|
|
|
|
function video_exists($videoid){return $this->VideoExists($videoid);}
|
|
|
|
function CheckVideoExists($videokey){return $this->VideoExists($videokey);}
|
2009-08-25 12:16:42 +00:00
|
|
|
|
2009-10-10 14:25:07 +00:00
|
|
|
//Function used to Delete Video
|
2009-08-25 12:16:42 +00:00
|
|
|
|
|
|
|
function DeleteVideo($videoid){
|
2009-08-31 12:01:33 +00:00
|
|
|
global $cbvid;
|
2009-10-10 14:25:07 +00:00
|
|
|
return $cbvid->delete_video($videoid);
|
2009-08-25 12:16:42 +00:00
|
|
|
}
|
2009-10-10 14:25:07 +00:00
|
|
|
|
|
|
|
//Video Actions - All Moved to video.class.php
|
|
|
|
function MakeFeaturedVideo($videoid){global $cbvid;return $cbvid->action('feature',$videoid);}
|
|
|
|
function MakeUnFeaturedVideo($videoid){global $cbvid;return $cbvid->action('unfeature',$videoid);}
|
|
|
|
function ActivateVideo($videoid){global $cbvid;return $cbvid->action('activate',$videoid);}
|
|
|
|
function DeActivateVideo($videoid){global $cbvid;return $cbvid->action('deactivate',$videoid);}
|
2009-08-25 12:16:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to get video details
|
|
|
|
* from video table
|
|
|
|
* @param INPUT vid or videokey
|
|
|
|
*/
|
2009-10-10 14:25:07 +00:00
|
|
|
function get_video_details($vid){global $cbvid;return $cbvid->get_video($vid);}
|
|
|
|
function GetVideoDetails($video){return $this->get_video_details($video);}
|
|
|
|
function GetVideDetails($video){return $this->get_video_details($video);}
|
2009-08-25 12:16:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
//Function Used To Update Videos Views
|
2009-10-10 14:25:07 +00:00
|
|
|
function UpdateVideoViews($vkey){increment_views($vkey,'video');}
|
2009-08-25 12:16:42 +00:00
|
|
|
|
2009-11-04 10:27:40 +00:00
|
|
|
/**
|
|
|
|
* Function used to check weather username exists not
|
|
|
|
*/
|
|
|
|
function check_user($username){
|
|
|
|
global $userquery;
|
|
|
|
return $userquery->username_exists($username);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to check weather email exists not
|
|
|
|
*/
|
|
|
|
function check_email($email){
|
|
|
|
global $userquery;
|
|
|
|
return $userquery->email_exists($email);
|
|
|
|
}
|
2009-08-25 12:16:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to delete comments
|
|
|
|
* @param CID
|
|
|
|
*/
|
2009-12-21 21:11:54 +00:00
|
|
|
function delete_comment($cid,$type='v',$is_reply=FALSE,$forceDelete=false)
|
2009-08-25 12:16:42 +00:00
|
|
|
{
|
|
|
|
global $db,$userquery,$LANG;
|
|
|
|
//first get comment details
|
|
|
|
|
2009-12-21 21:11:54 +00:00
|
|
|
$cdetails = $this->get_comment($cid);
|
2009-08-25 12:16:42 +00:00
|
|
|
$uid = user_id();
|
2009-12-21 21:11:54 +00:00
|
|
|
|
|
|
|
if(($uid == $cdetails['userid'] && $cdetails['userid']!='')
|
2010-02-02 16:19:41 +00:00
|
|
|
|| $cdetails['type_owner_id'] == userid()
|
2010-01-25 13:18:18 +00:00
|
|
|
|| has_access("admin_del_access",false)
|
2009-12-21 21:11:54 +00:00
|
|
|
|| $is_reply==TRUE || $forceDelete)
|
2009-08-25 12:16:42 +00:00
|
|
|
{
|
|
|
|
$replies = $this->get_comments($cdetails['type_id'],$type,FALSE,$cid,TRUE);
|
|
|
|
if(count($replies)>0 && is_array($replies))
|
|
|
|
{
|
|
|
|
foreach($replies as $reply)
|
|
|
|
{
|
2009-12-21 21:11:54 +00:00
|
|
|
$this->delete_comment($reply['comment_id'],$type,TRUE,$forceDelete);
|
2009-08-25 12:16:42 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-06 09:56:30 +00:00
|
|
|
$db->Execute("DELETE FROM ".tbl("comments")." WHERE comment_id='$cid'");
|
2009-12-04 21:03:27 +00:00
|
|
|
|
2010-01-17 13:53:14 +00:00
|
|
|
/*if($uid)
|
|
|
|
$myquery->update_comments_by_user($uid);*/
|
2009-12-21 21:11:54 +00:00
|
|
|
|
2010-01-13 09:53:21 +00:00
|
|
|
e(lang('usr_cmt_del_msg'),"m");
|
2010-01-25 13:18:18 +00:00
|
|
|
return $cdetails['type_id'];
|
2009-08-25 12:16:42 +00:00
|
|
|
}else{
|
2010-01-13 09:53:21 +00:00
|
|
|
e(lang('no_comment_del_perm'));
|
2009-12-04 21:03:27 +00:00
|
|
|
return false;
|
2009-08-25 12:16:42 +00:00
|
|
|
}
|
2009-12-04 21:03:27 +00:00
|
|
|
return false;
|
2009-08-25 12:16:42 +00:00
|
|
|
}
|
2009-10-10 14:25:07 +00:00
|
|
|
function DeleteComment($id,$videoid){return $this->delete_comment($videoid);}
|
2010-01-25 13:18:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to set comment as spam
|
|
|
|
*/
|
|
|
|
function spam_comment($cid)
|
|
|
|
{
|
|
|
|
global $db;
|
|
|
|
$comment = $this->get_comment($cid);
|
|
|
|
$uid = user_id();
|
|
|
|
if($comment)
|
|
|
|
{
|
|
|
|
$voters = $comment['spam_voters'];
|
|
|
|
|
|
|
|
$niddle = "|";
|
|
|
|
$niddle .= userid();
|
|
|
|
$niddle .= "|";
|
|
|
|
$flag = strstr($voters, $niddle);
|
|
|
|
|
|
|
|
if(!$comment)
|
|
|
|
e(lang('no_comment_exists'));
|
|
|
|
elseif(!userid())
|
|
|
|
e(lang('login_to_mark_as_spam'));
|
|
|
|
elseif(userid()==$comment['userid'] || (!userid() && $_SERVER['REMOTE_ADDR'] == $comment['comment_ip']))
|
|
|
|
e(lang('no_own_commen_spam'));
|
|
|
|
elseif(!empty($flag))
|
|
|
|
e(lang('already_spammed_comment'));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(empty($voters))
|
|
|
|
$voters .= "|";
|
|
|
|
|
|
|
|
$voters .= userid();
|
|
|
|
$voters.= "|";
|
|
|
|
|
|
|
|
$newscore = $comment['spam_votes']+1;
|
2010-02-06 09:56:30 +00:00
|
|
|
$db->update(tbl('comments'),array('spam_votes','spam_voters'),array($newscore,$voters)," comment_id='$cid'");
|
2010-01-25 13:18:18 +00:00
|
|
|
e(lang('spam_comment_ok'),"m");
|
|
|
|
return $newscore;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
e(lang('no_comment_exists'));
|
|
|
|
return false;
|
|
|
|
}
|
2009-12-21 21:11:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to delete all comments of particlar object
|
|
|
|
*/
|
|
|
|
function delete_comments($objid,$type='v',$forceDelete=false)
|
|
|
|
{
|
|
|
|
global $db,$userquery,$LANG;
|
|
|
|
|
|
|
|
$uid = user_id();
|
|
|
|
|
2010-01-17 13:53:14 +00:00
|
|
|
if($userquery->permission['admin_del_access'] == 'yes' || $forceDelete)
|
2009-12-21 21:11:54 +00:00
|
|
|
{
|
2010-02-06 09:56:30 +00:00
|
|
|
$db->Execute("DELETE FROM ".tbl("comments")." WHERE type_id='$objid' AND type='$type' ");
|
2009-12-21 21:11:54 +00:00
|
|
|
|
2010-01-13 09:53:21 +00:00
|
|
|
e(lang('usr_cmt_del_msg'),m);
|
2009-12-21 21:11:54 +00:00
|
|
|
return true;
|
|
|
|
}else{
|
2010-01-13 09:53:21 +00:00
|
|
|
e(lang('no_comment_del_perm'));
|
2009-12-21 21:11:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2009-11-30 19:46:45 +00:00
|
|
|
|
|
|
|
/***
|
|
|
|
* Function used to rate comment
|
|
|
|
***/
|
|
|
|
function rate_comment($rate,$cid)
|
|
|
|
{
|
|
|
|
global $db;
|
|
|
|
$comment = $this->get_comment($cid);
|
|
|
|
$voters = $comment['voters'];
|
|
|
|
|
|
|
|
$niddle = "|";
|
|
|
|
$niddle .= userid();
|
|
|
|
$niddle .= "|";
|
|
|
|
$flag = strstr($voters, $niddle);
|
|
|
|
|
|
|
|
if(!$comment)
|
|
|
|
e(lang('no_comment_exists'));
|
|
|
|
elseif(!userid())
|
|
|
|
e(lang('class_comment_err6'));
|
|
|
|
elseif(userid()==$comment['userid'] || (!userid() && $_SERVER['REMOTE_ADDR'] == $comment['comment_ip']))
|
|
|
|
e(lang('no_own_commen_rate'));
|
|
|
|
elseif(!empty($flag))
|
|
|
|
e(lang('class_comment_err7'));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(empty($voters))
|
|
|
|
$voters .= "|";
|
|
|
|
|
|
|
|
$voters .= userid();
|
|
|
|
$voters.= "|";
|
|
|
|
|
|
|
|
$newscore = $comment['vote']+$rate;
|
2010-02-06 09:56:30 +00:00
|
|
|
$db->update(tbl('comments'),array('vote','voters'),array($newscore,$voters)," comment_id='$cid'");
|
2009-11-30 19:46:45 +00:00
|
|
|
e(lang('thanks_rating_comment'),"m");
|
|
|
|
return $newscore;
|
2009-08-25 12:16:42 +00:00
|
|
|
}
|
2009-11-30 19:46:45 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2009-08-25 12:16:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
//Function Used To Varify Syntax
|
|
|
|
function isValidSyntax($syntax){
|
|
|
|
global $LANG;
|
|
|
|
$pattern = "^^[_a-z0-9-]+$";
|
|
|
|
if (eregi($pattern, $syntax)){
|
|
|
|
return true;
|
|
|
|
}else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* FUNCTION USED TO GET VIDEOS FROM DATABASE
|
|
|
|
* @param: array of query parameters array()
|
|
|
|
* featured => '' (yes,no)
|
|
|
|
* username => '' (TEXT)
|
|
|
|
* title => '' (TEXT)
|
|
|
|
* tags => '' (TEXT)
|
|
|
|
* category => '' (INT)
|
|
|
|
* limit => '' (OFFSET,LIMIT)
|
|
|
|
* order=>'' (BY SORT) -- (date_added DESC)
|
|
|
|
* extra_param=>'' ANYTHING FOR MYSQL QUERY
|
|
|
|
* @param: boolean
|
|
|
|
* @param: results type (results,query)
|
|
|
|
*/
|
|
|
|
|
|
|
|
function getVideoList($param=array(),$global_cond=true,$result='results')
|
|
|
|
{
|
|
|
|
global $db;
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM video";
|
|
|
|
|
|
|
|
//Global Condition For Videos
|
|
|
|
if($global_cond==true)
|
|
|
|
$cond = "broadcast='public' AND active='yes' AND status='Successful'";
|
|
|
|
//Checking Condition
|
|
|
|
if(!empty($param['featured']))
|
|
|
|
{
|
|
|
|
$param['featured'] = 'yes' ? 'yes' : 'no';
|
|
|
|
$cond .=" AND featured= '".$param['featured']."' ";
|
|
|
|
}
|
|
|
|
if(!empty($param['username']))
|
|
|
|
{
|
|
|
|
$username = mysql_clean($param['username']);
|
|
|
|
$cond .=" AND featured= '".$username."' ";
|
|
|
|
}
|
|
|
|
if(!empty($param['category']))
|
|
|
|
{
|
|
|
|
$category = intval($param['category']);
|
|
|
|
$cond .=" AND (category01= '".$category."' OR category02= '".$category."' OR category03= '".$category."') ";
|
|
|
|
}
|
|
|
|
if(!empty($param['tags']))
|
|
|
|
{
|
|
|
|
$tags = mysql_clean($param['tags']);
|
|
|
|
$cond .=" AND tags LIKE '%".$tags."%' ";
|
|
|
|
}
|
|
|
|
if(!empty($param['title']))
|
|
|
|
{
|
|
|
|
$tags = mysql_clean($param['tags']);
|
|
|
|
$cond .=" AND title LIKE '%".$param['title']."%' ";
|
|
|
|
}
|
|
|
|
|
|
|
|
//Adding Condition in Query
|
|
|
|
if(!empty($cond))
|
|
|
|
$sql .= " WHERE $cond ";
|
|
|
|
|
|
|
|
//SORTING VIDEOS
|
|
|
|
if(!empty($param['order']))
|
|
|
|
$sort = 'ORDER BY '.$param['order'];
|
|
|
|
|
|
|
|
//Adding Sorting In Query
|
|
|
|
$sql .= $sort;
|
|
|
|
|
|
|
|
//LIMITING VIDEO LIST
|
|
|
|
if(empty($param['limit']))
|
|
|
|
$limit = " LIMIT ". VLISTPP;
|
|
|
|
elseif($param['limit']=='nolimit')
|
|
|
|
$limit = '';
|
|
|
|
else
|
|
|
|
$limit = " LIMIT ".$param['limit'];
|
|
|
|
|
|
|
|
$sql .= $limit;
|
|
|
|
//Final Executing of Query and Returning Results
|
|
|
|
if($result=='results')
|
|
|
|
return $db->Execute($sql);
|
|
|
|
else
|
|
|
|
return $sql;
|
|
|
|
}
|
2010-02-06 13:38:16 +00:00
|
|
|
|
|
|
|
|
2009-08-25 12:16:42 +00:00
|
|
|
/**
|
|
|
|
* Function used to send subsribtion message
|
|
|
|
*/
|
|
|
|
function send_subscription($subscriber,$from,$video)
|
|
|
|
{
|
|
|
|
global $LANG;
|
|
|
|
//First checking weather $subscriber exists or not
|
|
|
|
$array = array('%subscriber%','%user%','%website_title%');
|
|
|
|
$replace = array($subscriber,$from,TITLE);
|
|
|
|
|
|
|
|
$to = $subscriber;
|
2010-01-13 09:53:21 +00:00
|
|
|
$subj = str_replace($array,$replace,lang('user_subscribe_subject'));
|
2009-08-25 12:16:42 +00:00
|
|
|
|
|
|
|
//Get Subscription Message Template
|
|
|
|
$msg = get_subscription_template();
|
|
|
|
$msg = str_replace($array,$replace,$msg);
|
|
|
|
$this->SendMessage($to,$from,$subj,$msg,$video,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to add comment
|
|
|
|
* This is more advance function ,
|
|
|
|
* in this function functions can be applied on comments
|
|
|
|
*/
|
2010-02-02 16:19:41 +00:00
|
|
|
function add_comment($comment,$obj_id,$reply_to=NULL,$type='v',$obj_owner=NULL)
|
2009-08-25 12:16:42 +00:00
|
|
|
{
|
2009-09-28 05:23:50 +00:00
|
|
|
global $userquery,$eh,$db,$Cbucket;
|
2009-08-25 12:16:42 +00:00
|
|
|
//Checking maximum comments characters allowed
|
|
|
|
if(defined("MAX_COMMENT_CHR"))
|
|
|
|
{
|
|
|
|
if(strlen($comment) > MAX_COMMENT_CHR)
|
|
|
|
e(sprintf("'%d' characters allowed for comment",MAX_COMMENT_CHR));
|
|
|
|
}
|
|
|
|
if(empty($comment))
|
|
|
|
e("Please enter something for comment");
|
|
|
|
|
2009-12-29 18:15:35 +00:00
|
|
|
$params = array('comment'=>$comment,'obj_id'=>$obj_id,'reply_to'=>$reply_to,'type'=>$type);
|
|
|
|
$this->validate_comment_functions($params);
|
|
|
|
/*
|
2009-08-25 12:16:42 +00:00
|
|
|
if($type=='video' || $type=='v')
|
|
|
|
{
|
|
|
|
if(!$this->video_exists($obj_id))
|
|
|
|
e("Video does not exist");
|
|
|
|
|
|
|
|
//Checking owner of video
|
|
|
|
if(!USER_COMMENT_OWN)
|
|
|
|
{
|
|
|
|
if(userid()==$this->get_vid_owner($obj_id));
|
|
|
|
e("You cannot comment on your video");
|
|
|
|
}
|
|
|
|
}
|
2009-12-29 18:15:35 +00:00
|
|
|
*/
|
2009-09-28 05:23:50 +00:00
|
|
|
if(!userid() && $Cbucket->configs['anonym_comments']!='yes')
|
2009-08-25 12:16:42 +00:00
|
|
|
e("You are not logged in");
|
|
|
|
|
2009-09-28 05:23:50 +00:00
|
|
|
if(!userid() && $Cbucket->configs['anonym_comments']=='yes')
|
|
|
|
{
|
|
|
|
//Checking for input name and email
|
|
|
|
if(empty($_POST['name']))
|
|
|
|
e("Please enter your name");
|
|
|
|
if(empty($_POST['email']))
|
|
|
|
e("Please enter your email");
|
|
|
|
|
|
|
|
$name = mysql_clean($_POST['name']);
|
|
|
|
$email = mysql_clean($_POST['email']);
|
|
|
|
}
|
|
|
|
|
2009-08-25 12:16:42 +00:00
|
|
|
if(empty($eh->error_list))
|
|
|
|
{
|
2010-02-06 09:56:30 +00:00
|
|
|
$db->insert(tbl("comments"),array
|
2010-02-02 16:19:41 +00:00
|
|
|
('type,comment,type_id,userid,date_added,parent_id,anonym_name,anonym_email','comment_ip','type_owner_id'),
|
2009-08-25 12:16:42 +00:00
|
|
|
array
|
2010-02-02 16:19:41 +00:00
|
|
|
($type,$comment,$obj_id,userid(),NOW(),$reply_to,$name,$email,$_SERVER['REMOTE_ADDR'],$obj_owner));
|
2010-02-06 09:56:30 +00:00
|
|
|
$db->update(tbl("users"),array("total_comments"),array("|f|total_comments+1")," userid='".userid()."'");
|
2009-12-04 21:03:27 +00:00
|
|
|
|
2009-08-25 12:16:42 +00:00
|
|
|
e("Comment has been added",m);
|
2010-01-21 13:49:49 +00:00
|
|
|
|
|
|
|
$cid = $db->insert_id();
|
|
|
|
return $cid;
|
2009-08-25 12:16:42 +00:00
|
|
|
}
|
2009-11-30 19:46:45 +00:00
|
|
|
|
|
|
|
return false;
|
2009-08-25 12:16:42 +00:00
|
|
|
}
|
|
|
|
|
2009-11-30 19:46:45 +00:00
|
|
|
|
2009-08-25 12:16:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to get file details from database
|
|
|
|
*/
|
|
|
|
function file_details($file_name)
|
|
|
|
{
|
|
|
|
global $db;
|
2009-12-09 13:43:19 +00:00
|
|
|
return get_file_details($file_name);
|
|
|
|
/*$results = $db->select("video_files","*"," src_name='$file_name'");
|
2009-08-25 12:16:42 +00:00
|
|
|
if($db->num_rows==0)
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $results[0];
|
2009-12-09 13:43:19 +00:00
|
|
|
}*/
|
2009-08-25 12:16:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to update video and set a thumb as default
|
|
|
|
* @param VID
|
|
|
|
* @param THUMB NUM
|
|
|
|
*/
|
|
|
|
function set_default_thumb($vid,$thumb)
|
|
|
|
{
|
2009-11-04 10:27:40 +00:00
|
|
|
global $cbvid;
|
|
|
|
return $cbvid->set_default_thumb($vid,$thumb);
|
2009-08-25 12:16:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to update video
|
|
|
|
*/
|
|
|
|
function update_video()
|
|
|
|
{
|
2009-08-31 12:01:33 +00:00
|
|
|
global $cbvid;
|
|
|
|
return $cbvid->update_video();
|
2009-08-25 12:16:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to get categorie details
|
|
|
|
*/
|
|
|
|
function get_category($id)
|
|
|
|
{
|
|
|
|
global $db;
|
2010-02-06 09:56:30 +00:00
|
|
|
$results = $db->select(tbl("category"),"*"," categoryid='$id'");
|
2009-08-25 12:16:42 +00:00
|
|
|
return $results[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to get comment from its ID
|
|
|
|
* @param ID
|
|
|
|
*/
|
|
|
|
function get_comment($id)
|
|
|
|
{
|
2010-01-25 13:18:18 +00:00
|
|
|
global $db,$userquery;
|
2010-02-06 09:56:30 +00:00
|
|
|
$result = $db->select(tbl("comments"),"*"," comment_id='$id'");
|
2009-08-25 12:16:42 +00:00
|
|
|
if($db->num_rows>0)
|
|
|
|
{
|
2010-01-25 13:18:18 +00:00
|
|
|
$result = $result[0];
|
|
|
|
if($result['userid'])
|
|
|
|
$udetails = $userquery->get_user_details($result['userid']);
|
|
|
|
if($udetails)
|
|
|
|
$result = array_merge($result,$udetails);
|
|
|
|
return $result ;
|
2009-08-25 12:16:42 +00:00
|
|
|
}else{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to get from database
|
|
|
|
* @param TYPE_ID
|
|
|
|
* @param TYPE
|
|
|
|
* @param COUNT_ONLY Boolean
|
|
|
|
* @param PARENT_ID
|
|
|
|
* @param GET_REPLYIES_ONLY Boolean
|
|
|
|
*/
|
|
|
|
function get_comments($type_id,$type='v',$count_only=FALSE,$parent_id=NULL,$get_reply_only=FALSE)
|
|
|
|
{
|
|
|
|
global $db;
|
|
|
|
$cond = '';
|
|
|
|
|
|
|
|
#Checking if user wants to get replies of comment
|
|
|
|
if($parent_id!=NULL && $get_reply_only)
|
|
|
|
{
|
|
|
|
$cond .= " AND parent_id='$parent_id'";
|
|
|
|
}
|
|
|
|
|
2010-01-23 13:16:19 +00:00
|
|
|
if($type_id!='wildcard')
|
2010-01-23 13:50:53 +00:00
|
|
|
$typeid_query = "AND type_id='$type_id' ";
|
2009-08-25 12:16:42 +00:00
|
|
|
|
2010-01-23 13:16:19 +00:00
|
|
|
if(!$count_only)
|
2009-08-25 12:16:42 +00:00
|
|
|
{
|
2010-01-25 13:18:18 +00:00
|
|
|
//Fetching comments by registered users
|
2010-02-06 15:49:38 +00:00
|
|
|
$result = $db->select(tbl("comments,users"),"*"," type='$type' $typeid_query AND ".tbl("comments.userid")." = ".tbl("users.userid")." $cond");
|
2010-01-25 13:18:18 +00:00
|
|
|
//Fetchign comments by anonymous users
|
2010-02-06 15:49:38 +00:00
|
|
|
$result_anonym = $db->select(tbl("comments"),"*"," type='$type' $typeid_query AND ".tbl("comments.userid")." = '0' $cond");
|
2010-01-25 13:18:18 +00:00
|
|
|
//Mergin both arrays
|
|
|
|
if(is_array($result) && is_array($result_anonym))
|
|
|
|
$result = array_merge($result,$result_anonym);
|
|
|
|
elseif(is_array($result_anonym))
|
|
|
|
$result = $result_anonym;
|
|
|
|
|
|
|
|
//Sorting
|
|
|
|
$new_results = array();
|
|
|
|
if(is_array($result))
|
|
|
|
foreach($result as $r)
|
|
|
|
{
|
|
|
|
$new_results[$r['comment_id']] = $r;
|
|
|
|
}
|
|
|
|
//Sorting wrt keys..
|
|
|
|
ksort($new_results);
|
|
|
|
//pr($result);pr($new_results);
|
|
|
|
//pr($new_results);
|
|
|
|
if(count($new_results) > 0)
|
2010-01-23 13:16:19 +00:00
|
|
|
{
|
2010-01-25 13:18:18 +00:00
|
|
|
return $new_results;
|
2010-01-23 13:16:19 +00:00
|
|
|
}else{
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}else
|
|
|
|
{
|
2010-02-06 09:56:30 +00:00
|
|
|
return $db->count(tbl("comments"),"*"," type='$type' $typeid_query $cond");
|
2009-08-25 12:16:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to get video owner
|
|
|
|
*/
|
|
|
|
function get_vid_owner($vid)
|
|
|
|
{
|
|
|
|
global $db;
|
2010-02-06 09:56:30 +00:00
|
|
|
$results = $db->select(tbl("video"),"userid"," videoid='$vid'");
|
2009-08-25 12:16:42 +00:00
|
|
|
return $results[0];
|
|
|
|
}
|
|
|
|
|
2009-09-28 05:23:50 +00:00
|
|
|
/**
|
|
|
|
* Function used to set website template
|
|
|
|
*/
|
|
|
|
function set_template($template)
|
|
|
|
{
|
|
|
|
global $myquery;
|
|
|
|
if(is_dir(STYLES_DIR.'/'.$template) &&template)
|
|
|
|
{
|
|
|
|
$myquery->Set_Website_Details('template_dir',$template);
|
|
|
|
e("Template has been activated",m);
|
|
|
|
}else
|
|
|
|
e("An error occured while changing the template");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to update comment
|
|
|
|
*/
|
|
|
|
function update_comment($cid,$text)
|
|
|
|
{
|
|
|
|
global $db;
|
2010-02-06 09:56:30 +00:00
|
|
|
$db->Execute("UPDATE ".tbl("comments")." SET comment='$text' WHERE comment_id='$cid'");
|
2009-09-28 05:23:50 +00:00
|
|
|
}
|
2009-12-29 18:15:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to validate comments
|
|
|
|
*/
|
|
|
|
function validate_comment_functions($params)
|
|
|
|
{
|
|
|
|
$type = $params['type'];
|
|
|
|
$obj_id = $params['obj_id'];
|
|
|
|
$comment = $params['comment'];
|
|
|
|
$reply_to = $params['reply_to'];
|
|
|
|
|
|
|
|
if($type=='video' || $type=='v')
|
|
|
|
{
|
|
|
|
if(!$this->video_exists($obj_id))
|
|
|
|
e("Video does not exist");
|
|
|
|
|
|
|
|
//Checking owner of video
|
|
|
|
if(!USER_COMMENT_OWN)
|
|
|
|
{
|
|
|
|
if(userid()==$this->get_vid_owner($obj_id));
|
|
|
|
e("You cannot comment on your video");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$func_array = get_functions('validate_comment_functions');
|
|
|
|
if(is_array($func_array))
|
|
|
|
{
|
|
|
|
foreach($func_array as $func)
|
|
|
|
{
|
|
|
|
if(function_exists($func))
|
|
|
|
{
|
|
|
|
return $func($params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-01-05 09:47:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to insert note in data base for admin referance
|
|
|
|
*/
|
|
|
|
function insert_note($note)
|
|
|
|
{
|
|
|
|
global $db;
|
2010-02-06 14:10:53 +00:00
|
|
|
$db->insert(tbl('admin_notes'),array('note,date_added,userid'),array($note,now(),userid()));
|
2010-01-05 09:47:10 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Function used to get notes
|
|
|
|
*/
|
|
|
|
function get_notes()
|
|
|
|
{
|
|
|
|
global $db;
|
2010-02-06 14:10:53 +00:00
|
|
|
return $db->select(tbl('admin_notes'),'*'," userid='".userid()."'",NULL," date_added DESC ");
|
2010-01-05 09:47:10 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Function usde to delete note
|
|
|
|
*/
|
|
|
|
function delete_note($id)
|
|
|
|
{
|
|
|
|
global $db;
|
2010-02-06 14:10:53 +00:00
|
|
|
$db->delete(tbl("admin_notes"),array("note_id"),array($id));
|
2010-01-05 09:47:10 +00:00
|
|
|
}
|
2009-08-25 12:16:42 +00:00
|
|
|
}
|
|
|
|
?>
|