<?php
    include_once '../../account/session.php';
    include_once '../../../scripts/bd.php';
    
    if($_SESSION["type"] == 'it') {
      die("404 not found: <a href='/app/manager/offer/show.php'>Go back</a>");
    }
    
    if(isset($_GET['action'])){
        $action=$_GET['action'];
        if($action=='show')show();
        if($action=='show_mailer')show_mailer();
   }
   
   function show(){ 
      $list=array();
      $data= bd::query("SELECT mailer_log.id,mailer_log.id_server,mailer_log.connect_ip,mailer_log.activity,mailer_log.date_activity,server.id as id_server,server.name as name_server,account_mailer.username,account_mailer.id as id_mailer FROM mailer_log,server,account_mailer WHERE mailer_log.id_mailer=account_mailer.id && mailer_log.id_server=server.id");
      while ($row = mysql_fetch_object($data)) {
          $list[]=$row;
      }
      echo json_encode($list);
   }
   
   function show_mailer(){ 
      $list=array();
      $data= bd::query("SELECT mailer_log.id,mailer_log.id_server,mailer_log.connect_ip,mailer_log.activity,mailer_log.date_activity,server.id as id_server,server.name as name_server FROM mailer_log,server WHERE id_mailer='{$_GET["id"]}' && mailer_log.id_server=server.id");
      while ($row = mysql_fetch_object($data)) {
          $list[]=$row;
      }
      echo json_encode($list);
   }
   
   function get(){ 
      $data = bd::query("SELECT id,username FROM account_mailer WHERE id='{$_GET["id_mailer"]}'");
      $row = mysql_fetch_array($data);
      return $row;
   }