Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Lib.Util.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Utilities functions for freedom
8  *
9  * @author Anakeen
10  * @version $Id: Lib.Util.php,v 1.23 2009/01/07 18:05:08 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
18 {
19  include_once ("VAULT/Class.VaultFile.php");
20  return new VaultFile($dbaccess, "FREEDOM");
21 }
22 /**
23  * for FDLGEN directory
24  * @param $dbaccess
25  * @return string
26  */
27 function getGen($dbaccess)
28 {
29  return "GEN";
30 }
31 /**
32  * convert French date to iso8601
33  * @param string $fdate DD/MM/YYYY HH:MM:SS (CET)
34  * @param string $wtz with timezone add time zone in the end if true
35  * @return string date YYYY-MM-DD HH:MM:SS
36  * @deprecated use stringDateToIso() instead
37  */
38 function toIso8601($fdate, $wtz = false)
39 {
41  $isoDate = "";
42  $tz = "";
43  if (preg_match("/^(\d\d)\/(\d\d)\/(\d\d\d\d)\s(\d\d)?:?(\d\d)?:?(\d\d)?\s+?(\w+)?$/", $fdate, $reg)) {
44  $isoDate = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $reg[3], $reg[2], $reg[1], $reg[4], $reg[5], $reg[6]);
45  if ($reg[8] != "") $tz = $reg[7];
46  }
47  // ISO 8601
48  if ($wtz && $tz) $isoDate.= " " . $tz;
49 
50  return $isoDate;
51 }
52 
53 function StringDateToJD($sdate)
54 {
55  $jd = FrenchDateToJD($sdate);
56  if ($jd === false) $jd = Iso8601ToJD($sdate);
57  return $jd;
58 }
59 /**
60  * convert French date to Julian day
61  * the seconds are ignored
62  * @param string $fdate DD/MM/YYYY HH:MM
63  * @return float julian day (return false if incorrect date)
64  */
65 function FrenchDateToJD($fdate)
66 {
67  if (preg_match("/^(\d\d)\/(\d\d)\/(\d\d\d\d)\s?(\d\d)?:?(\d\d)?:?(\d\d)?(\.\d)*/", $fdate, $reg)) {
68  if (empty($reg[4])) {
69  $reg[4] = 0;
70  }
71  if (empty($reg[5])) {
72  $reg[5] = 0;
73  }
74  return cal2jd("CE", $reg[3], $reg[2], $reg[1], $reg[4], $reg[5], 0);
75  }
76  return false;
77 }
78 /**
79  * convert French date to unix timestamp
80  * date must be > 01/01/1970 and < 2038
81  * @param string $fdate DD/MM/YYYY HH:MM
82  * @return float number of second since epoch (return -1 if incorrect date)
83  */
84 function FrenchDateToUnixTs($fdate, $utc = false)
85 {
86  if (preg_match("/^(\d\d)\/(\d\d)\/(\d\d\d\d)\s?(\d\d)?:?(\d\d)?:?(\d\d)?/", $fdate, $r)) {
87  $r[4] = isset($r[4]) ? $r[4] : 0;
88  $r[5] = isset($r[5]) ? $r[5] : 0;
89  $r[6] = isset($r[6]) ? $r[6] : 0;
90  if ($utc) $dt = gmmktime($r[4], $r[5], $r[6], $r[2], $r[1], $r[3]);
91  else $dt = mktime($r[4], $r[5], $r[6], $r[2], $r[1], $r[3]);
92  } else {
93  $dt = - 1;
94  }
95  return $dt;
96 }
97 
98 function stringDateToLocaleDate($fdate, $format = '')
99 {
100  if (preg_match('/^(\d\d\d\d)-(\d\d)-(\d\d)[\s|T]?(\d\d)?:?(\d\d)?:?(\d\d)?/', $fdate, $r)) {
101  // convert to french
102  $yy = $r[1];
103  $mo = $r[2];
104  $dd = $r[3];
105  $hh = isset($r[4]) ? $r[4] : null;
106  $mm = isset($r[5]) ? $r[5] : null;
107  $ss = isset($r[6]) ? $r[6] : null;
108  if (!$hh && !$mm && !$ss) {
109  $fdate = sprintf("%s/%s/%s", $dd, $mo, $yy);
110  } elseif (!$ss) {
111 
112  $fdate = sprintf("%s/%s/%s %s:%s", $dd, $mo, $yy, $hh, $mm);
113  } else {
114 
115  $fdate = sprintf("%s/%s/%s %s:%s:%s", $dd, $mo, $yy, $hh, $mm, $ss);
116  }
117  }
118  return FrenchDateToLocaleDate($fdate, $format);
119 }
120 /**
121  *
122  * @param string $fdate
123  * @return string
124  */
125 function FrenchDateToLocaleDate($fdate, $format = '')
126 {
127  if (empty($fdate)) {
128  return "";
129  }
130  if (empty($format)) {
131  $localeconfig = getLocaleConfig();
132  if ($localeconfig !== false) {
133  if (strlen($fdate) >= 16) {
134  $format = $localeconfig['dateTimeFormat'];
135  } else {
136  $format = $localeconfig['dateFormat'];
137  }
138  } else {
139  return $fdate;
140  }
141  }
142  $ldate = $format;
143  $d = substr($fdate, 0, 2);
144  $m = substr($fdate, 3, 2);
145  $y = substr($fdate, 6, 4);
146  if (!ctype_digit($d)) return $fdate;
147  if (!ctype_digit($m)) return $fdate;
148  if (!ctype_digit($y)) return $fdate;
149  if (strlen($fdate) >= 16) {
150  $h = substr($fdate, 11, 2);
151  $i = substr($fdate, 14, 2);
152  if (!ctype_digit($h)) return $fdate;
153  if (!ctype_digit($i)) return $fdate;
154  if (strlen($fdate) == 19) {
155  $s = substr($fdate, 17, 2);
156  if (!ctype_digit($s)) return $fdate;
157  }
158  }
159  $ldate = str_replace('%d', $d, $ldate);
160  $ldate = str_replace('%m', $m, $ldate);
161  $ldate = str_replace('%Y', $y, $ldate);
162  if (isset($h)) {
163  $ldate = str_replace('%H', $h, $ldate);
164  }
165  if (isset($i)) {
166  $ldate = str_replace('%M', $i, $ldate);
167  }
168  if (isset($s)) {
169  $ldate = str_replace('%S', $s, $ldate);
170  }
171  return $ldate;
172 }
173 /**
174  * convert French date DD/MM/YYYY to iso
175  * date must be > 01/01/1970 and < 2038
176  * @param string $fdate DD/MM/YYYY HH:MM
177  * @param boolean $withT return YYYY-MM-DDTHH:MM:SS else YYYY-MM-DD HH:MM:SS
178  * @return string YYYY-MM-DD HH:MM:SS
179  */
180 function FrenchDateToIso($fdate, $withT = true)
181 {
182  if (!$fdate) return '';
183  if (preg_match('/^(\d\d)\/(\d\d)\/(\d\d\d\d)\s?(\d\d)?:?(\d\d)?:?(\d\d)?/', $fdate, $r)) {
184 
185  if (empty($r[4])) $dt = sprintf("%04d-%02d-%02d", $r[3], $r[2], $r[1]);
186  else $dt = sprintf("%04d-%02d-%02d%s%02d:%02d:%02d", $r[3], $r[2], $r[1], ($withT) ? 'T' : ' ', $r[4], $r[5], $r[6]);
187  } else {
188  $dt = "";
189  }
190  return $dt;
191 }
192 /**
193  * convert iso date to unix timestamp
194  * date must be > 1970-01-01 and < 2038
195  * @param string $isodate YYYY-MM-DD HH:MM
196  * @return float number of second since epoch (return -1 if incorrect date)
197  */
198 function iso8601DateToUnixTs($isodate, $utc = false)
199 {
200  if (preg_match("/^(\d\d\d\d)-(\d\d)-(\d\d)[\s|T]?(\d\d)?:?(\d\d)?:?(\d\d)?/", $isodate, $r)) {
201  if (empty($r[4])) $r[4] = 0;
202  if (empty($r[5])) $r[5] = 0;
203  if (empty($r[6])) $r[6] = 0;
204  if ($utc) $dt = gmmktime($r[4], $r[5], $r[6], $r[2], $r[3], $r[1]);
205  else $dt = mktime($r[4], $r[5], $r[6], $r[2], $r[3], $r[1]);
206  } else {
207  $dt = - 1;
208  }
209  return $dt;
210 }
211 /**
212  * convert date to unix timestamp
213  * date must be > 1970-01-01 and < 2038
214  * @param string $isodate YYYY-MM-DD HH:MM
215  * @return float number of second since epoch (return -1 if incorrect date)
216  */
217 function stringDateToUnixTs($isodate, $utc = false)
218 {
219  $dt = FrenchDateToUnixTs($isodate, $utc);
220  if ($dt < 0) $dt = iso8601DateToUnixTs($isodate, $utc);
221  return $dt;
222 }
223 /**
224  * verify if a date seems valid
225  * @param string $date iso, french english date
226  * @return bool true if it ia a valid date
227  */
228 function isValidDate($date)
229 {
230  if ((strlen($date) > 0) && (strlen($date) < 3)) return false;
231  $date = stringDateToIso($date, "");
232  if (preg_match('/^(\d\d\d\d)-(\d\d)-(\d\d)/', $date, $reg)) {
233  return checkdate($reg[2], $reg[3], $reg[1]);
234  }
235  return false;
236 }
237 /**
238  * convert string date to iso
239  * @note if the $date input is not recognised like a date the function return the original $date argument
240  *
241  * @param string $date DD/MM/YYYY HH:MM or YYYY-MM-DD HH:MM or YYYY-MM-DDTHH:MM
242  * @param bool|string optionnal input $format to indicate locale : french default is "%d/%m/%Y %H:%M". If not set use locale configuration of server
243  * @param bool $withT to add a T between day and hour: YYYY-MM-DDTHH:MM
244  * @return string YYYY-MM-DD HH:MM
245  */
246 function stringDateToIso($date, $format = false, $withT = false)
247 {
248  if ($format === false) {
249  if (preg_match('/^(\d\d\d\d)-(\d\d)-(\d\d)[\s|T]?(\d\d)?:?(\d\d)?:?(\d\d)?/', $date, $r)) {
250  if ($withT) {
251  if (strlen($date) > 11) {
252  $date[10] = 'T';
253  }
254  }
255  return $date;
256  } else {
257  $dt = FrenchDateToIso($date, $withT);
258  if (!$dt) return $date;
259  return $dt;
260  }
261  }
262  if (empty($format)) {
263  $localeconfig = getLocaleConfig();
264  if ($localeconfig !== false) {
265  $format = $localeconfig['dateTimeFormat'];
266  if (strlen($date) < strlen($format)) {
267  $format = $localeconfig['dateFormat'];
268  }
269  }
270  }
271  if (!empty($format)) {
272  $format = str_replace('%Y', '%YYY', $format);
273  if (strlen($date) < strlen($format)) {
274  return $date;
275  }
276  // date
277  $d = strpos($format, '%d');
278  $m = strpos($format, '%m');
279  $y = strpos($format, '%YYY');
280  if ($d !== false && $m !== false && $y !== false) {
281  $tmp = substr($date, $y, 4);
282  if (!ctype_digit($tmp)) return $date;
283  $dt = $tmp . '-';
284  $tmp = substr($date, $m, 2);
285  if (!ctype_digit($tmp)) return $date;
286  $dt.= $tmp . '-';
287  $tmp = substr($date, $d, 2);
288  if (!ctype_digit($tmp)) return $date;
289  $dt.= $tmp;
290  } else {
291  return $date;
292  }
293  // time
294  $h = strpos($format, '%H');
295  $m = strpos($format, '%M');
296  $s = strpos($format, '%S');
297  if ($h !== false && $m !== false) {
298  $dt.= ($withT ? 'T' : ' ') . substr($date, $h, 2) . ':' . substr($date, $m, 2);
299  if ($s !== false) {
300  $dt.= ':' . substr($date, $s, 2);
301  }
302  }
303  return $dt;
304  } else {
305  $dt = FrenchDateToIso($date, $withT);
306  if (!$dt) return $date;
307  return $dt;
308  }
309 }
310 /**
311  * convert iso8601 date to Julian day
312  * the seconds are ignored
313  * @param string $isodate YYYY-MM-DD HH:MM
314  * @return float julian day (return false if incorrect date)
315  */
316 function Iso8601ToJD($isodate)
317 {
318  if (preg_match("/^(\d\d\d\d)-(\d\d)-(\d\d)\s?(\d\d)?:?(\d\d)?:?(\d\d)?/", $isodate, $reg)) {
319  if (!isset($reg[4])) $reg[4] = 0;
320  if (!isset($reg[5])) $reg[5] = 0;
321  return cal2jd("CE", $reg[1], $reg[2], $reg[3], $reg[4], $reg[5], 0);
322  }
323  return false;
324 }
325 
326 function cal2jd($era, $y, $m, $d, $h, $mn, $s)
327 {
328  if (($y > 1969) && ($y < 2038)) {
329  $nd = unixtojd(mktime($h, $mn, $s, $m, $d, $y));
330  $nm = (($h * 60 + $mn) - 720) / 1440;
331  $nd+= round($nm, 5);
332  return $nd;
333  } else {
334 
335  if ($y == 0) {
336  AddWarningMsg("There is no year 0 in the Julian system!");
337  return "invalid";
338  }
339  if ($y == 1582 && $m == 10 && $d > 4 && $d < 15 && $era != "BCE") {
340  AddWarningMsg("The dates 5 through 14 October, 1582, do not exist in the Gregorian system!");
341  return "invalid";
342  }
343 
344  if ($era == "BCE") $y = - $y + 1;
345  if ($m > 2) {
346  $jy = $y;
347  $jm = $m + 1;
348  } else {
349  $jy = $y - 1;
350  $jm = $m + 13;
351  }
352 
353  $intgr = floor(floor(365.25 * $jy) + floor(30.6001 * $jm) + $d + 1720995);
354  //check for switch to Gregorian calendar
355  $gregcal = 15 + 31 * (10 + 12 * 1582);
356  if ($d + 31 * ($m + 12 * $y) >= $gregcal) {
357  $ja = floor(0.01 * $jy);
358  $intgr+= 2 - $ja + floor(0.25 * $ja);
359  }
360  //correct for half-day offset
361  $dayfrac = $h / 24.0 - 0.5;
362  if ($dayfrac < 0.0) {
363  $dayfrac+= 1.0;
364  $intgr--;
365  }
366  //now set the fraction of a day
367  $frac = $dayfrac + ($mn + $s / 60.0) / 60.0 / 24.0;
368  //round to nearest second
369  $jd0 = ($intgr + $frac) * 100000;
370  $jd = floor($jd0);
371  if ($jd0 - $jd > 0.5) $jd++;
372  return $jd / 100000;
373  }
374 }
375 /**
376  * return the day of the week (1 id Monday, 7 is Sunday)
377  * @param float $jd julian date
378  * @return int
379  */
380 function jdWeekDay($jd)
381 {
382  //weekday
383  $t = doubleval($jd) + 0.5;
384  $wd = floor(($t / 7 - floor($t / 7)) * 7 + 0.000000000317); //add 0.01 sec for truncation error correction
385  return $wd + 1;
386 }
387 /**
388  * return the number of the week in year
389  * @param float $jd julian date
390  * @return int between 1 and 53
391  */
392 function jdWeekNumber($jd)
393 {
394  $j = doubleval($jd) + 0.5;
395  $d4 = ((($j + 31741 - ($j % 7)) % 146097) % 36524) % 1461;
396  $l = floor($d4 / 1460);
397  $d1 = (($d4 - $l) % 365) + $l;
398  $wn = floor($d1 / 7) + 1;
399  return ($wn);
400 }
401 /**
402  * return date in string format
403  * @param float $jd julian date
404  * @param string $dformat the format (default iso8601)
405  * @return string the formatted date
406  */
407 function jd2cal($jd, $dformat = '')
408 {
409  //
410  // get the date from the Julian day number
411  //
412  $intgr = floor($jd);
413  $frac = $jd - $intgr;
414  $gregjd = 2299160.5;
415  if ($jd >= $gregjd) { //Gregorian calendar correction
416  $tmp = floor((($intgr - 1867216.0) - 0.25) / 36524.25);
417  $j1 = $intgr + 1 + $tmp - floor(0.25 * $tmp);
418  } else $j1 = $intgr;
419  //correction for half day offset
420  $df = $frac + 0.5;
421  if ($df >= 1.0) {
422  $df-= 1.0;
423  $j1++;
424  }
425 
426  $j2 = $j1 + 1524.0;
427  $j3 = floor(6680.0 + (($j2 - 2439870.0) - 122.1) / 365.25);
428  $j4 = floor($j3 * 365.25);
429  $j5 = floor(($j2 - $j4) / 30.6001);
430 
431  $d = floor($j2 - $j4 - floor($j5 * 30.6001));
432  $m = floor($j5 - 1.0);
433  if ($m > 12) $m-= 12;
434  $y = floor($j3 - 4715.0);
435  if ($m > 2) $y--;
436  if ($y <= 0) $y--;
437  //
438  // get time of day from day fraction
439  //
440  $hr = floor($df * 24.0);
441  $mn = floor(($df * 24.0 - $hr) * 60.0);
442  $f = (($df * 24.0 - $hr) * 60.0 - $mn) * 60.0;
443  $sc = floor($f);
444  $f-= $sc;
445  if ($f > 0.5) $sc++;
446  if ($sc == 60) {
447  $sc = 0;
448  $mn++;
449  }
450  if ($mn == 60) {
451  $mn = 0;
452  $hr++;
453  }
454  if ($hr == 24) {
455  $hr = 0;
456  $d++; //this could cause a bug, but probably will never happen in practice
457 
458  }
459 
460  if ($y < 0) {
461  $y = - $y;
462  $ce = ' BCE';
463  // form.era[1].checked = true;
464 
465  } else {
466  $ce = '';
467  // form.era[0].checked = true;
468 
469  }
470  switch ($dformat) {
471  case 'M':
472  $retiso8601 = $m;
473  break;
474 
475  case 'Y':
476  $retiso8601 = $y;
477  break;
478 
479  case 'd':
480  $retiso8601 = $d;
481  break;
482 
483  case 'French':
484  $retiso8601 = sprintf("%02d/%02d/%04s", $d, $m, $y);
485  break;
486 
487  case 'FrenchLong':
488  $retiso8601 = sprintf("%02d/%02d/%04s %02d:%02d %s", $d, $m, $y, $hr, $mn, $ce);
489  break;
490 
491  default:
492  $retiso8601 = sprintf("%04d-%02d-%02s %02d:%02d%s", $y, $m, $d, $hr, $mn, $ce);
493  }
494  return $retiso8601;
495 }
496 /**
497  * backslash quote and replace double-quote by html entity
498  */
499 function addJsSlashes($s)
500 {
501  return str_replace(array(
502  "'",
503  "\""
504  ) , array(
505  "\\'",
506  "&#34;"
507  ) , $s);
508 }
509 /**
510  * Remove Character Accents
511  * Replaces accented characters in a string with their unaccented versions, for instance, converts "ÉéÜüÄäÖ" into "EeUuAaO". The function will handle any accented character for which there exists an HTML entity in PHP's translation table (i.e. pretty much any and all characters). Credits go to jennings at trad dot uji dot es for the original version of this incredibly useful little function. I used this function to good effect in OpenSEF.
512  */
513 function unaccent_($text)
514 {
515  static $search, $replace;
516  if (!$search) {
517  $search = $replace = array();
518  // Get the HTML entities table into an array
519  $trans = get_html_translation_table(HTML_ENTITIES);
520  // Go through the entity mappings one-by-one
521  foreach ($trans as $literal => $entity) {
522  // Make sure we don't process any other characters
523  // such as fractions, quotes etc:
524  if (ord($literal) >= 192) {
525  // Get the accented form of the letter
526  $search[] = $literal;
527  // Get e.g. 'E' from the string '&Eacute'
528  $replace[] = $entity[1];
529  }
530  }
531  }
532  return str_replace($search, $replace, $text);
533 }
534 
535 function unaccent_iso8859_1($string)
536 {
537  $string = strtr($string, "\xA1\xAA\xBA\xBF\xC0\xC1\xC2\xC3\xC5\xC7
538  \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
539  \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD\xE0
540  \xE1\xE2\xE3\xE5\xE7\xE8\xE9\xEA\xEB\xEC
541  \xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
542  \xF9\xFA\xFB\xFD\xFF", "!ao?AAAAAC
543  EEEEIIIIDN
544  OOOOOUUUYa
545  aaaaceeeei
546  iiidnooooo
547  uuuyy");
548  $string = strtr($string, array(
549  "\xC4" => "Ae",
550  "\xC6" => "AE",
551  "\xD6" => "Oe",
552  "\xDC" => "Ue",
553  "\xDE" => "TH",
554  "\xDF" => "ss",
555  "\xE4" => "ae",
556  "\xE6" => "ae",
557  "\xF6" => "oe",
558  "\xFC" => "ue",
559  "\xFE" => "th"
560  ));
561  return ($string);
562 }
563 
564 function unaccent_utf8($string)
565 {
566  return iconv("UTF-8", "ASCII//TRANSLIT", $string);
567 }
568 
569 function unaccent($s)
570 {
571  return unaccent_utf8($s);
572 }
573 /**
574  * replace a string separate by $sep
575  */
576 function sep_replace($ak, $idx, $by = "-", $sep = "\n")
577 {
578  $endoff = - 1;
579  do {
580  $offset = $endoff + 1;
581  $endoff = strpos($ak, "\n", $offset);
582  $idx--;
583  } while (($idx >= 0) && ($endoff !== false));
584 
585  if ($idx >= 0) return $ak . str_repeat("\n-", $idx) . "\n$by";
586  else if ($endoff == false) {
587  if ($offset == 0) return "$by";
588  else return substr($ak, 0, $offset - 1) . "\n$by";
589  } else return substr($ak, 0, $offset) . "$by\n" . substr($ak, $endoff + 1);
590 }
591 /**
592  * change & < and > character to respetiv entity
593  * @param string $s string to encode
594  * @return string encoded string
595  */
597 {
598  return str_replace(array(
599  '&',
600  "<",
601  ">"
602  ) , array(
603  "&amp;",
604  "&lt;",
605  "&gt;"
606  ) , $s);
607 }
609 {
610  return str_replace(array(
611  '"',
612  "'"
613  ) , array(
614  "&quot;",
615  "&apos;"
616  ) , xml_entity_encode($s));
617 }
618 /**
619  * Remove JS and other insecure elements from HTML.
620  *
621  * @param string $html
622  * @return string
623  */
624 function cleanhtmljs($html)
625 {
626  /* Tags to remove */
627  $tag_list = array(
628  'script',
629  'iframe',
630  'frame',
631  'frameset',
632  'object',
633  'embed',
634  'applet'
635  );
636  /* Attributes to remove */
637  $attr_list = 'on[a-z]+';
638  /* Pre-compute tag_list regexes */
639  $remove_list = array();
640  foreach ($tag_list as $tag) {
641  $remove_list[] = array(
642  'name' => $tag,
643  'start' => sprintf('#^<%s\b#i', $tag) ,
644  'end' => sprintf('#^</%s\b#i', $tag)
645  );
646  }
647  /*
648  * Tokenize HTML: stream of ["text", "<TAG>", "text", "</TAG>", "text", "<FOO/>", "text", etc.]
649  */
650  $tokens = preg_split("#(<[^>]*?>)#", $html, NULL, PREG_SPLIT_DELIM_CAPTURE);
651  /* Parse tokens and remove unwanted elements */
652  $skip = false;
653  foreach ($tokens as & $elmt) {
654  /*
655  * Pass 1: remove tags
656  */
657  foreach ($remove_list as $tag) {
658  if (!$skip && preg_match($tag['start'], $elmt)) {
659  /* Skip tag */
660  $elmt = '';
661  /* If not a self-closing tag, then mark to skip it's content */
662  if (!preg_match(':/>$:', $elmt)) {
663  $skip = $tag['name'];
664  }
665  break;
666  } elseif ($skip == $tag['name'] && preg_match($tag['end'], $elmt)) {
667  /* End of skipped tag's content */
668  $skip = false;
669  $elmt = '';
670  break;
671  } elseif (!$skip && preg_match($tag['end'], $elmt)) {
672  /* Remove ending tags that have not been started */
673  $elmt = '';
674  break;
675  }
676  }
677  if ($skip) {
678  /* Skip content from removed tags */
679  $elmt = '';
680  continue;
681  }
682  /*
683  * Pass 2: remove attributes
684  */
685  if (preg_match('#^<[^>]*?>$#s', $elmt)) {
686  $elmt = preg_replace("#\\s*\\b$attr_list\\b\\s*=\\s*(['\"])(.*?)(\\1)#is", "", $elmt);
687  }
688  }
689  unset($elmt);
690  /* Recompose content */
691  return join('', $tokens);
692 }
StringDateToJD($sdate)
Definition: Lib.Util.php:53
sep_replace($ak, $idx, $by="-", $sep="\n")
Definition: Lib.Util.php:576
unaccent_utf8($string)
Definition: Lib.Util.php:564
newFreeVaultFile($dbaccess)
Definition: Lib.Util.php:17
unaccent_iso8859_1($string)
Definition: Lib.Util.php:535
$dt
Definition: dav.php:69
jdWeekNumber($jd)
Definition: Lib.Util.php:392
stringDateToIso($date, $format=false, $withT=false)
Definition: Lib.Util.php:246
addJsSlashes($s)
Definition: Lib.Util.php:499
stringDateToLocaleDate($fdate, $format= '')
Definition: Lib.Util.php:98
jdWeekDay($jd)
Definition: Lib.Util.php:380
cleanhtmljs($html)
Definition: Lib.Util.php:624
jd2cal($jd, $dformat= '')
Definition: Lib.Util.php:407
iso8601DateToUnixTs($isodate, $utc=false)
Definition: Lib.Util.php:198
if($famId) $s
getLocaleConfig($core_lang= '')
Definition: Lib.Common.php:853
$d
Definition: dav.php:77
xml_entity_encode_all($s)
Definition: Lib.Util.php:608
$d1
Definition: dav.php:11
$search
toIso8601($fdate, $wtz=false)
Definition: Lib.Util.php:38
FrenchDateToJD($fdate)
Definition: Lib.Util.php:65
cal2jd($era, $y, $m, $d, $h, $mn, $s)
Definition: Lib.Util.php:326
FrenchDateToLocaleDate($fdate, $format= '')
Definition: Lib.Util.php:125
isValidDate($date)
Definition: Lib.Util.php:228
deprecatedFunction($msg= '')
Definition: Lib.Common.php:86
unaccent_($text)
Definition: Lib.Util.php:513
stringDateToUnixTs($isodate, $utc=false)
Definition: Lib.Util.php:217
$dbaccess
Definition: checkVault.php:17
xml_entity_encode($s)
Definition: Lib.Util.php:596
unaccent($s)
Definition: Lib.Util.php:569
FrenchDateToUnixTs($fdate, $utc=false)
Definition: Lib.Util.php:84
FrenchDateToIso($fdate, $withT=true)
Definition: Lib.Util.php:180
Iso8601ToJD($isodate)
Definition: Lib.Util.php:316
getGen($dbaccess)
Definition: Lib.Util.php:27
← centre documentaire © anakeen