Advertisement
Guest User

Untitled

a guest
Jan 12th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.55 KB | None | 0 0
  1. <?php
  2. require_once '../includes/config.inc.php';
  3. require_once 'auth.php';
  4.  
  5. $campaign_id = isset($_REQUEST['campaign_id']) && $_REQUEST['campaign_id'] ? $_REQUEST['campaign_id'] : '';
  6. $widget_name = isset($_REQUEST['widget_name']) && $_REQUEST['widget_name'] ? $_REQUEST['widget_name'] : '';
  7. $redirect_url = isset($_REQUEST['redirect_url']) && $_REQUEST['redirect_url'] ? $_REQUEST['redirect_url'] : '';
  8. $redirect_url_params = isset($_REQUEST['redirect_url_params']) ? $_REQUEST['redirect_url_params'] : [];
  9. $test_signup = isset($_REQUEST['test_signup']) && $_REQUEST['test_signup'] ? $_REQUEST['test_signup'] : 1;
  10. $post_msg = isset($_REQUEST['post_msg']) && $_REQUEST['post_msg'] ? $_REQUEST['post_msg'] : '';
  11. $deposit = isset($_REQUEST['deposit']) && $_REQUEST['deposit'] ? $_REQUEST['deposit'] : '';
  12. $affiliate_id = isset($_REQUEST['affiliate_id']) && $_REQUEST['affiliate_id'] ? $_REQUEST['affiliate_id'] : 'c';
  13. $ip = isset($_REQUEST['ip']) ? $_REQUEST['ip'] : getUserIP();
  14.  
  15. $country_code = getCountryCodeFromIP($ip);
  16. $country_id = getCountryInfo(array("code" => $country_code));
  17.  
  18. // add a click to make a proper BAT
  19. $user = new User();
  20. $user_id = $user->loadUserFromHash($affiliate_id);
  21. $project = new Project();
  22. $project_id = $project->loadProjectFromHash($_REQUEST['project_id']);
  23.  
  24. $data = array();
  25. $data['user_id'] = $user_id;
  26. $data['project_page_id'] = null;
  27. $data['affiliate_display'] = $affiliate_id;
  28. if (isset($_REQUEST['referer']) && $_REQUEST['referer']) {
  29. $data['http_referer'] = $_REQUEST['referer'];
  30. }
  31. $data['country_id'] = $country_id;
  32. $clickID = $project->addProjectUserClick($data);
  33.  
  34. $trader = new Trader();
  35. $data = array ();
  36. $data["trader_id"] = 0;
  37. $data['affiliate_id'] = $clickID;
  38. $data['affiliate_display'] = $affiliate_id;
  39. $data["project_id"] = $project_id;
  40. $data["custom"] = $input["custom"];
  41. $data["custom1"] = $input["custom1"];
  42. $data["custom2"] = $input["custom2"];
  43. $data["custom3"] = $input["custom3"];
  44. $data["custom4"] = $input["custom4"];
  45. $data["custom5"] = $input["custom5"];
  46. $data["country_id"] = $country_id;
  47. $data["ip"] = $input['ip'];
  48. $result = $trader->insertTraderHit($data);
  49. $trader_hit_id = $result['trader_hit_id'];
  50. $trader_hit_hash = $result['trader_hit_hash'];
  51.  
  52. $redirect_url_params_string = "";
  53. if(!empty($redirect_url_params) && is_array($redirect_url_params)) {
  54. foreach ($redirect_url_params as $key => $value) {
  55. $redirect_url_params_string .= "&redirect_url_params[$key]=" . urlencode($value);
  56. }
  57. }
  58.  
  59. if(isset($_REQUEST["trader_hit_id"]) && $_REQUEST["trader_hit_id"]) { setTraderHitHash($project_id, $_REQUEST["trader_hit_id"]); }
  60. $trader_hit_hash = getTraderHitHash($project_id);
  61. //$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");
  62. $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");
  63.  
  64. $options = "";
  65. foreach ($arrActiveBanners as $banner) {
  66. $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>';
  67. }
  68. ?>
  69. <!DOCTYPE html>
  70. <html>
  71. <head>
  72. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  73. <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>
  74. <style type="text/css">
  75. body {
  76. font-family: Arial, Helvetica, sans-serif;
  77. font-size: 14px;
  78. margin: 0;
  79. padding: 0;
  80. }
  81. .clear {
  82. clear:both;
  83. }
  84. #register_form {
  85. display: block;
  86. padding: 25px 50px;
  87. margin: 0 auto;
  88. width: 422px;
  89. }
  90. #register_form #banners {
  91. height: 191px;
  92. }
  93. #register_form #banners #broker_banner {
  94. height: 110px;
  95. text-align: center;
  96. }
  97. #register_form input {
  98. border-radius: 6px;
  99. border: 1px solid #999;
  100. height: 30px;
  101. width: 400px;
  102. padding: 5px 10px;
  103. margin: 15px 0 5px;
  104. font-size: 14px;
  105. color: #777777;
  106. }
  107. #register_form select {
  108. border-radius: 6px;
  109. border: 1px solid #999;
  110. width: 422px;
  111. padding: 10px;
  112. margin: 20px 0 5px;
  113. font-size: 14px;
  114. color: #777777;
  115. }
  116. #register_form textarea {
  117. border-radius: 6px;
  118. border: 1px solid #999;
  119. height: 70px;
  120. width: 400px;
  121. padding: 5px 10px;
  122. margin: 15px 0 5px;
  123. font-size: 14px;
  124. color: #777777;
  125. }
  126. #register_form label.error {
  127. display: block;
  128. color: #ff0000;
  129. font-size: 13px;
  130. line-height: normal;
  131. }
  132. #register_form .register {
  133. cursor:pointer;
  134. height: auto;
  135. width: auto;
  136. padding: 10px;
  137. <?php if($test_signup) { ?>background-color: #ff7f7f;<?php } ?>
  138. }
  139. </style>
  140. </head>
  141.  
  142. <body>
  143. <?php if($country_code == '') { ?>
  144. <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>
  145. <?php } ?>
  146. <input id="country_code" value="<?php echo $country_code; ?>" type="hidden" />
  147. <input id="trader_hit_id" value="<?php echo $trader_hit_hash; ?>" type="hidden" />
  148. <form id="register_form" method="post">
  149. <div id="banners">
  150. <div id="broker_banner"><img alt="Select Broker" src="<?php echo BASE_URL; ?>layout/images/select_broker.png" /></div>
  151. <select id="broker_id" name="broker_id"><option value="">Choose Broker</option><?php echo $options; ?></select>
  152. <input id="broker_name" name="broker_name" type="hidden" />
  153. <input id="broker_url" name="broker_url" type="hidden" />
  154. </div>
  155. <input id="first_name" name="first_name" type="text" placeholder="Your First Name" value="<?php echo $first_name; ?>" />
  156. <input id="last_name" name="last_name" type="text" placeholder="Your Last Name" value="<?php echo $last_name; ?>" />
  157. <input id="email" name="email" type="email" placeholder="Your Email Address" value="<?php echo $email; ?>" />
  158. <input id="password" name="password" type="password" placeholder="Enter A Password" />
  159. <div>
  160. <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>
  161. <div style="float:right; width:330px;"><input id="phone" name="phone" type="tel" placeholder="Your Phone Number" style="width:310px;" /></div>
  162. <div class="clear"></div>
  163. </div>
  164. <textarea id="comment" name="comment" placeholder="Enter Comments here..."></textarea>
  165. <div align="center"><input class="register" type="submit" value="Register For <?php echo $project->get_data('title'); ?>" /></div>
  166. </form>
  167. <div id="redirect"></div>
  168. <script type="text/javascript" src="<?php echo BASE_URL; ?>3rdParty/jquery-1.8.3.min.js"></script>
  169. <script type="text/javascript" src="<?php echo BASE_URL;?>3rdParty/jquery.validate.min.js"></script>
  170. <script type="text/javascript" src="<?php echo BASE_URL; ?>3rdParty/jquery.blockUI.js"></script>
  171. <script type="text/javascript">
  172. function blockDiv(element, image) {
  173. $('#'+element).block({
  174. message: '<img src="<?php echo BASE_URL; ?>layout/images/loader.gif" />',
  175. css: { top: ($(window).height() - 24) / 2 + 'px', left: ($(window).width() - 144) / 2 + 'px', height: '24px', width: '144px', border: '0' }
  176. });
  177. }
  178.  
  179. function unblockDiv(element) {
  180. $('#'+element).unblock();
  181. }
  182.  
  183. $.validator.addMethod("alphanumeric", function(value, element) {
  184. return this.optional(element) || /^[a-zA-Z0-9-]+$/i.test(value);
  185. });
  186.  
  187. $.urlParam = function(url, name) {
  188. var results = new RegExp('[\?&amp;]' + name + '=([^&amp;#]*)').exec(url);
  189. return results[1] || '';
  190. }
  191.  
  192. $(document).ready(function() {
  193. $('.country').live('change', function(e){
  194. $("#country_code").val(this.value);
  195. });
  196.  
  197. $('#broker_id').live('change', function(e){
  198. $("#broker_banner").html('<img alt="Open Account with ' + $('option:selected', this).text() + '" src="' + $('option:selected', this).data('banner') + '" />');
  199. $("#broker_name").val($('option:selected', this).text());
  200. $("#broker_url").val($('option:selected', this).data('url'));
  201.  
  202. $.ajax({
  203. type : "POST",
  204. dataType : 'json',
  205. url : '<?php echo API_URL; ?>broker.php',
  206. 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; ?>',
  207. success : function(data) { if (data.result == "SUCCESS") { $("#trader_hit_id").val(data.trader_hit_hash); } }
  208. });
  209.  
  210. if($('#broker_id option[value=]').length > 0) {
  211. $('#broker_id option[value=]').remove();
  212. }
  213. });
  214.  
  215. $("#register_form").validate({
  216. 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 } },
  217. 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" },
  218. submitHandler: function() {
  219. $.ajax({
  220. type: "POST",
  221. url : '<?php echo API_URL; ?>broker_account.php',
  222. 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; ?>',
  223. beforeSend : function() { blockDiv('register_form'); },
  224. complete : function() { unblockDiv('register_form'); },
  225. timeout: 30000,
  226. dataType: 'json',
  227. success: function(data) {
  228. if (data.result == "SUCCESS") {
  229. blockDiv('register_form');
  230. <?php if($new_window || $post_msg) { ?>var message = { data: { registrationSuccessful: "true", signupRequestId: data.signup_request_id } }; window.parent.postMessage(message, "*");<?php } ?>
  231. <?php if($deposit) { ?>
  232. window.location = '<?php echo BASE_URL; ?>test/test_deposit.php?project_id=<?php echo $project_id; ?>&signup_request_id=' + data.signup_request_id;
  233. <?php } else { ?>
  234. if(data.form == '') {
  235. window.top.location = data.redirect_url;
  236. } else {
  237. $("#redirect").html('<form id="redirect_form" action="' + data.redirect_url + '" method="post" target="_blank">' + data.form + '</form>');
  238. $("#redirect_form").submit();
  239. }
  240. <?php } ?>
  241. } else if (data.result == "SUCCESS_US_REGISTRATION") {
  242. alert('Thank You for registration and we will contact you soon');
  243. $("#reg_form").hide();
  244. } else if (data.result == "PHONE_NOT_VERIFIED"){
  245. console.log(data.msg);
  246. alert('The phone number you provided is invalid. Please try again with a valid phone number');
  247. } else if (data.result == "EMAIL_NOT_VERIFIED"){
  248. console.log(data.msg);
  249. alert('The email you provided is invalid. Please try again with a valid email');
  250. } else {
  251. console.log("Error in registeration: " + data.msg + "\nCountry Code:" + $("#country_code").val() + "\nApi Url: " + data.api_url + "\nApi Currency: " + data.api_currency);
  252. if (data.msg ) {
  253. alert(data.msg);
  254. }
  255. }
  256. },
  257. error: function(jqXHR, textStatus, errorThrown) {
  258. if(textStatus==="timeout") {
  259. alert("Call has timed out"); //Handle the timeout
  260. } else {
  261. alert("Another error was returned"); //Handle other error type
  262. }
  263. }
  264. });
  265. }
  266. });
  267. });
  268. </script>
  269.  
  270.  
  271.  
  272. </body>
  273. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement