REPORT URL SHORTNER
This commit is contained in:
parent
23ba0372f0
commit
479e3942e0
@ -115,6 +115,7 @@ defined('OFFICER_TRACKING_URL') OR define('OFFICER_TRACKING_URL','https://demo.p
|
||||
defined('CUSTOMER_IMG_URL') OR define('CUSTOMER_IMG_URL','https://demo.pdgenie.com/customer/#/pd-images/');
|
||||
defined('SALESPD_CUSTOMER_IMG_URL') OR define('SALESPD_CUSTOMER_IMG_URL','https://demo.pdgenie.com/customer/#/salespd_images/');
|
||||
defined('CUSTOMER_IMG_URL') OR define('CUSTOMER_IMG_URL','https://demo.pdgenie.com/customer/#/pd-images/');
|
||||
defined('PDF_ATTACHEMENT_URL') OR define('PDF_ATTACHEMENT_URL','https://apitest.pdgenie.com/sparqdev/api/short?dat=');
|
||||
}
|
||||
else if(ENVIRONMENT == 'testing')
|
||||
{
|
||||
@ -128,6 +129,7 @@ else if(ENVIRONMENT == 'testing')
|
||||
defined('OFFICER_TRACKING_URL') OR define('OFFICER_TRACKING_URL','https://demo.pdgenie.com/otnew/#/');
|
||||
defined('SALESPD_CUSTOMER_IMG_URL') OR define('SALESPD_CUSTOMER_IMG_URL','https://demo.pdgenie.com/customer/#/salespd_images/');
|
||||
defined('CUSTOMER_IMG_URL') OR define('CUSTOMER_IMG_URL','https://demo.pdgenie.com/customer/#/pd-images/');
|
||||
defined('PDF_ATTACHEMENT_URL') OR define('PDF_ATTACHEMENT_URL','https://apitest.pdgenie.com/sparqtest/api/short?dat=');
|
||||
}
|
||||
else if(ENVIRONMENT == 'production')
|
||||
{
|
||||
@ -141,6 +143,7 @@ else if(ENVIRONMENT == 'production')
|
||||
defined('OFFICER_TRACKING_URL') OR define('OFFICER_TRACKING_URL','https://pdgenie.com/track/#/');
|
||||
defined('SALESPD_CUSTOMER_IMG_URL') OR define('SALESPD_CUSTOMER_IMG_URL','https://pdgenie.com/customer/#/salespd_images/');
|
||||
defined('CUSTOMER_IMG_URL') OR define('CUSTOMER_IMG_URL','https://pdgenie.com/customer/#/pd-images/');
|
||||
defined('PDF_ATTACHEMENT_URL') OR define('PDF_ATTACHEMENT_URL','https://api.pdgenie.com/sparqprod/api/short?dat=');
|
||||
}
|
||||
|
||||
/*********************END of AWS resources Constants*************************************************/
|
||||
|
||||
@ -50,7 +50,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
| my-controller/my-method -> my_controller/my_method
|
||||
*/
|
||||
$route['default_controller'] = 'welcome';
|
||||
$route['vdo'] = 'welcome/short';
|
||||
$route['short'] = 'welcome/receiveShortenURL';
|
||||
$route['autenticadors'] = 'autenticador/index';
|
||||
$route['404_override'] = '';
|
||||
$route['translate_uri_dashes'] = FALSE;
|
||||
|
||||
@ -4866,7 +4866,7 @@ public function getPDFormDetailsJSON_post()
|
||||
|
||||
//Get attachment links and embed here...
|
||||
//get img pdf
|
||||
$report_attachments = (new report_attachments)->getReportAttchments($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string']);
|
||||
$report_attachments = (new report_attachments)->getReportAttchments($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string'],$pd_master_details);
|
||||
$temp = substr_replace($temp,$report_attachments,strpos($temp,'</body>'),0);
|
||||
//End Get attachment links
|
||||
|
||||
|
||||
@ -18,17 +18,35 @@ class Welcome extends CI_Controller {
|
||||
* map to /index.php/welcome/<method_name>
|
||||
* @see https://codeigniter.com/user_guide/general/urls.html
|
||||
*/
|
||||
|
||||
|
||||
protected $redirect_url = 'https://demo.pdgenie.com/error/404.html';
|
||||
|
||||
|
||||
function __construct()
|
||||
{
|
||||
// Construct the parent class
|
||||
parent::__construct();
|
||||
$this->external_path = $this->config->item('external_data_path');
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('welcome_message');
|
||||
}
|
||||
|
||||
public function short()
|
||||
public function checktest()
|
||||
{
|
||||
$this->load->helper('url_shortener');
|
||||
// echo $_SERVER['REQUEST_URI'];die();
|
||||
print('<pre>'.print_r(url_shortener::url_shorten(2148,'nmi9iJ2tDKrc7GRo')).'</pre>');
|
||||
}
|
||||
|
||||
|
||||
public function receiveShortenURL()
|
||||
{
|
||||
$data = $this->input->get('dat');
|
||||
//echo $data;
|
||||
|
||||
$redirect_url = 'https://demo.pdgenie.com/error/404.html';
|
||||
if($data)
|
||||
{
|
||||
|
||||
@ -36,36 +54,85 @@ class Welcome extends CI_Controller {
|
||||
$uri = custom_encryption::decode($data);
|
||||
// echo $uri;
|
||||
$uri = explode('/',$uri);
|
||||
$video_name = $uri[0];
|
||||
$date = $uri[1];
|
||||
$is_expired = MYUTIL::isDateExpired($date,7);
|
||||
if(!$is_expired)
|
||||
// print_r($uri);die();
|
||||
$pd_id = $uri[2];
|
||||
$random_string = $uri[3];//in case type is video then randon string will be video name(composition id)
|
||||
$type = $uri[0];
|
||||
$date_created = $uri[1];
|
||||
$is_expired = MYUTIL::isDateExpired($date_created,15);
|
||||
if(!$is_expired)
|
||||
{
|
||||
|
||||
$this->load->model('PD_Model');
|
||||
$this->load->library('AWS_S3');
|
||||
$room_info = $this->PD_Model->selectCustomRecords(array('*'),array('composition_id' => $video_name),VIDEO_ROOM_INFO);
|
||||
//print_r($room_info);die();
|
||||
if(count($room_info))
|
||||
{
|
||||
$pd_master_details = $this->PD_Model->getPDMasterDetails($room_info[0]['fk_pd_id']);
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id'];
|
||||
$final_key = 'pd'.$pd_master_details[0]['pd_id'].'/video/'.$video_name.'.mp4';
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$final_key,'+2 hour');
|
||||
$redirect_url = $singed_uri;
|
||||
}
|
||||
if($type == 'vdo')
|
||||
{
|
||||
$this->redirect_url = $this->vdo($pd_id,$random_string);
|
||||
}
|
||||
else if($type == 'ppdf')
|
||||
{
|
||||
$this->redirect_url = $this->ppdf($pd_id,$random_string);
|
||||
}else if($type == 'zip')
|
||||
{
|
||||
$this->redirect_url = $this->zip($pd_id,$random_string);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$redirect_url = 'https://demo.pdgenie.com/error/exp.html';
|
||||
$this->redirect_url = 'https://demo.pdgenie.com/error/exp.html';
|
||||
}
|
||||
}
|
||||
|
||||
// echo $this->redirect_url;die();
|
||||
header("Location: $this->redirect_url");
|
||||
|
||||
}
|
||||
|
||||
|
||||
//echo $redirect_url;
|
||||
header("Location: $redirect_url");
|
||||
}
|
||||
public function vdo($pdid,$video_name)
|
||||
{
|
||||
$this->load->model('PD_Model');
|
||||
$this->load->library('AWS_S3');
|
||||
$room_info = $this->PD_Model->selectCustomRecords(array('*'),array('composition_id' => $video_name),VIDEO_ROOM_INFO);
|
||||
// print_r($room_info);die();
|
||||
if(count($room_info))
|
||||
{
|
||||
// echo 'vdo working';
|
||||
$pd_master_details = $this->PD_Model->getPDMasterDetails($room_info[0]['fk_pd_id']);
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id'];
|
||||
|
||||
if(!$room_info[0]['is_uploaded']){ $video_name = $video_name.'.mp4'; }
|
||||
|
||||
$final_key = 'pd'.$pd_master_details[0]['pd_id'].'/video/'.$video_name;
|
||||
// echo $final_key;die();
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$final_key,'+2 hour');
|
||||
return
|
||||
//echo
|
||||
$singed_uri;//die();
|
||||
// $viewdata['uri'] = $singed_uri;
|
||||
// $this->load->view('vdoplayer.php',$viewdata);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function ppdf($pd_id,$random_string)
|
||||
{
|
||||
$this->load->helper('photo_pdf_converter');
|
||||
return $res_data = (new photo_pdf_converter)->covertImgs2PDF($pd_id,$random_string,array());
|
||||
}
|
||||
|
||||
function zip($pd_id,$random_string)
|
||||
{
|
||||
$this->load->helper('photo_zip_creator');
|
||||
return $res_data = (new photo_zip_creator)->covertImgs2ZIP($pd_id,$random_string,array());
|
||||
}
|
||||
|
||||
public function checkAfterResponse()
|
||||
{
|
||||
// $data['dataStatus'] = false;
|
||||
// $data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
||||
// $data['msg'] = 'No Data File Found!';
|
||||
// $this->response($data,REST_Controller::HTTP_OK,true);
|
||||
echo 'Hi';
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ class photo_pdf_converter
|
||||
//echo 'this is from daiu';
|
||||
$CI =&get_instance();
|
||||
$CI->load->model('PD_Model');
|
||||
$CI->load->library('pdfgenerator');
|
||||
|
||||
if(!count($pd_master_details))
|
||||
{
|
||||
|
||||
@ -10,34 +10,36 @@ class report_attachments
|
||||
|
||||
public function getReportAttchments($pdid,$random_string,$pd_master_details = array())
|
||||
{
|
||||
//echo 'this is from daiu';
|
||||
// print_r($pd_master_details);die();
|
||||
$CI =&get_instance();
|
||||
$CI->load->model('PD_Model');
|
||||
$CI->load->helper('photo_pdf_converter');
|
||||
$CI->load->helper('photo_zip_creator');
|
||||
$CI->load->helper('video_grabber_helper');
|
||||
// $CI->load->helper('photo_pdf_converter');
|
||||
// $CI->load->helper('photo_zip_creator');
|
||||
// $CI->load->helper('video_grabber_helper');
|
||||
|
||||
if(!count($pd_master_details))
|
||||
{
|
||||
$pd_master_details = $CI->PD_Model->getPDMasterDetails($pdid,$random_string);
|
||||
}
|
||||
$img_pdf_aws_uri = (new photo_pdf_converter)->covertImgs2PDF($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string'],$pd_master_details);
|
||||
$CI->load->helper('url_shortener');
|
||||
$uri = url_shortener::url_shorten($pdid,$random_string);
|
||||
// if(!count($pd_master_details))
|
||||
// {
|
||||
// $pd_master_details = $CI->PD_Model->getPDMasterDetails($pdid,$random_string);
|
||||
// }
|
||||
// $img_pdf_aws_uri = (new photo_pdf_converter)->covertImgs2PDF($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string'],$pd_master_details);
|
||||
|
||||
$img_zip_aws_uri = (new photo_zip_creator)->covertImgs2ZIP($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string'],$pd_master_details);
|
||||
// $img_zip_aws_uri = (new photo_zip_creator)->covertImgs2ZIP($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string'],$pd_master_details);
|
||||
|
||||
$video_uri = (new video_grabber_helper)->grabAllVideo($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string'],$pd_master_details);
|
||||
// $video_uri = (new video_grabber_helper)->grabAllVideo($pd_master_details[0]['pd_id'],$pd_master_details[0]['random_string'],$pd_master_details);
|
||||
// print_r($video_uri) ;die();
|
||||
$attachment = '<div id="page_break"></div><h2>Data Links</h2><p><a target="_blank" href="'.$img_pdf_aws_uri.'">Click here for Image PDF Link</a></p> <p> <a target="_blank" href="'.$img_zip_aws_uri.'">Click here for Image ZIP Link</a> </p>';
|
||||
if($pd_master_details[0]['fk_pd_type'] == 2 && count($video_uri))// if smart pd
|
||||
$attachment = '<div id="page_break"></div><h2>Data Links</h2><p><a target="_blank" href="'.PDF_ATTACHEMENT_URL.$uri['ppdf'].'">Click here for Image PDF Link</a></p> <p> <a target="_blank" href="'.PDF_ATTACHEMENT_URL.$uri['zip'].'">Click here for Image ZIP Link</a> </p>';
|
||||
if($pd_master_details[0]['fk_pd_type'] == 2 && count($uri['vdo']))// if smart pd
|
||||
{
|
||||
$attachment .='<h2>videos</h2>';
|
||||
foreach ($video_uri as $key => $value)
|
||||
foreach ($uri['vdo'] as $key => $value)
|
||||
{
|
||||
$attachment .= '<p><a target="_blank" href="'.$value['url'].'">'.$value['video_name'].'</a></p>';
|
||||
$attachment .= '<p><a target="_blank" href="'.PDF_ATTACHEMENT_URL.$value['url'].'">'.$value['video_name'].'</a></p>';
|
||||
}
|
||||
|
||||
}
|
||||
$attachment.= '<br><br><br><p style="font-size:10px;text-align:center;">(Note all links will expire in 7 days from the date of report generation.)</p>';
|
||||
$attachment.= '<br><br><br><p style="font-size:10px;text-align:center;">(Note all links will expire in 15 days from the date of report generation.)</p>';
|
||||
return $attachment;
|
||||
|
||||
}
|
||||
|
||||
51
api/application/helpers/url_shortener_helper.php
Normal file
51
api/application/helpers/url_shortener_helper.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?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;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user