Advertisement
misha_evro

UTMWORK PART2

Jun 28th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.06 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $filename = scandir(__DIR__ . DIRECTORY_SEPARATOR . 'files/', 1);
  5.  
  6. define(FAILIK, __DIR__ . DIRECTORY_SEPARATOR . 'files/' . $filename[0]);
  7.  
  8. //echo FAILIK;
  9.  
  10. $db = array();
  11.  
  12. $file = file(FAILIK);
  13. unset($file[0]);
  14.  
  15. $last = count($file);
  16. unset($file[$last]);
  17. //echo $last;
  18.  
  19.  
  20. foreach ($file as $line) {
  21.  
  22.     $buf = explode(",", trim($line));
  23.     $db[$buf[0]] = $buf;
  24.  
  25.  
  26. }
  27.  
  28.  
  29. //var_dump($db);
  30.  
  31.  
  32. //utm_source,Clicks,"LP Views","LP Clicks","LP CTR",Leads,"Offer CVR","LP CVR",EPC,CPC,Rev.,Cost,P/L,ROI
  33.  
  34. if (isset($_POST['SUBMIT'])) {
  35.  
  36.  
  37.     foreach ($db as $parametr => $stats) {
  38.  
  39.         if ($stats[2] >=  $_POST['clicks'] and ((($stats[5] * $_POST['pay']) - ($stats[2] * $_POST['cpc'])) / ($stats[2] * $_POST['cpc']) * 100 ) <= $_POST['roi'])
  40.  
  41.         $vuvod[$parametr] = $stats;
  42.     }
  43.  
  44.  
  45.  
  46. }
  47.  
  48.  
  49. else {
  50.  
  51.     foreach ($db as $parametr => $stats) {
  52.  
  53.         $vuvod[$parametr] = $stats;
  54.     }
  55. }
  56.  
  57. //сортировка
  58.  
  59. uasort($parametr, 'cmp');
  60.  
  61. function cmp ($a, $b) {
  62.  
  63.   if ($a[2] == b[2]) {
  64.  
  65.       return 0;
  66.  
  67.   }
  68.  
  69.     return ($a[2] < b[2]) ? -1: 1;
  70.  
  71.  
  72. }
  73.  
  74. //сортировка
  75.  
  76.  
  77.  
  78. ?>
  79.  
  80.  
  81. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  82.         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  83. <html xmlns="http://www.w3.org/1999/xhtml">
  84. <head>
  85.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  86.     <title>Найди минусовые ПАБЫ ТЕЛЕГА</title>
  87.     <!-- Latest compiled and minified CSS -->
  88.     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
  89.     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
  90.     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
  91.  
  92. </head>
  93.  
  94. <body>
  95.  
  96.  
  97. <br/>
  98. <br/>
  99.  
  100.  
  101. <div style=" width: 500px; margin: 20px auto">
  102.     <form action="work.php" method="post" name="filtr">
  103.         <p>
  104.             <label for="textfield">CPC </label>
  105.             <input type="text" name="cpc" value="<?php echo $_POST['cpc'];?>" id="textfield"/>
  106.  
  107.  
  108.         </p>
  109.         <p><label for="textfield">CLICK/PARAM</label>
  110.             <input type="text" name="clicks" id="textfield" value="<?php echo $_POST['clicks'];?>"/></p>
  111.         <p><label for="textfield">PAYOUT</label>
  112.             <input type="text" name="pay" value="<?php echo $_POST['pay'];?>" id="textfield"/></p>
  113.         <p><label for="textfield">ROI</label>
  114.             <input type="text" name="roi" value="<?php echo $_POST['roi'];?>" id=</p>
  115.  
  116.         <p>
  117.             <input name="SUBMIT" type="submit" value="Фильтровать"/>
  118.     </form>
  119. </div>
  120.  
  121.  
  122. <br/>
  123. <br/>
  124.  
  125. <!--  utm_source,Clicks,"LP Views","LP Clicks","LP CTR",Leads,"Offer CVR","LP CVR",EPC,CPC,Rev.,Cost,P/L,ROI -->
  126. <div style=" width: 800px; margin: 20px auto">
  127.  
  128.     <?php echo $_POST['cpc'] * $stats[2] ;?>
  129.  
  130.  
  131.  
  132.     <div class="table-responsive">
  133.         <table class="table table-bordered">
  134.             <thead>
  135.             <tr>
  136.                 <th>utm_PARAM</th>
  137.                 <th>Clicks</th>
  138.                 <th>Leads</th>
  139.                 <th>Rev</th>
  140.                 <th>Cost</th>
  141.                 <th>P/L</th>
  142.                 <th>ROI</th>
  143.             </tr>
  144.             </thead>
  145.             <tbody>
  146.  
  147.  
  148.             <?php foreach ($vuvod as $parametr => $stats) { ?>
  149.                 <tr>
  150.                     <th><?php echo $parametr; ?></th>
  151.                     <th><?php echo $stats[2]; ?></th>
  152.                     <th><?php echo $stats[5]; ?></th>
  153.                     <th><?php echo $stats[5] * $_POST['pay']; ?></th>
  154.                     <th><?php echo $stats[2] * $_POST['cpc']; ?></th>
  155.                     <th><?php echo ($stats[5] * $_POST['pay']) - ($stats[2] * $_POST['cpc']); ?></th>
  156.                     <th><?php echo (($stats[5] * $_POST['pay']) - ($stats[2] * $_POST['cpc'])) / ($stats[2] * $_POST['cpc']) * 100; ?></th>
  157.  
  158.  
  159.                 </tr>
  160.             <?php } ?>
  161.  
  162.  
  163.             </tbody>
  164.         </table>
  165.     </div>
  166.  
  167.  
  168. </body>
  169. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement