Advertisement
Guest User

Untitled

a guest
Feb 7th, 2021
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 53.74 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.1.0.1
  8. * @ Author : DeZender
  9. * @ Release on : 29.08.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class ApplicationController extends Controller
  15. {
  16. final public function license_check($addoncode = '', $from_framework = 0)
  17. {
  18. $lic_data = '';
  19.  
  20. for ($i = 0; $i < VALIDATOR_SERVER_COUNT; $i++) {
  21. $validator = ($i == 0 ? 'validator' : 'validator' . $i);
  22. $url = 'http://' . $validator . '.mariascripts.com/index.php?page=license/validate/' . PRODUCT_CODE . '/' . $_SERVER['HTTP_HOST'] . '/' . LICENSE_KEY;
  23. $lic_data = '';
  24. if ((ini_get('allow_url_fopen') == 1) && ($fp_license = fopen($url, 'r'))) {
  25. while (!feof($fp_license)) {
  26. $lic_data .= fgetc($fp_license);
  27. }
  28.  
  29. fclose($fp_license);
  30. }
  31. else if (function_exists('curl_init')) {
  32. $ch = curl_init();
  33. curl_setopt($ch, CURLOPT_URL, $url);
  34. curl_setopt($ch, CURLOPT_HEADER, 0);
  35. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  36. $content = curl_exec($ch);
  37. curl_close($ch);
  38. $lic_data = $content;
  39. }
  40. else {
  41. Main::print_error('Either URL fopen or CURL must be enabled on your server.');
  42. exit();
  43. }
  44.  
  45. if ($lic_data == -1) {
  46. $this->set_root_cookie(COOKIE_ADMIN_USERNAME, '', 0, ADMIN_DIR);
  47. $this->set_root_cookie(COOKIE_ADMIN_PASSWORD, '', 0, ADMIN_DIR);
  48. $this->set_root_cookie(COOKIE_ADMIN_LOGINID, '', 0, ADMIN_DIR);
  49. $this->set_root_cookie(COOKIE_ADMIN_TYPE, '', 0, ADMIN_DIR);
  50.  
  51. if ($from_framework == 0) {
  52. Main::print_error('License validation failed. Please verify the key in your configuration file.');
  53. exit();
  54. }
  55. else {
  56. return $lic_data;
  57. }
  58.  
  59. continue;
  60. }
  61.  
  62. if ($lic_data == 1) {
  63. if ($from_framework == 0) {
  64. break;
  65. }
  66. else {
  67. return $lic_data;
  68. }
  69.  
  70. continue;
  71. }
  72.  
  73. continue;
  74. }
  75.  
  76. if ($lic_data == '') {
  77. return $this->check_license_validation_network_failure();
  78. }
  79. }
  80.  
  81. final public function check_license_validation_network_failure()
  82. {
  83. $db = DAL::get_instance();
  84. $rowdata = $db->execute_query('SELECT id,value FROM ' . TABLE_PREFIX . 'config WHERE name=?', ['report_lnfth']);
  85. $rowdatacount = $rowdata->get_num_records();
  86. $config_id = 0;
  87. $report_lnfth = '';
  88.  
  89. if (0 < $rowdatacount) {
  90. $rowdatacontent = $rowdata->fetch_assoc();
  91. $config_id = $rowdatacontent['id'];
  92. $report_lnfth = $rowdatacontent['value'];
  93. }
  94.  
  95. $secret_key = 'xyzadmarkethash';
  96. $failure_time = 0;
  97. $hash = '';
  98. $dbinsert_flag = 0;
  99. $print_error_flag = 0;
  100. $current_time = time();
  101.  
  102. if ($report_lnfth != '') {
  103. $report_array = json_decode($report_lnfth, 1);
  104.  
  105. if (isset($report_array['ft'])) {
  106. $failure_time = intval($report_array['ft']);
  107. }
  108.  
  109. if (isset($report_array['h'])) {
  110. $hash = $report_array['h'];
  111. }
  112.  
  113. if (0 < $failure_time) {
  114. if (43200 <= $current_time - $failure_time) {
  115. $print_error_flag = 1;
  116. }
  117. }
  118. else {
  119. $dbinsert_flag = 1;
  120. $print_error_flag = 1;
  121. }
  122.  
  123. if ($print_error_flag == 0) {
  124. $created_hash = md5($failure_time . $secret_key);
  125.  
  126. if ($hash != $created_hash) {
  127. $print_error_flag = 1;
  128. }
  129. }
  130. }
  131. else {
  132. $dbinsert_flag = 1;
  133. $print_error_flag = 1;
  134. }
  135.  
  136. if ($dbinsert_flag == 1) {
  137. $failure_time = $current_time;
  138. $new_hash = md5($failure_time . $secret_key);
  139. $json_data = '{"ft":' . $failure_time . ',"h":"' . $new_hash . '"}';
  140.  
  141. if ($config_id == 0) {
  142. $db->execute_query('INSERT INTO `' . TABLE_PREFIX . 'config` (`id`, `name`, `value`) VALUES (?,?,?)', ['', 'report_lnfth', $json_data]);
  143. }
  144. else {
  145. $db->execute_query('UPDATE `' . TABLE_PREFIX . 'config` SET value=? WHERE name=?', [$json_data, 'report_lnfth']);
  146. }
  147. }
  148.  
  149. if ($print_error_flag == 1) {
  150. Main::print_error('Unable to validate license. If you are repeatedly getting this error please contact support desk.');
  151. exit();
  152. }
  153. else {
  154. return 1;
  155. }
  156. }
  157.  
  158. public function before_execute()
  159. {
  160. parent::before_execute();
  161. $curr_folder = substr(getcwd(), strrpos(getcwd(), DIRECTORY_SEPARATOR) + 1);
  162.  
  163. if ($curr_folder != INSTALL_DIR) {
  164. date_default_timezone_set(Configuration::get_instance()->read('default_time_zone'));
  165. }
  166. }
  167.  
  168. public function get_fraud_type($type)
  169. {
  170. if ($type == 1) {
  171. $fraud = $this->get_label('repetitive click');
  172. }
  173. else if ($type == 2) {
  174. $fraud = $this->get_label('publisher fraud click');
  175. }
  176. else if ($type == 3) {
  177. $fraud = $this->get_label('invalid ip click');
  178. }
  179. else if ($type == 4) {
  180. $fraud = $this->get_label('invalid geo click');
  181. }
  182. else if ($type == 5) {
  183. $fraud = $this->get_label('proxy click');
  184. }
  185. else if ($type == 6) {
  186. $fraud = $this->get_label('bot click');
  187. }
  188. else if ($type == 7) {
  189. $fraud = $this->get_label('ip limit exceed');
  190. }
  191.  
  192. return $fraud;
  193. }
  194.  
  195. public function get_publisher_top_adunits($time_flag = 3, $pid = 0, $display_type = 0)
  196. {
  197. $cpa_addon_enabled = $this->get_addon_status('cpa_enabled');
  198. $cpm_addon_enabled = $this->get_addon_status('cpm_enabled');
  199. $html_addon_enabled = $this->get_addon_status('html_enabled');
  200. $pop_addon_enabled = $this->get_addon_status('pop-ads_enabled');
  201. $affiliate_addon_enabled = $this->get_addon_status('affiliate-ads_enabled');
  202. $cpv_addon_enabled = $this->get_addon_status('video-ads_enabled');
  203. $result_array = [];
  204. $db = DAL::get_instance();
  205. $query_string = '';
  206. $uidspc_str = '';
  207.  
  208. if ($pid == 0) {
  209. $query_string = '';
  210. $uidspc_str = '';
  211. }
  212. else {
  213. $query_string .= ' s.uid=\'' . intval($pid) . '\' and ';
  214. $uidspc_str .= ' and a.pubid=\'' . intval($pid) . '\' ';
  215. }
  216.  
  217. $impressionstring = '';
  218. $datastring = '';
  219.  
  220. if ($display_type == 0) {
  221. $impressionstring = ' sum(s.pub_profit) ';
  222. $datastring = ' AND (display_type=0 OR display_type=4) ';
  223. }
  224. else if (($display_type == 1) && ($cpm_addon_enabled == 1) && ($html_addon_enabled == 1)) {
  225. $impressionstring = ' sum(s.cpm_profit+s.html_profit) ';
  226. $datastring = ' AND (display_type=1 OR display_type=4) ';
  227. }
  228. else if (($display_type == 1) && ($cpm_addon_enabled == 1)) {
  229. $impressionstring = ' sum(s.cpm_profit) ';
  230. $datastring = ' AND (display_type=1 OR display_type=4) ';
  231. }
  232. else if (($display_type == 1) && ($html_addon_enabled == 1)) {
  233. $impressionstring = ' sum(s.html_profit) ';
  234. $datastring = ' AND (display_type=1 OR display_type=4) ';
  235. }
  236. else if (($display_type == 6) && ($cpa_addon_enabled == 1)) {
  237. $impressionstring = ' sum(s.cpa_profit) ';
  238. $datastring = ' AND (display_type=6 OR display_type=4) ';
  239. }
  240. else if (($display_type == 9) && ($pop_addon_enabled == 1)) {
  241. $impressionstring = ' sum(s.pop_profit) ';
  242. $datastring = ' AND (display_type=9) ';
  243. }
  244. else if (($display_type == 12) && ($affiliate_addon_enabled == 1)) {
  245. $impressionstring = ' sum(s.affiliate_profit) ';
  246. $datastring = ' AND (display_type=12) ';
  247. }
  248. else if (($display_type == 13) && ($cpv_addon_enabled == 1)) {
  249. $impressionstring = ' sum(s.cpv_profit) ';
  250. $datastring = ' AND (display_type=13) ';
  251. }
  252.  
  253. $text_ads_enabled = Configuration::get_instance()->read('text-ads_enabled');
  254. $adtype_str = '';
  255.  
  256. if ($this->get_addon_status('interstitial_enabled') != 1) {
  257. $adtype_str .= ' ab.banner_type <>1 ';
  258. }
  259.  
  260. if ($this->get_addon_status('text-image-ads_enabled') != 1) {
  261. if ($adtype_str != '') {
  262. $adtype_str .= ' AND ';
  263. }
  264.  
  265. $adtype_str .= ' ab.banner_type <>3 ';
  266. }
  267.  
  268. if ($this->get_addon_status('skin-ads_enabled') != 1) {
  269. if ($adtype_str != '') {
  270. $adtype_str .= ' AND ';
  271. }
  272.  
  273. $adtype_str .= ' ab.banner_type <>4 ';
  274. }
  275.  
  276. if ($text_ads_enabled != 1) {
  277. if ($adtype_str != '') {
  278. $adtype_str .= ' AND ';
  279. }
  280.  
  281. $adtype_str .= ' ab.type <>1 ';
  282. }
  283.  
  284. if ($adtype_str != '') {
  285. $adtype_str = ' AND ((' . $adtype_str . ') OR ab.banner_type IS NULL) ';
  286. }
  287.  
  288. if ($time_flag == 1) {
  289. $start_time = date('Y', time());
  290. $start_time .= date('m', time());
  291. $start_time .= date('d', time());
  292. $start = $start_time;
  293. $table = TABLE_PREFIX . 'statistics_pub_daily';
  294. }
  295. else if ($time_flag == 2) {
  296. $start_time = date('Y', time());
  297. $start_time .= date('m', time());
  298. $start_time .= date('d', time());
  299.  
  300. for ($i = 0; $i < 13; $i++) {
  301. $start_time = $this->get_previous_day($start_time);
  302. }
  303.  
  304. $start = $start_time;
  305. $table = TABLE_PREFIX . 'statistics_pub_daily';
  306. }
  307. else if ($time_flag == 3) {
  308. $start_time = date('Y', time());
  309. $start_time .= date('m', time());
  310. $start_time .= date('d', time());
  311.  
  312. for ($i = 0; $i < 29; $i++) {
  313. $start_time = $this->get_previous_day($start_time);
  314. }
  315.  
  316. $start = $start_time;
  317. $table = TABLE_PREFIX . 'statistics_pub_daily';
  318. }
  319. else if ($time_flag == 4) {
  320. $start_time = date('Y', time());
  321. $start_time .= date('m', time());
  322. $start_temp = $start_time;
  323.  
  324. for ($i = 0; $i < 11; $i++) {
  325. $start_time = $this->get_previous_month($start_time);
  326. }
  327.  
  328. $start = $start_time;
  329. $table = TABLE_PREFIX . 'statistics_pub_monthly';
  330. $table1 = TABLE_PREFIX . 'statistics_pub_monthly_temp';
  331. }
  332. else if ($time_flag == 5) {
  333. $start_temp = date('Y', time());
  334. $start = 0;
  335. $table = TABLE_PREFIX . 'statistics_pub_yearly';
  336. $table1 = TABLE_PREFIX . 'statistics_pub_yearly_temp';
  337. }
  338. if (($time_flag == 1) || ($time_flag == 2) || ($time_flag == 3)) {
  339. $row_res = $db->execute_query('SELECT a.id as aduid,a.pubid as apubid,a.name as aduname,display_type as disp from ' . TABLE_PREFIX . 'adunit a LEFT OUTER JOIN ' . TABLE_PREFIX . 'adblock ab ON ab.id=a.blockid LEFT OUTER JOIN ' . $table . ' s ON a.id=s.bid WHERE display_type <>3 ' . $datastring . $adtype_str . ' AND ((' . $query_string . ' s.time >=?) OR (s.uid IS NULL AND s.time IS NULL)) ' . $uidspc_str . ' GROUP BY a.id ORDER BY ' . $impressionstring . ' DESC LIMIT 0,6', [$start]);
  340. }
  341. else if (($time_flag == 4) || ($time_flag == 5)) {
  342. $row = 'SELECT x.aduid as aduid,x.apubid as apubid,x.aduname as aduname,x.disp as disp FROM' . "\r\n\t\t" . '((SELECT a.id as aduid,' . $impressionstring . ' as impss,a.pubid as apubid,a.name as aduname,display_type as disp from ' . TABLE_PREFIX . 'adunit a LEFT OUTER JOIN ' . TABLE_PREFIX . 'adblock ab ON ab.id=a.blockid LEFT OUTER JOIN ' . $table . ' s ON a.id=s.bid WHERE display_type <>3 ' . $datastring . $adtype_str . ' AND ((' . $query_string . ' s.time >=?) OR (s.uid IS NULL AND s.time IS NULL)) ' . $uidspc_str . ' GROUP BY a.id ORDER BY impss DESC LIMIT 0,6)' . "\r\n\t\t\t\t" . 'UNION (SELECT a.id as aduid,' . $impressionstring . ' as impss,a.pubid as apubid,a.name as aduname,display_type as disp from ' . TABLE_PREFIX . 'adunit a LEFT OUTER JOIN ' . TABLE_PREFIX . 'adblock ab ON ab.id=a.blockid LEFT OUTER JOIN ' . $table1 . ' s ON a.id=s.bid WHERE display_type <>3 ' . $datastring . $adtype_str . ' AND ((' . $query_string . ' s.time >=?) OR (s.uid IS NULL AND s.time IS NULL)) ' . $uidspc_str . ' GROUP BY a.id ORDER BY impss DESC LIMIT 0,6)) as x GROUP BY x.aduid ORDER BY sum(x.impss) DESC LIMIT 0,6';
  343. $row_res = $db->execute_query($row, [$start, $start_temp]);
  344. }
  345.  
  346. $key = 0;
  347.  
  348. while ($row_result = $row_res->fetch_assoc()) {
  349. $result_array[$key][0] = $row_result['aduid'];
  350. $result_array[$key][1] = $row_result['apubid'];
  351.  
  352. if (0 < $row_result['apubid']) {
  353. $result_array[$key][2] = $this->get_user_name($row_result['apubid']);
  354. }
  355. else {
  356. $result_array[$key][2] = $this->get_label('admin');
  357. }
  358.  
  359. $result_array[$key][3] = $row_result['aduname'];
  360. $result_array[$key][4] = $row_result['disp'];
  361. $key = $key + 1;
  362. }
  363.  
  364. return $result_array;
  365. }
  366.  
  367. public function get_advertiser_top_ads($time_flag = 3, $uid = 0, $display_type = 0)
  368. {
  369. $cpa_addon_enabled = $this->get_addon_status('cpa_enabled');
  370. $cpm_addon_enabled = $this->get_addon_status('cpm_enabled');
  371. $html_addon_enabled = $this->get_addon_status('html_enabled');
  372. $pop_addon_enabled = $this->get_addon_status('pop-ads_enabled');
  373. $affiliate_addon_enabled = $this->get_addon_status('affiliate-ads_enabled');
  374. $cpv_addon_enabled = $this->get_addon_status('video-ads_enabled');
  375. $text_ads_enabled = Configuration::get_instance()->read('text-ads_enabled');
  376. $result_array = [];
  377. $db = DAL::get_instance();
  378. $query_string = '';
  379. $uidspc_str = '';
  380.  
  381. if ($uid == 0) {
  382. $query_string = '';
  383. $uidspc_str = '';
  384. }
  385. else {
  386. $query_string .= ' s.uid=\'' . intval($uid) . '\' and ';
  387. $uidspc_str .= ' and a.uid=\'' . intval($uid) . '\' ';
  388. }
  389.  
  390. if ($time_flag == 1) {
  391. $start_time = date('Y', time());
  392. $start_time .= date('m', time());
  393. $start_time .= date('d', time());
  394. $start = $start_time;
  395. $table = TABLE_PREFIX . 'statistics_adv_daily';
  396. }
  397. else if ($time_flag == 2) {
  398. $start_time = date('Y', time());
  399. $start_time .= date('m', time());
  400. $start_time .= date('d', time());
  401.  
  402. for ($i = 0; $i < 13; $i++) {
  403. $start_time = $this->get_previous_day($start_time);
  404. }
  405.  
  406. $start = $start_time;
  407. $table = TABLE_PREFIX . 'statistics_adv_daily';
  408. }
  409. else if ($time_flag == 3) {
  410. $start_time = date('Y', time());
  411. $start_time .= date('m', time());
  412. $start_time .= date('d', time());
  413.  
  414. for ($i = 0; $i < 29; $i++) {
  415. $start_time = $this->get_previous_day($start_time);
  416. }
  417.  
  418. $start = $start_time;
  419. $table = TABLE_PREFIX . 'statistics_adv_daily';
  420. }
  421. else if ($time_flag == 4) {
  422. $start_time = date('Y', time());
  423. $start_time .= date('m', time());
  424. $start_temp = $start_time;
  425.  
  426. for ($i = 0; $i < 11; $i++) {
  427. $start_time = $this->get_previous_month($start_time);
  428. }
  429.  
  430. $start = $start_time;
  431. $table = TABLE_PREFIX . 'statistics_adv_monthly';
  432. $table1 = TABLE_PREFIX . 'statistics_adv_monthly_temp';
  433. }
  434. else if ($time_flag == 5) {
  435. $start_temp = date('Y', time());
  436. $start = 0;
  437. $table = TABLE_PREFIX . 'statistics_adv_yearly';
  438. $table1 = TABLE_PREFIX . 'statistics_adv_yearly_temp';
  439. }
  440.  
  441. $impressionstring = '';
  442. $uidstrings = '';
  443.  
  444. if ($display_type == 0) {
  445. $impressionstring = ' sum(s.money_spent) ';
  446. $uidstrings = ' and a.uid<>0 ';
  447. }
  448. else if (($display_type == 1) && ($cpm_addon_enabled == 1)) {
  449. $impressionstring = ' sum(s.cpm_spend) ';
  450. $uidstrings = ' and a.uid<>0 ';
  451. }
  452. else if (($display_type == 2) && ($html_addon_enabled == 1)) {
  453. $impressionstring = ' sum(s.html_profit) ';
  454. $uidstrings = ' and a.uid=0 AND a.html_default =0 ';
  455. }
  456. else if (($display_type == 6) && ($cpa_addon_enabled == 1)) {
  457. $impressionstring = ' sum(s.cpa_spend) ';
  458. $uidstrings = ' and a.uid<>0 ';
  459. }
  460. else if (($display_type == 9) && ($pop_addon_enabled == 1)) {
  461. $impressionstring = ' sum(s.pop_spend) ';
  462. $uidstrings = ' and a.uid<>0 ';
  463. }
  464. else if (($display_type == 12) && ($affiliate_addon_enabled == 1)) {
  465. $impressionstring = ' sum(s.affiliate_spend) ';
  466. $uidstrings = ' and a.uid<>0 ';
  467. }
  468. else if (($display_type == 13) && ($cpv_addon_enabled == 1)) {
  469. $impressionstring = ' sum(s.cpv_spend) ';
  470. $uidstrings = ' and a.uid<>0 ';
  471. }
  472.  
  473. $adtype_str = '';
  474.  
  475. if ($this->get_addon_status('ecommerce-ads_enabled') != 1) {
  476. $adtype_str .= ' AND a.type <>7 ';
  477. }
  478. else {
  479. $adtype_str .= ' AND (a.type <>7 OR (a.type =7 AND a.ecommerce_parent >0)) ';
  480. }
  481.  
  482. if ($this->get_addon_status('text-image-ads_enabled') != 1) {
  483. $adtype_str .= ' AND a.type <>11 ';
  484. }
  485.  
  486. if ($this->get_addon_status('interstitial_enabled') != 1) {
  487. $adtype_str .= ' AND a.type <>5 ';
  488. }
  489.  
  490. if ($cpv_addon_enabled != 1) {
  491. $adtype_str .= ' AND a.type <>13 ';
  492. }
  493.  
  494. if ($this->get_addon_status('skin-ads_enabled') != 1) {
  495. $adtype_str .= ' AND a.type <>14 ';
  496. }
  497.  
  498. if ($text_ads_enabled != 1) {
  499. $adtype_str .= ' AND a.type <>1 ';
  500. }
  501. if (($time_flag == 1) || ($time_flag == 2) || ($time_flag == 3)) {
  502. $row_res = $db->execute_query('SELECT a.id as ad_id,a.uid as auid,a.name as aname from ' . TABLE_PREFIX . 'ads a LEFT OUTER JOIN ' . $table . ' s ON a.id=s.aid WHERE a.display_type <>3 AND ((' . $query_string . ' s.time >=?) OR (s.uid IS NULL AND s.time IS NULL)) ' . $uidstrings . $adtype_str . ' and a.status=? and a.display_type=? ' . $uidspc_str . ' GROUP BY a.id ORDER BY ' . $impressionstring . ' DESC LIMIT 0,6', [$start, 1, $display_type]);
  503. }
  504. else if (($time_flag == 4) || ($time_flag == 5)) {
  505. $row_res = $db->execute_query('SELECT x.ad_id as ad_id,x.auid as auid,x.aname as aname FROM' . "\r\n\t\t" . '((SELECT a.id as ad_id,' . $impressionstring . ' as impss,a.uid as auid,a.name as aname from ' . TABLE_PREFIX . 'ads a LEFT OUTER JOIN ' . $table . ' s ON a.id=s.aid WHERE a.display_type <>3 AND ((' . $query_string . ' s.time >=?) OR (s.uid IS NULL AND s.time IS NULL)) ' . $uidstrings . $adtype_str . ' and a.status=1 and a.display_type=? ' . $uidspc_str . ' GROUP BY a.id ORDER BY impss DESC LIMIT 0,6)' . "\r\n\t\t\t\t" . 'UNION (SELECT a.id as ad_id,' . $impressionstring . ' as impss,a.uid as auid,a.name as aname from ' . TABLE_PREFIX . 'ads a LEFT OUTER JOIN ' . $table1 . ' s ON a.id=s.aid WHERE a.display_type <>3 AND ((' . $query_string . ' s.time >=?) OR (s.uid IS NULL AND s.time IS NULL)) ' . $uidstrings . $adtype_str . ' and a.status=1 and a.display_type=? ' . $uidspc_str . ' GROUP BY a.id ORDER BY impss DESC LIMIT 0,6)) as x GROUP BY x.ad_id ORDER BY sum(x.impss) DESC LIMIT 0,6', [$start, $display_type, $start_temp, $display_type]);
  506. }
  507.  
  508. $key = 0;
  509.  
  510. while ($row_result = $row_res->fetch_assoc()) {
  511. $result_array[$key][0] = $row_result['ad_id'];
  512. $result_array[$key][1] = $row_result['auid'];
  513. $result_array[$key][2] = $this->get_user_name($row_result['auid']);
  514. $result_array[$key][3] = $row_result['aname'];
  515. $key = $key + 1;
  516. }
  517.  
  518. return $result_array;
  519. }
  520.  
  521. public function get_suggested_value_ad($type, $aid, $bannerid = 0, $pricing = 0, $device = 2)
  522. {
  523. $increment_value = 0.01;
  524. $db = DAL::get_instance();
  525. $uid = $this->read_cookie_param(COOKIE_LOGINID);
  526. $devicestring = '';
  527.  
  528. if ($device != 2) {
  529. $devicestring = ' AND (a.device=2 OR a.device=' . intval($device) . ') ';
  530. }
  531. if (($type == 2) || ($type == 7)) {
  532. $typestring = ' AND (a.type=2 OR a.type=7) ';
  533. }
  534. else {
  535. $typestring = ' AND a.type=' . intval($type) . ' ';
  536. }
  537.  
  538. $sugest_val = $db->read_single_column('SELECT COALESCE(round(max(default_rate),2),0) FROM ' . "\r\n\t\t\t\t" . TABLE_PREFIX . 'ads a ' . "\r\n\t\t\t\t" . 'WHERE a.status=1 ' . "\r\n\t\t\t\t" . 'AND a.id<>? ' . "\r\n\t\t\t\t" . 'AND a.display_type=?' . "\r\n\t\t\t\t" . 'AND a.pause_status=0' . "\r\n\t\t\t\t" . 'AND a.pricing_status=1' . "\r\n\t\t\t\t" . 'AND a.user_status=1' . "\r\n\t\t\t\t" . $devicestring . "\t\t\t\t\r\n\t\t\t\t" . $typestring . "\r\n\t\t\t\t" . 'AND a.banner_id=?', [$aid, $pricing, $bannerid]);
  539. $minvalue = $this->get_minrate_by_uid($uid, $pricing);
  540.  
  541. if ($minvalue <= $sugest_val) {
  542. $value = $sugest_val + $increment_value;
  543. }
  544. else {
  545. $value = $minvalue;
  546. }
  547.  
  548. return $value;
  549. }
  550.  
  551. public function get_date_format($type, $year, $month = '', $day = '', $hour = '')
  552. {
  553. $d = Configuration::get_instance()->read('day_format');
  554. $m = Configuration::get_instance()->read('month_format');
  555. $y = Configuration::get_instance()->read('year_format');
  556. $dp = Configuration::get_instance()->read('day_position');
  557. $ds = Configuration::get_instance()->read('day_separator');
  558. $hs = Configuration::get_instance()->read('time_separator');
  559. $hds = Configuration::get_instance()->read('hour_display_format');
  560. $h = Configuration::get_instance()->read('hour_format');
  561. $mfor = Configuration::get_instance()->read('minute_format');
  562. $sfor = Configuration::get_instance()->read('second_format');
  563.  
  564. if ($type == 2) {
  565. $time = $year;
  566. $cday = date('j', $time);
  567. $cday1 = date('d', $time);
  568. $cmonth0 = date('n', $time);
  569. $cmonth = date('m', $time);
  570. $cmonth1 = date('M', $time);
  571. $cyear = date('y', $time);
  572. $cyear1 = date('Y', $time);
  573.  
  574. if ($hds == 12) {
  575. if ($h == 'HH') {
  576. $chour = date('h', $time);
  577. }
  578. else {
  579. $chour = date('g', $time);
  580. }
  581. }
  582. else if ($hds == 24) {
  583. if ($h == 'HH') {
  584. $chour = date('H', $time);
  585. }
  586. else {
  587. $chour = date('G', $time);
  588. }
  589. }
  590.  
  591. $cminute = date('i', $time);
  592.  
  593. if ($mfor == 'M') {
  594. if ($cminute < 10) {
  595. $cminute = substr($cminute, -1);
  596. }
  597. }
  598.  
  599. $csecond = date('s', $time);
  600.  
  601. if ($sfor == 'S') {
  602. if ($csecond < 10) {
  603. $csecond = substr($csecond, -1);
  604. }
  605. }
  606.  
  607. $cformat = date('A', $time);
  608. $datestring = '';
  609.  
  610. if ($d == 'd') {
  611. $datestring_day = $cday;
  612. }
  613. else if ($d == 'D') {
  614. $datestring_day = $cday1;
  615. }
  616.  
  617. if ($m == 'm') {
  618. $daystring_month = $cmonth0;
  619. }
  620. else if ($m == 'M') {
  621. $daystring_month = $cmonth;
  622. }
  623. else if ($m == 'Mon') {
  624. $daystring_month = $cmonth1;
  625. }
  626.  
  627. if ($y == 'y') {
  628. $daystring_year = $cyear;
  629. }
  630. else if ($y == 'Y') {
  631. $daystring_year = $cyear1;
  632. }
  633.  
  634. if ($hds == 12) {
  635. $daystring_time = ' ' . $chour . $hs . $cminute . $hs . $csecond . ' ' . $cformat;
  636. }
  637. else if ($hds == 24) {
  638. $daystring_time = ' ' . $chour . $hs . $cminute . $hs . $csecond;
  639. }
  640.  
  641. if ($dp == 1) {
  642. $datestring = $datestring_day . $ds . $daystring_month . $ds . $daystring_year . $daystring_time;
  643. }
  644. else if ($dp == 2) {
  645. $datestring = $daystring_month . $ds . $datestring_day . $ds . $daystring_year . $daystring_time;
  646. }
  647. else if ($dp == 3) {
  648. $datestring = $daystring_year . $ds . $daystring_month . $ds . $datestring_day . $daystring_time;
  649. }
  650. else if ($dp == 4) {
  651. $datestring = $daystring_year . $ds . $datestring_day . $ds . $daystring_month . $daystring_time;
  652. }
  653.  
  654. return $datestring;
  655. }
  656.  
  657. if ($type == 1) {
  658. $day_str = '';
  659. $month_str = '';
  660. $hour_str = '';
  661.  
  662. if ($hour != '') {
  663. $hour_str = ' ' . $hour;
  664. }
  665.  
  666. if ($day != '') {
  667. if ($d == 'd') {
  668. $day_first = substr($day, 0, 1);
  669.  
  670. if ($day_first == 0) {
  671. $day = substr($day, 1, 1);
  672. }
  673. }
  674.  
  675. if ($dp == 3) {
  676. $day_str = $day;
  677. }
  678. else {
  679. $day_str = $day . $ds;
  680. }
  681. }
  682.  
  683. if ($month != '') {
  684. if ($m == 'm') {
  685. $month_first = substr($month, 0, 1);
  686.  
  687. if ($month_first == 0) {
  688. $month = substr($month, 1, 1);
  689. }
  690. }
  691. else if ($m == 'Mon') {
  692. if ($month == '01') {
  693. $month = 'Jan';
  694. }
  695. else if ($month == '02') {
  696. $month = 'Feb';
  697. }
  698. else if ($month == '03') {
  699. $month = 'Mar';
  700. }
  701. else if ($month == '04') {
  702. $month = 'Apr';
  703. }
  704. else if ($month == '05') {
  705. $month = 'May';
  706. }
  707. else if ($month == '06') {
  708. $month = 'Jun';
  709. }
  710. else if ($month == '07') {
  711. $month = 'Jul';
  712. }
  713. else if ($month == '08') {
  714. $month = 'Aug';
  715. }
  716. else if ($month == '09') {
  717. $month = 'Sep';
  718. }
  719. else if ($month == '10') {
  720. $month = 'Oct';
  721. }
  722. else if ($month == '11') {
  723. $month = 'Nov';
  724. }
  725. else if ($month == '12') {
  726. $month = 'Dec';
  727. }
  728. }
  729.  
  730. if ($dp == 4) {
  731. $month_str = $month;
  732. }
  733. else {
  734. $month_str = $month . $ds;
  735. }
  736. }
  737.  
  738. if ($y == 'y') {
  739. $year = substr($year, 2, 2);
  740. }
  741.  
  742. if ($dp == 1) {
  743. $d_format = $day_str . $month_str . $year . $hour_str;
  744. }
  745. else if ($dp == 2) {
  746. $d_format = $month_str . $day_str . $year . $hour_str;
  747. }
  748. else if ($dp == 3) {
  749. $d_format = $year . $ds . $month_str . $day_str . $hour_str;
  750. }
  751. else if ($dp == 4) {
  752. $d_format = $year . $ds . $day_str . $month_str . $hour_str;
  753. }
  754.  
  755. return $d_format;
  756. }
  757.  
  758. if ($type == 3) {
  759. $time = $year;
  760. $cday = date('j', $time);
  761. $cday1 = date('d', $time);
  762. $cmonth0 = date('n', $time);
  763. $cmonth = date('m', $time);
  764. $cmonth1 = date('M', $time);
  765. $cyear = date('y', $time);
  766. $cyear1 = date('Y', $time);
  767. $datestring = '';
  768.  
  769. if ($d == 'd') {
  770. $datestring_day = $cday;
  771. }
  772. else if ($d == 'D') {
  773. $datestring_day = $cday1;
  774. }
  775.  
  776. if ($m == 'm') {
  777. $daystring_month = $cmonth0;
  778. }
  779. else if ($m == 'M') {
  780. $daystring_month = $cmonth;
  781. }
  782. else if ($m == 'Mon') {
  783. $daystring_month = $cmonth1;
  784. }
  785.  
  786. if ($y == 'y') {
  787. $daystring_year = $cyear;
  788. }
  789. else if ($y == 'Y') {
  790. $daystring_year = $cyear1;
  791. }
  792.  
  793. $daystring_time = '';
  794.  
  795. if ($dp == 1) {
  796. $datestring = $datestring_day . $ds . $daystring_month . $ds . $daystring_year . $daystring_time;
  797. }
  798. else if ($dp == 2) {
  799. $datestring = $daystring_month . $ds . $datestring_day . $ds . $daystring_year . $daystring_time;
  800. }
  801. else if ($dp == 3) {
  802. $datestring = $daystring_year . $ds . $daystring_month . $ds . $datestring_day . $daystring_time;
  803. }
  804. else if ($dp == 4) {
  805. $datestring = $daystring_year . $ds . $datestring_day . $ds . $daystring_month . $daystring_time;
  806. }
  807.  
  808. return $datestring;
  809. }
  810. }
  811.  
  812. public function get_number_format($value, $places = 2)
  813. {
  814. $ts = Configuration::get_instance()->read('thousand_separator');
  815. $ds = Configuration::get_instance()->read('decimal_separator');
  816. $ds_places = Configuration::get_instance()->read('decimal_place');
  817.  
  818. if ($places == 0) {
  819. $value = sprintf('%d', round($value, $ds_places));
  820. return number_format($value, 0, $ds, $ts);
  821. }
  822. else {
  823. $value = sprintf('%0.' . $ds_places . 'F', round($value, $ds_places));
  824. return number_format($value, $ds_places, $ds, $ts);
  825. }
  826. }
  827.  
  828. public function get_money_format($money, $places = 2)
  829. {
  830. $money = self::get_number_format($money, $places);
  831.  
  832. if (Configuration::get_instance()->read('currency_position') == 1) {
  833. $money = Configuration::get_instance()->read('currency_symbol') . ' ' . $money;
  834. }
  835. else {
  836. $money = $money . ' ' . Configuration::get_instance()->read('currency_symbol');
  837. }
  838.  
  839. return $money;
  840. }
  841.  
  842. public function get_advertiser_check_statistics($time_flag)
  843. {
  844. $cpa_addon_enabled = $this->get_addon_status('cpa_enabled');
  845. $cpm_addon_enabled = $this->get_addon_status('cpm_enabled');
  846. $html_addon_enabled = $this->get_addon_status('html_enabled');
  847. $pop_addon_enabled = $this->get_addon_status('pop-ads_enabled');
  848. $affiliate_addon_enabled = $this->get_addon_status('affiliate-ads_enabled');
  849. $cpv_addon_enabled = $this->get_addon_status('video-ads_enabled');
  850.  
  851. if ($cpa_addon_enabled == 1) {
  852. $cpaquerystring = ' ,COALESCE(sum(cpa_impression),0) as cpaimp,COALESCE(sum(cpa_click),0) as cpaclick,COALESCE(sum(cpa_conversion),0) as cpaconversion,COALESCE(sum(cpa_spend),0) as cpaspend,COALESCE(sum(cpa_profit),0) as cpaprofit ';
  853. $cpaquerystring1 = ' ,COALESCE(sum(x.cpaimp),0) as cpaimp,COALESCE(sum(x.cpaclick),0) as cpaclick,COALESCE(sum(x.cpaconversion),0) as cpaconversion,COALESCE(sum(x.cpaspend),0) as cpaspend,COALESCE(sum(x.cpaprofit),0) as cpaprofit ';
  854. $cpaquerystring2 = ' ,COALESCE(sum(cpa_impression),0) as cpaimp ';
  855. }
  856. else {
  857. $cpaquerystring = '';
  858. $cpaquerystring1 = '';
  859. $cpaquerystring2 = '';
  860. }
  861.  
  862. if ($affiliate_addon_enabled == 1) {
  863. $cpaquerystring .= ' ,COALESCE(sum(affiliate_click),0) as affiliateclick,COALESCE(sum(affiliate_conversion),0) as affiliateconversion,COALESCE(sum(affiliate_spend),0) as affiliatespend,COALESCE(sum(affiliate_profit),0) as affiliateprofit ';
  864. $cpaquerystring1 .= ' ,COALESCE(sum(x.affiliateclick),0) as affiliateclick,COALESCE(sum(x.affiliateconversion),0) as affiliateconversion,COALESCE(sum(x.affiliatespend),0) as affiliatespend,COALESCE(sum(x.affiliateprofit),0) as affiliateprofit ';
  865. }
  866.  
  867. if ($cpm_addon_enabled == 1) {
  868. $cpmquerystring = ' ,COALESCE(sum(cpm_impression),0) as cpmimp,COALESCE(sum(cpm_spend),0) as cpmspend,COALESCE(sum(cpm_profit),0) as cpmprofit,COALESCE(sum(cpm_click),0) as cpmclick ';
  869. $cpmquerystring1 = ' ,COALESCE(sum(x.cpmimp),0) as cpmimp,COALESCE(sum(x.cpmspend),0) as cpmspend,COALESCE(sum(x.cpmprofit),0) as cpmprofit,COALESCE(sum(x.cpmclick),0) as cpmclick ';
  870. }
  871. else {
  872. $cpmquerystring = '';
  873. $cpmquerystring1 = '';
  874. }
  875.  
  876. if ($cpv_addon_enabled == 1) {
  877. $cpmquerystring .= ' ,COALESCE(sum(cpv_impression),0) as cpvimp,COALESCE(sum(cpv_spend),0) as cpvspend,COALESCE(sum(cpv_profit),0) as cpvprofit,COALESCE(sum(cpv_click),0) as cpvclick ';
  878. $cpmquerystring1 .= ' ,COALESCE(sum(x.cpvimp),0) as cpvimp,COALESCE(sum(x.cpvspend),0) as cpvspend,COALESCE(sum(x.cpvprofit),0) as cpvprofit,COALESCE(sum(x.cpvclick),0) as cpvclick ';
  879. }
  880.  
  881. if ($pop_addon_enabled == 1) {
  882. $cpmquerystring .= ' ,COALESCE(sum(pop_impression),0) as popimp,COALESCE(sum(pop_spend),0) as popspend,COALESCE(sum(pop_profit),0) as popprofit ';
  883. $cpmquerystring1 .= ' ,COALESCE(sum(x.popimp),0) as popimp,COALESCE(sum(x.popspend),0) as popspend,COALESCE(sum(x.popprofit),0) as popprofit ';
  884. }
  885.  
  886. if ($html_addon_enabled == 1) {
  887. $htmlquerystring = ' ,COALESCE(sum(html_impression),0) as htmlimp,COALESCE(sum(html_profit),0) as htmlprofit ';
  888. $htmlquerystring1 = ' ,COALESCE(sum(x.htmlimp),0) as htmlimp,COALESCE(sum(x.htmlprofit),0) as htmlprofit ';
  889. }
  890. else {
  891. $htmlquerystring = '';
  892. $htmlquerystring1 = '';
  893. }
  894.  
  895. $db = DAL::get_instance();
  896. $data_array = [];
  897.  
  898. if ($time_flag == 3) {
  899. $start_time = date('Y', time());
  900. $start_time .= date('m', time());
  901. $start_time .= date('d', time());
  902. $current_time = $start_time;
  903. $start = date('Y', time());
  904. $start .= date('m', time());
  905. $start .= '01';
  906. $table = TABLE_PREFIX . 'statistics_adv_daily';
  907. }
  908. else if ($time_flag == 4) {
  909. $start_time = date('Y', time());
  910. $start_time .= date('m', time());
  911. $start_time = $this->get_previous_month($start_time);
  912. $current_time = $start_time;
  913. $start_temp = $start_time;
  914. $start = date('Y', time());
  915. $start .= '01';
  916. $table = TABLE_PREFIX . 'statistics_adv_monthly';
  917. $table1 = TABLE_PREFIX . 'statistics_adv_monthly_temp';
  918. }
  919. else if ($time_flag == 5) {
  920. $start_temp = date('Y', time());
  921. $start_temp = $this->get_previousyear($start_temp);
  922. $current_time = $start_temp;
  923. $start = $db->read_single_column('SELECT min(time) FROM ' . TABLE_PREFIX . 'statistics_adv_yearly');
  924. if (($start == '') || ($start == 0)) {
  925. $start = $start_temp;
  926. }
  927.  
  928. $table = TABLE_PREFIX . 'statistics_adv_yearly';
  929. $table1 = TABLE_PREFIX . 'statistics_adv_yearly_temp';
  930. }
  931.  
  932. if ($time_flag == 3) {
  933. $row_res = $db->execute_query('SELECT COALESCE(sum(impression),0) as imp,COALESCE(sum(click),0) as clk,COALESCE(sum(money_spent),0) as spent,time' . $cpmquerystring . ' ' . $htmlquerystring . ' ' . $cpaquerystring . ' FROM ' . $table . ' WHERE time >=? GROUP BY time ORDER BY time ASC', [$start]);
  934. $today_array = [];
  935.  
  936. while ($tdy = $row_res->fetch_assoc()) {
  937. $key = $tdy['time'];
  938. $today_array[$key]['impression'] = $tdy['imp'];
  939. $today_array[$key]['click'] = $tdy['clk'];
  940. $today_array[$key]['money_spent'] = $tdy['spent'];
  941.  
  942. if ($cpm_addon_enabled == 1) {
  943. $today_array[$key]['cpm_impression'] = $tdy['cpmimp'];
  944. $today_array[$key]['cpm_spend'] = $tdy['cpmspend'];
  945. $today_array[$key]['cpm_click'] = $tdy['cpmclick'];
  946. }
  947.  
  948. if ($cpv_addon_enabled == 1) {
  949. $today_array[$key]['cpv_impression'] = $tdy['cpvimp'];
  950. $today_array[$key]['cpv_spend'] = $tdy['cpvspend'];
  951. $today_array[$key]['cpv_click'] = $tdy['cpvclick'];
  952. }
  953.  
  954. if ($html_addon_enabled == 1) {
  955. $today_array[$key]['html_impression'] = $tdy['htmlimp'];
  956. $today_array[$key]['html_profit'] = $tdy['htmlprofit'];
  957. }
  958.  
  959. if ($cpa_addon_enabled == 1) {
  960. $today_array[$key]['cpa_impression'] = $tdy['cpaimp'];
  961. $today_array[$key]['cpa_click'] = $tdy['cpaclick'];
  962. $today_array[$key]['cpa_conversion'] = $tdy['cpaconversion'];
  963. $today_array[$key]['cpa_spend'] = $tdy['cpaspend'];
  964. $today_array[$key]['cpa_profit'] = $tdy['cpaprofit'];
  965. }
  966.  
  967. if ($affiliate_addon_enabled == 1) {
  968. $today_array[$key]['affiliate_click'] = $tdy['affiliateclick'];
  969. $today_array[$key]['affiliate_conversion'] = $tdy['affiliateconversion'];
  970. $today_array[$key]['affiliate_spend'] = $tdy['affiliatespend'];
  971. $today_array[$key]['affiliate_profit'] = $tdy['affiliateprofit'];
  972. }
  973.  
  974. if ($pop_addon_enabled == 1) {
  975. $today_array[$key]['pop_impression'] = $tdy['popimp'];
  976. $today_array[$key]['pop_spend'] = $tdy['popspend'];
  977. }
  978. }
  979. }
  980. else if (($time_flag == 4) || ($time_flag == 5)) {
  981. $row_res = $db->execute_query('SELECT COALESCE(sum(x.imp),0) as imp,COALESCE(sum(x.clk),0) as clk,COALESCE(sum(x.spent),0) as spent,time' . $cpmquerystring1 . ' ' . $htmlquerystring1 . ' ' . $cpaquerystring1 . ' FROM' . "\r\n\t\t\t" . '((SELECT COALESCE(sum(impression),0) as imp,COALESCE(sum(click),0) as clk,COALESCE(sum(money_spent),0) as spent,time' . $cpmquerystring . ' ' . $htmlquerystring . ' ' . $cpaquerystring . ' FROM ' . $table . ' WHERE time >=? GROUP BY time ORDER BY time ASC)' . "\r\n\t\t\t" . 'UNION (SELECT COALESCE(sum(impression),0) as imp,COALESCE(sum(click),0) as clk,COALESCE(sum(money_spent),0) as spent,time' . $cpmquerystring . ' ' . $htmlquerystring . ' ' . $cpaquerystring . ' FROM ' . $table1 . ' WHERE time >=? GROUP BY time ORDER BY time ASC)) as x' . "\r\n\t\t\t" . 'GROUP BY x.time ORDER BY x.time ASC', [$start, $start_temp]);
  982. $today_array = [];
  983.  
  984. while ($tdy = $row_res->fetch_assoc()) {
  985. $key = $tdy['time'];
  986. $today_array[$key]['impression'] = $tdy['imp'];
  987. $today_array[$key]['click'] = $tdy['clk'];
  988. $today_array[$key]['money_spent'] = $tdy['spent'];
  989.  
  990. if ($cpm_addon_enabled == 1) {
  991. $today_array[$key]['cpm_impression'] = $tdy['cpmimp'];
  992. $today_array[$key]['cpm_spend'] = $tdy['cpmspend'];
  993. $today_array[$key]['cpm_click'] = $tdy['cpmclick'];
  994. }
  995.  
  996. if ($cpv_addon_enabled == 1) {
  997. $today_array[$key]['cpv_impression'] = $tdy['cpvimp'];
  998. $today_array[$key]['cpv_spend'] = $tdy['cpvspend'];
  999. $today_array[$key]['cpv_click'] = $tdy['cpvclick'];
  1000. }
  1001.  
  1002. if ($html_addon_enabled == 1) {
  1003. $today_array[$key]['html_impression'] = $tdy['htmlimp'];
  1004. $today_array[$key]['html_profit'] = $tdy['htmlprofit'];
  1005. }
  1006.  
  1007. if ($cpa_addon_enabled == 1) {
  1008. $today_array[$key]['cpa_impression'] = $tdy['cpaimp'];
  1009. $today_array[$key]['cpa_click'] = $tdy['cpaclick'];
  1010. $today_array[$key]['cpa_conversion'] = $tdy['cpaconversion'];
  1011. $today_array[$key]['cpa_spend'] = $tdy['cpaspend'];
  1012. $today_array[$key]['cpa_profit'] = $tdy['cpaprofit'];
  1013. }
  1014.  
  1015. if ($affiliate_addon_enabled == 1) {
  1016. $today_array[$key]['affiliate_click'] = $tdy['affiliateclick'];
  1017. $today_array[$key]['affiliate_conversion'] = $tdy['affiliateconversion'];
  1018. $today_array[$key]['affiliate_spend'] = $tdy['affiliatespend'];
  1019. $today_array[$key]['affiliate_profit'] = $tdy['affiliateprofit'];
  1020. }
  1021.  
  1022. if ($pop_addon_enabled == 1) {
  1023. $today_array[$key]['pop_impression'] = $tdy['popimp'];
  1024. $today_array[$key]['pop_spend'] = $tdy['popspend'];
  1025. }
  1026. }
  1027. }
  1028.  
  1029. while ($start <= $current_time) {
  1030. if (array_key_exists($start, $today_array)) {
  1031. $data_array[$start]['impression'] = $today_array[$start]['impression'];
  1032. $data_array[$start]['click'] = $today_array[$start]['click'];
  1033. $data_array[$start]['money_spent'] = $today_array[$start]['money_spent'];
  1034.  
  1035. if ($cpm_addon_enabled == 1) {
  1036. $data_array[$start]['cpm_impression'] = $today_array[$start]['cpm_impression'];
  1037. $data_array[$start]['cpm_spend'] = $today_array[$start]['cpm_spend'];
  1038. $data_array[$start]['cpm_click'] = $today_array[$start]['cpm_click'];
  1039. }
  1040.  
  1041. if ($cpv_addon_enabled == 1) {
  1042. $data_array[$start]['cpv_impression'] = $today_array[$start]['cpv_impression'];
  1043. $data_array[$start]['cpv_spend'] = $today_array[$start]['cpv_spend'];
  1044. $data_array[$start]['cpv_click'] = $today_array[$start]['cpv_click'];
  1045. }
  1046.  
  1047. if ($html_addon_enabled == 1) {
  1048. $data_array[$start]['html_impression'] = $today_array[$start]['html_impression'];
  1049. $data_array[$start]['html_profit'] = $today_array[$start]['html_profit'];
  1050. }
  1051.  
  1052. if ($cpa_addon_enabled == 1) {
  1053. $data_array[$start]['cpa_impression'] = $today_array[$start]['cpa_impression'];
  1054. $data_array[$start]['cpa_click'] = $today_array[$start]['cpa_click'];
  1055. $data_array[$start]['cpa_conversion'] = $today_array[$start]['cpa_conversion'];
  1056. $data_array[$start]['cpa_spend'] = $today_array[$start]['cpa_spend'];
  1057. $data_array[$start]['cpa_profit'] = $today_array[$start]['cpa_profit'];
  1058. }
  1059.  
  1060. if ($affiliate_addon_enabled == 1) {
  1061. $data_array[$start]['affiliate_click'] = $today_array[$start]['affiliate_click'];
  1062. $data_array[$start]['affiliate_conversion'] = $today_array[$start]['affiliate_conversion'];
  1063. $data_array[$start]['affiliate_spend'] = $today_array[$start]['affiliate_spend'];
  1064. $data_array[$start]['affiliate_profit'] = $today_array[$start]['affiliate_profit'];
  1065. }
  1066.  
  1067. if ($pop_addon_enabled == 1) {
  1068. $data_array[$start]['pop_impression'] = $today_array[$start]['pop_impression'];
  1069. $data_array[$start]['pop_spend'] = $today_array[$start]['pop_spend'];
  1070. }
  1071. }
  1072. else {
  1073. $data_array[$start]['impression'] = 0;
  1074. $data_array[$start]['click'] = 0;
  1075. $data_array[$start]['money_spent'] = 0;
  1076.  
  1077. if ($cpm_addon_enabled == 1) {
  1078. $data_array[$start]['cpm_impression'] = 0;
  1079. $data_array[$start]['cpm_spend'] = 0;
  1080. $data_array[$start]['cpm_click'] = 0;
  1081. }
  1082.  
  1083. if ($cpv_addon_enabled == 1) {
  1084. $data_array[$start]['cpv_impression'] = 0;
  1085. $data_array[$start]['cpv_spend'] = 0;
  1086. $data_array[$start]['cpv_click'] = 0;
  1087. }
  1088.  
  1089. if ($html_addon_enabled == 1) {
  1090. $data_array[$start]['html_impression'] = 0;
  1091. $data_array[$start]['html_profit'] = 0;
  1092. }
  1093.  
  1094. if ($cpa_addon_enabled == 1) {
  1095. $data_array[$start]['cpa_impression'] = 0;
  1096. $data_array[$start]['cpa_click'] = 0;
  1097. $data_array[$start]['cpa_conversion'] = 0;
  1098. $data_array[$start]['cpa_spend'] = 0;
  1099. $data_array[$start]['cpa_profit'] = 0;
  1100. }
  1101.  
  1102. if ($affiliate_addon_enabled == 1) {
  1103. $data_array[$start]['affiliate_click'] = 0;
  1104. $data_array[$start]['affiliate_conversion'] = 0;
  1105. $data_array[$start]['affiliate_spend'] = 0;
  1106. $data_array[$start]['affiliate_profit'] = 0;
  1107. }
  1108.  
  1109. if ($pop_addon_enabled == 1) {
  1110. $data_array[$start]['pop_impression'] = 0;
  1111. $data_array[$start]['pop_spend'] = 0;
  1112. }
  1113. }
  1114.  
  1115. if ($time_flag == 3) {
  1116. $start = $this->get_nextday($start);
  1117. continue;
  1118. }
  1119.  
  1120. if ($time_flag == 4) {
  1121. $start = $this->get_nextmonth($start);
  1122. continue;
  1123. }
  1124.  
  1125. if ($time_flag == 5) {
  1126. $start = $this->get_nextyear($start);
  1127. }
  1128. }
  1129.  
  1130. return $data_array;
  1131. }
  1132.  
  1133. public function get_publisher_check_statistics($time_flag)
  1134. {
  1135. $cpa_addon_enabled = $this->get_addon_status('cpa_enabled');
  1136. $cpm_addon_enabled = $this->get_addon_status('cpm_enabled');
  1137. $html_addon_enabled = $this->get_addon_status('html_enabled');
  1138. $pop_addon_enabled = $this->get_addon_status('pop-ads_enabled');
  1139. $affiliate_addon_enabled = $this->get_addon_status('affiliate-ads_enabled');
  1140. $cpv_addon_enabled = $this->get_addon_status('video-ads_enabled');
  1141.  
  1142. if ($cpa_addon_enabled == 1) {
  1143. $cpaquerystring = ' ,COALESCE(sum(cpa_impression),0) as cpaimp,COALESCE(sum(cpa_click),0) as cpaclick,COALESCE(sum(cpa_conversion),0) as cpaconversion,COALESCE(sum(cpa_spend),0) as cpaspend,COALESCE(sum(cpa_profit),0) as cpaprofit ';
  1144. $cpaquerystring1 = ' ,COALESCE(sum(x.cpaimp),0) as cpaimp,COALESCE(sum(x.cpaclick),0) as cpaclick,COALESCE(sum(x.cpaconversion),0) as cpaconversion,COALESCE(sum(x.cpaspend),0) as cpaspend,COALESCE(sum(x.cpaprofit),0) as cpaprofit ';
  1145. $cpaquerystring2 = ' ,COALESCE(sum(cpa_impression),0) as cpaimp ';
  1146. }
  1147. else {
  1148. $cpaquerystring = '';
  1149. $cpaquerystring1 = '';
  1150. $cpaquerystring2 = '';
  1151. }
  1152.  
  1153. if ($affiliate_addon_enabled == 1) {
  1154. $cpaquerystring .= ' ,COALESCE(sum(affiliate_click),0) as affiliateclick,COALESCE(sum(affiliate_conversion),0) as affiliateconversion,COALESCE(sum(affiliate_spend),0) as affiliatespend,COALESCE(sum(affiliate_profit),0) as affiliateprofit ';
  1155. $cpaquerystring1 .= ' ,COALESCE(sum(x.affiliateclick),0) as affiliateclick,COALESCE(sum(x.affiliateconversion),0) as affiliateconversion,COALESCE(sum(x.affiliatespend),0) as affiliatespend,COALESCE(sum(x.affiliateprofit),0) as affiliateprofit ';
  1156. }
  1157.  
  1158. if ($cpm_addon_enabled == 1) {
  1159. $cpmquerystring = ' ,COALESCE(sum(cpm_impression),0) as cpmimp,COALESCE(sum(cpm_spend),0) as cpmspend,COALESCE(sum(cpm_profit),0) as cpmprofit,COALESCE(sum(cpm_click),0) as cpmclick ';
  1160. $cpmquerystring1 = ' ,COALESCE(sum(x.cpmimp),0) as cpmimp,COALESCE(sum(x.cpmspend),0) as cpmspend,COALESCE(sum(x.cpmprofit),0) as cpmprofit,COALESCE(sum(x.cpmclick),0) as cpmclick ';
  1161. }
  1162. else {
  1163. $cpmquerystring = '';
  1164. $cpmquerystring1 = '';
  1165. }
  1166.  
  1167. if ($cpv_addon_enabled == 1) {
  1168. $cpmquerystring .= ' ,COALESCE(sum(cpv_impression),0) as cpvimp,COALESCE(sum(cpv_spend),0) as cpvspend,COALESCE(sum(cpv_profit),0) as cpvprofit,COALESCE(sum(cpv_click),0) as cpvclick ';
  1169. $cpmquerystring1 .= ' ,COALESCE(sum(x.cpvimp),0) as cpvimp,COALESCE(sum(x.cpvspend),0) as cpvspend,COALESCE(sum(x.cpvprofit),0) as cpvprofit,COALESCE(sum(x.cpvclick),0) as cpvclick ';
  1170. }
  1171.  
  1172. if ($pop_addon_enabled == 1) {
  1173. $cpmquerystring .= ' ,COALESCE(sum(pop_impression),0) as popimp,COALESCE(sum(pop_spend),0) as popspend,COALESCE(sum(pop_profit),0) as popprofit ';
  1174. $cpmquerystring1 .= ' ,COALESCE(sum(x.popimp),0) as popimp,COALESCE(sum(x.popspend),0) as popspend,COALESCE(sum(x.popprofit),0) as popprofit ';
  1175. }
  1176.  
  1177. if ($html_addon_enabled == 1) {
  1178. $htmlquerystring = ' ,COALESCE(sum(html_impression),0) as htmlimp,COALESCE(sum(html_profit),0) as htmlprofit ';
  1179. $htmlquerystring1 = ' ,COALESCE(sum(x.htmlimp),0) as htmlimp,COALESCE(sum(x.htmlprofit),0) as htmlprofit ';
  1180. }
  1181. else {
  1182. $htmlquerystring = '';
  1183. $htmlquerystring1 = '';
  1184. }
  1185.  
  1186. $db = DAL::get_instance();
  1187. $data_array = [];
  1188.  
  1189. if ($time_flag == 3) {
  1190. $start_time = date('Y', time());
  1191. $start_time .= date('m', time());
  1192. $start_time .= date('d', time());
  1193. $current_time = $start_time;
  1194. $start = date('Y', time());
  1195. $start .= date('m', time());
  1196. $start .= '01';
  1197. $table = TABLE_PREFIX . 'statistics_pub_daily';
  1198. }
  1199. else if ($time_flag == 4) {
  1200. $start_time = date('Y', time());
  1201. $start_time .= date('m', time());
  1202. $start_time = $this->get_previous_month($start_time);
  1203. $current_time = $start_time;
  1204. $start_temp = $start_time;
  1205. $start = date('Y', time());
  1206. $start .= '01';
  1207. $table = TABLE_PREFIX . 'statistics_pub_monthly';
  1208. $table1 = TABLE_PREFIX . 'statistics_pub_monthly_temp';
  1209. }
  1210. else if ($time_flag == 5) {
  1211. $start_temp = date('Y', time());
  1212. $start_temp = $this->get_previousyear($start_temp);
  1213. $current_time = $start_temp;
  1214. $start = $db->read_single_column('SELECT min(time) FROM ' . TABLE_PREFIX . 'statistics_pub_yearly');
  1215. if (($start == '') || ($start == 0)) {
  1216. $start = $start_temp;
  1217. }
  1218.  
  1219. $table = TABLE_PREFIX . 'statistics_pub_yearly';
  1220. $table1 = TABLE_PREFIX . 'statistics_pub_yearly_temp';
  1221. }
  1222.  
  1223. if ($time_flag == 3) {
  1224. $row_res = $db->execute_query('SELECT COALESCE(sum(impression),0) as imp,COALESCE(sum(click),0) as clk,COALESCE(sum(money_spent),0) as spent,time' . $cpmquerystring . ' ' . $htmlquerystring . ' ' . $cpaquerystring . ' FROM ' . $table . ' WHERE time >=? GROUP BY time ORDER BY time ASC', [$start]);
  1225. $today_array = [];
  1226.  
  1227. while ($tdy = $row_res->fetch_assoc()) {
  1228. $key = $tdy['time'];
  1229. $today_array[$key]['impression'] = $tdy['imp'];
  1230. $today_array[$key]['click'] = $tdy['clk'];
  1231. $today_array[$key]['money_spent'] = $tdy['spent'];
  1232.  
  1233. if ($cpm_addon_enabled == 1) {
  1234. $today_array[$key]['cpm_impression'] = $tdy['cpmimp'];
  1235. $today_array[$key]['cpm_spend'] = $tdy['cpmspend'];
  1236. $today_array[$key]['cpm_click'] = $tdy['cpmclick'];
  1237. }
  1238.  
  1239. if ($cpv_addon_enabled == 1) {
  1240. $today_array[$key]['cpv_impression'] = $tdy['cpvimp'];
  1241. $today_array[$key]['cpv_spend'] = $tdy['cpvspend'];
  1242. $today_array[$key]['cpv_click'] = $tdy['cpvclick'];
  1243. }
  1244.  
  1245. if ($html_addon_enabled == 1) {
  1246. $today_array[$key]['html_impression'] = $tdy['htmlimp'];
  1247. $today_array[$key]['html_profit'] = $tdy['htmlprofit'];
  1248. }
  1249.  
  1250. if ($cpa_addon_enabled == 1) {
  1251. $today_array[$key]['cpa_impression'] = $tdy['cpaimp'];
  1252. $today_array[$key]['cpa_click'] = $tdy['cpaclick'];
  1253. $today_array[$key]['cpa_conversion'] = $tdy['cpaconversion'];
  1254. $today_array[$key]['cpa_spend'] = $tdy['cpaspend'];
  1255. $today_array[$key]['cpa_profit'] = $tdy['cpaprofit'];
  1256. }
  1257.  
  1258. if ($affiliate_addon_enabled == 1) {
  1259. $today_array[$key]['affiliate_click'] = $tdy['affiliateclick'];
  1260. $today_array[$key]['affiliate_conversion'] = $tdy['affiliateconversion'];
  1261. $today_array[$key]['affiliate_spend'] = $tdy['affiliatespend'];
  1262. $today_array[$key]['affiliate_profit'] = $tdy['affiliateprofit'];
  1263. }
  1264.  
  1265. if ($pop_addon_enabled == 1) {
  1266. $today_array[$key]['pop_impression'] = $tdy['popimp'];
  1267. $today_array[$key]['pop_spend'] = $tdy['popspend'];
  1268. }
  1269. }
  1270. }
  1271. else if (($time_flag == 4) || ($time_flag == 5)) {
  1272. $row_res = $db->execute_query('SELECT COALESCE(sum(x.imp),0) as imp,COALESCE(sum(x.clk),0) as clk,COALESCE(sum(x.spent),0) as spent,time' . $cpmquerystring1 . ' ' . $htmlquerystring1 . ' ' . $cpaquerystring1 . ' FROM' . "\r\n\t\t\t" . '((SELECT COALESCE(sum(impression),0) as imp,COALESCE(sum(click),0) as clk,COALESCE(sum(money_spent),0) as spent,time' . $cpmquerystring . ' ' . $htmlquerystring . ' ' . $cpaquerystring . ' FROM ' . $table . ' WHERE time >=? GROUP BY time ORDER BY time ASC)' . "\r\n\t\t\t" . 'UNION (SELECT COALESCE(sum(impression),0) as imp,COALESCE(sum(click),0) as clk,COALESCE(sum(money_spent),0) as spent,time' . $cpmquerystring . ' ' . $htmlquerystring . ' ' . $cpaquerystring . ' FROM ' . $table1 . ' WHERE time >=? GROUP BY time ORDER BY time ASC)) as x' . "\r\n\t\t\t" . 'GROUP BY x.time ORDER BY x.time ASC', [$start, $start_temp]);
  1273. $today_array = [];
  1274.  
  1275. while ($tdy = $row_res->fetch_assoc()) {
  1276. $key = $tdy['time'];
  1277. $today_array[$key]['impression'] = $tdy['imp'];
  1278. $today_array[$key]['click'] = $tdy['clk'];
  1279. $today_array[$key]['money_spent'] = $tdy['spent'];
  1280.  
  1281. if ($cpm_addon_enabled == 1) {
  1282. $today_array[$key]['cpm_impression'] = $tdy['cpmimp'];
  1283. $today_array[$key]['cpm_spend'] = $tdy['cpmspend'];
  1284. $today_array[$key]['cpm_click'] = $tdy['cpmclick'];
  1285. }
  1286.  
  1287. if ($cpv_addon_enabled == 1) {
  1288. $today_array[$key]['cpv_impression'] = $tdy['cpvimp'];
  1289. $today_array[$key]['cpv_spend'] = $tdy['cpvspend'];
  1290. $today_array[$key]['cpv_click'] = $tdy['cpvclick'];
  1291. }
  1292.  
  1293. if ($html_addon_enabled == 1) {
  1294. $today_array[$key]['html_impression'] = $tdy['htmlimp'];
  1295. $today_array[$key]['html_profit'] = $tdy['htmlprofit'];
  1296. }
  1297.  
  1298. if ($cpa_addon_enabled == 1) {
  1299. $today_array[$key]['cpa_impression'] = $tdy['cpaimp'];
  1300. $today_array[$key]['cpa_click'] = $tdy['cpaclick'];
  1301. $today_array[$key]['cpa_conversion'] = $tdy['cpaconversion'];
  1302. $today_array[$key]['cpa_spend'] = $tdy['cpaspend'];
  1303. $today_array[$key]['cpa_profit'] = $tdy['cpaprofit'];
  1304. }
  1305.  
  1306. if ($affiliate_addon_enabled == 1) {
  1307. $today_array[$key]['affiliate_click'] = $tdy['affiliateclick'];
  1308. $today_array[$key]['affiliate_conversion'] = $tdy['affiliateconversion'];
  1309. $today_array[$key]['affiliate_spend'] = $tdy['affiliatespend'];
  1310. $today_array[$key]['affiliate_profit'] = $tdy['affiliateprofit'];
  1311. }
  1312.  
  1313. if ($pop_addon_enabled == 1) {
  1314. $today_array[$key]['pop_impression'] = $tdy['popimp'];
  1315. $today_array[$key]['pop_spend'] = $tdy['popspend'];
  1316. }
  1317. }
  1318. }
  1319.  
  1320. while ($start <= $current_time) {
  1321. if (array_key_exists($start, $today_array)) {
  1322. $data_array[$start]['impression'] = $today_array[$start]['impression'];
  1323. $data_array[$start]['click'] = $today_array[$start]['click'];
  1324. $data_array[$start]['money_spent'] = $today_array[$start]['money_spent'];
  1325.  
  1326. if ($cpm_addon_enabled == 1) {
  1327. $data_array[$start]['cpm_impression'] = $today_array[$start]['cpm_impression'];
  1328. $data_array[$start]['cpm_spend'] = $today_array[$start]['cpm_spend'];
  1329. $data_array[$start]['cpm_click'] = $today_array[$start]['cpm_click'];
  1330. }
  1331.  
  1332. if ($cpv_addon_enabled == 1) {
  1333. $data_array[$start]['cpv_impression'] = $today_array[$start]['cpv_impression'];
  1334. $data_array[$start]['cpv_spend'] = $today_array[$start]['cpv_spend'];
  1335. $data_array[$start]['cpv_click'] = $today_array[$start]['cpv_click'];
  1336. }
  1337.  
  1338. if ($html_addon_enabled == 1) {
  1339. $data_array[$start]['html_impression'] = $today_array[$start]['html_impression'];
  1340. $data_array[$start]['html_profit'] = $today_array[$start]['html_profit'];
  1341. }
  1342.  
  1343. if ($cpa_addon_enabled == 1) {
  1344. $data_array[$start]['cpa_impression'] = $today_array[$start]['cpa_impression'];
  1345. $data_array[$start]['cpa_click'] = $today_array[$start]['cpa_click'];
  1346. $data_array[$start]['cpa_conversion'] = $today_array[$start]['cpa_conversion'];
  1347. $data_array[$start]['cpa_spend'] = $today_array[$start]['cpa_spend'];
  1348. $data_array[$start]['cpa_profit'] = $today_array[$start]['cpa_profit'];
  1349. }
  1350.  
  1351. if ($affiliate_addon_enabled == 1) {
  1352. $data_array[$start]['affiliate_click'] = $today_array[$start]['affiliate_click'];
  1353. $data_array[$start]['affiliate_conversion'] = $today_array[$start]['affiliate_conversion'];
  1354. $data_array[$start]['affiliate_spend'] = $today_array[$start]['affiliate_spend'];
  1355. $data_array[$start]['affiliate_profit'] = $today_array[$start]['affiliate_profit'];
  1356. }
  1357.  
  1358. if ($pop_addon_enabled == 1) {
  1359. $data_array[$start]['pop_impression'] = $today_array[$start]['pop_impression'];
  1360. $data_array[$start]['pop_spend'] = $today_array[$start]['pop_spend'];
  1361. }
  1362. }
  1363. else {
  1364. $data_array[$start]['impression'] = 0;
  1365. $data_array[$start]['click'] = 0;
  1366. $data_array[$start]['money_spent'] = 0;
  1367.  
  1368. if ($cpm_addon_enabled == 1) {
  1369. $data_array[$start]['cpm_impression'] = 0;
  1370. $data_array[$start]['cpm_spend'] = 0;
  1371. $data_array[$start]['cpm_click'] = 0;
  1372. }
  1373.  
  1374. if ($cpv_addon_enabled == 1) {
  1375. $data_array[$start]['cpv_impression'] = 0;
  1376. $data_array[$start]['cpv_spend'] = 0;
  1377. $data_array[$start]['cpv_click'] = 0;
  1378. }
  1379.  
  1380. if ($html_addon_enabled == 1) {
  1381. $data_array[$start]['html_impression'] = 0;
  1382. $data_array[$start]['html_profit'] = 0;
  1383. }
  1384.  
  1385. if ($cpa_addon_enabled == 1) {
  1386. $data_array[$start]['cpa_impression'] = 0;
  1387. $data_array[$start]['cpa_click'] = 0;
  1388. $data_array[$start]['cpa_conversion'] = 0;
  1389. $data_array[$start]['cpa_spend'] = 0;
  1390. $data_array[$start]['cpa_profit'] = 0;
  1391. }
  1392.  
  1393. if ($affiliate_addon_enabled == 1) {
  1394. $data_array[$start]['affiliate_click'] = 0;
  1395. $data_array[$start]['affiliate_conversion'] = 0;
  1396. $data_array[$start]['affiliate_spend'] = 0;
  1397. $data_array[$start]['affiliate_profit'] = 0;
  1398. }
  1399.  
  1400. if ($pop_addon_enabled == 1) {
  1401. $data_array[$start]['pop_impression'] = 0;
  1402. $data_array[$start]['pop_spend'] = 0;
  1403. }
  1404. }
  1405.  
  1406. if ($time_flag == 3) {
  1407. $start = $this->get_nextday($start);
  1408. continue;
  1409. }
  1410.  
  1411. if ($time_flag == 4) {
  1412. $start = $this->get_nextmonth($start);
  1413. continue;
  1414. }
  1415.  
  1416. if ($time_flag == 5) {
  1417. $start = $this->get_nextyear($start);
  1418. }
  1419. }
  1420.  
  1421. return $data_array;
  1422. }
  1423.  
  1424. public function get_publisher_timeperiod_statistics($time_flag = 1, $pid = -1, $bid = 0, $sid = 0)
  1425. {
  1426. $cpa_addon_enabled = $this->get_addon_status('cpa_enabled');
  1427. $category_targeting_enabled = $this->get_addon_status('category-targeting_enabled');
  1428. $cpm_addon_enabled = $this->get_addon_status('cpm_enabled');
  1429. $html_addon_enabled = $this->get_addon_status('html_enabled');
  1430. $pop_addon_enabled = $this->get_addon_status('pop-ads_enabled');
  1431. $affiliate_addon_enabled = $this->get_addon_status('affiliate-ads_enabled');
  1432. $cpv_addon_enabled = $this->get_addon_status('video-ads_enabled');
  1433.  
  1434. if ($cpa_addon_enabled == 1) {
  1435. $cpaquerystring = ' ,COALESCE(sum(cpa_impression),0) as cpaimp,COALESCE(sum(cpa_click),0) as cpaclick,COALESCE(sum(cpa_conversion),0) as cpaconversion,COALESCE(sum(cpa_spend),0) as cpaspend,COALESCE(sum(cpa_profit),0) as cpaprofit ';
  1436. $cpaquerystring1 = ' ,COALESCE(sum(x.cpaimp),0) as cpaimp,COALESCE(sum(x.cpaclick),0) as cpaclick,COALESCE(sum(x.cpaconversion),0) as cpaconversion,COALESCE(sum(x.cpaspend),0) as cpaspend,COALESCE(sum(x.cpaprofit),0) as cpaprofit ';
  1437. $cpaquerystring2 = ' ,COALESCE(sum(cpa_impression),0) as cpaimp ';
  1438. }
  1439. else {
  1440. $cpaquerystring = '';
  1441. $cpaquerystring1 = '';
  1442. $cpaquerystring2 = '';
  1443. }
  1444.  
  1445. if ($affiliate_addon_enabled == 1) {
  1446. $cpaquerystring .= ' ,COALESCE(sum(affiliate_click),0) as affiliateclick,COALESCE(sum(affiliate_conversion),0) as affiliateconversion,COALESCE(sum(affiliate_spend),0) as affiliatespend,COALESCE(sum(affiliate_profit),0) as affiliateprofit ';
  1447. $cpaquerystring1 .= ' ,COALESCE(sum(x.affiliateclick),0) as affiliateclick,COALESCE(sum(x.affiliateconversion),0) as affiliateconversion,COALESCE(sum(x.affiliatespend),0) as affiliatespend,COALESCE(sum(x.affiliateprofit),0) as affiliateprofit ';
  1448. }
  1449.  
  1450. if ($cpm_addon_enabled == 1) {
  1451. $cpmquerystring = ' ,COALESCE(sum(cpm_impression),0) as cpmimp,COALESCE(sum(cpm_profit),0) as cpmprofit,COALESCE(sum(cpm_spend),0) as cpmspend ';
  1452. $cpmquerystring1 = ' ,COALESCE(sum(x.cpmimp),0) as cpmimp,COALESCE(sum(x.cpmprofit),0) as cpmprofit,COALESCE(sum(x.cpmspend),0) as cpmspend ';
  1453. $cpmquerystring2 = ' ,COALESCE(sum(cpm_click),0) as cpmclick ';
  1454. $cpmquerystring3 = ' ,COALESCE(sum(x.cpmclick),0) as cpmclick ';
  1455. }
  1456. else {
  1457. $cpmquerystring = '';
  1458. $cpmquerystring1 = '';
  1459. .................................................................
  1460. ..........................................
  1461. ...............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement