@ 2015-04-21T01:49:53Z <?php
/**
* @file requestUserInfo.php
* @TIME
* @brief Brief
* @Author Author
* @Website www.lotto-pass.cn
*
*/
define('IN_ECS', true);
//echo "<p>in request:";
//print_r($_POST);
$current_path = dirname(__FILE__);
$base_path = substr($current_path, 0, strlen($current_path) - strlen("/webservice"));
require_once($base_path . '/includes/init.php');
require_once(ROOT_PATH . 'includes/cls_json.php');
require_once(ROOT_PATH . 'includes/lib_common.php');
// echo "<p>After include:";
require_once (ROOT_PATH . 'includes/utilities/dbutilities.php');
require_once (ROOT_PATH . 'includes/webservice/webserviceutilities.php');
require_once (ROOT_PATH . 'includes/utilities/userUtilities.php');
$device_id = getHttpRequest("device_id");
$trans_time = getHttpRequest("trans_time");
$card_number = getHttpRequest("card_number");
$sessionId = getHttpRequest("sessionId");
$pSessionId = getHttpRequest("pSessionId");
$sessionTime = $trans_time; //getHttpRequest("sessionTime");
$min_required_points = getHttpRequest("mpb");
$check_sum = getHttpRequest("checksum");
$check_sum_array = array(
"device_id" => $device_id,
"card_number" => $card_number,
"mpb" => $min_required_points,
"trans_time" => $trans_time,
"sessionId" => $sessionId,
"checksum" => $check_sum
);
$check_sum_str = constructHttpParameters($check_sum_array);
// echo "<p>card_number:".$card_number;
// echo "<p>check_sum_str:".$check_sum_str;
$resultcode = 0;
$xml_string = "";
$update_data = array();
$log_date = array();
$post_data = array();
// In case previousSessionId is found
if (strlen($pSessionId) > 0) {
include_once("closeUserTransaction.php");
$closedPreviousTransaction = array();
$consumed_points = getHttpRequest("consumed_points");
$received_award_points = getHttpRequest("award_points");
$transfer_points = getHttpRequest("transfer_points");
$user_points = 0;
$received_cash_points = getHttpRequest("cash_points");
$closingRecordsReceived['card_number'] = $card_number;
$closingRecordsReceived['sessionId'] = $pSessionId;
$closingRecordsReceived['consumed_points'] = $consumed_points;
$closingRecordsReceived['award_points'] = $received_award_points;
$closingRecordsReceived['transfer_points'] = $transfer_points;
$closingRecordsReceived['user_points'] = $user_points;
$closingRecordsReceived['cash_points'] = $received_cash_points;
$closingRecordsReceived['device_id'] = $device_id;
$closingRecordsReceived['TransTime'] = $trans_time;
$closedPreviousTransaction = closeUserTransaction($closingRecordsReceived);
$post_data = array_merge($post_data, $closedPreviousTransaction);
$post_data['pSessionId'] = $pSessionId;
$resultcode_closing = 3;
$post_data['status_closing'] = $resultcode_closing;
}
$min_factor1=5; //最低积分的倍数;
$min_factor2=10;
$transfer_factor1 = 0; // Not enough, no transfer
$transfer_factor2 = 1; // Very low, send everything that enough for purchase
$transfer_factor3 = 2; // Not enough for 10 purchases, send half of the points
$transfer_factor4 = 10; // Sufficient, send points for 10 purchases.
$exist_card_number = 0;
$post_data['sessionId'] = $sessionId;
$post_data['device_id'] = $device_id;
$post_data['sessionTime'] = $sessionTime;
$post_data['trans_time'] = $trans_time;
$post_data['mpb'] = $min_required_points;
$post_data['user_id'] = "";
$post_data['user_name'] = "";
$post_data['alias'] = "";//urlencode($alias);
$post_data['display_user_points'] = 0;
$post_data['message'] = "";
$post_data['transfer_points'] = 0;
$post_data['user_points'] = 0;
$post_data['fund_status'] = 100; //100 means not enough fund
// Retrieve the jackpot related information and messages
$jackpot_table_name = "jackpot_award";
$jackpot_key = "add_time";
$jackpot_sql_result = selectLastRecord($jackpot_key, $jackpot_table_name);
while($sql_data = mysql_fetch_array($jackpot_sql_result, MYSQL_ASSOC)){
// echo "<p>The sql_result:";
// print_r($sql_data);
$jackpot_amount = $sql_data['jackpot_amount'];
$jackpot_ceiling = $sql_data['jackpot_ceiling'];
$jackpot_preserved = $sql_data['jackpot_preserved'];
$message_front = $sql_data['message_front'];
$message_mid = $sql_data['message_mid'];
$message_end = $sql_data['message_end'];
$message_top = $sql_data['message_top'];
//echo "The messages:".$message_front."-".$message_mid."-".$message_end."-".$message_top;
$jackpot_data['jackpot_amount'] = $jackpot_amount;
$jackpot_data['jackpot_ceiling'] = $jackpot_ceiling;
$jackpot_data['jackpot_preserved'] = $jackpot_preserved;
$jackpot_data['message_front'] = $message_front;
$jackpot_data['message_mid'] = $message_mid;
$jackpot_data['message_end'] = $message_end;
$jackpot_data['message_top'] = $message_top;
$post_data['Jackpot'] = $jackpot_data;
}
mysql_free_result($sql_result);
// echo "<p>The post data:";
// print_r($post_data);
// echo "<p>card_number length:".strlen($card_number);
if (!existSessionId($sessionId, $sessionTime)) {
// Retrieve the user information and the points from database
$table_name = "users";
// echo "before check sum";
if (strlen($card_number) > 0) {
$conditions = "card_number = ".$card_number;
if (true) {// if (checkBcc($check_sum_str, $check_sum)) {
// echo "after check sum";
$sql_result = selectConditionalRecords($conditions, $table_name);
while($sql_data = mysql_fetch_array($sql_result, MYSQL_ASSOC)){
// echo "<p>The sql_result:";
// print_r($sql_data);
$exist_card_number++;
$user_id = $sql_data['user_id'];
$user_name = $sql_data['user_name'];
$alias = $sql_data['alias'];
$current_user_points = abs($sql_data['user_points']);
$current_frozen_points = abs($sql_data['frozen_points']);
$post_data['user_id'] = $user_id;
$post_data['user_name'] = $user_name;
$post_data['alias'] = $alias;
$post_data['display_user_points'] = abs(intval($current_user_points));
$usable_points = $current_user_points - $current_frozen_points;
// echo "<p>usable_points:".$usable_points;
switch ($usable_points) {
case ($usable_points < $min_required_points) :
// echo "<p>case: 100";
$post_data['message'] = "剩余积分不足, 请充值后再继续。";
//$usable_points = 0;
$transfer_points = $usable_points * $transfer_factor1;
$user_points = $current_user_points;
$frozen_points = $current_frozen_points + $transfer_points;
$post_data['transfer_points'] = abs(intval($transfer_points));
$post_data['user_points'] = abs(intval($user_points));
$post_data['fund_status'] = 100; //100 means not enough fund
break;
case ($usable_points >= $min_required_points and $usable_points <= $min_required_points*$min_factor1) :
// echo "<p>case: 200";
$post_data['message'] = "剩余积分很低,请速充值。";
$transfer_points = round($usable_points/($min_required_points * $transfer_factor2),0)*$min_required_points;
while ($transfer_points > $usable_points) {
$transfer_points = $transfer_points - $min_required_points;
}
$frozen_points = $current_frozen_points + $transfer_points;
$user_points = $current_user_points - $transfer_points;
// echo "<p> transfer_points:".$transfer_points;
$post_data['frozen_points'] = abs(intval($frozen_points));
$post_data['transfer_points'] = abs(intval($transfer_points));
$post_data['user_points'] = abs(intval($user_points));
$post_data['fund_status'] = 200; //200 means very low fund
break;
case ($usable_points > $min_required_points*$min_factor1 and $usable_points <= $min_required_points*$min_factor2) :
// echo "<p>case: 300";
$post_data['message'] = "剩余积分低,请速充值。";
$transfer_points = round($usable_points /($min_required_points * $transfer_factor3),0)*$min_required_points;
while ($transfer_points > $usable_points) {
$transfer_points = $transfer_points - $min_required_points;
}
$frozen_points = $current_frozen_points + $transfer_points;
$user_points = $current_user_points - $transfer_points;
// echo "<p> transfer_points:".$transfer_points;
$post_data['frozen_points'] = abs(intval($frozen_points));
$post_data['transfer_points'] = abs(intval($transfer_points));
$post_data['user_points'] = abs(intval($user_points));
$post_data['fund_status'] = 300; //300 means low fund
break;
case ($usable_points >= $min_required_points*$min_factor4) :
// echo "<p>case: default";
$post_data['message'] = "感谢参与公益购彩。";
$transfer_points = $min_required_points*$transfer_factor4;
$frozen_points = $current_frozen_points + $transfer_points;
$user_points = $current_user_points - $transfer_points;
// echo "<p> transfer_points:".$transfer_points;
$post_data['frozen_points'] = abs(intval($frozen_points));
$post_data['transfer_points'] = abs(intval($transfer_points));
$post_data['user_points'] = abs(intval($user_points));
$post_data['fund_status'] = 1000; //1000 means sufficient fund
break;
default :
// echo "<p>case: 0";
$post_data['message'] = "无法获取有效积分,请重试。";
$usable_points = 0;
$transfer_points = 0;
$user_points = 0;
$post_data['transfer_points'] = 0;
$post_data['user_points'] = 0;
$post_data['fund_status'] = 0; //0 means not processed
}
}
mysql_free_result($sql_result);
} else {
$resultcode = -5;
}
} else {
$resultcode = 0;
}
// print_r($post_data);
// Update
if ($exist_card_number > 0) {
$post_data['card_number'] = $card_number;
$user_point_change = - $transfer_points;
$frozen_points_change = $transfer_points;
$change_desc = "可用积分".$usable_points.",向".$device_id."上划拨".$frozen_points."积分,资金状态".$post_data['fund_status'];
log_account_change($user_id, 0, 0, 0, $user_point_change, $frozen_points_change, 0, 0, $change_desc);
$resultcode = 1;
$post_data['status'] = $resultcode;
// Check if there is any voucher need to be printed for this user.
$voucher_table_name = "active_vouchers";
$conditions = "user_id = ".$user_id." AND status = 0";
$voucher_sql_result = selectConditionalRecords($conditions, $voucher_table_name);;
while($sql_data = mysql_fetch_array($voucher_sql_result, MYSQL_ASSOC)){
// echo "<p>The sql_result:";
// print_r($sql_data);
$voucher_id = $sql_data['id'];
$voucher_template_id = $sql_data['voucher_id'];
$qr_message = $sql_data['qr_message'];
$voucher_message = $sql_data['message'];
$voucher_data['voucher_id'] = $voucher_id;
$voucher_data['voucher_template_id'] = $voucher_template_id;
$voucher_data['qr_message'] = $qr_message;
$voucher_data['voucher_message'] = $voucher_message;
$post_data['Coupon'] = $voucher_data;
}
mysql_free_result($sql_result);
} else {
$post_data['card_number'] = -1;
}
$xml_string = getArrayToXML($post_data);
//echo $xml_string;
$dbStatus = setSessionId($sessionId, $sessionTime, $frozen_points, $xml_string);
// echo "<p> The XML_data:".$xml_string;
} else {
if (strlen($card_number) > 0) {
$resultcode = 2;//重发
// $post_data['status'] = $resultcode;
echo "resultcode:".$resultcode;
$xml_string = getTransferred($sessionId, $sessionTime);
} else {
$resultcode = -1;
$post_data['status'] = $resultcode;
$post_data['card_number'] = -1;
$xml_string = getArrayToXML($post_data);
}
}
header("Expires: date('Y-m-d H:i:s')");
echo $xml_string;
function setAcceptableArgs() {
//echo "<p>In setAcceptableArgs: ";
$acceptable_args = array(
"card_number",
"sessionId",
"trans_time",
"award_points",
"min_required_points",
"device_id",
"checksum"
);
return $acceptable_args;
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.14 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Warning: require_once(): open_basedir restriction in effect. File(/includes/init.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Gj4JX on line 17
Warning: require_once(/includes/init.php): Failed to open stream: Operation not permitted in /in/Gj4JX on line 17
Fatal error: Uncaught Error: Failed opening required '/includes/init.php' (include_path='.:') in /in/Gj4JX:17
Stack trace:
#0 {main}
thrown in /in/Gj4JX on line 17
Process exited with code 255 . Output for 8.0.0 - 8.0.13 Warning: require_once(/includes/init.php): Failed to open stream: No such file or directory in /in/Gj4JX on line 17
Fatal error: Uncaught Error: Failed opening required '/includes/init.php' (include_path='.:') in /in/Gj4JX:17
Stack trace:
#0 {main}
thrown in /in/Gj4JX on line 17
Process exited with code 255 . Output for 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.40 , 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.34 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.25 , 7.4.33 Warning: require_once(/includes/init.php): failed to open stream: No such file or directory in /in/Gj4JX on line 17
Fatal error: require_once(): Failed opening required '/includes/init.php' (include_path='.:') in /in/Gj4JX on line 17
Process exited with code 255 . Output for 7.4.26 - 7.4.32 Warning: require_once(): open_basedir restriction in effect. File(/includes/init.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Gj4JX on line 17
Warning: require_once(/includes/init.php): failed to open stream: Operation not permitted in /in/Gj4JX on line 17
Fatal error: require_once(): Failed opening required '/includes/init.php' (include_path='.:') in /in/Gj4JX on line 17
Process exited with code 255 . preferences:dark mode live preview
257.21 ms | 402 KiB | 385 Q