Fixed : Current page and Next Page

Fixed : Photo Download Issue
Fixed : Video by filename issue
Added : ClipBucket Security Key
Fixed : SEO URls little more
Cleaned : Functions
Added : Logout Hooks
Added : Module
Added : Signup Hooks
This commit is contained in:
Arslan Hassan 2012-03-17 12:50:07 +00:00
parent b438db4a7b
commit ee101b63b9
25 changed files with 1833 additions and 1581 deletions

View file

@ -33,6 +33,8 @@ RewriteRule ^([^.]*)/?$ index.php [L]
RewriteEngine on
RewriteBase /
#
#
#
@ -109,9 +111,7 @@ RewriteRule ^rss/([a-zA-Z0-9].+)$ rss.php?mode=$1&%{QUERY_STRING} [nc]
########## End - Rewrite rules For SEO urls ######################
RewriteRule ^([a-zA-Z0-9-]+)/?$ view_channel.php?uid=$1&seo_diret=yes [NS]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
#Audio Start#
RewriteRule ^audio/(.*)/(.*) module.php?s=audio&p=listen_audio&a=$1
#Audio End#
RewriteRule ^([a-zA-Z0-9.]+)\.?([a-zA-Z0-9]+)?/?$ view_channel.php?uid=$1&seo_diret=yes [NC]

View file

@ -75,6 +75,8 @@ foreach($files as $file)
}
}
//Sending Subscription Emails
$videoDetails = $cbvideo->get_video($file['cqueue_name'],true);
if($videoDetails)

View file

@ -375,6 +375,9 @@ class pages{
//Assigning Variable that can be used in templates
assign('pagination',$this->pagination);
assign('current_page',$page);
assign('total_pages',$total);
assign('next_link',$this->next_link);
assign('pre_link',$this->pre_link);

View file

@ -2497,6 +2497,17 @@ class CBPhotos
if($fp=@fopen($file['file_url'],'r')) {
$this->incrementDownload($p);
// sending the headers
/* Alternate Download Method
header('Content-Type: application/octet-stream');
header("Content-Length: $size");
header("Content-Disposition: attachment; filename=\"".$p['photo_title'].".".$p['ext']."\"");
header('Content-Transfer-Encoding: binary');
header('Pragma: public');
ob_clean();
flush();
readfile($photo_file);*/
header("Content-type: $mime");
header("Content-Length: $size");
header("Content-Disposition: attachment; filename=\"".$p['photo_title'].".".$p['ext']."\"");

View file

@ -761,6 +761,8 @@ class CBvideo extends CBCategory
{
if($cond!='')
$cond .= ' AND (';
else
$cond .=" ( ";
$fileNameQue = 0;
foreach($params['filename'] as $filename)
@ -773,6 +775,7 @@ class CBvideo extends CBCategory
$cond .=" ) ";
}
}
if($params['cond'])

View file

@ -21,9 +21,15 @@
ob_start();
define('IN_CLIPBUCKET',true);
define("DEVELOPMENT_MODE",FALSE);
//ClipBucket Website secret key
//Check docs.clip-bucket.com for more about secret key
define('CB_SECRET_KEY','0?hx4]{o?Wu');
define("DEVELOPMENT_MODE",true);
define("DEV_INGNORE_SYNTAX",TRUE);
//Setting Cookie Timeout
define('COOKIE_TIMEOUT',86400*1); // 1
define('GARBAGE_TIMEOUT',COOKIE_TIMEOUT);
@ -45,7 +51,12 @@ if(!@$in_bg_cron)
ini_set('session.save_path', $sessdir);*/
if (array_key_exists('session', $_REQUEST))
session_id($_REQUEST['session']);
session_start();
}
//Required Files
@ -67,6 +78,7 @@ if(!@$in_bg_cron)
$row = $myquery->Get_Website_Details();
define('DEBUG_LEVEL', 2);
switch(DEBUG_LEVEL)
@ -96,7 +108,7 @@ if(!@$in_bg_cron)
else
{
error_reporting(E_ALL ^E_NOTICE);
ini_set('display_errors', '1');
//ini_set('display_errors', '1');
}
}
}
@ -423,6 +435,7 @@ if(!@$in_bg_cron)
//Assigning Smarty Tags & Values
Assign('CB_VERSION',CB_VERSION);
assign('session_id',session_id());
Assign('FFMPEG_FLVTOOLS_BINARY',FFMPEG_FLVTOOLS_BINARY);
Assign('FFMPEG_MPLAYER_BINARY',FFMPEG_MPLAYER_BINARY);
Assign('PHP_PATH',PHP_PATH);

View file

@ -11,19 +11,21 @@
// We Can Set SEO urls or Simple Urls by selecting following options, by selecting YES , make sure that all ReWrites are defined in .httaccess
$seo_urls = @SEO; // yes/no
function SEO( $text, $slash=false ) {
function SEO( $text, $slash=false,$iconv=true ) {
//This is the MOOOOOOOOOOST BEATUIFUL PART OF SEO URL
if($iconv)
$text = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text);
$text = preg_replace('/ \&\#?[(0-9a-zA-Z){4}]+\;/','',$text);
$entities_match = array('&quot;','!','@','#','%','^','&','*','_','(',')','+','{','}','|',':','"','<','>','?','[',']','\\',';','"',',','.','/','*','+','~','`','=',"'");
$new_props = array('£','¥','|','§','«','¬','¯','º','±','ª',',','µ','»','¼','½','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à ','á','â','ã','ä','å','æ','ç ','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ');
$new_props = array('£','¥','|','§','«','¬','¯','º','±','ª',',','µ','»','¼','½','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à ','á','â','ã','ä','å','æ','ç ','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ','%E9');
$new_replace = array('','','','','','','','','','','','u','','','','','A','A','A','A','A','A','E','C','E','E','E','E','I','I','I','I','D','N','O','O','O','O','O','O','U','U ','U','U','Y','b','B','a','a','a','a','a','a','a','c ','e','e','e','e','i','í','i','i','o','n','o','o','o','o','o','','','u','u','u','u','y','p','y');
$new_replace = array('','','','','','','','','','','','u','','','','','A','A','A','A','A','A','E','C','E','E','E','E','I','I','I','I','D','N','O','O','O','O','O','O','U','U ','U','U','Y','b','B','a','a','a','a','a','a','a','c ','e','e','e','e','i','í','i','i','o','n','o','o','o','o','o','','','u','u','u','u','y','p','y','e');
$entities_replace = array('','','','','','','','','','','','','','','','','','','','','','','','');
$clean_text = str_replace($entities_match, $entities_replace, $text);

View file

@ -70,7 +70,8 @@
return $string;
}
function cb_clean($string,$array=array('no_html'=>true,'mysql_clean'=>false))
function cb_clean($string,$array=array('no_html'=>true,
'mysql_clean'=>false))
{
if($array['no_html'])
$string = htmlentities($string);
@ -83,7 +84,9 @@
return $string;
}
//This Fucntion is for Securing Password, you may change its combination for security reason but make sure dont not rechange once you made your script run
//This Fucntion is for Securing Password,
// you may change its combination for security reason but make
// sure dont not rechange once you made your script run
function pass_code($string) {
$password = md5(md5(sha1(sha1(md5($string)))));
@ -350,7 +353,7 @@
//Function Used TO Get Extensio Of File
function GetExt($file){
return substr($file, strrpos($file,'.') + 1);
return strtolower(substr($file, strrpos($file,'.') + 1));
}
@ -692,10 +695,935 @@
}
/**
* this_page()
*
* get current page name as defined in THIS_PAGE static variable
*
* @param STRING $page_name
* @return STRING current_page
*/
function this_page($page)
{
if(defined('THIS_PAGE'))
return THIS_PAGE;
else
return 'index';
}
/**
* isValidToken()
*
* validate input token given in $_POST request when submitting data in
* ClipBucket.
*
* @param STRING $token
* @param STRING $method
*
* return BOOLEAN
*/
function isValidToken($token,$method=NULL)
{
$fullToken = getToken($method);
if($fullToken!=$token)
return false;
else {
return true;
}
}
/**
* getToken()
*
* Function used to get current token
*
* @param STRING $method
* @return STRING $token
*/
function getToken($method=NULL)
{
$sess = session_id();
$ip = $_SERVER['REMOTE_ADDR'];
$webkey = "";
if(defined('CB_WEBSITE_KEY'))
{
$webkey = CB_WEBSITE_KEY;
}
if($webkey)
$fullToken = md5($sess.$method.$ip.$webkey);
else
$fullToken = md5($sess.$method.$ip);
return $fullToken;
}
/**
* createDataFolders()
*
* create date folders with respect to date. so that no folder gets overloaded
* with number of files.
*
* @param string FOLDER, if set to null, sub-date-folders will be created in
* all data folders
* @return string
*/
function createDataFolders($headFolder=NULL)
{
$year = date("Y");
$month = date("m");
$day = date("d");
$folder = $year.'/'.$month.'/'.$day;
if(!$headFolder)
{
@mkdir(VIDEOS_DIR.'/'.$folder,0777,true);
@mkdir(THUMBS_DIR.'/'.$folder,0777,true);
@mkdir(ORIGINAL_DIR.'/'.$folder,0777,true);
@mkdir(PHOTOS_DIR.'/'.$folder,0777,true);
}else
{
@mkdir($headFolder.'/'.$folder,0777,true);
}
return $folder;
}
/**
* Gets the list of comments and assign it the given paramter
* @global type $myquery
* @param type $params ARGUMENTS , assign=variable to assign comments array
* in smarty template, read getComments for more information
* @return ARRAY $comments
*/
function getSmartyComments($params)
{
global $myquery;
$comments = $myquery->getComments($params);
if($params['assign'])
assign($params['assign'],$comments);
else
return $comments;
}
/**
* This wil get an Advertisment from database and display it
*
* @global type $adsObj
* @param ARRAY (style,class,align,place)
* style = Css Styling on div wrapping AD
* class = class of div wrapping AD
* place = AD placement code e.g ad_300x250
* @return string
*/
function getAd($params)
{
global $adsObj;
$data = '';
if($params['style'] || $params['class'] || $params['align'])
$data .= '<div style="'.$params['style'].'" class="'.$params['class'].'" align="'.$params['align'].'">';
$data .= ad($adsObj->getAd($params['place']));
if($params['style'] || $params['class'] || $params['align'])
$data .= '</div>';
return $data;
}
/**
* FUNCTION USED TO GET VIDEO RATING IN SMARTY
* @param : array(pullRating($videos[$id]['videoid'],false,false,false,'novote');
*/
function pullSmartyRating($param)
{
return pullRating($param['id'],$param['show5'],$param['showPerc'],$aram['showVotes'],$param['static']);
}
/**
* FUNCTION USED TO CLEAN VALUES THAT CAN BE USED IN FORMS
*/
function cleanForm($string)
{
if(is_string($string))
$string = htmlspecialchars($string);
if(get_magic_quotes_gpc())
if(!is_array($string))
$string = stripslashes($string);
return $string;
}
function form_val($string){return cleanForm($string); }
//Escaping Magic Quotes
/**
* FUNCTION USED TO MAKE TAGS MORE PERFECT
* @Author : Arslan Hassan <arslan@clip-bucket.com,arslan@labguru.com>
* @param tags text unformatted
* returns tags formatted
*/
function genTags($tags,$sep=',')
{
//Remove fazool spaces
$tags = preg_replace(array('/ ,/','/, /'),',',$tags);
$tags = preg_replace( "`[,]+`" , ",", $tags);
$tag_array = explode($sep,$tags);
foreach($tag_array as $tag)
{
if(isValidtag($tag))
{
$newTags[] = $tag;
}
}
//Creating new tag string
if(is_array($newTags))
$tagString = implode(',',$newTags);
else
$tagString = 'no-tag';
return $tagString;
}
/**
* FUNCTION USED TO VALIDATE TAG
* @Author : Arslan Hassan <arslan@clip-bucket.com,arslan@labguru.com>
* @param tag
* return true or false
*/
function isValidtag($tag)
{
$disallow_array = array
('of','is','no','on','off','a','the','why','how','what','in');
if(!in_array($tag,$disallow_array) && strlen($tag)>2)
return true;
else
return false;
}
/**
* FUNCTION USED TO GET CATEGORY LIST
*/
function getCategoryList($params=false)
{
global $cats;
$cats = "";
$type = $params['type'];
switch($type)
{
default:
{
cb_call_functions('categoryListing',$params);
}
break;
case "video":case "videos":
case "v":
{
global $cbvid;
$cats = $cbvid->cbCategories($params);
}
break;
case "users":case "user":
case "u": case "channels": case "channels":
{
global $userquery;
$cats = $userquery->cbCategories($params);
}
break;
case "group":case "groups":
case "g":
{
global $cbgroup;
$cats = $cbgroup->cbCategories($params);
}
break;
case "collection":case "collections":
case "cl":
{
global $cbcollection;
$cats = $cbcollection->cbCategories($params);
}
break;
}
return $cats;
}
function cb_bottom()
{
//Woops..its gone
}
function getSmartyCategoryList($params)
{
return getCategoryList($params);
}
/**
* Function used to insert data in database
* @param : table name
* @param : fields array
* @param : values array
* @param : extra params
*/
function dbInsert($tbl,$flds,$vls,$ep=NULL)
{
global $db ;
$db->insert($tbl,$flds,$vls,$ep);
}
/**
* Function used to Update data in database
* @param : table name
* @param : fields array
* @param : values array
* @param : Condition params
* @params : Extra params
*/
function dbUpdate($tbl,$flds,$vls,$cond,$ep=NULL)
{
global $db ;
return $db->update($tbl,$flds,$vls,$cond,$ep);
}
/**
* Function used to Delete data in database
* @param : table name
* @param : fields array
* @param : values array
* @params : Extra params
*/
function dbDelete($tbl,$flds,$vls,$ep=NULL)
{
global $db ;
return $db->delete($tbl,$flds,$vls,$ep);
}
/**
**
*/
function cbRocks()
{
define("isCBSecured",TRUE);
//echo cbSecured(CB_SIGN);
}
/**
* Insert Id
*/
function get_id($code)
{
global $Cbucket;
$id = $Cbucket->ids[$code];
if(empty($id)) $id = $code;
return $id;
}
/**
* Set Id
*/
function set_id($code,$id)
{
global $Cbucket;
return $Cbucket->ids[$code]=$id;
}
/**
* Function used to select data from database
*/
function dbselect($tbl,$fields='*',$cond=false,$limit=false,$order=false,$p=false)
{
global $db;
return $db->dbselect($tbl,$fields,$cond,$limit,$order,$p);
}
/**
* Function used to count fields in mysql
* @param TABLE NAME
* @param Fields
* @param condition
*/
function dbcount($tbl,$fields='*',$cond=false)
{
global $db;
if($cond)
$condition = " Where $cond ";
$query = "Select Count($fields) From $tbl $condition";
$result = $db->Execute($query);
$db->total_queries++;
$db->total_queries_sql[] = $query;
return $result->fields[0];
}
/**
* An easy function for erorrs and messages (e is basically short form of exception)
* I dont want to use the whole Trigger and Exception code, so e pretty works for me :D
* @param TEXT $msg
* @param TYPE $type (e for Error, m for Message
* @param INT $id Any Predefined Message ID
*/
function e($msg=NULL,$type='e',$id=NULL)
{
global $eh;
if(!empty($msg))
return $eh->e($msg,$type,$id);
}
/**
* Function used to get subscription template
*/
function get_subscription_template()
{
global $LANG;
return lang('user_subscribe_message');
}
/**
* Short form of print_r as pr
*/
function pr($text,$wrap_pre=false)
{
if(!$wrap_pre)
print_r($text);
else
{
echo "<pre>";
print_r($text);
echo "</pre>";
}
}
/**
* This function is used to call function in smarty template
* This wont let you pass parameters to the function, but it will only call it
*/
function FUNC($params)
{
global $Cbucket;
//Function used to call functions by
//{func namefunction_name}
// in smarty
$func=$params['name'];
if(function_exists($func))
$func();
}
/**
* Function used to return mysql time
* @author : Fwhite
*/
function NOW()
{
return date('Y-m-d H:i:s', time());
}
/**
* Function used to get Regular Expression from database
* @param : code
*/
function get_re($code)
{
global $db;
$results = $db->select(tbl("validation_re"),"*"," re_code='$code'");
if($db->num_rows>0)
{
return $results[0]['re_syntax'];
}else{
return false;
}
}
function get_regular_expression($code)
{
return get_re($code);
}
/**
* Function used to check weather input is valid or not
* based on preg_match
*/
function check_re($syntax,$text)
{
preg_match('/'.$syntax.'/i',$text,$matches);
if(!empty($matches[0]))
{
return true;
}else{
return false;
}
}
function check_regular_expression($code,$text)
{
return check_re($code,$text);
}
/**
* Function used to check field directly
*/
function validate_field($code,$text)
{
$syntax = get_re($code);
if(empty($syntax))
return true;
return check_regular_expression($syntax,$text);
}
function is_valid_syntax($code,$text)
{
if(DEVELOPMENT_MODE && DEV_INGNORE_SYNTAX)
return true;
return validate_field($code,$text);
}
/**
* Function used to apply function on a value
*/
function is_valid_value($func,$val)
{
if(!function_exists($func))
return true;
elseif(!$func($val))
return false;
else
return true;
}
function apply_func($func,$val)
{
if(is_array($func))
{
foreach($func as $f)
if(function_exists($f))
$val = $f($val);
}else{
$val = $func($val);
}
return $val;
}
/**
* Function used to validate YES or NO input
*/
function yes_or_no($input,$return=yes)
{
$input = strtolower($input);
if($input!=yes && $input !=no)
return $return;
else
return $input;
}
/**
* Function used to display flash player for ClipBucket video
*/
function flashPlayer($param)
{
global $Cbucket,$swfobj;
$param['player_div'] = $param['player_div'] ? $param['player_div'] : 'videoPlayer';
$key = $param['key'];
$flv = $param['flv'].'.flv';
$code = $param['code'];
$flv_url = $file;
$embed = $param['embed'];
$code = $param['code'];
$height = $param['height'] ? $param['height'] : config('player_height');
$width = $param['width'] ? $param['width'] : config('player_width');
$param['height'] = $height;
$param['width'] = $width ;
if(!$param['autoplay'])
$param['autoplay'] = config('autoplay_video');
assign('player_params',$param);
if(count($Cbucket->actions_play_video)>0)
{
foreach($Cbucket->actions_play_video as $funcs )
{
if(function_exists($funcs))
{
$func_data = $funcs($param);
}
if($func_data)
{
$player_code = $func_data;
break;
}
}
}
if(function_exists('cbplayer') && empty($player_code))
$player_code = cbplayer($param,true);
global $pak_player;
if($player_code)
if(!$pak_player && $show_player)
{
assign("player_js_code",$player_code);
Template(PLAYER_DIR.'/player.html',false);
return false;
}else
{
return false;
}
return blank_screen($param);
}
/**
* FUnctiuon used to plya HQ videos
*/
function HQflashPlayer($param)
{
return flashPlayer($param);
}
/**
* Function used to get player from website settings
*/
function get_player()
{
global $Cbucket;
return $Cbucket->configs['player_file'];
}
/**
* This funcion used to call function dynamically in smarty
*/
function load_form($param)
{
$func = $param['name'];
if(function_exists($func))
return $func($param);
}
/**
* Function used to get PHP Path
*/
function php_path()
{
if(PHP_PATH !='')
return PHP_PATH;
else
return "/usr/bin/php";
}
/**
* Functon used to get binary paths
*/
function get_binaries($path)
{
if(is_array($path))
{
$type = $path['type'];
$path = $path['path'];
}
if($type=='' || $type=='user')
{
$path = strtolower($path);
switch($path)
{
case "php":
return php_path();
break;
case "mp4box":
return config("mp4boxpath");
break;
case "flvtool2":
return config("flvtool2path");
break;
case "ffmpeg":
return config("ffmpegpath");
break;
}
}else{
$path = strtolower($path);
switch($path)
{
case "php":
$return_path = shell_output("which php");
if($return_path)
return $return_path;
else
return "Unable to find PHP path";
break;
case "mp4box":
$return_path = shell_output("which MP4Box");
if($return_path)
return $return_path;
else
return "Unable to find mp4box path";
break;
case "flvtool2":
$return_path = shell_output("which flvtool2");
if($return_path)
return $return_path;
else
return "Unable to find flvtool2 path";
break;
case "ffmpeg":
$return_path = shell_output("which ffmpeg");
if($return_path)
return $return_path;
else
return "Unable to find ffmpeg path";
break;
}
}
}
/**
* Function in case htmlspecialchars_decode does not exist
*/
function unhtmlentities ($string)
{
$trans_tbl =get_html_translation_table (HTML_ENTITIES );
$trans_tbl =array_flip ($trans_tbl );
return strtr ($string ,$trans_tbl );
}
/**
* Function used to execute command in background
*/
function bgexec($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
//exec($cmd." >> /dev/null &");
exec($cmd);
//pclose(popen("start \"bla\" \"" . $exe . "\" " . escapeshellarg($args), "r"));
}else{
exec($cmd . " > /dev/null &");
}
}
/**
* Function used to get array value
* if you know partial value of array and wants to know complete
* value of an array, this function is being used then
*/
function array_find($needle, $haystack)
{
foreach ($haystack as $item)
{
if (strpos($item, $needle) !== FALSE)
{
return $item;
break;
}
}
}
/**
* Function used to give output in proper form
*/
function input_value($params)
{
$input = $params['input'];
$value = $input['value'];
if($input['value_field']=='checked')
$value = $input['checked'];
if($input['return_checked'])
return $input['checked'];
if(function_exists($input['display_function']))
return $input['display_function']($value);
elseif($input['type']=='dropdown')
{
if($input['checked'])
return $value[$input['checked']];
else
return $value[0];
}else
return $input['value'];
}
/**
* Function used to convert input to categories
* @param input can be an array or #12# like
*/
function convert_to_categories($input)
{
if(is_array($input))
{
foreach($input as $in)
{
if(is_array($in))
{
foreach($in as $i)
{
if(is_array($i))
{
foreach($i as $info)
{
$cat_details = get_category($info);
$cat_array[] = array($cat_details['categoryid'],$cat_details['category_name']);
}
}elseif(is_numeric($i)){
$cat_details = get_category($i);
$cat_array[] = array($cat_details['categoryid'],$cat_details['category_name']);
}
}
}elseif(is_numeric($in)){
$cat_details = get_category($in);
$cat_array[] = array($cat_details['categoryid'],$cat_details['category_name']);
}
}
}else{
preg_match_all('/#([0-9]+)#/',$default['category'],$m);
$cat_array = array($m[1]);
foreach($cat_array as $i)
{
$cat_details = get_category($i);
$cat_array[] = array($cat_details['categoryid'],$cat_details['category_name']);
}
}
$count = 1;
if(is_array($cat_array))
{
foreach($cat_array as $cat)
{
echo '<a href="'.$cat[0].'">'.$cat[1].'</a>';
if($count!=count($cat_array))
echo ', ';
$count++;
}
}
}
/**
* Function used to get categorie details
*/
function get_category($id)
{
global $myquery;
return $myquery->get_category($id);
}
/**
* Sharing OPT displaying
*/
function display_sharing_opt($input)
{
foreach($input as $key => $i)
{
return $key;
break;
}
}
/**
* Function used to get error_list
*/
function error_list()
{
global $eh;
return $eh->error_list;
}
/**
* Function used to get msg_list
*/
function msg_list()
{
global $eh;
return $eh->message_list;
}
/**
* Function used to add tempalte in display template list
* @param File : file of the template
* @param Folder : weather to add template folder or not
* if set to true, file will be loaded from inside the template
* such that file path will becom $templatefolder/$file
* @param follow_show_page : this param tells weather to follow ClipBucket->show_page
* variable or not, if show_page is set to false and follow is true, this template will not load
* otherwise there it WILL
*/
function template_files($file,$folder=false,$follow_show_page=true)
{
global $ClipBucket;
if(!$folder)
$ClipBucket->template_files[] = array('file' => $file,'follow_show_page'=>$follow_show_page);
else
$ClipBucket->template_files[] = array('file'=>$file,
'folder'=>$folder,'follow_show_page'=>$follow_show_page);
}
/**
* Function used to include file
*/
function include_template_file($params)
{
$file = $params['file'];
if(file_exists(LAYOUT.'/'.$file))
Template($file);
elseif(file_exists($file))
Template($file,false);
}
//Including videos functions
include("functions_videos.php");
//Including Users Functions
include("functions_users.php");
//Group Functions
include("functions_groups.php");
//Collections Functions
include("functions_collections.php");
include("functions1.php");
include("functions2.php");
include("functions3.php");
?>

File diff suppressed because it is too large Load diff

View file

@ -72,45 +72,13 @@
}
/**
* Function used to validate username
* @input USERNAME
*/
function username_check($username)
{
global $Cbucket;
$banned_words = $Cbucket->configs['disallowed_usernames'];
$banned_words = explode(',',$banned_words);
foreach($banned_words as $word)
{
preg_match("/$word/Ui",$username,$match);
if(!empty($match[0]))
return false;
}
//Checking if its syntax is valid or not
$multi = config('allow_unicode_usernames');
//Checking Spaces
if(!config('allow_username_spaces'))
preg_match('/ /',$username,$matches);
if(!is_valid_syntax('username',$username) && $multi!='yes' || $matches)
e(lang("class_invalid_user"));
return true;
}
/**
* Function used to check weather username already exists or not
* @input USERNAME
*/
function user_exists($user)
{
global $userquery;
return $userquery->username_exists($user);
}
/**
* Function used to check weather email already exists or not
@ -595,21 +563,7 @@
}
/**
* Function used to check weather video has Mp4 file or not
*/
function has_hq($vdetails,$is_file=false)
{
if(!$is_file)
$file = get_hq_video_file($vdetails);
else
$file = $vdetails;
if(getext($file)=='mp4' && !strstr($file,'-m'))
return $file;
else
return false;
}
/**
* Function used to display an ad
@ -676,7 +630,6 @@
}
function get_config($input){ return config($input); }
/**
* Funcion used to call functions
* when video is going to watched
@ -1014,15 +967,7 @@
return $total_pages = round($records+0.49,0);
}
/**
* Function used to return level name
* @param levelid
*/
function get_user_level($id)
{
global $userquery;
return $userquery->usr_levels[$id];
}
@ -1298,14 +1243,7 @@
}
/**
* function used to get vidos
*/
function get_users($param)
{
global $userquery;
return $userquery->get_users($param);
}
/**

View file

@ -117,14 +117,7 @@
}
/**
* FUnction used to get username from userid
*/
function get_username($uid)
{
global $userquery;
return $userquery->get_username($uid,'username');
}
/**
* Function used to get collection name from id
@ -1650,23 +1643,6 @@
return basename(dirname($pluginFile));
}
/**
* function used to create folder for video
* and files
*/
function createDataFolders()
{
$year = date("Y");
$month = date("m");
$day = date("d");
$folder = $year.'/'.$month.'/'.$day;
@mkdir(VIDEOS_DIR.'/'.$folder,0777,true);
@mkdir(THUMBS_DIR.'/'.$folder,0777,true);
@mkdir(ORIGINAL_DIR.'/'.$folder,0777,true);
@mkdir(PHOTOS_DIR.'/'.$folder,0777,true);
return $folder;
}
/**
@ -1867,6 +1843,16 @@
{
global $db;
unset($query['order']);
$newQuery = array();
//Cleaning values...
foreach($query as $field => $value)
$newQuery[$field] = mysql_clean($value);
$counter = mysql_clean($counter);
$query = $newQuery;
$je_query = json_encode($query);
$query_md5 = md5($je_query);
$count = $db->count(tbl('counters'),"*","section='$section' AND query_md5='$query_md5'");

View file

@ -0,0 +1,15 @@
<?php
/**
* Function used to validate category
* INPUT $cat array
*/
function validate_collection_category($array=NULL)
{
global $cbcollection;
return $cbcollection->validate_collection_category($array);
}
?>

View file

@ -0,0 +1,14 @@
<?php
/**
* Function used to validate category
* INPUT $cat array
*/
function validate_group_category($array=NULL)
{
global $cbgroup;
return $cbgroup->validate_group_category($array);
}
?>

View file

@ -0,0 +1,140 @@
<?php
/*
* $Id$
*
* @Since : 12/7/2011 - 2.7
*
* All users related functions
*/
/**
* Function used to get number of videos uploaded by user
* @param INT userid
* @param Conditions
*/
function get_user_vids($uid,$cond=NULL,$count_only=false)
{
global $userquery;
return $userquery->get_user_vids($uid,$cond,$count_only);
}
/**
* Function used to return level name
* @param levelid
*/
function get_user_level($id)
{
global $userquery;
return $userquery->usr_levels[$id];
}
/**
* function used to get vidos
*/
function get_users($param)
{
global $userquery;
return $userquery->get_users($param);
}
/**
* Function used to check weather username already exists or not
* @input USERNAME
*/
function user_exists($user)
{
global $userquery;
return $userquery->username_exists($user);
}
/**
* Function used to validate username
* @input USERNAME
*/
function username_check($username)
{
global $Cbucket;
$banned_words = $Cbucket->configs['disallowed_usernames'];
$banned_words = explode(',',$banned_words);
foreach($banned_words as $word)
{
preg_match("/$word/Ui",$username,$match);
if(!empty($match[0]))
return false;
}
//Checking if its syntax is valid or not
$multi = config('allow_unicode_usernames');
//Checking Spaces
if(!config('allow_username_spaces'))
preg_match('/ /',$username,$matches);
if(!is_valid_syntax('username',$username) && $multi!='yes' || $matches)
e(lang("class_invalid_user"));
return true;
}
/**
* FUnction used to get username from userid
*/
function get_username($uid)
{
global $userquery;
return $userquery->get_username($uid,'username');
}
/**
* Function used to get userid anywhere
* if there is no user_id it will return false
*/
function user_id()
{
global $userquery;
if($userquery->userid !='' && $userquery->is_login) return $userquery->userid; else false;
}
//alias
function userid(){return user_id();}
/**
* Function used to get username anywhere
* if there is no usern_name it will return false
*/
function user_name()
{
global $userquery;
if($userquery->user_name)
return $userquery->user_name;
else
return $userquery->get_logged_username();
}
function username(){return user_name();}
/**
* Function used to check weather user access or not
*/
function has_access($access,$check_only=TRUE,$verify_logged_user=true)
{
global $userquery;
return $userquery->login_check($access,$check_only,$verify_logged_user);
}
/**
* Function used to get user avatar
* @param ARRAY $userdetail
* @param SIZE $int
*/
function avatar($param)
{
global $userquery;
$udetails = $param['details'];
$size = $param['size'];
$uid = $param['uid'];
return $userquery->avatar($udetails,$size,$uid);
}
?>

View file

@ -425,3 +425,469 @@ function getSmartyThumb($params)
{
return get_thumb($params['vdetails'],$params['num'],$params['multi'],$params['count_only'],true,true,$params['size']);
}
/**
* Function used to check weather video has Mp4 file or not
*/
function has_hq($vdetails,$is_file=false)
{
$custom_funcs = cb_get_functions('has_hq');
if($custom_funcs && !$is_file)
foreach($custom_funcs as $func)
{
if(function_exists($func))
{
return $func($vdetails);
}
}
if(!$is_file)
$file = get_hq_video_file($vdetails);
else
$file = $vdetails;
if(getext($file)=='mp4' && !strstr($file,'-m'))
return $file;
else
return false;
}
/**
* Gets video link , used in Smarty
* {VideoLink vdetails=$vdata type=link,playlist assign=somevar}
* @param type $params
* @return type
*/
function videoSmartyLink($params)
{
$link = VideoLink($params['vdetails'],$params['type']);
if(!$params['assign'])
return $link;
else
assign($params['assign'],$link);
}
/**
* function used to validate Video Category
*
* @global type $myquery
* @global type $LANG
* @global type $cbvid
* @param type $array
* @return type
*/
function validate_vid_category($array=NULL)
{
global $myquery,$LANG,$cbvid;
if($array==NULL)
$array = $_POST['category'];
if(count($array)==0)
return false;
else
{
foreach($array as $arr)
{
if($cbvid->category_exists($arr))
$new_array[] = $arr;
}
}
if(count($new_array)==0)
{
e(lang('vdo_cat_err3'));
return false;
}elseif(count($new_array)>ALLOWED_VDO_CATS)
{
e(sprintf(lang('vdo_cat_err2'),ALLOWED_VDO_CATS));
return false;
}
return true;
}
/**
* Function used to check videokey exists or not
* key_exists
*/
function vkey_exists($key)
{
global $db;
$db->select(tbl("video"),"videokey"," videokey='$key'");
if($db->num_rows>0)
return true;
else
return false;
}
/**
* Function used to check file_name exists or not
* as its a unique name so it will not let repost the data
*/
function file_name_exists($name)
{
global $db;
$results = $db->select(tbl("video"),"videoid,file_name"," file_name='$name'");
if($db->num_rows >0)
return $results[0]['videoid'];
else
return false;
}
/**
* Function used to get video from conversion queue
*/
function get_queued_video($update=TRUE,$fileName=NULL)
{
global $db;
$max_conversion = config('max_conversion');
$max_conversion = $max_conversion ? $max_conversion : 2;
$max_time_wait = config('max_time_wait'); //Maximum Time Wait to make PRocessing Video Automatcially OK
$max_time_wait = $max_time_wait ? $max_time_wait : 7200;
//First Check How Many Videos Are In Queu Already
$processing = $db->count(tbl("conversion_queue"),"cqueue_id"," cqueue_conversion='p' ");
if(true)
{
if($fileName)
{
$queueName = getName($fileName);
$ext = getExt($fileName);
$fileNameQuery = " AND cqueue_name ='$queueName' AND cqueue_ext ='$ext' ";
}
$results = $db->select(tbl("conversion_queue"),"*","cqueue_conversion='no' $fileNameQuery",1);
$result = $results[0];
if($update)
$db->update(tbl("conversion_queue"),array("cqueue_conversion","time_started"),array("p",time())," cqueue_id = '".$result['cqueue_id']."'");
return $result;
}else
{
//Checking if video is taking more than $max_time_wait to convert so we can change its time to
//OK Automatically
//Getting All Videos That are being processed
$results = $db->select(tbl("conversion_queue"),"*"," cqueue_conversion='p' ");
foreach($results as $vid)
{
if($vid['time_started'])
{
if($vid['time_started'])
$time_started = $vid['time_started'];
else
$time_started = strtotime($vid['date_added']);
$elapsed_time = time()-$time_started;
if($elapsed_time>$max_time_wait)
{
//CHanging Status TO OK
$db->update(tbl("conversion_queue"),array("cqueue_conversion"),
array("yes")," cqueue_id = '".$result['cqueue_id']."'");
}
}
}
return false;
}
}
/**
* Function used to get video being processed
*/
function get_video_being_processed($fileName=NULL)
{
global $db;
if($fileName)
{
$queueName = getName($fileName);
$ext = getExt($fileName);
$fileNameQuery = " AND cqueue_name ='$queueName' AND cqueue_ext ='$ext' ";
}
$results = $db->select(tbl("conversion_queue"),"*","cqueue_conversion='p' $fileNameQuery");
return $results;
}
function get_video_details($vid=NULL)
{
global $myquery;
if(!$vid)
global $vid;
return $myquery->get_video_details($vid);
}
/**
* Function used to get all video files
* @param Vdetails
* @param $count_only
* @param $with_path
*/
function get_all_video_files($vdetails,$count_only=false,$with_path=false)
{
$details = get_video_file($vdetails,true,$with_path,true,$count_only);
if($count_only)
return count($details);
return $details;
}
function get_all_video_files_smarty($params)
{
$vdetails = $params['vdetails'];
$count_only = $params['count_only'];
$with_path = $params['with_path'];
return get_all_video_files($vdetails,$count_only,$with_path);
}
/**
* Function use to get video files
*/
function get_video_file($vdetails,$return_default=true,$with_path=true,$multi=false,$count_only=false,$hq=false)
{
global $Cbucket;
# checking if there is any other functions
# available
if(is_array($Cbucket->custom_video_file_funcs))
foreach($Cbucket->custom_video_file_funcs as $func)
if(function_exists($func))
{
$func_returned = $func($vdetails, $hq);
if($func_returned)
return $func_returned;
}
#Now there is no function so lets continue as (WITH .files)
if($vdetails['file_name'])
$vid_files = glob(VIDEOS_DIR."/".$vdetails['file_name'].".*");
#Now there is no function so lets continue as (WITH - files)
if($vdetails['file_name'])
$vid_files_more = glob(VIDEOS_DIR."/".$vdetails['file_name']."-*");
if($vid_files && $vid_files_more)
$vid_files = array_merge($vid_files,$vid_files_more);
#replace Dir with URL
if(is_array($vid_files))
foreach($vid_files as $file)
{
$files_part = explode('/',$file);
$video_file = $files_part[count($files_part)-1];
if($with_path)
$files[] = VIDEOS_URL.'/'.$video_file;
else
$files[] = $video_file;
}
if(count($files)==0 && !$multi && !$count_only)
{
if($return_default)
{
if($with_path)
return VIDEOS_URL.'/no_video.flv';
else
return 'no_video.flv';
}else{
return false;
}
}else{
if($multi)
return $files;
if($count_only)
return count($files);
foreach($files as $file)
{
if($hq)
{
if(getext($file)=='mp4' && !strstr($file,'-m'))
{
return $file;
break;
}
}else{
return $file;
break;
}
}
return $files[0];
}
}
/**
* FUnction used to get HQ ie mp4 video
*/
function get_hq_video_file($vdetails,$return_default=true)
{
return get_video_file($vdetails,$return_default,true,false,false,true);
}
/**
* Function used to update processed video
* @param Files details
*/
function update_processed_video($file_array,$status='Successful',$ingore_file_status=false,$failed_status='')
{
global $db;
$file = $file_array['cqueue_name'];
$array = explode('-',$file);
if(!empty($array[0]))
$file_name = $array[0];
$file_name = $file;
$file_path = VIDEOS_DIR.'/'.$file_array['cqueue_name'].'.flv';
$file_size = @filesize($file_path);
if(file_exists($file_path) && $file_size>0 && !$ingore_file_status)
{
$stats = get_file_details($file_name);
//$duration = $stats['output_duration'];
//if(!$duration)
// $duration = $stats['duration'];
$duration = parse_duration(LOGS_DIR.'/'.$file_array['cqueue_name'].'.log');
$db->update(tbl("video"),array("status","duration","failed_reason"),
array($status,$duration,$failed_status)," file_name='".$file_name."'");
}else
{
$stats = get_file_details($file_name);
//$duration = $stats['output_duration'];
//if(!$duration)
// $duration = $stats['duration'];
$duration = parse_duration(LOGS_DIR.'/'.$file_array['cqueue_name'].'.log');
$db->update(tbl("video"),array("status","duration","failed_reason"),
array('Failed',$duration,$failed_status)," file_name='".$file_name."'");
}
}
/**
* This function will activate the video if file exists
*/
function activate_video_with_file($vid)
{
global $db;
$vdetails = get_video_details($vid);
$file_name = $vdetails['file_name'];
$results = $db->select(tbl("conversion_queue"),"*"," cqueue_name='$file_name' AND cqueue_conversion='yes'");
$result = $results[0];
update_processed_video($result);
}
/**
* Function Used to get video file stats from database
* @param FILE_NAME
*/
function get_file_details($file_name)
{
global $db;
//$result = $db->select(tbl("video_files"),"*"," id ='$file_name' OR src_name = '$file_name' ");
//Reading Log File
$file = LOGS_DIR.'/'.$file_name.'.log';
if(!file_exists($file))
$file = $file_name;
if(file_exists($file))
{
$data = file_get_contents($file);
//$file = file_get_contents('1260270267.log');
preg_match_all('/(.*) : (.*)/',trim($data),$matches);
$matches_1 = ($matches[1]);
$matches_2 = ($matches[2]);
for($i=0;$i<count($matches_1);$i++)
{
$statistics[trim($matches_1[$i])] = trim($matches_2[$i]);
}
if(count($matches_1)==0)
{
return false;
}
$statistics['conversion_log'] = $data;
return $statistics;
}else
return false;
}
function parse_duration($log)
{
$duration = false;
$log_details = get_file_details($log);
$duration = $log['output_duration'];
if(!$duration || !is_numeric($duration))
$duration = $log['duration'];
if(!$duration || !is_numeric($duration))
{
if(file_exists($log))
$log_content = file_get_contents($log);
//Parse duration..
preg_match_all('/Duration: ([0-9]{1,2}):([0-9]{1,2}):([0-9.]{1,5})/i',$log_content,$matches);
unset($log_content);
//Now we will multiple hours, minutes accordingly and then add up with seconds to
//make a single variable of duration
$hours = $matches[1][0];
$minutes = $matches[2][0];
$seconds = $matches[3][0];
$hours = $hours * 60 * 60;
$minutes = $minutes * 60;
$duration = $hours+$minutes+$seconds;
$duration;
}
return $duration;
}
/**
* Function used to get thumbnail number from its name
* Updated: If we provide full path for some reason and
* web-address has '-' in it, this means our result is messed.
* But we know our number will always be in last index
* So wrap it with end() and problem solved.
*/
function get_thumb_num($name)
{
$list = end(explode('-',$name));
$list = explode('.',$list);
return $list[0];
}
/**
* Function used to remove thumb
*/
function delete_video_thumb($file)
{
global $LANG;
$path = THUMBS_DIR.'/'.$file;
if(file_exists($path))
{
unlink($path);
e(lang('video_thumb_delete_msg'),'m');
}else{
e(lang('video_thumb_delete_err'));
}
}

View file

@ -141,15 +141,19 @@
/**
* add link in admin area left menu
*
* Function used to add items in admin menu
* This function will insert new item in admin menu
* under given header, if the header is not available
* it will create one, ( Header means titles ie 'Plugins' 'Videos' etc)
* @param STRING $header - Could be Plugin , Videos, Users , please check
* http://docs.clip-bucket.com. for reference
* @param STRING name
* @param STRING link
* That will add new item in admin menu
* http://docs.clip-bucket.com/add_admin_menu-function for reference
*
* @param STRING $header - Could be Plugin , Videos, Users ,
* @param STRING $name - Menu title
* @param STRING $link - Menu Link
* @param STRING $plug_folder - Path to plugin folder
* @param STRING $is_player_file - Just to tell if plugin is somehow related to players
*/
function add_admin_menu($header='Tool Box',$name,$link,$plug_folder=false,$is_player_file=false)
{

View file

@ -3,7 +3,7 @@
***************************************************************
| Copyright (c) 2007-2010 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
| @ Software : ClipBucket , <EFBFBD> PHPBucket.com
****************************************************************
*/

View file

@ -1,6 +1,9 @@
<?php
require_once 'includes/config.inc.php';
$userquery->logout();
if(cb_get_functions('logout')) cb_call_functions('logout');
setcookie('is_logout','yes',time()+3600,'/');
redirect_to(BASEURL);
?>

View file

@ -8,8 +8,6 @@
*/
define("IN_MODULE",true);
define("PARENT_PAGE",$_GET['s']);
define("THIS_PAGE",$_GET['p']);
require 'includes/config.inc.php';
@ -19,7 +17,7 @@ $pages->page_redir();
load_modules();
if(!defined("THIS_PAGE"))
e("Invalid module");
e("Invalid module");
display_it();

21
upload/out.php Normal file
View file

@ -0,0 +1,21 @@
<?php
/**
* file used to redirect links to outer website
*/
include("includes/config.inc.php");
$link = urldecode($_GET['l']);
if(!$link)
redirect_to(BASEURL);
if(!strstr($link,'http'))
$link = "http://".$link;
redirect_to($link);
exit();
?>

View file

@ -46,7 +46,8 @@ if(!function_exists('cb_player'))
{
$hd = $data['hq'];
if($hd=='yes') $file = get_hq_video_file($vdetails); else $file = get_video_file($vdetails,true,true);
if($hd=='yes') $file = get_hq_video_file($vdetails);
else $file = get_video_file($vdetails,true,true);
$hd_file = get_hq_video_file($vdetails);

View file

@ -57,6 +57,8 @@ if(isset($_POST['login'])){
if($userquery->login_user($username,$password,$remember))
{
if(cb_get_functions('login_success')) cb_call_functions('login_success');
if($_COOKIE['pageredir'])
redirect_to($_COOKIE['pageredir']);
else

View file

@ -1,3 +1,120 @@
<div id="wrap">
<div class="inner_wrap">
{assign var=sort value=$smarty.get.sort|replace:'most_commented':'commented'}
<div class="itemListTitle br3 b89" id="sortingDD">
{lang code=$sort} <span class="itemListTitleArrow"></span>
<div style="border-bottom:1px solid #ddd; width:150px; position:absolute;bottom:-2px; left:0px"></div>
<div class="itemListDD br3_bottom b89" style="display:none" id="sortingDDList">
<ul>
{assign var=sorting_links value=func->sorting_links()}
{foreach from=$sorting_links item=name key=sort name=sorts}
<li><a href="{link name=sort sort=$sort type=videos}">{$name}</a></li>
{/foreach}
</ul>
</div>
</div>
{assign var=time_frame value=$smarty.get.time|replace:'_':''"}
<div class="itemListTitle br3 b89" id="timingDD">
{lang code=$time_frame} <span class="itemListTitleArrow"></span>
<div style="border-bottom:1px solid #ddd; width:150px; position:absolute;bottom:-2px; left:0px"></div>
<div class="itemListDD br3_bottom b89" style="display:none" id="timingDDList">
<ul>
{assign var=time_links value=func->time_links()}
{foreach from=$time_links item=name key=sort name=times}
<li><a href="{link name=time sort=$sort type=videos}">{$name}</a></li>
{/foreach}
</ul>
</div>
</div>
{cbCategories assign="category_list" type='v' with_all=TRUE echo=TRUE}
<div class="itemListTitle br3 b89" id="catDD" style="float:right">
{if $smarty.get.cat == 'all' || $smarty.get.cat == ''}
All Categories
{else}
{$cbvid->get_category_field($smarty.get.cat,'category_name')}
{/if}
<span class="itemListTitleArrow"></span>
<div style="border-bottom:1px solid #ddd; width:150px; position:absolute;bottom:-2px; left:0px"></div>
<div class="itemListDD br3_bottom b89" style="display:none" id="catDDList">
{if $category_list}
<ul>
{$category_list}
</ul>
{/if}
</div>
</div>
<div style="clear:both"></div>
</div>
<script>
{literal}
$('#sortingDD')
.bind('mouseenter',function(){ $('#sortingDDList').show()});
$('#sortingDDList,#sortingDD').bind('mouseleave',function(){ $('#sortingDDList').hide() });
$('#timingDD')
.bind('mouseenter',function(){ $('#timingDDList').show()});
$('#timingDDList,#timingDD').bind('mouseleave',function(){ $('#timingDDList').hide() });
$('#catDD')
.bind('mouseenter',function(){ $('#catDDList').show()});
$('#catDDList,#catDD').bind('mouseleave',function(){ $('#catDDList').hide() });
{/literal}
</script>
<div class="break2"></div>
<div class="inner_wrap clearfix">
{section name=v_list loop=$videos}
{include file="$style_dir/blocks/video.html"
view_video="normal" video=$videos[v_list] number=$smarty.section.v_list.iteration}
{sectionelse}
{lang code='no_results_found'}
{/section}
<div class="clear"></div>
{include file="$style_dir/blocks/pagination.html"}
</div> <!--inner_wrap end-->
</div>
<!-- Listing Categories -->
{include file="$style_dir/blocks/category_list.html" type='collections'}
<!-- Listing Categories End -->

View file

@ -10,7 +10,7 @@
{ANCHOR place='mature_content'}
{ANCHOR place='above_menu'}
{ANCHOR place='premium_button'}