| Server IP : 10.200.247.200 / Your IP : 216.73.217.19 Web Server : Apache System : Linux synergy-usa-sites 6.8.0-138-generic #138-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 31 22:41:49 UTC 2026 x86_64 User : jeremy ( 1001) PHP Version : 8.4.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/usa_sites/pcisecureform.com/lcapi/ |
Upload File : |
<?
/**
* CreateUser.php
*
* This file will create a new user within the Learning Center CRM.
* @package LCAPI
* @see UserSignup
* @author Patrick Miller <patrick@spcoaching.com>
* @version 0.1
* @copyright Copywrite (c) Synergy Pro Marketing
*/
/* *
* Run Phpdocumentor. TODO: Need to put this in a script.
* phpdoc -o HTML:Smarty:HandS -f /home/learning/www/lcapi/CreateUser.php,/home/learning/www/lcapi/inc/UserSignup.php -t /home/learning/www/lcapi/docs-new
*/
/**
* @access private
*/
require_once($_SERVER['DOCUMENT_ROOT'].'/php/db_config_lc_user.php');
/**
* @access private
*/
require_once("{$_SERVER["DOCUMENT_ROOT"]}/lcapi/inc/UserSignup.php");
/**
* @access private
*/
require_once("{$_SERVER["DOCUMENT_ROOT"]}/lcapi/inc/Logger.php");
/**
* @access private
*/
require_once("{$_SERVER["DOCUMENT_ROOT"]}/lcapi/inc/common.php");
$site = (isset($_REQUEST['site']) && $_REQUEST['site'] != '') ? preg_replace('/[^a-zA-Z0-9]/','',$_REQUEST['site']) : '';
$sendemail = ($_REQUEST['sendemail'] == 'no') ? 'no' : 'yes';
$email_type = (isset($_REQUEST['email_type']) && $_REQUEST['email_type'] != '') ? $_REQUEST['email_type'] : 'Welcome';
if(empty($site)) {
SendError(__FILE__." at line ".__LINE__, "Failure to connect to database (No Site Passed)");
die("Failure: Unable to connect to database.");
}
if(!$db = connect_lc2user_new('lc2'.$site.'_lc')) {
SendError(__FILE__." at line ".__LINE__, "Failure to connect to database (lc2".$site."_lc). MySQL: ".$db->error());
die("Failure: Unable to connect to database.");
}
if(in_array($_REQUEST['email'],array('browngraeve43@gmail.com','browngraeve@gmail.com')) || in_array($_REQUEST['phone'],array('8134696478','8132058990','8132431913'))) {
//This lady is crazy and we are not going to let her sign up again
die("Failure: Could not create user account.");
}
//$db->debug_all = true;
//$db->show_errors();
SendDebug(__FILE__);
$user = new UserSignup($db, $site);
//Check to see if they already got created, and they just refreshed.
$is_there = $db->get_results("SELECT id FROM lc2{$site}_lc.lc_reseller WHERE email='".$db->clean($_REQUEST['email'])."' AND DATE(date_ordered)=CURDATE()");
if(!empty($is_there[0]->id)) {
$user->userid = $is_there[0]->id;
}
$aid = 0;
if(!empty($_REQUEST['allocatorid'])) {
$aid = $_REQUEST['allocatorid'];
}
$cc_num = '';
if(!empty($_REQUEST['cc_num'])) {
$cc_num = $_REQUEST['cc_num'];
}
if(!empty($aid) && empty($cc_num)) {
$has_customer_vault = $db->get_results("SELECT customer_vault_id,bin_number,last_four,exp_month,exp_year
FROM allocator.leads_customer_vault
WHERE lead_id='".$db->clean($aid)."'
ORDER BY id DESC LIMIT 1");
if(!empty($has_customer_vault)) {
$user->customer_vault_id = $has_customer_vault[0]->customer_vault_id;
$_POST['cc_num'] = $has_customer_vault[0]->bin_number.'******'.$has_customer_vault[0]->last_four;
$_POST['cc_exp_month'] = $has_customer_vault[0]->exp_month;
$_POST['cc_exp_year'] = $has_customer_vault[0]->exp_year;
}
} else {
$has_customer_vault = false;
}
if (!$user->LoadUser($site)) {
SendError("LoadUser() in ".__FILE__." at line ".__LINE__,$user->lasterror);
die("Failure: " . $user->lasterror);
}
if ($user->leadid == "") {
if (!$user->CreateLead()) {
SendError("CreateLead() in ".__FILE__." at line ".__LINE__,$user->lasterror);
die("Failure: Unable to create lead. " . $user->lasterror);
}
}
if(empty($user->userid)) {
//Check for fraud bot
$lead_info = $db->get_results("SELECT email,phone FROM lc2{$user->site}_lc.lc_leads WHERE id='".$db->clean($user->leadid)."'");
if($lead_info[0]->phone!=$user->phone && $lead_info[0]->email!=$user->email) {
$db->query("INSERT INTO lc2admin.fraud_signups
(
site_code
,lead_id
,lead_email
,lead_phone
,first
,last
,email
,phone
,bin
,last_four
,ts
) VALUES (
'".$db->clean($user->site)."'
,'".$db->clean($user->leadid)."'
,'".$db->clean($lead_info[0]->email)."'
,'".$db->clean($lead_info[0]->phone)."'
,'".$db->clean($user->fname)."'
,'".$db->clean($user->lname)."'
,'".$db->clean($user->email)."'
,'".$db->clean($user->phone)."'
,'".$db->clean(substr($user->cc_num,0,6))."'
,'".$db->clean(substr($user->cc_num,-4))."'
,NOW()
)");
ob_start();
$db->debug();
$email_body = ob_get_clean();
$is_there = $db->get_results("SELECT COUNT(*) as c FROM lc2admin.fraud_signups WHERE ts >= '".date('Y-m-d H:i:s',strtotime('-10 minute'))."'");
if($is_there[0]->c>5) {
$user->mailgun_send_message('heinz57@gmail.com','NoReply@surfcrm.com','Potential Fraud Signup','<p>There have been '.$is_there[0]->c.' potential fraud signups in the last 10 minutes.</p>'.nl2br($email_body),1,'Fraud Bot','','','',0);
}
//die("Failure: Decline");
}
//New variable for billing to tell it to void on bad cvv or avs response.
$user->creating_new_client = true;
//Check if we have tried to charge them before
$previous_proc_res = $db->get_results("SELECT proc_id FROM lc2{$user->site}_lc.lc_billing WHERE lead_id='".$db->clean($user->leadid)."' ORDER BY bill_time DESC LIMIT 1");
if(!empty($previous_proc_res)) {
if(!empty($previous_proc_res[0]->proc_id)) {
$user->rebill_proc_id = $previous_proc_res[0]->proc_id;
}
}
if (!$user->ChargeUser()) {
$error = $user->lasterror;
$user->SaveBillingResult();
SendError("ChargeUser() in ".__FILE__." at line ".__LINE__,$error);
$aid = 0;
$result = $db->get_results("SELECT id FROM allocator.leads WHERE leaddb='{$user->site}' AND leadtype='partials' AND email='{$user->email}'");
if(!empty($result)) {
$aid = $result[0]->id;
if($error=='REJECTED CONTACT CUST SERV') {
$db->query("UPDATE allocator.leads SET disposition='Do Not Call' WHERE id='".$db->clean($aid)."'");
}
}
$db->query("INSERT INTO lc2admin.marketer_credit_card_errors
(
username
,site_code
,lead_id
,allocator_id
,error_message
,ts
) VALUES (
'".$db->clean($user->sid)."'
,'".$db->clean($user->site)."'
,'".$db->clean($user->leadid)."'
,'".$db->clean($aid)."'
,'".$db->clean($error)."'
,NOW()
)");
if($error=='Pick up card - SF') {
$error = '"Pick Up Card" is a payment response from your bank declining the transaction because they don\'t recognize the transaction. You may have received an email or a text notification asking if you recognize the transaction. You may have to call your bank to let them know the transaction is valid. Once you resolved it, please rerun the transaction.';
$is_there = $db->get_results("SELECT id FROM lc2admin.pick_up_card_sf_attempts
WHERE site_code='".$db->clean($user->site)."'
AND lead_id='".$db->clean($user->leadid)."'
AND ts >= CURDATE()");
if(empty($is_there)) {
$db->query("INSERT INTO lc2admin.pick_up_card_sf_attempts
(
site_code
,lead_id
,did_approve
,ts
) VALUES (
'".$db->clean($user->site)."'
,'".$db->clean($user->leadid)."'
,'0'
,NOW()
)");
}
}
die("Failure:" . $error);
}
//check the pick up card - sf db
$is_there = $db->get_results("SELECT id FROM lc2admin.pick_up_card_sf_attempts
WHERE site_code='".$db->clean($user->site)."'
AND lead_id='".$db->clean($user->leadid)."'
ORDER BY id DESC LIMIT 1");
if(!empty($is_there)) {
$db->query("UPDATE lc2admin.pick_up_card_sf_attempts
SET did_approve=1
WHERE id='".$db->clean($is_there[0]->id)."'");
}
if (!$user->CreateAccount()) {
// Uh-oh! If we got here it means we billed the user
// but we can't create their account!
// Try to save the billing information, if possible
$error = $user->lasterror;
$user->SaveBillingResult();
SendError("CreateAccount() in ".__FILE__." at line ".__LINE__,$error);
$aid = 0;
$result = $db->get_results("SELECT id FROM allocator.leads WHERE leaddb='{$user->site}' AND leadtype='partials' AND email='{$user->email}'");
if(!empty($result)) {
$aid = $result[0]->id;
}
$db->query("INSERT INTO lc2admin.marketer_credit_card_errors
(
username
,site_code
,lead_id
,allocator_id
,error_message
,ts
) VALUES (
'".$db->clean($user->sid)."'
,'".$db->clean($user->site)."'
,'".$db->clean($user->leadid)."'
,'".$db->clean($aid)."'
,'".$db->clean($error)."'
,NOW()
)");
die("Failure: Unable to create user account. " . $error);
}
/*
if(empty($user->customer_vault_id)) {
if(!empty($_REQUEST['allocatorid'])) {
$aid = $_REQUEST['allocatorid'];
}
if(empty($aid)) {
$result = $db->get_results("SELECT id FROM allocator.leads WHERE leaddb='{$user->site}' AND leadtype='partials' AND email='{$user->email}'");
if(!empty($result)) {
$aid = $result[0]->id;
}
}
if(!empty($aid)) {
$has_customer_vault = $db->get_results("SELECT customer_vault_id,bin_number,last_four,exp_month,exp_year
FROM allocator.leads_customer_vault
WHERE lead_id='".$db->clean($aid)."'");
if(!empty($has_customer_vault)) {
$user->customer_vault_id = $has_customer_vault[0]->customer_vault_id;
$db->query("UPDATE lc2{$user->site}_lc.lc_reseller
SET bin_number='".$db->clean($has_customer_vault[0]->bin_number)."'
,customer_vault_id='".$db->clean($has_customer_vault[0]->customer_vault_id)."'
WHERE id='".$db->clean($user->userid)."'");
} else {
$user->sitedb->AddToCustomerVault($user);
}
} else {
}
}*/
//Add this user to the customer vault
$user->sitedb->AddToCustomerVault($user);
/*if(!empty($aid)) {
$db->query("DELETE FROM allocator.leads_customer_vault WHERE lead_id='".$db->clean($aid)."'");
}*/
if (!$user->SaveBillingResult())
{
// OK, not a HUGE deal, but a slight problem nonetheless.
// We were able to create an account for the user but we weren't able
// to save their billing information. This is not a fatal error
// the function SaveBillingResult takes care of sending us some debug info
}
//Fix issue with some people missing their zip or state
if($user->zip=='') {
$res2 = $db->get_results("SELECT zip FROM lc2{$user->site}_lc.lc_leads WHERE id='".$db->clean($user->leadid)."'");
if(!empty($res2[0]->zip)) {
$db->query("UPDATE lc2{$user->site}_lc.lc_reseller
SET zip='".$db->clean($res2[0]->zip)."'
WHERE id='".$db->clean($user->userid)."'");
}
}
if($user->state=='') {
$res2 = $db->get_results("SELECT state FROM lc2{$user->site}_lc.lc_leads WHERE id='".$db->clean($user->leadid)."'");
if(!empty($res2[0]->state)) {
$db->query("UPDATE lc2{$user->site}_lc.lc_reseller
SET state='".$db->clean($res2[0]->state)."'
WHERE id='".$db->clean($user->userid)."'");
}
}
// If we got here then everything is good!
// Send them their welcome email!
// if sendemail is set to 'no', then don't send the welcome email
if ($sendemail == 'yes')
{
$user->SendEmail($email_type);
}
if(empty($user->text_phone) || strlen($user->text_phone)<10) {
$user->text_phone = $user->phone;
}
if(strlen($user->text_phone)>10) {
$user->text_phone = substr($user->text_phone,-10);
}
if(strlen($user->text_phone)==10)
{
include_once($_SERVER['DOCUMENT_ROOT'].'/php/txtwire_usa.php');
$sres = $db->get_results("SELECT site_name,site_domain,phone FROM lc2admin.site WHERE site_code='".$db->clean($site)."'");
$sites_redirect = array(
'agf'=>'https://agfvx.com/'
,'agg'=>'https://aggvx.com/'
,'fa'=>'https://fappvx.com/'
,'ggus'=>'https://ggusvx.com/'
,'nusaf'=>'https://nusafvx.com/'
,'nusag'=>'https://nusagvx.com/'
,'usafa'=>'https://usafavx.com/'
,'usaga'=>'https://usagavx.com/'
,'usagaorg'=>'https://usagaorgvx.com/'
,'usft'=>'https://usftvx.com/'
);
$bar = str_split($user->userid.'.13');
$foo = '';
$letters = range('a','z');
foreach($bar as $b)
{
$foo .= (!empty($letters[$b])) ? $letters[$b] : $b;
}
$link = $sites_redirect[$site] . trim($foo);
$send_text = 'yes';
if(!empty($_REQUEST['sendtext'])) {
if($_REQUEST['sendtext']=='no') {
$send_text = 'no';
}
}
if($email_type=='Confirmation Subscription Delay') {
$send_text = 'no';
}
if(false && $send_text=='yes') {
$body = "Congrats on your enrollment.\nClick here to log in: {$link}\nFor Q's call: ".(substr($sres[0]->phone,0,3).'-'.substr($sres[0]->phone,3,3).'-'.substr($sres[0]->phone,6,4))."\n\nReply STOP to opt-out";
send_text($user->text_phone,$body,'usa','Confirmation',$site);
$db->query("INSERT INTO lc2admin.texts
(
site_code
,client_id
,result
,comments
,sender_name
,ts
) VALUES (
'".$db->clean($site)."'
,'".$db->clean($user->userid)."'
,'TEXT'
,'".$db->clean($body)."'
,'SurfCRM'
,NOW()
)");
$db->query("
INSERT INTO surfcrm.notes
(
timeclock_id,
site_code,
client_type,
client_id,
`date`,
type,
note,
username,
first_name,
last_name,
active
)
VALUES
(
'0',
'".$db->clean($site)."',
'clients',
'".$db->clean($user->userid)."',
NOW(),
'Text',
'Sent From /lcapi/CreateUser.php Confirmation Text: \n".$db->clean($body)."',
'SurfCRM',
'Surf',
'SurfCRM',
'1'
)
");
}
}
}
/*if(in_array($user->site,array('op2','mos','ebs','safe','safe1','mebi','mebibj','hcg','extreme')))
{
//inserts new user into joomla backend for dbgroup-inc
if(add_user_to_joomla($user->fname." ".$user->lname, $user->email, $user->email, $user->zip, $user->site) !== true)
{
SendError("add_user_to_joomla() in ".__FILE__." at line ".__LINE__,$result);
}
}*/
die("Success: " . $user->userid);