PageRenderTime 26ms CodeModel.GetById 39ms RepoModel.GetById 1ms app.codeStats 0ms

/ajax/update_cpc.php

https://github.com/ClickBooth/XTracks
PHP | 226 lines | 189 code | 25 blank | 12 comment | 43 complexity | 0d24e0edbeceee65b2c1fd51141806e0 MD5 | raw file
  1. <? include_once($_SERVER['DOCUMENT_ROOT'] . '/xtracks-app/bootstrap.php');
  2. AUTH::require_user();
  3. //check variables
  4. $from = explode('/', $_POST['from']);
  5. $from_month = $from[0];
  6. $from_day = $from[1];
  7. $from_year = $from[2];
  8. $to = explode('/', $_POST['to']);
  9. $to_month = $to[0];
  10. $to_day = $to[1];
  11. $to_year = $to[2];
  12. //if from or to, validate, and if validated, set it accordingly
  13. if ((!$_POST['from']) and (!$_POST['to'])) {
  14. $error['time'] = '<div class="error">Please enter in the dates from and to like this <strong>mm/dd/yyyy</strong></div>';
  15. }
  16. $clean['from'] = mktime(0,0,0,$from_month,$from_day,$from_year);
  17. $html['from'] = date('m/d/y g:ia', $clean['from']);
  18. $clean['to'] = mktime(23,59,59,$to_month,$to_day,$to_year);
  19. $html['to'] = date('m/d/y g:ia', $clean['to']);
  20. //set mysql variables
  21. $mysql['user_id'] = mysql_real_escape_string($_SESSION['user_id']);
  22. //check affiliate network id, that you own
  23. if ($_POST['aff_network_id']) {
  24. $mysql['aff_network_id'] = mysql_real_escape_string($_POST['aff_network_id']);
  25. $aff_network_sql = "SELECT * FROM 202_aff_networks WHERE aff_network_id='".$mysql['aff_network_id']."' AND user_id='".$mysql['user_id']."'";
  26. $aff_network_result = mysql_query($aff_network_sql) or record_mysql_error($aff_network_sql);
  27. $aff_network_row = mysql_fetch_assoc($aff_network_result);
  28. if (!$aff_network_row) {
  29. $error['user'] = '<div class="error">You can not modify other peoples cpc history.</div>';
  30. } else {
  31. $html['aff_network_name'] = htmlentities($aff_network_row['aff_network_name'], ENT_QUOTES, 'UTF-8');
  32. }
  33. } else {
  34. $html['aff_network_name'] = 'ALL your affiliate networks';
  35. }
  36. //check aff_campaign id, that you own
  37. if ($_POST['aff_campaign_id']) {
  38. $mysql['aff_campaign_id'] = mysql_real_escape_string($_POST['aff_campaign_id']);
  39. $aff_campaign_sql = "SELECT * FROM 202_aff_campaigns WHERE aff_campaign_id='".$mysql['aff_campaign_id']."' AND user_id='".$mysql['user_id']."'";
  40. $aff_campaign_result = mysql_query($aff_campaign_sql) or record_mysql_error($aff_campaign_sql);
  41. $aff_campaign_row = mysql_fetch_assoc($aff_campaign_result);
  42. if (!$aff_campaign_row) {
  43. $error['user'] = '<div class="error">You can not modify other peoples cpc history.</div>';
  44. } else {
  45. $html['aff_campaign_name'] = htmlentities($aff_campaign_row['aff_campaign_name'], ENT_QUOTES, 'UTF-8');
  46. }
  47. } else {
  48. $html['aff_campaign_name'] = 'ALL your affiliate campaigns in these affiliate networks';
  49. }
  50. //check text_ad id, that you own
  51. if ($_POST['text_ad_id']) {
  52. $mysql['text_ad_id'] = mysql_real_escape_string($_POST['text_ad_id']);
  53. $text_ad_sql = "SELECT * FROM 202_text_ads WHERE text_ad_id='".$mysql['text_ad_id']."' AND user_id='".$mysql['user_id']."'";
  54. $text_ad_result = mysql_query($text_ad_sql) or record_mysql_error($text_ad_sql);
  55. $text_ad_row = mysql_fetch_assoc($text_ad_result);
  56. if (!$text_ad_row) {
  57. $error['user'] = '<div class="error">You can not modify other peoples cpc history.</div>';
  58. } else {
  59. $html['text_ad_name'] = htmlentities($text_ad_row['text_ad_name'], ENT_QUOTES, 'UTF-8');
  60. }
  61. } else {
  62. $html['text_ad_name'] = 'ALL your text ads in these affiliate campaigns';
  63. }
  64. //check method of promotion, that you own
  65. if ($_POST['method_of_promotion']) {
  66. if ($_POST['method_of_promotion'] == 'landingpage') {
  67. $html['method_of_promotion'] = 'Landing pages';
  68. $mysql['method_of_promotion'] = ' click_landing_site_url_id!=0 ';
  69. } else {
  70. $html['method_of_promotion'] = 'Direct links';
  71. $mysql['method_of_promotion'] = ' click_landing_site_url_id=0 ';
  72. }
  73. } else {
  74. $html['method_of_promotion'] = 'BOTH direct links and landing pages';
  75. }
  76. //check landing_page id, that you own
  77. if (($_POST['method_of_promotion'] == 'landingpage') or ($_POST['tracker_type'] == 1)) {
  78. if ($_POST['landing_page_id']) {
  79. $mysql['landing_page_id'] = mysql_real_escape_string($_POST['landing_page_id']);
  80. $landing_page_sql = "SELECT * FROM 202_landing_pages WHERE landing_page_id='".$mysql['landing_page_id']."' AND user_id='".$mysql['user_id']."'";
  81. $landing_page_result = mysql_query($landing_page_sql) or record_mysql_error($landing_page_sql);
  82. $landing_page_row = mysql_fetch_assoc($landing_page_result);
  83. if (!$landing_page_row) {
  84. $error['user'] = '<div class="error">You can not modify other peoples cpc history.</div>';
  85. } else {
  86. $html['landing_page_name'] = htmlentities($landing_page_row['landing_page_nickname'], ENT_QUOTES, 'UTF-8');
  87. }
  88. } else {
  89. $html['landing_page_name'] = 'ALL your landing pages in these affiliate campaigns';
  90. }
  91. } else {
  92. $html['landing_page_name'] = 'n/a';
  93. }
  94. //check affiliate network id, that you own
  95. if ($_POST['ppc_network_id']) {
  96. $mysql['ppc_network_id'] = mysql_real_escape_string($_POST['ppc_network_id']);
  97. $ppc_network_sql = "SELECT * FROM 202_ppc_networks WHERE ppc_network_id='".$mysql['ppc_network_id']."' AND user_id='".$mysql['user_id']."'";
  98. $ppc_network_result = mysql_query($ppc_network_sql) or record_mysql_error($ppc_network_sql);
  99. $ppc_network_row = mysql_fetch_assoc($ppc_network_result);
  100. if (!$ppc_network_row) {
  101. $error['user'] = '<div class="error">You can not modify other peoples cpc history.</div>';
  102. } else {
  103. $html['ppc_network_name'] = htmlentities($ppc_network_row['ppc_network_name'], ENT_QUOTES, 'UTF-8');
  104. }
  105. } else {
  106. $html['ppc_network_name'] = 'ALL your PPC networks';
  107. }
  108. //check ppc_account id, that you own
  109. if ($_POST['ppc_account_id']) {
  110. $mysql['ppc_account_id'] = mysql_real_escape_string($_POST['ppc_account_id']);
  111. $ppc_account_sql = "SELECT * FROM 202_ppc_accounts WHERE ppc_account_id='".$mysql['ppc_account_id']."' AND user_id='".$mysql['user_id']."'";
  112. $ppc_account_result = mysql_query($ppc_account_sql) or record_mysql_error($ppc_account_sql);
  113. $ppc_account_row = mysql_fetch_assoc($ppc_account_result);
  114. if (!$ppc_account_row) {
  115. $error['user'] = '<div class="error">You can not modify other peoples cpc history.</div>';
  116. } else {
  117. $html['ppc_account_name'] = htmlentities($ppc_account_row['ppc_account_name'], ENT_QUOTES, 'UTF-8');
  118. }
  119. } else {
  120. $html['ppc_account_name'] = 'ALL your PPC accounts in these PPC networks';
  121. }
  122. if((!is_numeric($_POST['cpc_dollars'])) or (!is_numeric($_POST['cpc_cents']))) {
  123. $error['cpc'] = '<div class="error">You did not input a numeric max CPC.</div>';
  124. } else {
  125. $click_cpc = $_POST['cpc_dollars'] . '.' . $_POST['cpc_cents'];
  126. $html['click_cpc'] = htmlentities(dollar_format($click_cpc), ENT_QUOTES, 'UTF-8');
  127. $mysql['click_cpc'] = mysql_real_escape_string($click_cpc);
  128. }
  129. //echo error
  130. echo $error['time'] . $error['user'];
  131. //if there was an error terminate, or else just continue to run
  132. if ($error) { die(); } ?>
  133. <table style="margin: 0px auto;">
  134. <tr>
  135. <th colspan="2"><h3 class="green">Double Check Your Update CPC Settings</h3></th>
  136. </tr>
  137. <tr>
  138. <td class="left_caption"><img src="/xtracks-img/icons/16x16/exclamation.png" align="right"></td>
  139. <td>
  140. <p>
  141. Please make sure the following information below is accurate<br/>
  142. before preceding. When you make your changes the clicks are<br/>
  143. updated for immediately so make sure you set it correctly.<br/><br>
  144. Note: Your update could take a while depending on how many</br>
  145. clicks you have selected to update, you will know when the</br>
  146. update is complete, do not click update twice.</br>
  147. </p>
  148. </td>
  149. <tr>
  150. <? if ($_POST['tracker_type'] == 0) { ?>
  151. <tr>
  152. <td class="left_caption">Affiliate Network</td>
  153. <td><? echo $html['aff_network_name']; ?></td>
  154. </tr>
  155. <tr>
  156. <td class="left_caption">Campaign</td>
  157. <td><? echo $html['aff_campaign_name']; ?><td>
  158. </tr>
  159. <? } ?>
  160. <tr>
  161. <td class="left_caption">Text Ad</td>
  162. <td><? echo $html['text_ad_name']; ?></td>
  163. </tr>
  164. <? if ($_POST['tracker_type'] == 0) { ?>
  165. <tr>
  166. <td class="left_caption">Method of Promotion</td>
  167. <td><? echo $html['method_of_promotion']; ?></td>
  168. </tr>
  169. <? } ?>
  170. <tr valign="top">
  171. <td class="left_caption">Landing Page</td>
  172. <td><? echo $html['landing_page_name']; ?></td>
  173. </tr>
  174. <tr>
  175. <td class="left_caption">PPC Network</td>
  176. <td><? echo $html['ppc_network_name']; ?></td>
  177. </tr>
  178. <tr>
  179. <td class="left_caption">PPC Account</td>
  180. <td><? echo $html['ppc_account_name']; ?></td>
  181. </tr>
  182. <tr>
  183. <td class="left_caption">From</td>
  184. <td><? echo $html['from']; ?></td>
  185. </tr>
  186. <tr>
  187. <td class="left_caption">To</td>
  188. <td><? echo $html['to']; ?></td>
  189. </tr>
  190. <tr>
  191. <td class="left_caption">Updated CPC</td>
  192. <td><? echo $html['click_cpc']; ?></td>
  193. </tr>
  194. <tr>
  195. <td colspan="2"><p style="font-weight: bold; color: #900; text-align: center;">BE VERY SURE YOU WANT TO DO THIS!</td>
  196. </tr>
  197. <tr valign="middle">
  198. <td colspan="2" style="text-align: center;"><button onclick="update_cpc2();">Update My CPC</button> <img id="update_cpc2_loading" style="display: none;" src="/xtracks-img/loader-small.gif"/></td>
  199. </tr>
  200. </table
  201. <div id="update_cpc2" style="width: 500px; margin: 0px auto;"></div>