Ejemplo n.º 1
0
 /**
  * Index Page for this controller.
  *
  * Maps to the following URL
  * 		http://example.com/index.php/welcome
  *	- or -
  * 		http://example.com/index.php/welcome/index
  *	- or -
  * Since this controller is set as the default controller in
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see http://codeigniter.com/user_guide/general/urls.html
  */
 public function ubet()
 {
     $this->load->library('pdf');
     $pdf = new Pdf('L', 'mm', 'A4', true, 'UTF-8', false);
     //$pdf->setPrintHeader(false);
     //$pdf->setPrintFooter(false);
     $pdf->SetPrintFooter(false);
     //$pdf->SetAutoPageBreak(true, 9);
     $pdf->SetFont('dejavusans', '', 10);
     //$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     $pdf->AddPage();
     $pdf->SetFillColor(255, 255, 127);
     //$pdf->SetFont('helvetica', 'B', 12);
     //$pdf->getPageDimensions();
     //$hasBorder = false; //flag for fringe case
     $sql = "select customerName,contactLastName,contactFirstName from customers";
     $sqlq = $this->db->query($sql);
     $sqla = $sqlq->result_array();
     //print_r($sqla); //exit();
     $page = 0;
     foreach ($sqla as $row) {
         $maxnocells = 0;
         $cellcount = 0;
         //write text first
         $startX = $pdf->GetX();
         $startY = $pdf->GetY();
         //draw cells and record maximum cellcount
         //cell height is 6 and width is 80
         $cellcount = $pdf->MultiCell(30, 6, $row['customerName'], 0, 'L', 0, 0);
         if ($cellcount > $maxnocells) {
             $maxnocells = $cellcount;
         }
         $cellcount = $pdf->MultiCell(80, 6, $row['contactLastName'], 0, 'L', 0, 0);
         if ($cellcount > $maxnocells) {
             $maxnocells = $cellcount;
         }
         $cellcount = $pdf->MultiCell(80, 6, $row['contactFirstName'], 0, 'L', 0, 0);
         if ($cellcount > $maxnocells) {
             $maxnocells = $cellcount;
         }
         $page++;
         $pdf->SetXY($startX, $startY);
         //if($page>20){
         //$pdf->AddPage();
         //$page=0;
         //}
         //now do borders and fill
         //cell height is 6 times the max number of cells
         $pdf->MultiCell(30, $maxnocells * 6, '', 1, 'L', 0, 0);
         $pdf->MultiCell(80, $maxnocells * 6, '', 1, 'L', 0, 0);
         $pdf->MultiCell(80, $maxnocells * 6, '', 1, 'L', 0, 0);
         $pdf->Ln();
     }
     //$pdf->Cell(240,0,'','T');  //last bottom border
     $pdf->Output('example_005.pdf', 'I');
 }
Ejemplo n.º 2
0
     $pdf->SetFont('Big5', '', 9);
 } else {
     $profile_label = mb_convert_encoding($profile_label, 'ISO-8859-1', 'HTML-ENTITIES');
     $profile_data = mb_convert_encoding($profile_data, 'ISO-8859-1', 'HTML-ENTITIES');
     $pdf->SetFont('Helvetica', '', 9);
 }
 $pdf->Cell(30, 6, $profile_label . ":", 1, 0, 'L');
 $pdf->Cell(98, 6, $profile_data, 1, 0, 'L');
 //$pdf->Cell(70,6,"Owner: $query_uid",1,1,'L');
 $pdf->Cell(30, 6, $generated . ":", 1, 0, 'L');
 $pdf->Cell(32, 6, "{$gendate}", 1, 1, 'L');
 //$pdf->Cell(0, 6, "Subnet Description: $sub_desc", 1, 0, 'L');
 #    $pdf->Ln();
 $pdf->SetFont('Helvetica', '', 10);
 //get current possition so we can put the pie chart to the side
 $valX = $pdf->GetX();
 $valY = $pdf->GetY();
 $riskarray = array();
 //array of risks for pie chart
 $colorarray = array();
 //array of colors for pie chart
 //$query = "SELECT DISTINCT hostIP, hostname FROM vuln_nessus_results t1
 //    where report_id='$report_id' $query_host $query_critical order BY hostIP";
 $perms_where = Session::get_ctx_where() != "" ? " AND t1.ctx in (" . Session::get_ctx_where() . ")" : "";
 $query = "SELECT DISTINCT t1.hostip as hostIP, HEX(t1.ctx) as ctx\n             FROM vuln_nessus_results t1\n             where\n             t1.report_id in ({$report_id}) \n             {$query_host}\n             {$query_critical} \n             and falsepositive='N'\n             {$perms_where}\n             order BY hostIP";
 $result = $dbconn->execute($query);
 //initialise variable for number of hosts while loop
 $hosts = array();
 while ($row = $result->fields) {
     if (Session::hostAllowed_by_ip_ctx($dbconn, $row['hostIP'], $row['ctx'])) {
         $host_id = key(Asset_host::get_id_by_ips($dbconn, $row['hostIP'], $row['ctx']));