sparqapi/api/application/helpers/url_shortener_helper.php

76 lines
1.8 KiB
PHP

<?php
class url_shortener
{
protected $CI = '';
function __construct()
{
//$CI =&get_instance();
}
public static function url_shorten($pdid,$random_string,$type = '')
{
//echo 'this is from daiu';
$CI =&get_instance();
$CI->load->model('PD_Model');
$date_of_creation = date('Ymd');
$uri = array();
if($type)
{
$uri[ $type ] = $type.'/'.$date_of_creation.'/'.$pdid.'/'.$random_string;
}
else
{
// echo 'else';
$query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pdid and isactive = 1";
$video_info = $CI->db->query($query);
if($video_info && ($video_info->num_rows()))
{
foreach ($video_info->result_array() as $key => $value)
{
$video_name = $value['composition_id'];
$uri['vdo'][$key] = ['url' => custom_encryption::encode( 'vdo/'.$date_of_creation.'/'.$pdid.'/'.$video_name),'video_name' => $video_name];
}
}
$uri[ 'ppdf' ] = custom_encryption::encode ( 'ppdf/'.$date_of_creation.'/'.$pdid.'/'.$random_string);
$uri[ 'zip' ] = custom_encryption::encode ( 'zip/'.$date_of_creation.'/'.$pdid.'/'.$random_string );
}
// print_r($uri);die();
return $uri;
}
public static function SMC_report_url_shorten($pdid,$random_string,$type = '')
{
//echo 'this is from daiu';
$CI =&get_instance();
$CI->load->model('PD_Model');
$date_of_creation = date('Ymd');
$uri = array();
if($type)
{
$uri[ $type ] = $type.'/'.$date_of_creation.'/'.$pdid.'/'.$random_string;
}
else
{
$uri[ 'ppdf' ] = custom_encryption::encode ( 'ppdf/'.$date_of_creation.'/'.$pdid.'/'.$random_string);
$uri[ 'zip' ] = custom_encryption::encode ( 'zip/'.$date_of_creation.'/'.$pdid.'/'.$random_string );
}
// print_r($uri);die();
return $uri;
}
}
?>