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
+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();
}
}
}