192 lines
4.1 KiB
PHP
192 lines
4.1 KiB
PHP
<?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);
|
|
}
|
|
|
|
|
|
/**
|
|
* Function used to check weather email already exists or not
|
|
* @input email
|
|
*/
|
|
function email_exists($user)
|
|
{
|
|
global $userquery;
|
|
return $userquery->duplicate_email($user);
|
|
}
|
|
|
|
/**
|
|
* Function used to count age from date
|
|
*/
|
|
function get_age($input)
|
|
{
|
|
$time = strtotime($input);
|
|
$iMonth = date("m",$time);
|
|
$iDay = date("d",$time);
|
|
$iYear = date("Y",$time);
|
|
|
|
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
|
|
$iDays = $iTimeStamp / 86400;
|
|
$iYears = floor($iDays / 365 );
|
|
return $iYears;
|
|
}
|
|
|
|
|
|
|
|
function update_user_voted($array,$userid=NULL)
|
|
{
|
|
global $userquery;
|
|
return $userquery->update_user_voted($array,$userid);
|
|
}
|
|
|
|
|
|
/**
|
|
* Function used to check username is disallowed or not
|
|
* @param USERNAME
|
|
*/
|
|
function check_disallowed_user($username)
|
|
{
|
|
global $Cbucket;
|
|
$disallowed_user = $Cbucket->configs['disallowed_usernames'];
|
|
$censor_users = explode(',',$disallowed_user);
|
|
if(in_array($username,$censor_users))
|
|
return false;
|
|
else
|
|
return true;
|
|
}
|
|
|
|
?>
|