This commit is contained in:
2022-02-28 19:31:37 -05:00
parent 862d129d00
commit 49e0c1191f
21 changed files with 554 additions and 62 deletions
+3
View File
@@ -169,6 +169,9 @@ define('WRENCHBOARD_LOG_MEMBER', 11040);
define('WRENCHBOARD_DELETE_RECACC', 11041);
define('WRENCHBOARD_SAVE_GALLERY', 11042);
define('WRENCHBOARD_USER_ADNEWCC', 11054);
define('WRENCHBOARD_USER_USESAVEDCC', 11056);
define('WRENCHBOARD_ACCOUNT_END', 11999);
//**************************************************************
define('WRENCHBOARD_JOB_CREATEJOB',13010 );
+1 -1
View File
@@ -52,4 +52,4 @@ defined('BASEPATH') OR exit('No direct script access allowed');
$route['default_controller'] = 'login';
$route['404_override'] = 'Wrb404';
$route['translate_uri_dashes'] = FALSE;
$route['auth/(.+)'] = 'home/auth/$1';
+160 -1
View File
@@ -2,12 +2,57 @@
defined('BASEPATH') OR exit('No direct script access allowed');
//Include Hybridauth autoloader
require APPPATH . '/third_party/hybridauth/autoload.php';
//Import Hybridauth's namespace
use Hybridauth\Hybridauth;
class Home extends WRB_Controller {
function __construct()
{
parent::__construct();
//Load URL helper
$this->load->helper('url');
//Load session library
$this->load->library('session');
}
//Displays social login links
public function index() {
//Instantiate Hybridauth's classes
$hybrid = new Hybridauth($this->getHybridConfig());
//Get enabled providers array
$providers = $hybrid->getProviders();
$login_links = "";
$provider_icons = array(
'Apple' => '/site3/assets/media/svg/brand-logos/apple-black.svg',
'Facebook' => '/site3/assets/media/svg/brand-logos/facebook-4.svg',
'Google' => '/site3/assets/media/svg/brand-logos/google-icon.svg'
);
//List a link to login
foreach ($providers as $provider)
{
$href = sprintf(base_url('%s/auth/%s/') , strtolower($this->router->fetch_class()) , $provider);
$login_links .= '<a href="' . $href . '" class="btn btn-flex flex-center btn-light btn-lg w-100 mb-5">';
if (array_key_exists($provider, $provider_icons)) {
$login_links .= '<img alt="Logo" src="' . $provider_icons[$provider] . '" class="h-20px me-3">';
}
$login_links .= 'Continue with ' . $provider . '</a>';
}
$data['login_links'] = $login_links;
//$this->home1('');
$this->load->view('site3/external/view_home');
$this->load->view('site3/external/view_home', $data);
}
public function about() {
@@ -15,4 +60,118 @@ class Home extends WRB_Controller {
$this->home2('home2/about');
}
//Processes social login
function auth($provider = NULL)
{
$service = NULL;
try
{
//Instantiate Hybridauth's classes
$hybrid = new Hybridauth($this->getHybridConfig());
//Check if given provider is enabled
if ((isset($provider)) && in_array($provider, $hybrid->getProviders()))
{
$this->session->set_userdata('provider', $provider);
}
//Update variable with the valid provider
$provider = $this->session->userdata('provider');
if ($provider)
{
$service = $hybrid->authenticate($provider);
if ($service->isConnected())
{
//Get user profile
$profile = $service->getUserProfile();
//Get user contacts
$contacts = $service->getUserContacts();
/*
Disconnect the service else HA would reuse stored session data
rather making a fresh request in case the user has denied permissions
in the previous authorization request
*/
$service->disconnect();
$this->session->unset_userdata('provider');
//Display the profile data
echo 'Name: ' . $profile->displayName;
print_r($profile);
}
else
{
$this->session->set_flashdata('showmsg', array('msg' => 'Sorry! We couldn\'t authenticate your identity.'));
}
}
}
catch(Exception $e)
{
if (isset($service) && $service->isConnected())
$service->disconnect();
$error = 'Sorry! We couldn\'t authenticate you.';
$this->session->set_flashdata('showmsg', array('msg' => $error));
$error .= '\nError Code: ' . $e->getCode();
$error .= '\nError Message: ' . $e->getMessage();
log_message('error', $error);
}
//redirect();
}
//Hybridauth configuration
private function getHybridConfig()
{
$config = array(
'callback' => site_url('social/auth/') ,
'providers' => array(
'Google' => array(
'enabled' => true,
'keys' => array(
'id' => 'YOUR_CLIENT_ID',
'secret' => 'YOUR_CLIENT_SECRET'
) ,
'scope' => 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile'
) ,
'Facebook' => array(
'enabled' => true,
'keys' => array(
'id' => (ENVIRONMENT == 'development') ? '390204307987009' : '390204307987009',
'secret' => (ENVIRONMENT == 'development') ? '19f778e312f2ab96d147bacb612910c2' : '19f778e312f2ab96d147bacb612910c2'
) ,
'scope' => 'email, public_profile'
) ,
'Apple' => array(
"enabled" => true,
"keys" => [
"id" => "Your Apple ID",
"team_id" => "Your Apple team id",
"key_id" => "Your Apple key id",
"key_content" => "Your Apple key (content including BEGIN and END lines)",
"key_file" => "Full path to your Apple key file (alternative to key_content)"
],
"scope" => "name email",
"verifyTokenSignature" => true
)
) ,
'hybrid_debug' => array(
'debug_mode' => 'info', /* none, debug, info, error */
'debug_file' => APPPATH . '/logs/log-' . date('Y-m-d') . '.php'
)
);
return $config;
}
}
+5 -1
View File
@@ -26,7 +26,11 @@ class Member extends Users_Controller {
}
}
public function deleteacc(){
echo "Please log out of your account, and you will not be able to log in anymore. ";
$data = $this->getSessionArray();
}
public function addreccipient() {
+70 -2
View File
@@ -15,9 +15,77 @@ class Paymnt extends Users_Controller {
public function paymus() {
$data = $this->getSessionArray();
$data['card_table_result'] = $this->cardListData(4)['card_table_result'];
$this->RenderUserPage('users/view_startpaymus', $data);
}
private function cardListData($limit){
$data = array();
$mysql = "SELECT * FROM creditcard WHERE member_id = " . $_SESSION['member_id'] . " AND status =3 AND active =1 ORDER BY id DESC limit ".$limit;
$query = $this->db->query($mysql);
$data['card_table_result'] = $query->result();
return $data;
}
public function newcc(){
$data = $this->getSessionArray();
if ($_POST) {
$this->load->model('cardpay_model');
$cd = array();
$cd['cardnumber'] = $this->input->post('cardnumber');
$cd['exp_month'] = $this->input->post('exp_month');
$cd['exp_year'] = $this->input->post('exp_year');
$cd['cvc'] = $this->input->post('cvc');
$cd['description']= $this->input->post('description');
$amount = rand(5555,9999);
$cardTestResult= $this->cardpay_model->verifyCardData($cd);
//var_dump($cardTestResult);
//var_dump($cd);
if ( $cardTestResult['error_status'] == false) // no error
{
$member_id = $_SESSION['member_id'];
$email ="support@wrenchboard.com";
$cardData=array(
"action" => WRENCHBOARD_USER_ADNEWCC,
"cardnumber" => $cd['cardnumber'],
"exp_month" => $cd['exp_month'],
"exp_year" => $cd['exp_year'],
"cvc" => $cd['cvc'],
"amount" => $amount ,
"email" => $email,
"description" => $cd['description'],
"member_id" => $member_id,
"paymenttype" => 100
);
$out=array();
$this->load->model('backend_model');
$res = $this->backend_model->wrenchboard_api($cardData, $out);
// var_dump($out);
if ($res == PHP_API_OK) {
// we are good
} else {
// we still have error
}
} // no error(s) from card test PHP model
else{
$data['card_test_result'] = $cardTestResult;
$data['card_table_result'] = $this->cardListData(4)['card_table_result'];
$this->RenderUserPage('users/view_startpaymus', $data); // return back to card page
}
}
else
{
return $this->paymus();
}
}
}
+89
View File
@@ -0,0 +1,89 @@
<?php
class Cardpay_model extends CI_Model {
function __construct() {
}
public function verifyCardData($data){
$error_status = false;
$errorArray = array ();
/*
$cd['cardnumber'] = $this->input->post('cardnumber');
$cd['exp_month'] = $this->input->post('exp_month');
$cd['exp_year'] = $this->input->post('exp_year');
$cd['cvc'] = $this->input->post('cvc');
$cd['description']= $this->input->post('description');
*/
if ( strlen( $data['cvc'] ) == 0 ){
$error_status = true;
$errorArray[]="Enter valid card CVV";
}
if ( strlen( $data['cardnumber'] ) == 0 || $this->luhn_check( $data['cardnumber'] ) == false){
$error_status = true;
$errorArray[]="Enter valid card number";
}
if ( strlen( $data['exp_year'] ) == 0 || $data['exp_year'] < date('Y') ){
$error_status = true;
$errorArray[]="Enter valid card expiration date";
}
else{
// let us test the month now
}
if ( strlen( $data['description'] ) == 0 ){
$error_status = true;
$errorArray[]="Enter name on card";
}
return [
"error_status" => $error_status,
"error_message" => $errorArray
];
}
public function verifyCCNumber($cardNumber) {
return $this->luhn_check($cardNumber);
}
/* Luhn algorithm number checker - (c) 2005-2008 shaman - www.planzero.org *
* This code has been released into the public domain, however please *
* give credit to the original author where possible. */
private function luhn_check($number) {
// Strip any non-digits (useful for credit card numbers with spaces and hyphens)
$number=preg_replace('/\D/', '', $number);
// Set the string length and parity
$number_length=strlen($number);
$parity=$number_length % 2;
// Loop through each digit and do the maths
$total=0;
for ($i=0; $i<$number_length; $i++) {
$digit=$number[$i];
// Multiply alternate digits by two
if ($i % 2 == $parity) {
$digit*=2;
// If the sum is two digits, add them together (in effect)
if ($digit > 9) {
$digit-=9;
}
}
// Total up the digits
$total+=$digit;
}
// If the total mod 10 equals 0, the number is valid
return ($total % 10 == 0) ? TRUE : FALSE;
}
}
+3 -2
View File
@@ -69,13 +69,14 @@
<img alt="Logo" src="/site3/assets/media/svg/brand-logos/google-icon.svg" class="h-20px me-3" />Continue with Google</a -->
<!--end::Google link-->
<!--begin::Google link-->
<a href="<?php echo $this->lib_login->getLoginUrl(); ?>" class="btn btn-flex flex-center btn-light btn-lg w-100 mb-5">
<img alt="Logo" src="/site3/assets/media/svg/brand-logos/facebook-4.svg" class="h-20px me-3" />Continue with Facebook</a>
<!-- a href="<?php echo $this->lib_login->getLoginUrl(); ?>" class="btn btn-flex flex-center btn-light btn-lg w-100 mb-5">
<img alt="Logo" src="/site3/assets/media/svg/brand-logos/facebook-4.svg" class="h-20px me-3" />Continue with Facebook</a -->
<!--end::Google link-->
<!--begin::Google link-->
<!-- a href="#" class="btn btn-flex flex-center btn-light btn-lg w-100">
<img alt="Logo" src="/site3/assets/media/svg/brand-logos/apple-black.svg" class="h-20px me-3" />Continue with Apple</a -->
<!--end::Google link-->
<?php echo isset($login_links) ? $login_links :''; ?>
</div>
<!--end::Actions-->
</form>
+17 -5
View File
@@ -360,7 +360,7 @@ $email_preff = array (
<!--end::Card body-->
<!--begin::Card footer-->
<div class="card-footer d-flex justify-content-end py-6 px-9">
<button onclick="return deactivateMyAccount();" id="kt_account_deactivate_account_submit" type="submit" class="btn btn-danger fw-bold">Deactivate Account</button>
<div id="del-sec" name="del-sec"><button onclick="return deactivateMyAccount();" id="kt_account_deactivate_account_submit" type="submit" class="btn btn-danger fw-bold">Deactivate Account</button></div>
</div>
<!--end::Card footer-->
</form>
@@ -376,15 +376,27 @@ $email_preff = array (
function deactivateMyAccount() {
var deactivate = document.dact_individual.deactivate.value;
if (deactivate == '') {
alert('You must confirm my account deactivation');
return false;
//return false;
}
var dialog = confirm("Please confirm account deletion. We will not be able to reverse this action. ?");
if (dialog) {
//console.log('Continue')
}
else {
return true;
}
return true;
$.ajax({
url: "/member/deleteacc?contact_id=DELETE"
}).done(function (data) {
$('#del-sec').html(data);
});
return false;
}
// -->
</script>
@@ -10,7 +10,6 @@
<div class="card-header border-0 pt-5">
<h3 class="card-title align-items-start flex-column">
<span class="card-label fw-bolder fs-3 mb-1">Payment Methods</span>
<span class="text-muted mt-1 fw-bold fs-7">Last updated:</span>
</h3>
<div class="card-toolbar">
Credit / Debit Card
@@ -20,6 +19,8 @@
<!--begin::Body-->
<div class="card-body py-3">
<!--begin::Table container-->
<form method="POST" action="/paymnt/newcc">
<!--begin::Input group-->
<div class="d-flex flex-column mb-7 fv-row">
@@ -29,10 +30,8 @@
<i class="fas fa-exclamation-circle ms-2 fs-7" data-bs-toggle="tooltip" title="Specify a card holder's name"></i>
</label>
<!--end::Label-->
<input type="text" class="form-control form-control-solid" placeholder="" name="card_name" value="<?=$_SESSION['firstname']?> <?=$_SESSION['lastname']?>" />
<input type="text" class="form-control form-control-solid" placeholder="" name="description" value="<?=$_SESSION['firstname']?> <?=$_SESSION['lastname']?>" />
</div>
<!--end::Input group-->
<!--begin::Input group-->
@@ -43,13 +42,13 @@
<!--begin::Input wrapper-->
<div class="position-relative">
<!--begin::Input-->
<input type="text" class="form-control form-control-solid" placeholder="Enter card number" name="card_number" value="4111 1111 1111 1111" />
<input type="text" class="form-control form-control-solid" placeholder="Enter card number" name="cardnumber" value="" />
<!--end::Input-->
<!--begin::Card logos-->
<div class="position-absolute translate-middle-y top-50 end-0 me-5">
<img src="/metronic8/demo8/assets/media/svg/card-logos/visa.svg" alt="" class="h-25px" />
<img src="/metronic8/demo8/assets/media/svg/card-logos/mastercard.svg" alt="" class="h-25px" />
<img src="/metronic8/demo8/assets/media/svg/card-logos/american-express.svg" alt="" class="h-25px" />
<img src="/site3/assets/media/svg/card-logos/visa.svg" alt="" class="h-25px" />
<img src="/site3/assets/media/svg/card-logos/mastercard.svg" alt="" class="h-25px" />
<img src="/site3/assets/media/svg/card-logos/american-express.svg" alt="" class="h-25px" />
</div>
<!--end::Card logos-->
</div>
@@ -68,17 +67,17 @@
<div class="row fv-row">
<!--begin::Col-->
<div class="col-6">
<select name="card_expiry_month" class="form-select form-select-solid" data-control="select2" data-hide-search="true" data-placeholder="Month">
<select name="exp_month" class="form-select form-select-solid" data-control="select2" data-hide-search="true" data-placeholder="Month">
<option></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
@@ -87,7 +86,7 @@
<!--end::Col-->
<!--begin::Col-->
<div class="col-6">
<select name="card_expiry_year" class="form-select form-select-solid" data-control="select2" data-hide-search="true" data-placeholder="Year">
<select name="exp_year" class="form-select form-select-solid" data-control="select2" data-hide-search="true" data-placeholder="Year">
<option></option>
<option value="2022">2022</option>
<option value="2023">2023</option>
@@ -118,7 +117,7 @@
<!--begin::Input wrapper-->
<div class="position-relative">
<!--begin::Input-->
<input type="text" class="form-control form-control-solid" minlength="3" maxlength="4" placeholder="CVV" name="card_cvv" />
<input type="text" class="form-control form-control-solid" minlength="3" maxlength="4" placeholder="CVV" name="cvc" />
<!--end::Input-->
<!--begin::CVV icon-->
<div class="position-absolute translate-middle-y top-50 end-0 me-3">
@@ -169,6 +168,9 @@
<!--end::Switch-->
</div>
<!--end::Input group-->
<!--begin::Actions-->
<div class="text-center pt-15">
<button type="reset" id="kt_modal_new_card_cancel" class="btn btn-light me-3">Discard</button>
@@ -179,6 +181,26 @@
</button>
</div>
<!--end::Actions-->
</form>
<?php
if (isset($card_test_result) && is_array($card_test_result) && $card_test_result['error_status']==true)
{
?>
<div class="text-center pt-15">
<div class="d-flex align-items-center bg-light-danger rounded p-5 mb-7">
<?php
foreach($card_test_result['error_message'] as $err)
{
echo $err ." ,";
}
?>
</div>
</div>
<?php
}
?>
<!--end::Table container-->
</div>
<!--begin::Body-->
@@ -207,36 +229,45 @@
<!--begin::Tap pane-->
<div class="tab-pane fade show active" id="kt_table_widget_4_tab_1">
<!--begin::Table container-->
<!--begin::Card-->
<div class="card card-dashed h-xl-100 flex-row flex-stack flex-wrap p-6">
<!--begin::Info-->
<div class="d-flex flex-column py-2">
<!--begin::Owner-->
<div class="d-flex align-items-center fs-4 fw-bolder mb-5">Marcus Morris
<span class="badge badge-light-success fs-7 ms-2">Primary</span></div>
<!--end::Owner-->
<!--begin::Wrapper-->
<div class="d-flex align-items-center">
<!--begin::Icon-->
<img src="/metronic8/demo8/assets/media/svg/card-logos/visa.svg" alt="" class="me-4" />
<!--end::Icon-->
<!--begin::Details-->
<div>
<div class="fs-4 fw-bolder">Visa **** 1679</div>
<div class="fs-6 fw-bold text-gray-400">Card expires at 09/24</div>
<?php
foreach ($card_table_result as $cr){
?>
<!--begin::Card-->
<div class="card card-dashed h-xl-100 flex-row flex-stack flex-wrap p-6">
<!--begin::Info-->
<div class="d-flex flex-column py-2">
<!--begin::Owner-->
<div class="d-flex align-items-center fs-4 fw-bolder mb-5"><?=$cr->firstname?> <?=$cr->lastname?>
<span class="badge badge-light-success fs-7 ms-2">Primary</span></div>
<!--end::Owner-->
<!--begin::Wrapper-->
<div class="d-flex align-items-center">
<!--begin::Icon-->
<img src="/site3/assets/media/svg/card-logos/<?=strtolower($cr->description)?>.svg" alt="" class="me-4" />
<!--end::Icon-->
<!--begin::Details-->
<div>
<div class="fs-4 fw-bolder"><?=$cr->description?> **** <?=$cr->digits?></div>
<div class="fs-6 fw-bold text-gray-400">Card expires at <?=$cr->expiration_month?>/<?=$cr->expiration_year?></div>
</div>
<!--end::Details-->
</div>
<!--end::Details-->
<!--end::Wrapper-->
</div>
<!--end::Wrapper-->
<!--end::Info-->
<!--begin::Actions-->
<div class="d-flex align-items-center py-2">
<button type="reset" class="btn btn-sm btn-danger btn-active-light-primary me-3">Delete</button>
</div>
<!--end::Actions-->
</div>
<!--end::Info-->
<!--begin::Actions-->
<div class="d-flex align-items-center py-2">
<button type="reset" class="btn btn-sm btn-danger btn-active-light-primary me-3">Delete</button>
</div>
<!--end::Actions-->
</div>
<!--end::Card-->
<!--end::Card-->
<?php
}
?>
<!--end::Table-->
</div>
<!--end::Tap pane-->