diff --git a/www/TEST/test_stripe.php b/www/TEST/test_stripe.php index 2ca4d3c0..fac3a8a2 100644 --- a/www/TEST/test_stripe.php +++ b/www/TEST/test_stripe.php @@ -1,5 +1,6 @@
cfgReadChar("database.host");
@@ -16,7 +17,7 @@ $in=array(
"action" => 90005, /* WRENCHBOARD_STRIPE_CHARGE_NEW */
"ccnum" => "4242424242424242",
"ccexpm" => "12",
- "ccexpy" => "18",
+ "ccexpy" => "26",
"cccvc" => "123",
"amount" => "100",
"customer_id" => $f["id"],
diff --git a/www/application/config/constants.php b/www/application/config/constants.php
index 374ab938..215bcc70 100644
--- a/www/application/config/constants.php
+++ b/www/application/config/constants.php
@@ -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 );
diff --git a/www/application/config/routes.php b/www/application/config/routes.php
index 9a5c12d9..3192d532 100644
--- a/www/application/config/routes.php
+++ b/www/application/config/routes.php
@@ -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';
diff --git a/www/application/controllers/Home.php b/www/application/controllers/Home.php
index 489229ba..c06a634a 100644
--- a/www/application/controllers/Home.php
+++ b/www/application/controllers/Home.php
@@ -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 .= '';
+ if (array_key_exists($provider, $provider_icons)) {
+ $login_links .= '
';
+ }
+ $login_links .= 'Continue with ' . $provider . '';
+ }
+
+ $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;
+ }
+
}
diff --git a/www/application/controllers/Member.php b/www/application/controllers/Member.php
index 6aa8731f..5ec096a2 100644
--- a/www/application/controllers/Member.php
+++ b/www/application/controllers/Member.php
@@ -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() {
diff --git a/www/application/controllers/Paymnt.php b/www/application/controllers/Paymnt.php
index c4017895..b231b67e 100644
--- a/www/application/controllers/Paymnt.php
+++ b/www/application/controllers/Paymnt.php
@@ -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();
+ }
+ }
}
diff --git a/www/application/models/Cardpay_model.php b/www/application/models/Cardpay_model.php
new file mode 100644
index 00000000..2e81b8cc
--- /dev/null
+++ b/www/application/models/Cardpay_model.php
@@ -0,0 +1,89 @@
+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;
+
+ }
+
+}
diff --git a/www/application/views/site3/external/view_home.php b/www/application/views/site3/external/view_home.php
index 735695b7..66ce5aa7 100644
--- a/www/application/views/site3/external/view_home.php
+++ b/www/application/views/site3/external/view_home.php
@@ -69,13 +69,14 @@
Continue with Google
-
-
Continue with Facebook
+
+
diff --git a/www/application/views/users/view_settings.php b/www/application/views/users/view_settings.php
index f212ca84..566b6817 100644
--- a/www/application/views/users/view_settings.php
+++ b/www/application/views/users/view_settings.php
@@ -360,7 +360,7 @@ $email_preff = array (
@@ -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;
}
// -->
diff --git a/www/application/views/users/view_startpaymus.php b/www/application/views/users/view_startpaymus.php
index a028511c..0e6ace01 100644
--- a/www/application/views/users/view_startpaymus.php
+++ b/www/application/views/users/view_startpaymus.php
@@ -10,7 +10,6 @@
Payment Methods
- Last updated: