<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Pback extends CI_Controller
{
//http://www.offerspen.com/pback/sonic?applicationUserId=[USER_ID]&rewards=[REWARDS]&eventId=[EVENT_ID]&itemName=[ITEM_NAME]
//http://www.offerspen.com/pback/paymentwall
private $tb_thanhvien='users';
private $tb_credit='credit';
private $offer='';
private $paymentwall_secret = '68d8b0c09dc36bfee504555af89bfeb3'; //paymentwall
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load_thuvien();
}
function index()
{
$alias = (string)$this->uri->segment(2,0);
$alias = $this->security->xss_clean($alias);
$alias = preg_replace("/(.html)/", '', $alias);//cat duoi html
//$alias="test";
$this->$alias();
}
function load_thuvien(){
$this->load->helper(array('security','text'));
$this->load->library(array('session','form_validation','tank_auth'));
$this->load->helper('url');
$this->load->model('Home_model');
//$this->load->library('Dynamic_menu');
}
function number(){
$this->offer = 'Performa';
$userId = $this->security->xss_clean($_GET['SubId']); // Username of the user that earned the reward(s).
$earn = $this->security->xss_clean($_GET['Earn']); //point['']); // Amount that the user has earned.
$earn =$earn*10;
$this->addcredit($earn,$userId);
echo "False";
}
function tiendau(){
$this->offer = 'blvd-media';
$userId = $this->security->xss_clean($_GET['SubId']); // Username of the user that earned the reward(s).
$earn = $this->security->xss_clean($_GET['Earn']); //point['']); // Amount that the user has earned.
$this->addcredit($earn,$userId);
echo "False";
}
function ultrapay(){
$this->offer = 'ultrapay';
$userId = $this->security->xss_clean($_GET['subid']);
$point = $this->security->xss_clean($_GET['comission']);
$point=$point*20;
$this->addcredit($point,$userId);
echo "False";
}
function radium(){
$userId = $this->security->xss_clean($_GET['userId']);
$point = $this->security->xss_clean($_GET['amount']);
$SECRET = '18fab9b99dddad3c89cf689abcf312de';
$this->offer = "Radiumone";
$this->addcredit($point,$userId);
echo "User ".$userId." Earned ".$point." Point";
}
function chienao(){
$YOURPASSWORD = "lehung228"; //this is the password you set when creating your widget
$password = $_POST['password'];
if ($password != $YOURPASSWORD) {
echo "Access Denied";
exit;
}
$userId = $this->security->xss_clean($_POST['tracking_id']);
$point = $this->security->xss_clean($_POST['payout']);
$point =$point*20;
$this->offer = "Platfrom";
$this->addcredit($point,$userId);
echo " Flase";
}
function Video(){
$userId = $this->security->xss_clean($_GET['user']);
$point = $this->security->xss_clean($_GET['reward']);
$SECRET = '1da7d5be3aff6880178581db0fb2c040';
$this->offer = "Video";
$this->addcredit($point,$userId);
echo " Flase";
}
function Conga(){
$id = $this->security->xss_clean($_GET['id']);
$new = $this->security->xss_clean($_GET['new']); //point
$userId = $this->security->xss_clean($_GET['uid']);//iduser
$this->offer = $this->security->xss_clean($_GET['oid']);//ofer identity
$sig = $this->security->xss_clean($_GET['sig']);//ofer identity
$ipsWhitelist = array(
'54.243.222.172'
);
$SECRET = '8d2b2e35737747052b7bd10592422bb7';
$sig1 = md5($id . ':' . $new . ':' . $userId . ':' . $SECRET);
if (in_array($_SERVER['REMOTE_ADDR'], $ipsWhitelist)){
if( $sig==$sig ){
$this->offer = 'SuperRewards';
$this->addcredit($new,$userId);
echo 1;
}else echo 0;
}else echo 0;
}
function discon(){
$userId = $this->security->xss_clean($_GET['applicationUserId']);
$point = $this->security->xss_clean($_GET['rewards']);
$eventId = $this->security->xss_clean($_GET['eventId']);
$ipsWhitelist = array(
'79.125.5.179',
'79.125.26.193',
'79.125.117.130',
'176.34.224.39',
'176.34.224.41',
'176.34.224.49',
'183.81.62.51'
);
if (in_array($_SERVER['REMOTE_ADDR'], $ipsWhitelist)){
$this->offer = 'Supersonic';
$this->addcredit($point,$userId);
echo $eventId.":OK";
}else echo 'false';
}
function ksix(){
/*
if($_GET){
$data=$_GET;
foreach($data as $k => $data){
$this->db->insert('gpt_test', array('parentid'=>1,'title'=>$k));
$this->db->insert('gpt_test', array('parentid'=>$k,'title'=>$data));
}
}*/
$userId = $this->security->xss_clean($_GET['applicationUserId']);
$point = $this->security->xss_clean($_GET['rewards']);
$point=$point*20;
$this->offer = $this->security->xss_clean($_GET['offer']);
if(empty($this->offer)){$this->offer='Ksix_network';}
$this->addcredit($point,$userId);
}
function paymentwall(){
$userId = $this->security->xss_clean($_GET['uid']);
$credits = $this->security->xss_clean($_GET['currency']);
$signature = $this->security->xss_clean($_GET['sig']);
$refId = $this->security->xss_clean($_GET['ref']);
$type = $this->security->xss_clean($_GET['type']);
$result = false;
if (!empty($userId) && !empty($credits) && isset($type) && !empty($refId) &&!empty($signature)) {
$signatureParams = array(
'uid' => $userId,
'currency' => $credits,
'type' => $type,
'ref' => $refId
);
//check key
$params = $signatureParams;
$secret = $this->paymentwall_secret;
$str = '';
foreach ($params as $k=>$v) {
$str .= "$k=$v";
}
$str .= $secret;
$signatureCalculated = md5($str);
//end check key
if ($signature == $signatureCalculated) {
$result = true;
if ($type == 2) {
// Deduct credits from user
// This is optional, but we recommend this type ofcrediting to be implemented as well
// Note that currency amount sent for chargeback isnegative, e.g. -5, so be caferul about the sign
// Don’t deduct negative number, otherwise user will getcredits instead of losing them
}
else {
$this->offer = 'Paymentwall';
$this->addcredit($credits,$userId);// Give credits to user
echo 'OK';
}
}
}
}
function addcredit($point,$userId){
$Id = $userId;
$user = $this->Home_model->get_one_array($this->tb_thanhvien,array('id'=>$Id));
if($user)
{
$data = array(
'point' => $point,
'credit'=>$point,
'ip' =>$this->input->ip_address(),
'username' =>$user['username'],
'offer' =>$this->offer,
'id_user'=>$userId
);
$this->db->insert($this->tb_credit, $data);
$pointn = $user['point']+$point;
$credit = $user['credit']+$point;
$data1 = array(
'point' => $pointn,
'credit' => $credit
);
$this->db->where('id', $Id);
$this->db->update($this->tb_thanhvien, $data1);
}return false;
}
function test(){
$pointn=1000;
$credit=2000;
$this->db->where(array('id'=>1));
$this->db->update($this->tb_thanhvien,array('point'=>$pointn,'credit'=>$credit));
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */