5
5
ini_set ("error_reporting " ,0 );
6
6
7
7
function conectar (){
8
- require __DIR__ .'/config.php ' ;
8
+ require __DIR__ .'/config.php ' ;
9
9
$ link = new mysqli (
10
10
$ config ['db ' ]['host ' ],
11
11
$ config ['db ' ]['user ' ],
12
12
$ config ['db ' ]['pass ' ],
13
13
$ config ['db ' ]['name ' ]
14
14
);
15
- if ($ link ->connect_errno ) {
16
- die ('No pudo conectarse: ' . $ link ->connect_error );
17
- }
18
- $ link ->set_charset ('utf8 ' );
19
- return $ link ;
15
+ if ($ link ->connect_errno ) {
16
+ die ('No pudo conectarse: ' . $ link ->connect_error );
17
+ }
18
+ $ link ->set_charset ('utf8 ' );
19
+ return $ link ;
20
20
}
21
21
22
22
function conectar2 (){
23
- require __DIR__ .'/config.php ' ;
23
+ require __DIR__ .'/config.php ' ;
24
24
$ link = new mysqli (
25
25
$ config ['db ' ]['host ' ],
26
26
$ config ['db ' ]['user ' ],
27
27
$ config ['db ' ]['pass ' ],
28
28
$ config ['db ' ]['name ' ]
29
29
);
30
- if ($ link ->connect_errno ) {
31
- die ('No pudo conectarse: ' . $ link ->connect_error );
32
- }
33
- //mysql_set_charset('utf8',$link);
34
- return $ link ;
30
+ if ($ link ->connect_errno ) {
31
+ die ('No pudo conectarse: ' . $ link ->connect_error );
32
+ }
33
+ //mysql_set_charset('utf8',$link);
34
+ return $ link ;
35
35
}
36
36
37
37
@@ -73,20 +73,6 @@ function obtener2( $tabla, $iden, $id, $campo )
73
73
return $ segm ;
74
74
}
75
75
76
- function datosreg ( $ id , $ tabla , $ campo , $ iden )
77
- {
78
- $ sql_link = conectar ();
79
- if ( $ id == "" || empty ($ id ) )
80
- return "" ;
81
- // obtener datos del usuario
82
- $ q = "SELECT * FROM " .$ tabla ." WHERE " .$ iden ." = ' " .$ id ."' " ;
83
- $ result = $ sql_link ->query ($ q ) or oiError ($ sql_link ->error ());
84
- $ ret = $ result ->fetch_array ();
85
- $ segm = $ ret [$ campo ];
86
- $ result ->free_result ();
87
- return $ segm ;
88
- }
89
-
90
76
/**
91
77
* function obtener (de_la_tabla, donde_este_campo, es_igual_a_esto, este_campo_quiero);
92
78
* Obtenemos un campo especifico.
@@ -307,19 +293,31 @@ function Comprobariexplorer2($user_agent) {
307
293
return false ;
308
294
}
309
295
310
- // ENCRIPTAR
311
-
296
+ /**
297
+ * function encriptar ($cad);
298
+ * We obtain the encrypted string
299
+ * @$cad: string
300
+ *
301
+ * return string
302
+ */
312
303
function encriptar ($ cad ){
313
- $ cc = base64_encode ($ cad );
314
- $ key = 'rnvoxjnj ' ;
315
- $ iv = '12345678 ' ;
316
- $ cipher = mcrypt_module_open (MCRYPT_BLOWFISH ,'' ,'cbc ' ,'' );
317
- mcrypt_generic_init ($ cipher , $ key , $ iv );
318
- $ encrypted = mcrypt_generic ($ cipher ,$ cc );
319
- mcrypt_generic_deinit ($ cipher );
320
- return base64_encode ($ encrypted );
304
+ $ cc = base64_encode ($ cad );
305
+ $ key = 'rnvoxjnj ' ;
306
+ $ iv = '12345678 ' ;
307
+ $ cipher = mcrypt_module_open (MCRYPT_BLOWFISH ,'' ,'cbc ' ,'' );
308
+ mcrypt_generic_init ($ cipher , $ key , $ iv );
309
+ $ encrypted = mcrypt_generic ($ cipher ,$ cc );
310
+ mcrypt_generic_deinit ($ cipher );
311
+ return base64_encode ($ encrypted );
321
312
}
322
313
314
+ /**
315
+ * function desenencriptar ($cad);
316
+ * We obtain the original string
317
+ * @$cad: string
318
+ *
319
+ * return string
320
+ */
323
321
function desencriptar ($ cad )
324
322
{
325
323
$ cc = base64_decode ($ cad );
@@ -332,99 +330,30 @@ function desencriptar($cad)
332
330
return base64_decode ($ decrypted );
333
331
}
334
332
335
- // COMPLETAR CON CEROS A LA IZQUIERDA
336
- /////////////////////////////////////
337
- function completar ($ valor , $ digitos ){
338
- $ resultado ='' ;
339
- if (strlen ($ valor )<$ digitos ){
340
-
341
- $ ceros =$ digitos -strlen (ceil ($ valor ));
342
- for ($ i =0 ;$ i <$ ceros ;$ i ++){
333
+ /**
334
+ * function completar ($valor, $digitos);
335
+ * Completed variable with zeros to the left
336
+ * @$valor: variable
337
+ * @digitos: size of variable
338
+ *
339
+ * return string
340
+ */
341
+ function completar ($ valor , $ digitos )
342
+ {
343
+ $ resultado ='' ;
344
+ if (strlen ($ valor )<$ digitos )
345
+ {
346
+ $ ceros =$ digitos -strlen (ceil ($ valor ));
347
+ for ($ i =0 ;$ i <$ ceros ;$ i ++)
348
+ {
343
349
$ resultado .='0 ' ;
344
350
}
345
351
}
346
- $ resultado .=$ valor ;
347
- return $ resultado ;
348
- }
349
-
350
- ////////////////////////////////////////////////////
351
-
352
- //Convierte fecha de mysql a normal
353
-
354
- ////////////////////////////////////////////////////
355
-
356
- function fechanormal ($ fecha ){
357
- if ($ fecha >0 ){
358
- ereg ( "([0-9]{2,4})-([0-9]{1,2})-([0-9]{1,2}) " , $ fecha , $ mifecha );
359
-
360
- $ lafecha =$ mifecha [3 ]."/ " .$ mifecha [2 ]."/ " .$ mifecha [1 ];
361
- }
362
- else {
363
- $ lafecha ="" ;
364
- }
365
- return $ lafecha ;
366
-
352
+ $ resultado .= $ valor ;
353
+ return $ resultado ;
367
354
}
368
355
369
- // MESES EN ESPAÑOL DE ESPAÑA
370
- /////////////////////////////////
371
- function meses ($ valor ){
372
- if ($ valor ==1 ){
373
- $ resultado ="Enero " ;
374
- }
375
- if ($ valor ==2 ){
376
- $ resultado ="Febrero " ;
377
- }
378
- if ($ valor ==3 ){
379
- $ resultado ="Marzo " ;
380
- }
381
- if ($ valor ==4 ){
382
- $ resultado ="Abril " ;
383
- }
384
- if ($ valor ==5 ){
385
- $ resultado ="Mayo " ;
386
- }
387
- if ($ valor ==6 ){
388
- $ resultado ="Junio " ;
389
- }
390
- if ($ valor ==7 ){
391
- $ resultado ="Julio " ;
392
- }
393
- if ($ valor ==8 ){
394
- $ resultado ="Agosto " ;
395
- }
396
- if ($ valor ==9 ){
397
- $ resultado ="Septiembre " ;
398
- }
399
- if ($ valor ==10 ){
400
- $ resultado ="Octubre " ;
401
- }
402
- if ($ valor ==11 ){
403
- $ resultado ="Noviembre " ;
404
- }
405
- if ($ valor ==12 ){
406
- $ resultado ="Diciembre " ;
407
- }
408
- return $ resultado ;
409
- }
410
-
411
- // DATOS TABLA POR COD
412
- /////////////////////
413
- /*
414
- function datosreg($codigo, $tabla, $campo, $campocod='cod'){
415
- $query=mysql_query("select ".$campo." as valor from ".$tabla." where ".$campocod."='".$codigo."';" );
416
- if(mysql_errno()!=0){
417
- $resultado=mysql_error();
418
- } else {
419
- while($rows=mysql_fetch_array($query)){
420
- $resultado=$rows["valor"];
421
- }
422
- }
423
- return $resultado;
424
- }
425
- */
426
356
//QUITAR CODIFICACION HTML ACENTOS, EÑES...
427
-
428
357
function quitar_html ($ cadena ){
429
358
$ txt =str_replace ("<br /> " ,chr (13 ).chr (10 ),$ cadena );
430
359
$ txt =str_replace ("<br> " ,chr (13 ).chr (10 ),$ txt );
@@ -455,7 +384,7 @@ function quitar_html($cadena){
455
384
$ txt =str_replace ("º " ,'º ' ,$ txt );
456
385
$ txt =str_replace ("& " ,'& ' ,$ txt );
457
386
$ txt =str_replace ("• " ,'• ' ,$ txt );
458
- $ txt =str_replace ("€ " ,'€ ' ,$ txt );
387
+ $ txt =str_replace ("€ " ,'€ ' ,$ txt );
459
388
460
389
return $ txt ;
461
390
}
@@ -809,4 +738,4 @@ function limpiar($valor){
809
738
$ valor = htmlentities ($ valor );
810
739
return $ valor ;
811
740
}
812
- ?>
741
+ ?>
0 commit comments