19 include_once (
"VAULT/Class.VaultFile.php");
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];
48 if ($wtz && $tz) $isoDate.=
" " . $tz;
67 if (preg_match(
"/^(\d\d)\/(\d\d)\/(\d\d\d\d)\s?(\d\d)?:?(\d\d)?:?(\d\d)?(\.\d)*/", $fdate, $reg)) {
74 return cal2jd(
"CE", $reg[3], $reg[2], $reg[1], $reg[4], $reg[5], 0);
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;
100 if (preg_match(
'/^(\d\d\d\d)-(\d\d)-(\d\d)[\s|T]?(\d\d)?:?(\d\d)?:?(\d\d)?/', $fdate,
$r)) {
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);
112 $fdate = sprintf(
"%s/%s/%s %s:%s", $dd, $mo, $yy, $hh, $mm);
115 $fdate = sprintf(
"%s/%s/%s %s:%s:%s", $dd, $mo, $yy, $hh, $mm, $ss);
130 if (empty($format)) {
132 if ($localeconfig !==
false) {
133 if (strlen($fdate) >= 16) {
134 $format = $localeconfig[
'dateTimeFormat'];
136 $format = $localeconfig[
'dateFormat'];
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;
159 $ldate = str_replace(
'%d',
$d, $ldate);
160 $ldate = str_replace(
'%m', $m, $ldate);
161 $ldate = str_replace(
'%Y', $y, $ldate);
163 $ldate = str_replace(
'%H', $h, $ldate);
166 $ldate = str_replace(
'%M', $i, $ldate);
169 $ldate = str_replace(
'%S',
$s, $ldate);
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)) {
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]);
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;
230 if ((strlen($date) > 0) && (strlen($date) < 3))
return false;
232 if (preg_match(
'/^(\d\d\d\d)-(\d\d)-(\d\d)/', $date, $reg)) {
233 return checkdate($reg[2], $reg[3], $reg[1]);
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)) {
251 if (strlen($date) > 11) {
258 if (!
$dt)
return $date;
262 if (empty($format)) {
264 if ($localeconfig !==
false) {
265 $format = $localeconfig[
'dateTimeFormat'];
266 if (strlen($date) < strlen($format)) {
267 $format = $localeconfig[
'dateFormat'];
271 if (!empty($format)) {
272 $format = str_replace(
'%Y',
'%YYY', $format);
273 if (strlen($date) < strlen($format)) {
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;
284 $tmp = substr($date, $m, 2);
285 if (!ctype_digit($tmp))
return $date;
287 $tmp = substr($date,
$d, 2);
288 if (!ctype_digit($tmp))
return $date;
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);
300 $dt.=
':' . substr($date,
$s, 2);
306 if (!
$dt)
return $date;
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);
328 if (($y > 1969) && ($y < 2038)) {
329 $nd = unixtojd(mktime($h, $mn,
$s, $m,
$d, $y));
330 $nm = (($h * 60 + $mn) - 720) / 1440;
336 AddWarningMsg(
"There is no year 0 in the Julian system!");
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!");
344 if ($era ==
"BCE") $y = - $y + 1;
353 $intgr = floor(floor(365.25 * $jy) + floor(30.6001 * $jm) +
$d + 1720995);
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);
361 $dayfrac = $h / 24.0 - 0.5;
362 if ($dayfrac < 0.0) {
367 $frac = $dayfrac + ($mn +
$s / 60.0) / 60.0 / 24.0;
369 $jd0 = ($intgr + $frac) * 100000;
371 if ($jd0 - $jd > 0.5) $jd++;
383 $t = doubleval($jd) + 0.5;
384 $wd = floor(($t / 7 - floor($t / 7)) * 7 + 0.000000000317);
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;
413 $frac = $jd - $intgr;
415 if ($jd >= $gregjd) {
416 $tmp = floor((($intgr - 1867216.0) - 0.25) / 36524.25);
417 $j1 = $intgr + 1 + $tmp - floor(0.25 * $tmp);
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);
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);
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;
484 $retiso8601 = sprintf(
"%02d/%02d/%04s",
$d, $m, $y);
488 $retiso8601 = sprintf(
"%02d/%02d/%04s %02d:%02d %s",
$d, $m, $y, $hr, $mn, $ce);
492 $retiso8601 = sprintf(
"%04d-%02d-%02s %02d:%02d%s", $y, $m,
$d, $hr, $mn, $ce);
501 return str_replace(array(
519 $trans = get_html_translation_table(HTML_ENTITIES);
521 foreach ($trans as $literal => $entity) {
524 if (ord($literal) >= 192) {
528 $replace[] = $entity[1];
532 return str_replace(
$search, $replace, $text);
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
548 $string = strtr($string, array(
566 return iconv(
"UTF-8",
"ASCII//TRANSLIT", $string);
580 $offset = $endoff + 1;
581 $endoff = strpos($ak,
"\n", $offset);
583 }
while (($idx >= 0) && ($endoff !==
false));
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);
598 return str_replace(array(
610 return str_replace(array(
637 $attr_list =
'on[a-z]+';
639 $remove_list = array();
640 foreach ($tag_list as $tag) {
641 $remove_list[] = array(
643 'start' => sprintf(
'#^<%s\b#i', $tag) ,
644 'end' => sprintf(
'#^</%s\b#i', $tag)
650 $tokens = preg_split(
"#(<[^>]*?>)#", $html, NULL, PREG_SPLIT_DELIM_CAPTURE);
653 foreach ($tokens as & $elmt) {
657 foreach ($remove_list as $tag) {
658 if (!$skip && preg_match($tag[
'start'], $elmt)) {
662 if (!preg_match(
':/>$:', $elmt)) {
663 $skip = $tag[
'name'];
666 } elseif ($skip == $tag[
'name'] && preg_match($tag[
'end'], $elmt)) {
671 } elseif (!$skip && preg_match($tag[
'end'], $elmt)) {
685 if (preg_match(
'#^<[^>]*?>$#s', $elmt)) {
686 $elmt = preg_replace(
"#\\s*\\b$attr_list\\b\\s*=\\s*(['\"])(.*?)(\\1)#is",
"", $elmt);
691 return join(
'', $tokens);
sep_replace($ak, $idx, $by="-", $sep="\n")
newFreeVaultFile($dbaccess)
unaccent_iso8859_1($string)
stringDateToIso($date, $format=false, $withT=false)
stringDateToLocaleDate($fdate, $format= '')
jd2cal($jd, $dformat= '')
iso8601DateToUnixTs($isodate, $utc=false)
getLocaleConfig($core_lang= '')
xml_entity_encode_all($s)
toIso8601($fdate, $wtz=false)
cal2jd($era, $y, $m, $d, $h, $mn, $s)
FrenchDateToLocaleDate($fdate, $format= '')
deprecatedFunction($msg= '')
stringDateToUnixTs($isodate, $utc=false)
FrenchDateToUnixTs($fdate, $utc=false)
FrenchDateToIso($fdate, $withT=true)