sparqapi/api/application/controllers/Welcome.php
2021-02-11 00:41:03 +05:30

139 lines
3.7 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* 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 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');
if($data)
{
// $uri = custom_encryption::encode($data);die();
$uri = custom_encryption::decode($data);
// echo $uri;
$uri = explode('/',$uri);
// 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)
{
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
{
$this->redirect_url = 'https://demo.pdgenie.com/error/exp.html';
}
}
// echo $this->redirect_url;die();
header("Location: $this->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';
}
}