<?php
defined('BASEPATH') or exit('No direct script access allowed');
include APPPATH . 'third_party/coinbase/autoload.php';

use CoinbaseCommerce\ApiClient;
use CoinbaseCommerce\Resources\Charge;
use CoinbaseCommerce\Webhook;

class Wh extends Guess_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->model(['m_deposit', 'm_offerwall']);
		$this->data['settings'] = $this->m_core->getSettings();
		$this->data['whitelist_ips'] = [
			'coinbase' => [],
			'faucetpay' => [],
			'wannads' => [
				'34.250.159.173',
				'34.244.210.150',
				'52.212.236.135',
				'34.251.83.149',
				'3.22.177.178'
			],
			'cpx' => [
				'188.40.3.73'
			],
			'offertoro' => [
				'54.175.173.245'
			],
			'admantium' => [
				'3.22.177.178'
			],
			'ayetstudios' => [
				'35.165.166.40',
				'35.166.159.131',
				'52.40.3.140'
			],
			'personaly' => [
				'159.203.84.146',
				'52.200.142.249'
			],
			'bitswall' => [
				'188.165.198.204',
				'2001:41d0:2:8fcc::'
			],
			'revlum' => [
				'209.159.156.198'
			],
			'payeer' => [
				'185.71.65.92',
				'185.71.65.189',
				'149.202.17.210'
			]
		];
	}

	public function coinbase()
	{
		if ($this->data['settings']['coinbase_deposit_status'] == 'off') {
			die();
		}
		$secret = $this->data['settings']['coinbase_secret'];
		$signraturHeader = isset($_SERVER['HTTP_X_CC_WEBHOOK_SIGNATURE']) ? $_SERVER['HTTP_X_CC_WEBHOOK_SIGNATURE'] : null;
		$payload = trim(file_get_contents('php://input'));

		try {
			$event = Webhook::buildEvent($payload, $signraturHeader, $secret);
			http_response_code(200);
			switch ($event->type) {
				case 'charge:created':
					$this->m_deposit->updateStatus($event->data->code, 'Created');
					break;
				case 'charge:confirmed':
					$this->m_deposit->updateStatus($event->data->code, 'Confirmed');
					$this->m_deposit->depositSuccess($event->data->code);
					break;
				case 'charge:failed':
					$this->m_deposit->updateStatus($event->data->code, 'Failed');
					break;
				case 'charge:delayed':
					$this->m_deposit->updateStatus($event->data->code, 'Delayed');
					break;
				case 'charge:pending':
					$this->m_deposit->updateStatus($event->data->code, 'Pending');
					break;
				case 'charge:resolved':
					$this->m_deposit->updateStatus($event->data->code, 'Confirmed');
					$this->m_deposit->updateStatus($event->data->code, 'Resolved');
					break;
			}
			echo sprintf('Successully verified event with id %s and type %s.', $event->id, $event->type);
		} catch (\Exception $exception) {
			http_response_code(400);
			echo 'Error occured. ' . $exception->getMessage();
		}
	}

	public function faucetpay()
	{
		if ($this->data['settings']['faucetpay_deposit_status'] == 'off') {
			die();
		}
		$token = $this->input->post('token');
		$validate = @json_decode(get_data('https://faucetpay.io/merchant/get-payment/' . $token), TRUE);
		if ($validate['valid'] && $validate['merchant_username'] == $this->data['settings']['faucetpay_username'] && $validate['amount1'] >= $this->data['settings']['faucetpay_min_deposit']) {
			if ($this->data['settings']['faucetpay_currency'] != "") {
				$faucetpayMethods = explode(',', $this->data['settings']['faucetpay_currency']);
				if (in_array($validate['currency2'], $faucetpayMethods)) {
					$this->m_deposit->addDeposit($validate['custom'], $validate['amount1'], $validate['transaction_id'], 1, 'Confirmed');
					$this->m_deposit->updateUser($validate['custom'], $validate['amount1']);
				}
			} else {
				$this->m_deposit->addDeposit($validate['custom'], $validate['amount1'], $validate['transaction_id'], 1, 'Confirmed');
				$this->m_deposit->updateUser($validate['custom'], $validate['amount1']);
			}
		}
	}

	public function payeer()
	{
		if (!in_array($this->input->ip_address(), $this->data['whitelist_ips']['payeer'])) {
			echo 'ok';
			die();
		}
		if (isset($_POST['m_operation_id']) && isset($_POST['m_sign'])) {
			$arHash = array(
				$_POST['m_operation_id'],
				$_POST['m_operation_ps'],
				$_POST['m_operation_date'],
				$_POST['m_operation_pay_date'],
				$_POST['m_shop'],
				$_POST['m_orderid'],
				$_POST['m_amount'],
				$_POST['m_curr'],
				$_POST['m_desc'],
				$_POST['m_status']
			);

			if (isset($_POST['m_params'])) {
				$arHash[] = $_POST['m_params'];
			}

			$arHash[] = $this->data['settings']['payeer_secret'];

			$sign_hash = strtoupper(hash('sha256', implode(':', $arHash)));

			if ($_POST['m_sign'] == $sign_hash && $_POST['m_status'] == 'success' && $_POST['m_amount'] >= $this->data['settings']['payeer_min_deposit']) {
				$orderId = $this->db->escape_str($_POST['m_orderid']);
				$this->m_deposit->updateStatus($orderId, 'Confirmed');
				$this->m_deposit->depositSuccess($orderId);
				die($_POST['m_orderid'] . '|success');
			}

			die($_POST['m_orderid'] . '|error');
		}
	}

	public function wannads()
	{
		if (!in_array($this->input->ip_address(), $this->data['whitelist_ips']['wannads'])) {
			die();
		}
		$userId = isset($_GET['subId']) ? $this->db->escape_str($_GET['subId']) : null;
		$transactionId = isset($_GET['transId']) ? $this->db->escape_str($_GET['transId']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$offername = isset($_GET['offername']) ? $this->db->escape_str($_GET['offername']) : null;
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$action = isset($_GET['status']) ? $this->db->escape_str($_GET['status']) : null;
		$userIp = isset($_GET['userIp']) ? $this->db->escape_str($_GET['userIp']) : "0.0.0.0";
		$new_exp = $reward*50;

		

		$trans = $this->m_offerwall->getTransaction($transactionId, 'wannads');
		if ($action == 2) {
			$this->m_offerwall->reduceUserBalance($userId, abs($reward));
			$this->m_offerwall->insertTransaction($userId, 'wannads', $userIp, $reward, $transactionId, 1, $offername, time());
			echo "OK";
		} else {
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['wannads_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'wannads', $userIp, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Wannads Offer #" . $offername . " was credited to your balance.", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'wannads', $userIp, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your Wannads Offer #" . $offername . " is pending approval.", 0);
				}
				echo "OK";
			} else {
				echo "DUP";
			}
		}
	}
//https://coinlycash.com/wh/offertoro?userId={user_id}&reward={amount}&offerName={oid}&offerId={offer_id}&ipAddress={ip_address}&transactionId={oid}&teeefaaa
	public function offertoro()
	{
		if (!in_array($this->input->ip_address(), $this->data['whitelist_ips']['offertoro'])) {
			echo 'ok';
			die();
		}
		$secret = $this->data['settings']['offertoro_app_secret'];

		$userId = isset($_GET['user_id']) ? $this->db->escape_str($_GET['user_id']) : 2;
		$transactionId = isset($_GET['oid']) ? $this->db->escape_str($_GET['oid']) : null;
		$offerId = isset($_GET['oid']) ? $this->db->escape_str($_GET['oid']) : null;
		$reward = isset($_GET['amount']) ? $this->db->escape_str($_GET['amount']) : null;
		$ipAddress = isset($_GET['ip_address']) ? $this->db->escape_str($_GET['ip_address']) : null;
		$signature = isset($_GET['sig']) ? $this->db->escape_str($_GET['sig']) : null;

		if (md5($offerId . '-' . $userId . '-' . $secret) != $signature) {
			echo 0;
			return;
		}

		if ($reward < 0) {
			$this->m_offerwall->reduceUserBalance($userId, abs($reward));
			$this->m_offerwall->insertTransaction($userId, 'Offertoro', $ipAddress, $reward, $transactionId, 1, time());
			echo 1;
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'offertoro');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'offertoro', $ipAddress, $reward, $transactionId, 2, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Offertoro Offer #" . $offerId . " was credited to your balance.", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $this->data['settings']['offerwall_exp_reward']);
					if (($user['exp'] + $this->data['settings']['offerwall_exp_reward']) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'offertoro', $ipAddress, $reward, $transactionId, 0, $availableAt);
					$this->m_core->addNotification($userId, "Your Offertoro Offer #" . $offerId . " is pending approval.", 0);
				}
				echo 1;
			} else {
				echo 1;
			}
		}
	}
	//https://coinlycash.com/wh/revlum?subId={subId}&reward={reward}&offerName={offerName}&offerId={offerId}&userIp={userIp}&transId={transId}
	public function revlum()
	{
		
		$userId = isset($_GET['subId']) ? $this->db->escape_str($_GET['subId']) : 2;
		$transactionId = isset($_GET['transId']) ? $this->db->escape_str($_GET['transId']) : null;
		$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward'])/1000 : null;
		$ipAddress = isset($_GET['userIp']) ? $this->db->escape_str($_GET['userIp']) : null;
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;

		

		if ($reward < 0) {
			$this->m_offerwall->reduceUserBalance($userId, abs($reward));
			$this->m_offerwall->insertTransaction($userId, 'revlum', $ipAddress, $reward, $transactionId, 1, $offername, time());
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'revlum');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'revlum', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from revlum Offer #" . $offername . " was credited to your balance.", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $this->data['settings']['offerwall_exp_reward']);
					if (($user['exp'] + $this->data['settings']['offerwall_exp_reward']) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'revlum', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your revlum Offer #" . $offername . " is pending approval.", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	public function adswed()
	{
		
		$secret = "Yg8Nt8Ap6Cs7Ac4";

		$userId = isset($_GET['subId']) ? $this->db->escape_str($_GET['subId']) : 2;
		$transactionId = isset($_GET['transId']) ? $this->db->escape_str($_GET['transId']) : null;
		$offername = isset($_GET['offer_name']) ? $this->db->escape_str($_GET['offer_name']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['userIp']) ? $this->db->escape_str($_GET['userIp']) : null;
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;

		

		if ($reward < 0) {
			$this->m_offerwall->reduceUserBalance($userId, abs($reward));
			$this->m_offerwall->insertTransaction($userId, 'Typlayed', $ipAddress, $reward, $transactionId, 1, $offername, time());
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'Typlayed');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Typlayed', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Typlayed Offer :" . $offername . " was credited to your balance.", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Typlayed', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your Typlayed Offer :" . $offername . " is pending approval.", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	public function adbreak()
	{
	    //https://coinlycash.com/wh/adbreak?user=[YOUR_USER_ID]&reward=[REWARD_VALUE]&offerName=[OFFER_NAME]&offerId=[OFFER_ID]&ip=[USER_IP]&status=[STATUS]&transaction_id=[TXID]

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
		$transactionId = isset($_GET['transaction_id']) ? $this->db->escape_str($_GET['transaction_id']) : null;
		$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = isset($_GET['status']) ? $this->db->escape_str($_GET['status']) : null;
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'AdbreakMedia', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your AdbreakMedia Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'AdbreakMedia');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'AdbreakMedia', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from AdbreakMedia Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'AdbreakMedia', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your AdbreakMedia Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	public function ovnix()
{
    // Ovnix Postback URL: 
    // https://yoursite.com/wh/ovnix?user_id={sub1}&amount={rewardValue}&offer_name={offername}&user_ip={userip}&status={status}
    
    $userId = isset($_GET['user_id']) ? $this->db->escape_str($_GET['user_id']) : null;

    // Convert amount to float and divide by 1000
    $rawAmount = isset($_GET['amount']) ? floatval($_GET['amount']) : 0;
    $reward = $rawAmount / 1000;

    $offername = isset($_GET['offer_name']) ? $this->db->escape_str($_GET['offer_name']) : null;
    $ipAddress = isset($_GET['user_ip']) ? $this->db->escape_str($_GET['user_ip']) : null;
    $status = isset($_GET['status']) ? $this->db->escape_str($_GET['status']) : null;
    
    // Generate transaction ID if not provided
    $transactionId = isset($_GET['txid']) ? $this->db->escape_str($_GET['txid']) : bin2hex(random_bytes(10));
    
    // Validate required parameters
    if (empty($userId) || empty($status)) {
        echo "Missing required parameters";
        return;
    }

    // Calculate EXP only if reward is valid
    $new_exp = ($reward > 0) ? $reward * 50 : 0;

    // Handle status codes from Ovnix
    if ($status == '2' || $reward < 0) {
        // Status 2 = invalid/chargeback or negative reward
        $this->m_offerwall->insertTransaction($userId, 'ovnix', $ipAddress, $reward, $transactionId, 1, $offername, time());
        $this->m_core->addNotification($userId, "Your ovnix Offer: " . $offername . " is rejected", 0);
        echo "ok";
    } else if ($status == '1') {
        // Status 1 = valid conversion
        $trans = $this->m_offerwall->getTransaction($transactionId, 'ovnix');
        if (!$trans) {
            $hold = 0;
            if ($reward > $this->data['settings']['offerwall_min_hold']) {
                $hold = isset($this->data['settings']['ovnix_hold']) ? $this->data['settings']['ovnix_hold'] : $this->data['settings']['offertoro_hold'];
            }
            
            if ($hold == 0) {
                // Immediate credit
                $offerId = $this->m_offerwall->insertTransaction($userId, 'ovnix', $ipAddress, $reward, $transactionId, 2, $offername, time());
                $this->m_offerwall->updateUserBalance($userId, $reward);
                $this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Ovnix Offer: " . $offername . " was credited to your balance", 1);

                $user = $this->m_core->get_user_from_id($userId);
                if ($user && $new_exp > 0) {
                    $this->m_core->addExp($user['id'], $new_exp);
                    if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
                        $this->m_core->levelUp($user['id']);
                    }
                }
            } else {
                // Hold for approval
                $availableAt = time() + $hold * 86400;
                $offerId = $this->m_offerwall->insertTransaction($userId, 'ovnix', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
                $this->m_core->addNotification($userId, "Your Ovnix Offer: " . $offername . " is pending approval", 0);
            }
            echo "ok";
        } else {
            echo "Transaction already processed";
        }
    } else {
        echo "Invalid status: " . $status;
  }
}
	////////////
		public function adminmoo()
	{
	    //https://coinlycash.com/wh/adminmoo?user={uid}&reward={virtual_currency}&offerName={of_name}&offerId={of_id}&ip={ip}&transaction_id={transaction_id}

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
		$transactionId = isset($_GET['transaction_id']) ? $this->db->escape_str($_GET['transaction_id']) : null;
		$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = isset($_GET['status']) ? $this->db->escape_str($_GET['status']) : null;
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'Admantuim', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your Admantuim Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'Admantuim');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Admantuim', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Admantuim Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Admantuim', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your Admantuim Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	
	
	public function offertorox()
	{
       //https://coinlycash.com/wh/offertorox?user={user_id}&reward={amount}&offerName={oid}&offerId={oid}&ip={ip_address}&trans_id={oid}&teeefaaa

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
		$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = "0";
		$status = isset($_GET['status']) ? $this->db->escape_str($_GET['status']) : null;
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'Torox', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your Torox Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'Torox');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Torox', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Torox Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Torox', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your Torox Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	
	
	public function admantium()
	{
	
		
		$secret = "5a6385ef32" ;

		$userId = isset($_GET['user_id']) ? $this->db->escape_str($_GET['user_id']) : 2;
		$transactionId = isset($_GET['transaction_id']) ? $this->db->escape_str($_GET['transaction_id']) : null;
		$offername = isset($_GET['offer_name']) ? $this->db->escape_str($_GET['offer_name']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip_address']) ? $this->db->escape_str($_GET['ip_address']) : null;
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;

		

		if ($reward < 0) {
			$this->m_offerwall->reduceUserBalance($userId, abs($reward));
			$this->m_offerwall->insertTransaction($userId, 'admantium', $ipAddress, $reward, $transactionId, 1, $offername, time());
			echo 1;
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'admantium');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'admantium', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from admantium Offer " . $offername . " was credited to your balance.", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'admantium', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your admantium Offer " . $offername . " is pending approval.", 0);
				}
				echo 1;
			} else {
				echo 0;
			}
		}
	}
	
	
	//aaaaaaa
		public function sushi()
	{
	    //https://coinlycash.com/wh/sushi?user={user_id}&reward={reward}&offerName={offer_name}&trans_id={transaction_id}&offerId={offer_id}&ip={ip}
		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
	$transactionId = isset($_GET['trans_id']) ? $this->db->escape_str($_GET['trans_id']) : null;
		$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'sushi', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your sushi Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'sushi');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'sushi', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from sushi Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'sushi', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your sushi Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
			public function vortexwall()
{
    // https://two2cash.com/wh/vortexwall?identity_id={IDENTITY_ID}&campaign_id={CAMPAIGN_ID}&campaign_name={CAMPAIGN_NAME}&payout={PAYOUT}&txid={TXID}&result={RESULT}&ipaddr={IPADDR}&hash={HASH}
    
    $userId = isset($_GET['identity_id']) ? $this->db->escape_str($_GET['identity_id']) : null;
    $transactionId = isset($_GET['txid']) ? $this->db->escape_str($_GET['txid']) : bin2hex(random_bytes(10));
    $offername = isset($_GET['campaign_name']) ? $this->db->escape_str($_GET['campaign_name']) : (isset($_GET['campaign_id']) ? $this->db->escape_str($_GET['campaign_id']) : null);
    $reward = isset($_GET['payout']) ? $this->db->escape_str($_GET['payout']) * 0.45 : null;
    $ipAddress = isset($_GET['ipaddr']) ? $this->db->escape_str($_GET['ipaddr']) : (isset($_GET['user_ip']) ? $this->db->escape_str($_GET['user_ip']) : null);
    $status = isset($_GET['result']) ? $this->db->escape_str($_GET['result']) : '1'; // Default to approved if not specified
    $signature = isset($_GET['hash']) ? $this->db->escape_str($_GET['hash']) : null;
    $new_exp = $reward * 50;

    if ($status === 'completed') {
        $status = '1';
    } elseif ($status === 'rejected') {
        $status = 'rejected';
    }

    if ($reward < 0 || $status === 'rejected') {
        $this->m_offerwall->insertTransaction($userId, 'vortexwall', $ipAddress, $reward, $transactionId, 1, $offername, time());
        $this->m_core->addNotification($userId, "Your vortexwall Offer: " . $offername . " is rejected", 0);
        echo "ok";
    } else {
        $trans = $this->m_offerwall->getTransaction($transactionId, 'vortexwall');
        if (!$trans) {
            $hold = 0;
            if ($reward > $this->data['settings']['offerwall_min_hold']) {
                $hold = $this->data['settings']['offertoro_hold'];
            }
            if ($hold == 0) {
                $offerId = $this->m_offerwall->insertTransaction($userId, 'vortexwall', $ipAddress, $reward, $transactionId, 2, $offername, time());
                $this->m_offerwall->updateUserBalance($userId, $reward);
                $this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from vortexwall Offer: " . $offername . " was credited to your balance", 1);

                $user = $this->m_core->get_user_from_id($userId);
                $this->m_core->addExp($user['id'], $new_exp);
                if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
                    $this->m_core->levelUp($user['id']);
                }
            } else {
                $availableAt = time() + $hold * 86400;
                $offerId = $this->m_offerwall->insertTransaction($userId, 'vortexwall', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
                $this->m_core->addNotification($userId, "Your vortexwall Offer: " . $offername . " is pending approval", 0);
            }
            echo "ok";
        } else {
            echo "No";
        }
    }
}

	public function adjetapp()
	{
	    //https://earngift.net/wh/adjetapp?user={user_id}&reward={amount}&offerName={offer_name}&offerId={offer_id}&ip={ip}&trans_id={trans}
	    

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'Adjet', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your Adjet Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'Adjet');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Adjet', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Adjet Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'notik', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your notik Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
		
		
		
			public function aaaaovixolabs()
	{
	    //https://earngift.net/wh/avixolabs?user={user_id}&reward={amount}&offerName={offer_name}&offerId={offer_id}&ip={ip}&trans_id={trans}
	    

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'avixolabs', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your avixolabs Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'avixolabs');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'avixolabs', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from avixolabs Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'avixolabs', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your avixolabs Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
		
		
		
			public function klinck()
	{
	    //https://earngift.net/wh/klinck?user={{userId}}&reward={{payout}}&offerName={{offerName}}&ip={{ip}}
	    

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward'])*0.55 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'Klink', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your Klink Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'Klink');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Klink', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Klink Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Klink', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your Klink Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
		

		public function adnets()
	{
	    //https://coinlycash.com/wh/adnets?user={user_id}&reward={reward}&offerName={offer_name}&trans_id={transaction_id}&offerId={offer_id}&ip={ip}
		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
	$transactionId = isset($_GET['trans_id']) ? $this->db->escape_str($_GET['trans_id']) : null;
		$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'Admanutim', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your Admanutim Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'Admanutim');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Admanutim', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Admanutim Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Admanutim', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your Admanutim Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
		public function pubscale()
{
    //https://coinlycash.com/wh/pubscale?user_id={user_id}&reward={value}&token={token}&offer_name={offer_name}&ip={ip}
    $userId = isset($_GET['user_id']) ? $this->db->escape_str($_GET['user_id']) : 2;
    $transactionId = isset($_GET['token']) ? $this->db->escape_str($_GET['token']) : null;
    $offername = isset($_GET['offer_name']) ? $this->db->escape_str($_GET['offer_name']) : 'pubscale';
    $reward = isset($_GET['value']) ? $this->db->escape_str($_GET['value']) /1000 : null;
    $ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : $_SERVER['REMOTE_ADDR'];
    $status = '1';
    $signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
    $new_exp = $reward*50;

    if ($reward < 0 || $status === 'rejected') {
        $this->m_offerwall->insertTransaction($userId, 'Pubscale', $ipAddress, $reward, $transactionId, 1, $offername, time());
        $this->m_core->addNotification($userId, "Your Pubscale Offer: " . $offername . " is rejected", 0);
        echo "ok";
    } else {
        $trans = $this->m_offerwall->getTransaction($transactionId, 'Pubscale');
        if (!$trans) {
            $hold = 0;
            if ($reward > $this->data['settings']['offerwall_min_hold']) {
                $hold = $this->data['settings']['offertoro_hold'];
            }
            if ($hold == 0) {
                $offerId = $this->m_offerwall->insertTransaction($userId, 'Pubscale', $ipAddress, $reward, $transactionId, 2, $offername, time());
                $this->m_offerwall->updateUserBalance($userId, $reward);
                $this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Pubscale Offer: " . $offername . " was credited to your balance", 1);

                $user = $this->m_core->get_user_from_id($userId);
                $this->m_core->addExp($user['id'], $new_exp);
                if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
                    $this->m_core->levelUp($user['id']);
                }
            } else {
                $availableAt = time() + $hold * 86400;
                $offerId = $this->m_offerwall->insertTransaction($userId, 'Pubscale', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
                $this->m_core->addNotification($userId, "Your Pubscale Offer: " . $offername . " is pending approval", 0);
            }
            echo "ok";
        } else {
            echo "No";
        }
    }
}
		public function pubscalemax()
{
    //https://coinlycash.com/wh/pubscalemax?user_id={user_id}&reward={value}&token={token}&offer_name={offer_name}&ip={ip}
    $userId = isset($_GET['user_id']) ? $this->db->escape_str($_GET['user_id']) : 2;
    $transactionId = isset($_GET['token']) ? $this->db->escape_str($_GET['token']) : null;
    $offername = isset($_GET['offer_name']) ? $this->db->escape_str($_GET['offer_name']) : 'pubscale';
    $reward = isset($_GET['value']) ? $this->db->escape_str($_GET['value']) /1000 : null;
    $ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : $_SERVER['REMOTE_ADDR'];
    $status = '1';
    $signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
    $new_exp = $reward*50;

    if ($reward < 0 || $status === 'rejected') {
        $this->m_offerwall->insertTransaction($userId, 'Pubscale', $ipAddress, $reward, $transactionId, 1, $offername, time());
        $this->m_core->addNotification($userId, "Your Pubscale Offer: " . $offername . " is rejected", 0);
        echo "ok";
    } else {
        $trans = $this->m_offerwall->getTransaction($transactionId, 'Pubscale');
        if (!$trans) {
            $hold = 0;
            if ($reward > $this->data['settings']['offerwall_min_hold']) {
                $hold = $this->data['settings']['offertoro_hold'];
            }
            if ($hold == 0) {
                $offerId = $this->m_offerwall->insertTransaction($userId, 'Pubscale', $ipAddress, $reward, $transactionId, 2, $offername, time());
                $this->m_offerwall->updateUserBalance($userId, $reward);
                $this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Pubscale Offer: " . $offername . " was credited to your balance", 1);

                $user = $this->m_core->get_user_from_id($userId);
                $this->m_core->addExp($user['id'], $new_exp);
                if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
                    $this->m_core->levelUp($user['id']);
                }
            } else {
                $availableAt = time() + $hold * 86400;
                $offerId = $this->m_offerwall->insertTransaction($userId, 'Pubscale', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
                $this->m_core->addNotification($userId, "Your Pubscale Offer: " . $offername . " is pending approval", 0);
            }
            echo "ok";
        } else {
            echo "No";
        }
    }
}
		public function clickwall()
	{
	    //https://two2cash.com/wh/clickwall?user={user_id}&reward={amount}&offerName={offer_name}&trans_id={TXID}&ip={user_ip}
		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
	        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
		$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'clickwall', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your clickwall Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'clickwall');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'clickwall', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from clickwall Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'sushi', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your clickwall Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
public function gemiad()
{
    $userId        = isset($_GET['USER_ID']) ? $this->db->escape_str($_GET['USER_ID']) : 2;
    $transactionId = isset($_GET['TXID']) ? $this->db->escape_str($_GET['TXID']) : bin2hex(random_bytes(10));
    $offername     = isset($_GET['OFFER_NAME']) ? $this->db->escape_str($_GET['OFFER_NAME']) : null;
    $reward        = isset($_GET['REWARD']) ? ((float)$_GET['REWARD'] / 1000) : 0;
    $ipAddress     = isset($_GET['IPADDR']) ? $this->db->escape_str($_GET['IPADDR']) : null;

    $new_exp = $reward * 50;

    // تحقق إذا العملية موجودة مسبقاً
    $trans = $this->m_offerwall->getTransaction($transactionId, 'gemiad');
    if (!$trans) {
        $this->m_offerwall->insertTransaction($userId, 'gemiad', $ipAddress, $reward, $transactionId, 2, $offername, time());
        $this->m_offerwall->updateUserBalance($userId, $reward);

        $this->m_core->addNotification(
            $userId,
            currency($reward, $this->data['settings']['currency_rate']) .
            " from GemiAd Offer : " . $offername . " was credited to your balance",
            1
        );

        $user = $this->m_core->get_user_from_id($userId);
        $this->m_core->addExp($user['id'], $new_exp);
        if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
            $this->m_core->levelUp($user['id']);
        }
    }
    echo "ok";
}


	public function pixylabs()
{
    // https://two2cash.com/wh/pixylabs?pub_id={pub_id}&offer_id={offer_id}&reward={amount}&pub_click_id={click_id}&user_ip={user_ip}
    
    // الحصول على المعطيات من Pixylabs
    $pubId = isset($_GET['pub_id']) ? $this->db->escape_str($_GET['pub_id']) : null;
    $offerId = isset($_GET['offer_id']) ? $this->db->escape_str($_GET['offer_id']) : null;
    $reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) / 1000 : null;
    $transactionId = isset($_GET['pub_click_id']) ? $this->db->escape_str($_GET['pub_click_id']) : bin2hex(random_bytes(10));
    $ipAddress = isset($_GET['user_ip']) ? $this->db->escape_str($_GET['user_ip']) : null;
    
    // استخدام unique1 كمعرف المستخدم أو pub_sub_id
    $userId = isset($_GET['unique1']) ? $this->db->escape_str($_GET['unique1']) : 
              (isset($_GET['pub_sub_id']) ? $this->db->escape_str($_GET['pub_sub_id']) : 2);
    
    // اسم العرض من offer_id إذا لم يتم إرسال اسم محدد
    $offername = isset($_GET['offer_name']) ? $this->db->escape_str($_GET['offer_name']) : 
                 "Pixylabs_Offer_" . $offerId;
    
    $status = '1';
    $signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
    $new_exp = $reward * 50;

    if ($reward < 0 || $status === 'rejected') {
        $this->m_offerwall->insertTransaction($userId, 'pixylabs', $ipAddress, $reward, $transactionId, 1, $offername, time());
        $this->m_core->addNotification($userId, "Your Pixylabs Offer: " . $offername . " is rejected", 0);
        echo "ok";
    } else {
        $trans = $this->m_offerwall->getTransaction($transactionId, 'pixylabs');
        if (!$trans) {
            $hold = 0;
            if ($reward > $this->data['settings']['offerwall_min_hold']) {
                $hold = $this->data['settings']['offertoro_hold'];
            }
            if ($hold == 0) {
                $offerId = $this->m_offerwall->insertTransaction($userId, 'pixylabs', $ipAddress, $reward, $transactionId, 2, $offername, time());
                $this->m_offerwall->updateUserBalance($userId, $reward);
                $this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Pixylabs Offer: " . $offername . " was credited to your balance", 1);

                $user = $this->m_core->get_user_from_id($userId);
                $this->m_core->addExp($user['id'], $new_exp);
                if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
                    $this->m_core->levelUp($user['id']);
                }
            } else {
                $availableAt = time() + $hold * 86400;
                $offerId = $this->m_offerwall->insertTransaction($userId, 'pixylabs', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
                $this->m_core->addNotification($userId, "Your Pixylabs Offer: " . $offername . " is pending approval", 0);
            }
            echo "ok";
        } else {
            echo "No";
        }
    }
}
	
public function playtime() {     
    // https://yourserver.com/postback?user_id={user_id}&offer_id={offer_id}&offer_name={offer_name}&payout={payout}&amount={amount}      
    $userId = isset($_GET['user_id']) ? $this->db->escape_str($_GET['user_id']) : 2;     
    $transactionId = bin2hex(random_bytes(10));     
    $offername = isset($_GET['offer_name']) ? $this->db->escape_str($_GET['offer_name']) : null;     
    
    // تقسيم القيمة على 1000
    $reward = isset($_GET['amount']) ? ((float) $this->db->escape_str($_GET['amount']) / 1000) : 0;     

    $ipAddress = isset($_GET['clickIp']) ? $this->db->escape_str($_GET['clickIp']) : "0.0.0.0";     
    $status = '1';     

    // EXP بعد التعديل (القيمة مقسومة على 1000 بالفعل)
    $new_exp = $reward * 50;      

    if ($reward <= 0 || $status === 'rejected') {         
        $this->m_offerwall->insertTransaction($userId, 'playtime', $ipAddress, $reward, $transactionId, 1, $offername, time());         
        $this->m_core->addNotification($userId, "Your Playtime Offer: " . $offername . " is rejected", 0);         
        echo "ok";     
    } else {         
        $trans = $this->m_offerwall->getTransaction($transactionId, 'playtime');         
        if (!$trans) {             
            $hold = 0;             
            if ($reward > $this->data['settings']['offerwall_min_hold']) {                 
                $hold = $this->data['settings']['offertoro_hold'];             
            }             
            if ($hold == 0) {                 
                $offerId = $this->m_offerwall->insertTransaction($userId, 'playtime', $ipAddress, $reward, $transactionId, 2, $offername, time());                 
                $this->m_offerwall->updateUserBalance($userId, $reward);                 
                $this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Playtime Offer :" . $offername . " was credited to your balance", 1);                  

                $user = $this->m_core->get_user_from_id($userId);                 
                $this->m_core->addExp($user['id'], $new_exp);                 
                if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {                     
                    $this->m_core->levelUp($user['id']);                 
                }             
            } else {                 
                $availableAt = time() + $hold * 86400;                 
                $offerId = $this->m_offerwall->insertTransaction($userId, 'playtime', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);                 
                $this->m_core->addNotification($userId, "Your Playtime Offer: " . $offername . " is pending approval", 0);             
            }             
            echo "ok";         
        } else {             
            echo "No";         
        }     
    } 
}


	
	
		public function tiplayed()
	{
	    //https://two2cash.com/wh/tiplayed?user={subId}&reward={reward}&offerName={offer_name}&trans_id={transId}&ip={userIp}
		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
	        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
		$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;

		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'Typlayed', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your Typlayed Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'Typlayed');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Typlayed', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Typlayed Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'sushi', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your Typlayed Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}


	//aaaaass
		public function adgatereach()
	{
	    //https://coinlycash.com/wh/adgatereach?user={subId}&reward={reward}&offerName={offer_name}&ip={userIp}
		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
		$transactionId = '0';
		$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'adgatereach', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your adgatereach Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'adgatereach');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'adgatereach', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from adgatereach Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'adgatereach', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your AdspiritMedia Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
		public function addd()
	{
	    //https://coinlycash.com/wh/addd?user={user_id}&reward={reward}&offerName={offerName}&trans_id={trans_id}&offerId={offer_id}&ip={user_ip}
		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
$transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'AdspiritMedia', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your AdspiritMedia Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'AdspiritMedia');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'AdspiritMedia', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from AdspiritMedia Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'AdspiritMedia', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your AdspiritMedia Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	
	public function hupport()
	{
	    //https://coinlycash.com/wh/hupport?user=[USER_ID]&reward=[REWARD]&offerName=[OFFER_NAME]&trans_id=[TXID]&offerId=[OFFER_ID]&ip=[USER_IP]
		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
$transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'AdPortHub', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your AdPortHub Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'AdPortHub');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'AdPortHub', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from AdPortHub Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'AdPortHub', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your AdPortHub Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	public function flextoo()
	{
	    //https://coinlycash.com/wh/flextoo?user={user_id}&reward={amount}&offerName={offer_name}&trans_id={tixid}&ip={user_ip}
		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
$transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'FlexWall', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your FlexWall Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'FlexWall');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'FlexWall', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from FlexWall Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'FlexWall', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your FlexWall Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	
		public function adhopes()

	{
	    //https://earngift.net/wh/addd?user={user_id}&reward={reward}&offerName={offerName}&trans_id={trans_id}&offerId={offer_id}&ip={user_ip}
		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
$transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'Adhope', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your AdhopeAdhope Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'Adhopemedia');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Adhopemedia', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Adhopemedia Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Adhopemedia', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your AdhopeAdhope Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	
	
	public function timewall()
	{
		
		
		$secret = "252f032923a8358f7ffee2271da3b7b9" ;

		$userId = isset($_GET['userID']) ? $this->db->escape_str($_GET['userID']) : 2;
		$transactionId = isset($_GET['transactionID']) ? $this->db->escape_str($_GET['transactionID']) : null;
		$offername = isset($_GET['offer_name']) ? $this->db->escape_str($_GET['offer_name']) : null;
		$reward = isset($_GET['currencyAmount']) ? $this->db->escape_str($_GET['currencyAmount']) : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$ipAddress = isset($_GET['revenue']) ? $this->db->escape_str($_GET['revenue']) : null;

		

		if ($reward < 0) {
			$this->m_offerwall->reduceUserBalance($userId, abs($reward));
			$this->m_offerwall->insertTransaction($userId, 'timewall', $ipAddress, $reward, $transactionId, 1, $offername, time());
			echo 1;
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'timewall');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'timewall', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from timewall Offer " . $offerId . " was credited to your balance.", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $this->data['settings']['offerwall_exp_reward']);
					if (($user['exp'] + $this->data['settings']['offerwall_exp_reward']) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'timewall', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your timewall Offer " . $offerId . " is pending approval.", 0);
				}
				echo 1;
			} else {
				echo 0;
			}
		}
	}
	
	
	
	public function tapjoy()
{
    $secret = "5a6385ef32";

    $userId = isset($_GET['snuid']) ? $this->db->escape_str($_GET['snuid']) : 2;
    $transactionId = "15151";
    $offerId = isset($_GET['offer_name']) ? $this->db->escape_str($_GET['offer_name']) : null;
    $reward = isset($_GET['currency']) ? $this->db->escape_str($_GET['currency']) /1000 : null;
    $ipAddress = "0";
    $signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
    $new_exp = $reward*50;

    // Check if the transaction ID already exists
        if ($reward < 0) {
            $this->m_offerwall->reduceUserBalance($userId, abs($reward));
            $this->m_offerwall->insertTransaction($userId, 'tapjoy', $ipAddress, $reward, $transactionId, 1, time());
            echo 1;
        } else {
            $hold = 0;
            if ($reward > $this->data['settings']['offerwall_min_hold']) {
                $hold = $this->data['settings']['offertoro_hold'];
            }
            if ($hold == 0) {
                $offerId = $this->m_offerwall->insertTransaction($userId, 'offertoro', $ipAddress, $reward, $transactionId, 2, time());
                $this->m_offerwall->updateUserBalance($userId, $reward);
                $this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from tapjoy Offer " . $offerId . " was credited to your balance.", 1);

                $user = $this->m_core->get_user_from_id($userId);
                $this->m_core->addExp($user['id'], $new_exp);
                if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
                    $this->m_core->levelUp($user['id']);
                }
            } else {
                $availableAt = time() + $hold * 86400;
                $offerId = $this->m_offerwall->insertTransaction($userId, 'tapjoy', $ipAddress, $reward, $transactionId, 0, $availableAt);
                $this->m_core->addNotification($userId, "Your tapjoy Offer " . $offerId . " is pending approval.", 0);
            }
            echo 1;
        }
    
}




public function adgem()
	{
		if (!in_array($this->input->ip_address(), $this->data['whitelist_ips']['offertoro'])) {
			echo 'ok';
			die();
		}
		$secret = $this->data['settings']['offertoro_app_secret'];

		$userId = isset($_GET['user_id']) ? $this->db->escape_str($_GET['user_id']) : 2;
		$transactionId = isset($_GET['oid']) ? $this->db->escape_str($_GET['oid']) : null;
		$offerId = isset($_GET['oid']) ? $this->db->escape_str($_GET['oid']) : null;
		$reward = isset($_GET['amount']) ? $this->db->escape_str($_GET['amount']) : null;
		$ipAddress = isset($_GET['ip_address']) ? $this->db->escape_str($_GET['ip_address']) : null;
		$signature = isset($_GET['sig']) ? $this->db->escape_str($_GET['sig']) : null;

		if (md5($offerId . '-' . $userId . '-' . $secret) != $signature) {
			echo 0;
			return;
		}

		if ($reward < 0) {
			$this->m_offerwall->reduceUserBalance($userId, abs($reward));
			$this->m_offerwall->insertTransaction($userId, 'Offertoro', $ipAddress, $reward, $transactionId, 1, time());
			echo 1;
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'offertoro');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'offertoro', $ipAddress, $reward, $transactionId, 2, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Offertoro Offer #" . $offerId . " was credited to your balance.", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $this->data['settings']['offerwall_exp_reward']);
					if (($user['exp'] + $this->data['settings']['offerwall_exp_reward']) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'offertoro', $ipAddress, $reward, $transactionId, 0, $availableAt);
					$this->m_core->addNotification($userId, "Your Offertoro Offer #" . $offerId . " is pending approval.", 0);
				}
				echo 1;
			} else {
				echo 0;
			}
		}
	}
	
	
	
	
	public function ewall()
	{
		if (!in_array($this->input->ip_address(), $this->data['whitelist_ips']['offertoro'])) {
			echo 'ok';
			die();
		}
		$secret = $this->data['settings']['offertoro_app_secret'];

		$userId = isset($_GET['user_id']) ? $this->db->escape_str($_GET['user_id']) : 2;
		$transactionId = isset($_GET['oid']) ? $this->db->escape_str($_GET['oid']) : null;
		$offerId = isset($_GET['oid']) ? $this->db->escape_str($_GET['oid']) : null;
		$reward = isset($_GET['amount']) ? $this->db->escape_str($_GET['amount']) : null;
		$ipAddress = isset($_GET['ip_address']) ? $this->db->escape_str($_GET['ip_address']) : null;
		$signature = isset($_GET['sig']) ? $this->db->escape_str($_GET['sig']) : null;

		if (md5($offerId . '-' . $userId . '-' . $secret) != $signature) {
			echo 0;
			return;
		}

		if ($reward < 0) {
			$this->m_offerwall->reduceUserBalance($userId, abs($reward));
			$this->m_offerwall->insertTransaction($userId, 'Offertoro', $ipAddress, $reward, $transactionId, 1, time());
			echo 1;
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'offertoro');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'offertoro', $ipAddress, $reward, $transactionId, 2, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Offertoro Offer #" . $offerId . " was credited to your balance.", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $this->data['settings']['offerwall_exp_reward']);
					if (($user['exp'] + $this->data['settings']['offerwall_exp_reward']) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'offertoro', $ipAddress, $reward, $transactionId, 0, $availableAt);
					$this->m_core->addNotification($userId, "Your Offertoro Offer #" . $offerId . " is pending approval.", 0);
				}
				echo 1;
			} else {
				echo 0;
			}
		}
	}




	public function cpx()
	{
		if (!in_array($this->input->ip_address(), $this->data['whitelist_ips']['cpx'])) {
			echo 'ok';
			die();
		}
		$secret = $this->data['settings']['cpx_hash'];
		$userId = isset($_GET['user_id']) ? $this->db->escape_str($_GET['user_id']) : null;
		$action = isset($_GET['status']) ? $this->db->escape_str($_GET['status']) : null;
		$transactionId = isset($_GET['trans_id']) ? $this->db->escape_str($_GET['trans_id']) : null;
		$reward = isset($_GET['amount']) ? $this->db->escape_str($_GET['amount']) : null;
		$userIp = isset($_GET['ip_click']) ? $this->db->escape_str($_GET['ip_click']) : "0.0.0.0";
		$signature = isset($_GET['hash']) ? $this->db->escape_str($_GET['hash']) : null;

		if (md5($transactionId . '-' . $secret) != $signature) {
			echo "ERROR: Signature doesn't match";
			return;
		}

		$trans = $this->m_offerwall->getTransaction($transactionId, 'CPX Research');
		if ($action == 2) {
			$this->m_offerwall->reduceUserBalance($userId, abs($reward));
			$this->m_offerwall->insertTransaction($userId, 'CPX Research', $userIp, $reward, $transactionId, 1, time());
			echo "OK";
		} else {
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['cpx_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'CPX Research', $userIp, $reward, $transactionId, 2, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from CPX Research Offer #" . $offerId . " was credited to your balance.", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $this->data['settings']['offerwall_exp_reward']);
					if (($user['exp'] + $this->data['settings']['offerwall_exp_reward']) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'CPX Research', $userIp, $reward, $transactionId, 0, $availableAt);
					$this->m_core->addNotification($userId, "Your CPX Research Offer #" . $offerId . " is pending approval.", 0);
				}
				echo "OK";
			} else {
				echo "DUP";
			}
		}
	}

	public function ayetstudios()
	{
		$userId = isset($_REQUEST['uid']) ? $this->db->escape_str($_REQUEST['uid']) : null;
		$transactionId = isset($_REQUEST['transaction_id']) ? $this->db->escape_str($_REQUEST['transaction_id']) : null;
		$action = isset($_REQUEST['is_chargeback']) ? $this->db->escape_str($_REQUEST['is_chargeback']) : null;
		$reward = isset($_REQUEST['currency_amount']) ? $this->db->escape_str($_REQUEST['currency_amount']) : null;
		$userIp = isset($_REQUEST['ip']) ? $this->db->escape_str($_REQUEST['ip']) : "not available";
		$signature = isset($_SERVER['HTTP_X_AYETSTUDIOS_SECURITY_HASH']) ? $this->db->escape_str($_SERVER['HTTP_X_AYETSTUDIOS_SECURITY_HASH']) : null;

		ksort($_REQUEST, SORT_STRING);
		$sortedQueryString = http_build_query($_REQUEST, '', '&');
		$securityHash = hash_hmac('sha256', $sortedQueryString, $this->data['settings']['ayetstudios_api']);
		error_log($_SERVER['HTTP_X_AYETSTUDIOS_SECURITY_HASH']);
		if ($securityHash != $signature) {
			echo "invalid signature";
			return;
		}

		$trans = $this->m_offerwall->getTransaction($transactionId, 'AyetStudios');
		if ($action == 1) {
			$this->m_offerwall->reduceUserBalance($userId, abs($reward));
			$this->m_offerwall->insertTransaction($userId, 'AyetStudios', $userIp, $reward, $transactionId, 1, time());
			echo "ok";
		} else {
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['ayetstudios_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'AyetStudios', $userIp, $reward, $transactionId, 2, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from AyetStudios Offer #" . $offerId . " was credited to your balance.", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $this->data['settings']['offerwall_exp_reward']);
					if (($user['exp'] + $this->data['settings']['offerwall_exp_reward']) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'AyetStudios', $userIp, $reward, $transactionId, 0, $availableAt);
					$this->m_core->addNotification($userId, "Your AyetStudios Offer #" . $offerId . " is pending approval.", 0);
				}
				echo "ok";
			} else {
				echo "ok";
			}
		}
	}
	public function offerdaddy()
	{
		$transactionId = $this->db->escape_str(urldecode($_GET["transaction_id"]));
		$offername = $this->db->escape_str(urldecode($_GET["offer_id"]));
		$reward = $this->db->escape_str(urldecode($_GET["amount"]));
		$userId = $this->db->escape_str(urldecode($_GET["userid"]));
		$signature = urldecode($_GET["signature"]);

		//Check the signature
		$validationSignature = md5($transactionId . "/" . $offer_id . "/" . $this->data['settings']['offerdaddy_app_key']);

		if ($validationSignature != trim($signature)) {
			echo "0";
			die();
		}

		$trans = $this->m_offerwall->getTransaction($transactionId, 'OfferDady');
		if ($reward < 0) {
			$this->m_offerwall->reduceUserBalance($userId, abs($reward));
			$this->m_offerwall->insertTransaction($userId, 'OfferDady', 'not available', $reward, $transactionId, 1, $offername, time());
			echo "1";
		} else {
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offerdaddy_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'OfferDady', 'not available', $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from OfferDady Offer #" . $offername . " was credited to your balance.", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $this->data['settings']['offerwall_exp_reward']);
					if (($user['exp'] + $this->data['settings']['offerwall_exp_reward']) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'OfferDady', 'not available', $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your OfferDady Offer #" . $offername . " is pending approval.", 0);
				}
				echo "1";
			} else {
				echo "1";
			}
		}
	}
	public function personaly()
	{
		if (!in_array($this->input->ip_address(), $this->data['whitelist_ips']['personaly'])) {
			echo 'ok';
			die();
		}
		$transactionId = isset($_GET['offer_id']) ? $this->db->escape_str($_GET['offer_id']) : null;
		$reward = isset($_GET['amount']) ? $this->db->escape_str($_GET['amount']) : null;
		$userId = isset($_GET['user_id']) ? $this->db->escape_str($_GET['user_id']) : null;
		$userIp = isset($_GET['user_ip']) ? $this->db->escape_str($_GET['user_ip']) : "not available";
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : "null";

		//Check the signature
		$validationSignature = md5($userId . ':' . $this->data['settings']['personaly_hash'] . ':' . $this->data['settings']['personaly_secret_key']);

		if ($validationSignature != trim($signature)) {
			echo "0";
			die();
		}

		if ($reward < 0) {
			$this->m_offerwall->reduceUserBalance($userId, abs($reward));
			$this->m_offerwall->insertTransaction($userId, 'Persona.ly', $userIp, $reward, $transactionId, 1, time());
			echo "1";
		} else {
			$hold = 0;
			if ($reward > $this->data['settings']['offerwall_min_hold']) {
				$hold = $this->data['settings']['personaly_hold'];
			}
			if ($hold == 0) {
				$offerId = $this->m_offerwall->insertTransaction($userId, 'Persona.ly', $userIp, $reward, $transactionId, 2, time());
				$this->m_offerwall->updateUserBalance($userId, $reward);
				$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Persona.ly Offer #" . $offerId . " was credited to your balance.", 1);

				$user = $this->m_core->get_user_from_id($userId);
				$this->m_core->addExp($user['id'], $this->data['settings']['offerwall_exp_reward']);
				if (($user['exp'] + $this->data['settings']['offerwall_exp_reward']) >= ($user['level'] + 1) * 100) {
					$this->m_core->levelUp($user['id']);
				}
			} else {
				$availableAt = time() + $hold * 86400;
				$offerId = $this->m_offerwall->insertTransaction($userId, 'Persona.ly', $userIp, $reward, $transactionId, 0, $availableAt);
				$this->m_core->addNotification($userId, "Your Persona.ly Offer #" . $offerId . " is pending approval.", 0);
			}
			echo "1";
		}
	}

	public function pollfish()
	{
		$transactionId = isset($_GET['tx_id']) ? $this->db->escape_str($_GET['tx_id']) : null;
		$reward = isset($_GET['reward_value']) ? $this->db->escape_str($_GET['reward_value']) : null;
		$status = isset($_GET['status']) ? $this->db->escape_str($_GET['status']) : null;
		$userId = isset($_GET['request_uuid']) ? $this->db->escape_str($_GET['request_uuid']) : null;
		$userIp = isset($_GET['user_ip']) ? $this->db->escape_str($_GET['user_ip']) : "not available";
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : "null";

		$cpa = rawurldecode($_GET["cpa"]);
		$device_id = rawurldecode($_GET["device_id"]);
		$reward_name = rawurldecode($_GET["reward_name"]);
		$timestamp = rawurldecode($_GET["timestamp"]);

		$data = $cpa . ":" . $device_id;
		if (!empty($userId)) {
			$data = $data . ":" . $userId;
		}
		$data = $data . ":" . $reward_name . ":" . $reward . ":" . $status . ":" . $timestamp . ":" . $transactionId;

		$computedSignature = base64_encode(hash_hmac("sha1", $data, $this->data['settings']['pollfish_secret'], true));
		if ($signature == $computedSignature) {
			if ($status == 'eligible') {
				if ($this->data['settings']['pollfish_hold'] == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Pollfish', $userIp, $reward, $transactionId, 2, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Pollfish Offer #" . $offerId . " was credited to your balance.", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $this->data['settings']['offerwall_exp_reward']);
					if (($user['exp'] + $this->data['settings']['offerwall_exp_reward']) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $this->data['settings']['pollfish_hold'] * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Pollfish', $userIp, $reward, $transactionId, 0, $availableAt);
					$this->m_core->addNotification($userId, "Your Pollfish Offer #" . $offerId . " is pending approval.", 0);
				}
				echo "1";
			} else {
				$this->m_offerwall->insertTransaction($userId, 'Pollfish', $userIp, $reward, $transactionId, 1, time());
			}
		}
	}

	public function bitswall()
	{
		// if (!in_array($this->input->ip_address(), $this->data['whitelist_ips']['bitswall'])) {
		// 	echo 'ok';
		// 	die();
		// }
		$userId = isset($_REQUEST['subId']) ? $this->db->escape_str($_REQUEST['subId']) : null;
		$transactionId = isset($_REQUEST['transId']) ? $this->db->escape_str($_REQUEST['transId']) : null;
		$reward = isset($_REQUEST['reward']) ? $this->db->escape_str($_REQUEST['reward']) : null;
		$userIp = isset($_REQUEST['userIp']) ? $this->db->escape_str($_REQUEST['userIp']) : "0.0.0.0";
		$signature = isset($_REQUEST['signature']) ? $this->db->escape_str($_REQUEST['signature']) : null;
		if (md5($userId . $transactionId . $reward . $this->data['settings']['bitswall_secret']) != $signature) {
			echo "ERROR: Signature doesn't match";
			return;
		}

		$trans = $this->m_offerwall->getTransaction($transactionId, 'Bitswall');
		if (!$trans) {
			$hold = 0;
			if ($reward > $this->data['settings']['offerwall_min_hold']) {
				$hold = $this->data['settings']['bitswall_hold'];
			}
			if ($hold == 0) {
				$offerId = $this->m_offerwall->insertTransaction($userId, 'Bitswall', $userIp, $reward, $transactionId, 2, time());
				$this->m_offerwall->updateUserBalance($userId, $reward);
				$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Bitswall Offer #" . $offerId . " was credited to your balance.", 1);

				$user = $this->m_core->get_user_from_id($userId);
				$this->m_core->addExp($user['id'], $this->data['settings']['offerwall_exp_reward']);
				if (($user['exp'] + $this->data['settings']['offerwall_exp_reward']) >= ($user['level'] + 1) * 100) {
					$this->m_core->levelUp($user['id']);
				}
			} else {
				$availableAt = time() + $hold * 86400;
				$offerId = $this->m_offerwall->insertTransaction($userId, 'Bitswall', $userIp, $reward, $transactionId, 0, $availableAt);
				$this->m_core->addNotification($userId, "Your Bitswall Offer #" . $offerId . " is pending approval.", 0);
			}
			echo "ok";
		} else {
			echo "DUP";
		}
	}
//https://coinlycash.com/wh/monlix?userId={{userId}}&transactionId={{transactionId}}&userIp={{userIp}}&rewardValue={{rewardValue}}&status={{status}}&secretKey={{secretKey}}&offerName={{taskName}}

  public function monlix()
  {
    // UPDATE YOUR SECRET KEY
    $secretKey = $this->data['settings']['monlix_secret'];
    $hold = $this->data['settings']['monlix_hold'];
    $userId = isset($_GET['userId']) ? $this->db->escape_str($_GET['userId']) : null;
    $userIp = isset($_GET['userIp']) ? $this->db->escape_str($_GET['userIp']) : "0.0.0.0";
    $transactionId = isset($_GET['transactionId']) ? $this->db->escape_str($_GET['transactionId']) : null;
    $offer_name = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
    $reward = isset($_GET['rewardValue']) ? $this->db->escape_str($_GET['rewardValue']) / 1000 : null;
    $action = isset($_GET['status']) ? $this->db->escape_str($_GET['status']) : null;
    $signature = isset($_GET['secretKey']) ? $this->db->escape_str($_GET['secretKey']) : null;
    if ($secretKey != $signature) {
      echo "ERROR: Signature doesn't match";
      return;
    }
    $trans = $this->m_offerwall->getTransaction($transactionId, 'Monlix');
    if ($action == 2) {
      $this->m_offerwall->reduceUserBalance($userId, abs($reward));
      $this->m_offerwall->insertTransaction($userId, 'Monlix', $userIp, $reward, $transactionId, 1, $offer_name, time());
      echo "OK";
    } else {
      if (!$trans) {
        $hold = 0;
        if ($reward > $this->data['settings']['offerwall_min_hold']) {
          $hold = $this->data['settings']['monlix_hold'];
        }
        if ($hold == 0) {
          $offerId = $this->m_offerwall->insertTransaction($userId, 'Monlix', $userIp, $reward, $transactionId, 2, $offer_name, time());
          $this->m_offerwall->updateUserBalance($userId, $reward);
          $this->m_core->addNotification($userId, format_money($reward) . " USD from Monlix Offer #" . $offer_name . " was credited to your balance.", 1);
          $user = $this->m_core->get_user_from_id($userId);
          $this->m_core->addExp($user['id'], $this->data['settings']['offerwall_exp_reward']);
          if (($user['exp'] + $this->data['settings']['offerwall_exp_reward']) >= ($user['level'] + 1) * 100) {
            $this->m_core->levelUp($user['id']);
          }
        } else {
          $availableAt = time() + $hold * 86400;
          $offerId = $this->m_offerwall->insertTransaction($userId, 'Monlix', $userIp, $reward, $transactionId, 0, $offer_name, $availableAt);
          $this->m_core->addNotification($userId, "Your Monlix Offer #" . $offer_name . " is pending approval.", 0);
        }
        echo "OK";
      } else {
        echo "DUP";
      }
    }
  }
	public function admantums()
	{
	    //https://coinlycash.com/wh/admantums?user={uid}&reward={virtual_currency}&offerName={of_name}&trans_id={transaction_id}&offerId={of_id}&ip={ip}
		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
	$transactionId = isset($_GET['trans_id']) ? $this->db->escape_str($_GET['trans_id']) : null;
		$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'admantums', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your admantums Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'admantums');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'admantums', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from admantums Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'admantums', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your admantums Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	public function earnetiz()
	{
	    //https://coinlycash.com/wh/earnetiz?user={userid}&reward={user_amount}&offerName={offer_name}&trans_id={transaction_id}&offerId={offer_id}&ip={ip_address}
		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
	$transactionId = isset($_GET['trans_id']) ? $this->db->escape_str($_GET['trans_id']) : null;
		$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'earnetiz', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your earnetiz Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'earnetiz');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'earnetiz', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from earnetiz Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'earnetiz', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your earnetiz Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	public function adflee()
	{
		
		$secret = "Cq5Nm0Vk8Bo2Lz4";

		$userId = isset($_GET['subId']) ? $this->db->escape_str($_GET['subId']) : 2;
		$transactionId = isset($_GET['transId']) ? $this->db->escape_str($_GET['transId']) : null;
		$offername ='Adfleet';
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['userIp']) ? $this->db->escape_str($_GET['userIp']) : null;
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;

		

		if ($reward < 0) {
			$this->m_offerwall->reduceUserBalance($userId, abs($reward));
			$this->m_offerwall->insertTransaction($userId, 'Adlfeet', $ipAddress, $reward, $transactionId, 1, $offername, time());
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'Adfleet');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Adfleet', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Adfleet Offer :" . $offername . " was credited to your balance.", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Adfleet', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your Adfleet Offer :" . $offername . " is pending approval.", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	
		public function offeasw()
{
    //https://two2cash.com/wh/offeasw

    // Using POST instead of GET
    $userId = isset($_POST['subId']) ? $this->db->escape_str($_POST['subId']) : 2;
    $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
    $offername = 'Offery';
    $reward = isset($_POST['reward']) ? $this->db->escape_str($_POST['reward']) / 1000 : null;
    $ipAddress = '1.1.1.1';
    $status = '1';
    $new_exp = $reward * 50;

    if ($reward < 0 || $status === 'rejected') {
        $this->m_offerwall->insertTransaction($userId, 'offery', $ipAddress, $reward, $transactionId, 1, $offername, time());
        $this->m_core->addNotification($userId, "Your offery Offer: " . $offername . "  is rejected", 0);
        echo "ok";
    } else {
        $trans = $this->m_offerwall->getTransaction($transactionId, 'offery');
        if (!$trans) {
            $hold = 0;
            if ($reward > $this->data['settings']['offerwall_min_hold']) {
                $hold = $this->data['settings']['offertoro_hold'];
            }
            if ($hold == 0) {
                $offerId = $this->m_offerwall->insertTransaction($userId, 'offery', $ipAddress, $reward, $transactionId, 2, $offername, time());
                $this->m_offerwall->updateUserBalance($userId, $reward);
                $this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from offery Offer :" . $offername . " was credited to your balance", 1);

                $user = $this->m_core->get_user_from_id($userId);
                $this->m_core->addExp($user['id'], $new_exp);
                if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
                    $this->m_core->levelUp($user['id']);
                }
            } else {
                $availableAt = time() + $hold * 86400;
                $offerId = $this->m_offerwall->insertTransaction($userId, 'offery', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
                $this->m_core->addNotification($userId, "Your offery Offer: " . $offername . "  is pending approval", 0);
            }
            echo "ok";
        } else {
            echo "No";
        }
    }
}


	public function avixolabs()
{
    //https://earngift.net/wh/avixolabs

    // Using POST instead of GET
    $userId = isset($_POST['subId']) ? $this->db->escape_str($_POST['subId']) : 2;
    $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
    $offername = 'avixolabs';
    $reward = isset($_POST['reward']) ? $this->db->escape_str($_POST['reward']) / 1000 : null;
    $ipAddress = '1.1.1.1';
    $status = '1';
    $new_exp = $reward * 50;

    if ($reward < 0 || $status === 'rejected') {
        $this->m_offerwall->insertTransaction($userId, 'avixolabs', $ipAddress, $reward, $transactionId, 1, $offername, time());
        $this->m_core->addNotification($userId, "Your avixolabs Offer: " . $offername . "  is rejected", 0);
        echo "ok";
    } else {
        $trans = $this->m_offerwall->getTransaction($transactionId, 'avixolabs');
        if (!$trans) {
            $hold = 0;
            if ($reward > $this->data['settings']['offerwall_min_hold']) {
                $hold = $this->data['settings']['offertoro_hold'];
            }
            if ($hold == 0) {
                $offerId = $this->m_offerwall->insertTransaction($userId, 'avixolabs', $ipAddress, $reward, $transactionId, 2, $offername, time());
                $this->m_offerwall->updateUserBalance($userId, $reward);
                $this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from avixolabs Offer :" . $offername . " was credited to your balance", 1);

                $user = $this->m_core->get_user_from_id($userId);
                $this->m_core->addExp($user['id'], $new_exp);
                if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
                    $this->m_core->levelUp($user['id']);
                }
            } else {
                $availableAt = time() + $hold * 86400;
                $offerId = $this->m_offerwall->insertTransaction($userId, 'avixolabs', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
                $this->m_core->addNotification($userId, "Your avixolabs Offer: " . $offername . "  is pending approval", 0);
            }
            echo "ok";
        } else {
            echo "No";
        }
    }
}

	public function adlexy()
{
    //https://two2cash.com/wh/adlexy

    // Using POST instead of GET
    $userId = isset($_POST['subId']) ? $this->db->escape_str($_POST['subId']) : 2;
    $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
    $offername = 'adlexy';
    $reward = isset($_POST['reward']) ? $this->db->escape_str($_POST['reward']) / 1000 : null;
    $ipAddress = '1.1.1.1';
    $status = '1';
    $new_exp = $reward * 50;

    if ($reward < 0 || $status === 'rejected') {
        $this->m_offerwall->insertTransaction($userId, 'adlexy', $ipAddress, $reward, $transactionId, 1, $offername, time());
        $this->m_core->addNotification($userId, "Your adlexy Offer: " . $offername . "  is rejected", 0);
        echo "ok";
    } else {
        $trans = $this->m_offerwall->getTransaction($transactionId, 'adlexy');
        if (!$trans) {
            $hold = 0;
            if ($reward > $this->data['settings']['offerwall_min_hold']) {
                $hold = $this->data['settings']['offertoro_hold'];
            }
            if ($hold == 0) {
                $offerId = $this->m_offerwall->insertTransaction($userId, 'adlexy', $ipAddress, $reward, $transactionId, 2, $offername, time());
                $this->m_offerwall->updateUserBalance($userId, $reward);
                $this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from adlexy Offer :" . $offername . " was credited to your balance", 1);

                $user = $this->m_core->get_user_from_id($userId);
                $this->m_core->addExp($user['id'], $new_exp);
                if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
                    $this->m_core->levelUp($user['id']);
                }
            } else {
                $availableAt = time() + $hold * 86400;
                $offerId = $this->m_offerwall->insertTransaction($userId, 'offery', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
                $this->m_core->addNotification($userId, "Your adlexy Offer: " . $offername . "  is pending approval", 0);
            }
            echo "ok";
        } else {
            echo "No";
        }
    }
}


    public function revtoos()
{
    //https://two2cash.com/wh/revtoo

    // Using POST instead of GET
    $userId = isset($_POST['subId']) ? $this->db->escape_str($_POST['subId']) : 2;
    $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
    $offername = 'revtoo';
    $reward = isset($_POST['reward']) ? $this->db->escape_str($_POST['reward']) / 1000 : null;
    $ipAddress = '1.1.1.1';
    $status = '1';
    $new_exp = $reward * 50;

    if ($reward < 0 || $status === 'rejected') {
        $this->m_offerwall->insertTransaction($userId, 'revtoo', $ipAddress, $reward, $transactionId, 1, $offername, time());
        $this->m_core->addNotification($userId, "Your revtoo Offer: " . $offername . "  is rejected", 0);
        echo "ok";
    } else {
        $trans = $this->m_offerwall->getTransaction($transactionId, 'revtoo');
        if (!$trans) {
            $hold = 0;
            if ($reward > $this->data['settings']['offerwall_min_hold']) {
                $hold = $this->data['settings']['offertoro_hold'];
            }
            if ($hold == 0) {
                $offerId = $this->m_offerwall->insertTransaction($userId, 'revtoo', $ipAddress, $reward, $transactionId, 2, $offername, time());
                $this->m_offerwall->updateUserBalance($userId, $reward);
                $this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from revtoo Offer :" . $offername . " was credited to your balance", 1);

                $user = $this->m_core->get_user_from_id($userId);
                $this->m_core->addExp($user['id'], $new_exp);
                if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
                    $this->m_core->levelUp($user['id']);
                }
            } else {
                $availableAt = time() + $hold * 86400;
                $offerId = $this->m_offerwall->insertTransaction($userId, 'revtoo', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
                $this->m_core->addNotification($userId, "Your revtoo Offer: " . $offername . "  is pending approval", 0);
            }
            echo "ok";
        } else {
            echo "No";
        }
    }
}
	
	
		public function zadflyoff()
	{
	    //https://earngift.net/wh/zadflyoff?user=[USER_ID]&reward=[REWARD]&offerName=[OFFER_NAME]&ip=[USER_IP]&trans_id=[TXID]
	    //https://earn-flash.com/wh/zadfly?user=[USER_ID]&reward=[REWARD]
		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'zadfly', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your zadfly Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'zadfly');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'zadfly', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from zadfly Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'zadfly', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your zadfly Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	public function notik()
	{
	    //https://earngift.net/wh/notik?user={user_id}&reward={amount}&offerName={offer_name}&offerId={offer_id}&ip={conversion_ip}&trans_id={event_id}
	    //https://earngift.net/wh/notik?user={user_id}&reward={amount}&offerName={offer_name}&offerId={offer_id}&ip={conversion_ip}&trans_id={txn_id}

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'notik', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your notik Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'notik');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'notik', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from notik Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'notik', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your notik Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	
		public function addcend()
	{
	   
	    //https://trygames.ink/wh/addcend?user=[SB1]&reward=[CUR]&offerName=[ONM]&offerId=[OID]&ip=[IP]

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'Adcendmedia', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your Adcendmedia Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'Adcendmedia');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Adcendmedia', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Adcendmedia Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Adcendmedia', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your Adcendmedia Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	
	
		public function gemiadofferwall()
	{
	    //https://trygames.ink/wh/gemiadofferwall?user={USER_ID}&reward={REWARD}&offerName={OFFER_NAME}&offerId={OFFER_ID}&ip={IPADDR}&trans_id={TXID}
	   

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'Gemiad', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your Gemiad Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'Gemiad');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Gemiad', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Gemiad Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Gemiad', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your Gemiad Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
			public function farly()
		{
			// Old URL: https://pluscash.live/wh/farly?user={sub1}&reward={payout_amount}&offerName={offer_name}&offerId={offer_id}&ip={session_ip}&trans_id={conversion_id}
			// New URL: https://goldtasker.com/api/offers/RrA7ssyflq/farly?user_id={sub1}&reward={payout_amount}&trans_id={conversion_id}&offername={offer_name}&offer_id={offer_id}&ip={session_ip}

			// 1. Get parameters from the incoming request (pluscash.live)
			$old_user = isset($_GET["user"]) ? $_GET["user"] : null;
			$old_reward_raw = isset($_GET["reward"]) ? floatval($_GET["reward"]) : 0; // Get raw reward as float
			$old_offerName = isset($_GET["offerName"]) ? $_GET["offerName"] : null;
			$old_offerId = isset($_GET["offerId"]) ? $_GET["offerId"] : null;
			$old_ip = isset($_GET["ip"]) ? $_GET["ip"] : null;
			$old_trans_id = isset($_GET["trans_id"]) ? $_GET["trans_id"] : null;

			// --- Reward Conversion Logic ---
			$points_per_dollar = 1000; // 1 dollar = 1000 points
			$profit_percentage = 0.65; // 65% profit, so user gets 65% of the points

			$converted_reward = $old_reward_raw * $points_per_dollar * $profit_percentage;
			// Ensure reward is an integer if points are always whole numbers
			$converted_reward = round($converted_reward);
			// ---------------------------------

			// 2. Prepare parameters for the new URL (GoldTasker)
			$new_params = [
				"user_id"   => $old_user,
				"reward"    => $converted_reward, // Use the converted reward
				"trans_id"  => $old_trans_id,
				"offername" => $old_offerName,
				"offer_id"  => $old_offerId,
				"ip"        => $old_ip
			];

			// 3. Build the new URL
			$new_base_url = "https://goldtasker.com/api/offers/RrA7ssyflq/farly";
			$new_full_url = $new_base_url . "?" . http_build_query(array_filter($new_params));

			// 4. Forward the request using cURL
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, $new_full_url);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
			$response = curl_exec($ch);
			
			if (curl_errno($ch)) {
				// Log the error for debugging purposes
				// In a CodeIgniter environment, you might use log_message("error", ...)
				echo "error"; // Or a more specific error message
			} else {
				// Return the response from GoldTasker back to Farly
				echo $response;
			}
			curl_close($ch);
		}

	
		public function grock()
	{
	    //https://earngift.net/wh/grock?user={user_id}&reward={reward}&offerName={campaign_name}&ip={click_ip}&trans_id={transaction_id}
	   

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'GrowDeck', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your GrowDeck Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'GrowDeck');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'GrowDeck', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from GrowDeck Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'GrowDeck', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your GrowDeck Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	public function adhopemedia()
{
    // Log for debugging (اختياري)
    // file_put_contents(FCPATH.'adhopemedia_log.txt', print_r($_GET, true), FILE_APPEND);

    // =========================
    // 1️⃣ Get User ID safely
    // =========================
    $userId = 0;

    if (!empty($_GET['user'])) {
        $userId = intval($_GET['user']);
    } elseif (!empty($_GET['user_id'])) {
        $userId = intval($_GET['user_id']);
    }

    if ($userId <= 0) {
        echo "invalid user";
        return;
    }

    // =========================
    // 2️⃣ Get required params
    // =========================
    $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : 'Adhopemedia Offer';
    $reward    = isset($_GET['reward']) ? floatval($_GET['reward']) : 0;
    $ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
    $status    = isset($_GET['status']) ? intval($_GET['status']) : 1; // 1 = credit, 2 = chargeback

    if ($reward <= 0) {
        echo "invalid reward";
        return;
    }

    // =========================
    // 3️⃣ Transaction ID (ANTI DUPLICATE)
    // =========================
    $transactionId = md5(
        $userId . '|' . $offername . '|' . $reward . '|' . $ipAddress
    );

    // =========================
    // 4️⃣ Check duplicate
    // =========================
    $trans = $this->m_offerwall->getTransaction($transactionId, 'adhopemedia');
    if ($trans) {
        echo "duplicate";
        return;
    }

    // =========================
    // 5️⃣ Handle chargeback
    // =========================
    if ($status == 2) {
        $this->m_offerwall->insertTransaction(
            $userId,
            'adhopemedia',
            $ipAddress,
            -abs($reward),
            $transactionId,
            1,
            $offername,
            time()
        );

        $this->m_core->addNotification(
            $userId,
            "Your Adhopemedia offer '{$offername}' was charged back",
            0
        );

        echo "ok";
        return;
    }

    // =========================
    // 6️⃣ Hold system
    // =========================
    $hold = 0;
    if ($reward > $this->data['settings']['offerwall_min_hold']) {
        $hold = $this->data['settings']['offertoro_hold'];
    }

    // =========================
    // 7️⃣ Credit or Pending
    // =========================
    if ($hold == 0) {

        // CREDIT
        $this->m_offerwall->insertTransaction(
            $userId,
            'adhopemedia',
            $ipAddress,
            $reward,
            $transactionId,
            2,
            $offername,
            time()
        );

        $this->m_offerwall->updateUserBalance($userId, $reward);

        $this->m_core->addNotification(
            $userId,
            currency($reward, $this->data['settings']['currency_rate']) .
            " from Adhopemedia offer '{$offername}' was credited",
            1
        );

        // EXP & LEVEL
        $new_exp = $reward * 50;
        $user = $this->m_core->get_user_from_id($userId);
        $this->m_core->addExp($userId, $new_exp);

        if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
            $this->m_core->levelUp($userId);
        }

    } else {

        // PENDING
        $availableAt = time() + ($hold * 86400);

        $this->m_offerwall->insertTransaction(
            $userId,
            'adhopemedia',
            $ipAddress,
            $reward,
            $transactionId,
            0,
            $offername,
            $availableAt
        );

        $this->m_core->addNotification(
            $userId,
            "Your Adhopemedia offer '{$offername}' is pending approval",
            0
        );
    }

    echo "ok";
}

	
		public function pixlabsapp()
	{
	    //https://earngift.net/wh/pixlabsapp?user=#{click.publisher.unique1}&reward=#{payout.theyGetPoints}&offerName=#{offer.name}&offerId=#{offer.offerId}&ip=#{click.user.connection.ip}&trans_id=#{click.unixTime}
	    //https://earngift.net/wh/pixylabs?user={pub_id}&offer_id={offer_id}&reward={amount}&ip={user_ip}

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'pixlabs', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your pixlabs Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'pixlabs');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'pixlabs', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from pixlabs Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'pixlabs', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your pixlabs Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	
	
		public function lootably()
	{
	    //https://trygames.ink/wh/lootably?user={userID}&reward={currencyReward}&offerName={offerName}&offerId={offerID}&ip={ip}&trans_id={transactionID}

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'Lootbaly', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your Lootbaly Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'Lootbaly');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Lootbaly', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Lootbaly Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Lootbaly', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your Lootbaly Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
        public function adtowallda()
	{
	    //https://giftlyway.com/wh/adtowallda?user={user_id}&reward={points}&offerName={offer_name}&offerId={offer_id}&ip={conversion_id}&trans_id={transaction_id}
	    //https://giftlyway.com/wh/notik?user={user_id}&reward={amount}&offerName={offer_name}&offerId={offer_id}&ip={conversion_ip}&trans_id={txn_id}

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'adtogame', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your adtogame Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'adtogame');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'adtogame', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from adtogame Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'adtogame', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your adtowall Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	
	
	
	
	public function upwall()
	{
	    //https://coinlycash.com/wh/upwall?user={userid}&reward={user_amount}&offerName={offer_name}&ip={ip_address}

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'UPWall', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your UPWall Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'UPWall');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'UPWall', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from UPWall Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'UPWall', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your UPWall Offer: " . $offername . "  is pending approval", 0);
				}
				echo "1";
			} else {
				echo "No";
			}
		}
	}
	
	public function adoffers()
	{
	    //https://coinlycash.com/wh/adoffers?user={user_id}&reward={amount}&offerName={offer_name}&offerId={offer_id}&ip={ip}

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
		$transactionId = bin2hex(random_bytes(8));
		$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'adoffers', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your adoffers Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'adoffers');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'adoffers', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from adoffers Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'adoffers', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your adoffers Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
}

		public function adlyce()
	{
	    //https://coinlycash.com/wh/adlyce?user={userID}&reward={reward}&offerName={offerName}

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = '0';
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'Adlycee', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your Adlycee Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'Adlycee');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Adlycee', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Adlycee Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Adlycee', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your Adlycee Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
		public function taskloo()
	{
	    //https://coinlycash.com/wh/taskloo?user={userid}&reward={user_amount}&offerName={offer_name}&offerId={offer_id}&ip={ip_address}

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
		$transactionId = bin2hex(random_bytes(8));
		$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'Taskwall', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your Taskwall Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'Taskwall');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Taskwall', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from Taskwall Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Taskwall', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your Taskwall Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
}



	public function typlayd()
	{
		
		$secret = "Rx9Hs4Mw9Rp8Mq0";

		$userId = isset($_GET['subId']) ? $this->db->escape_str($_GET['subId']) : 2;
		$transactionId = isset($_GET['transId']) ? $this->db->escape_str($_GET['transId']) : null;
		$offername = isset($_GET['offer_name']) ? $this->db->escape_str($_GET['offer_name']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['userIp']) ? $this->db->escape_str($_GET['userIp']) : null;
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;

		

		if ($reward < 0) {
			$this->m_offerwall->reduceUserBalance($userId, abs($reward));
			$this->m_offerwall->insertTransaction($userId, 'typlayed', $ipAddress, $reward, $transactionId, 1, $offername, time());
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'typlayed');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'typlayed', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from typlayed Offer :" . $offername . " was credited to your balance.", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'typlayed', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your typlayed Offer :" . $offername . " is pending approval.", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	

	public function prize()
	{
	    //https://coinlycash.com/wh/prize?user={user_id}&reward={amount}&offerName={offer_name}&offerId={offer_id}&ip={user_ip}

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        		$transactionId = '0';

        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'prize', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your prize Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'prize');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'prizeloot', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from prize Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'prizeloot', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your prizeloot Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
	public function tasku()
	{
//https://coinlycash.com/wh/tasku?user={userid}&reward={user_amount}&offerName={offer_name}&offerId={offer_id}&ip={ip_address}

           $userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        $transactionId = bin2hex(random_bytes(10)); // 10 bytes = 20 hex characters
        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;



		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'TaskWall', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your TaskWall Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'TaskWall');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'TaskWall', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from TaskWall Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'Taskwall', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your Taskwall Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
		public function bitlabs()
	{
	    //https://coinlycash.com/wh/bitlabs?user=[%UID%]&reward=[%VAL%]&offerName=[%OFFER_NAME%]&offerId=[%OFFER_ID%]&ip=[%IP%]

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
        		$transactionId = '0';

        $offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'bitlabs', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your bitlabs Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'prize');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'bitlabs', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from bitlabs Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'bitlabs', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your bitlabs Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
		
	
	///////adcend
		

// Assuming this is part of a CodeIgniter or similar framework controller/method

// Make sure your database helper/library is loaded if needed
// Make sure your offerwall model (m_offerwall) and core model (m_core) are loaded

public function revtoo()
{
    // --- 1. Get and Validate Essential Parameters from GET request ---

    $userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : null;
    if ($userId === null || $userId == '') {
        error_log("Revtoo Postback Error: Missing user ID in GET data.");
        echo "Error: Missing user ID";
        return;
    }

    $transactionId = isset($_GET['transId']) ? $this->db->escape_str($_GET['transId']) : null;
    if ($transactionId === null || $transactionId == '') {
        error_log("Revtoo Postback Error: Missing transaction ID in GET data.");
        echo "Error: Missing transaction ID";
        return;
    }

    $offername = isset($_GET['offer_name']) ? $this->db->escape_str($_GET['offer_name']) : 'Unknown Offer (revtoo)';

    $reward = isset($_GET['reward']) ? $_GET['reward'] : null;
     if ($reward === null || !is_numeric($reward) ) {
         error_log("Revtoo Postback Error: Invalid or missing reward amount. Reward: " . print_r($reward, true) . ", Status: " . ($_GET['status'] ?? 'N/A'));
         echo "Error: Invalid reward amount";
         return;
    }
    $reward = (float)$reward;

    $ipAddress = isset($_GET['ip_address']) ? $this->db->escape_str($_GET['ip_address']) : 'N/A';

    $status = isset($_GET['status']) ? $this->db->escape_str($_GET['status']) : null;
    if ($status === null || ($status !== '1' && $status !== '2')) {
        error_log("Revtoo Postback Error: Invalid status value. Status: " . print_r($status, true));
        echo "Error: Invalid status";
        return;
    }

    $incomingSignature = isset($_GET['signature']) ? $_GET['signature'] : null;

    $debug = isset($_GET['debug']) ? $_GET['debug'] : '0';
    if ($debug === '1') {
        error_log("Revtoo Postback Debug: Received test postback for User ID: " . $userId . ", Trans ID: " . $transactionId);
    }


    // --- 2. Signature Verification (CRUCIAL SECURITY STEP) ---
    // ** IMPORTANT: You MUST implement the correct signature verification logic here.
    // ** The documentation states it's an MD5 hash. You need your secret key from revtoo.
    // ** The exact string to hash depends on how revtoo constructs it.
    // ** Refer to revtoo's specific documentation for signature calculation details.
    // ** If verification fails, you MUST exit or return an error response like "Invalid signature".

    $yourSecretKey = '271200436659bb508ee2495bc57c549f'; // <-- REPLACE WITH YOUR ACTUAL SECRET KEY FROM REVTOO

    // Example Signature Calculation (CHECK REVTOO'S DOCS FOR THE EXACT METHOD!):
    // $stringToHash = $yourSecretKey . $transactionId . $reward . $status;
    // $calculatedSignature = md5($stringToHash);

    // if ($incomingSignature === null || $incomingSignature !== $calculatedSignature) {
    //     error_log("Revtoo Postback Security Alert: Invalid signature. Incoming: " . $incomingSignature . ", Calculated: " . ($calculatedSignature ?? 'N/A') . " for Trans ID: " . $transactionId);
    //     echo "Error: Invalid signature";
    //     return;
    // }
    // ** End of Placeholder - Implement actual verification above **

     if ($incomingSignature === null) {
         error_log("Revtoo Postback Warning: Signature is missing in the request for Trans ID: " . $transactionId);
     } else {
          error_log("Revtoo Postback Warning: Signature verification is NOT implemented or skipped for Trans ID: " . $transactionId);
     }


    // --- 3. Process Postback based on Status ---

    if ($status === '1') { // Status 1: Credit Points

        $trans = $this->m_offerwall->getTransaction($transactionId, 'revtoo');

        if (!$trans) {

            $hold = 0;
            if ($reward > $this->data['settings']['offerwall_min_hold']) {
                $hold = $this->data['settings']['offertoro_hold'];
            }

            $transactionStatus = ($hold == 0) ? 2 : 0;
            $availableAt = ($hold == 0) ? time() : time() + $hold * 86400;

            $offerDbId = $this->m_offerwall->insertTransaction($userId, 'revtoo', $ipAddress, $reward, $transactionId, $transactionStatus, $offername, $availableAt);

            if ($hold == 0) {

                $this->m_offerwall->updateUserBalance($userId, $reward);

                $creditedAmountFormatted = currency($reward, $this->data['settings']['currency_rate']);
                $this->m_core->addNotification($userId, $creditedAmountFormatted . " from " . $offername . " Offer (revtoo) was credited to your balance", 1);

                $user = $this->m_core->get_user_from_id($userId);
                if ($user) {
                     $this->m_core->addExp($user['id'], $new_exp);

                     if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
                         $this->m_core->levelUp($user['id']);
                     }
                } else {
                    error_log("Revtoo Postback Error: User with ID " . $userId . " not found for EXP/Level update after crediting.");
                }

            } else {
                 $this->m_core->addNotification($userId, $offername . " Offer (revtoo) is pending approval", 0);
            }

            echo "ok";

        } else {
            error_log("Revtoo Postback Info: Received duplicate transaction ID: " . $transactionId . " for user ID: " . $userId);
            echo "No";
        }

    } elseif ($status === '2') { // Status 2: Chargeback / Subtract Points

        // --- Implement Chargeback Logic Here ---
        // 1. Find the original transaction record (using $userId, $transactionId, 'revtoo').
        // 2. Verify it was credited and not already charged back.
        // 3. Deduct the reward amount from the user's balance.
        // 4. Update the transaction status in your DB (e.g., 'chargeback').
        // 5. Add a notification to the user.

        /*
        $originalTransaction = $this->m_offerwall->getCompletedTransactionByTransId($userId, $transactionId, 'revtoo');

        if ($originalTransaction) {
            if ($originalTransaction['status'] == 2 && ($originalTransaction['chargeback_status'] ?? 'none') != 'applied') {
                $deductionAmount = $originalTransaction['reward'];

                $this->m_offerwall->deductUserBalance($userId, $deductionAmount);

                $this->m_offerwall->updateTransactionStatus($originalTransaction['id'], 'chargeback');

                $deductedAmountFormatted = currency($deductionAmount, $this->data['settings']['currency_rate']);
                $this->m_core->addNotification($userId, "Chargeback: " . $deductedAmountFormatted . " from " . $offername . " Offer (revtoo) was deducted from your balance", 0);

                echo "ok";

            } else {
                 error_log("Revtoo Postback Info: Received chargeback for transaction (User ID: " . $userId . ", Trans ID: " . $transactionId . ") that was not completed or already charged back.");
                 echo "ok";
            }

        } else {
            error_log("Revtoo Postback Warning: Received chargeback but original completed transaction not found. User ID: " . $userId . ", Trans ID: " . $transactionId . " for revtoo.");
            echo "No";
        }
        */
        // ** Current Placeholder - Replace this with your actual chargeback logic above **
        error_log("Revtoo Postback Info: Received Chargeback status (2) for User ID: " . $userId . ", Trans ID: " . $transactionId . ". Chargeback logic is NOT implemented for revtoo.");
        echo "No";
    } else {
         error_log("Revtoo Postback Error: Reached unexpected status processing block. User ID: " . $userId . ", Status: " . print_r($status, true));
         echo "Error: Internal Processing Error";
    }
}


	
	public function taskwall1()
	{
	    //https://coinlycash.com/wh/taskwall?user={userid}&reward={user_amount}&offerName={offer_name}&offerId={offer_id}&ip={ip_address}

		$userId = isset($_GET['user']) ? $this->db->escape_str($_GET['user']) : 2;
		$transactionId = '0';
		$offername = isset($_GET['offerName']) ? $this->db->escape_str($_GET['offerName']) : null;
		$reward = isset($_GET['reward']) ? $this->db->escape_str($_GET['reward']) /1000 : null;
		$ipAddress = isset($_GET['ip']) ? $this->db->escape_str($_GET['ip']) : null;
		$status = '1';
		$signature = isset($_GET['signature']) ? $this->db->escape_str($_GET['signature']) : null;
		$new_exp = $reward*50;


		if ($reward < 0 || $status === 'rejected') {
			$this->m_offerwall->insertTransaction($userId, 'taskwall', $ipAddress, $reward, $transactionId, 1, $offername, time());
			$this->m_core->addNotification($userId, "Your taskwall Offer: " . $offername . "  is rejected", 0);
			echo "ok";
		} else {
			$trans = $this->m_offerwall->getTransaction($transactionId, 'taskwall');
			if (!$trans) {
				$hold = 0;
				if ($reward > $this->data['settings']['offerwall_min_hold']) {
					$hold = $this->data['settings']['offertoro_hold'];
				}
				if ($hold == 0) {
					$offerId = $this->m_offerwall->insertTransaction($userId, 'taskwall', $ipAddress, $reward, $transactionId, 2, $offername, time());
					$this->m_offerwall->updateUserBalance($userId, $reward);
					$this->m_core->addNotification($userId, currency($reward, $this->data['settings']['currency_rate']) . " from taskwall Offer :" . $offername . " was credited to your balance", 1);

					$user = $this->m_core->get_user_from_id($userId);
					$this->m_core->addExp($user['id'], $new_exp);
					if (($user['exp'] + $new_exp) >= ($user['level'] + 1) * 100) {
						$this->m_core->levelUp($user['id']);
					}
				} else {
					$availableAt = time() + $hold * 86400;
					$offerId = $this->m_offerwall->insertTransaction($userId, 'taskwall', $ipAddress, $reward, $transactionId, 0, $offername, $availableAt);
					$this->m_core->addNotification($userId, "Your taskwall Offer: " . $offername . "  is pending approval", 0);
				}
				echo "ok";
			} else {
				echo "No";
			}
		}
	}
}

