pdf_nombramientos_split.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <?php
  2. ini_set('max_execution_time', 150);
  3. /* AJAX
  4. * Genera nombramientos en pdf
  5. * Recibe:
  6. * fecha_inicial
  7. * fecha_final
  8. * fecha_inicial_extras
  9. * fecha_final_extras
  10. * Return:
  11. * imprime pdf
  12. */
  13. setlocale(LC_TIME, 'es_MX.UTF-8');
  14. require_once("../../include/nocache.php");
  15. require_once("../../include/bd_pdo.php");
  16. require_once("../../include/util.php");
  17. require_once("../../include/constantes.php");
  18. require_once("../../classes/ValidaSesion.php");
  19. include_once('../../include/xTemplate/xtemplate.class.php'); // including mpdf.php
  20. include_once('../../include/mpdf/autoload.php'); // including mpdf.php
  21. function generaMarcaDeAgua($marca, $carpeta) {
  22. $imagen = imagecreatetruecolor(344,143); // Crear la imagen de 591x379
  23. $textColor = imagecolorallocate($imagen, 224, 224, 224); //Colores del texto
  24. $transparente = imagecolorallocate ($imagen, 0, 0, 0); //Color que cambiará a transparene
  25. imagecolortransparent($imagen, $transparente); // Hacer el fondo transparente
  26. for ($cont = 0; $cont < 5; $cont++) { $marca .= $marca; }
  27. // Escribirlo
  28. for ($cont=1; $cont <= 50; $cont++){
  29. if ($cont%2 == 0)
  30. $val = -5;
  31. else
  32. $val = 5;
  33. imagestring($imagen,1, $val, 10*$cont, $marca, $textColor); //Escribe el texto
  34. }
  35. header('Content-Type: image/png');
  36. imagepng($imagen, $carpeta.'marca.png'); //Genera la imagen
  37. imagedestroy($imagen);
  38. }
  39. //$fechasArr[] ["busca"=>CODIGO, "reemplaza"=>fecha ]
  40. function cambiaFechas($texto, $fechasArr){
  41. $buscaArr = array();
  42. $reemplazaArr = array();
  43. foreach($fechasArr as $opt){
  44. $buscaArr[] = $opt["busca"];
  45. $reemplazaArr[] = $opt["reemplaza"];
  46. }
  47. return str_replace ($buscaArr, $reemplazaArr, $texto);
  48. }
  49. function directorioArea($texto){
  50. if($texto == "")
  51. return "";
  52. return "/".$texto;
  53. }
  54. $pag = "../nombramientos.php";
  55. //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
  56. $objSesion = new ValidaSesion($pdo, 54, APSA);
  57. if(!$objSesion->tieneAcceso()){
  58. header("Location: ".$pag."?error=3");
  59. exit();
  60. }
  61. unset($objValida);
  62. if(!isset($_POST["texto"]) || !isset($_POST["fecha_carta"]) || !isset($_POST["fecha_inicial"]) || !isset($_POST["fecha_final"]) /*|| !isset($_POST["fecha_inicial_extras"]) || !isset($_POST["fecha_final_extras"])*/){
  63. header("Location: ".$pag."?error=0");
  64. exit();
  65. }
  66. $texto = $_POST["texto"];
  67. $fecha_carta = fechaGuion(trim(filter_input(INPUT_POST, "fecha_carta", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto
  68. /*$fecha_inicial = fechaGuion(trim(filter_input(INPUT_POST, "fecha_inicial", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto
  69. $fecha_final = fechaGuion(trim(filter_input(INPUT_POST, "fecha_final", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto*/
  70. if(isset($_POST["profesor"])){
  71. $profesor = filter_input(INPUT_POST, "profesor", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  72. }
  73. //----
  74. $stmt = $pdo->prepare('Select * from fs_director()');
  75. if(!$stmt->execute()){
  76. header("Location:".$pag."?error=1");
  77. //print_r($stmt->errorInfo());
  78. exit();
  79. }
  80. $director_rs = $stmt->fetch();
  81. $stmt->closeCursor();
  82. $stmt = null;
  83. $stmt = $pdo->prepare('Select * from fs_constanciafirma(NULL, NULL) where "Usuario_id" = :usr');
  84. $stmt->bindParam(":usr", $director_rs["Usuario_id"]);
  85. if(!$stmt->execute()){
  86. header("Location:".$pag."?error=1");
  87. //print_r($stmt->errorInfo());
  88. exit();
  89. }
  90. $firma_director = $stmt->fetch();
  91. $stmt->closeCursor();
  92. //-----
  93. $stmt = $pdo->prepare('Select * from fs_puesto(2)');//Secretario académico
  94. if(!$stmt->execute()){
  95. header("Location:".$pag."?error=1");
  96. //print_r($stmt->errorInfo());
  97. exit();
  98. }
  99. $secretario_rs = $stmt->fetch();
  100. $stmt->closeCursor();
  101. $stmt = null;
  102. $stmt = $pdo->prepare('Select * from fs_constanciafirma(NULL, NULL) where "Usuario_id" = :usr');
  103. $stmt->bindParam(":usr", $secretario_rs["Usuario_id"]);
  104. if(!$stmt->execute()){
  105. header("Location:".$pag."?error=1");
  106. //print_r($stmt->errorInfo());
  107. exit();
  108. }
  109. $firma_secretario = $stmt->fetch();
  110. $stmt->closeCursor();
  111. unset($tmp_rs);
  112. //Obtiene fechas de periodo
  113. $stmt = $pdo->prepare('Select * from fs_periodo(:periodo, NULL, NULL, true)');
  114. $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
  115. if(!$stmt->execute()){
  116. header("Location:".$pag."?error=1");
  117. //print_r($stmt->errorInfo());
  118. exit();
  119. }
  120. $periodo_rs = $stmt->fetch();
  121. $nivel = $periodo_rs["Nivel_id"];
  122. $stmt->closeCursor();
  123. if($nivel == 1){
  124. $fecha_inicial_extras = fechaGuion(trim(filter_input(INPUT_POST, "fecha_inicial_extras", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto
  125. $fecha_final_extras = fechaGuion(trim(filter_input(INPUT_POST, "fecha_final_extras", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto
  126. }
  127. //---Inserta/Actualiza fechas importantes nuevas
  128. $stmt = $pdo->prepare('Select * from fi_fechaimportante(:periodo, 4, :fechai, :fechaf )');//fecha de la carta
  129. $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
  130. $stmt->bindParam(":fechai", $fecha_carta);
  131. $stmt->bindParam(":fechaf", $fecha_carta);
  132. if(!$stmt->execute()){
  133. //echo "4";print_r($stmt->errorInfo());exit();
  134. header("Location:".$pag."?error=4");
  135. exit();
  136. }
  137. $stmt->closeCursor();
  138. $stmt = $pdo->prepare('Select * from fs_fechaimportante(:periodo, 3 )');//fechas profesores
  139. $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
  140. if(!$stmt->execute()){
  141. //echo "4";print_r($stmt->errorInfo());exit();
  142. header("Location:".$pag."?error=4");
  143. exit();
  144. }
  145. $rs = $stmt->fetch();
  146. $stmt->closeCursor();
  147. $fecha_inicial = $rs["FechaImportante_inicial"];
  148. $fecha_final = $rs["FechaImportante_final"];
  149. $stmt = $pdo->prepare('Select * from fs_fechaimportante(:periodo, 2 )');//fecha de extraordinarios
  150. $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
  151. if(!$stmt->execute()){
  152. //echo "4";print_r($stmt->errorInfo());exit();
  153. header("Location:".$pag."?error=4");
  154. exit();
  155. }
  156. $rs = $stmt->fetch();
  157. $stmt->closeCursor();
  158. $fecha_inicial_extras = $rs["FechaImportante_inicial"];
  159. $fecha_final_extras = $rs["FechaImportante_final"];
  160. //Guarda nuevo texto de carta
  161. $stmt = $pdo->prepare('Select * from fi_cartanombramiento(:periodo, :text, :firmaD, :firmaS)');
  162. $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
  163. $stmt->bindParam(":text", $texto);
  164. $stmt->bindParam(":firmaD", $firma_director["ConstanciaFirma_id"]);
  165. $stmt->bindParam(":firmaS", $firma_secretario["ConstanciaFirma_id"]);
  166. if(!$stmt->execute()){
  167. //print_r($stmt->errorInfo());
  168. header("Location:".$pag."?error=5");
  169. exit();
  170. }
  171. $stmt->closeCursor();
  172. $stmt = null;
  173. //-----
  174. $defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
  175. $fontDirs = $defaultConfig['fontDir'];
  176. $defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
  177. $fontData = $defaultFontConfig['fontdata'];
  178. $defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
  179. $fontDirs = $defaultConfig['fontDir'];
  180. $defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
  181. $fontData = $defaultFontConfig['fontdata'];
  182. $stylesheet = "<style>";
  183. $stylesheet .= file_get_contents('../../css/indivisa.css'); // external css
  184. $stylesheet .= file_get_contents('../css/carta.css'); // external css
  185. $stylesheet .= "</style>";
  186. //Obtiene fechas de periodo
  187. $stmt = $pdo->prepare('Select * from fs_periodo(:periodo, NULL, NULL, true)');
  188. $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
  189. if(!$stmt->execute()){
  190. header("Location:".$pag."?error=1");
  191. //print_r($stmt->errorInfo());
  192. exit();
  193. }
  194. $periodo_rs = $stmt->fetch();
  195. $nivel = $periodo_rs["Nivel_id"];
  196. $stmt->closeCursor();
  197. $stmt = $pdo->prepare('Select * from fs_director()');
  198. if(!$stmt->execute()){
  199. header("Location:".$pag."?error=1");
  200. //print_r($stmt->errorInfo());
  201. exit();
  202. }
  203. $director_rs = $stmt->fetch();
  204. $stmt->closeCursor();
  205. $stmt = null;
  206. if($nivel == 1){
  207. if($profesor == 0)
  208. //$stmt = $pdo->prepare('Select * from fs_profesoresperiodo(:periodo, NULL, 0, NULL)');
  209. $stmt = $pdo->prepare('Select * from fs_profesoresperiodo_area(:periodo, NULL, 0, NULL)');
  210. else{
  211. //$stmt = $pdo->prepare('Select * from fs_profesoresperiodo(:periodo, :prof, 0, NULL)');
  212. $stmt = $pdo->prepare('Select * from fs_profesoresperiodo_area(:periodo, :prof, 0, NULL)');
  213. $stmt->bindParam(":prof", $profesor);
  214. }
  215. }else{
  216. if($profesor == 0)
  217. $stmt = $pdo->prepare('Select * from fs_profesoresperiodo_carrera(:periodo, NULL)');
  218. else{
  219. $stmt = $pdo->prepare('Select * from fs_profesoresperiodo_carrera(:periodo, :prof)');
  220. $stmt->bindParam(":prof", $profesor);
  221. }
  222. }
  223. $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
  224. if(!$stmt->execute()){
  225. header("Location:".$pag."?error=1");
  226. //print_r($stmt->errorInfo());
  227. exit();
  228. }
  229. $rs = $stmt->fetchAll();
  230. $stmt->closeCursor();
  231. $stmt = null;
  232. $cuenta = count($rs);
  233. $fechasArr = array();
  234. //Periodo tiene fechas de ciclo
  235. $fechasArr[] = array("busca"=>PR_INI, "reemplaza"=>fechaTexto($periodo_rs["Periodo_fecha_inicial"], false));
  236. $fechasArr[] = array("busca"=>PR_INI_Y, "reemplaza"=>fechaTexto($periodo_rs["Periodo_fecha_inicial"], true));
  237. $fechasArr[] = array("busca"=>PR_FIN, "reemplaza"=>fechaTexto($periodo_rs["Periodo_fecha_final"], false));
  238. $fechasArr[] = array("busca"=>PR_FIN_Y, "reemplaza"=>fechaTexto($periodo_rs["Periodo_fecha_final"], true));
  239. //forma tiene fechas periodo completo
  240. $fechasArr[] = array("busca"=>PE_INI, "reemplaza"=>fechaTexto($fecha_inicial, false));
  241. $fechasArr[] = array("busca"=>PE_INI_Y, "reemplaza"=>fechaTexto($fecha_inicial, true));
  242. $fechasArr[] = array("busca"=>PE_FIN, "reemplaza"=>fechaTexto($fecha_final, false));
  243. $fechasArr[] = array("busca"=>PE_FIN_Y, "reemplaza"=>fechaTexto($fecha_final, true));
  244. if($nivel == 1){
  245. //forma tiene fechas extraordinarios
  246. $fechasArr[] = array("busca"=>EX_INI, "reemplaza"=>fechaTexto($fecha_inicial_extras, false));
  247. $fechasArr[] = array("busca"=>EX_INI_Y, "reemplaza"=>fechaTexto($fecha_inicial_extras, true));
  248. $fechasArr[] = array("busca"=>EX_FIN, "reemplaza"=>fechaTexto($fecha_final_extras, false));
  249. $fechasArr[] = array("busca"=>EX_FIN_Y, "reemplaza"=>fechaTexto($fecha_final_extras, true));
  250. }
  251. $texto = cambiaFechas($texto, $fechasArr);
  252. $stmt = $pdo->prepare('Select * from fi_profesorperiodo_categoria(:periodo, :prof )');
  253. $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
  254. foreach($rs_usr as $prof){
  255. if(strtoupper($prof["Usuario_nombre"]) != "VACANTE"){//no vacante
  256. $stmt->bindParam(":prof", $prof["Usuario_id"]);
  257. if(!$stmt->execute()){
  258. //echo "4";print_r($stmt->errorInfo());exit();
  259. header("Location:".$pag."?error=4");
  260. exit();
  261. }
  262. }
  263. }
  264. $stmt->closeCursor();
  265. //----------- Archivos y zip ---
  266. $fecha = date("Ymd_His");
  267. $tmp_folder = "./zip/pdf_".$fecha;
  268. if (!file_exists($tmp_folder)) {
  269. mkdir($tmp_folder, 0777, true);
  270. }
  271. $zip = new ZipArchive();
  272. $zip_filename = "zip/nombramientos_".$fecha.".zip";
  273. if ($zip->open($zip_filename, ZipArchive::CREATE)!==TRUE) {
  274. exit("cannot open <$zip_filename>\n");
  275. }
  276. //Marca de agua
  277. if (!file_exists($_SERVER['DOCUMENT_ROOT']. '/apsa/export/zip/marca.png')) {
  278. $marca = mb_strtoupper("Nombramiento",'UTF-8') . ' ' . fechaGuion($fecha_carta) . ' | '; //No acepta caracteres especiales
  279. generaMarcaDeAgua($marca, "./zip/");
  280. }
  281. $num = 1;
  282. foreach($rs as $profesor){
  283. if(strtoupper($profesor["Usuario_nombre"]) != "VACANTE"){//no vacante
  284. $mpdf = new \Mpdf\Mpdf([
  285. 'mode' => 'utf-8',
  286. 'format' => [215, 279],
  287. 'orientation' => 'P',
  288. 'margin_left' => 14,
  289. 'margin_right' => 14,
  290. 'margin_top' => 7,
  291. 'margin_bottom' => 7,
  292. 'fontDir' => array_merge($fontDirs, [
  293. __DIR__ . '/../../fonts/indivisaFont/ttf',
  294. ]),
  295. 'fontdata' => $fontData + [
  296. 'indivisa-display' => [
  297. 'R' => 'IndivisaDisplaySans-Regular.ttf',
  298. ],
  299. 'indivisa-title' => [
  300. 'R' => 'IndivisaDisplaySerif-RegularItalic.ttf',
  301. ],
  302. 'indivisa-text' => [
  303. 'R' => 'IndivisaTextSans-Regular.ttf',
  304. ]
  305. ],
  306. 'default_font' => 'indivisa-text'
  307. ]);
  308. if($nivel == 1){
  309. $xtpl = new XTemplate('../tpl/nombramiento.tpl.html');
  310. }else{
  311. $xtpl = new XTemplate('../tpl/nombramiento_pos.tpl.html');
  312. }
  313. $xtpl->assign("FECHA_HOY", fechaTexto($fecha_carta, true));
  314. $xtpl->assign("FACULTAD", FACULTAD);
  315. //$titulo = "Ing."; //Título del director
  316. $xtpl->assign("TEXTO_CARTA", $texto);
  317. $nombre = $profesor["Usuario_apellidos"]." ".$profesor["Usuario_nombre"];
  318. $xtpl->assign("PROFESOR", $nombre);
  319. $xtpl->assign("CATEGORIA", $profesor["Profesor_categoria"]);
  320. if($nivel != 1){
  321. $xtpl->assign("PLAN", $profesor["Carrera_desc"]);
  322. $stmt = $pdo->prepare('Select * from fs_horariogrupoprofesor(:prof, :periodo, :carr)');
  323. $stmt->bindParam(":carr", $profesor["Carrera_id"]);
  324. }else
  325. $stmt = $pdo->prepare('Select * from fs_horariogrupoprofesor(:prof, :periodo, NULL)');
  326. $stmt->bindParam(":prof", $profesor["Usuario_id"]);
  327. $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
  328. if(!$stmt->execute()){
  329. header("Location:".$pag."?error=2");
  330. //print_r($stmt->errorInfo());
  331. exit();
  332. }
  333. $asignatura_rs = $stmt->fetchAll();
  334. $stmt->closeCursor();
  335. $grupo_last = $asignatura_rs[0]["Grupo_id"].$asignatura_rs[0]["Materia_id"];
  336. foreach($asignatura_rs as $asignatura){
  337. if($grupo_last != $asignatura["Grupo_id"].$asignatura["Materia_id"]){
  338. $grupo_last = $asignatura["Grupo_id"].$asignatura["Materia_id"];
  339. $xtpl->parse("main.renglon");
  340. }
  341. $xtpl->assign("ASIGNATURA", $asignatura["Materia_desc"]);
  342. if($nivel == 1)
  343. $xtpl->assign("GRUPO", $asignatura["Grupo_desc"]." ".$asignatura["Carrera_prefijo"]);
  344. else
  345. $xtpl->assign("GRUPO", $asignatura["Materia_grupo_posgrado"]);
  346. if($asignatura["Salon_desc"] != "")
  347. $xtpl->assign("SALON", $asignatura["Salon_desc"]);
  348. else
  349. $xtpl->assign("SALON", "&nbsp;");
  350. $xtpl->assign("DIA", diaNombre($asignatura["Dia_id"]));
  351. //$hora_fin = date('H:i', strtotime('+'.$asignatura["Horario_duracion"].' minutes', strtotime('2019-01-01 '.$asignatura["Horario_hora"])));
  352. $xtpl->assign("HORARIO", substr($asignatura["Horario_hora"], 0, 5)." - ".substr($asignatura["Horario_hora_final"],0, 5));
  353. $xtpl->parse("main.renglon.detalle");
  354. }
  355. $xtpl->parse("main.renglon");
  356. $cuenta--;
  357. /*if($profesor["Usuario_id"] != $director_rs["Usuario_id"]){
  358. $director = $titulo." ".$director_rs["Usuario_nombre"]." ".$director_rs["Usuario_apellidos"];
  359. $xtpl->assign("NOMBRE_FIRMA", $director);
  360. $xtpl->assign("PUESTO_FIRMA", $director_rs["Puesto_desc"]);
  361. }else{//TODO cambiar por secretario académico
  362. $xtpl->assign("NOMBRE_FIRMA", "Mtro. Carlos Alfonso Herrera Anda");
  363. $xtpl->assign("PUESTO_FIRMA", "Secretario Académico");
  364. }*/
  365. $xtpl->assign('MARCA', './zip/marca.png');
  366. if($profesor["Usuario_id"] != $director_rs["Usuario_id"]){
  367. $xtpl->assign('FIRMA', $firma_director["ConstanciaFirma_imagen"]);
  368. $director = $firma_director["ConstanciaFirma_grado"]." ".$director_rs["Usuario_nombre"]." ".$director_rs["Usuario_apellidos"];
  369. $xtpl->assign("NOMBRE_FIRMA", $director);
  370. $xtpl->assign("PUESTO_FIRMA", $director_rs["Puesto_desc"]);
  371. }else{//TODO cambiar por secretario académico
  372. $xtpl->assign('FIRMA', $firma_secretario["ConstanciaFirma_imagen"]);
  373. $secretario = $firma_secretario["ConstanciaFirma_grado"]." ".$secretario_rs["Usuario_nombre"]." ".$secretario_rs["Usuario_apellidos"];
  374. $xtpl->assign("NOMBRE_FIRMA", $secretario);
  375. $xtpl->assign("PUESTO_FIRMA", $secretario_rs["Puesto_desc"]);
  376. }
  377. //if($cuenta > 0) $xtpl->parse("main.pagebreak");
  378. $xtpl->parse("main");
  379. $mpdf->WriteHTML($stylesheet);
  380. $mpdf->WriteHTML($xtpl->text("main"));
  381. $mpdf->SetProtection(array('print', 'print-highres'), '', md5(time()));
  382. $mpdf->Output($tmp_folder."/nombramiento_".sprintf("%03d", $num).".pdf", 'F');
  383. if(isset($profesor["Area_desc"])){
  384. $zip->addFile(
  385. $tmp_folder."/nombramiento_".sprintf("%03d", $num).".pdf",
  386. "nombramientos_".$fecha.directorioArea($profesor["Area_desc"])."/nombramiento_".sprintf("%06d", $profesor["Usuario_claveULSA"]).".pdf"
  387. );
  388. }else{
  389. $zip->addFile(
  390. $tmp_folder."/nombramiento_".sprintf("%03d", $num).".pdf",
  391. "nombramientos_".$fecha."/nombramiento_".sprintf("%06d", $profesor["Usuario_claveULSA"]).".pdf"
  392. );
  393. }
  394. if($cuenta > 0){
  395. $num++;
  396. }
  397. }//fin vacante
  398. }//for profesor
  399. if($zip->numFiles<=0){
  400. echo "Error al guardar en el zip";
  401. $zip->close();
  402. unlink($zip_filename);
  403. exit();
  404. }
  405. $zip->close();
  406. removeFolder($tmp_folder);
  407. header("Content-Type: application/zip");
  408. header("Content-Disposition: attachment; filename=".basename($zip_filename));
  409. header("Pragma: no-cache");
  410. header("Expires: 0");
  411. ob_end_clean();
  412. flush();
  413. readfile($zip_filename);
  414. unlink($zip_filename);
  415. function removeFolder($folderName) {
  416. if (is_dir($folderName))
  417. $folderHandle = opendir($folderName);
  418. if (!$folderHandle)
  419. return false;
  420. while($file = readdir($folderHandle)) {
  421. if ($file != "." && $file != "..") {
  422. if (!is_dir($folderName."/".$file))
  423. unlink($folderName."/".$file);
  424. else
  425. removeFolder($folderName.'/'.$file);
  426. }
  427. }
  428. closedir($folderHandle);
  429. rmdir($folderName);
  430. return true;
  431. }
  432. /*echo $stylesheet;
  433. $xtpl->out("main");*/