expnaded sample env
This commit is contained in:
@@ -70,6 +70,26 @@ class Database extends Config
|
|||||||
'port' => 5432,
|
'port' => 5432,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $myfit = [
|
||||||
|
'DSN' => '',
|
||||||
|
'hostname' => '10.20.30.60',
|
||||||
|
'username' => 'myfit',
|
||||||
|
'password' => 'myfit',
|
||||||
|
'database' => 'myfit_dev',
|
||||||
|
'DBDriver' => 'postgre',
|
||||||
|
'DBPrefix' => '',
|
||||||
|
'pConnect' => false,
|
||||||
|
'DBDebug' => (ENVIRONMENT !== 'production'),
|
||||||
|
'charset' => 'utf8',
|
||||||
|
'DBCollat' => 'utf8_general_ci',
|
||||||
|
'swapPre' => '',
|
||||||
|
'encrypt' => false,
|
||||||
|
'compress' => false,
|
||||||
|
'strictOn' => false,
|
||||||
|
'failover' => [],
|
||||||
|
'port' => 5432,
|
||||||
|
];
|
||||||
|
|
||||||
public $mermsemr_blog = [
|
public $mermsemr_blog = [
|
||||||
'DSN' => '',
|
'DSN' => '',
|
||||||
'hostname' => '10.10.33.60',
|
'hostname' => '10.10.33.60',
|
||||||
@@ -147,5 +167,9 @@ class Database extends Config
|
|||||||
if (ENVIRONMENT === 'testing') {
|
if (ENVIRONMENT === 'testing') {
|
||||||
$this->defaultGroup = 'tests';
|
$this->defaultGroup = 'tests';
|
||||||
}
|
}
|
||||||
|
$this->myfit['hostname'] = getenv('MYFIT_DATABASE_HOSTNAME');
|
||||||
|
$this->myfit['username'] = getenv('MYFIT_DATABASE_USERNAME');
|
||||||
|
$this->myfit['password'] = getenv('MYFIT_DATABASE_PASSWORD');
|
||||||
|
$this->myfit['database'] = getenv('MYFIT_DATABASE');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-8
@@ -33,8 +33,8 @@ class Email extends BaseConfig
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $protocol = 'mail';
|
//public $protocol = 'mail';
|
||||||
|
public $protocol = 'smtp';
|
||||||
/**
|
/**
|
||||||
* The server path to Sendmail.
|
* The server path to Sendmail.
|
||||||
*
|
*
|
||||||
@@ -47,28 +47,32 @@ class Email extends BaseConfig
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $SMTPHost;
|
//public $SMTPHost;
|
||||||
|
public $SMTPHost= 'smtp.google.com';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMTP Username
|
* SMTP Username
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $SMTPUser;
|
//public $SMTPUser;
|
||||||
|
public $SMTPUser='support@chiefsoft.com';
|
||||||
/**
|
/**
|
||||||
* SMTP Password
|
* SMTP Password
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $SMTPPass;
|
//public $SMTPPass;
|
||||||
|
public $SMTPPass='may12002!';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMTP Port
|
* SMTP Port
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $SMTPPort = 25;
|
//public $SMTPPort = 25;
|
||||||
|
public $SMTPPort = 465; // 993; //465;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMTP Timeout (in seconds)
|
* SMTP Timeout (in seconds)
|
||||||
@@ -89,8 +93,8 @@ class Email extends BaseConfig
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
//public $SMTPCrypto = 'tls';
|
||||||
public $SMTPCrypto = 'tls';
|
public $SMTPCrypto = 'tls';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable word-wrap
|
* Enable word-wrap
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -58,13 +58,15 @@ $routes->post('/en/desktop/api/v2/myfituser/resetpass', 'Myfitauth::users');
|
|||||||
$routes->post('/en/desktop/api/v2/myfituser/login', 'Myfitauth::users');
|
$routes->post('/en/desktop/api/v2/myfituser/login', 'Myfitauth::users');
|
||||||
//--create acount
|
//--create acount
|
||||||
$routes->post('/en/desktop/api/v2/myfituser/account', 'Myfitauth::users');
|
$routes->post('/en/desktop/api/v2/myfituser/account', 'Myfitauth::users');
|
||||||
|
$routes->post('/en/desktop/api/v2/myfituser/signup-code', 'Myfitauth::users');
|
||||||
|
$routes->post('/en/desktop/api/v2/myfituser/resetpass-code', 'Myfitauth::users');
|
||||||
|
|
||||||
$routes->get('/en/desktop/api/v2/myfituser/profile', 'Myfituser::users');
|
$routes->get('/en/desktop/api/v2/myfituser/profile', 'Myfituser::users');
|
||||||
$routes->get('/en/desktop/api/v2/myfituser/myfeed', 'Myfituser::users');
|
$routes->get('/en/desktop/api/v2/myfituser/myfeed', 'Myfituser::users');
|
||||||
|
|
||||||
//Tracking
|
//Tracking
|
||||||
$routes->post('/en/desktop/api/v2/myfituser/tracking', 'Myfituser::users');
|
$routes->post('/en/desktop/api/v2/myfituser/tracking', 'Myfituser::users');
|
||||||
|
$routes->get('/en/desktop/api/v2/myfituser/trackinghx', 'Myfituser::users');
|
||||||
$routes->get('/en/desktop/api/v2/myfituser/trackcategory', 'Myfituser::users');
|
$routes->get('/en/desktop/api/v2/myfituser/trackcategory', 'Myfituser::users');
|
||||||
|
|
||||||
// REMINDERS -------------------------------------------------------------
|
// REMINDERS -------------------------------------------------------------
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ class Myfitauth extends BaseController
|
|||||||
'account' => ['POST'],
|
'account' => ['POST'],
|
||||||
'login' => ['POST'],
|
'login' => ['POST'],
|
||||||
'resetpass' => ['POST'],
|
'resetpass' => ['POST'],
|
||||||
|
'signup-code' => ['POST'],
|
||||||
|
'resetpass-code' => ['POST']
|
||||||
];
|
];
|
||||||
|
|
||||||
$res1 = [];
|
$res1 = [];
|
||||||
@@ -59,19 +61,51 @@ class Myfitauth extends BaseController
|
|||||||
$res1 = $userAccess->startLogin($raw_array);
|
$res1 = $userAccess->startLogin($raw_array);
|
||||||
break;
|
break;
|
||||||
case 'account':
|
case 'account':
|
||||||
$res1 = $this->dummyData($raw_array);
|
$userSignUp = new \App\Models\userSignUp();
|
||||||
|
//$this->push();
|
||||||
|
$res1 = $userSignUp->startSignUp($raw_array);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'resetpass':
|
case 'resetpass':
|
||||||
$res1 = [
|
$passReset = new \App\Models\usersResetPass();
|
||||||
'email' => $raw_array['email'],
|
$res1 = $passReset->startPassReset($raw_array);
|
||||||
'status' => 1,
|
break;
|
||||||
];
|
|
||||||
|
case 'signup-code':
|
||||||
|
$userSignUp = new \App\Models\userSignUp();
|
||||||
|
$res1 = $userSignUp->tempCodes();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'resetpass-code':
|
||||||
|
$passReset = new \App\Models\usersResetPass();
|
||||||
|
$res1 = $passReset->tempCodes();
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response->setJson($res1);
|
return $this->response->setJson($res1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function push()
|
||||||
|
{
|
||||||
|
$to = 'ameye@chiefsoft.com';//Type here the mail address where you want to send
|
||||||
|
$subject = 'myFit Signup';//Write here Subject of Email
|
||||||
|
$message='Conngrats ! You did it.';//Write the message you want to send
|
||||||
|
$email = \Config\Services::email();
|
||||||
|
$email->setTo($to);
|
||||||
|
$email->setFrom('works@chiefsoft.com', 'Just testing the emsil function');//set From
|
||||||
|
$email->setSubject($subject);
|
||||||
|
$email->setMessage($message);
|
||||||
|
if($email->send())
|
||||||
|
{
|
||||||
|
//echo 'Email has been Sent.';
|
||||||
|
log_message('critical', "Email has been Sent" );
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// echo 'Something went wrong !';
|
||||||
|
log_message('critical', "Something went wrong" );
|
||||||
|
}
|
||||||
|
}
|
||||||
//this is dummy function to establish the endpoints before real implementations
|
//this is dummy function to establish the endpoints before real implementations
|
||||||
private function dummyData($raw_array)
|
private function dummyData($raw_array)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ class Myfituser extends BaseController
|
|||||||
'trackcategory' => ['GET'],
|
'trackcategory' => ['GET'],
|
||||||
'resetpass' => ['POST'],
|
'resetpass' => ['POST'],
|
||||||
'tracking' => ['POST'],
|
'tracking' => ['POST'],
|
||||||
|
'trackinghx' => ['GET']
|
||||||
];
|
];
|
||||||
|
|
||||||
$res1 = [];
|
$res1 = [];
|
||||||
@@ -138,6 +139,10 @@ class Myfituser extends BaseController
|
|||||||
$myfitTracking = new \App\Models\myfitTracking();
|
$myfitTracking = new \App\Models\myfitTracking();
|
||||||
$res1 = $myfitTracking->trackEngine($raw_array);
|
$res1 = $myfitTracking->trackEngine($raw_array);
|
||||||
break;
|
break;
|
||||||
|
case 'trackinghx':
|
||||||
|
$myfitTracking = new \App\Models\myfitTracking();
|
||||||
|
$res1 = $myfitTracking->readTracking($raw_array);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response->setJson($res1);
|
return $this->response->setJson($res1);
|
||||||
|
|||||||
+54
-16
@@ -2,6 +2,8 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use CodeIgniter\Model;
|
use CodeIgniter\Model;
|
||||||
|
use CodeIgniter\Database\RawSql;
|
||||||
|
|
||||||
|
|
||||||
class baseModel extends Model
|
class baseModel extends Model
|
||||||
{
|
{
|
||||||
@@ -12,27 +14,46 @@ class baseModel extends Model
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->db = \Config\Database::connect($this->con_name);
|
$this->db = \Config\Database::connect($this->con_name);
|
||||||
|
log_message('critical', "BaseModel-Entered" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function insert_db($inserDataArray, $insertTable)
|
public function insert_db($inserDataArray, $insertTable)
|
||||||
{
|
{
|
||||||
$insert_id=0;
|
log_message('critical', "insert_db-WAS CALLED user 000=>" );
|
||||||
$ic = 0;
|
$insert_id=0;
|
||||||
$fl_part = '';
|
$ic = 0;
|
||||||
$val_part = '';
|
$fl_part = '';
|
||||||
$sqlQ = '';
|
$val_part = '';
|
||||||
$fields = array_keys($inserDataArray);
|
$sqlQ = '';
|
||||||
foreach ($fields as $field) {
|
// try {
|
||||||
$fl_part .= $ic > 0 ? ',' : '';
|
|
||||||
$fl_part .= $field;
|
$fields = array_keys($inserDataArray);
|
||||||
|
log_message('critical', "insert_db-WAS CALLED user 009a=>" );
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
$fl_part .= $ic > 0 ? ',' : '';
|
||||||
|
$fl_part .= $field;
|
||||||
|
|
||||||
|
$val_part .= $ic > 0 ? ',' : '';
|
||||||
|
$val_part .= "'" . $inserDataArray[$field] . "'";
|
||||||
|
$ic++;
|
||||||
|
}
|
||||||
|
log_message('critical', "insert_db-WAS CALLED user 009b=>" );
|
||||||
|
$sqlQ = "INSERT INTO $insertTable ($fl_part) VALUES ($val_part)";
|
||||||
|
log_message('critical', "SQL-WAS CALLED user =>". $sqlQ );
|
||||||
|
$query = $this->db->query($sqlQ);
|
||||||
|
if(!$query){
|
||||||
|
$insert_id=-1;
|
||||||
|
}
|
||||||
|
// $insert_id = $this->db->insert_id();
|
||||||
|
// $insert_id = $this->db->getInsertID();
|
||||||
|
// $this->db->insert($insertTable,$inserDataArray);
|
||||||
|
// $insert_id = $this->db->insert_id();
|
||||||
|
// } catch (Exception $e) {
|
||||||
|
//echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||||
|
// log_message('critical', "Caught exception: => ".$e->getMessage() );
|
||||||
|
// }
|
||||||
|
|
||||||
$val_part .= $ic > 0 ? ',' : '';
|
|
||||||
$val_part .= "'" . $inserDataArray[$field] . "'";
|
|
||||||
$ic++;
|
|
||||||
}
|
|
||||||
$sqlQ = "INSERT INTO $insertTable ($fl_part) VALUES ($val_part)";
|
|
||||||
$query = $this->db->query($sqlQ);
|
|
||||||
$insert_id = $this->db->insert_id();
|
|
||||||
return $insert_id;
|
return $insert_id;
|
||||||
}
|
}
|
||||||
public function update_db($UupdateDataArray,$whereAray, $updateTable)
|
public function update_db($UupdateDataArray,$whereAray, $updateTable)
|
||||||
@@ -60,4 +81,21 @@ class baseModel extends Model
|
|||||||
$query = $this->db->query($sqlQ);
|
$query = $this->db->query($sqlQ);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getIPAddress()
|
||||||
|
{
|
||||||
|
//whether ip is from the share internet
|
||||||
|
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||||
|
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||||
|
}
|
||||||
|
//whether ip is from the proxy
|
||||||
|
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||||
|
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||||
|
}
|
||||||
|
//whether ip is from the remote address
|
||||||
|
else {
|
||||||
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
|
}
|
||||||
|
return $ip;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,29 +5,29 @@ use CodeIgniter\Model;
|
|||||||
|
|
||||||
class myfitHx extends baseModel
|
class myfitHx extends baseModel
|
||||||
{
|
{
|
||||||
protected $db;
|
|
||||||
// public $con_name = 'mermsemr';
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
// $this->db = \Config\Database::connect($this->con_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function readLoginHx($in)
|
public function readLoginHx($in)
|
||||||
{
|
{
|
||||||
// $in['member_id'] = 16;
|
// $in['member_id'] = 16;
|
||||||
$member_id =
|
$member_id2 =
|
||||||
isset($in['member_id']) &&
|
isset($in['member_id']) &&
|
||||||
$in['member_id'] > 0 &&
|
$in['member_id'] > 0 &&
|
||||||
is_int($in['member_id'])
|
is_int($in['member_id'])
|
||||||
? $in['member_id']
|
? $in['member_id']
|
||||||
: 0;
|
: 0;
|
||||||
// $member_id = 13;
|
$member_id = isset($in["member_id"]) ? (int) $in["member_id"]: 0 ;
|
||||||
|
|
||||||
|
$member_id = 13;
|
||||||
$sqlQ =
|
$sqlQ =
|
||||||
'SELECT * FROM members_login_hx WHERE member_id=' .
|
'SELECT * FROM members_login_hx WHERE member_id=' .
|
||||||
$member_id .
|
$member_id .
|
||||||
' ORDER BY id DESC LIMIT 15';
|
' ORDER BY id DESC LIMIT 15';
|
||||||
|
log_message('critical', "readLoginHx=>".$sqlQ );
|
||||||
$query = $this->db->query($sqlQ);
|
$query = $this->db->query($sqlQ);
|
||||||
$data['loginhx_data'] = $query->getResultArray();
|
$data['loginhx_data'] = $query->getResultArray();
|
||||||
return $inx = [
|
return $inx = [
|
||||||
|
|||||||
@@ -23,12 +23,13 @@ class myfitTracking extends baseModel
|
|||||||
|
|
||||||
public function readTracking($in)
|
public function readTracking($in)
|
||||||
{
|
{
|
||||||
$sqlQ = 'SELECT * FROM members_reminders';
|
$code_line = ( isset($in["code"]) && $in["code"] !='') ? " AND code= '".$in['code']."'" :'';
|
||||||
|
$member_id = isset($in["member_id"]) ? (int) $in["member_id"]: 0 ;
|
||||||
|
$sqlQ = "SELECT * FROM members_tracking WHERE member_id=$member_id $code_line";
|
||||||
$query = $this->db->query($sqlQ);
|
$query = $this->db->query($sqlQ);
|
||||||
$data['reminders_data'] = $query->getResultArray();
|
$data['tracking_data'] = $query->getResultArray();
|
||||||
return $inx = [
|
return $inx = [
|
||||||
'reminders' => $data['reminders_data'],
|
'tracking_data' => $data['tracking_data'],
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'raw_data' => $in,
|
'raw_data' => $in,
|
||||||
];
|
];
|
||||||
@@ -49,15 +50,31 @@ class myfitTracking extends baseModel
|
|||||||
switch($in['code']){
|
switch($in['code']){
|
||||||
case "WEIGT":
|
case "WEIGT":
|
||||||
$inData = [
|
$inData = [
|
||||||
|
'code'=>$in['code'],
|
||||||
'member_id'=>$in['member_id'],
|
'member_id'=>$in['member_id'],
|
||||||
'val1'=>$in['value'],
|
'val1'=>$in['val1'],
|
||||||
'munit'=>$in['unit'],
|
'munit'=>$in['unit'],
|
||||||
|
'event_time'=>$in['event_time'],
|
||||||
|
'loc'=>$this->getIPAddress()
|
||||||
];
|
];
|
||||||
$insert_id = $this->insert_db($inData, 'members_tracking_summary');
|
$insert_id = $this->insert_db($inData, 'members_tracking');
|
||||||
break;
|
break;
|
||||||
|
case 'BLPR':
|
||||||
|
$inData = [
|
||||||
|
'code'=>$in['code'],
|
||||||
|
'member_id'=>$in['member_id'],
|
||||||
|
'val1'=>$in['val1'],
|
||||||
|
'val2'=>$in['val2'],
|
||||||
|
'val3'=>$in['val3'],
|
||||||
|
'munit'=>$in['unit'],
|
||||||
|
'event_time'=>$in['event_time'],
|
||||||
|
'loc'=>$this->getIPAddress()
|
||||||
|
];
|
||||||
|
$insert_id = $this->insert_db($inData, 'members_tracking');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['insert_id'=> $insert_id, 'raw_data'=>$in ];
|
return ['insert_id'=> $insert_id, 'raw_data'=>$in ,'inData'=> $inData];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,11 @@ use CodeIgniter\Model;
|
|||||||
|
|
||||||
class userAccess extends baseModel
|
class userAccess extends baseModel
|
||||||
{
|
{
|
||||||
protected $db;
|
// protected $db;
|
||||||
// public $con_name = 'mermsemr';
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
//$db = \Config\Database::connect('mermsemr');
|
|
||||||
// $this->db = \Config\Database::connect($this->con_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function startLogin($in)
|
public function startLogin($in)
|
||||||
@@ -105,7 +102,7 @@ class userAccess extends baseModel
|
|||||||
return $tk;
|
return $tk;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getIPAddress()
|
private function getIPAddress_old()
|
||||||
{
|
{
|
||||||
//whether ip is from the share internet
|
//whether ip is from the share internet
|
||||||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use CodeIgniter\Model;
|
||||||
|
|
||||||
|
class userSignUp extends baseModel
|
||||||
|
{
|
||||||
|
// protected $db;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
CREATE TABLE members_pending (
|
||||||
|
id SERIAL,
|
||||||
|
uuid UUID DEFAULT (gen_random_uuid()),
|
||||||
|
username VARCHAR(50) NOT NULL,
|
||||||
|
firstname VARCHAR(50),
|
||||||
|
lastname VARCHAR(50),
|
||||||
|
email VARCHAR(50),
|
||||||
|
password VARCHAR(100) NOT NULL,
|
||||||
|
random_text VARCHAR(15),
|
||||||
|
status INT DEFAULT 0,
|
||||||
|
updated timestamp without time zone DEFAULT now(),
|
||||||
|
added timestamp without time zone DEFAULT now()
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
public function startSignUp($in)
|
||||||
|
{
|
||||||
|
$insert_id=0;
|
||||||
|
$uuid='';
|
||||||
|
$status=0;
|
||||||
|
$passEnr = $this->encryptmd5($in["password"]);
|
||||||
|
$randomText = rand(1010101,999999);// rand(1010101,999999);
|
||||||
|
$inData =[
|
||||||
|
'username'=> $in["username"],
|
||||||
|
'email'=> $in["email"],
|
||||||
|
'password'=> $passEnr,
|
||||||
|
'firstname'=> $in["firstname"],
|
||||||
|
'lastname'=> $in["lastname"],
|
||||||
|
'random_text' => $randomText
|
||||||
|
];
|
||||||
|
|
||||||
|
$insert_id = $this->insert_db($inData, 'members_pending');
|
||||||
|
if( $insert_id>=0){ // for now
|
||||||
|
$sqlQ = "SELECT id AS insert_id,uuid FROM members_pending WHERE username='".$in["username"]."' AND random_text='$randomText' AND password='$passEnr' LIMIT 1";
|
||||||
|
$query = $this->db->query($sqlQ);
|
||||||
|
$dat = $query->getResultArray();
|
||||||
|
$insert_id = $dat[0]['insert_id'];
|
||||||
|
$uuid = $dat[0]['uuid'];
|
||||||
|
$status=1;
|
||||||
|
}
|
||||||
|
return $inx = [
|
||||||
|
'insert_id' => $insert_id,
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'status' => $status,
|
||||||
|
'error_msg' => '',
|
||||||
|
'raw_data' => $in,
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function encryptmd5($rwStstr){
|
||||||
|
|
||||||
|
$sqlQ = "SELECT md5('$rwStstr') AS md5_string";
|
||||||
|
log_message('critical', "encryptmd5-Entered".$sqlQ );
|
||||||
|
$query = $this->db->query($sqlQ);
|
||||||
|
$data = $query->getResultArray();
|
||||||
|
return $data[0]['md5_string'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tempCodes(){
|
||||||
|
$sqlQ = "SELECT id AS insert_id,uuid,username,random_text FROM members_pending ORDER BY id DESC LIMIT 10";
|
||||||
|
$query = $this->db->query($sqlQ);
|
||||||
|
return $query->getResultArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
CREATE TABLE members_login_hx (
|
||||||
|
id SERIAL,
|
||||||
|
member_id INT REFERENCES members(id) NOT NULL,
|
||||||
|
channel VARCHAR(15),
|
||||||
|
added timestamp without time zone DEFAULT now(),
|
||||||
|
loc INET
|
||||||
|
);
|
||||||
|
ALTER TABLE ONLY members_login_hx
|
||||||
|
ADD CONSTRAINT members_login_hx_id_key UNIQUE (id);*/
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use CodeIgniter\Model;
|
||||||
|
|
||||||
|
class usersResetPass extends baseModel
|
||||||
|
{
|
||||||
|
// protected $db;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
$res1 = [
|
||||||
|
'email' => $raw_array['email'],
|
||||||
|
'status' => 1,
|
||||||
|
];
|
||||||
|
CREATE TABLE members_pending (
|
||||||
|
id SERIAL,
|
||||||
|
uuid UUID DEFAULT (gen_random_uuid()),
|
||||||
|
username VARCHAR(50) NOT NULL,
|
||||||
|
firstname VARCHAR(50),
|
||||||
|
lastname VARCHAR(50),
|
||||||
|
email VARCHAR(50),
|
||||||
|
password VARCHAR(100) NOT NULL,
|
||||||
|
random_text VARCHAR(15),
|
||||||
|
status INT DEFAULT 0,
|
||||||
|
updated timestamp without time zone DEFAULT now(),
|
||||||
|
added timestamp without time zone DEFAULT now()
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
public function startPassReset($in)
|
||||||
|
{
|
||||||
|
$insert_id=0;
|
||||||
|
$uuid='';
|
||||||
|
$status=0;
|
||||||
|
$passEnr = '';// $this->encryptmd5($in["password"]);
|
||||||
|
$randomText = rand(1010101,999999);// rand(1010101,999999);
|
||||||
|
$pdata =[];
|
||||||
|
|
||||||
|
$sqlQ = "SELECT id AS member_id,uuid FROM members WHERE username='".$in["username"]."' ";
|
||||||
|
$query = $this->db->query($sqlQ);
|
||||||
|
$data['user_data'] = $query->getResultArray();
|
||||||
|
|
||||||
|
if (count($data['user_data']) == 1) {
|
||||||
|
$userData = $data['user_data'][0];
|
||||||
|
$pdata = [
|
||||||
|
'username'=> $in["username"],
|
||||||
|
'member_uid'=> $userData["uuid"],
|
||||||
|
'random_text' => $randomText,
|
||||||
|
'status'=>1
|
||||||
|
];
|
||||||
|
|
||||||
|
$insert_id = $this->insert_db($pdata, 'members_password_reset');
|
||||||
|
if( $insert_id>=0){ // for now
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
CREATE TABLE members_password_reset (
|
||||||
|
id SERIAL,
|
||||||
|
uuid UUID DEFAULT (gen_random_uuid()),
|
||||||
|
username VARCHAR(50) NOT NULL,
|
||||||
|
member_uid VARCHAR(50),
|
||||||
|
random_text VARCHAR(15),
|
||||||
|
status INT DEFAULT 0,
|
||||||
|
updated timestamp without time zone DEFAULT now(),
|
||||||
|
added timestamp without time zone DEFAULT now()
|
||||||
|
);
|
||||||
|
|
||||||
|
$inData =[
|
||||||
|
'username'=> $in["username"],
|
||||||
|
'email'=> $in["email"],
|
||||||
|
'password'=> $passEnr,
|
||||||
|
'firstname'=> $in["firstname"],
|
||||||
|
'lastname'=> $in["lastname"],
|
||||||
|
'random_text' => $randomText
|
||||||
|
];
|
||||||
|
|
||||||
|
$insert_id = $this->insert_db($inData, 'members_pending');
|
||||||
|
if( $insert_id>=0){ // for now
|
||||||
|
$sqlQ = "SELECT id AS insert_id,uuid FROM members WHERE username='".$in["username"]."' AND random_text='$randomText' AND password='$passEnr' LIMIT 1";
|
||||||
|
$query = $this->db->query($sqlQ);
|
||||||
|
$dat = $query->getResultArray();
|
||||||
|
$insert_id = $dat[0]['insert_id'];
|
||||||
|
$uuid = $dat[0]['uuid'];
|
||||||
|
$status=1;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return $inx = [
|
||||||
|
'insert_id' => $insert_id,
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'status' => $status,
|
||||||
|
'pdata' => $pdata,
|
||||||
|
'error_msg' => '',
|
||||||
|
'raw_data' => $in,
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tempCodes(){
|
||||||
|
$sqlQ = "SELECT username,uuid,member_uid,random_text FROM members_password_reset WHERE status = 1 ORDER BY id DESC LIMIT 10";
|
||||||
|
$query = $this->db->query($sqlQ);
|
||||||
|
return $query->getResultArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function encryptmd5($rwStstr){
|
||||||
|
|
||||||
|
$sqlQ = "SELECT md5('$rwStstr') AS md5_string";
|
||||||
|
log_message('critical', "encryptmd5-Entered".$sqlQ );
|
||||||
|
$query = $this->db->query($sqlQ);
|
||||||
|
$data = $query->getResultArray();
|
||||||
|
return $data[0]['md5_string'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
CREATE TABLE members_login_hx (
|
||||||
|
id SERIAL,
|
||||||
|
member_id INT REFERENCES members(id) NOT NULL,
|
||||||
|
channel VARCHAR(15),
|
||||||
|
added timestamp without time zone DEFAULT now(),
|
||||||
|
loc INET
|
||||||
|
);
|
||||||
|
ALTER TABLE ONLY members_login_hx
|
||||||
|
ADD CONSTRAINT members_login_hx_id_key UNIQUE (id);*/
|
||||||
+145
@@ -0,0 +1,145 @@
|
|||||||
|
#--------------------------------------------------------------------
|
||||||
|
# Example Environment Configuration file
|
||||||
|
#
|
||||||
|
# This file can be used as a starting point for your own
|
||||||
|
# custom .env files, and contains most of the possible settings
|
||||||
|
# available in a default install.
|
||||||
|
#
|
||||||
|
# By default, all of the settings are commented out. If you want
|
||||||
|
# to override the setting, you must un-comment it by removing the '#'
|
||||||
|
# at the beginning of the line.
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# ENVIRONMENT
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
# CI_ENVIRONMENT = production
|
||||||
|
UID=1000
|
||||||
|
MYSQL_ROOT_PASSWORD=cod31gn1t3
|
||||||
|
MYSQL_DATABASE=codeigniter_db
|
||||||
|
CI_ENVIRONMENT=production
|
||||||
|
|
||||||
|
|
||||||
|
MYFIT_DATABASE_HOSTNAME='10.20.30.60'
|
||||||
|
MYFIT_DATABASE_USERNAME='myfit'
|
||||||
|
MYFIT_DATABASE_PASSWORD='myfit'
|
||||||
|
MYFIT_DATABASE='myfit_dev'
|
||||||
|
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# APP
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
# app.baseURL = ''
|
||||||
|
# app.forceGlobalSecureRequests = false
|
||||||
|
|
||||||
|
# app.sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler'
|
||||||
|
# app.sessionCookieName = 'ci_session'
|
||||||
|
# app.sessionExpiration = 7200
|
||||||
|
# app.sessionSavePath = null
|
||||||
|
# app.sessionMatchIP = false
|
||||||
|
# app.sessionTimeToUpdate = 300
|
||||||
|
# app.sessionRegenerateDestroy = false
|
||||||
|
|
||||||
|
# app.CSPEnabled = false
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# DATABASE
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
# database.default.hostname = localhost
|
||||||
|
# database.default.database = ci4
|
||||||
|
# database.default.username = root
|
||||||
|
# database.default.password = root
|
||||||
|
# database.default.DBDriver = MySQLi
|
||||||
|
# database.default.DBPrefix =
|
||||||
|
|
||||||
|
# database.tests.hostname = localhost
|
||||||
|
# database.tests.database = ci4
|
||||||
|
# database.tests.username = root
|
||||||
|
# database.tests.password = root
|
||||||
|
# database.tests.DBDriver = MySQLi
|
||||||
|
# database.tests.DBPrefix =
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# CONTENT SECURITY POLICY
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
# contentsecuritypolicy.reportOnly = false
|
||||||
|
# contentsecuritypolicy.defaultSrc = 'none'
|
||||||
|
# contentsecuritypolicy.scriptSrc = 'self'
|
||||||
|
# contentsecuritypolicy.styleSrc = 'self'
|
||||||
|
# contentsecuritypolicy.imageSrc = 'self'
|
||||||
|
# contentsecuritypolicy.base_uri = null
|
||||||
|
# contentsecuritypolicy.childSrc = null
|
||||||
|
# contentsecuritypolicy.connectSrc = 'self'
|
||||||
|
# contentsecuritypolicy.fontSrc = null
|
||||||
|
# contentsecuritypolicy.formAction = null
|
||||||
|
# contentsecuritypolicy.frameAncestors = null
|
||||||
|
# contentsecuritypolicy.frameSrc = null
|
||||||
|
# contentsecuritypolicy.mediaSrc = null
|
||||||
|
# contentsecuritypolicy.objectSrc = null
|
||||||
|
# contentsecuritypolicy.pluginTypes = null
|
||||||
|
# contentsecuritypolicy.reportURI = null
|
||||||
|
# contentsecuritypolicy.sandbox = false
|
||||||
|
# contentsecuritypolicy.upgradeInsecureRequests = false
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# COOKIE
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
# cookie.prefix = ''
|
||||||
|
# cookie.expires = 0
|
||||||
|
# cookie.path = '/'
|
||||||
|
# cookie.domain = ''
|
||||||
|
# cookie.secure = false
|
||||||
|
# cookie.httponly = false
|
||||||
|
# cookie.samesite = 'Lax'
|
||||||
|
# cookie.raw = false
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# ENCRYPTION
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
# encryption.key =
|
||||||
|
# encryption.driver = OpenSSL
|
||||||
|
# encryption.blockSize = 16
|
||||||
|
# encryption.digest = SHA512
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# HONEYPOT
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
# honeypot.hidden = 'true'
|
||||||
|
# honeypot.label = 'Fill This Field'
|
||||||
|
# honeypot.name = 'honeypot'
|
||||||
|
# honeypot.template = '<label>{label}</label><input type="text" name="{name}" value=""/>'
|
||||||
|
# honeypot.container = '<div style="display:none">{template}</div>'
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# SECURITY
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
# security.csrfProtection = 'cookie'
|
||||||
|
# security.tokenRandomize = false
|
||||||
|
# security.tokenName = 'csrf_token_name'
|
||||||
|
# security.headerName = 'X-CSRF-TOKEN'
|
||||||
|
# security.cookieName = 'csrf_cookie_name'
|
||||||
|
# security.expires = 7200
|
||||||
|
# security.regenerate = true
|
||||||
|
# security.redirect = true
|
||||||
|
# security.samesite = 'Lax'
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# LOGGER
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
# logger.threshold = 4
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# CURLRequest
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
|
||||||
|
# curlrequest.shareOptions = true
|
||||||
Reference in New Issue
Block a user