|
- <?php
-
- require('fpdf/fpdf.php');
-
-
- class PDFO6H extends FPDF
- {
- protected $B = 0;
- protected $I = 0;
- protected $U = 0;
- protected $HREF = '';
-
- // Margins
- var $left = 10;
- var $right = 10;
- var $top = 10;
- var $bottom = 10;
-
-
- function WriteHTML($html)
- {
- // Intérprete de HTML
- $html = str_replace("\n",' ',$html);
- $a = preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
- foreach($a as $i=>$e)
- {
- if($i%2==0)
- {
- // Text
- if($this->HREF)
- $this->PutLink($this->HREF,$e);
- else
- $this->Write(5,$e);
- }
- else
- {
- // Etiqueta
- if($e[0]=='/')
- $this->CloseTag(strtoupper(substr($e,1)));
- else
- {
- // Extraer atributos
- $a2 = explode(' ',$e);
- $tag = strtoupper(array_shift($a2));
- $attr = array();
- foreach($a2 as $v)
- {
- if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
- $attr[strtoupper($a3[1])] = $a3[2];
- }
- $this->OpenTag($tag,$attr);
- }
- }
- }
- }
-
- function OpenTag($tag, $attr)
- {
- // Etiqueta de apertura
- if($tag=='B' || $tag=='I' || $tag=='U')
- $this->SetStyle($tag,true);
- if($tag=='A')
- $this->HREF = $attr['HREF'];
- if($tag=='BR')
- $this->Ln(5);
- }
-
- function CloseTag($tag)
- {
- // Etiqueta de cierre
- if($tag=='B' || $tag=='I' || $tag=='U')
- $this->SetStyle($tag,false);
- if($tag=='A')
- $this->HREF = '';
- }
-
- function SetStyle($tag, $enable)
- {
- // Modificar estilo y escoger la fuente correspondiente
- $this->$tag += ($enable ? 1 : -1);
- $style = '';
- foreach(array('B', 'I', 'U') as $s)
- {
- if($this->$s>0)
- $style .= $s;
- }
- $this->SetFont('',$style);
- }
-
- function PutLink($URL, $txt)
- {
- // Escribir un hiper-enlace
- $this->SetTextColor(0,0,255);
- $this->SetStyle('U',true);
- $this->Write(5,$txt,$URL);
- $this->SetStyle('U',false);
- $this->SetTextColor(0);
- }
- function ShadowCell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $color='G', $distance=0.5)
- {
- if($color=='G')
- $ShadowColor = 100;
- elseif($color=='B')
- $ShadowColor = 0;
- else
- $ShadowColor = $color;
- $TextColor = $this->TextColor;
- $x = $this->x;
- $this->SetTextColor($ShadowColor);
- $this->Cell($w, $h, $txt, $border, 0, $align, $fill, $link);
- $this->TextColor = $TextColor;
- $this->x = $x;
- $this->y += $distance;
- $this->Cell($w, $h, $txt, 0, $ln, $align);
- }
-
-
- // Create Table
- function WriteTable($tcolums)
- {
- // go through all colums
- for ($i = 0; $i < sizeof($tcolums); $i++)
- {
- $current_col = $tcolums[$i];
- $height = 0;
-
- // get max height of current col
- $nb=0;
- for($b = 0; $b < sizeof($current_col); $b++)
- {
- // set style
- $this->SetFont($current_col[$b]['font_name'], $current_col[$b]['font_style'], $current_col[$b]['font_size']);
- $color = explode(",", $current_col[$b]['fillcolor']);
- $this->SetFillColor($color[0], $color[1], $color[2]);
- $color = explode(",", $current_col[$b]['textcolor']);
- $this->SetTextColor($color[0], $color[1], $color[2]);
- $color = explode(",", $current_col[$b]['drawcolor']);
- $this->SetDrawColor($color[0], $color[1], $color[2]);
- $this->SetLineWidth($current_col[$b]['linewidth']);
-
- $nb = max($nb, $this->NbLines($current_col[$b]['width'], $current_col[$b]['text']));
- $height = $current_col[$b]['height'];
- }
- $h=$height*$nb;
-
-
- // Issue a page break first if needed
- $this->CheckPageBreak($h);
-
- // Draw the cells of the row
- for($b = 0; $b < sizeof($current_col); $b++)
- {
- $w = $current_col[$b]['width'];
- $a = $current_col[$b]['align'];
-
- // Save the current position
- $x=$this->GetX();
- $y=$this->GetY();
-
- // set style
- $this->SetFont($current_col[$b]['font_name'], $current_col[$b]['font_style'], $current_col[$b]['font_size']);
- $color = explode(",", $current_col[$b]['fillcolor']);
- $this->SetFillColor($color[0], $color[1], $color[2]);
- $color = explode(",", $current_col[$b]['textcolor']);
- $this->SetTextColor($color[0], $color[1], $color[2]);
- $color = explode(",", $current_col[$b]['drawcolor']);
- $this->SetDrawColor($color[0], $color[1], $color[2]);
- $this->SetLineWidth($current_col[$b]['linewidth']);
-
- $color = explode(",", $current_col[$b]['fillcolor']);
- $this->SetDrawColor($color[0], $color[1], $color[2]);
-
-
- // Draw Cell Background
- $this->Rect($x, $y, $w, $h, 'FD');
-
- $color = explode(",", $current_col[$b]['drawcolor']);
- $this->SetDrawColor($color[0], $color[1], $color[2]);
-
- // Draw Cell Border
- if (substr_count($current_col[$b]['linearea'], "T") > 0)
- {
- $this->Line($x, $y, $x+$w, $y);
- }
-
- if (substr_count($current_col[$b]['linearea'], "B") > 0)
- {
- $this->Line($x, $y+$h, $x+$w, $y+$h);
- }
-
- if (substr_count($current_col[$b]['linearea'], "L") > 0)
- {
- $this->Line($x, $y, $x, $y+$h);
- }
-
- if (substr_count($current_col[$b]['linearea'], "R") > 0)
- {
- $this->Line($x+$w, $y, $x+$w, $y+$h);
- }
-
-
- // Print the text
- $this->MultiCell($w, $current_col[$b]['height'], $current_col[$b]['text'], 0, $a, 0);
-
- // Put the position to the right of the cell
- $this->SetXY($x+$w, $y);
- }
-
- // Go to the next line
- $this->Ln($h);
- }
- }
-
-
- // If the height h would cause an overflow, add a new page immediately
- function CheckPageBreak($h)
- {
- if($this->GetY()+$h>$this->PageBreakTrigger)
- $this->AddPage($this->CurOrientation);
- }
-
-
- // Computes the number of lines a MultiCell of width w will take
- function NbLines($w, $txt)
- {
- $cw=&$this->CurrentFont['cw'];
- if($w==0)
- $w=$this->w-$this->rMargin-$this->x;
- $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
- $s=str_replace("\r", '', $txt);
- $nb=strlen($s);
- if($nb>0 and $s[$nb-1]=="\n")
- $nb--;
- $sep=-1;
- $i=0;
- $j=0;
- $l=0;
- $nl=1;
- while($i<$nb)
- {
- $c=$s[$i];
- if($c=="\n")
- {
- $i++;
- $sep=-1;
- $j=$i;
- $l=0;
- $nl++;
- continue;
- }
- if($c==' ')
- $sep=$i;
- $l+=$cw[$c];
- if($l>$wmax)
- {
- if($sep==-1)
- {
- if($i==$j)
- $i++;
- }
- else
- $i=$sep+1;
- $sep=-1;
- $j=$i;
- $l=0;
- $nl++;
- }
- else
- $i++;
- }
- return $nl;
- }
- }
-
-
- //$name = $_POST['name'];
- $info = $_POST['pdf_power2'];
- $nombreDominio = $_POST['dominio_nuevo'];
- //$nombre_base = $_POST['nombre_bd'];
- //$info=$_GET['datos_pdf'];
- $enlace = '<br><a href="http://www.open6hosting.com">www.open6hosting.com</a>';
-
- $hoy = date("d-m-Y H:i:s");
-
- $pdf = new PDFO6H();
- // Primera página
- $pdf->AddPage();
- $pdf->SetFont('Arial','',32);
- //$pdf->Write(5,'Para saber qué hay de nuevo en este tutorial, pulse ');
- $pdf->SetFont('','U');
- //$link = $pdf->AddLink();
- //$pdf->Write(5,'aquí',$link);
- $pdf->SetFont('');
- $pdf->SetTextColor(0, 200, 100);
- $Text = sprintf($_POST['dominio_nuevo'], 0.5);
- $pdf->ShadowCell(0, 80, $Text, 1, 1, 'C', false, '', 'B', 0.5);
- $pdf->SetTextColor(0, 0, 0);
-
- $pdf->AliasNbPages();
- $pdf->SetMargins($pdf->left, $pdf->top, $pdf->right);
- //$pdf->AddPage();
-
- // create table
- $columns = array();
-
- // header col
- $col = array();
- $col[] = array('text' => '', 'width' => '50', 'height' => '7', 'align' => 'C', 'font_name' => 'Arial', 'font_size' => '10', 'font_style' => 'B', 'fillcolor' => '255,255,255', 'textcolor' => '0,0,0', 'drawcolor' => '255,255,255', 'linewidth' => '0.4', 'linearea' => 'LTBR');
- $col[] = array('text' => 'BBDD', 'width' => '50', 'height' => '7', 'align' => 'C', 'font_name' => 'Arial', 'font_size' => '10', 'font_style' => 'B', 'fillcolor' => '135,206,250', 'textcolor' => '0,0,0', 'drawcolor' => '0,0,0', 'linewidth' => '0.4', 'linearea' => 'LTBR');
- $col[] = array('text' => 'FTP', 'width' => '50', 'height' => '7', 'align' => 'C', 'font_name' => 'Arial', 'font_size' => '10', 'font_style' => 'B', 'fillcolor' => '135,206,250', 'textcolor' => '0,0,0', 'drawcolor' => '0,0,0', 'linewidth' => '0.4', 'linearea' => 'LTBR');
- $columns[] = $col;
-
- // data col
- $col = array();
- $col[] = array('text' => 'Usuario', 'width' => '50', 'height' => '7', 'align' => 'C', 'font_name' => 'Arial', 'font_size' => '10', 'font_style' => '', 'fillcolor' => '255,255,255', 'textcolor' => '0,0,0', 'drawcolor' => '0,0,0', 'linewidth' => '0.4', 'linearea' => 'LTBR');
- $col[] = array('text' => 'NUsuario', 'width' => '50', 'height' => '7', 'align' => 'C', 'font_name' => 'Arial', 'font_size' => '10', 'font_style' => '', 'fillcolor' => '255,255,255', 'textcolor' => '0,0,0', 'drawcolor' => '0,0,0', 'linewidth' => '0.4', 'linearea' => 'LTBR');
- $col[] = array('text' => 'NUsuarioFTP', 'width' => '50', 'height' => '7', 'align' => 'C', 'font_name' => 'Arial', 'font_size' => '10', 'font_style' => '', 'fillcolor' => '255,255,255', 'textcolor' => '0,0,0', 'drawcolor' => '0,0,0', 'linewidth' => '0.4', 'linearea' => 'LTBR');
- $columns[] = $col;
-
- // data col
- $col = array();
- $col[] = array('text' => 'Clave', 'width' => '50', 'height' => '7', 'align' => 'C', 'font_name' => 'Arial', 'font_size' => '10', 'font_style' => '', 'fillcolor' => '255,255,255', 'textcolor' => '0,0,0', 'drawcolor' => '0,0,0', 'linewidth' => '0.4', 'linearea' => 'LTBR');
- $col[] = array('text' => 'NClave', 'width' => '50', 'height' => '7', 'align' => 'C', 'font_name' => 'Arial', 'font_size' => '10', 'font_style' => '', 'fillcolor' => '255,255,255', 'textcolor' => '0,0,0', 'drawcolor' => '0,0,0', 'linewidth' => '0.4', 'linearea' => 'LTBR');
- $col[] = array('text' => 'NClave', 'width' => '50', 'height' => '7', 'align' => 'C', 'font_name' => 'Arial', 'font_size' => '10', 'font_style' => '', 'fillcolor' => '255,255,255', 'textcolor' => '0,0,0', 'drawcolor' => '0,0,0', 'linewidth' => '0.4', 'linearea' => 'LTBR');
- $columns[] = $col;
-
- $pdf->WriteHTML('<br>');
-
-
-
- // Draw Table
- //$pdf->WriteTable($columns);
-
-
-
- //$pdf->AddPage();
- $pdf->SetLink($link);
- $pdf->Image('imagen/open6-logo.png',10,12,50,0,'','http://www.open6hosting.com');
- $pdf->SetLeftMargin(65);
- $pdf->SetFontSize(12);
- //$pdf->WriteHTML($name);
- $pdf->WriteHTML($info);
- $pdf->WriteHTML($enlace);
- //$pdf->WriteHTML($nombre_base);
- $pdf->Output();
-
- //header('Location: http://www.open6hosting.com');
- ?>
|