Problem : Change from http to https :
Step :
Edit .htaccess file adding the following code :
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Then,
Edit .htaccess file adding the following code :
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Then,
1) go to cpanel file manager directory :
public_html/crm/application/config
or
go to filezilla directory :
/var/www/html/crm/application/config
2) Ctrl + F find http and change all of them to https.
-----------------------------
Problem : Edit page content.
Step : Cpanel > public_html/client.bfm.expert/application/views/member/network.php
-----------------------------
Migrate website to new server :
Edit 3 files :
1) /application/config/constant.php
2) /application/config/database.php
3) /application/config/config.php
if page error : No input file specified.
Solution : go edit .htaccess file add ? after index.php become index.php?
for domain like member.inferlion.com, htaccess should looks like :
If 404 not found, then check folder permission. Change folder permission from 0750 to 0755 (tick allow read and execute for world)
If 403 error, then should be .htaccess file rule problem
If 403 error or ajax error, then delete / from ajax code url. Eg : 2aek.com/ replace by 2aek.com
If 403 error or ajax error, then go to config.php turn false ALL $config['csrf_protection'] = FALSE;
If 500 error, it is database connection problem, change 2aek_db to olyemall_db, and change 2aek_zac1987 user to olyemall_zac1987 user
If sub folder, config.php should look like this :
else if($_SERVER['HTTP_HOST'] == "2aek.com")
{
$base_url = 'https://2aek.com/zac-work/';
}
----------------------------
change Email Sender FROM for email verification :
file path : application > config > constants.php
database : tbl_site_setting > scroll to right find column Email.
---------------------------
php mysql code file path at :
application > controllers > member > Register.php
--------------------------
order package save poa into pdf file code path :
controllers/member/Product.php
-------------------------
To echo $total_invested on dashboard
file 1 : application/views/member/dashboard.php : $this->load->view("member/inc_statistics");
file 2 : application/views/member/inc_statistics.php : $total_invested;
file 3 : application/libraries/Common.php : function getTotalInvested($user_id=0){}
file 4 : application/controllers/member/Dashboard.php : $data['total_invested'] = $this->common->getTotalInvested();
To echo $member_active_status on dashboard
file 1 : application/views/member/dashboard.php : $member_active_status = $this->Member_model->checkMemberKycStatus()
file 2 : application/models/Member_model.php : function checkMemberKycStatus($user_id=0){}
-----------------------
To change timedate timezone:
application/constant.php
------------------------
javascript and jquery file at
application/views/member/inc_common_validation_all.php
-----------------------
To check if package purchase date is greater than a specific date :
To check if today is 3 days after package purchase date :
1) mysql WHERE .... && ((created_on < '2020-02-18') || (created_on > '2020-02-18' && created_on <= SUBDATE(CURDATE(), INTERVAL 3 DAY)))";
To check if today is before 7 days expiry :
2) mysql WHERE ...
AND ((o.created_on < '2020-02-18') OR (o.created_on > '2020-02-18' AND o.created_on <= SUBDATE(CURDATE(), INTERVAL 3 DAY)))
3) WHERE... AND DATEDIFF(CURDATE(),created_on) >= 2
-----------------------------------------------
javascript function change_status(id, url) is save at
application/views/secure/inc_footer.php
-----------------------------------------------
error 404 page not found
if u want to create a new page,
Step 1 : create html at view/withdraw_flamingo.php (must 1st character capital big, _ small capital
Step 2 : create php at controllers/withdraw_flamingo.php
Step 3 : add class and load->view at the php file that u created on (Step2) :
class Withdraw_flamingo extends CI_Controller
{ function index($tran_account=0)
{
$this->load->view('member/withdraw_flamingo ', $data);
}
}
----------------------------------------------
if ajax error, then delete html may fix ajax error
-------------------------------------------
if return 1 instead of 1500
then change
$data['Rows1'] = $Result1->row_array();
to
$data['Rows1'] = $Result1->result_array();
--------------------------------------------
ajax sort has bug?
file path : application/controllers/secure/Manage_flamingo_product_orders.php
$column_order = array('u.id','u.id','u.created_on','unique_code', 'm.first_name AS fname', 'u.package_amount', 'u.user_sign', 'u.auto_renew','u.status', 'u.poa_path', 'u.package_id');
The code above must in correct sequence from left to right fields on html table in views folder.
-----------------------------------------
ajax echo database record on to html table
file path : application/controllers/secure/Manage_flamingo_product_orders.php
foreach ($Rows as $Res)
{
$no++;
$row = array();
$row[] = $no;
$row[] = 'F'.PACKAGE_PREFIX.str_pad($Res['id'], 6, '0', STR_PAD_LEFT);
$row[] = $Res['created_on'];
$row[] = $Res['unique_code'];
$row[] = $Res['fname'];
$row[] = $Res['package_amount'];
----------------------------------------
simple database query echo on html page :
$placement = $this->common->getSelectedOneRow("placement", "tbl_user_master", "WHERE user_id = '".$this->session->userdata('WDW_MEMBER_LOGIN_ID')."'");
if ($placement['placement'] == ""){
---------------------------------------------
SUM(amount) no need to use getAllRow, you can use getSelectedOneRow :
$withdraw_pending = $this->getSelectedOneRow("Sum(withdraw_amount) AS withdraw_pending_amount","tbl_withdraw_request","WHERE user_id = '".$user_id."' AND status=0 AND tran_account=$tran_account");
-------------------------------------------
Select multiple records from database :
$withdraw_pending = $this->common->getAllRec("Sum(withdraw_amount) AS withdraw_pending_amount","tbl_withdraw_request","WHERE user_id = '".$user_id."' AND status=0 AND tran_account=$tran_account");
foreach ($withdraw_pending as $row2)
{
echo $row2["withdraw_amount"]."
";
//$pending_amount=$row2["withdraw_amount"];
//$total_pending+=$pending_amount;
}
-----------------------------------------------
SQL statement Where Clause && syntax :
$this->common->updateRecord("tbl_ewallet",$up_data1, "customerid = '" . $user_id_arr . "' AND id = '" . $bonus_id_arr . "'");
--------------------------------------------
If purchase package on sat, then wont get % jumping and profit on Tues, only will get them on Wednesday :
using mysql WHERE .... AND ((DAYOFWEEK(created_on) IN(0,1,2,3,4,6)) OR (DAYOFWEEK(created_on) = 5 AND DAYOFWEEK('".CURRENTDATE."') = 1 AND DATEDIFF('".CURRENTDATE."',created_on) >= 4) OR (DAYOFWEEK(created_on) = 5 AND DAYOFWEEK('".CURRENTDATE."') IN(0,2,3,4,5,6)))
ORDER BY created_on ASC;");
or using php
$purchase_day = date('D', strtotime($created_on));
$today_date = date('Y-m-d', time());
$diff_day = date_diff(new DateTime($today_date),new DateTime($created_on));
//echo $diff_day->format("%a"); //haha
//if($diff_day->format("%a") > 60){ echo "yes"; }else{echo "No";}
//echo $purchase_day;
if ($purchase_day == "Sat" && date("l") == "Tuesday" && $diff_day->format("%a") < 7 ){
$created_on = 0;
}
-------------------------
ajax call php function :
Search "drawCallBack" on page (inside ajax there). Paste the following code under this line :
//page loaded immediately check if 1st flamingo package auto renew is yes or no, then update all top up package auto renew in database
var arTp = $('.artp');
var arTpArray=[];
for(var i=0; i arTpArray[i] = $(arTp[i]).text();
}
var arPurchase = $(".arpp").attr('id');
if (arPurchase == "Yes"){ var oppAR = "No"; var currentArP = 1;}
if (arPurchase == "No"){ var oppAR = "Yes"; var currentArP = 0;}
if ($.inArray(oppAR,arTpArray) > -1) {
update_auto_renew_to_database(currentArP);
}
---------------------------------------
Ajax Datatable error / 500 error mostly because mysql syntax error,
Use filezilla only can access this directory username/domain/logs/domain/https or http (use notepad to open and check the error log)
you may create a html page try to query database by your mysql to check where is the syntax error.
Previous case was WHERE order_method == 0; is wrong, should be order_method = 0;
----------------------------------------
WEEKDAY : 0=Monday, 1=Tuesday, 2=Wednesday, 3=Thursday, 4=Friday, 5=Saturday, 6=Sunday
-------------------------------------
$last_top_up_day = date('d/m/Y',strtotime('+21 days',strtotime(str_replace('/', '-', $flamingo_order_approved_date)))) . PHP_EOL;
-----------------------------------
mysql update multiple rows
$up_data1['star_bonus_per'] = $v1_star_bonus = $this->common->custom_safe_string($this->input->post('v1_star_bonus')); $up_data2['star_bonus_per'] = $v1_star_bonus = $this->common->custom_safe_string($this->input->post('v2_star_bonus')); $up_data3['star_bonus_per'] = $v1_star_bonus = $this->common->custom_safe_string($this->input->post('v3_star_bonus')); $up_data4['star_bonus_per'] = $v1_star_bonus = $this->common->custom_safe_string($this->input->post('v4_star_bonus')); $up_data5['star_bonus_per'] = $v1_star_bonus = $this->common->custom_safe_string($this->input->post('v5_star_bonus')); $this->common->updateRecord('tbl_agent_qualificaiton',$up_data1,"id=1"); $this->common->updateRecord('tbl_agent_qualificaiton',$up_data2,"id=2"); $this->common->updateRecord('tbl_agent_qualificaiton',$up_data3,"id=3"); $this->common->updateRecord('tbl_agent_qualificaiton',$up_data4,"id=4"); $this->common->updateRecord('tbl_agent_qualificaiton',$up_data5,"id=5");
----------------------------------------
change all email address in database
UPDATE tbl_user_master SET user_email = CONCAT( `unique_code` , "@test.com" );
-----------------------------------------
Array with value only, without key :
global $temp_paid_star_bonus_package; //declare at function getChildren() && function printList() $temp_paid_star_bonus_package = array(); //declare at function getChildren() $single_package_id= explode("#",$multiple_package_id); foreach($single_package_id as $package_id) { if($package_id != 0) { $temp_paid_star_bonus_package[] = $package_id; //add value into array } } foreach($temp_paid_star_bonus_package as $fpackage_id) //retrive value from array and insert into database { $up_data1['star_bonus_paid'] = 1; $this->common->updateRecord('tbl_flamingo_product_order',$up_data1,'id='.$fpackage_id); }
----------------------------------------------
Array with key and value :
if got bug then might be because u didn't declare $temp_paid_breakaway_bonus_ref = array(); at the first function index()
$member_got_bonus_already=array(); //declare at function index()
global $member_got_bonus_already; //declare at function printList()
//deduct previous already paid out star bonus
if (@array_key_exists($userid, $member_got_bonus_already)) //retrive value from array
{ //check array if this member already get bonus previously
$individul_paid_bonus_rate = explode("#",$member_got_bonus_already[$userid]);
foreach($individul_paid_bonus_rate as $i_p_b_r) {
$final_star_bonus_rate = $final_star_bonus_rate - $i_p_b_r;
}
$star_bonus_receive = $individu_total_package_size * $final_star_bonus_rate / 100;
}else{
}
//insert value into array sample 1 :
if($star_bonus_receive != "" || $star_bonus_receive != 0)
{
if (@array_key_exists($userid, $member_got_bonus_already)) //userid 123 => bonus 15# bonus 200 # bonus 39
{
$member_got_bonus_already[$userid] = $member_got_bonus_already[$userid] . "#" . $final_star_bonus_rate;
}else{
$member_got_bonus_already[$userid] = $final_star_bonus_rate; //save member_id and bonus_rate into array, so later his upline will deduct bonus_rate from this array.this array.
}
}
//insert value into array sample 2 :
foreach($single_package_id as $package_id)
{
if($package_id != 0)
{
if (isset($package_id) AND isset($temp_paid_star_bonus_package) AND array_key_exists($package_id,$temp_paid_star_bonus_package))
{
$temp_paid_star_bonus_package[$package_id] = $temp_paid_star_bonus_package[$package_id] + $final_star_bonus_rate;
}else{
$temp_paid_star_bonus_package[$package_id] = $final_star_bonus_rate ;
}
}
}
//if want to retrive both keyand value
foreach ($member_got_bonus_already as $key => $value )
{
echo $key;
echo $value;
}
--------------------------------------------------
NOT Exist mysql query :
$user_tree = $this->getAllRec("u.user_id,(SELECT COUNT(o.user_id) FROM tbl_user_master o WHERE o.sponsor_id = u.user_id AND o.user_type = 2 AND o.status = 1 AND NOT EXISTS (
SELECT p.user_id
FROM tbl_flamingo_product_order p
WHERE (p.user_id = u.user_id OR p.user_id = o.user_id) AND p.status=3)) AS ChildCnt",
"tbl_user_master u",
"WHERE u.sponsor_id = '".$user_id."' AND u.user_type = 2 AND u.status =1 AND NOT EXISTS (
SELECT p.user_id
FROM tbl_flamingo_product_order p
WHERE p.user_id = u.user_id AND p.status=3)");
Becareful, if upline is not exist in other table, then won't show this uplines, so will causing bug not showing all downlines of this upline. (missing downlines bug)
--------------------------------------------------
NOT Exist mysql query WHERE id in array ()
$data['member'] = $member = $this->common->getAllRec("o.user_id,o.username,o.first_name, o.last_name",
"tbl_user_master o",
"WHERE o.user_id IN (".$my_tree_ids.") and o.status != 3 AND o.user_type = 2
AND NOT EXISTS (
SELECT p.user_id
FROM tbl_flamingo_product_order p
WHERE p.user_id = o.user_id AND p.status=3)
ORDER BY o.first_name ASC, o.last_name ASC");
}
Save all agents id in array, then Where id IN array
----------------------------------------------------
Return string that extended by recursive loop :
Live demo at lifestartoday.com>library>common.php>loop_get_three_uplines()
Simple Live demo 2 at generate_user_unique_code() function at common.php file
Method 1 : Pass variable in function argument :
function test_loop($x_values,$x, $y)
{
$x = $x + 1;
if($x < 10)
{
$x_values[] = $x."#"; // insert item 2#,3#,4# into array
}
//loop again if y is not = 3;
$y = $y + 1;
if($y < 5)
{
return $x_values = test_loop($x_values, $x, $y); // need to put two return. 1 at recall loop function, another 1 at else statement
}else{
echo "gula"; //need to put the echo at else statement
return $x_values;
}
}
function abc(){
$bababa = test_loop([],1,0);
foreach($bababa as $fpackage_id)
{
echo $fpackage_id;
}
}
abc();
---------------------------------------------------
Method 2 : declare variable by static
function test_loop($x, $y)
{
static $x_values = array();
$x = $x + 1;
if($x < 10)
{
$x_values[] = $x."#"; // insert item 2#,3#,4# into array
}
//loop again if y is not = 3;
$y = $y + 1;
if($y < 5)
{
return test_loop($x, $y); // need to put two return. 1 at recall loop function, another 1 at else statement
}else{
echo "gula"; //need to put the echo at else statement
return $x_values;
}
}
function abc(){
$bababa = test_loop(1,0);
foreach($bababa as $fpackage_id)
{
echo $fpackage_id;
}
}
abc();
-------------------------------------------------
Split a big functions into many small functions and pass value by many array from Controllers to Views sample at :
1) https://stackoverflow.com/questions/61550787/how-to-insert-key-and-value-of-an-array-into-another-array-key
2)https://stackoverflow.com/questions/61548454/how-to-pass-array-multiple-array-key-and-value-from-controllers-to-views-in-code
-----------------------------
Migrate website to new server :
Edit 3 files :
1) /application/config/constant.php
2) /application/config/database.php
3) /application/config/config.php
if page error : No input file specified.
Solution : go edit .htaccess file add ? after index.php become index.php?
for domain like member.inferlion.com, htaccess should looks like :
If 404 not found, then check folder permission. Change folder permission from 0750 to 0755 (tick allow read and execute for world)
If 403 error, then should be .htaccess file rule problem
If 403 error or ajax error, then delete / from ajax code url. Eg : 2aek.com/ replace by 2aek.com
If 403 error or ajax error, then go to config.php turn false ALL $config['csrf_protection'] = FALSE;
If 500 error, it is database connection problem, change 2aek_db to olyemall_db, and change 2aek_zac1987 user to olyemall_zac1987 user
If sub folder, config.php should look like this :
else if($_SERVER['HTTP_HOST'] == "2aek.com")
{
$base_url = 'https://2aek.com/zac-work/';
}
----------------------------
change Email Sender FROM for email verification :
file path : application > config > constants.php
database : tbl_site_setting > scroll to right find column Email.
---------------------------
php mysql code file path at :
application > controllers > member > Register.php
--------------------------
order package save poa into pdf file code path :
controllers/member/Product.php
-------------------------
To echo $total_invested on dashboard
file 1 : application/views/member/dashboard.php : $this->load->view("member/inc_statistics");
file 2 : application/views/member/inc_statistics.php : $total_invested;
file 3 : application/libraries/Common.php : function getTotalInvested($user_id=0){}
file 4 : application/controllers/member/Dashboard.php : $data['total_invested'] = $this->common->getTotalInvested();
To echo $member_active_status on dashboard
file 1 : application/views/member/dashboard.php : $member_active_status = $this->Member_model->checkMemberKycStatus()
file 2 : application/models/Member_model.php : function checkMemberKycStatus($user_id=0){}
-----------------------
To change timedate timezone:
application/constant.php
------------------------
javascript and jquery file at
application/views/member/inc_common_validation_all.php
-----------------------
To check if package purchase date is greater than a specific date :
To check if today is 3 days after package purchase date :
1) mysql WHERE .... && ((created_on < '2020-02-18') || (created_on > '2020-02-18' && created_on <= SUBDATE(CURDATE(), INTERVAL 3 DAY)))";
To check if today is before 7 days expiry :
2) mysql WHERE ...
AND ((o.created_on < '2020-02-18') OR (o.created_on > '2020-02-18' AND o.created_on <= SUBDATE(CURDATE(), INTERVAL 3 DAY)))
3) WHERE... AND DATEDIFF(CURDATE(),created_on) >= 2
-----------------------------------------------
javascript function change_status(id, url) is save at
application/views/secure/inc_footer.php
-----------------------------------------------
error 404 page not found
if u want to create a new page,
Step 1 : create html at view/withdraw_flamingo.php (must 1st character capital big, _ small capital
Step 2 : create php at controllers/withdraw_flamingo.php
Step 3 : add class and load->view at the php file that u created on (Step2) :
class Withdraw_flamingo extends CI_Controller
{ function index($tran_account=0)
{
$this->load->view('member/withdraw_flamingo ', $data);
}
}
----------------------------------------------
if ajax error, then delete html may fix ajax error
-------------------------------------------
if return 1 instead of 1500
then change
$data['Rows1'] = $Result1->row_array();
to
$data['Rows1'] = $Result1->result_array();
--------------------------------------------
ajax sort has bug?
file path : application/controllers/secure/Manage_flamingo_product_orders.php
$column_order = array('u.id','u.id','u.created_on','unique_code', 'm.first_name AS fname', 'u.package_amount', 'u.user_sign', 'u.auto_renew','u.status', 'u.poa_path', 'u.package_id');
The code above must in correct sequence from left to right fields on html table in views folder.
-----------------------------------------
ajax echo database record on to html table
file path : application/controllers/secure/Manage_flamingo_product_orders.php
foreach ($Rows as $Res)
{
$no++;
$row = array();
$row[] = $no;
$row[] = 'F'.PACKAGE_PREFIX.str_pad($Res['id'], 6, '0', STR_PAD_LEFT);
$row[] = $Res['created_on'];
$row[] = $Res['unique_code'];
$row[] = $Res['fname'];
$row[] = $Res['package_amount'];
----------------------------------------
simple database query echo on html page :
$placement = $this->common->getSelectedOneRow("placement", "tbl_user_master", "WHERE user_id = '".$this->session->userdata('WDW_MEMBER_LOGIN_ID')."'");
if ($placement['placement'] == ""){
---------------------------------------------
SUM(amount) no need to use getAllRow, you can use getSelectedOneRow :
$withdraw_pending = $this->getSelectedOneRow("Sum(withdraw_amount) AS withdraw_pending_amount","tbl_withdraw_request","WHERE user_id = '".$user_id."' AND status=0 AND tran_account=$tran_account");
-------------------------------------------
Select multiple records from database :
$withdraw_pending = $this->common->getAllRec("Sum(withdraw_amount) AS withdraw_pending_amount","tbl_withdraw_request","WHERE user_id = '".$user_id."' AND status=0 AND tran_account=$tran_account");
foreach ($withdraw_pending as $row2)
{
echo $row2["withdraw_amount"]."
";
//$pending_amount=$row2["withdraw_amount"];
//$total_pending+=$pending_amount;
}
-----------------------------------------------
SQL statement Where Clause && syntax :
$this->common->updateRecord("tbl_ewallet",$up_data1, "customerid = '" . $user_id_arr . "' AND id = '" . $bonus_id_arr . "'");
--------------------------------------------
If purchase package on sat, then wont get % jumping and profit on Tues, only will get them on Wednesday :
using mysql WHERE .... AND ((DAYOFWEEK(created_on) IN(0,1,2,3,4,6)) OR (DAYOFWEEK(created_on) = 5 AND DAYOFWEEK('".CURRENTDATE."') = 1 AND DATEDIFF('".CURRENTDATE."',created_on) >= 4) OR (DAYOFWEEK(created_on) = 5 AND DAYOFWEEK('".CURRENTDATE."') IN(0,2,3,4,5,6)))
ORDER BY created_on ASC;");
or using php
$purchase_day = date('D', strtotime($created_on));
$today_date = date('Y-m-d', time());
$diff_day = date_diff(new DateTime($today_date),new DateTime($created_on));
//echo $diff_day->format("%a"); //haha
//if($diff_day->format("%a") > 60){ echo "yes"; }else{echo "No";}
//echo $purchase_day;
if ($purchase_day == "Sat" && date("l") == "Tuesday" && $diff_day->format("%a") < 7 ){
$created_on = 0;
}
-------------------------
ajax call php function :
Search "drawCallBack" on page (inside ajax there). Paste the following code under this line :
//page loaded immediately check if 1st flamingo package auto renew is yes or no, then update all top up package auto renew in database
var arTp = $('.artp');
var arTpArray=[];
for(var i=0; i
}
var arPurchase = $(".arpp").attr('id');
if (arPurchase == "Yes"){ var oppAR = "No"; var currentArP = 1;}
if (arPurchase == "No"){ var oppAR = "Yes"; var currentArP = 0;}
if ($.inArray(oppAR,arTpArray) > -1) {
update_auto_renew_to_database(currentArP);
}
---------------------------------------
Ajax Datatable error / 500 error mostly because mysql syntax error,
Use filezilla only can access this directory username/domain/logs/domain/https or http (use notepad to open and check the error log)
you may create a html page try to query database by your mysql to check where is the syntax error.
Previous case was WHERE order_method == 0; is wrong, should be order_method = 0;
----------------------------------------
WEEKDAY : 0=Monday, 1=Tuesday, 2=Wednesday, 3=Thursday, 4=Friday, 5=Saturday, 6=Sunday
-------------------------------------
$last_top_up_day = date('d/m/Y',strtotime('+21 days',strtotime(str_replace('/', '-', $flamingo_order_approved_date)))) . PHP_EOL;
-----------------------------------
mysql update multiple rows
$up_data1['star_bonus_per'] = $v1_star_bonus = $this->common->custom_safe_string($this->input->post('v1_star_bonus')); $up_data2['star_bonus_per'] = $v1_star_bonus = $this->common->custom_safe_string($this->input->post('v2_star_bonus')); $up_data3['star_bonus_per'] = $v1_star_bonus = $this->common->custom_safe_string($this->input->post('v3_star_bonus')); $up_data4['star_bonus_per'] = $v1_star_bonus = $this->common->custom_safe_string($this->input->post('v4_star_bonus')); $up_data5['star_bonus_per'] = $v1_star_bonus = $this->common->custom_safe_string($this->input->post('v5_star_bonus')); $this->common->updateRecord('tbl_agent_qualificaiton',$up_data1,"id=1"); $this->common->updateRecord('tbl_agent_qualificaiton',$up_data2,"id=2"); $this->common->updateRecord('tbl_agent_qualificaiton',$up_data3,"id=3"); $this->common->updateRecord('tbl_agent_qualificaiton',$up_data4,"id=4"); $this->common->updateRecord('tbl_agent_qualificaiton',$up_data5,"id=5");
----------------------------------------
change all email address in database
UPDATE tbl_user_master SET user_email = CONCAT( `unique_code` , "@test.com" );
-----------------------------------------
Array with value only, without key :
global $temp_paid_star_bonus_package; //declare at function getChildren() && function printList() $temp_paid_star_bonus_package = array(); //declare at function getChildren() $single_package_id= explode("#",$multiple_package_id); foreach($single_package_id as $package_id) { if($package_id != 0) { $temp_paid_star_bonus_package[] = $package_id; //add value into array } } foreach($temp_paid_star_bonus_package as $fpackage_id) //retrive value from array and insert into database { $up_data1['star_bonus_paid'] = 1; $this->common->updateRecord('tbl_flamingo_product_order',$up_data1,'id='.$fpackage_id); }
----------------------------------------------
Array with key and value :
if got bug then might be because u didn't declare $temp_paid_breakaway_bonus_ref = array(); at the first function index()
$member_got_bonus_already=array(); //declare at function index()
global $member_got_bonus_already; //declare at function printList()
//deduct previous already paid out star bonus
if (@array_key_exists($userid, $member_got_bonus_already)) //retrive value from array
{ //check array if this member already get bonus previously
$individul_paid_bonus_rate = explode("#",$member_got_bonus_already[$userid]);
foreach($individul_paid_bonus_rate as $i_p_b_r) {
$final_star_bonus_rate = $final_star_bonus_rate - $i_p_b_r;
}
$star_bonus_receive = $individu_total_package_size * $final_star_bonus_rate / 100;
}else{
}
//insert value into array sample 1 :
if($star_bonus_receive != "" || $star_bonus_receive != 0)
{
if (@array_key_exists($userid, $member_got_bonus_already)) //userid 123 => bonus 15# bonus 200 # bonus 39
{
$member_got_bonus_already[$userid] = $member_got_bonus_already[$userid] . "#" . $final_star_bonus_rate;
}else{
$member_got_bonus_already[$userid] = $final_star_bonus_rate; //save member_id and bonus_rate into array, so later his upline will deduct bonus_rate from this array.this array.
}
}
//insert value into array sample 2 :
foreach($single_package_id as $package_id)
{
if($package_id != 0)
{
if (isset($package_id) AND isset($temp_paid_star_bonus_package) AND array_key_exists($package_id,$temp_paid_star_bonus_package))
{
$temp_paid_star_bonus_package[$package_id] = $temp_paid_star_bonus_package[$package_id] + $final_star_bonus_rate;
}else{
$temp_paid_star_bonus_package[$package_id] = $final_star_bonus_rate ;
}
}
}
//if want to retrive both keyand value
foreach ($member_got_bonus_already as $key => $value )
{
echo $key;
echo $value;
}
--------------------------------------------------
NOT Exist mysql query :
$user_tree = $this->getAllRec("u.user_id,(SELECT COUNT(o.user_id) FROM tbl_user_master o WHERE o.sponsor_id = u.user_id AND o.user_type = 2 AND o.status = 1 AND NOT EXISTS (
SELECT p.user_id
FROM tbl_flamingo_product_order p
WHERE (p.user_id = u.user_id OR p.user_id = o.user_id) AND p.status=3)) AS ChildCnt",
"tbl_user_master u",
"WHERE u.sponsor_id = '".$user_id."' AND u.user_type = 2 AND u.status =1 AND NOT EXISTS (
SELECT p.user_id
FROM tbl_flamingo_product_order p
WHERE p.user_id = u.user_id AND p.status=3)");
Becareful, if upline is not exist in other table, then won't show this uplines, so will causing bug not showing all downlines of this upline. (missing downlines bug)
--------------------------------------------------
NOT Exist mysql query WHERE id in array ()
$data['member'] = $member = $this->common->getAllRec("o.user_id,o.username,o.first_name, o.last_name",
"tbl_user_master o",
"WHERE o.user_id IN (".$my_tree_ids.") and o.status != 3 AND o.user_type = 2
AND NOT EXISTS (
SELECT p.user_id
FROM tbl_flamingo_product_order p
WHERE p.user_id = o.user_id AND p.status=3)
ORDER BY o.first_name ASC, o.last_name ASC");
}
Save all agents id in array, then Where id IN array
----------------------------------------------------
Return string that extended by recursive loop :
Live demo at lifestartoday.com>library>common.php>loop_get_three_uplines()
Simple Live demo 2 at generate_user_unique_code() function at common.php file
Method 1 : Pass variable in function argument :
function test_loop($x_values,$x, $y)
{
$x = $x + 1;
if($x < 10)
{
$x_values[] = $x."#"; // insert item 2#,3#,4# into array
}
//loop again if y is not = 3;
$y = $y + 1;
if($y < 5)
{
return $x_values = test_loop($x_values, $x, $y); // need to put two return. 1 at recall loop function, another 1 at else statement
}else{
echo "gula"; //need to put the echo at else statement
return $x_values;
}
}
function abc(){
$bababa = test_loop([],1,0);
foreach($bababa as $fpackage_id)
{
echo $fpackage_id;
}
}
abc();
---------------------------------------------------
Method 2 : declare variable by static
function test_loop($x, $y)
{
static $x_values = array();
$x = $x + 1;
if($x < 10)
{
$x_values[] = $x."#"; // insert item 2#,3#,4# into array
}
//loop again if y is not = 3;
$y = $y + 1;
if($y < 5)
{
return test_loop($x, $y); // need to put two return. 1 at recall loop function, another 1 at else statement
}else{
echo "gula"; //need to put the echo at else statement
return $x_values;
}
}
function abc(){
$bababa = test_loop(1,0);
foreach($bababa as $fpackage_id)
{
echo $fpackage_id;
}
}
abc();
-------------------------------------------------
Split a big functions into many small functions and pass value by many array from Controllers to Views sample at :
1) https://stackoverflow.com/questions/61550787/how-to-insert-key-and-value-of-an-array-into-another-array-key
2)https://stackoverflow.com/questions/61548454/how-to-pass-array-multiple-array-key-and-value-from-controllers-to-views-in-code
3) Common.php > function cal_sponsor_bonus()
4) Common.php > function loop_get_three_uplines()
5) Controllers & Views / Direct_sponsor_bonus_setting.php
--------------------------------------------------
error : Severity: Warning --> ini_set(): Headers already sent. You cannot change
maybe because u put end of php tag ?> at bottom of page, u need to delete it.
-----------------------------------
There are two difference recursive loop for 2 difference DSB payout for LST project common.php file :
1) direct sponsor bonus payout immediately on new package order :
recursive loop at function direct_sponsor_bonus_payout_immediately()
2) direct sponsor bonus payout generated by admin manually :
recursive loop at function loop_get_three_uplines()
---------------------------------------------------
Simple recursive loop to get all downlines :
function downline_v5_ids($user_id=0,$mydowns)
{
if($user_id != 0)
{
$user_tree = $this->getAllRec("u.user_id, u.rank, (SELECT COUNT(user_id) FROM tbl_user_master WHERE sponsor_id = u.user_id AND user_type = 2 AND status =1) AS ChildCnt",
"tbl_user_master u",
"WHERE u.sponsor_id = '".$user_id."' AND u.user_type = 2 AND u.status =1");
/* echo $this->db->last_query(); */
if(count($user_tree) > 0)
{
foreach($user_tree as $Res)
{
if($Res['rank'] == 1)
{
$mydowns[]=$Res['user_id'];
}
if($Res['ChildCnt'] > 0)
{
//if(!is_array($mydowns)){ //prevent error Severity: Notice --> Array to string conversion
$mydowns = $this->downline_v5_ids($Res['user_id'], $mydowns);
//}
}
}
}
}
return $mydowns;
}
---------------------------------------------------------
Get Method / Get value from URL :
example url : www.lifestartoday.com/member/wallets/report/3-1.html
1)wallets is php file name at Controllers/Wallets.php
2)report is function name in the php file.
3)3-1 is argument in the function.
So at Controller/Wallets.php u will see a function
function report($tran_account_ref_id)
{
$explode_arr = explode("-",$tran_account_ref_id);
$tran_account = $explode_arr[0];
$ref_id = $explode_arr[1];
}
----------------------------------------
2) cannot update records WHERE id In (12,32,47). Solution is either add quote for string or remove quote for number :
----------------------------------
DataTables warning or responded with a status of 403 ()
Make sure Ajax url don't have / at the end of url. Eg :
----------------------------------
Language Chinese English :
----------------------------------
$total_direct_all_child_cnt = count($this->getAllRec("u.user_id, u.username, u.unique_code, u.user_email, p.id, p.status", "tbl_user_master u LEFT JOIN tbl_product_order p ON p.user_id = u.user_id","WHERE u.sponsor_id = '".$user_id."' AND u.status = 1 AND u.user_type = 2 AND p.status = 3", "GROUP BY u.user_id"));
----------------------------------
To debug :
----------------------------------
To pop up request security password for withdraw page :
----------------------------------
To debug direct sponsor bonus printlist(), just change hidden to visible
----------------------------------
Network tree chinese word not show :
Solution at https://stackoverflow.com/questions/8218230/php-domdocument-loadhtml-not-encoding-utf-8-correctly
File Directory : member/Controller/Network2.php > get_high_level_tree_member_data()
File Directory : member/views/network2.php > foreach($user_tree as $Res){
----------------------------------
Get latest new inserted id :
----------------------------------
Invalid argument supplied for foreach()
array foreach loop show error if array is empty :
----------------------------------
Show Pop up : views/member/dashboard.php : views/member/dashboard.php :
Controller/member/Dashboard.php :
----------------------------------
one line easy : $prize_pool_db=$this->common->getSelectedOneField("prize_pool","tbl_site_setting","where id=1");
----------------------------------
mysql select date less than or equal today :
----------------------------------
Convert datetime format :
----------------------------------
Mysql WHERE compare date :
----------------------------------
Test php mailer :
copy paste the below code onto Controller/Dashboard.php below code line $this
----------------------------------
Show records from two tables / 2 tables / multiple tables to javascript DATATABLE :
----------------------------------
HTML textbox is not updated after form submitted update database record?
You are fetching the data before updating it. Just move the fetch below like this:
----------------------------------
Cron job :
To debug it, just copy paste open the link http://client.bfm.expert/index.php/cron_weekly_profit
Then check error log file.
To test it, check :
1) receive email on each run cron script?
2) check database tbl_wallet got inserted new record?
3) check application/log/ error, if got error, then won't be able to receive email and won't be able to insert record in database
To stop running cron job, change the following line of code :
----------------------------------
Compare 2 dates :
Modify day of a date :
----------------------------------
jquery validation :
jquery validation max: other input
----------------------------------
jquery make div become the same height with other div :
----------------------------------
count record row :
----------------------------------
Jquery get string before and after a character :
----------------------------------
prevent submit button double click twice
----------------------------------
check database record date is this month
----------------------------------
Those errors are because you didn't include inc_footer.php :
1) checkboxlist_all_new error
2) status active inactive toogle error
3) change_status error
4) delete_all error
Upload photo extension small letter. Solution at model/xxx.-model.php edit:
$config['file_ext_tolower'] = TRUE;
$this->upload->initialize($config);
Bootstrap Modal cannot close.
make sure dont have repeating the same id of div in two files :
1) modal_view_tree_member_data.php
2) dashboard.php
Then if using bootstrap v5 instead of v4, solution :
----------------------------------
Bug : Boostrap 5 Modal cannot open.
Solution : Change data-toggle="modal" data-target="#lostpassword" TO :
data-bs-toggle="modal" data-bs-target="#lostpassword"
Error : Cannot reinitialise DataTable.
Solution : Delete "datatable" class from div or table so that it won't auto apply datatable. Then manually apply datatable by jquery :
----------------------------------
Jquery clipboard copy text from hidden texbox. Solution is at wcss_member.css
----------------------------------
if $left_id and $right_id is not working, then it should be database record 0 vs null, so php compare !isset(left_id) for record 0 is not working.
network tree show more gap / space beside name?
go to : /assets/admin/user_tree/jquery.treegrid.css to change width : 16 to 22px at .treegrid-expander
Case insensitive Like clause on pdo mysql :
Allow Upload zip rar zip files :
if user not yet sign agreement, when user login account, it will redirect to disclosure or upload document page :
Fail to save Signature image because 2 reasons :
1) when user login, it always redirect user to disclose.php to force user sign the signature, so Ajax cannot open save.php because always redirect to disclosure.php , so you need to allow open save.php
at application/models/Member_model.php : Change :
To :
2) You must update disclosure_flag = 1 to database before open save.php to save the signature image. Because disclosure_flag = 0 on database always redirect user to disclose.php causing fail to open save.php
Apply css to all tables but not 1 specific table :
Click Button prevent submitting form :
get value from Checkbox and mysql insert to database :
Database checkbox value record file must be TEXT or long_TEXT.
totalfinance.asia/application/controllers/secure/Manage_members.php
totalfinance.asia/application/views/secure/modal_view_progress.php
totalfinance.asia/application/controllers/member/Dashboard.php
totalfinance.asia/application/views/member/dashboard.php
Posted by Zac1987 on
21 December, 2019
0 comments