Merge branch 'main' of bitbucket.org:venbainformationtechnology/bb_sign
This commit is contained in:
commit
4d29b494cf
@ -12,7 +12,7 @@ use CodeIgniter\Filters\InvalidChars;
|
||||
use CodeIgniter\Filters\PageCache;
|
||||
use CodeIgniter\Filters\PerformanceMetrics;
|
||||
use CodeIgniter\Filters\SecureHeaders;
|
||||
|
||||
use App\Filters\SignedUrlFilter;
|
||||
class Filters extends BaseFilters
|
||||
{
|
||||
/**
|
||||
@ -34,6 +34,7 @@ class Filters extends BaseFilters
|
||||
'forcehttps' => ForceHTTPS::class,
|
||||
'pagecache' => PageCache::class,
|
||||
'performance' => PerformanceMetrics::class,
|
||||
'signedUrl' => SignedUrlFilter::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@ -38,7 +38,7 @@ class Logger extends BaseConfig
|
||||
*
|
||||
* @var int|list<int>
|
||||
*/
|
||||
public $threshold = (ENVIRONMENT === 'production') ? 4 : 9;
|
||||
public $threshold = 4;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
|
||||
@ -100,4 +100,7 @@ use CodeIgniter\Router\RouteCollection;
|
||||
$routes->post('status_branch','BranchController::status_branch');
|
||||
|
||||
|
||||
|
||||
$routes->get('sendSms','TestController::sendSms');
|
||||
$routes->get('preview', 'TestController::protectedPage', ['filter' => 'signedUrl']);
|
||||
$routes->get('sendUrl', 'TestController::sendUrl');
|
||||
$routes->get('protectedPage', 'TestController::protectedPage');
|
||||
172
app/Controllers/TestController.php
Normal file
172
app/Controllers/TestController.php
Normal file
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
use App\Helpers\MailHelper;
|
||||
use App\Models\ServiceModel;
|
||||
use App\Models\TemplateModel;
|
||||
use App\Models\StaffModel;
|
||||
use App\Models\ClientDocsModel;
|
||||
use App\Models\ClientModel;
|
||||
use App\Models\BusinessModel;
|
||||
use App\Models\BranchModel;
|
||||
use App\Models\ServiceGroupModel;
|
||||
use App\Models\ClientBranchModel;
|
||||
use App\Models\DocsStatusModel;
|
||||
use CodeIgniter\Controller;
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
|
||||
protected $ServiceModel;
|
||||
protected $TemplateModel;
|
||||
protected $StaffModel;
|
||||
protected $ClientDocsModel;
|
||||
protected $ClientModel;
|
||||
protected $BusinessModel;
|
||||
protected $BranchModel;
|
||||
protected $ServiceGroupModel;
|
||||
protected $ClientBranchModel;
|
||||
protected $DocsStatusModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->ServiceModel = new ServiceModel();
|
||||
$this->TemplateModel = new TemplateModel();
|
||||
$this->StaffModel = new StaffModel();
|
||||
$this->ClientDocsModel = new ClientDocsModel();
|
||||
$this->ClientModel = new ClientModel();
|
||||
$this->BusinessModel = new BusinessModel();
|
||||
$this->BranchModel = new BranchModel();
|
||||
$this->ServiceGroupModel = new ServiceGroupModel();
|
||||
$this->ClientBranchModel = new ClientBranchModel();
|
||||
$this->DocsStatusModel = new DocsStatusModel();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function sendSms()
|
||||
{
|
||||
$apiKey = 'HgvlULWCIrs'; // Your API key
|
||||
$mobileNumbers = '919894638731'; // Recipient mobile numbers
|
||||
$DLTTemplateID = '1105171896608602869'; // DLT Template ID
|
||||
$senderId = 'LDRAJ'; // Sender ID
|
||||
$message = 'Dear Gowtham, 986532 is OTP to approve Service group for service name purposes.';
|
||||
$serviceName = 'TEMPLATE_BASED'; // Service name
|
||||
|
||||
// URL encode the message
|
||||
$encodedMessage = urlencode($message);
|
||||
|
||||
// Initialize cURL
|
||||
$ch = curl_init();
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_URL, "https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=$apiKey&MobileNo=$mobileNumbers&SenderID=$senderId&Message=$encodedMessage&ServiceName=$serviceName&DLTTemplateID=$DLTTemplateID");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
|
||||
// Execute cURL request and get the response
|
||||
$output = curl_exec($ch);
|
||||
|
||||
// Close cURL session
|
||||
curl_close($ch);
|
||||
|
||||
// Output the response (for testing purposes)
|
||||
return $this->response->setJSON(['response' => $output]);
|
||||
}
|
||||
|
||||
public function sendUrl()
|
||||
{
|
||||
helper('url');
|
||||
$signedUrl = generate_signed_url('preview', ['doc_id'=>md5(7)], 60);
|
||||
// Send the $signedUrl to your client (e.g., via email)
|
||||
|
||||
return $this->response->setJSON(['url' => $signedUrl]);
|
||||
}
|
||||
|
||||
public function protectedPage(){
|
||||
$doc_id = $this->request->getVar('doc_id');
|
||||
$data['docData'] = $this->ClientDocsModel->docPreview($doc_id);
|
||||
|
||||
$data['clientData'] = $this->ClientBranchModel->select('client.name , client.pan_no ,client_branch.gst_no , client_branch.mobile_no , client_branch.email , client_branch.address , client_branch.country , client_branch.state , client_branch.city , client_branch.pin_code ')
|
||||
->join('client', 'client_branch.client_id = client.client_id', 'left')
|
||||
->where('client_branch.id',$data['docData']->client_branch_id)
|
||||
->get()->getRow();
|
||||
|
||||
|
||||
|
||||
|
||||
$data['header_html'] = $data['docData']->header_html;
|
||||
$data['footer_html'] = $data['docData']->footer_html;
|
||||
$data['body_html'] = $data['docData']->body_html;
|
||||
//replace client details in template content
|
||||
foreach ($data['clientData'] as $key => $value) {
|
||||
$placeHolder = '%'.$key.'%';
|
||||
$data['body_html'] = str_replace($placeHolder,$value,$data['body_html']);
|
||||
}
|
||||
|
||||
if($data['docData']->is_active == 1){
|
||||
$DateAndYears = $data['docData']->place_holder_object;
|
||||
}else{
|
||||
$DateAndYears = $this->dateAndYearPlaceholder();
|
||||
}
|
||||
//replace Date and Year values in template content
|
||||
foreach (json_decode($DateAndYears,true) as $key => $value) {
|
||||
$placeHolder = '%'.$key.'%';
|
||||
$data['body_html'] = str_replace($placeHolder,$value,$data['body_html']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
echo view('layout/doc_header');
|
||||
echo view('client_docs_preview',$data);
|
||||
echo view('layout/footer');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function dateAndYearPlaceholder()
|
||||
{
|
||||
$currentDate = date('d-m-Y');
|
||||
$currentYear = date('Y');
|
||||
$currentMonth = date('m');
|
||||
|
||||
|
||||
if ($currentMonth >= 4) {
|
||||
$financialYearStart = $currentYear . '-04-01';
|
||||
$financialYearEnd = ($currentYear + 1) . '-03-31';
|
||||
$financialYear = $currentYear . '-' . ($currentYear + 1);
|
||||
$assessmentYear = ($currentYear + 1) . '-' . ($currentYear + 2);
|
||||
$q1 = '01-04-' . $currentYear . ' to ' . '30-06-' . $currentYear;
|
||||
$q2 = '01-07-' . $currentYear . ' to ' . '30-09-' . $currentYear;
|
||||
$q3 = '01-10-' . $currentYear . ' to ' . '31-12-' . $currentYear;
|
||||
$q4 = '01-01-' . ($currentYear + 1) . ' to ' . '31-03-' . ($currentYear + 1);
|
||||
|
||||
} else {
|
||||
$financialYearStart = ($currentYear - 1) . '-04-01';
|
||||
$financialYearEnd = $currentYear . '-03-31';
|
||||
$financialYear = ($currentYear - 1) . '-' . $currentYear;
|
||||
$assessmentYear = $currentYear . '-' . ($currentYear + 1);
|
||||
$q1 = '01-04-' . ($currentYear - 1) . ' to ' . '30-06-' . ($currentYear - 1);
|
||||
$q2 = '01-07-' . ($currentYear - 1) . ' to ' . '30-09-' . ($currentYear - 1);
|
||||
$q3 = '01-10-' . ($currentYear - 1) . ' to ' . '31-12-' . ($currentYear - 1);
|
||||
$q4 = '01-01-' . $currentYear . ' to ' . '31-03-' . $currentYear;
|
||||
}
|
||||
|
||||
$DateAndYears = [
|
||||
"CD" => $currentDate,
|
||||
"CY" => $currentYear,
|
||||
"FY" => $financialYear,
|
||||
"AY" => $assessmentYear,
|
||||
"Q1" => $q1,
|
||||
"Q2" => $q2,
|
||||
"Q3" => $q3,
|
||||
"Q4" => $q4,
|
||||
];
|
||||
|
||||
return json_encode($DateAndYears);
|
||||
|
||||
}
|
||||
}
|
||||
44
app/Filters/SignedUrlFilter.php
Normal file
44
app/Filters/SignedUrlFilter.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\Filters\FilterInterface;
|
||||
use Config\Services;
|
||||
class SignedUrlFilter implements FilterInterface
|
||||
{
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
$secretKey = 'your-secret-key'; // Change this to your secret key
|
||||
$expires = $request->getGet('expires');
|
||||
$signature = $request->getGet('signature');
|
||||
|
||||
if (!$expires || !$signature) {
|
||||
return Services::response()->setStatusCode(403)->setBody('Forbidden');
|
||||
}
|
||||
|
||||
if (time() > $expires) {
|
||||
$body = view('expired_link');
|
||||
return Services::response()->setStatusCode(403)->setBody($body);
|
||||
}
|
||||
|
||||
$queryParams = $request->getGet();
|
||||
unset($queryParams['signature']);
|
||||
$route = $request->getPath();
|
||||
$expectedSignature = hash_hmac('sha256', $route . '?' . http_build_query($queryParams), $secretKey);
|
||||
|
||||
if (!hash_equals($expectedSignature, $signature)) {
|
||||
return Services::response()->setStatusCode(403)->setBody('Invalid signature');
|
||||
}
|
||||
|
||||
return true; // Allow the request
|
||||
}
|
||||
|
||||
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
|
||||
{
|
||||
// Do nothing here
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
15
app/Helpers/url_helper.php
Normal file
15
app/Helpers/url_helper.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use Config\Services;
|
||||
|
||||
if (!function_exists('generate_signed_url')) {
|
||||
function generate_signed_url($route, $params = [], $expiresIn = 3600)
|
||||
{
|
||||
$secretKey = 'your-secret-key'; // Change this to your secret key
|
||||
$expiresAt = time() + $expiresIn;
|
||||
$params['expires'] = $expiresAt;
|
||||
$signature = hash_hmac('sha256', $route . '?' . http_build_query($params), $secretKey);
|
||||
$params['signature'] = $signature;
|
||||
return base_url($route . '?' . http_build_query($params));
|
||||
}
|
||||
}
|
||||
35
app/Views/expired_link.php
Normal file
35
app/Views/expired_link.php
Normal file
@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Link Expired</title>
|
||||
<style>
|
||||
body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
.container {
|
||||
text-align: center;
|
||||
}
|
||||
img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
.text{
|
||||
font-size: large;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<img src="<?= base_url('public/assets/images/404.gif') ?>" alt="Link Expired">
|
||||
<p class="text">Link expired</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
176
app/Views/layout/doc_header.php
Normal file
176
app/Views/layout/doc_header.php
Normal file
@ -0,0 +1,176 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Approve Dox</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
|
||||
<meta content="Coderthemes" name="author" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<!-- App favicon -->
|
||||
<link rel="shortcut icon" href="<?= base_url()."public"; ?>/assets/images/favicon.ico">
|
||||
|
||||
<!-- App css -->
|
||||
<link href="<?= base_url()."public"; ?>/assets/css/bootstrap-creative.min.css" rel="stylesheet" type="text/css" id="bs-default-stylesheet" />
|
||||
<link href="<?= base_url()."public"; ?>/assets/css/app-creative.min.css" rel="stylesheet" type="text/css" id="app-default-stylesheet" />
|
||||
|
||||
<link href="<?= base_url()."public"; ?>/assets/css/bootstrap-creative-dark.min.css" rel="stylesheet" type="text/css" id="bs-dark-stylesheet" />
|
||||
<link href="<?= base_url()."public"; ?>/assets/css/app-creative-dark.min.css" rel="stylesheet" type="text/css" id="app-dark-stylesheet" />
|
||||
|
||||
<!-- icons -->
|
||||
<link href="<?= base_url()."public"; ?>/assets/css/icons.min.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
<!-- third party css -->
|
||||
<link href="<?= base_url()."public"; ?>/assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<?= base_url()."public"; ?>/assets/libs/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<?= base_url()."public"; ?>/assets/libs/datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<?= base_url()."public"; ?>/assets/libs/datatables.net-select-bs4/css//select.bootstrap4.min.css" rel="stylesheet" type="text/css" />
|
||||
<!-- third party css end -->
|
||||
|
||||
<!-- Plugins css -->
|
||||
<link href="<?= base_url()."public"; ?>/assets/libs/select2/css/select2.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.1.0/css/select2.min.css" rel="stylesheet" />
|
||||
|
||||
<!-- toster alert -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/toastr@2.1.4/toastr.min.js"></script>
|
||||
<link href="https://cdn.jsdelivr.net/npm/toastr@2.1.4/build/toastr.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Summernote css -->
|
||||
<link href="<?= base_url()."public"; ?>/assets/libs/summernote/summernote-bs4.min.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<link href="<?= base_url() . "public"; ?>/assets/libs/admin-resources/jquery.vectormap/jquery-jvectormap-1.2.2.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
|
||||
<style>
|
||||
.select2-container .select2-selection--multiple .select2-selection__choice {
|
||||
padding: 5px 7px 5px 0 !important;
|
||||
color: #000000;
|
||||
}
|
||||
#business_list_header option{
|
||||
background-color: white;
|
||||
color:black;
|
||||
}
|
||||
.btn-secondary {
|
||||
background-color: #f4f9fb;
|
||||
border-color: #f4f9fb;
|
||||
color:black;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
color: #343a40;
|
||||
background-color: #d8eaf1;
|
||||
border-color: #cfe5ed;
|
||||
}
|
||||
.loader-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #00000069;
|
||||
z-index: 99999;
|
||||
}
|
||||
.dataTables_wrapper button{
|
||||
background: #f1f5f7;
|
||||
color: #343a40;
|
||||
border-width: 0;
|
||||
}
|
||||
.dataTables_wrapper .dt-buttons{
|
||||
float:left;
|
||||
}
|
||||
.loader {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
font-size: 0;
|
||||
color: #00c9d0;
|
||||
display: inline-block;
|
||||
margin: -25px 0 0 -25px;
|
||||
text-indent: -9999em;
|
||||
-webkit-transform: translateZ(0);
|
||||
-ms-transform: translateZ(0);
|
||||
transform: translateZ(0);
|
||||
}
|
||||
|
||||
.lead {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.loader div {
|
||||
background-color: #6ad9cf;
|
||||
display: inline-block;
|
||||
float: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
opacity: .5;
|
||||
border-radius: 50%;
|
||||
-webkit-animation: ballPulseDouble 2s ease-in-out infinite;
|
||||
animation: ballPulseDouble 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.loader div:last-child {
|
||||
-webkit-animation-delay: -1s;
|
||||
animation-delay: -1s;
|
||||
}
|
||||
.dropdown-item:focus, .dropdown-item:hover{
|
||||
background-color: #7ce4dd;
|
||||
}
|
||||
@media (min-width: 992px) {
|
||||
.topnav { height: 56px; }
|
||||
.logo-lg img{ height:50px; }
|
||||
.navbar-custom{ height:60px; }
|
||||
.logo-box .logo{ line-height: 60px; }
|
||||
.navbar-custom .topnav-menu .nav-link{ line-height: 60px; height: 60px; color:#ffffff; }
|
||||
.topnav{ margin-top:55px; height:50px; }
|
||||
}
|
||||
@media (max-width: 991px){
|
||||
.logo-sm img{ height:50px; }
|
||||
}
|
||||
footer{
|
||||
padding:10px 15px 10px!important;
|
||||
}
|
||||
.page-title-box-alt {
|
||||
background-color: transparent;
|
||||
padding: 15px 27px;
|
||||
box-shadow: none;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.navbar-custom{
|
||||
background-color: #85a7c9;
|
||||
/* background-color: #d44d4dd1; */
|
||||
}
|
||||
|
||||
.select2-container .select2-selection--single{
|
||||
height: 36px;
|
||||
border:1px solid #ced4da;
|
||||
}
|
||||
.select2-container--default .select2-selection--single .select2-selection__rendered{
|
||||
line-height: 36px;
|
||||
}
|
||||
.select2-container--default .select2-selection--single .select2-selection__arrow{
|
||||
top:4px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body class="loading" data-layout-mode="horizontal" data-layout='{"mode": "light", "width": "fluid", "menuPosition": "fixed", "topbar": {"color": "dark"}, "showRightSidebarOnPageLoad": true}'>
|
||||
|
||||
<!-- Begin page -->
|
||||
<div id="wrapper">
|
||||
|
||||
<!-- Topbar Start -->
|
||||
|
||||
<!-- end Topbar -->
|
||||
|
||||
|
||||
BIN
public/assets/images/404.gif
Normal file
BIN
public/assets/images/404.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 MiB |
Loading…
Reference in New Issue
Block a user