我正在使用一个视频脚本,我想随机化 url thumbs:有一个 common.php 定义了 thumbs dir 和 url 的全局变量:
define('THUMB_FILES_DIR',' ');
define('THUMB_FILES_URL','');
define('THUMBS_DIR',THUMB_FILES_DIR.'/thumbs');
define('THUMBS_URL',THUMB_FILES_URL.'/thumbs');
获得拇指的功能是:
/**
* FUNCTION USED TO GET THUMBNAIL
* @param ARRAY video_details, or videoid will also work
*/
function get_thumb($vdetails,$num='default',$multi=false,$count=false,$return_full_path=true,$return_big=true,$size=false){
global $db,$Cbucket,$myquery;
$num = $num ? $num : 'default';
#checking what kind of input we have
if(is_array($vdetails))
{
if(empty($vdetails['title']))
{
#check for videoid
if(empty($vdetails['videoid']) && empty($vdetails['vid']) && empty($vdetails['videokey']))
{
if($multi)
return $dthumb[0] = default_thumb();
return default_thumb();
}else{
if(!empty($vdetails['videoid']))
$vid = $vdetails['videoid'];
elseif(!empty($vdetails['vid']))
$vid = $vdetails['vid'];
elseif(!empty($vdetails['videokey']))
$vid = $vdetails['videokey'];
else
{
if($multi)
return $dthumb[0] = default_thumb();
return default_thumb();
}
}
}
}else{
if(is_numeric($vdetails))
$vid = $vdetails;
else
{
if($multi)
return $dthumb[0] = default_thumb();
return default_thumb();
}
}
#checking if we have vid , so fetch the details
if(!empty($vid))
$vdetails = $myquery->get_video_details($vid);
if(empty($vdetails['title']))
{
if($multi)
return default_thumb();
return default_thumb();
}
#Checking if there is any custom function for
if(count($Cbucket->custom_get_thumb_funcs) > 0)
{
foreach($Cbucket->custom_get_thumb_funcs as $funcs)
{
//Merging inputs
$in_array = array(
'num' => $num,
'multi' => $multi,
'count' => $count,
'return_full_path' => $return_full_path,
'return_big' => $return_big
);
if(function_exists($funcs))
{
$func_returned = $funcs($vdetails,$in_array);
if($func_returned)
return $func_returned;
}
}
}
#get all possible thumbs of video
if($vdetails['file_name'])
$vid_thumbs = glob(THUMBS_DIR."/".$vdetails['file_name']."*");
#replace Dir with URL
if(is_array($vid_thumbs))
foreach($vid_thumbs as $thumb)
{
if(file_exists($thumb) && filesize($thumb)>0)
{
$thumb_parts = explode('/',$thumb);
$thumb_file = $thumb_parts[count($thumb_parts)-1];
if(!is_big($thumb_file) || $return_big)
{
if($return_full_path)
$thumbs[] = THUMBS_URL.'/'.$thumb_file;
else
$thumbs[] = $thumb_file;
}
}elseif(file_exists($thumb))
unlink($thumb);
}
if(count($thumbs)==0)
{
if($count)
return count($thumbs);
if($multi)
return $dthumb[0] = default_thumb();
return default_thumb();
}
else
{
if($multi)
return $thumbs;
if($count)
return count($thumbs);
//Now checking for thumb
if($num=='default')
{
$num = $vdetails['default_thumb'];
}
if($num=='big' || $size=='big')
{
$num = 'big-'.$vdetails['default_thumb'];
if(!file_exists(THUMBS_DIR.'/'.$vdetails['file_name'].'-'.$num.'.jpg'))
$num = 'big';
}
$default_thumb = array_find($vdetails['file_name'].'-'.$num,$thumbs);
if(!empty($default_thumb))
return $default_thumb;
return $thumbs[0];
}
}
/**
* Function used to check weaether given thumb is big or not
*/
function is_big($thumb_file)
{
if(strstr($thumb_file,'big'))
return true;
else
return false;
}
function GetThumb($vdetails,$num='default',$multi=false,$count=false)
{
return get_thumb($vdetails,$num,$multi,$count);
}
/**
* function used to get detaulf thumb of ClipBucket
*/
function default_thumb()
{
if(file_exists(TEMPLATEDIR.'/images/thumbs/processing.png'))
{
return TEMPLATEURL.'/images/thumbs/processing.png';
}elseif(file_exists(TEMPLATEDIR.'/images/thumbs/processing.jpg'))
{
return TEMPLATEURL.'/images/thumbs/processing.jpg';
}else
return BASEURL.'/files/thumbs/processing.jpg';
}
我想以这种方式随机化从中提供图像的拇指 url
http://img[random number].domainname
如果我使用拇指 url 的值创建一个数组,然后将结果随机播放到
define('THUMB_FILES_DIR',' ');
define('THUMB_FILES_URL','');
所有拇指都将具有相同的 url 值如何将不同的值传递给 html 页面?