Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once '../includes/config.inc.php';
- require_once 'auth.php';
- $campaign_id = isset($_REQUEST['campaign_id']) && $_REQUEST['campaign_id'] ? $_REQUEST['campaign_id'] : '';
- $widget_name = isset($_REQUEST['widget_name']) && $_REQUEST['widget_name'] ? $_REQUEST['widget_name'] : '';
- $redirect_url = isset($_REQUEST['redirect_url']) && $_REQUEST['redirect_url'] ? $_REQUEST['redirect_url'] : '';
- $redirect_url_params = isset($_REQUEST['redirect_url_params']) ? $_REQUEST['redirect_url_params'] : [];
- $test_signup = isset($_REQUEST['test_signup']) && $_REQUEST['test_signup'] ? $_REQUEST['test_signup'] : 1;
- $post_msg = isset($_REQUEST['post_msg']) && $_REQUEST['post_msg'] ? $_REQUEST['post_msg'] : '';
- $deposit = isset($_REQUEST['deposit']) && $_REQUEST['deposit'] ? $_REQUEST['deposit'] : '';
- $affiliate_id = isset($_REQUEST['affiliate_id']) && $_REQUEST['affiliate_id'] ? $_REQUEST['affiliate_id'] : 'c';
- $ip = isset($_REQUEST['ip']) ? $_REQUEST['ip'] : getUserIP();
- $country_code = getCountryCodeFromIP($ip);
- $country_id = getCountryInfo(array("code" => $country_code));
- // add a click to make a proper BAT
- $user = new User();
- $user_id = $user->loadUserFromHash($affiliate_id);
- $project = new Project();
- $project_id = $project->loadProjectFromHash($_REQUEST['project_id']);
- $data = array();
- $data['user_id'] = $user_id;
- $data['project_page_id'] = null;
- $data['affiliate_display'] = $affiliate_id;
- if (isset($_REQUEST['referer']) && $_REQUEST['referer']) {
- $data['http_referer'] = $_REQUEST['referer'];
- }
- $data['country_id'] = $country_id;
- $clickID = $project->addProjectUserClick($data);
- $trader = new Trader();
- $data = array ();
- $data["trader_id"] = 0;
- $data['affiliate_id'] = $clickID;
- $data['affiliate_display'] = $affiliate_id;
- $data["project_id"] = $project_id;
- $data["custom"] = $input["custom"];
- $data["custom1"] = $input["custom1"];
- $data["custom2"] = $input["custom2"];
- $data["custom3"] = $input["custom3"];
- $data["custom4"] = $input["custom4"];
- $data["custom5"] = $input["custom5"];
- $data["country_id"] = $country_id;
- $data["ip"] = $input['ip'];
- $result = $trader->insertTraderHit($data);
- $trader_hit_id = $result['trader_hit_id'];
- $trader_hit_hash = $result['trader_hit_hash'];
- $redirect_url_params_string = "";
- if(!empty($redirect_url_params) && is_array($redirect_url_params)) {
- foreach ($redirect_url_params as $key => $value) {
- $redirect_url_params_string .= "&redirect_url_params[$key]=" . urlencode($value);
- }
- }
- if(isset($_REQUEST["trader_hit_id"]) && $_REQUEST["trader_hit_id"]) { setTraderHitHash($project_id, $_REQUEST["trader_hit_id"]); }
- $trader_hit_hash = getTraderHitHash($project_id);
- //$arrActiveBanners = DbRead::instance()->fetchArray("SELECT * FROM " . DB_TABLE_ACTIVE_BANNERS . " WHERE project_id = {$project_id} AND status = 0 AND display = 1 GROUP BY broker_account_project_id ORDER BY priority ASC");
- $arrActiveBanners = DbRead::instance()->fetchArray("SELECT p.hash as broker_account_project_hash, a.title as broker_name, b.logo as banner_url FROM " . DB_TABLE_BROKERS . " as b, " . DB_TABLE_BROKER_ACCOUNTS . " as a, " . DB_TABLE_BROKER_ACCOUNT_PROJECTS . " as p WHERE project_id = {$project_id} AND display = 1 AND b.ID = broker_id AND b.status = 0 AND a.ID = broker_account_id AND register_api = 1 AND a.status = 0 ORDER BY broker_name");
- $options = "";
- foreach ($arrActiveBanners as $banner) {
- $options .= '<option value="' . $banner['broker_account_project_hash'] . '" data-url="' . BROKER_LINK_URL . "bclick.php?bid={$banner['broker_account_project_hash']}&b=-1&l=-1&t={$trader_hit_hash}" . '" data-banner="' . BROKER_LOGOS_URL . $banner['banner_url'] . '">'. $banner['broker_name'] .'</option>';
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Broker Registration Form For <?php echo $project->get_data('title'); if($_SESSION[SESSION_NAME]['type'] == User::Admin) echo ' - '.$project->get_data('title_admin'); ?></title>
- <style type="text/css">
- body {
- font-family: Arial, Helvetica, sans-serif;
- font-size: 14px;
- margin: 0;
- padding: 0;
- }
- .clear {
- clear:both;
- }
- #register_form {
- display: block;
- padding: 25px 50px;
- margin: 0 auto;
- width: 422px;
- }
- #register_form #banners {
- height: 191px;
- }
- #register_form #banners #broker_banner {
- height: 110px;
- text-align: center;
- }
- #register_form input {
- border-radius: 6px;
- border: 1px solid #999;
- height: 30px;
- width: 400px;
- padding: 5px 10px;
- margin: 15px 0 5px;
- font-size: 14px;
- color: #777777;
- }
- #register_form select {
- border-radius: 6px;
- border: 1px solid #999;
- width: 422px;
- padding: 10px;
- margin: 20px 0 5px;
- font-size: 14px;
- color: #777777;
- }
- #register_form textarea {
- border-radius: 6px;
- border: 1px solid #999;
- height: 70px;
- width: 400px;
- padding: 5px 10px;
- margin: 15px 0 5px;
- font-size: 14px;
- color: #777777;
- }
- #register_form label.error {
- display: block;
- color: #ff0000;
- font-size: 13px;
- line-height: normal;
- }
- #register_form .register {
- cursor:pointer;
- height: auto;
- width: auto;
- padding: 10px;
- <?php if($test_signup) { ?>background-color: #ff7f7f;<?php } ?>
- }
- </style>
- </head>
- <body>
- <?php if($country_code == '') { ?>
- <div align="center"><select class="country"><option value="">Select Country</option><?php foreach (getCountries() as $crty) { echo "<option value=\"{$crty["code"]}\">{$crty["name"]}</option>"; } ?></select></div>
- <?php } ?>
- <input id="country_code" value="<?php echo $country_code; ?>" type="hidden" />
- <input id="trader_hit_id" value="<?php echo $trader_hit_hash; ?>" type="hidden" />
- <form id="register_form" method="post">
- <div id="banners">
- <div id="broker_banner"><img alt="Select Broker" src="<?php echo BASE_URL; ?>layout/images/select_broker.png" /></div>
- <select id="broker_id" name="broker_id"><option value="">Choose Broker</option><?php echo $options; ?></select>
- <input id="broker_name" name="broker_name" type="hidden" />
- <input id="broker_url" name="broker_url" type="hidden" />
- </div>
- <input id="first_name" name="first_name" type="text" placeholder="Your First Name" value="<?php echo $first_name; ?>" />
- <input id="last_name" name="last_name" type="text" placeholder="Your Last Name" value="<?php echo $last_name; ?>" />
- <input id="email" name="email" type="email" placeholder="Your Email Address" value="<?php echo $email; ?>" />
- <input id="password" name="password" type="password" placeholder="Enter A Password" />
- <div>
- <div style="float:left; width:70px;"><input id="prefix" name="prefix" type="tel" placeholder="Area Code" value="<?php echo getCountryInfo(array ('code'=>$country_code), 'dial_code'); ?>" style="width:55px;" /></div>
- <div style="float:right; width:330px;"><input id="phone" name="phone" type="tel" placeholder="Your Phone Number" style="width:310px;" /></div>
- <div class="clear"></div>
- </div>
- <textarea id="comment" name="comment" placeholder="Enter Comments here..."></textarea>
- <div align="center"><input class="register" type="submit" value="Register For <?php echo $project->get_data('title'); ?>" /></div>
- </form>
- <div id="redirect"></div>
- <script type="text/javascript" src="<?php echo BASE_URL; ?>3rdParty/jquery-1.8.3.min.js"></script>
- <script type="text/javascript" src="<?php echo BASE_URL;?>3rdParty/jquery.validate.min.js"></script>
- <script type="text/javascript" src="<?php echo BASE_URL; ?>3rdParty/jquery.blockUI.js"></script>
- <script type="text/javascript">
- function blockDiv(element, image) {
- $('#'+element).block({
- message: '<img src="<?php echo BASE_URL; ?>layout/images/loader.gif" />',
- css: { top: ($(window).height() - 24) / 2 + 'px', left: ($(window).width() - 144) / 2 + 'px', height: '24px', width: '144px', border: '0' }
- });
- }
- function unblockDiv(element) {
- $('#'+element).unblock();
- }
- $.validator.addMethod("alphanumeric", function(value, element) {
- return this.optional(element) || /^[a-zA-Z0-9-]+$/i.test(value);
- });
- $.urlParam = function(url, name) {
- var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(url);
- return results[1] || '';
- }
- $(document).ready(function() {
- $('.country').live('change', function(e){
- $("#country_code").val(this.value);
- });
- $('#broker_id').live('change', function(e){
- $("#broker_banner").html('<img alt="Open Account with ' + $('option:selected', this).text() + '" src="' + $('option:selected', this).data('banner') + '" />');
- $("#broker_name").val($('option:selected', this).text());
- $("#broker_url").val($('option:selected', this).data('url'));
- $.ajax({
- type : "POST",
- dataType : 'json',
- url : '<?php echo API_URL; ?>broker.php',
- data : 'command=addBannerImpression&broker_account_id=' + $("#broker_id").val() + '&banner_id=' + $.urlParam($("#broker_url").val(), 'b') + '&link_id=' + $.urlParam($("#broker_url").val(), 'l') + '&trader_hit_id=' + $("#trader_hit_id").val() + '&ip=<?php echo $ip; ?>',
- success : function(data) { if (data.result == "SUCCESS") { $("#trader_hit_id").val(data.trader_hit_hash); } }
- });
- if($('#broker_id option[value=]').length > 0) {
- $('#broker_id option[value=]').remove();
- }
- });
- $("#register_form").validate({
- rules: { broker_id: "required", first_name: { required: true, minlength: 3}, last_name: { required: true, minlength: 3}, email: { required: true, email: true }, password: { required: true, minlength: 6, alphanumeric: true}, prefix: { required: true, number: true }, phone: { required: true, number: true } },
- messages: { broker_id: "Please select broker", first_name: { required: "Please enter first name", minlength: "First name should be at least 3 characters" }, last_name: { required: "Please enter last name", minlength: "Last name should be at least 3 characters" }, email: "Please enter a valid email address", password: { required: "Please enter a password.", minlength: "Password should be at least 6 characters", alphanumeric: "Password must contain only letters or numbers" }, prefix: "Please enter area code", phone: "Please enter phone number" },
- submitHandler: function() {
- $.ajax({
- type: "POST",
- url : '<?php echo API_URL; ?>broker_account.php',
- data: 'command=signUser&broker_account_id=' + $("#broker_id").val() + '&banner_id=' + $.urlParam($("#broker_url").val(), 'b') + '&link_id=' + $.urlParam($("#broker_url").val(), 'l') + '&trader_hit_id=' + $("#trader_hit_id").val() + '&first_name=' + $("#first_name").val() + '&last_name=' + $("#last_name").val() + '&email=' + $("#email").val() + '&password=' + $("#password").val() + '&phone=' + $("#prefix").val() + $("#phone").val() + '&comment=' + $("#comment").val() + '&country=' + $("#country_code").val() + '&ip=<?php echo $ip; ?>&campaign_id=<?php echo $campaign_id; ?>&widget_name=<?php echo $widget_name; ?>&redirect_url=<?php echo $redirect_url; echo $redirect_url_params_string; ?>&test_signup=<?php echo $test_signup; ?>',
- beforeSend : function() { blockDiv('register_form'); },
- complete : function() { unblockDiv('register_form'); },
- timeout: 30000,
- dataType: 'json',
- success: function(data) {
- if (data.result == "SUCCESS") {
- blockDiv('register_form');
- <?php if($new_window || $post_msg) { ?>var message = { data: { registrationSuccessful: "true", signupRequestId: data.signup_request_id } }; window.parent.postMessage(message, "*");<?php } ?>
- <?php if($deposit) { ?>
- window.location = '<?php echo BASE_URL; ?>test/test_deposit.php?project_id=<?php echo $project_id; ?>&signup_request_id=' + data.signup_request_id;
- <?php } else { ?>
- if(data.form == '') {
- window.top.location = data.redirect_url;
- } else {
- $("#redirect").html('<form id="redirect_form" action="' + data.redirect_url + '" method="post" target="_blank">' + data.form + '</form>');
- $("#redirect_form").submit();
- }
- <?php } ?>
- } else if (data.result == "SUCCESS_US_REGISTRATION") {
- alert('Thank You for registration and we will contact you soon');
- $("#reg_form").hide();
- } else if (data.result == "PHONE_NOT_VERIFIED"){
- console.log(data.msg);
- alert('The phone number you provided is invalid. Please try again with a valid phone number');
- } else if (data.result == "EMAIL_NOT_VERIFIED"){
- console.log(data.msg);
- alert('The email you provided is invalid. Please try again with a valid email');
- } else {
- console.log("Error in registeration: " + data.msg + "\nCountry Code:" + $("#country_code").val() + "\nApi Url: " + data.api_url + "\nApi Currency: " + data.api_currency);
- if (data.msg ) {
- alert(data.msg);
- }
- }
- },
- error: function(jqXHR, textStatus, errorThrown) {
- if(textStatus==="timeout") {
- alert("Call has timed out"); //Handle the timeout
- } else {
- alert("Another error was returned"); //Handle other error type
- }
- }
- });
- }
- });
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement