PageRenderTime 57ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/_jppf/classes/vxr/vxr.php

https://bitbucket.org/countach/jpphpframework
PHP | 780 lines | 464 code | 138 blank | 178 comment | 89 complexity | ceadefcac2e701556d16d67e6f662473 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /**
  3. * vxr.php
  4. *
  5. * PhotoViewer System.
  6. * Displays images in a directory, properly.
  7. *
  8. * Creado el 22-jul-2006
  9. *
  10. * @author Juan Prada
  11. *
  12. *
  13. Ideas:
  14. Que se puedan elegir varios tama?os desde el menu.
  15. Que reciba un parámetro para iniciar en esa foto.
  16. Un botón en el menu para entregar dicho link [LINK]
  17. Tambien para el link en PHPBB
  18. (Panel flotante, que se puedan ir a?adiendo y luego copiarlo para pegar)
  19. * @version (In spanish, sorry)
  20. *
  21. 1.8 20/01/2011 18:32:42
  22. Mejoras en el DEBUG
  23. 1.7 08/06/2008
  24. Se permite la paremtración con archivos .ini
  25. vxr.ini
  26. vxr_showpage.ini
  27. * 1.6 27/11/2007
  28. * Se pule el indicador de foto cargando, envitando entre otras
  29. * cosas la aparición de la barra de scroll lateral innecesariamente.
  30. *
  31. * Se mejora la representación EXIF, no mostrando los datos que no están
  32. * y mostrando inteligentemente el nombre y modelo de la cámara.
  33. *
  34. * En la parte JS, detecta el navegador para realizar la transparencia de una
  35. * manera o de otra.
  36. *
  37. * Tambien cambia los estilos en el CSS y en el PHP según el navegador.
  38. *
  39. * Se hace compatible con IE 6.0
  40. *
  41. * Se hace que se ilumine la foto ante un MouseOver
  42. *
  43. * Se mejora el sistema de debug automatico que se actuva al poner el parámetro
  44. * ?debug=1
  45. *
  46. * Se corrige el bug que ocurría cuando en el directorio de iconos había otros
  47. * iconos de otras dimensiones (otros archivos)
  48. *
  49. *
  50. *
  51. * 1.5 1/11/2007
  52. * Llamada a la función de componer una página usando arrays.
  53. * Usa transparencias para indicar el icono que se está cargando.
  54. * Al cargar, selecciona la primera foto.
  55. * Paneles ocultables
  56. * Panel de EXIF
  57. * Menu
  58. *
  59. * 1.4 20/05/2007
  60. * Incorpora el sistema de seguridad
  61. *
  62. * 1.3 31/03/2007
  63. * Usa divs para la representación
  64. *
  65. * 1.2 10/10/2006
  66. * Permite disponer los iconos verticalmente
  67. */
  68. include_once('aa/inc_funks_images.php');
  69. include_once 'funkpack_vxr.php';
  70. class vxr {
  71. var $dat = array();
  72. var $html = '';
  73. var $is_version = '';
  74. var $is_idioma = '';
  75. var $is_version_f = '';
  76. var $is_debug_txt = '';
  77. var $ib_debug = false;
  78. var $i_browser = array();
  79. var $msg = array();
  80. function vxr($param='') {
  81. global $fnvxr;
  82. $this->is_version = '1.8';
  83. $this->is_version_f = '20/01/2011 18:32:58';
  84. // Debug flag pick
  85. $this->ib_debug = isset($_REQUEST['debug']);
  86. // Picks the browser info
  87. $this->i_browser = $fnvxr->f_get_browser();
  88. // Language pick
  89. $this->is_idioma = substr(strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']),0,2);
  90. // Initialize messages
  91. $this->of_vxr_inic_msg();
  92. // Initialize parameters
  93. $this->of_vxr_param_inic();
  94. // If some params arrived, set them
  95. if ((!isset($param)) && file_exists('vxr.ini')) {
  96. $param = parse_ini_file('vxr.ini');
  97. $this->of_set_param($param);
  98. //die( nl2br(print_r($param, true)) );
  99. } else {
  100. if ( (is_array($param)) && (!empty($param)) ) $this->of_set_param($param);
  101. }
  102. //echo( nl2br(print_r($this->dat, true)) );
  103. // Start the security system
  104. $this->vxkey(); // (This function can end in a die() statment!)
  105. }
  106. function vxkey() {
  107. // First of all, check la key
  108. if (!isset($this->dat['key'])) $this->dat['key']='';
  109. if (strlen($this->dat['key'])) {
  110. if ( ($_REQUEST['key'] != $this->dat['key']) && ($_COOKIE['vxKey'] != $this->dat['key']) ) {
  111. // Acceso no permitido
  112. switch($this->is_idioma) {
  113. case 'es':
  114. $msg = array(
  115. 'Error 19823.2 en su navegador. Configure los DNS y el Wins por lo menos.',
  116. 'Internet colapsado, pruebe de nuevo en un futuro.',
  117. 'El servidor ha sido afectado por un escape radiactivo, deshágase de su computadora.',
  118. 'Aquí no es',
  119. 'Formateando su disco duro... espere unos minutos.',
  120. 'Ella dijo no.',
  121. 'Espere unos instantes...',
  122. 'Problema con el cable, revise sus conexiones.',
  123. 'La están peinando...',
  124. 'Error supremo. Recompile el kernel.',);
  125. break;
  126. default:
  127. $msg = array(
  128. 'Browser 19823.2 error. Please configure the DNS and Wins.',
  129. 'Internet turned off, please check again in the future.',
  130. 'The server has a radiactive leak. Please remove your computer.',
  131. 'OH NOES! I HAS NOZING',
  132. 'Formatting your harddrive... wait some minutes.',
  133. 'Hi chap!',
  134. 'Please wait...',
  135. 'Cable issue, check your connections.',
  136. 'OH NOES! I IZ TUNED OF...',
  137. 'Supreme Error. Rebuild the Kernel.',);
  138. }
  139. $h.='<form name="vxkey" id="" class="f" method="post" action="">';
  140. $h.='<input style="position:fixed; left:0px; bottom:0px; border:0px none;color:white;background-color:orange;" type="password" name="key" value="">';
  141. $h.='</form>';
  142. die($msg[rand(0, count($msg) - 1)].'<br><br>'.$h);
  143. } else {
  144. // La clave es válida, graba una cookie válida durante 48 horas
  145. setcookie("vxKey", $this->dat['key'], time()+ (3600 * 48) );
  146. }
  147. }
  148. }
  149. function of_debug($as_txt) {
  150. $this->is_debug_txt.=$as_txt;
  151. }
  152. function of_vxr_param_inic() {
  153. $this->dat=array(
  154. 'php_time_limit' => '240',
  155. 'dir' => 'res/', // Resource files dir (The images of the toolbar, etc)
  156. 'dir_vxr_naveg' => "/_comun/classes/vxr/", // Place where this class is stored, mapped for the client
  157. 'icon_dim' => '150x32', // Icon dimensions
  158. 'princ_dim' => '-650', // Width 650px for the main imagen. If not set, the main image is not modified
  159. 'princ_pref' => '650_', // Main image filename sub-prefix if modified
  160. 'princ_BorrarOrig' => true, // In case of modifying the main image, if the original one must be deleted
  161. 'princ_load_opa' => '.4', // Main image transparency when loading
  162. 'icon_pref' => '150_', // Icon's filename sub-prefix
  163. 'icon_path' => 'vxrtn/', // Path where icons must be stored
  164. 'imgtratada_pref' => 'p', // Filename prefix for everyone, to allow knowing witch to convert
  165. 'progDiv_load_opa'=> '.5', // La transparencia del DIV del gráfico de progreso
  166. 'progDiv_icon_opa'=> '.4', // La transparencia del DIV del gráfico de progreso en el icono
  167. 'icon_style' => 'border:1px solid black;', // El estilo CSS para el icono
  168. 'icon_style_sel' => '', // El estilo CSS para el icono seleccionado
  169. 'princ_style' => '', // El estilo CSS de la imagen principal
  170. 'icon_sep' => '', // Algo para poner en las celdas de la tabla además del icono
  171. 'icon_TextoInicial'=>'',
  172. 'icon_TextoFinal' => '<div align="center">'.$this->msg['infoinic'].'</div>',
  173. 'progImgRes' => 'vxr_progress_01.gif',
  174. 'progIcoRes' => 'p2.gif',
  175. 'icon_spread' => 'vertical', // Modo en el cual se van disponiendo los iconos
  176. 'icon_Filas' => 16, // Filas cuando la disposición es vertical
  177. 'icon_Columnas' => 6, // (Para cuando 'icon_spread' es horizontal
  178. 'icon_spacing' => '0', // El cellspacing de la tabla de iconos
  179. '' => '',
  180. );
  181. }
  182. function of_set_param($param) {
  183. $this->dat = array_merge($this->dat, $param);
  184. }
  185. function of_vxr_do() {
  186. global $fnvxr;
  187. // Elabora la lista de las imagenes
  188. $d = $this->ib_debug;
  189. set_time_limit ( $this->dat['php_time_limit'] );
  190. if (!strlen($this->dat['princ_dim'])) {
  191. $this->dat['princ_pref']='';
  192. }
  193. $imagenes=array(); reset($imagenes);
  194. $img_validas=array(); reset($img_validas);
  195. $html=array(); reset($html);
  196. // Lista los archivos del directorio
  197. $li_num = $fnvxr->f_dir_img($this->dat['dir'],$imagenes,'');
  198. // Elimina los iconos de la versión anterior
  199. $i=0;
  200. for ($n=0; $n<$li_num; $n++) {
  201. if (substr($imagenes[$n],0,3) != 'TN_') {
  202. $img_validas[$i] = $imagenes[$n];
  203. $i++;
  204. }
  205. }
  206. $imagenes = $img_validas;
  207. $li_num = $i;
  208. $il_tratadas_a = 0;
  209. $il_tratadas_b = 0;
  210. // Recorre los archivos para ver si tiene que convertir alguno
  211. if ($d) $this->of_debug('Recorre los '.$li_num.' archivos para ver si tiene que convertir alguno...'.'<br/>');
  212. if ($d) $this->of_debug('print_r($imagenes):<pre> '.print_r($imagenes,true).'</pre><br/>');
  213. for ($n=0; $n < $li_num; $n++) {
  214. $partes_ruta = pathinfo($imagenes[$n]);
  215. $ext_orig[$n] = $partes_ruta['extension'];
  216. if ($d) $this->of_debug( $n.': '.$imagenes[$n].'<br/>');
  217. // Tratamiento del icono
  218. $ls_temp = $this->dat['dir'].$this->dat['icon_path'].$this->dat['imgtratada_pref'].$this->dat['icon_pref'].$partes_ruta['basename'];
  219. if ($d) $this->of_debug( 'Comprobado el tratamiento del icono: $ls_temp='.$ls_temp.'<br/>');
  220. if (!file_exists($ls_temp)) {
  221. if ($d) $this->of_debug('No existe el icono, se crea. '.$this->msg['debug_noimageicon'].' $ls_temp='.$ls_temp.'<br/>');
  222. $ls_nueva = f_img_asegura_icono('',$imagenes[$n],$this->dat['dir'],$this->dat['icon_dim'],$this->dat['imgtratada_pref'].$this->dat['icon_pref'],'',$this->dat['icon_path'],true);
  223. $il_tratadas_a++;
  224. } else {
  225. if ($d) $this->of_debug('El icono existe'.'<br/>');
  226. }
  227. // Código para redimensinar la imagen si está especificado ello
  228. $ls_temp = substr($imagenes[$n],0,strlen($this->dat['imgtratada_pref']));
  229. if ($d) $this->of_debug( 'Prueba redimensionado: $ls_temp='.$ls_temp.'; $this->dat[\'imgtratada_pref\']='. $this->dat['imgtratada_pref'].'<br/>');
  230. if ($ls_temp != $this->dat['imgtratada_pref']) {
  231. if ($d) $this->of_debug('$this->dat[\'princ_dim\']="'.$this->dat['princ_dim'].'"<br/>');
  232. if (strlen($this->dat['princ_dim'])) {
  233. // Comprueba si existe la imagen ya tratada para principal (650 px de ancho)
  234. $ls_temp=$this->dat['dir'].$this->dat['imgtratada_pref'].$this->dat['princ_pref'].$imagenes[$n];
  235. if ($d) $this->of_debug('Comprobando si existe $ls_temp="'.$ls_temp.'"<br/>');
  236. if (!file_exists($ls_temp)) {
  237. if ($d) $this->of_debug( 'No existe!. Asegura icono para '.$imagenes[$n].'<br/>');
  238. $ls_nueva = f_img_asegura_icono('',$imagenes[$n],$this->dat['dir'],$this->dat['princ_dim'],$this->dat['imgtratada_pref'].$this->dat['princ_pref'],'','',true);
  239. $il_tratadas_b++;
  240. // Ahora borra la original
  241. if ($this->dat['princ_BorrarOrig']) unlink($this->dat['dir'].$imagenes[$n]);
  242. }
  243. }
  244. } else {
  245. if ($d) $this->of_debug('No es necesario redimensionar'.'<br/>');
  246. }
  247. }
  248. if ($d) $this->of_debug('Fin de la conversión, comienza a recorrer las imágenes para pintarlas'.'<br/>');
  249. if ($d) $this->of_debug( 'print_r($imagenes): <pre>'.print_r($imagenes,true).'</pre><br/>');
  250. // Vuelve a recorrer el las imagenes para ir pintándolas
  251. $li_len_pref = strlen($this->dat['imgtratada_pref'].$this->dat['princ_pref']);
  252. $li_len_pref_icon = strlen($this->dat['imgtratada_pref'].$this->dat['icon_pref']);
  253. if ($d) $this->of_debug( '$this->dat[\'dir\'].$this->dat[\'icon_path\']='.$this->dat['dir'].$this->dat['icon_path'].'<br/>');
  254. $li_num = $fnvxr->f_dir_img($this->dat['dir'].$this->dat['icon_path'],$imagenes,'');
  255. if ($d) $this->of_debug( 'print_r($imagenes): <pre>'.print_r($imagenes,true).'</pre><br/>');
  256. $li_index_js = 0;
  257. $li_index_js_sel = 0;
  258. $ls_img_inic = '';
  259. $ls_exif_inic = '';
  260. $html['jsInLine'] = "\nfunction jf_vxr_start() {\n";
  261. $html['imggran'] = '';
  262. // Averigua donde colocar el PROGRESSBAR de cada icono, (el offset x e y)
  263. list($ancho, $alto, $tipo, $atr) = getimagesize(dirname(__FILE__).'/res/'.$this->dat['progIcoRes']);
  264. $icoDim = explode('x',$this->dat['icon_dim']);
  265. $ll_icoXoffset = round(($icoDim[0] - $ancho) / 2);
  266. $ll_icoYoffset = round(($icoDim[1] - $alto) / 2);
  267. // Predefine las características de transparencia de los iconos
  268. switch($this->i_browser['agent']) {
  269. case 'IE':
  270. $ls_style_tr_icon = ';filter=alpha(opacity=40);';
  271. $ls_style_tr_icon_sel = ';filter=alpha(opacity=100);';
  272. break;
  273. default:
  274. $ls_style_tr_icon = ';opacity:.5;';
  275. $ls_style_tr_icon_sel = ';opacity:1;';
  276. }
  277. $nn=0; // Almacena un index de las fotos válidas, para cuando hay varios archivos de iconos en el directorio
  278. // Es el index y orden real de aparición de fotos
  279. for ($n=0; $n < $li_num; $n++) {
  280. if ($d) $this->of_debug( '<hr/>');
  281. if ($d) $this->of_debug( '$n='.$n.'; <b>$nn='.$nn.'</b><br/>');
  282. if ($d) $this->of_debug( '$imagenes['.$n.']='.$imagenes[$n]."<br/>");
  283. if ($d) $this->of_debug( 'substr($imagenes[$n],0,$li_len_pref_icon)='.substr($imagenes[$n],0,$li_len_pref_icon)."<br/>");
  284. if ($d) $this->of_debug( '$this->dat[\'imgtratada_pref\'].$this->dat[\'icon_pref\']='.$this->dat['imgtratada_pref'].$this->dat['icon_pref']."<br/>");
  285. if (substr($imagenes[$n],0,$li_len_pref_icon) == $this->dat['imgtratada_pref'].$this->dat['icon_pref']) {
  286. // La imagen listada corresponde con la del icono, o sea que hay que buscar la principal
  287. if ($d) $this->of_debug( '$this->dat["princ_pref"]='.$this->dat['princ_pref']."<br/>");
  288. if (strlen($this->dat['princ_pref'])) {
  289. // Hay definido un prefijo para la imagen principal, se compone la imagen final usándolo, tras quitar el anterior prefilo (el del icono)
  290. if ($d) $this->of_debug( '$li_len_pref='.$li_len_pref."<br/>");
  291. $ls_img_gran=$this->dat['imgtratada_pref'].$this->dat['princ_pref'].substr($imagenes[$n], $li_len_pref);
  292. } else {
  293. if ($d) $this->of_debug( '$li_len_pref_icon='.$li_len_pref_icon."<br/>");
  294. $ls_img_gran = substr($imagenes[$n], $li_len_pref_icon, strlen($imagenes[$n]) - 3 - $li_len_pref_icon ).$ext_orig[$nn];
  295. }
  296. if ($d) $this->of_debug( '$ls_img_gran='.$ls_img_gran."<br/>");
  297. // Construye el index de almacenamiento en arrays
  298. if (file_exists($this->dat['dir'].$ls_img_gran)) {
  299. $li_index_js++;
  300. list($ls_width, $ls_height, $type, $attr) = getimagesize($this->dat['dir'].$ls_img_gran);
  301. $html['jsInLine'].="\t".'arrayImg['.$li_index_js.']="'.$this->dat['dir'].$ls_img_gran.'";'."\n";
  302. $html['jsInLine'].="\t".'arrayWidth['.$li_index_js.']="'.$ls_width.'";'."\n";
  303. $html['jsInLine'].="\t".'arrayHeight['.$li_index_js.']="'.$ls_height.'";'."\n";
  304. $ls_exif = $this->of_vxr_getexif($this->dat['dir'].$ls_img_gran);
  305. $html['jsInLine'].="\t".'arrayExif['.$li_index_js.']="'.addslashes($ls_exif).'";'."\n";
  306. // Determina la imagen inicial y el estilo del primer icono seleccionado
  307. if (!strlen($ls_img_inic)) {
  308. $ls_img_inic = $ls_img_gran;
  309. $ls_exif_inic = $ls_exif;
  310. $li_index_js_sel = $li_index_js;
  311. $ls_style_img=$ls_style_tr_icon_sel.$this->dat['icon_style'].$this->dat['icon_style_sel'];
  312. } else {
  313. $ls_style_img=$ls_style_tr_icon.$this->dat['icon_style'];
  314. }
  315. // Construye el HTML que lo llamará
  316. $ls_adic =' ID="ico'.$li_index_js.'"';
  317. $ls_adic.=' OnClick="jfvxroc(\''.$li_index_js.'\');"';
  318. $ls_adic.=' OnMouseOver="jfvxromo(\''.$li_index_js.'\');"';
  319. $ls_adic.=' OnMouseOut="jfvxromu(\''.$li_index_js.'\');"';
  320. $ls_adic.=' style="'.$ls_style_img.'"';
  321. $html['icons'][$nn] =
  322. '<div id="divIco'.$li_index_js.'" style="text-align:center;vertical-align:middle;position:relative;">'.
  323. $fnvxr->f_draw_img($this->dat['dir'].$this->dat['icon_path'].$imagenes[$n],'','','','0','','','',$ls_adic).$this->dat['icon_sep'];
  324. // Pone la imagen con la progress bar
  325. switch($this->i_browser['agent']) {
  326. case 'IE':
  327. $ls_style_img = 'filter=alpha(opacity='.($this->dat['progDiv_icon_opa'] * 100).');';
  328. break;
  329. default:
  330. $ls_style_img = 'opacity:'.$this->dat['progDiv_icon_opa'].';';
  331. }
  332. $ls_style_img.='position:absolute; left:'.$ll_icoXoffset.'px; top:'.$ll_icoXoffset.'px; z-index:4; display:none;';
  333. $html['icons'][$nn].= '<img src="'.$this->dat['dir_vxr_naveg'].'res/'.$this->dat['progIcoRes'].'" style="'.$ls_style_img.'" id="imgProgIco'.$li_index_js.'">';
  334. // Finaliza el DIV que alberga el icono y la barra de progreso
  335. $html['icons'][$nn].='</div>';
  336. // Suma el contador de iconos
  337. $nn++;
  338. } else {
  339. // Error! La imagen grande no ha sido bien calculada!
  340. if ($d) $this->of_debug( 'ERROR! $this->dat[\'dir\'].$ls_img_gran=\''.$this->dat['dir'].$ls_img_gran.'\' NO EXISTE!<br/>');
  341. }
  342. }
  343. }
  344. $li_num_iconos_validos=$nn;
  345. if ($this->ib_debug) $this->of_debug('<hr/>');
  346. if ($this->ib_debug) $this->of_debug('$li_num_iconos_validos='.$li_num_iconos_validos.'<br>');
  347. if ($this->ib_debug) $this->of_debug('$li_index_js='.$li_index_js.'<br>');
  348. // Pone variables para que estén accesibles en el Javascript
  349. $html['jsInLine'].= "\t".'id_opacityImg='.$this->dat['princ_load_opa'].';'."\n";
  350. $html['jsInLine'].= "\t".'ii_vxr_curr_sel='.$li_index_js_sel.';'."\n";
  351. $html['jsInLine'].= "\t".'ii_vxr_last_sel='.$li_index_js_sel.';'."\n";
  352. $html['jsInLine'].= "\t".'ii_vxr_max='.$li_index_js.';'."\n";
  353. list($ancho, $altura, $tipo, $atr) = getimagesize(dirname(__FILE__).'/res/'.$this->dat['progImgRes']);
  354. $html['jsInLine'].= "\t".'ii_ancho_imgProcess='.$ancho.';'."\n";
  355. $html['jsInLine'].= "\t".'ii_alto_imgProcess='.$altura.';'."\n";
  356. if ($this->ib_debug) $html['jsInLine'].= "\t".'ib_vxrDebug=true;'."\n";
  357. $html['jsInLine'].= "}\n";
  358. // Prepara los datos que han de aparecer en el panel para el EXIF, inicialmente
  359. $html['exifinicial'] = $ls_exif_inic;
  360. // Inicia el DIV que contiene la imagen principal
  361. $html['imggran'].='<div id="vxrContenedorPrinc" style="text-align:center;position:relative;width:100%;height:auto;">';
  362. // Pone el div con la progress bar
  363. switch($this->i_browser['agent']) {
  364. case 'IE':
  365. $ls_temp = 'filter=alpha(opacity='.($this->dat['progDiv_load_opa'] * 100).');';
  366. break;
  367. default:
  368. $ls_temp = 'opacity:'.$this->dat['progDiv_load_opa'].';';
  369. }
  370. $ls_style_para_img_progress=' style="border:1px solid gray;'.$ls_temp.'"';
  371. $ls_img_progress = '<img src="'.$this->dat['dir_vxr_naveg'].'res/'.$this->dat['progImgRes'].'" '.$ls_style_para_img_progress.' id="imgProgress">';
  372. $html['imggran'].='<div id="divProgress"
  373. style="position:absolute; z-index:3;display:none;
  374. text-align:center;vertical-align:middle;overflow:hidden;
  375. left:0px;
  376. width:99%;
  377. border:0px solid red;">';
  378. $html['imggran'].= $ls_img_progress;
  379. $html['imggran'].= '</div>';
  380. // Define la imagen principal
  381. $html['imggran'].= '<img src="'.$this->dat['dir'].$ls_img_inic.'" id="img_princ" style="'.$this->dat['princ_style'].'" OnLoad="jf_vxr_princ_ol(this);">';
  382. // Termina el DIV que contiene la imagen principal
  383. $html['imggran'].= '</div>';
  384. // Construye la tabla con los iconos
  385. $html['listaimg'] = "\n";
  386. if ($this->dat['icon_spread'] == 'horizontal') {
  387. // Ha de disponerse horizontalmente
  388. $html['listaimg'] = "\n<tr>";
  389. foreach($html['icons'] as $k=>$icon) {
  390. $html['listaimg'].= "\n".'<td>'.$icon.'</td>';
  391. if ((($k + 1) % $this->dat['icon_Columnas']) == 0) {
  392. $html['listaimg'].= "\n</tr>";
  393. if (($k + 1) < $li_num_iconos_validos) $html['listaimg'].= "\n<tr>";
  394. }
  395. }
  396. if ((($k + 1) % $this->dat['icon_Columnas']) != 0) $html['listaimg'].= "\n</tr>";
  397. } else {
  398. // Ha de disponerse verticalmente
  399. $k = 0;
  400. $k_inic = 0;
  401. $html['listaimg'] = "\n<tr>";
  402. for ($i=0; $i < $li_num_iconos_validos; $i++) {
  403. if ($d) $this->of_debug( '$i='.$i.' $k='.$k.' $k_inic='.$k_inic.'<br/>');
  404. $html['listaimg'].= "\n".'<td>'.$html['icons'][$k].'</td>';
  405. $k += $this->dat['icon_Filas'];
  406. if ($k >= $li_num_iconos_validos) {
  407. $html['listaimg'].= "\n</tr>";
  408. $k = $k_inic + 1;
  409. $k_inic = $k;
  410. }
  411. }
  412. }
  413. $html['listaimg'].= "\n";
  414. // Engloba las lista de imagenes en una tabla
  415. $html['listaimg'] = '<table border=0 cellpadding=0 cellspacing='.$this->dat['icon_spacing'].'>'.$html['listaimg'].'</table>';
  416. // A?ade un texto final a los iconos
  417. if (strlen($this->dat['icon_TextoFinal'])) {
  418. $html['listaimg'].= '<div class="vxrIconTextoFinal">'.$this->dat['icon_TextoFinal'].'</div>';
  419. }
  420. // A?ade un texto inicial a los iconos
  421. if (strlen($this->dat['icon_TextoInicial'])) {
  422. $html['listaimg'] = '<div class="vxrIconTextoInicial">'.$this->dat['icon_TextoInicial'].'</div>'.$html['listaimg'];
  423. }
  424. // Monitoriza las que ha tratado
  425. if ($il_tratadas_a) $html['techinfo'].= 'Tratadas A: '.$il_tratadas_a.' ';
  426. if ($il_tratadas_b) $html['techinfo'].= 'Tratadas B: '.$il_tratadas_b.' ';
  427. // El archivo javascript a incluir
  428. $html['js']=$this->dat['dir_vxr_naveg'].'vxr.js';
  429. // Sitúa el retorno
  430. $this->html = $html;
  431. return $html;
  432. }
  433. function of_vxr_gethtml() {
  434. return $this->html;
  435. }
  436. // Toma y prepara los datos del EXIF del archivo
  437. function of_vxr_getexif($as_file) {
  438. global $fnvxr;
  439. $s='';
  440. if (function_exists('exif_read_data')) {
  441. $d = exif_read_data($as_file);
  442. $fnvxr->f_array_value_always_set($d, 'DateTimeOriginal');
  443. $fnvxr->f_array_value_always_set($d, 'Make');
  444. $fnvxr->f_array_value_always_set($d, 'Model');
  445. $fnvxr->f_array_value_always_set($d, 'COMPUTED');
  446. $fnvxr->f_array_value_always_set($d, 'ExposureTime');
  447. $fnvxr->f_array_value_always_set($d, 'ISOSpeedRatings');
  448. $fnvxr->f_array_value_always_set($d, 'FocalLengthIn35mmFilm');
  449. $fnvxr->f_array_value_always_set($d, 'Flash');
  450. $fnvxr->f_array_value_always_set($d['COMPUTED'], 'ApertureFNumber');
  451. $s.= $this->of_vxr_gepar('Fecha:',$d['DateTimeOriginal']);
  452. $s.= $this->of_vxr_gepar('Archivo',$d['FileName']);
  453. $s.= $this->of_vxr_gepar('Tama?o:',$d['FileSize']);
  454. $s.= $this->of_vxr_gepar('Dimensiones:',$d['COMPUTED']['Width'].'x'.$d['COMPUTED']['Height']);
  455. if ( $fnvxr->f_string_primer_elemento($d['Make'], ' ') ==
  456. $fnvxr->f_string_primer_elemento($d['Model'], ' ') ) {
  457. $s.= $this->of_vxr_gepar('Cámara:',$d['Model']);
  458. } else {
  459. $s.= $this->of_vxr_gepar('Cámara:',$d['Make'].' '.$d['Model']);
  460. }
  461. $s.= $this->of_vxr_gepar('Apertura:',$d['COMPUTED']['ApertureFNumber']);
  462. $s.= $this->of_vxr_gepar('Exposición:',$d['ExposureTime']);
  463. $s.= $this->of_vxr_gepar('ISO:',$d['ISOSpeedRatings']);
  464. $s.= $this->of_vxr_gepar('Focal:',$d['FocalLengthIn35mmFilm']);
  465. $s.= $this->of_vxr_gepar('Flash',$d['Flash']);
  466. }
  467. $all='';
  468. //$all='<hr/>'.nl2br(print_r($d,true));
  469. return '<table class="va">'.$s.'</table>'.$all;
  470. }
  471. function of_vxr_gepar($a, $b) {
  472. $s='';
  473. if (strlen($b))
  474. $s='<tr><td class="vb">'.$a.'</td><td class="vc">'.$b.'</td></tr>';
  475. return $s;
  476. }
  477. //----------------------------------------------------------------------------------------------
  478. //
  479. // Función que lo hace todo, para fotos en un mismo directorio
  480. //
  481. // Parametros: Por mantener la compatibilidad, se deja el sistema de parámetros
  482. // anterior, pero tambien se permite usar un array, que usará los valores
  483. // propios del VXR más los especiales para este visor rápido.
  484. function of_vxr_show_modo_a($as_titulo='VXr Quick Photo Gallery', $as_size_icono='48', $ai_columnas=3, $ai_borde=0, $as_colortexto='#ff6600', $as_colorfondo='#000000', $as_icon_style='border-top:1px solid black;', $as_icon_TF='') {
  485. // Usa los valores entregados como parámetro (Versión primitiva)
  486. // Los 'showpage_*' son los parametros relativos a esta funcion
  487. $pagedat=array(
  488. 'dir' => './',
  489. 'princ_dim' => '',
  490. 'icon_path' => 'vxrtn/',
  491. 'icon_sep' => '',
  492. 'icon_spread' => 'horizontal', // Can be 'vertical', too
  493. 'icon_Columnas' => $ai_columnas,
  494. 'icon_Filas' => $ai_columnas,
  495. 'icon_TextoFinal' => '',
  496. 'icon_spacing' => $ai_borde,
  497. 'icon_style' => $as_icon_style,
  498. 'icon_TextoFinal' => $as_icon_TF,
  499. 'showpage_size_icono' => $as_size_icono,
  500. 'showpage_colorfondo' => $as_colorfondo,
  501. 'showpage_colortexto' => $as_colortexto,
  502. 'showpage_titulo' => $as_titulo,
  503. );
  504. return $this->of_vxr_showpage($pagedat);
  505. }
  506. //
  507. // Función que lo hace todo, para fotos en un mismo directorio
  508. //
  509. // Esta función también es un ejemplo de cómo se implementaría cualquier otro
  510. // sitio de visor.
  511. //
  512. //
  513. //
  514. /*
  515. // Campos del array VXR, pero que al menos es necesario indicar en esta función
  516. (Ver el código)
  517. // Existen más campos del array VXR que se pueden utilizar
  518. // Campos del array propios de esta función:
  519. ********* Los que comienzan por 'showpage_*' ***********
  520. */
  521. function of_vxr_showpage($mydat='') {
  522. global $fnvxr;
  523. $html = array();
  524. $pagedat = array();
  525. // If some params arrived, set them
  526. if ((!is_array($mydat)) && file_exists('vxr_showpage.ini')) {
  527. $mydat = parse_ini_file('vxr_showpage.ini');
  528. } else {
  529. if (!is_array($mydat)) $mydat = array();
  530. }
  531. // Corrige los valores que faltan
  532. $fnvxr->f_asv($mydat['showpage_colorfondo'],'#000000');
  533. $fnvxr->f_asv($mydat['showpage_colortexto'],'#ff6600');
  534. $fnvxr->f_asv($mydat['showpage_titulo'],'VXr Quick Photo Gallery');
  535. if (strlen($mydat['showpage_size_icono'])) {
  536. $mydat['icon_dim'] = $mydat['showpage_size_icono'].'x'.$mydat['showpage_size_icono'];
  537. $mydat['icon_pref'] = $mydat['showpage_size_icono'].'_';
  538. } else {
  539. $fnvxr->f_asv($mydat['icon_dim'], '48x48');
  540. $fnvxr->f_asv($mydat['icon_pref'], '48_');
  541. }
  542. $fnvxr->f_asv($mydat['dir'],'./');
  543. $fnvxr->f_asv($mydat['princ_dim'],'');
  544. $fnvxr->f_asv($mydat['icon_path'],'vxrtn/');
  545. $fnvxr->f_asv($mydat['icon_sep'],'');
  546. $fnvxr->f_asv($mydat['icon_spread'],'horizontal');
  547. $fnvxr->f_asv($mydat['icon_Columnas'],'3');
  548. $fnvxr->f_asv($mydat['icon_Filas'],'');
  549. $fnvxr->f_asv($mydat['icon_spacing'],'0');
  550. $fnvxr->f_asv($mydat['icon_style'],'border:1px solid black;');
  551. $fnvxr->f_asv($mydat['icon_TextoFinal'],'');
  552. $fnvxr->f_asv($mydat['showpage_colorfondo'],'#000000');
  553. $fnvxr->f_asv($mydat['showpage_colortexto'],'#ff6600');
  554. $fnvxr->f_asv($mydat['showpage_titulo'],'VXr Quick Photo Gallery');
  555. $fnvxr->f_asv($mydat[''],'');
  556. //echo nl2br(print_r($mydat, true));
  557. // echo '<hr>';
  558. $this->dat = array_merge($this->dat, $mydat);
  559. //echo nl2br(print_r($this->dat, true));
  560. //die();
  561. switch($this->i_browser['agent']) {
  562. case 'IE':
  563. $ls_file_css='vxr_ie.css';
  564. $ls_tmp_css='absolute';
  565. $ls_tmp_tr_capa_exif='filter=alpha(opacity=40);';
  566. $ls_tmp_tr_capa_debug='filter=alpha(opacity=70);';
  567. break;
  568. default:
  569. $ls_file_css='vxr.css';
  570. $ls_tmp_css='fixed';
  571. $ls_tmp_tr_capa_exif='opacity:.4;';
  572. $ls_tmp_tr_capa_debug='opacity:.7;';
  573. }
  574. $html = $this->of_vxr_do();
  575. // Comienza con el HTML
  576. $pagedat=array(
  577. 'javascript' => $html['js'],
  578. 'jsInLine' => $html['jsInLine'],
  579. 'OnLoad' => 'jf_vxr_start();',
  580. 'stylesheet' => '/_comun/classes/vxr/'.$ls_file_css,
  581. 'borde' => '0',
  582. 'bgcolor' => $mydat['showpage_colorfondo'],
  583. 'text' => $mydat['showpage_colorfondo'],
  584. 'title' => $mydat['showpage_titulo'],
  585. 'comentario' => "VXr Quick Photo Gallery {$this->is_version}\n(C)2006-2007 Juan Prada / silueth.com",
  586. );
  587. echo $fnvxr->f_draw_html_start($pagedat);
  588. // El menu
  589. include(dirname(__FILE__).'/vxr_menu.php');
  590. // Código CSS para ver el borde de los divs
  591. $dc='';
  592. //$dc='border: 2px dotted yellow;';
  593. // La imagen grande
  594. echo "\n".'<div id="divPageImgGran" style="position:relative; width:100%; left:0px; top:18px; text-align:center;'.$dc.'">'.$html['imggran'].'</div>';
  595. // La lista de imagenes
  596. echo "\n".'<div id="divPageIconos" style="position:'.$ls_tmp_css.'; left:0px; top:20px;'.$dc.'">'.$html['listaimg'].'</div>';
  597. // El texto técnico
  598. echo "\n".'<div id="divPageTextoTec" style="position:'.$ls_tmp_css.'; left:5px; bottom:5px;'.$dc.'"><pre>'.$html['techinfo'].'</pre></div>';
  599. // La información del EXIF
  600. echo '<div id="divPageEXIF" style="position:absolute; right:0px; top:18px; z-index:300; display:none; background:#222222; color:#ffffff; padding:4px; '.$ls_tmp_tr_capa_exif.$dc.'">'.$html['exifinicial'].'</div>';
  601. // El DIV con el debug
  602. if ($this->ib_debug)
  603. echo '<div id="divPageDebug" style="position:absolute; right:8px; top:18px; z-index:300; background:#111111; color:#ffffff; padding:6px; '.$ls_tmp_tr_capa_debug.$dc.'"><pre>'.$this->is_debug_txt.'</pre></div>';
  604. echo $fnvxr->f_draw_html_end();
  605. }
  606. /**
  607. * of_vxr_inic_msg()
  608. *
  609. * Define appropiate text in the proper language
  610. */
  611. function of_vxr_inic_msg() {
  612. switch($this->is_idioma) {
  613. case 'es':
  614. $this->msg['infoinic']='Haga click en los iconos de esta columna para ampliar las fotos';
  615. $this->msg['debug_noimageicon']='No existe imagen para icono:';
  616. break;
  617. default:
  618. $this->msg['infoinic']='Click in the icons to select each picture';
  619. $this->msg['debug_noimageicon']='There is no image for the icon:';
  620. break;
  621. }
  622. }
  623. }
  624. ?>