ISPConfig module for simplify the creation of websites and DNS zones in a only step
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

350 line
11 KiB

  1. <?php
  2. require('fpdf/fpdf.php');
  3. class PDFO6H extends FPDF
  4. {
  5. protected $B = 0;
  6. protected $I = 0;
  7. protected $U = 0;
  8. protected $HREF = '';
  9. // Margins
  10. var $left = 10;
  11. var $right = 10;
  12. var $top = 10;
  13. var $bottom = 10;
  14. function WriteHTML($html)
  15. {
  16. // Intérprete de HTML
  17. $html = str_replace("\n",' ',$html);
  18. $a = preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
  19. foreach($a as $i=>$e)
  20. {
  21. if($i%2==0)
  22. {
  23. // Text
  24. if($this->HREF)
  25. $this->PutLink($this->HREF,$e);
  26. else
  27. $this->Write(5,$e);
  28. }
  29. else
  30. {
  31. // Etiqueta
  32. if($e[0]=='/')
  33. $this->CloseTag(strtoupper(substr($e,1)));
  34. else
  35. {
  36. // Extraer atributos
  37. $a2 = explode(' ',$e);
  38. $tag = strtoupper(array_shift($a2));
  39. $attr = array();
  40. foreach($a2 as $v)
  41. {
  42. if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
  43. $attr[strtoupper($a3[1])] = $a3[2];
  44. }
  45. $this->OpenTag($tag,$attr);
  46. }
  47. }
  48. }
  49. }
  50. function OpenTag($tag, $attr)
  51. {
  52. // Etiqueta de apertura
  53. if($tag=='B' || $tag=='I' || $tag=='U')
  54. $this->SetStyle($tag,true);
  55. if($tag=='A')
  56. $this->HREF = $attr['HREF'];
  57. if($tag=='BR')
  58. $this->Ln(5);
  59. }
  60. function CloseTag($tag)
  61. {
  62. // Etiqueta de cierre
  63. if($tag=='B' || $tag=='I' || $tag=='U')
  64. $this->SetStyle($tag,false);
  65. if($tag=='A')
  66. $this->HREF = '';
  67. }
  68. function SetStyle($tag, $enable)
  69. {
  70. // Modificar estilo y escoger la fuente correspondiente
  71. $this->$tag += ($enable ? 1 : -1);
  72. $style = '';
  73. foreach(array('B', 'I', 'U') as $s)
  74. {
  75. if($this->$s>0)
  76. $style .= $s;
  77. }
  78. $this->SetFont('',$style);
  79. }
  80. function PutLink($URL, $txt)
  81. {
  82. // Escribir un hiper-enlace
  83. $this->SetTextColor(0,0,255);
  84. $this->SetStyle('U',true);
  85. $this->Write(5,$txt,$URL);
  86. $this->SetStyle('U',false);
  87. $this->SetTextColor(0);
  88. }
  89. function ShadowCell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $color='G', $distance=0.5)
  90. {
  91. if($color=='G')
  92. $ShadowColor = 100;
  93. elseif($color=='B')
  94. $ShadowColor = 0;
  95. else
  96. $ShadowColor = $color;
  97. $TextColor = $this->TextColor;
  98. $x = $this->x;
  99. $this->SetTextColor($ShadowColor);
  100. $this->Cell($w, $h, $txt, $border, 0, $align, $fill, $link);
  101. $this->TextColor = $TextColor;
  102. $this->x = $x;
  103. $this->y += $distance;
  104. $this->Cell($w, $h, $txt, 0, $ln, $align);
  105. }
  106. // Create Table
  107. function WriteTable($tcolums)
  108. {
  109. // go through all colums
  110. for ($i = 0; $i < sizeof($tcolums); $i++)
  111. {
  112. $current_col = $tcolums[$i];
  113. $height = 0;
  114. // get max height of current col
  115. $nb=0;
  116. for($b = 0; $b < sizeof($current_col); $b++)
  117. {
  118. // set style
  119. $this->SetFont($current_col[$b]['font_name'], $current_col[$b]['font_style'], $current_col[$b]['font_size']);
  120. $color = explode(",", $current_col[$b]['fillcolor']);
  121. $this->SetFillColor($color[0], $color[1], $color[2]);
  122. $color = explode(",", $current_col[$b]['textcolor']);
  123. $this->SetTextColor($color[0], $color[1], $color[2]);
  124. $color = explode(",", $current_col[$b]['drawcolor']);
  125. $this->SetDrawColor($color[0], $color[1], $color[2]);
  126. $this->SetLineWidth($current_col[$b]['linewidth']);
  127. $nb = max($nb, $this->NbLines($current_col[$b]['width'], $current_col[$b]['text']));
  128. $height = $current_col[$b]['height'];
  129. }
  130. $h=$height*$nb;
  131. // Issue a page break first if needed
  132. $this->CheckPageBreak($h);
  133. // Draw the cells of the row
  134. for($b = 0; $b < sizeof($current_col); $b++)
  135. {
  136. $w = $current_col[$b]['width'];
  137. $a = $current_col[$b]['align'];
  138. // Save the current position
  139. $x=$this->GetX();
  140. $y=$this->GetY();
  141. // set style
  142. $this->SetFont($current_col[$b]['font_name'], $current_col[$b]['font_style'], $current_col[$b]['font_size']);
  143. $color = explode(",", $current_col[$b]['fillcolor']);
  144. $this->SetFillColor($color[0], $color[1], $color[2]);
  145. $color = explode(",", $current_col[$b]['textcolor']);
  146. $this->SetTextColor($color[0], $color[1], $color[2]);
  147. $color = explode(",", $current_col[$b]['drawcolor']);
  148. $this->SetDrawColor($color[0], $color[1], $color[2]);
  149. $this->SetLineWidth($current_col[$b]['linewidth']);
  150. $color = explode(",", $current_col[$b]['fillcolor']);
  151. $this->SetDrawColor($color[0], $color[1], $color[2]);
  152. // Draw Cell Background
  153. $this->Rect($x, $y, $w, $h, 'FD');
  154. $color = explode(",", $current_col[$b]['drawcolor']);
  155. $this->SetDrawColor($color[0], $color[1], $color[2]);
  156. // Draw Cell Border
  157. if (substr_count($current_col[$b]['linearea'], "T") > 0)
  158. {
  159. $this->Line($x, $y, $x+$w, $y);
  160. }
  161. if (substr_count($current_col[$b]['linearea'], "B") > 0)
  162. {
  163. $this->Line($x, $y+$h, $x+$w, $y+$h);
  164. }
  165. if (substr_count($current_col[$b]['linearea'], "L") > 0)
  166. {
  167. $this->Line($x, $y, $x, $y+$h);
  168. }
  169. if (substr_count($current_col[$b]['linearea'], "R") > 0)
  170. {
  171. $this->Line($x+$w, $y, $x+$w, $y+$h);
  172. }
  173. // Print the text
  174. $this->MultiCell($w, $current_col[$b]['height'], $current_col[$b]['text'], 0, $a, 0);
  175. // Put the position to the right of the cell
  176. $this->SetXY($x+$w, $y);
  177. }
  178. // Go to the next line
  179. $this->Ln($h);
  180. }
  181. }
  182. // If the height h would cause an overflow, add a new page immediately
  183. function CheckPageBreak($h)
  184. {
  185. if($this->GetY()+$h>$this->PageBreakTrigger)
  186. $this->AddPage($this->CurOrientation);
  187. }
  188. // Computes the number of lines a MultiCell of width w will take
  189. function NbLines($w, $txt)
  190. {
  191. $cw=&$this->CurrentFont['cw'];
  192. if($w==0)
  193. $w=$this->w-$this->rMargin-$this->x;
  194. $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
  195. $s=str_replace("\r", '', $txt);
  196. $nb=strlen($s);
  197. if($nb>0 and $s[$nb-1]=="\n")
  198. $nb--;
  199. $sep=-1;
  200. $i=0;
  201. $j=0;
  202. $l=0;
  203. $nl=1;
  204. while($i<$nb)
  205. {
  206. $c=$s[$i];
  207. if($c=="\n")
  208. {
  209. $i++;
  210. $sep=-1;
  211. $j=$i;
  212. $l=0;
  213. $nl++;
  214. continue;
  215. }
  216. if($c==' ')
  217. $sep=$i;
  218. $l+=$cw[$c];
  219. if($l>$wmax)
  220. {
  221. if($sep==-1)
  222. {
  223. if($i==$j)
  224. $i++;
  225. }
  226. else
  227. $i=$sep+1;
  228. $sep=-1;
  229. $j=$i;
  230. $l=0;
  231. $nl++;
  232. }
  233. else
  234. $i++;
  235. }
  236. return $nl;
  237. }
  238. }
  239. //$name = $_POST['name'];
  240. $info = $_POST['pdf_power2'];
  241. $nombreDominio = $_POST['dominio_nuevo'];
  242. //$nombre_base = $_POST['nombre_bd'];
  243. //$info=$_GET['datos_pdf'];
  244. $enlace = '<br><a href="http://www.open6hosting.com">www.open6hosting.com</a>';
  245. $hoy = date("d-m-Y H:i:s");
  246. $pdf = new PDFO6H();
  247. // Primera página
  248. $pdf->AddPage();
  249. $pdf->SetFont('Arial','',32);
  250. //$pdf->Write(5,'Para saber qué hay de nuevo en este tutorial, pulse ');
  251. $pdf->SetFont('','U');
  252. //$link = $pdf->AddLink();
  253. //$pdf->Write(5,'aquí­',$link);
  254. $pdf->SetFont('');
  255. $pdf->SetTextColor(0, 200, 100);
  256. $Text = sprintf($_POST['dominio_nuevo'], 0.5);
  257. $pdf->ShadowCell(0, 80, $Text, 1, 1, 'C', false, '', 'B', 0.5);
  258. $pdf->SetTextColor(0, 0, 0);
  259. $pdf->AliasNbPages();
  260. $pdf->SetMargins($pdf->left, $pdf->top, $pdf->right);
  261. //$pdf->AddPage();
  262. // create table
  263. $columns = array();
  264. // header col
  265. $col = array();
  266. $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');
  267. $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');
  268. $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');
  269. $columns[] = $col;
  270. // data col
  271. $col = array();
  272. $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');
  273. $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');
  274. $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');
  275. $columns[] = $col;
  276. // data col
  277. $col = array();
  278. $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');
  279. $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');
  280. $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');
  281. $columns[] = $col;
  282. $pdf->WriteHTML('<br>');
  283. // Draw Table
  284. //$pdf->WriteTable($columns);
  285. //$pdf->AddPage();
  286. $pdf->SetLink($link);
  287. $pdf->Image('imagen/open6-logo.png',10,12,50,0,'','http://www.open6hosting.com');
  288. $pdf->SetLeftMargin(65);
  289. $pdf->SetFontSize(12);
  290. //$pdf->WriteHTML($name);
  291. $pdf->WriteHTML($info);
  292. $pdf->WriteHTML($enlace);
  293. //$pdf->WriteHTML($nombre_base);
  294. $pdf->Output();
  295. //header('Location: http://www.open6hosting.com');
  296. ?>